From 409a6c46741422f0d6dc00acc38b5f7dc1f35e9f Mon Sep 17 00:00:00 2001
From: tuqin <tuqin@tuqin.cn>
Date: 星期四, 24 九月 2026 10:53:07 +0800
Subject: [PATCH] feat: 现场需求前端改动
---
src/views/officeProcessAutomation/SysAdmin/dept-manage/index.vue | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 54 insertions(+), 1 deletions(-)
diff --git a/src/views/officeProcessAutomation/SysAdmin/dept-manage/index.vue b/src/views/officeProcessAutomation/SysAdmin/dept-manage/index.vue
index 9dd4e90..0f31507 100644
--- a/src/views/officeProcessAutomation/SysAdmin/dept-manage/index.vue
+++ b/src/views/officeProcessAutomation/SysAdmin/dept-manage/index.vue
@@ -69,6 +69,8 @@
</el-table-column>
<el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width">
<template #default="scope">
+ <el-button link type="primary" icon="Top" @click="moveUp(scope.row)" v-hasPermi="['system:dept:edit']">涓婄Щ</el-button>
+ <el-button link type="primary" icon="Bottom" @click="moveDown(scope.row)" v-hasPermi="['system:dept:edit']">涓嬬Щ</el-button>
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:dept:edit']">淇敼</el-button>
<el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['system:dept:add']">鏂板</el-button>
<el-button v-if="scope.row.parentId != 0" link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:dept:remove']">鍒犻櫎</el-button>
@@ -146,7 +148,7 @@
</template>
<script setup name="Dept">
-import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild } from "@/api/system/dept"
+import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild, updateDeptSort } from "@/api/system/dept"
const { proxy } = getCurrentInstance()
const { sys_normal_disable } = proxy.useDict("sys_normal_disable")
@@ -286,6 +288,57 @@
}).catch(() => {})
}
+/** 鎵惧埌閮ㄩ棬鍦ㄥ悓绾т腑鐨勪綅缃� */
+function findSiblings(targetId, list = deptList.value) {
+ for (let i = 0; i < list.length; i++) {
+ if (list[i].deptId === targetId) {
+ return { list, index: i }
+ }
+ if (list[i].children && list[i].children.length) {
+ const r = findSiblings(targetId, list[i].children)
+ if (r) return r
+ }
+ }
+ return null
+}
+
+/** 淇濆瓨鍚岀骇鎺掑簭锛堥噸鎺� 0..n-1锛� */
+function saveDeptSort(siblings) {
+ const payload = siblings.map((d, i) => ({ deptId: d.deptId, orderNum: i }))
+ return updateDeptSort(payload).then(() => {
+ proxy.$modal.msgSuccess("鎺掑簭鎴愬姛")
+ getList()
+ })
+}
+
+/** 涓婄Щ */
+function moveUp(row) {
+ const s = findSiblings(row.deptId)
+ if (!s || s.index <= 0) {
+ proxy.$modal.msgWarning("宸茬粡鏄涓�涓簡")
+ return
+ }
+ const { list, index } = s
+ const tmp = list[index - 1]
+ list[index - 1] = list[index]
+ list[index] = tmp
+ saveDeptSort(list)
+}
+
+/** 涓嬬Щ */
+function moveDown(row) {
+ const s = findSiblings(row.deptId)
+ if (!s || s.index >= s.list.length - 1) {
+ proxy.$modal.msgWarning("宸茬粡鏄渶鍚庝竴涓簡")
+ return
+ }
+ const { list, index } = s
+ const tmp = list[index + 1]
+ list[index + 1] = list[index]
+ list[index] = tmp
+ saveDeptSort(list)
+}
+
getList()
</script>
--
Gitblit v1.9.3