From 569f0a57c02d222d8b652bba4255c9e428ce4a88 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 19 Mar 2026 17:19:52 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E9=97=A8=E7=AE=A1=E7=90=86=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=89=B9=E9=87=8F=E4=BF=9D=E5=AD=98=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/system/SysDeptController.java | 12 + .../resources/templates/system/dept/dept.html | 251 ++++++++++-------- .../ruoyi/system/mapper/SysDeptMapper.java | 7 + .../ruoyi/system/service/ISysDeptService.java | 8 + .../service/impl/SysDeptServiceImpl.java | 26 ++ .../resources/mapper/system/SysDeptMapper.xml | 4 + 6 files changed, 197 insertions(+), 111 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java index 39d4d213..c5539b91 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java @@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.constant.UserConstants; @@ -186,4 +187,15 @@ public class SysDeptController extends BaseController List ztrees = deptService.selectDeptTreeExcludeChild(dept); return ztrees; } + + /** + * 保存部门排序 + */ + @PostMapping("/updateSort") + @ResponseBody + public AjaxResult updateSort(@RequestParam String[] deptIds, @RequestParam String[] orderNums) + { + deptService.updateDeptSort(deptIds, orderNums); + return success(); + } } diff --git a/ruoyi-admin/src/main/resources/templates/system/dept/dept.html b/ruoyi-admin/src/main/resources/templates/system/dept/dept.html index 6663d184..6445af60 100644 --- a/ruoyi-admin/src/main/resources/templates/system/dept/dept.html +++ b/ruoyi-admin/src/main/resources/templates/system/dept/dept.html @@ -1,112 +1,141 @@ - - - - - - -
-
-
-
-
-
    -
  • - 部门名称: -
  • -
  • - 部门状态: -
  • -
  • -  搜索 -  重置 -
  • -
-
-
-
- - -
-
-
-
-
- - - + + + + + + +
+
+
+
+
+
    +
  • + 部门名称: +
  • +
  • + 部门状态: +
  • +
  • +  搜索 +  重置 +
  • +
+
+
+
+ + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java index 92514f27..0a0035ac 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java @@ -114,4 +114,11 @@ public interface SysDeptMapper * @return 子部门数 */ public int selectNormalChildrenDeptById(Long deptId); + + /** + * 保存部门排序 + * + * @param dept 部门信息(含deptId和orderNum) + */ + public void updateDeptSort(SysDept dept); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java index 0998732a..f62346e4 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java @@ -114,4 +114,12 @@ public interface ISysDeptService * @param deptId 部门id */ public void checkDeptDataScope(Long deptId); + + /** + * 保存部门排序 + * + * @param deptIds 部门ID数组 + * @param orderNums 排序数组 + */ + public void updateDeptSort(String[] deptIds, String[] orderNums); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index 454f7a90..41ee41cf 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -324,4 +324,30 @@ public class SysDeptServiceImpl implements ISysDeptService } } } + + /** + * 保存部门排序 + * + * @param deptIds 部门ID数组 + * @param orderNums 排序数组 + */ + @Override + @Transactional + public void updateDeptSort(String[] deptIds, String[] orderNums) + { + try + { + for (int i = 0; i < deptIds.length; i++) + { + SysDept dept = new SysDept(); + dept.setDeptId(Convert.toLong(deptIds[i])); + dept.setOrderNum(Convert.toInt(orderNums[i])); + deptMapper.updateDeptSort(dept); + } + } + catch (Exception e) + { + throw new ServiceException("保存排序异常,请联系管理员"); + } + } } diff --git a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml index fd3e64ee..4771d7b0 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -155,4 +155,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + update sys_dept set order_num = #{orderNum} where dept_id = #{deptId} + + \ No newline at end of file