This commit is contained in:
aixianling
2023-03-24 15:24:18 +08:00
parent da27eaee98
commit 0dda0201ba
3 changed files with 33 additions and 32 deletions

View File

@@ -26,7 +26,7 @@
</el-form>
</ai-dialog>
<ai-locate-dialog v-model="locate" :ins="instance" :latlng="latlng" @confirm="v=>handleLocate(selected,v)"/>
<ai-area custom-clicker :input-clicker="false" v-model="selected.areaId" :hideLevel="hideLevel" :instance="instance" ref="BindArea"
<ai-area custom-clicker :inputClicker="false" v-model="selected.areaId" :root="user.info.areaId" :instance="instance" ref="BindArea"
@change="handleSubmit(selected)"/>
</section>
</template>
@@ -57,7 +57,6 @@ export default {
return {width: per, height: per}
},
...mapState(['user']),
hideLevel: v => v.user.info.areaList?.length
},
data() {
@@ -202,7 +201,7 @@ export default {
display: flex;
flex-direction: column;
:deep( .headerBar ){
:deep( .headerBar ) {
display: flex;
align-items: center;
justify-content: flex-end;
@@ -255,13 +254,13 @@ export default {
}
}
:deep(.el-tree-node__content:hover ){
:deep(.el-tree-node__content:hover ) {
.menuBtn {
display: block;
}
}
:deep( .flexRow ){
:deep( .flexRow ) {
flex: 1;
min-width: 0;
display: flex;

View File

@@ -5,11 +5,9 @@
<div class="ailist-title">
<div class="ailist-title__left">
<h2>{{ title }}</h2>
<div v-if="isShowIM" class="openIM iconfont iconGroup_IM" @click="openIM"></div>
</div>
<div class="ailist-title__right">
<ai-area
v-if="isShowArea"
<ai-area v-if="isShowArea"
:instance="instance"
v-bind="$attrs"
:value="value"
@@ -19,7 +17,7 @@
:valueLevel="valueLevel"
:disabled="disabled"/>
<div class="aititle-right__btns">
<slot name="rightBtn"></slot>
<slot name="rightBtn"/>
</div>
</div>
</div>
@@ -65,9 +63,6 @@ export default {
type: Boolean,
default: false
},
openIM: {
type: Function
},
isShowBack: {
type: Boolean,
default: false
@@ -122,10 +117,6 @@ export default {
font-size: 16px;
font-weight: 600;
}
.openIM {
margin-left: 8px;
}
}
.ailist-title__right {

View File

@@ -64,7 +64,8 @@ export default {
separator: {type: String, default: ""},
showBadge: {type: Boolean, default: true},
value: String,
valueLevel: {type: [Number, String], default: -1}
valueLevel: {type: [Number, String], default: -1},
root: String
},
data() {
return {
@@ -76,13 +77,14 @@ export default {
}
},
computed: {
rootArea: v => new Area(v.root),
currentArea: v => v.selected || v.value,
selectedArea: v => new Area(v.currentArea, v.hashMap),
startLevel: v => Number(v.hideLevel) || 0,//地区最高可选行政地区等级
startLevel: v => Math.max(Number(v.hideLevel), 0, v.rootArea.level),//地区最高可选行政地区等级
endLevel: v => Number(v.areaLevel) || 0,//地区最低可选行政地区等级
selectedArea: v => new Area(v.currentArea, v.hashMap),
selectedName: v => v.selectedArea.name || "无",
validateState: v => ['', 'success'].includes(v.elFormItem?.validateState),
selectedMap: v => v.selectedArea.areaMap,
validateState: v => ['', 'success'].includes(v.elFormItem?.validateState),
hashMap() {
//地区数据缓存器,用于快速获取数据
const hash = {}
@@ -98,10 +100,18 @@ export default {
4: "村/社区"
}
let ops = this.areaOps.map((list, i) => ({
header: levelLabels[i], list
header: levelLabels[i], i, list
})).slice(Math.max(0, this.startLevel), this.endLevel)
if (this.startLevel > 0 && ops.length > 0) {
ops[0].list = ops[0].list.filter(e => e.id == this.selectedMap[this.startLevel])
const tmp = this.$copy(ops[0]?.list?.[0] || {})
if (this.startLevel >= ops[0].i) {
const opsMap = this.selectedMap.length > 0 ? this.selectedMap : this.rootArea.areaMap
ops[0].list = [this.hashMap[opsMap[ops[0].i]]].filter(Boolean) || []
} else {
const prev = +tmp.type - 1
const prevId = tmp.parentId
prev > -1 && ops.unshift({header: levelLabels[prev], list: [this.hashMap[prevId]]})
}
}
return ops
}
@@ -113,7 +123,7 @@ export default {
this.dispatch('ElFormItem', 'el.form.change', [v]);
this.initAreaName()
}
},
}
},
methods: {
dispatch(componentName, eventName, params) {
@@ -206,8 +216,9 @@ export default {
},
initOptions() {
this.areaOps = []
const opsMap = this.selectedMap.length > 0 ? this.selectedMap : this.rootArea.areaMap
let map = {};
return Promise.all([null, ...this.selectedMap].map((id, i) => this.getAreasByParentId(id).then(list => map[i] = list))).then(() => {
return Promise.all([null, ...opsMap].map((id, i) => this.getAreasByParentId(id).then(list => map[i] = list))).then(() => {
this.areaOps = Object.values(map)
})
},