BUG 28287

This commit is contained in:
aixianling
2022-03-17 15:40:36 +08:00
parent a05bfbb480
commit bbe12fe39a
3 changed files with 44 additions and 40 deletions

View File

@@ -7,7 +7,7 @@
</div> </div>
<div class="area-select"> <div class="area-select">
<div class="select-content"> <div class="select-content">
<div class="area-content"> <div class="area-content fill">
<AiPagePicker type="gird" isMyGird @select="handleGridSelect"> <AiPagePicker type="gird" isMyGird @select="handleGridSelect">
<AiMore v-model="gridName" placeholder="选择网格"/> <AiMore v-model="gridName" placeholder="选择网格"/>
</AiPagePicker> </AiPagePicker>
@@ -290,7 +290,6 @@ export default {
box-sizing: border-box; box-sizing: border-box;
.area-content { .area-content {
width: calc(100% - 402px);
line-height: 64px; line-height: 64px;
img { img {

View File

@@ -295,7 +295,7 @@ export default {
colItem = { colItem = {
...item, ...item,
type: item.type, type: item.type,
fieldValue: this.user.areaId, fieldValue: "",
} }
} else { } else {
if (item.type == 'date') { if (item.type == 'date') {

View File

@@ -55,6 +55,10 @@ import AiMore from "./AiMore";
export default { export default {
name: 'AiAreaPicker', name: 'AiAreaPicker',
components: {AiMore, AiSearchPopup}, components: {AiMore, AiSearchPopup},
model: {
prop: "value",
event: "select"
},
props: { props: {
areaId: {default: ''}, areaId: {default: ''},
name: {default: ''}, name: {default: ''},
@@ -92,29 +96,25 @@ export default {
}, },
hasSelected() { hasSelected() {
return this.fullArea?.length > 0 return this.fullArea?.length > 0
} },
}, },
data() { data() {
return { return {
fullArea: [], fullArea: [],
index: '', index: '',
areaName: '',
list: [], list: [],
levelLabels: ["省", "市", "县/区", "镇/街道", "村/社区"], levelLabels: ["省", "市", "县/区", "镇/街道", "村/社区"],
selected: {}, selected: {},
height: '500px' height: '500px',
areaName: ""
} }
}, },
watch: { watch: {
areaId(v) { root(v) {
v && (this.getFullArea(v)) v && (this.getFullArea(v))
}, },
value(v) { value(v) {
if (v) { v && !this.areaName && this.getAreaName(this.value)
this.getFullArea(v).then(list => {
this.areaName = list?.reverse()?.[0]?.name
})
}
}, },
fullArea: { fullArea: {
handler(v) { handler(v) {
@@ -126,8 +126,8 @@ export default {
} }
} }
}, },
mounted() { created() {
this.handleInit() this.getAreaName(this.value)
}, },
methods: { methods: {
show() { show() {
@@ -137,22 +137,27 @@ export default {
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(areaId) { getInfo(areaId) {
return areaId && this.$http.post('/admin/area/getAllParentAreaId', null, { return areaId && this.$http.post('/admin/area/getAllParentAreaId', null, {
withoutToken: true, withoutToken: true,
params: {areaId}, params: {areaId},
}).then((res) => { }).then(res => {
if (res?.data) { if (res?.data) {
res.data.forEach((e) => { res.data.forEach((e) => {
e && (e.levelLabel = this.levelLabels[e.type]) e && (e.levelLabel = this.levelLabels[e.type])
}) })
if (res.data.length > 1) { return res.data.reverse()
this.fullArea = res.data.reverse().slice(this.dataRange) }
})
},
getFullArea(areaId) {
return this.fullArea?.length > 0 ? Promise.resolve(this.fullArea) : this.getInfo(areaId).then(meta => {
if (meta.length > 1) {
this.fullArea = meta.slice(this.dataRange)
} else { } else {
this.fullArea = res.data this.fullArea = meta
} }
return this.fullArea return this.fullArea
}
}) })
}, },
getChildAreas(id) { getChildAreas(id) {
@@ -179,17 +184,8 @@ export default {
}, },
handleSelect() { handleSelect() {
this.$emit('select', this.index) this.$emit('select', this.index)
let fullName = '' this.$emit('update:name', this.selected.name)
this.fullArea.forEach(v => { this.getAreaName(null, this.selected.name)
fullName = fullName + v.name
})
if (this.selected.type == 5) {
fullName = fullName + (this.selected.name || this.areaName)
}
this.areaName = this.selected.name || this.areaName
this.$emit('update:fullName', fullName)
this.$emit('update:name', (this.selected.name || this.areaName))
this.closePopup() this.closePopup()
}, },
getChild(op) { getChild(op) {
@@ -201,9 +197,7 @@ export default {
this.selected = op this.selected = op
this.index = op.id this.index = op.id
} }
this.$nextTick(() => { this.$nextTick(() => {
this.scrollHeight() this.scrollHeight()
}) })
}, },
@@ -221,17 +215,17 @@ export default {
} }
}, },
handleInit() { handleInit() {
//初始化
this.index = this.value || this.root this.index = this.value || this.root
if (!this.disabled) { if (!this.disabled) {
if (this.all) { if (this.value) {
this.getProvinces()
return false
} else if (this.value) {
this.getFullArea(this.value).then(() => { this.getFullArea(this.value).then(() => {
let area = this.fullArea?.[0] let area = this.fullArea.find(e => e.id == this.value) || {}
if (area.type == this.valueLevel) this.getChildAreas(area.parentId) if (area.type == this.valueLevel) this.getChildAreas(area.parentId)
else this.getChildAreas(area.id) else this.getChildAreas(area.id)
}) })
} else if (this.all) {
this.getProvinces()
} else { } else {
this.getFullArea(this.root).then(() => { this.getFullArea(this.root).then(() => {
this.getChildAreas(this.root) this.getChildAreas(this.root)
@@ -239,6 +233,17 @@ export default {
} }
} }
}, },
getAreaName(area, name) {
name ? this.areaName = name : this.getFullArea(area).then(list => {
let arr = JSON.parse(JSON.stringify(list))
this.areaName = arr?.reverse()?.[0]?.name
})
let fullName = this.fullArea.map(e => e.name).join("")
if (this.selected.type == 5) {
fullName = fullName + name
}
this.$emit('update:fullName', fullName)
},
closePopup() { closePopup() {
this.$refs.areaSelector?.handleSelect() this.$refs.areaSelector?.handleSelect()
} }