ソースを参照

综管新增用户添加部门选择

luoxiao 2 ヶ月 前
コミット
bb9d47646a
2 ファイル変更40 行追加4 行削除
  1. 11 0
      src/api/user/index.ts
  2. 29 4
      src/views/sets/users.vue

+ 11 - 0
src/api/user/index.ts

@@ -174,3 +174,14 @@ export function addSystemUserMenu(obj: Object) {
     data: obj,
   });
 }
+
+/**
+ * 部门树形列表
+ * @param queryParams
+ */
+export function treeList(): AxiosPromise<any[]> {
+  return request({
+    url: "/api/v1/syn/dept/info/orgTree",
+    method: "get",
+  });
+}

+ 29 - 4
src/views/sets/users.vue

@@ -63,6 +63,7 @@ import {
   addSystemUserMenu,
   systemMenuList,
   systemUserMenuList,
+  treeList,
 } from "@/api/user/index";
 
 // 传入一个url,后面不带/
@@ -77,9 +78,13 @@ const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等
 
 const crudRef = ref(null); //crudRef.value 获取avue-crud对象
 
-onMounted(() => {
-  dataList();
-});
+const deptList = ref([]); //部门列表
+const getDeptList = async () => {
+  let res = await treeList();
+  if (res && res.code == 200) {
+    deptList.value = res.data ?? []; //获取部门列表
+  }
+};
 
 // 设置表格列或者其他自定义的option
 option.value = Object.assign(option.value, {
@@ -113,7 +118,6 @@ option.value = Object.assign(option.value, {
       ],
       search: true,
     },
-
     {
       label: "账号",
       prop: "userName",
@@ -168,6 +172,22 @@ option.value = Object.assign(option.value, {
       value: 0,
     },
     {
+      label: "部门名称",
+      prop: "deptIds",
+      type: "tree",
+      dicData: deptList, // 使用树形结构数据
+      props: {
+        label: "deptName", // 显示的字段
+        value: "id", // 传递给后端的字段
+        children: "children", // 子节点字段
+      },
+      checkStrictly: true,
+      multiple: true, // 支持多选
+      showCheckbox: true, // 显示复选框
+      search: true,
+      valueformat: "array", // 确保值是数组格式
+    },
+    {
       label: "操作",
       prop: "menu",
       span: 24,
@@ -214,4 +234,9 @@ const toggleCheckAll = () => {
 const resetChecked = () => {
   treeRef.value.setCheckedKeys([], false);
 };
+
+onMounted(() => {
+  getDeptList(); //获取部门列表
+  dataList();
+});
 </script>