清除异常
This commit is contained in:
		| @@ -11,25 +11,25 @@ | ||||
|         <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"> | ||||
|                 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"> | ||||
|               :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> | ||||
| @@ -37,43 +37,46 @@ | ||||
|     <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-import :instance="instance" :dict="dict" type="appconvenientaddressbook" name="便民通讯录" @success="getList()"> | ||||
|           <el-button size="small" type="primary" :disabled="isShowAdd" icon="iconfont iconAdd" @click="toAdd('')">添加 | ||||
|           </el-button> | ||||
|           <ai-import :instance="instance" :dict="dict" type="appconvenientaddressbook" name="便民通讯录" | ||||
|                      @success="getList()"> | ||||
|             <el-button icon="iconfont iconImport">导入</el-button> | ||||
|           </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> | ||||
|           </ai-download> | ||||
|         </template> | ||||
|         <template slot="right"> | ||||
|           <el-input | ||||
|             v-model="search.name" | ||||
|             class="search-input" | ||||
|             size="small" | ||||
|             @keyup.enter.native="search.current = 1, getList()" | ||||
|             placeholder="请输入名称/电话/类型" | ||||
|             clearable | ||||
|             @change="getList" | ||||
|             @clear="search.current = 1, search.name = '', getList()" | ||||
|             suffix-icon="iconfont iconSearch"> | ||||
|               v-model="search.name" | ||||
|               class="search-input" | ||||
|               size="small" | ||||
|               @keyup.enter.native="search.current = 1, getList()" | ||||
|               placeholder="请输入名称/电话/类型" | ||||
|               clearable | ||||
|               @change="getList" | ||||
|               @clear="search.current = 1, search.name = '', getList()" | ||||
|               suffix-icon="iconfont iconSearch"> | ||||
|           </el-input> | ||||
|         </template> | ||||
|       </ai-search-bar> | ||||
|       <ai-table | ||||
|         :tableData="tableData" | ||||
|         :col-configs="colConfigs" | ||||
|         :total="total" | ||||
|         style="margin-top: 6px;" | ||||
|         :current.sync="search.current" | ||||
|         :size.sync="search.size" | ||||
|         @getList="getList"> | ||||
|           :tableData="tableData" | ||||
|           :col-configs="colConfigs" | ||||
|           :total="total" | ||||
|           style="margin-top: 6px;" | ||||
|           :current.sync="search.current" | ||||
|           :size.sync="search.size" | ||||
|           @getList="getList"> | ||||
|         <el-table-column slot="isPublic" label="是否公开" align="center"> | ||||
|           <template slot-scope="{ row }"> | ||||
|             <el-switch | ||||
|               v-model="row.isPublic" | ||||
|               active-value="1" | ||||
|               @change="e => onChange(row.id, e)" | ||||
|               inactive-value="0"> | ||||
|                 v-model="row.isPublic" | ||||
|                 active-value="1" | ||||
|                 @change="e => onChange(row.id, e)" | ||||
|                 inactive-value="0"> | ||||
|             </el-switch> | ||||
|           </template> | ||||
|         </el-table-column> | ||||
| @@ -91,176 +94,175 @@ | ||||
| </template> | ||||
|  | ||||
| <script> | ||||
|   import { mapState } from 'vuex' | ||||
|   export default { | ||||
|     name: 'List', | ||||
| import {mapState} from 'vuex' | ||||
|  | ||||
|     props: { | ||||
|       instance: Function, | ||||
|       dict: Object | ||||
|     }, | ||||
| export default { | ||||
|   name: 'List', | ||||
|  | ||||
|     data() { | ||||
|       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: [] | ||||
|       } | ||||
|     }, | ||||
|   props: { | ||||
|     instance: Function, | ||||
|     dict: Object | ||||
|   }, | ||||
|  | ||||
|     computed: { | ||||
|       ...mapState(['user']), | ||||
|   data() { | ||||
|     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 () { | ||||
|         const str = this.search.areaId.substr(this.search.areaId.length - 3) | ||||
|   computed: { | ||||
|     ...mapState(['user']), | ||||
|  | ||||
|         return false | ||||
|       } | ||||
|     }, | ||||
|     isShowAdd() { | ||||
|       return false | ||||
|     } | ||||
|   }, | ||||
|  | ||||
|     watch: { | ||||
|       unitName (val) { | ||||
|         this.$refs.tree.filter(val) | ||||
|       } | ||||
|     }, | ||||
|   watch: { | ||||
|     unitName(val) { | ||||
|       this.$refs.tree.filter(val) | ||||
|     } | ||||
|   }, | ||||
|  | ||||
|     mounted() { | ||||
|       this.search.areaId = this.user.info.areaId | ||||
|       this.areaName = this.user.info.areaName | ||||
|       this.getTree() | ||||
|       this.getAreaList() | ||||
|       this.getList() | ||||
|   created() { | ||||
|     this.search.areaId = this.user.info.areaId | ||||
|     this.areaName = this.user.info.areaName | ||||
|     this.getTree() | ||||
|     this.getAreaList() | ||||
|     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: { | ||||
|       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 | ||||
|           } | ||||
|         }) | ||||
|       }, | ||||
|     onChange(id) { | ||||
|       this.instance.post(`/app/appconvenientaddressbook/enable?id=${id}`).then(res => { | ||||
|         if (res.code == 0) { | ||||
|           this.$message.success('修改成功') | ||||
|           this.getList() | ||||
|         } | ||||
|       }) | ||||
|     }, | ||||
|  | ||||
|       onChange (id) { | ||||
|         this.instance.post(`/app/appconvenientaddressbook/enable?id=${id}`).then(res => { | ||||
|     filterNode(value, data) { | ||||
|       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) { | ||||
|             this.$message.success('修改成功') | ||||
|             this.$message.success('删除成功!') | ||||
|             this.getList() | ||||
|           } | ||||
|         }) | ||||
|       }, | ||||
|       }) | ||||
|     }, | ||||
|  | ||||
|       filterNode(value, data) { | ||||
|         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]) | ||||
|           } | ||||
|     toAdd(id) { | ||||
|       this.$emit('change', { | ||||
|         type: 'Add', | ||||
|         params: { | ||||
|           areaName: this.areaName, | ||||
|           id: id || '', | ||||
|           areaId: this.search.areaId | ||||
|         } | ||||
|  | ||||
|         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> | ||||
|  | ||||
| <style lang="scss" scoped> | ||||
| @@ -315,6 +317,7 @@ | ||||
|  | ||||
|       .addressBook-left__list--search { | ||||
|         flex: 1; | ||||
|  | ||||
|         ::v-deep input { | ||||
|           width: 100%; | ||||
|         } | ||||
| @@ -336,7 +339,7 @@ | ||||
|       background: transparent; | ||||
|  | ||||
|       .el-tree-node__expand-icon.is-leaf { | ||||
|         color: transparent!important; | ||||
|         color: transparent !important; | ||||
|       } | ||||
|  | ||||
|       .el-tree-node__content > .el-tree-node__expand-icon { | ||||
| @@ -369,7 +372,7 @@ | ||||
|         } | ||||
|  | ||||
|         background: #2266FF; | ||||
|          | ||||
|  | ||||
|         span { | ||||
|           color: #fff; | ||||
|         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user