@@ -290,7 +290,6 @@ export default {
box-sizing: border-box;
.area-content {
- width: calc(100% - 402px);
line-height: 64px;
img {
diff --git a/src/apps/AppSpecialPeople/add.vue b/src/apps/AppSpecialPeople/add.vue
index 0432309c..b0a3cf82 100644
--- a/src/apps/AppSpecialPeople/add.vue
+++ b/src/apps/AppSpecialPeople/add.vue
@@ -295,7 +295,7 @@ export default {
colItem = {
...item,
type: item.type,
- fieldValue: this.user.areaId,
+ fieldValue: "",
}
} else {
if (item.type == 'date') {
diff --git a/src/components/AiAreaPicker.vue b/src/components/AiAreaPicker.vue
index ceb52772..adfc5381 100644
--- a/src/components/AiAreaPicker.vue
+++ b/src/components/AiAreaPicker.vue
@@ -55,6 +55,10 @@ import AiMore from "./AiMore";
export default {
name: 'AiAreaPicker',
components: {AiMore, AiSearchPopup},
+ model: {
+ prop: "value",
+ event: "select"
+ },
props: {
areaId: {default: ''},
name: {default: ''},
@@ -92,29 +96,25 @@ export default {
},
hasSelected() {
return this.fullArea?.length > 0
- }
+ },
},
data() {
return {
fullArea: [],
index: '',
- areaName: '',
list: [],
levelLabels: ["省", "市", "县/区", "镇/街道", "村/社区"],
selected: {},
- height: '500px'
+ height: '500px',
+ areaName: ""
}
},
watch: {
- areaId(v) {
+ root(v) {
v && (this.getFullArea(v))
},
value(v) {
- if (v) {
- this.getFullArea(v).then(list => {
- this.areaName = list?.reverse()?.[0]?.name
- })
- }
+ v && !this.areaName && this.getAreaName(this.value)
},
fullArea: {
handler(v) {
@@ -126,8 +126,8 @@ export default {
}
}
},
- mounted() {
- this.handleInit()
+ created() {
+ this.getAreaName(this.value)
},
methods: {
show() {
@@ -137,24 +137,29 @@ export default {
scrollHeight() {
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, {
withoutToken: true,
params: {areaId},
- }).then((res) => {
+ }).then(res => {
if (res?.data) {
res.data.forEach((e) => {
e && (e.levelLabel = this.levelLabels[e.type])
})
- if (res.data.length > 1) {
- this.fullArea = res.data.reverse().slice(this.dataRange)
- } else {
- this.fullArea = res.data
- }
- return this.fullArea
+ return res.data.reverse()
}
})
},
+ 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 {
+ this.fullArea = meta
+ }
+ return this.fullArea
+ })
+ },
getChildAreas(id) {
id && this.$http.post('/admin/area/queryAreaByParentId', null, {
withoutToken: true,
@@ -179,17 +184,8 @@ export default {
},
handleSelect() {
this.$emit('select', this.index)
- let fullName = ''
- this.fullArea.forEach(v => {
- 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.$emit('update:name', this.selected.name)
+ this.getAreaName(null, this.selected.name)
this.closePopup()
},
getChild(op) {
@@ -201,9 +197,7 @@ export default {
this.selected = op
this.index = op.id
}
-
this.$nextTick(() => {
-
this.scrollHeight()
})
},
@@ -221,17 +215,17 @@ export default {
}
},
handleInit() {
+ //初始化
this.index = this.value || this.root
if (!this.disabled) {
- if (this.all) {
- this.getProvinces()
- return false
- } else if (this.value) {
+ if (this.value) {
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)
else this.getChildAreas(area.id)
})
+ } else if (this.all) {
+ this.getProvinces()
} else {
this.getFullArea(this.root).then(() => {
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() {
this.$refs.areaSelector?.handleSelect()
}