修改筛选属性功能完善
This commit is contained in:
parent
8d6021a7e2
commit
a0c8a118c5
@ -29,3 +29,9 @@ export function updateProductAttrCate(id,data) {
|
|||||||
data:data
|
data:data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
export function fetchListWithAttr() {
|
||||||
|
return request({
|
||||||
|
url:'/productAttribute/category/list/withAttr',
|
||||||
|
method:'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@ -60,7 +60,8 @@ export const constantRouterMap = [
|
|||||||
path: 'productComment',
|
path: 'productComment',
|
||||||
name: 'productComment',
|
name: 'productComment',
|
||||||
component: () => import('@/views/pms/product/index'),
|
component: () => import('@/views/pms/product/index'),
|
||||||
meta: {title: '商品评价', icon: 'product-comment'}
|
meta: {title: '商品评价', icon: 'product-comment'},
|
||||||
|
hidden:true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'productCate',
|
path: 'productCate',
|
||||||
|
@ -46,8 +46,7 @@
|
|||||||
<el-cascader
|
<el-cascader
|
||||||
clearable
|
clearable
|
||||||
v-model="filterProductAttr.value"
|
v-model="filterProductAttr.value"
|
||||||
:options="filterAttrs"
|
:options="filterAttrs">
|
||||||
@active-item-change="handleItemChange">
|
|
||||||
</el-cascader>
|
</el-cascader>
|
||||||
<el-button style="margin-left: 20px" @click.prevent="removeFilterAttr(filterProductAttr)">删除</el-button>
|
<el-button style="margin-left: 20px" @click.prevent="removeFilterAttr(filterProductAttr)">删除</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@ -70,8 +69,8 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {fetchList, createProductCate, updateProductCate, getProductCate} from '@/api/productCate';
|
import {fetchList, createProductCate, updateProductCate, getProductCate} from '@/api/productCate';
|
||||||
import {fetchList as fetchProductAttrCateList} from '@/api/productAttrCate';
|
import {fetchListWithAttr} from '@/api/productAttrCate';
|
||||||
import {fetchList as fetchProductAttrList,getProductAttrInfo} from '@/api/productAttr';
|
import {getProductAttrInfo} from '@/api/productAttr';
|
||||||
import SingleUpload from '@/components/Upload/singleUpload';
|
import SingleUpload from '@/components/Upload/singleUpload';
|
||||||
|
|
||||||
const defaultProductCate = {
|
const defaultProductCate = {
|
||||||
@ -116,6 +115,17 @@
|
|||||||
getProductCate(this.$route.query.id).then(response => {
|
getProductCate(this.$route.query.id).then(response => {
|
||||||
this.productCate = response.data;
|
this.productCate = response.data;
|
||||||
});
|
});
|
||||||
|
getProductAttrInfo(this.$route.query.id).then(response => {
|
||||||
|
if (response.data != null && response.data.length > 0) {
|
||||||
|
this.filterProductAttrList = [];
|
||||||
|
for (let i = 0; i < response.data.length; i++) {
|
||||||
|
this.filterProductAttrList.push({
|
||||||
|
key: Date.now() + i,
|
||||||
|
value: [response.data[i].attributeCategoryId, response.data[i].attributeId]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
this.productCate = Object.assign({}, defaultProductCate);
|
this.productCate = Object.assign({}, defaultProductCate);
|
||||||
}
|
}
|
||||||
@ -130,11 +140,20 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
getProductAttrCateList() {
|
getProductAttrCateList() {
|
||||||
fetchProductAttrCateList({pageSize: 100, pageNum: 1}).then(response => {
|
fetchListWithAttr().then(response => {
|
||||||
let productAttrCateList = response.data.list;
|
let list = response.data;
|
||||||
for (let i = 0; i < productAttrCateList.length; i++) {
|
for (let i = 0; i < list.length; i++) {
|
||||||
let productAttrCate = productAttrCateList[i];
|
let productAttrCate = list[i];
|
||||||
this.filterAttrs.push({label: productAttrCate.name, value: productAttrCate.id, children: []});
|
let children = [];
|
||||||
|
if (productAttrCate.productAttributeList != null && productAttrCate.productAttributeList.length > 0) {
|
||||||
|
for (let j = 0; j < productAttrCate.productAttributeList.length; j++) {
|
||||||
|
children.push({
|
||||||
|
label: productAttrCate.productAttributeList[j].name,
|
||||||
|
value: productAttrCate.productAttributeList[j].id
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.filterAttrs.push({label: productAttrCate.name, value: productAttrCate.id, children: children});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -158,6 +177,7 @@
|
|||||||
type: 'warning'
|
type: 'warning'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
if (this.isEdit) {
|
if (this.isEdit) {
|
||||||
|
this.productCate.productAttributeIdList = this.getProductAttributeIdList();
|
||||||
updateProductCate(this.$route.query.id, this.productCate).then(response => {
|
updateProductCate(this.$route.query.id, this.productCate).then(response => {
|
||||||
this.$message({
|
this.$message({
|
||||||
message: '修改成功',
|
message: '修改成功',
|
||||||
@ -198,21 +218,6 @@
|
|||||||
value: []
|
value: []
|
||||||
}];
|
}];
|
||||||
},
|
},
|
||||||
handleItemChange(val) {
|
|
||||||
let cateId = Number(val);
|
|
||||||
fetchProductAttrList(cateId, {pageSize: 100, pageNum: 1, type: 1}).then(response => {
|
|
||||||
let data = response.data.list;
|
|
||||||
let children = [];
|
|
||||||
for (let i = 0; i < data.length; i++) {
|
|
||||||
children.push({label: data[i].name, value: data[i].id});
|
|
||||||
}
|
|
||||||
for (let i = 0; i < this.filterAttrs.length; i++) {
|
|
||||||
if (cateId === this.filterAttrs[i].value) {
|
|
||||||
this.filterAttrs[i].children = children;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
removeFilterAttr(productAttributeId) {
|
removeFilterAttr(productAttributeId) {
|
||||||
if (this.filterProductAttrList.length === 1) {
|
if (this.filterProductAttrList.length === 1) {
|
||||||
this.$message({
|
this.$message({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user