From 133ecc6c448f50875d675bf6494f2136bc98b706 Mon Sep 17 00:00:00 2001 From: wangfukang <15630117759@163.com> Date: Tue, 25 Aug 2026 10:37:04 +0800 Subject: [PATCH] 1 --- src/views/app/shop/addEdit.vue | 14 +++++- .../hiver/shopArea-tree-choose.vue | 44 +++++++++++++++++-- 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/src/views/app/shop/addEdit.vue b/src/views/app/shop/addEdit.vue index eaf7e14..34fec71 100644 --- a/src/views/app/shop/addEdit.vue +++ b/src/views/app/shop/addEdit.vue @@ -20,8 +20,8 @@ - - + @@ -289,11 +289,13 @@ }, }, data() { + const userInfo = JSON.parse(this.getStore("userInfo") || "{}"); return { roleList: [], roleList2: [], shopAreaList: [], businessDistrictLevelList: [], + userDepartmentId: userInfo.departmentId || "", visible: this.value, title: "", passColor: "", @@ -368,6 +370,11 @@ }, trigger: "change" }], + shopArea: [{ + required: true, + message: "请选择所属区域", + trigger: "change" + }], shopDeliveryLocation: [{ validator: (rule, value, callback) => { if (this.form.supportShopDelivery == 1 && !value) { @@ -422,6 +429,9 @@ }; }, computed: { + shopAreaRootId() { + return this.form.regionId || this.userDepartmentId || ""; + }, boundWorkerText() { if (!this.form.workerId) return ""; return `${this.form.workerName || ""} ${this.form.workerPhone || ""}`; diff --git a/src/views/my-components/hiver/shopArea-tree-choose.vue b/src/views/my-components/hiver/shopArea-tree-choose.vue index 72549df..4360012 100644 --- a/src/views/my-components/hiver/shopArea-tree-choose.vue +++ b/src/views/my-components/hiver/shopArea-tree-choose.vue @@ -105,6 +105,7 @@ } }); this.dataDep = res.result; + this.syncSelectedTitle(); } }); }, @@ -183,14 +184,49 @@ this.$emit("on-clear"); }, setData(ids, title) { - this.shopAreaTitle = title; if (this.multiple) { - this.shopArea = ids; + this.shopArea = Array.isArray(ids) ? ids : (ids ? [ids] : []); } else { this.shopArea = []; - this.shopArea.push(ids); + if (ids) { + this.shopArea.push(ids); + } + } + this.shopAreaTitle = title || ""; + this.syncSelectedTitle(); + this.emitChange(); + }, + emitChange() { + if (this.multiple) { + this.$emit("on-change", this.shopArea); + } else { + this.$emit("on-change", this.shopArea[0] || ""); } - this.$emit("on-change", this.shopArea); + }, + syncSelectedTitle() { + if (this.shopAreaTitle || !this.shopArea.length || !this.dataDep.length) { + return; + } + const selectedIds = this.shopArea.map(item => String(item)); + const titles = []; + const findTitles = (list) => { + list.forEach((item) => { + if (selectedIds.includes(String(item.id))) { + titles.push(item.title); + } + if (item.children && item.children.length) { + findTitles(item.children); + } + }); + }; + findTitles(this.dataDep); + this.shopAreaTitle = titles.join("、"); + }, + }, + watch: { + rootId() { + this.searchKey = ""; + this.initShopAreaData(); }, }, mounted() {