From fd530d9933d23af5911db28b6bda2dc89ba780a3 Mon Sep 17 00:00:00 2001 From: yaoxin <1752800946@qq.com> Date: Tue, 5 Mar 2024 21:06:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E8=A7=84=E6=A0=BC=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/product/category.js | 7 ++ src/components/CheckAttribute/index.vue | 15 ++- src/components/CheckAttributeGroup/index.vue | 15 ++- src/components/CheckBrand/index.vue | 15 ++- src/views/product/attributeGroup/index.vue | 11 +- src/views/product/category/index.vue | 30 ++++- src/views/product/rule/index.vue | 118 ++++++++++++++++++- 7 files changed, 193 insertions(+), 18 deletions(-) diff --git a/src/api/product/category.js b/src/api/product/category.js index a8ab19f..e1fd1e6 100644 --- a/src/api/product/category.js +++ b/src/api/product/category.js @@ -17,6 +17,13 @@ export function getCategory(id) { }) } +export function parentCommonElement(id) { + return request({ + url: '/product/category/parentCommonElement/' + id, + method: 'get' + }) +} + // 新增品类信息 export function addCategory(data) { return request({ diff --git a/src/components/CheckAttribute/index.vue b/src/components/CheckAttribute/index.vue index 81fb799..c798636 100644 --- a/src/components/CheckAttribute/index.vue +++ b/src/components/CheckAttribute/index.vue @@ -69,7 +69,11 @@ export default { props: { value: { type: Array, - default: [] + default: () => [] + }, + checkedList: { + type: Array, + default: null } }, watch: { @@ -81,6 +85,15 @@ export default { } }, immediate: true + }, + checkedList: { + handler(val) { + if (val !== undefined && val.length >0){ + this.checkedAttributeList = val + this.attributeIdList = this.checkedAttributeList.map(checked => checked.id); + } + }, + immediate: true } }, data() { diff --git a/src/components/CheckAttributeGroup/index.vue b/src/components/CheckAttributeGroup/index.vue index a047454..628d622 100644 --- a/src/components/CheckAttributeGroup/index.vue +++ b/src/components/CheckAttributeGroup/index.vue @@ -66,7 +66,11 @@ export default { props: { value: { type: Array, - default: [] + default: () => [] + }, + checkedList: { + type: Array, + default: null } }, watch: { @@ -78,6 +82,15 @@ export default { } }, immediate: true + }, + checkedList: { + handler(val) { + if (val !== null && val.length >0){ + this.checkedAttributeGroupList = val + this.attributeGroupIdList = this.checkedAttributeGroupList.map(checked => checked.id); + } + }, + immediate: true } }, data() { diff --git a/src/components/CheckBrand/index.vue b/src/components/CheckBrand/index.vue index 6692cfe..3826612 100644 --- a/src/components/CheckBrand/index.vue +++ b/src/components/CheckBrand/index.vue @@ -66,7 +66,11 @@ export default { props: { value: { type: Array, - default: [] + default: () => [] + }, + checkedList: { + type: Array, + default: null } }, watch: { @@ -78,6 +82,15 @@ export default { } }, immediate: true + }, + checkedList: { + handler(val){ + if (val !== null && val.length > 0){ + this.checkedBrandList = val + this.brandIdList = this.checkedBrandList.map(checked => checked.id); + } + }, + immediate: true } }, data() { diff --git a/src/views/product/attributeGroup/index.vue b/src/views/product/attributeGroup/index.vue index 1d69250..f46eca7 100644 --- a/src/views/product/attributeGroup/index.vue +++ b/src/views/product/attributeGroup/index.vue @@ -294,11 +294,14 @@ export default { this.checkedAttributeList.push(attribute); }else { // 删除 - console.log(this.checkedAttributeList) - console.log(attribute) - console.log(this.checkedAttributeList.indexOf(attribute)) + let att =undefined + this.checkedAttributeList.forEach(checked => { + if (checked.id == attribute.id){ + att = checked + } + }) this.checkedAttributeList.splice( - this.checkedAttributeList.indexOf(attribute), 1 + this.checkedAttributeList.indexOf(att), 1 ) } }, diff --git a/src/views/product/category/index.vue b/src/views/product/category/index.vue index 59992ed..0995973 100644 --- a/src/views/product/category/index.vue +++ b/src/views/product/category/index.vue @@ -151,13 +151,13 @@ - + - + - + @@ -171,7 +171,7 @@