From 088e9774ca5dedbab0f9d1c62cbc02794392ecd9 Mon Sep 17 00:00:00 2001
From: chenyao <1219716595@qq.com>
Date: Mon, 29 Sep 2025 16:22:04 +0800
Subject: [PATCH] feat:完善部门管理增加,更新,和删除
---
src/views/system/dept.vue | 50 +++++++++++++++++++++++++++++++++++++-------------
1 files changed, 37 insertions(+), 13 deletions(-)
diff --git a/src/views/system/dept.vue b/src/views/system/dept.vue
index 56694c6..9ba06be 100644
--- a/src/views/system/dept.vue
+++ b/src/views/system/dept.vue
@@ -40,10 +40,12 @@
import { getLazyTree } from '@/api/base/region'
import { mapGetters } from 'vuex'
import website from '@/config/website'
+import { getList } from '@/api/device/device';
export default {
data () {
return {
+ treeResolveMap: new Map(),
form: {},
selectionList: [],
query: {},
@@ -379,6 +381,14 @@
type: 'success',
message: '操作成功!',
})
+ this.parentId = ''
+ const resolve = this.treeResolveMap.get(row.parentId)
+ if (resolve) {
+ // 重新加载子节点数据
+ getChildLazyTree({ parentId: row.parentId }).then(res => {
+ resolve(res.data.data)
+ })
+ }
this.onLoad(this.page)
done(row)
},
@@ -394,7 +404,7 @@
loading()
return
}
- console.log('--- Start rowUpdate ---')
+ // console.log('--- Start rowUpdate ---')
// 提交时只使用县级代码
const submitData = {
@@ -402,27 +412,33 @@
areaCode: row.areaCode.split(',').pop(), // 取最后一个代码(县级)
}
- console.log('Row data before submit:', row)
+ console.log('编辑', row)
update(submitData)
.then(
res => {
- console.log('Update response:', res.data)
+ const resolve = this.treeResolveMap.get(row.parentId)
+ if (resolve) {
+ // 重新加载子节点数据
+ getChildLazyTree({ parentId: row.parentId }).then(res => {
+ resolve(res.data.data)
+ })
+ }
+ this.onLoad(this.page)
this.$message({
type: 'success',
message: '操作成功!',
})
- this.onLoad(this.page)
done(row)
},
error => {
- console.log('Update error:', error)
+ // console.log('Update error:', error)
this.loading = false
loading()
}
)
.catch(error => {
- console.log('Update promise rejected:', error)
+ // console.log('Update promise rejected:', error)
this.loading = false
})
},
@@ -436,11 +452,18 @@
return remove(row.id)
})
.then(() => {
+ const resolve = this.treeResolveMap.get(row.parentId)
+ if (resolve) {
+ // 重新加载子节点数据
+ getChildLazyTree({ parentId: row.parentId }).then(res => {
+ resolve(res.data.data)
+ })
+ }
+ this.onLoad(this.page)
this.$message({
type: 'success',
message: '操作成功!',
})
- this.onLoad(this.page)
done(row)
})
},
@@ -542,11 +565,11 @@
},
onLoad (page, params = {}) {
this.loading = true
- console.log('onLoad triggered with page:', page, 'params:', params)
- console.log('Current parentId:', this.parentId, 'query:', this.query)
+ // console.log('onLoad triggered with page:', page, 'params:', params)
+ // console.log('Current parentId:', this.parentId, 'query:', this.query)
getLazyList(this.parentId, Object.assign(params, this.query))
.then(res => {
- console.log('onLoad response:', res.data)
+ // console.log('onLoad response:', res.data)
// 处理 areaCode,确保是单一字符串
const data = (res.data.data || []).map(item => {
const fullAreaCode = this.getFullAreaCode(item.areaCode)
@@ -561,16 +584,17 @@
this.data = data
this.loading = false
this.selectionClear()
- console.log('Table data after onLoad:', this.data)
+ // console.log('Table data after onLoad:', this.data)
})
.catch(error => {
- console.log('onLoad error:', error)
+ // console.log('onLoad error:', error)
this.loading = false
this.data = this.data // 保留当前数据
- console.log('Table data after onLoad error:', this.data)
+ // console.log('Table data after onLoad error:', this.data)
})
},
treeLoad (tree, treeNode, resolve) {
+ this.treeResolveMap.set(tree.id, resolve)
getChildLazyTree({ parentId: tree.id }).then(res => {
resolve(res.data.data)
})
--
Gitblit v1.9.3