From a856cfc04747d4d8f3605168531b253240d2e87c Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期三, 27 十一月 2024 08:55:07 +0800
Subject: [PATCH] Merge branch 'master' of http://139.186.142.91:10010/r/productDev/funingyunwei
---
admin/src/views/business/areas.vue | 166 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 166 insertions(+), 0 deletions(-)
diff --git a/admin/src/views/business/areas.vue b/admin/src/views/business/areas.vue
new file mode 100644
index 0000000..0908620
--- /dev/null
+++ b/admin/src/views/business/areas.vue
@@ -0,0 +1,166 @@
+<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>
--
Gitblit v1.9.3