From 4af311d1dee17015e796feb0294e4c4ecc64fbd4 Mon Sep 17 00:00:00 2001 From: aixianling Date: Mon, 21 Mar 2022 19:44:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/AiAreaPicker/AiSearchPopup.vue | 92 ------------------- src/components/pages/selectArea.vue | 44 +++++---- 2 files changed, 24 insertions(+), 112 deletions(-) delete mode 100644 src/components/AiAreaPicker/AiSearchPopup.vue diff --git a/src/components/AiAreaPicker/AiSearchPopup.vue b/src/components/AiAreaPicker/AiSearchPopup.vue deleted file mode 100644 index 56d157b..0000000 --- a/src/components/AiAreaPicker/AiSearchPopup.vue +++ /dev/null @@ -1,92 +0,0 @@ - - - - - diff --git a/src/components/pages/selectArea.vue b/src/components/pages/selectArea.vue index 36c1487..c19f5a5 100644 --- a/src/components/pages/selectArea.vue +++ b/src/components/pages/selectArea.vue @@ -9,8 +9,8 @@

请选择

- - +
@@ -37,11 +37,11 @@ export default { computed: { ...mapState(['user']), dataRange() { - if (this.all || this.disabled) return 0 - return this.getAreaType(this.root) + console.log(this.urlParams.all, this.urlParams.disabled) + return this.urlParams.all || this.urlParams.disabled ? 0 : this.getAreaType(this.root) }, root() { - return this.areaId || this.user.areaId || this.$areaId + return this.urlParams.areaId || this.user.areaId || this.$areaId }, pending() { return this.list?.map(e => ({...e, levelLabel: this.levelLabels[e.type]})) || [] @@ -50,8 +50,11 @@ export default { return this.fullArea?.length > 0 }, hasLastLevelValue() { - return this.fullArea.some(e => e.type >= this.valueLevel) + return this.fullArea.some(e => e.type >= this.urlParams.valueLevel) }, + typeLabels() { + return this.fullArea.filter(e => e.type < this.urlParams.valueLevel) + } }, data() { return { @@ -99,7 +102,7 @@ export default { }).then((res) => { if (res?.data) { this.list = res.data - if (this.selectRoot) { + if (this.urlParams.selectRoot) { if (this.hasLastLevelValue) { let parent = JSON.parse(JSON.stringify(this.fullArea?.slice(-2)?.[0])) this.list.unshift(parent) @@ -127,13 +130,14 @@ export default { if (op.id != this.index) { this.selected = op this.index = op.id - if (op.type == this.valueLevel) { + let {length} = this.fullArea + if (op.type == this.urlParams.valueLevel) { if (this.hasLastLevelValue) { - this.fullArea.splice(this.fullArea.length - 1, 1, op) + this.fullArea.splice(length - 1, 1, op) } else this.fullArea.push(op) - } else if (op.type < this.valueLevel) { + } else if (op.type < this.urlParams.valueLevel) { if (this.hasLastLevelValue) { - this.fullArea.splice(this.fullArea.length - 1, 1) + this.fullArea.splice(length - 1, 1) } else { this.fullArea.push(op) this.getChildAreas(op.id) @@ -146,7 +150,7 @@ export default { if (deleteCount > 0) { this.fullArea.splice(i + 1, deleteCount) } - if (this.all && !area.id) { + if (this.urlParams.all && !area.id) { this.index = '' this.getProvinces() } else { @@ -156,18 +160,18 @@ export default { }, handleInit() { //初始化 - this.index = this.value || this.root - if (!this.disabled) { - if (this.value) { - this.getFullArea(this.value).then(() => { - let area = this.fullArea.find(e => e.id == this.value) || {} + this.index = this.urlParams.value || this.root + if (!this.urlParams.disabled) { + if (this.urlParams.value) { + this.getFullArea(this.urlParams.value).then(() => { + let area = this.fullArea.find(e => e.id == this.urlParams.value) || {} //当前选择列表必须是可选范围内的值 - let top = area.type == this.valueLevel ? area.parentId : area.id + let top = area.type == this.urlParams.valueLevel ? area.parentId : area.id if (this.getAreaType(top) >= this.dataRange) { this.getChildAreas(top) } }) - } else if (this.all) { + } else if (this.urlParams.all) { this.getProvinces() } else { this.getFullArea(this.root).then(() => { @@ -194,7 +198,7 @@ export default { }, onLoad(params) { Object.keys(params).map(k => { - this[k] = params[k] == "false" ? false : params[k] + this.$set(this.urlParams, k, params[k] == "false" ? false : params[k]) }) }, created() {