From 35ea8adf7daa9b3c16cae76b4f86f2acd21b4d9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?lemon=E6=A9=AA?= <17633066053@163.com> Date: Fri, 2 Jul 2021 09:37:46 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E9=85=8D=E9=80=81=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=E9=80=89=E6=8B=A9=E4=B8=8D=E5=9B=9E=E6=98=BEbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/lili-components/multiple-region.vue | 55 ++++++++++++++++--- seller/src/views/shop/ship/shipTemplate.vue | 1 + 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/seller/src/views/lili-components/multiple-region.vue b/seller/src/views/lili-components/multiple-region.vue index fe01cabf..bb9c8bf4 100644 --- a/seller/src/views/lili-components/multiple-region.vue +++ b/seller/src/views/lili-components/multiple-region.vue @@ -22,6 +22,11 @@ export default { this.init(); }, methods: { + clear() { + this.data = []; + this.selectedWay = []; + this.init(); + }, /** * 关闭 */ @@ -50,30 +55,66 @@ export default { // console.warn(this.$store.state.shipTemplate); // 禁止选中的地址 + + let checkData = []; let disabledData = checkedData.filter((item, i) => { - return i != index; + if (i != index) { + return i != index; + } else { + checkData.push(item); + } }); + // 选中 + checkData.forEach((check) => { + // 循环出已经选中的地址id + check.areaId.split(",").forEach((ids) => { + this.data.forEach((item) => { + // 如果当前省份下市区全部选中则选中该省份 + if (check.selectedAll) { + check.area.split(",").forEach((area) => { + if (area == item.name) { + this.$set(item, "checked", true); + } + }); + } + + // 将市区继续循环 + item.children.forEach((child, childIndex) => { + // 判断当前市区是否是已选中状态 + if (item.checked) { + this.$set(child, "checked", true); + } + if (child.id == ids) { + this.$set(child, "checked", true); + } + }); + }); + }); + }); + + // 禁用 disabledData.forEach((dis) => { - console.log(dis) // 循环出已经选中的地址id dis.areaId.split(",").forEach((ids) => { // 循环出省份 this.data.forEach((item) => { - // 如果当前省份下市区全部选中则选中该省份 - + // 如果当前省份下市区全部选中则禁用该省份 if (dis.selectedAll) { dis.area.split(",").forEach((area) => { if (area == item.name) { - console.log(item.name +"选中") this.$set(item, "disabled", true); } }); } // 将市区继续循环 item.children.forEach((child, childIndex) => { - // 判断当前市区是否是已选中状态 - if (child.id == ids) { + // 判断当前市区是否是已禁用状态 + if (item.disabled) { this.$set(child, "disabled", true); + } else { + if (child.id == ids) { + this.$set(child, "disabled", true); + } } }); }); diff --git a/seller/src/views/shop/ship/shipTemplate.vue b/seller/src/views/shop/ship/shipTemplate.vue index fc7f227b..83b0261c 100644 --- a/seller/src/views/shop/ship/shipTemplate.vue +++ b/seller/src/views/shop/ship/shipTemplate.vue @@ -213,6 +213,7 @@ export default { }, //添加运费模板 add() { + this.$refs.region.clear() this.title = "添加运费模板"; this.csTab = true; this.operation = "ADD";