优化界面和组件
This commit is contained in:
@@ -4,11 +4,11 @@
|
|||||||
<div slot="btn" @tap="handleInit">
|
<div slot="btn" @tap="handleInit">
|
||||||
<slot v-if="$slots.default"/>
|
<slot v-if="$slots.default"/>
|
||||||
<div v-else-if="isForm">
|
<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>
|
||||||
<div v-else class="areaSelector">
|
<div v-else class="areaSelector">
|
||||||
<image :src="locationIcon" class="location"/>
|
<image :src="locationIcon" class="location"/>
|
||||||
<div v-text="currentArea.name"/>
|
<div v-text="areaName"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="areaSelector" id="areaSelector">
|
<div class="areaSelector" id="areaSelector">
|
||||||
@@ -89,6 +89,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
fullArea: [],
|
fullArea: [],
|
||||||
index: '',
|
index: '',
|
||||||
|
areaName: '',
|
||||||
list: [],
|
list: [],
|
||||||
height: '500px',
|
height: '500px',
|
||||||
levelLabels: ["省", "市", "县/区", "镇/街道", "村/社区"],
|
levelLabels: ["省", "市", "县/区", "镇/街道", "村/社区"],
|
||||||
@@ -99,6 +100,11 @@ export default {
|
|||||||
areaId(v) {
|
areaId(v) {
|
||||||
v && this.getFullArea()
|
v && this.getFullArea()
|
||||||
},
|
},
|
||||||
|
value(v) {
|
||||||
|
if (this.list.length && v) {
|
||||||
|
this.areaName = this.list.find((e) => e.id == this.value).name
|
||||||
|
}
|
||||||
|
},
|
||||||
fullArea: {
|
fullArea: {
|
||||||
handler(v) {
|
handler(v) {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
@@ -150,17 +156,18 @@ export default {
|
|||||||
if (res.data.length) {
|
if (res.data.length) {
|
||||||
this.list = res.data
|
this.list = res.data
|
||||||
let self = this.fullArea.find((e) => e.id == this.areaId)
|
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) {
|
if (!!self?.id && !this.isHideTown) {
|
||||||
this.list.unshift(self)
|
this.list.unshift(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
isVillage(areaId) {
|
|
||||||
return areaId.substr(areaId.length - 3, 3) != '000'
|
|
||||||
},
|
|
||||||
|
|
||||||
getProvinces() {
|
getProvinces() {
|
||||||
this.$instance.post('/admin/area/queryProvinceList', null, {withoutToken: true}).then((res) => {
|
this.$instance.post('/admin/area/queryProvinceList', null, {withoutToken: true}).then((res) => {
|
||||||
if (res?.data) {
|
if (res?.data) {
|
||||||
@@ -178,6 +185,7 @@ export default {
|
|||||||
if (this.selected.type == 5) {
|
if (this.selected.type == 5) {
|
||||||
fullName = fullName + this.selected.name
|
fullName = fullName + this.selected.name
|
||||||
}
|
}
|
||||||
|
this.areaName = this.selected.name || this.areaName
|
||||||
this.$emit('update:fullName', fullName)
|
this.$emit('update:fullName', fullName)
|
||||||
this.$emit('update:name', this.selected.name)
|
this.$emit('update:name', this.selected.name)
|
||||||
this.closePopup()
|
this.closePopup()
|
||||||
|
|||||||
Reference in New Issue
Block a user