From 89380e6260a75d1d3b94de687ebcc2f50d50659d Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Tue, 03 Feb 2026 15:44:33 +0800
Subject: [PATCH] feat:环境变量配置调整

---
 applications/drone-command/src/views/permissionManage/permissionDept/index.vue |  111 ++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 96 insertions(+), 15 deletions(-)

diff --git a/applications/drone-command/src/views/permissionManage/permissionDept/index.vue b/applications/drone-command/src/views/permissionManage/permissionDept/index.vue
index 9930be6..572f9bf 100644
--- a/applications/drone-command/src/views/permissionManage/permissionDept/index.vue
+++ b/applications/drone-command/src/views/permissionManage/permissionDept/index.vue
@@ -49,26 +49,27 @@
 					<el-table-column type="index" show-overflow-tooltip width="64" label="序号" />
 					<el-table-column prop="deptName" show-overflow-tooltip label="部门名称" />
 					<el-table-column prop="fullName" show-overflow-tooltip label="部门全称" />
-					<el-table-column prop="deptCategory" show-overflow-tooltip width="120" label="部门类型">
+					<el-table-column prop="deptCategory" show-overflow-tooltip label="部门类型">
 						<template v-slot="{ row }">
 							{{ getDictLabel(row.deptCategory, dictObj.org_category) }}
 						</template>
 					</el-table-column>
-					<el-table-column prop="deptNature" show-overflow-tooltip width="120" label="部门性质">
+					<el-table-column prop="deptNature" show-overflow-tooltip label="部门性质">
 						<template v-slot="{ row }">
 							{{ getDictLabel(row.deptNature, dictObj.org_nature) }}
 						</template>
 					</el-table-column>
 					<el-table-column prop="sort" show-overflow-tooltip width="80" label="排序" />
-					<el-table-column prop="bingId" show-overflow-tooltip width="100" label="组织id" />
-					<el-table-column prop="areaName" show-overflow-tooltip width="180" label="行政区划" />
-					
-					<el-table-column label="操作" class-name="operation-btns" width="220">
+					<el-table-column prop="bingId" show-overflow-tooltip width="80" label="组织id" />
+					<el-table-column prop="areaName" show-overflow-tooltip label="行政区划" />
+
+					<el-table-column label="操作" class-name="operation-btns">
 						<template v-slot="{ row }">
 							<el-link @click="handleView(row)">查看</el-link>
 							<el-link @click="handleEdit(row)">编辑</el-link>
 							<el-link @click="handleAddChild(row)">新增子项</el-link>
 							<el-link type="danger" @click="handleDelete(row)">删除</el-link>
+							<el-link type="danger" @click="handleShare(row)" v-if="hasSharing">共享</el-link>
 						</template>
 					</el-table-column>
 				</el-table>
@@ -86,21 +87,29 @@
 			</div>
 		</div>
 
-		<FormDiaLog ref="dialogRef" @success="getList" />
+		<FormDiaLog ref="dialogRef" @success="handleFormSuccess" v-model="visible" v-if="visible" />
+		<ShareDiaLog ref="shareDialogRef" @success="getList" v-model="shareVisible" v-if="shareVisible" />
 	</basic-container>
 </template>
 
 <script setup>
 import { Delete, Plus, RefreshRight, Search } from '@element-plus/icons-vue'
-import { onMounted, provide, ref } from 'vue'
+import { nextTick, onMounted, provide, ref } from 'vue'
 import { ElMessage, ElMessageBox } from 'element-plus'
 import { getDictionary } from '@/api/system/dict'
 import { getChildLazyTree, getDeptTree, getLazyList, remove } from '@/api/system/dept'
 import { getDictLabel } from '@ztzf/utils'
 import FormDiaLog from './FormDiaLog.vue'
+import ShareDiaLog from './ShareDiaLog.vue'
 import { saveOperationLog } from '@ztzf/apis'
 import { useRoute } from 'vue-router'
+import { useStore } from 'vuex'
 
