清除异常

This commit is contained in:
aixianling
2022-03-09 14:22:04 +08:00
parent 071666f0fe
commit 6fe2cafabb

View File

@@ -11,25 +11,25 @@
<div class="addressBook-left__list"> <div class="addressBook-left__list">
<div class="addressBook-left__list--title"> <div class="addressBook-left__list--title">
<el-input <el-input
class="addressBook-left__list--search" class="addressBook-left__list--search"
size="mini" size="mini"
clearable clearable
placeholder="请输入地区名称" placeholder="请输入地区名称"
v-model="unitName" v-model="unitName"
suffix-icon="iconfont iconSearch"> suffix-icon="iconfont iconSearch">
</el-input> </el-input>
</div> </div>
<el-tree <el-tree
:filter-node-method="filterNode" :filter-node-method="filterNode"
ref="tree" ref="tree"
:props="defaultProps" :props="defaultProps"
node-key="id" node-key="id"
:data="areaTree" :data="areaTree"
highlight-current highlight-current
:current-node-key="search.areaId" :current-node-key="search.areaId"
:default-expanded-keys="defaultExpanded" :default-expanded-keys="defaultExpanded"
:default-checked-keys="defaultChecked" :default-checked-keys="defaultChecked"
@current-change="onTreeChange"> @current-change="onTreeChange">
</el-tree> </el-tree>
</div> </div>
</div> </div>
@@ -37,43 +37,46 @@
<template slot="content"> <template slot="content">
<ai-search-bar class="search-bar"> <ai-search-bar class="search-bar">
<template #left> <template #left>
<el-button size="small" type="primary" :disabled="isShowAdd" icon="iconfont iconAdd" @click="toAdd('')">添加</el-button> <el-button size="small" type="primary" :disabled="isShowAdd" icon="iconfont iconAdd" @click="toAdd('')">添加
<ai-import :instance="instance" :dict="dict" type="appconvenientaddressbook" name="便民通讯录" @success="getList()"> </el-button>
<ai-import :instance="instance" :dict="dict" type="appconvenientaddressbook" name="便民通讯录"
@success="getList()">
<el-button icon="iconfont iconImport">导入</el-button> <el-button icon="iconfont iconImport">导入</el-button>
</ai-import> </ai-import>
<ai-download :instance="instance" url="/app/appconvenientaddressbook/export" :params="search" fileName="便民通讯录" :disabled="tableData.length == 0"> <ai-download :instance="instance" url="/app/appconvenientaddressbook/export" :params="search" fileName="便民通讯录"
:disabled="tableData.length == 0">
<el-button icon="iconfont iconExported" :disabled="tableData.length == 0">导出</el-button> <el-button icon="iconfont iconExported" :disabled="tableData.length == 0">导出</el-button>
</ai-download> </ai-download>
</template> </template>
<template slot="right"> <template slot="right">
<el-input <el-input
v-model="search.name" v-model="search.name"
class="search-input" class="search-input"
size="small" size="small"
@keyup.enter.native="search.current = 1, getList()" @keyup.enter.native="search.current = 1, getList()"
placeholder="请输入名称/电话/类型" placeholder="请输入名称/电话/类型"
clearable clearable
@change="getList" @change="getList"
@clear="search.current = 1, search.name = '', getList()" @clear="search.current = 1, search.name = '', getList()"
suffix-icon="iconfont iconSearch"> suffix-icon="iconfont iconSearch">
</el-input> </el-input>
</template> </template>
</ai-search-bar> </ai-search-bar>
<ai-table <ai-table
:tableData="tableData" :tableData="tableData"
:col-configs="colConfigs" :col-configs="colConfigs"
:total="total" :total="total"
style="margin-top: 6px;" style="margin-top: 6px;"
:current.sync="search.current" :current.sync="search.current"
:size.sync="search.size" :size.sync="search.size"
@getList="getList"> @getList="getList">
<el-table-column slot="isPublic" label="是否公开" align="center"> <el-table-column slot="isPublic" label="是否公开" align="center">
<template slot-scope="{ row }"> <template slot-scope="{ row }">
<el-switch <el-switch
v-model="row.isPublic" v-model="row.isPublic"
active-value="1" active-value="1"
@change="e => onChange(row.id, e)" @change="e => onChange(row.id, e)"
inactive-value="0"> inactive-value="0">
</el-switch> </el-switch>
</template> </template>
</el-table-column> </el-table-column>
@@ -91,176 +94,175 @@
</template> </template>
<script> <script>
import { mapState } from 'vuex' import {mapState} from 'vuex'
export default {
name: 'List',
props: { export default {
instance: Function, name: 'List',
dict: Object
},
data() { props: {
return { instance: Function,
search: { dict: Object
current: 1, },
size: 10,
name: '',
areaId: ''
},
defaultExpanded: [],
defaultChecked: [],
areaTree: [],
defaultProps: {
children: 'children',
label: 'name'
},
currIndex: -1,
areaList: [],
total: 10,
colConfigs: [
{prop: 'name', label: '名称', align: 'left'},
{prop: 'type', label: '类型', align: 'center'},
{prop: 'phone', label: '电话', align: 'center'},
{prop: 'createTime', align: 'center', label: '创建时间'},
{slot: 'isPublic', label: '是否公开', align: 'center'}
],
areaName: '',
unitName: '',
tableData: []
}
},
computed: { data() {
...mapState(['user']), return {
search: {
current: 1,
size: 10,
name: '',
areaId: ''
},
defaultExpanded: [],
defaultChecked: [],
areaTree: [],
defaultProps: {
children: 'children',
label: 'name'
},
currIndex: -1,
areaList: [],
total: 10,
colConfigs: [
{prop: 'name', label: '名称', align: 'left'},
{prop: 'type', label: '类型', align: 'center'},
{prop: 'phone', label: '电话', align: 'center'},
{prop: 'createTime', align: 'center', label: '创建时间'},
{slot: 'isPublic', label: '是否公开', align: 'center'}
],
areaName: '',
unitName: '',
tableData: []
}
},
isShowAdd () { computed: {
const str = this.search.areaId.substr(this.search.areaId.length - 3) ...mapState(['user']),
return false isShowAdd() {
} return false
}, }
},
watch: { watch: {
unitName (val) { unitName(val) {
this.$refs.tree.filter(val) this.$refs.tree.filter(val)
} }
}, },
mounted() { created() {
this.search.areaId = this.user.info.areaId this.search.areaId = this.user.info.areaId
this.areaName = this.user.info.areaName this.areaName = this.user.info.areaName
this.getTree() this.getTree()
this.getAreaList() this.getAreaList()
this.getList() this.getList()
this.$nextTick(() => { this.$nextTick(() => {
})
},
methods: {
getList() {
this.instance.post(`/app/appconvenientaddressbook/list`, null, {
params: {
...this.search
}
}).then(res => {
if (res.code == 0) {
this.tableData = res.data.records
this.total = res.data.total
}
}) })
}, },
methods: { onChange(id) {
getList() { this.instance.post(`/app/appconvenientaddressbook/enable?id=${id}`).then(res => {
this.instance.post(`/app/appconvenientaddressbook/list`, null, { if (res.code == 0) {
params: { this.$message.success('修改成功')
...this.search this.getList()
} }
}).then(res => { })
if (res.code == 0) { },
this.tableData = res.data.records
this.total = res.data.total
}
})
},
onChange (id) { filterNode(value, data) {
this.instance.post(`/app/appconvenientaddressbook/enable?id=${id}`).then(res => { if (!value) return true
return data.name.indexOf(value) !== -1
},
onTreeChange(e) {
this.search.areaId = e.id
this.areaName = e.name
this.search.current = 1
this.$nextTick(() => {
this.getList()
})
},
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 => {
if (res.code == 0) { if (res.code == 0) {
this.$message.success('修改成功') this.$message.success('删除成功')
this.getList() this.getList()
} }
}) })
}, })
},
filterNode(value, data) { toAdd(id) {
if (!value) return true this.$emit('change', {
return data.name.indexOf(value) !== -1 type: 'Add',
}, params: {
areaName: this.areaName,
onTreeChange (e) { id: id || '',
this.search.areaId = e.id areaId: this.search.areaId
this.areaName = e.name
this.search.current = 1
this.$nextTick(() => {
this.getList()
})
},
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 => {
if (res.code == 0) {
this.$message.success('删除成功!')
this.getList()
}
})
})
},
toAdd(id) {
this.$emit('change', {
type: 'Add',
params: {
areaName: this.areaName,
id: id || '',
areaId: this.search.areaId
}
})
}
} }
} }
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@@ -315,6 +317,7 @@
.addressBook-left__list--search { .addressBook-left__list--search {
flex: 1; flex: 1;
::v-deep input { ::v-deep input {
width: 100%; width: 100%;
} }
@@ -336,7 +339,7 @@
background: transparent; background: transparent;
.el-tree-node__expand-icon.is-leaf { .el-tree-node__expand-icon.is-leaf {
color: transparent!important; color: transparent !important;
} }
.el-tree-node__content > .el-tree-node__expand-icon { .el-tree-node__content > .el-tree-node__expand-icon {
@@ -369,7 +372,7 @@
} }
background: #2266FF; background: #2266FF;
span { span {
color: #fff; color: #fff;
} }