优化界面和组件

This commit is contained in:
aixianling
2022-02-21 11:08:11 +08:00
parent 1bc309e60b
commit f841f2e462

View File

@@ -4,11 +4,11 @@
<div slot="btn" @tap="handleInit">
<slot v-if="$slots.default"/>
<div v-else-if="isForm">
<u-icon name="arrow-right" :label="currentArea.name||'请选择'" label-pos="left" color="#ddd"/>
<u-icon name="arrow-right" :label="areaName||'请选择'" label-pos="left" color="#ddd"/>
</div>
<div v-else class="areaSelector">
<image :src="locationIcon" class="location"/>
<div v-text="currentArea.name"/>
<div v-text="areaName"/>
</div>
</div>
<div class="areaSelector" id="areaSelector">
@@ -89,6 +89,7 @@ export default {
return {
fullArea: [],
index: '',
areaName: '',
list: [],
height: '500px',
levelLabels: ["省", "市", "县/区", "镇/街道", "村/社区"],
@@ -99,6 +100,11 @@ export default {
areaId(v) {
v && this.getFullArea()
},
value(v) {
if (this.list.length && v) {
this.areaName = this.list.find((e) => e.id == this.value).name
}
},
fullArea: {
handler(v) {
this.$nextTick(() => {
@@ -150,17 +156,18 @@ export default {
if (res.data.length) {
this.list = res.data
let self = this.fullArea.find((e) => e.id == this.areaId)
if (this.value && !this.areaName && this.value !== this.areaId) {
this.areaName = this.list.find((e) => e.id == this.value).name
}
if (!this.areaName && this.value === this.areaId) {
this.areaName = self.name
}
if (!!self?.id && !this.isHideTown) {
this.list.unshift(self)
}
}
})
},
isVillage(areaId) {
return areaId.substr(areaId.length - 3, 3) != '000'
},
getProvinces() {
this.$instance.post('/admin/area/queryProvinceList', null, {withoutToken: true}).then((res) => {
if (res?.data) {
@@ -178,6 +185,7 @@ export default {
if (this.selected.type == 5) {
fullName = fullName + this.selected.name
}
this.areaName = this.selected.name || this.areaName
this.$emit('update:fullName', fullName)
this.$emit('update:name', this.selected.name)
this.closePopup()