+const store = useStore()
+const permission = computed(() => store.state.user.permission)
+const ancestors = computed(() => store.state.user.userInfo?.detail?.ancestors)
+// 市级部门并且有权限才能看到共享按钮
+const hasSharing = computed(() => permission.value.department_share && ancestors.value.split(',')?.length === 2)
 const initSearchParams = () => ({
 	deptName: '',
 	fullName: '',
@@ -110,17 +119,23 @@
 
 const searchParams = ref(initSearchParams())
 const loading = ref(true)
+const visible = ref(false)
 const list = ref([])
 const total = ref(0)
 const selectedIds = ref([])
+const selectedRows = ref([])
+const lastActionParentRow = ref(null)
 const queryParamsRef = ref(null)
 const dialogRef = ref(null)
+const shareDialogRef = ref(null)
+const shareVisible = ref(false)
 const dictObj = ref({
 	org_category: [],
 	org_nature: [],
 })
 const deptTree = ref([])
 const route = useRoute()
+const treeResolveMap = new Map()
 
 provide('dictObj', dictObj)
 provide('deptTree', deptTree)
@@ -148,19 +163,39 @@
 }
 
 function handleAdd() {
-	dialogRef.value?.open({ mode: 'add' })
+	visible.value = true
+	nextTick(() => {
+		dialogRef.value?.open({ mode: 'add' })
+	})
 }
 
 function handleAddChild(row) {
-	dialogRef.value?.open({ mode: 'add', parent: row })
+	lastActionParentRow.value = row
+	visible.value = true
+	nextTick(() => {
+		dialogRef.value?.open({ mode: 'add', parent: row })
+	})
 }
 
 function handleView(row) {
-	dialogRef.value?.open({ mode: 'view', row: { ...row } })
+	visible.value = true
+	nextTick(() => {
+		dialogRef.value?.open({ mode: 'view', row: { ...row } })
+	})
 }
 
 function handleEdit(row) {
-	dialogRef.value?.open({ mode: 'edit', row: { ...row } })
+	visible.value = true
+	nextTick(() => {
+		dialogRef.value?.open({ mode: 'edit', row: { ...row } })
+	})
+}
+
+function handleShare(row) {
+	shareVisible.value = true
+	nextTick(() => {
+		shareDialogRef.value?.open({ row })
+	})
 }
 
 async function handleDelete(row) {
@@ -172,6 +207,7 @@
 		cancelButtonClass: 'command-message-box-cancel',
 	})
 	const ids = row ? row.id : selectedIds.value.join(',')
+	const rows = row ? [row] : selectedRows.value
 	await remove(ids)
 	saveOperationLog({
 		requestUri: route.path,
@@ -180,11 +216,18 @@
 	})
 	ElMessage.success('删除成功')
 	selectedIds.value = []
-	getList()
+	selectedRows.value = []
+	const parentIds = Array.from(new Set(rows.map(item => item.parentId).filter(Boolean)))
+	const hasRoot = rows.some(item => !item.parentId)
+	if (hasRoot) {
+		getList()
+	}
+	parentIds.forEach(parentId => refreshChildNodes(parentId))
 }
 
 function handleSelectionChange(rows) {
 	selectedIds.value = rows.map(item => item.id)
+	selectedRows.value = rows
 }
 
 function getDictList() {
@@ -205,11 +248,49 @@
 }
 
 function loadChildren(row, treeNode, resolve) {
+	treeResolveMap.set(row.id, { resolve, row })
 	getChildLazyTree({ parentId: row.id })
 		.then(res => {
-			resolve(res?.data?.data ?? [])
+			const children = res?.data?.data ?? []
+			row.hasChildren = children.length > 0
+			resolve(children)
 		})
-		.catch(() => resolve([]))
+		.catch(() => {
+			row.hasChildren = false
+			resolve([])
+		})
+}
+
+function refreshChildNodes(parentId) {
+	const cache = treeResolveMap.get(parentId)
+	if (!cache?.resolve) return
+	getChildLazyTree({ parentId })
+		.then(res => {
+			const children = res?.data?.data ?? []
+			if (cache.row) {
+				cache.row.hasChildren = children.length > 0
+			}
+			cache.resolve(children)
+		})
+		.catch(() => {
+			if (cache.row) {
+				cache.row.hasChildren = false
+			}
+			cache.resolve([])
+		})
+}
+
+function handleFormSuccess(payload = {}) {
+	if (payload?.parentId) {
+		refreshChildNodes(payload.parentId)
+		if (payload.isAddChild && lastActionParentRow.value?.id === payload.parentId) {
+			lastActionParentRow.value.hasChildren = true
+		}
+		lastActionParentRow.value = null
+		return
+	}
+	lastActionParentRow.value = null
+	getList()
 }
 
 onMounted(() => {

--
Gitblit v1.9.3