BUG 28186

This commit is contained in:
aixianling
2022-03-14 20:35:00 +08:00
parent 6be9eda1e1
commit c7e3d118c0

View File

@@ -3,6 +3,9 @@
<ai-search-popup mode="bottom" ref="areaSelector" length="85%"> <ai-search-popup mode="bottom" ref="areaSelector" length="85%">
<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">
<u-icon name="arrow-right" :label="areaName||'请选择'" label-pos="left" color="#ddd"/>
</div>
<div v-else class="areaSelector"> <div v-else class="areaSelector">
<image :src="locationIcon" class="location"/> <image :src="locationIcon" class="location"/>
<div v-text="areaName"/> <div v-text="areaName"/>
@@ -57,7 +60,10 @@ export default {
name: {default: ''}, name: {default: ''},
value: String, value: String,
all: Boolean, all: Boolean,
icon: {default: "location.svg"} icon: {default: "location.svg"},
isForm: Boolean,
valueLevel: {default: 5},
fullName: {default: ''}
}, },
computed: { computed: {
...mapState(['user']), ...mapState(['user']),
@@ -102,9 +108,9 @@ export default {
v && (this.getFullArea()) v && (this.getFullArea())
}, },
value (v) { value(v) {
if (this.list.length && v) { if (this.list.length && v) {
this.areaName = this.list.find((e) => e.id == this.value).name this.areaName = this.list.find((e) => e.id == this.value).name
} }
}, },
@@ -118,7 +124,7 @@ export default {
} }
} }
}, },
mounted () { mounted() {
this.handleInit() this.handleInit()
}, },
methods: { methods: {
@@ -126,7 +132,7 @@ export default {
this.handleInit() this.handleInit()
this.$refs.areaSelector.showPopup() this.$refs.areaSelector.showPopup()
}, },
scrollHeight () { scrollHeight() {
this.height = document.querySelector('.areaSelector') && `calc(100% - ${document.querySelector('.areaSelector').offsetHeight}px)` this.height = document.querySelector('.areaSelector') && `calc(100% - ${document.querySelector('.areaSelector').offsetHeight}px)`
}, },
getFullArea() { getFullArea() {
@@ -156,10 +162,10 @@ export default {
}).then((res) => { }).then((res) => {
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) { if (this.value && !this.areaName && this.value !== this.areaId) {
this.areaName = this.list.find((e) => e.id == this.value).name this.areaName = this.list.find((e) => e.id == this.value).name
} }
if (!this.areaName && this.value === this.areaId) { if (!this.areaName && this.value === this.areaId) {
this.areaName = self.name this.areaName = self.name
@@ -204,7 +210,7 @@ export default {
}, },
getChild(op) { getChild(op) {
if (op.id != this.index) { if (op.id != this.index) {
if (op.type < 5 && (/0{3}$/g.test(this.index) || !this.index)) { if (op.type <= this.valueLevel && op.type < 5 && (/0{3}$/g.test(this.index) || !this.index)) {
this.fullArea.push(op) this.fullArea.push(op)
this.getChildAreas(op.id) this.getChildAreas(op.id)
} }
@@ -213,7 +219,7 @@ export default {
} }
this.$nextTick(() => { this.$nextTick(() => {
this.scrollHeight() this.scrollHeight()
}) })
}, },