From 289035bd3c98ed9c4666f2cb9b4037548b1a2d78 Mon Sep 17 00:00:00 2001 From: yuanjunzhe <1374457292@qq.com> Date: Sat, 23 Mar 2024 09:01:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/CheckAttribute/index.vue | 17 ++-- src/components/CheckAttributeGroup/index.vue | 42 +++++----- src/components/CheckBrand/index.vue | 54 ++++++------ src/main.js | 10 +++ src/views/product/brand/index.vue | 20 ++--- src/views/product/category/index.vue | 3 +- src/views/product/info/index.vue | 86 +++++++++++++++++--- 7 files changed, 152 insertions(+), 80 deletions(-) diff --git a/src/components/CheckAttribute/index.vue b/src/components/CheckAttribute/index.vue index c798636..01b05aa 100644 --- a/src/components/CheckAttribute/index.vue +++ b/src/components/CheckAttribute/index.vue @@ -69,7 +69,7 @@ export default { props: { value: { type: Array, - default: () => [] + default: [] }, checkedList: { type: Array, @@ -80,16 +80,16 @@ export default { value: { handler(val) { if (val.toString() !== this.attributeIdList.toString()){ - this.attributeIdList = val + this.attributeIdList = val; this.checkedAttributeList = [] } }, - immediate: true + immediate: true, }, checkedList: { - handler(val) { - if (val !== undefined && val.length >0){ - this.checkedAttributeList = val + handler(val){ + if (val !== undefined && val.length > 0){ + this.checkedAttributeList = val; this.attributeIdList = this.checkedAttributeList.map(checked => checked.id); } }, @@ -104,10 +104,11 @@ export default { pageNum: 1, pageSize: 10, code: null, - name: null + name: null, }, attributeTotal: 0, - attributeList: [] + attributeList: [], + total:0 } }, created() { diff --git a/src/components/CheckAttributeGroup/index.vue b/src/components/CheckAttributeGroup/index.vue index 628d622..d857d81 100644 --- a/src/components/CheckAttributeGroup/index.vue +++ b/src/components/CheckAttributeGroup/index.vue @@ -66,33 +66,13 @@ export default { props: { value: { type: Array, - default: () => [] + default: [] }, checkedList: { type: Array, default: null } }, - watch: { - value: { - handler(val) { - if (val.toString() !== this.attributeGroupIdList.toString()){ - this.attributeGroupIdList = val - this.checkedAttributeGroupList = [] - } - }, - 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() { return { attributeGroupIdList: [], @@ -106,6 +86,26 @@ export default { attributeGroupList: [] } }, + watch: { + value: { + handler(val) { + if (val.toString() !== this.attributeGroupIdList.toString()){ + this.attributeGroupIdList = val; + this.checkedAttributeGroupList = [] + } + }, + immediate: true, + }, + checkedList: { + handler(val){ + if (val !== undefined && val.length > 0){ + this.checkedAttributeGroupList = val; + this.attributeGroupIdList = this.checkedAttributeGroupList.map(checked => checked.id); + } + }, + immediate: true + } + }, created() { this.queryAttributeGroup(); }, diff --git a/src/components/CheckBrand/index.vue b/src/components/CheckBrand/index.vue index 3826612..2f03d13 100644 --- a/src/components/CheckBrand/index.vue +++ b/src/components/CheckBrand/index.vue @@ -12,9 +12,9 @@ - {{ brand.nam }} + {{ brand.name }} @@ -27,7 +27,7 @@ - + 查询 @@ -42,7 +42,7 @@ :value="brand.id" :label="brand.id" @change="checkedBrand(brand)" - border>{{ brand.nam }} + border>{{ brand.name }} @@ -62,37 +62,17 @@ import {listBrand} from "@/api/product/brand"; export default { - name: "CheckBrand", + namee: "CheckBrand", props: { value: { type: Array, - default: () => [] + default: [] }, checkedList: { type: Array, default: null } }, - watch: { - vlue: { - handler(val) { - if (val.toString() !== this.brandIdList.toString()){ - this.brandIdList = val - this.checkedBrandList = [] - } - }, - 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() { return { brandIdList: [], @@ -100,12 +80,32 @@ export default { brandQuery: { pageNum: 1, pageSize: 10, - name: null + namee: null }, brandTotal: 0, brandList: [] } }, + watch: { + value: { + handler(val) { + if (val.toString() !== this.brandIdList.toString()){ + this.brandIdList = val; + this.checkedBrandList = [] + } + }, + immediate: true, + }, + checkedList: { + handler(val){ + if (val !== undefined && val.length > 0){ + this.checkedBrandList = val; + this.brandIdList = this.checkedBrandList.map(checked => checked.id); + } + }, + immediate: true + } + }, created() { this.queryBrand(); }, diff --git a/src/main.js b/src/main.js index 546f125..3226e88 100644 --- a/src/main.js +++ b/src/main.js @@ -37,6 +37,12 @@ import DictTag from '@/components/DictTag' import VueMeta from 'vue-meta' // 字典数据组件 import DictData from '@/components/DictData' +// 属性选择 +import CheckAttribute from "@/components/CheckAttribute/index.vue"; +// 属性组选择 +import CheckAttributeGroup from "@/components/CheckAttributeGroup/index.vue"; +// 品牌选择 +import CheckBrand from "@/components/CheckBrand/index.vue"; // 全局方法挂载 Vue.prototype.getDicts = getDicts @@ -57,6 +63,10 @@ Vue.component('Editor', Editor) Vue.component('FileUpload', FileUpload) Vue.component('ImageUpload', ImageUpload) Vue.component('ImagePreview', ImagePreview) +Vue.component('CheckAttribute', CheckAttribute) +Vue.component('CheckAttributeGroup', CheckAttributeGroup) +Vue.component('CheckBrand', CheckBrand) + Vue.use(directive) Vue.use(plugins) diff --git a/src/views/product/brand/index.vue b/src/views/product/brand/index.vue index 3bc6ffe..cb01534 100644 --- a/src/views/product/brand/index.vue +++ b/src/views/product/brand/index.vue @@ -1,9 +1,9 @@