| ¶Ô±ÈÐÂÎļþ | 
 |  |  | 
 |  |  | <template> | 
 |  |  |   <TableLayout :permissions="['business:areas:query']"> | 
 |  |  |     <!-- è¡¨æ ¼åå页 --> | 
 |  |  |     <template v-slot:table-wrap> | 
 |  |  |       <el-table | 
 |  |  |         ref="table" | 
 |  |  |         v-loading="isWorking.search" | 
 |  |  |         :data="tableData.list" | 
 |  |  |         lazy | 
 |  |  |         :load="load" | 
 |  |  |         :tree-props="{ children: 'childList', hasChildren: 'hasChildren' }" | 
 |  |  |         row-key="id" | 
 |  |  |         stripe | 
 |  |  |         border | 
 |  |  |         :header-row-class-name="'table-header'" | 
 |  |  |         class="doumee-element-table" | 
 |  |  |         @selection-change="handleSelectionChange" | 
 |  |  |       > | 
 |  |  |         <el-table-column prop="name" label="å°åºåç§°" min-width="100px"></el-table-column> | 
 |  |  |         <el-table-column prop="createDate" label="å建æ¶é´" align="center" min-width="140px"></el-table-column> | 
 |  |  |         <el-table-column prop="sortnum" label="æåºç " align="center" min-width="140px"></el-table-column> | 
 |  |  |         <el-table-column | 
 |  |  |           v-if="containPermissions(['business:areas:update', 'business:areas:create', 'business:areas:delete'])" | 
 |  |  |           label="æä½" | 
 |  |  |           align="center" | 
 |  |  |           min-width="220" | 
 |  |  |           fixed="right" | 
 |  |  |         > | 
 |  |  |           <template slot-scope="{ row }"> | 
 |  |  |             <el-button type="text" @click="edit(row)" v-permissions="['business:areas:update']">ç¼è¾</el-button> | 
 |  |  |             <el-button v-if="row.type!=2" type="text" @click="createChild(row)" v-permissions="['business:areas:create']">æ°å»º{{ row.type==0 ? 'å¸' : 'åºå¿' }}</el-button> | 
 |  |  |             <el-button type="text" @click="deleteById(row)" v-permissions="['business:areas:delete']">å é¤</el-button> | 
 |  |  |           </template> | 
 |  |  |         </el-table-column> | 
 |  |  |       </el-table> | 
 |  |  |     </template> | 
 |  |  |     <!-- æ°å»º/修湠--> | 
 |  |  |     <OperaAreasWindow ref="operaAreasWindow" @success="update"/> | 
 |  |  |   </TableLayout> | 
 |  |  | </template> | 
 |  |  |  | 
 |  |  | <script> | 
 |  |  | import BaseTable from '@/components/base/BaseTable' | 
 |  |  | import TableLayout from '@/layouts/TableLayout' | 
 |  |  | import Pagination from '@/components/common/Pagination' | 
 |  |  | import OperaAreasWindow from '@/components/business/OperaAreasWindow' | 
 |  |  | import { listByParentId } from '@/api/business/areas' | 
 |  |  | export default { | 
 |  |  |   name: 'Areas', | 
 |  |  |   extends: BaseTable, | 
 |  |  |   components: { TableLayout, Pagination, OperaAreasWindow }, | 
 |  |  |   data () { | 
 |  |  |     return { | 
 |  |  |       // æç´¢ | 
 |  |  |       searchForm: { | 
 |  |  |         type: 0, | 
 |  |  |         parentId: '' | 
 |  |  |       }, | 
 |  |  |       treeMaps: new Map(), | 
 |  |  |       parentId: null | 
 |  |  |     } | 
 |  |  |   }, | 
 |  |  |   created () { | 
 |  |  |     this.config({ | 
 |  |  |       module: 'çå¸åºä¿¡æ¯è¡¨', | 
 |  |  |       api: '/business/areas', | 
 |  |  |       'field.id': 'id', | 
 |  |  |       'field.main': 'id' | 
 |  |  |     }) | 
 |  |  |     this.search() | 
 |  |  |   }, | 
 |  |  |   methods: { | 
 |  |  |  | 
 |  |  |     // é¡µç åæ´å¤ç | 
 |  |  |     handlePageChange (pageIndex) { | 
 |  |  |  | 
 |  |  |       this.isWorking.search = true | 
 |  |  |       listByParentId(this.searchForm) | 
 |  |  |         .then(data => { | 
 |  |  |           this.tableData.list = this.dataAddBool(data) | 
 |  |  |         }) | 
 |  |  |         .catch(e => { | 
 |  |  |           console.log(e) | 
 |  |  |           this.$tip.error('æä½å¤±è´¥') | 
 |  |  |         }) | 
 |  |  |         .finally(() => { | 
 |  |  |           this.isWorking.search = false | 
 |  |  |         }) | 
 |  |  |     }, | 
 |  |  |     dataAddBool(array) { | 
 |  |  |       if(array==null){ | 
 |  |  |         return  [] | 
 |  |  |       } | 
 |  |  |       array.forEach(item => { | 
 |  |  |         item.hasChildren = item.type != 2 | 
 |  |  |         // item.childList = item.childList && this.dataAddBool(item.childList) | 
 |  |  |       }) | 
 |  |  |       return array | 
 |  |  |     }, | 
 |  |  |     load(tree, treeNode, resolve) { | 
 |  |  |       this.treeMaps.set(tree.id, { tree, treeNode, resolve }) | 
 |  |  |       listByParentId({ parentId: tree.id, type: tree.type + 1 }) | 
 |  |  |         .then(data => { | 
 |  |  |           resolve(this.dataAddBool(data || [])) | 
 |  |  |         }) | 
 |  |  |         .catch(e => { | 
 |  |  |           console.log(e) | 
 |  |  |           this.$tip.error('æä½å¤±è´¥') | 
 |  |  |         }) | 
 |  |  |         .finally(() => { | 
 |  |  |           this.isWorking.search = false | 
 |  |  |         }) | 
 |  |  |     }, | 
 |  |  |     refreshLoadTree(parentId) { | 
 |  |  |       if (this.treeMaps.get(parentId)) { | 
 |  |  |         const { tree, treeNode, resolve } = this.treeMaps.get(parentId) | 
 |  |  |         this.$set(this.$refs.table.store.states.lazyTreeNodeMap, parentId, []) | 
 |  |  |         if (tree) { // éæ°æ§è¡ç¶èç¹å è½½å级æä½ | 
 |  |  |           this.load(tree, treeNode, resolve) | 
 |  |  |           if (tree.parentId) { // è¥åå¨ç·ç·ç»ç¹ï¼åæ§è¡ç·ç·èç¹å è½½å级æä½ï¼é²æ¢æåä¸ä¸ªåèç¹è¢«å é¤åç¶èç¹ä¸æ¾ç¤ºå é¤æé® | 
 |  |  |             const a = this.treeMaps.get(tree.parentId) | 
 |  |  |             this.load(a.tree, a.treeNode, a.resolve) | 
 |  |  |           } | 
 |  |  |         } | 
 |  |  |       } else { | 
 |  |  |         this.handlePageChange() | 
 |  |  |       } | 
 |  |  |     }, | 
 |  |  |     deleteById (row, childConfirm = true) { | 
 |  |  |       // let message = `确认å é¤${this.module}ã${row[this.configData['field.main']]}ãå?` | 
 |  |  |       let message = `确认å é¤è¯¥è®°å½å?` | 
 |  |  |       if (childConfirm && row.childList != null && row.childList.length > 0) { | 
 |  |  |         // message = `确认å é¤${this.module}ã${row[this.configData['field.main']]}ãåå
¶å${this.module}å?` | 
 |  |  |         message = `确认å é¤è¯¥è®°å½åå
¶åæ°æ®å?` | 
 |  |  |       } | 
 |  |  |       this.$dialog.deleteConfirm(message) | 
 |  |  |         .then(() => { | 
 |  |  |           this.isWorking.delete = true | 
 |  |  |           this.api.deleteById(row[this.configData['field.id']]) | 
 |  |  |             .then(() => { | 
 |  |  |               this.$tip.apiSuccess('å é¤æå') | 
 |  |  |               this.refreshLoadTree(row.parentId) | 
 |  |  |             }) | 
 |  |  |             .catch(e => { | 
 |  |  |               console.log(e) | 
 |  |  |               this.$tip.error('æä½å¤±è´¥') | 
 |  |  |             }) | 
 |  |  |             .finally(() => { | 
 |  |  |               this.isWorking.delete = false | 
 |  |  |             }) | 
 |  |  |         }) | 
 |  |  |         .catch(() => {}) | 
 |  |  |     }, | 
 |  |  |     edit(row) { | 
 |  |  |       // this.parentId = row.type==0 ? null : row.type==1 ? 'ç¼è¾å¸' : 'ç¼è¾åºå¿' | 
 |  |  |       this.$refs.operaAreasWindow.open(row.type==0 ? 'ç¼è¾ç' : row.type==1 ? 'ç¼è¾å¸' : 'ç¼è¾åºå¿', row) | 
 |  |  |     }, | 
 |  |  |     createChild(row) { | 
 |  |  |       this.$refs.operaAreasWindow.open(row.type == 0 ? 'æ°å»ºå¸' : 'æ°å»ºå¿åº', { parentId: row.id, name: '', type: row.type + 1 }) | 
 |  |  |     }, | 
 |  |  |     update(parentId) { | 
 |  |  |       this.refreshLoadTree(parentId) | 
 |  |  |     } | 
 |  |  |   } | 
 |  |  | } | 
 |  |  | </script> |