This commit is contained in:
yanran200730
2022-02-10 13:56:50 +08:00
parent 14abe686a4
commit 9654b024b2
3 changed files with 26 additions and 116 deletions

View File

@@ -8,8 +8,15 @@
<ai-card title="基本信息">
<template #content>
<el-form ref="form" class="ai-form" :model="form" label-width="110px" label-position="right">
<el-form-item label="地区" style="width: 100%;" prop="codeName">
<span style="color: #666;">{{ form.areaName }}</span>
<el-form-item label="地区" style="width: 100%;" prop="areaId" :rules="[{ required: true, message: '请选择地区', trigger: 'change' }]">
<ai-area-select
placeholder="请选择地区"
clearable
always-show
:instance="instance"
v-model="form.areaId"
@fullname="v => form.areaName = v"
/>
</el-form-item>
<el-form-item style="width: 100%" label="名称" prop="name" :rules="[{ required: true, message: '请输入名称', trigger: 'blur' }]">
<el-input size="small" placeholder="请输入名称" show-word-limit v-model="form.name" :maxlength="30"></el-input>
@@ -77,13 +84,6 @@
},
created () {
this.getAreaList()
if (this.params && this.params.areaId && !this.params.id) {
this.form.areaId = this.params.areaId
this.form.areaName = this.params.areaName
}
if (this.params && this.params.id) {
this.id = this.params.id
this.getInfo(this.params.id)
@@ -99,23 +99,6 @@
})
},
getAreaList() {
this.instance.post(`/admin/area/queryAreaByParentId?id=341021104000`).then(res => {
if (res.code == 0) {
this.areaList = res.data.map(item => {
item.dictName = item.name
item.dictValue = item.id
return item
})
}
})
},
onClose () {
this.form.explain = ''
},
confirm () {
this.$refs.form.validate((valid) => {
if (valid) {

View File

@@ -3,41 +3,16 @@
<template slot="title">
<ai-title title="通讯录" isShowBottomBorder></ai-title>
</template>
<template #left>
<div class="villagecode-left">
<div class="villagecode-left__title">
<h2>地区</h2>
</div>
<div class="addressBook-left__list">
<div class="addressBook-left__list--title">
<el-input
class="addressBook-left__list--search"
size="mini"
clearable
placeholder="请输入地区名称"
v-model="unitName"
suffix-icon="iconfont iconSearch">
</el-input>
</div>
<el-tree
:filter-node-method="filterNode"
ref="tree"
:props="defaultProps"
node-key="id"
:data="areaTree"
highlight-current
:current-node-key="search.areaId"
:default-expanded-keys="defaultExpanded"
:default-checked-keys="defaultChecked"
@current-change="onTreeChange">
</el-tree>
</div>
</div>
</template>
<template slot="content">
<ai-search-bar class="search-bar">
<template #left>
<el-button size="small" type="primary" :disabled="isShowAdd" icon="iconfont iconAdd" @click="toAdd('')">添加</el-button>
<ai-area-get
style="width: 180px;"
placeholder="请选择地区"
:instance="instance"
v-model="search.areaId"
@select="onAreaChange"/>
<el-button size="small" type="primary" icon="iconfont iconAdd" @click="toAdd('')">添加</el-button>
</template>
<template slot="right">
<el-input
@@ -126,13 +101,7 @@
},
computed: {
...mapState(['user']),
isShowAdd () {
const str = this.search.areaId.substr(this.search.areaId.length - 3)
return false
}
...mapState(['user'])
},
watch: {
@@ -142,14 +111,7 @@
},
mounted() {
this.search.areaId = this.user.info.areaId
this.areaName = this.user.info.areaName
this.getTree()
this.getAreaList()
this.getList()
this.$nextTick(() => {
})
},
methods: {
@@ -166,6 +128,14 @@
})
},
onAreaChange () {
this.search.current = 1
this.$nextTick(() => {
this.getList()
})
},
onChange (id) {
this.instance.post(`/app/appconvenientaddressbook/enable?id=${id}`).then(res => {
if (res.code == 0) {
@@ -190,48 +160,6 @@
})
},
getTree () {
this.instance.post(`/admin/area/queryAllArea?id=${this.user.info.areaId}`).then(res => {
if (res.code === 0) {
let parent = res.data.map(v => {
v.label = v.name
v.children = []
return v
}).filter(e => !e.parentid)[0]
this.defaultExpanded = [parent.id]
this.defaultChecked = [parent.id]
this.search.areaId = parent.id
this.addChild(parent, res.data)
this.areaTree = [parent]
this.$nextTick(() => {
this.$refs.tree.setCurrentKey(parent.id)
})
}
})
},
addChild (parent, list) {
for (let i = 0; i < list.length; i++) {
if (list[i].parentId === parent.id) {
parent.children.push(list[i])
}
}
if (list.length > 0) {
parent['children'].map(v => this.addChild(v, list))
}
},
getAreaList() {
this.instance.post(`/admin/area/queryAreaByParentId?id=341021104000`).then(res => {
if (res.code == 0) {
this.areaList = res.data
}
})
},
remove(id) {
this.$confirm('确定删除该数据?').then(() => {
this.instance.post(`/app/appconvenientaddressbook/delete?ids=${id}`).then(res => {

View File

@@ -235,8 +235,7 @@ export default {
this.searchInit()
},
onAreaChange (e) {
this.search.areaId = e
onAreaChange () {
this.page.current = 1
this.$nextTick(() => {