修复地区选择器回显问题
This commit is contained in:
@@ -79,7 +79,7 @@ export default {
|
||||
value: {
|
||||
immediate: true,
|
||||
handler(v) {
|
||||
v && !this.areaName && this.getAreaName(this.value)
|
||||
v && this.getAreaName(this.value)
|
||||
}
|
||||
},
|
||||
fullArea(v) {
|
||||
@@ -104,17 +104,18 @@ export default {
|
||||
})
|
||||
},
|
||||
getInfo(areaId) {
|
||||
return areaId && this.$http.post('/admin/area/getAllParentAreaId', null, {
|
||||
return areaId ? this.$http.post('/admin/area/getAllParentAreaId', null, {
|
||||
withoutToken: true,
|
||||
params: {areaId},
|
||||
}).then(res => {
|
||||
if (res?.data) {
|
||||
return res.data.reverse()
|
||||
}
|
||||
})
|
||||
}) : Promise.reject()
|
||||
},
|
||||
getFullArea(areaId) {
|
||||
return this.fullArea?.length > 0 ? Promise.resolve(this.fullArea) : this.getInfo(areaId).then(meta => {
|
||||
const current = this.fullArea.slice(-1)?.[0]?.id
|
||||
return current && current == areaId ? Promise.resolve(this.fullArea) : this.getInfo(areaId).then(meta => {
|
||||
if (meta.length > 1) {
|
||||
this.fullArea = meta.slice(this.dataRange)
|
||||
} else {
|
||||
@@ -148,13 +149,15 @@ export default {
|
||||
uni.navigateTo({url})
|
||||
}
|
||||
},
|
||||
getAreaName(area, name) {
|
||||
name ? this.areaName = name :
|
||||
this.multiple ? this.areaName = !![area].toString() ? `已选择${[area].flat().length}个` : '' :
|
||||
this.getFullArea(area).then(list => {
|
||||
let arr = JSON.parse(JSON.stringify(list))
|
||||
this.areaName = arr?.reverse()?.[0]?.name || ""
|
||||
})
|
||||
getAreaName(area) {
|
||||
if (this.multiple) {
|
||||
this.areaName = `已选择${[area].flat().filter(Boolean)?.length}个`.replace('已选择0个', '')
|
||||
} else {
|
||||
this.getFullArea(area).then(list => {
|
||||
let arr = JSON.parse(JSON.stringify(list))
|
||||
this.areaName = arr?.reverse()?.[0]?.name || ""
|
||||
}).catch(() => this.areaName = '')
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user