From 43e4b7f1bf6caae8021b5987739b09fd23204448 Mon Sep 17 00:00:00 2001
From: yinbangzhong <zhongbangyin@126.com>
Date: 星期二, 27 八月 2024 11:45:16 +0800
Subject: [PATCH] set user dept

---
 src/views/authority/users/index.vue |  793 +++++++++++++++++++++++++++++++-------------------------
 1 files changed, 443 insertions(+), 350 deletions(-)

diff --git a/src/views/authority/users/index.vue b/src/views/authority/users/index.vue
index cf5ddba..55d397e 100644
--- a/src/views/authority/users/index.vue
+++ b/src/views/authority/users/index.vue
@@ -1,73 +1,69 @@
 <template>
   <div class="container">
     <authheader :items="menuTips"></authheader>
-    <a-card ref="account" class="general-card" :title="$t('menu.user.title')">
-      <a-row>
-        <a-col :flex="2"></a-col>
-        <a-col :flex="1">
-          <a-form :model="formModel">
-            <a-form-item field="name">
-              <a-input
-                v-model="formModel.name"
-                :style="{ width: '320px' }"
-                :placeholder="$t('璇疯緭鍏�')"
-              />
-            </a-form-item>
-          </a-form>
-        </a-col>
-        <a-divider style="height: 40px" direction="vertical" />
-        <a-col :flex="'200px'" style="text-align: right">
-          <a-button @click="reset" style="margin-right: 20px">
-            <template #icon>
-              <icon-refresh />
-            </template>
-            {{ $t('searchTable.form.reset') }}
-          </a-button>
-          <a-button type="primary" @click="search">
-            <template #icon>
-              <icon-search />
-            </template>
-            {{ $t('searchTable.form.search') }}
-          </a-button>
-        </a-col>
-      </a-row>
-      <a-divider style="margin-top: 0" />
-      <a-row style="margin-bottom: 16px">
-        <a-col :span="12">
-          <a-space>
-            <a-button type="primary" :align="'right'" @click="operation(0)"
-              >+ 鏂板缓璐︽埛</a-button
+    <a-card ref="account" class="general-card">
+      <div class="table-page-search-wrapper">
+        <div class="search-wrapper">
+          <div>
+            <a-input
+              v-model="formModel.name"
+              :style="{ width: '320px' }"
+              :placeholder="$t('璇疯緭鍏�')"
+            />
+          </div>
+          <div>
+            <a-button
+              type="primary"
+              @click="search"
+              style="margin-right: 20px; margin-left: 10px"
             >
-          </a-space>
-        </a-col>
-        <a-col
-          :span="12"
-          style="display: flex; align-items: center; justify-content: end"
-        >
-          <a-tooltip :content="$t('searchTable.actions.refresh')">
-            <div class="action-icon" @click="search">
-              <icon-refresh size="18" />
-            </div>
-          </a-tooltip>
-          <a-dropdown @select="handleSelectDensity">
-            <a-tooltip :content="$t('searchTable.actions.density')">
-              <div class="action-icon">
-                <icon-line-height size="18" />
+              <template #icon>
+                <icon-search />
+              </template>
+              {{ $t('searchTable.form.search') }}
+            </a-button>
+            <a-button @click="reset">
+              <template #icon>
+                <icon-refresh />
+              </template>
+              {{ $t('searchTable.form.reset') }}
+            </a-button>
+          </div>
+        </div>
+        <div class="search-wrapper">
+          <div>
+            <a-space>
+              <a-button type="primary" :align="'right'" @click="operation(0)"
+                >+ 鏂板缓璐︽埛</a-button
+              >
+            </a-space></div
+          >
+          <div class="wrapper-icon">
+            <a-tooltip :content="$t('searchTable.actions.refresh')">
+              <div class="action-icon" @click="search">
+                <icon-refresh size="18" />
               </div>
             </a-tooltip>
-            <template #content>
-              <a-doption
-                v-for="item in densityList"
-                :key="item.value"
-                :value="item.value"
-                :class="{ active: item.value === size }"
-              >
-                <span>{{ item.name }}</span>
-              </a-doption>
-            </template>
-          </a-dropdown>
-        </a-col>
-      </a-row>
+            <a-dropdown @select="handleSelectDensity">
+              <a-tooltip :content="$t('searchTable.actions.density')">
+                <div class="action-icon">
+                  <icon-line-height size="18" />
+                </div>
+              </a-tooltip>
+              <template #content>
+                <a-doption
+                  v-for="item in densityList"
+                  :key="item.value"
+                  :value="item.value"
+                  :class="{ active: item.value === size }"
+                >
+                  <span>{{ item.name }}</span>
+                </a-doption>
+              </template>
+            </a-dropdown>
+          </div>
+        </div>
+      </div>
       <a-table
         row-key="id"
         :loading="loading"
@@ -81,9 +77,6 @@
         <template #index="{ rowIndex }">
           {{ rowIndex + 1 + (pagination.current - 1) * pagination.pageSize }}
         </template>
-        <template #dept="{ record }">{{
-          record.dept ? record.dept.deptName : ''
-        }}</template>
         <template #status="{ record }">
           <a-switch
             checked-value="1"
@@ -93,23 +86,33 @@
           />
         </template>
         <template #operations="{ record }">
-          <a-button type="outline" @click="operation(1, record)"
-            >閲嶇疆瀵嗙爜</a-button
-          >
-          <a-button type="outline" @click="operation(2, record)">缂栬緫</a-button>
-          <a-popconfirm
-            content="Are you sure you want to delete?"
-            type="success"
-            @ok="operation(3, record)"
-          >
-            <a-button type="outline">鍒犻櫎</a-button>
-          </a-popconfirm>
-          <a-button type="outline" @click="operation(4, record)"
-            >鏉冮檺閰嶇疆</a-button
-          >
-          <a-button type="outline" @click="operation(5, record)"
-            >閮ㄩ棬閰嶇疆</a-button
-          >
+          <a-space>
+            <a-button
+              type="outline"
+              status="success"
+              @click="operation(1, record)"
+              >閲嶇疆瀵嗙爜</a-button
+            >
+            <a-button type="outline" @click="operation(2, record)"
+              >缂栬緫</a-button
+            >
+            <a-popconfirm
+              content="璇风‘璁ゆ槸鍚﹀垹闄わ紵"
+              type="success"
+              @ok="operation(3, record)"
+            >
+              <a-button type="outline" status="danger">鍒犻櫎</a-button>
+            </a-popconfirm>
+            <a-button
+              type="dashed"
+              status="warning"
+              @click="operation(4, record)"
+              >鏌ョ湅鏉冮檺</a-button
+            >
+            <a-button status="success" @click="operation(5, record)"
+              >閮ㄩ棬閰嶇疆</a-button
+            >
+          </a-space>
         </template>
       </a-table>
     </a-card>
@@ -118,20 +121,71 @@
       :title="save"
       @cancel="handleCancel(1)"
       @ok="editHandleOk"
+      width="48%"
     >
-      <a-form :model="editform">
-        <a-form-item field="name" label="鏄电О">
-          <a-input v-model="editform.nickName" />
-        </a-form-item>
-        <a-form-item field="userName" label="鐢ㄦ埛鍚�">
-          <a-input v-model="editform.userName" />
-        </a-form-item>
-        <a-form-item field="phoneNumber" label="鎵嬫満鍙�">
-          <a-input v-model="editform.phoneNumber" />
-        </a-form-item>
-        <a-form-item field="email" label="閭">
-          <a-input v-model="editform.email" />
-        </a-form-item>
+      <a-form ref="formRef" :model="editform" auto-label-width>
+        <a-row :gutter="20">
+          <a-col :span="10">
+            <a-form-item
+              field="loginName"
+              label="鐢ㄦ埛鍚�"
+              :rules="[
+                { required: true, message: '鐢ㄦ埛鍚嶅繀濉�' },
+                { maxLength: 50, message: '闀垮害涓嶈秴杩�50' },
+              ]"
+            >
+              <a-input v-model="editform.loginName" />
+            </a-form-item>
+          </a-col>
+          <a-col :span="10">
+            <a-form-item field="userName" label="濮撳悕">
+              <a-input v-model="editform.userName" />
+            </a-form-item>
+          </a-col>
+        </a-row>
+        <a-row :gutter="20">
+          <a-col :span="10">
+            <a-form-item field="phoneNumber" label="鎵嬫満鍙�">
+              <a-input v-model="editform.phoneNumber" />
+            </a-form-item>
+          </a-col>
+          <a-col :span="10">
+            <a-form-item
+              required
+              field="email"
+              label="閭"
+              :rules="[
+                { required: true, message: '閭蹇呭~' },
+                { maxLength: 50, message: '闀垮害涓嶈秴杩�50' },
+              ]"
+            >
+              <a-input v-model="editform.email" />
+            </a-form-item>
+          </a-col>
+        </a-row>
+        <a-row :gutter="20">
+          <a-col :span="10">
+            <a-form-item field="psw" label="瀵嗙爜">
+              <a-input v-model="editform.psw" />
+            </a-form-item>
+          </a-col>
+          <a-col :span="10">
+            <a-form-item
+              required
+              field="role"
+              label="瑙掕壊"
+              :rules="[{ required: true, message: '瑙掕壊蹇呴��' }]"
+            >
+              <a-select
+                v-model="editform.role"
+                :options="roles"
+                :field-names="fieldNames"
+                @change="roleChange"
+              >
+              </a-select>
+            </a-form-item>
+          </a-col>
+        </a-row>
       </a-form>
     </a-modal>
     <a-modal
@@ -160,7 +214,6 @@
               title: 'deptName',
               children: 'children',
             }"
-            :check-strictly="checkStrictly"
           >
           </a-tree>
         </a-card>
@@ -178,85 +231,19 @@
       </div>
     </a-modal>
     <a-modal
-      width="30%"
+      width="50%"
       v-model:visible="resourcevisible"
-      title="鏉冮檺閰嶇疆"
-      @cancel="handleCancel(3)"
-      @ok="editResourceHandleOk"
+      v-if="resourcevisible"
+      title="鐢ㄦ埛鎵�鏈夋潈闄�"
+      okText="鍏抽棴"
+      hide-Cancel="true"
+      @ok="handleCancel(3)"
     >
       <div :style="{ 'display': 'flex', 'flex-direction': 'column' }">
-        <a-tabs
-          :style="{ 'width': '100%', 'height': '500px', 'overflow-y': 'auto' }"
-        >
-          <a-tab-pane key="1">
-            <template #title>
-              <icon-calendar />
-              鑿滃崟
-            </template>
-            <a-tree
-              class="tree-demo"
-              v-model:checked-keys="checkedKeysMenu"
-              v-model:expanded-keys="expandKdysMenu"
-              :checkable="true"
-              :data="treeDataMenu"
-              :show-line="showLineMenu"
-              @check="onCheckMenu"
-              :fieldNames="{
-                key: 'menuId',
-                title: 'menuName',
-                children: 'children',
-              }"
-              :check-strictly="checkStrictlyMenu"
-            >
-            </a-tree>
-          </a-tab-pane>
-          <a-tab-pane key="2">
-            <template #title>
-              <icon-clock-circle />
-              鐭ヨ瘑搴�
-            </template>
-            <a-space direction="vertical" size="large">
-              <a-checkbox-group
-                v-model="checkedKeysKnowledge"
-                direction="vertical"
-                @change="onCheckKnowledge"
-              >
-                <a-checkbox
-                  v-for="(knowledg, index) of knowledgeList"
-                  :value="knowledg.id"
-                  :lable="knowledg.name"
-                  @change="onCheckKnowledge"
-                >
-                  {{ knowledg.name }}
-                </a-checkbox>
-              </a-checkbox-group>
-            </a-space>
-          </a-tab-pane>
-          <a-tab-pane key="3">
-            <template #title>
-              <icon-user />
-              鏅鸿兘浣�
-            </template>
-            <a-checkbox-group
-              v-model="checkedKeysDialog"
-              direction="vertical"
-              @change="onCheckDialog"
-            >
-              <a-checkbox
-                v-for="(dialog, index) of DialogsList"
-                :value="dialog.id"
-                :lable="dialog.name"
-                @change="onCheckDialog"
-              >
-                {{ dialog.name }}
-              </a-checkbox>
-            </a-checkbox-group>
-          </a-tab-pane>
-        </a-tabs>
         <a-card
           :style="{
             'width': '100%',
-            'height': '200px',
+            'height': '40%',
             'overflow-y': 'auto',
             'margin': '1px',
           }"
@@ -266,11 +253,7 @@
         >
           <a-space wrap>
             鑿滃崟鍔熻兘锛�
-            <a-tag
-              v-for="(tag, index) of checkStrictlyMenu"
-              :key="tag.menuId"
-              @close="handleMenuRemove(tag)"
-            >
+            <a-tag v-for="(tag, index) of checkStrictlyMenu" :key="tag.menuId">
               {{ tag.menuName }}
             </a-tag>
           </a-space>
@@ -280,7 +263,6 @@
             <a-tag
               v-for="(tag, index) of checkStrictlyKnowledge"
               :key="tag.knowledgeId"
-              @close="handleKnowledgeRemove(tag)"
             >
               {{ tag.knowledgeName }}
             </a-tag>
@@ -291,9 +273,14 @@
             <a-tag
               v-for="(tag, index) of checkStrictlyDialog"
               :key="tag.dialogId"
-              @close="handleDialogRemove(tag)"
             >
               {{ tag.dialogName }}
+            </a-tag>
+            <a-tag
+              v-for="(tag, index) of checkStrictlyAgent"
+              :key="tag.agentId"
+            >
+              {{ tag.agentName }}
             </a-tag>
           </a-space>
         </a-card>
@@ -303,7 +290,7 @@
 </template>
 
 <script lang="ts" setup>
-  import { computed, reactive, ref } from 'vue';
+  import { computed, reactive, ref, h, onMounted } from 'vue';
   import { useI18n } from 'vue-i18n';
   import useLoading from '@/hooks/loading';
   import { Pagination } from '@/types/global';
@@ -313,6 +300,8 @@
     KnowledgeList,
     OrganizationList,
     ResourceList,
+    Role,
+    RoleList,
     User,
     UserAdd,
     UserChangePwd,
@@ -323,25 +312,22 @@
   } from '@/api/authority';
   import { Modal } from '@arco-design/web-vue';
   import Authheader from '@/views/authority/components/authheader.vue';
+  import { create } from 'lodash';
+  import { queryCanvasList } from '@/api/Agent';
+
+  const fieldNames = { value: 'roleId', label: 'roleName' };
+  const roles = ref([]);
 
   let treeData = ref([]);
   let checkedKeys = ref([]);
   let expandKdys = ref([]);
   let checkStrictly = ref([]);
-
-  let treeDataMenu = ref([]);
-  let checkedKeysMenu = ref([]);
-  let expandKdysMenu = ref([]);
   let checkStrictlyMenu = ref([]);
-
-  let checkedKeysKnowledge = ref([]);
   let checkStrictlyKnowledge = ref([]);
-
-  let checkedKeysDialog = ref([]);
   let checkStrictlyDialog = ref([]);
+  let checkStrictlyAgent = ref([]);
+  let formRef = ref();
 
-  let knowledgeList = ref([]);
-  let DialogsList = ref([]);
 
   let menuTips = ref(['鏉冮檺绠$悊', '璐﹀彿']);
   type SizeProps = 'mini' | 'small' | 'medium' | 'large';
@@ -360,12 +346,16 @@
   let editform = ref<User>({
     createTime: '',
     dept: undefined,
+    deptName: '',
     email: '',
     nickName: '',
     phoneNumber: '',
     status: '',
     userId: '',
+    loginName: '',
     userName: '',
+    psw: '',
+    role: '',
   });
 
   let size = ref<SizeProps>('medium');
@@ -373,6 +363,16 @@
   let deptvisible = ref(false);
   let resourcevisible = ref(false);
   let selectUser = ref({});
+
+  const loadRole = async () => {
+    await RoleList(null).then((res) => {
+      roles.value = res.rows;
+    });
+  };
+
+  const roleChange = (val) => {
+    editform.value.role = val;
+  };
 
   const onCheck = (newCheckedKeys, event) => {
     let o = { deptId: event.node.deptId, deptName: event.node.deptName };
@@ -388,78 +388,10 @@
       });
     }
   };
-  const onCheckMenu = (newCheckedKeys, event) => {
-    let o = { menuId: event.node.menuId, menuName: event.node.menuName };
-    if (event.checked) {
-      checkStrictlyMenu.value.push(o);
-    } else {
-      checkStrictlyMenu.value.forEach((val, idx, array) => {
-        // val: 褰撳墠鍊�
-        if (val.menuId == event.node.menuId) {
-          checkStrictlyMenu.value.splice(idx, 1);
-          return true;
-        }
-      });
-    }
-  };
-  const onCheckKnowledge = (newCheckedKeys, event) => {
-    let o = {
-      knowledgeId: event.target.value,
-      knowledgeName: event.target.labels[0].innerText,
-    };
-    if (event.target.checked) {
-      checkStrictlyKnowledge.value.push(o);
-    } else {
-      checkStrictlyKnowledge.value.forEach((val, idx, array) => {
-        // val: 褰撳墠鍊�
-        if (val.knowledgeId == event.target.value) {
-          checkStrictlyKnowledge.value.splice(idx, 1);
-          return true;
-        }
-      });
-    }
-  };
-
-  const onCheckDialog = (newCheckedKeys, event) => {
-    let o = {
-      dialogId: event.target.value,
-      dialogName: event.target.labels[0].innerText,
-    };
-    if (event.target.checked) {
-      checkStrictlyDialog.value.push(o);
-    } else {
-      checkStrictlyDialog.value.forEach((val, idx, array) => {
-        // val: 褰撳墠鍊�
-        if (val.dialogId == event.target.value) {
-          checkStrictlyDialog.value.splice(idx, 1);
-          return true;
-        }
-      });
-    }
-  };
-
-  const handleRemove = (key) => {
-    checkStrictly.value = checkStrictly.value.filter((tag) => tag !== key);
-  };
-  const handleMenuRemove = (key) => {
-    checkStrictlyMenu.value = checkStrictlyMenu.value.filter(
-      (tag) => tag !== key
-    );
-  };
-  const handleKnowledgeRemove = (key) => {
-    checkStrictlyKnowledge.value = checkStrictlyKnowledge.value.filter(
-      (tag) => tag !== key
-    );
-  };
-  const handleDialogRemove = (key) => {
-    checkStrictlyDialog.value = checkStrictlyDialog.value.filter(
-      (tag) => tag !== key
-    );
-  };
 
   const basePagination: Pagination = {
     current: 1,
-    pageSize: 20,
+    pageSize: 15,
   };
   const pagination = reactive({
     ...basePagination,
@@ -491,16 +423,16 @@
     },
     {
       title: t('鐢ㄦ埛鍚�'),
-      dataIndex: 'userName',
+      dataIndex: 'loginName',
     },
     {
-      title: t('鍒涘缓鏃堕棿'),
-      dataIndex: 'createTime',
+      title: t('瑙掕壊'),
+      dataIndex: 'roleName',
     },
     {
       title: t('鎵�灞為儴闂�'),
-      dataIndex: 'dept',
-      slotName: 'dept',
+      dataIndex: 'deptName',
+      slotName: 'deptName',
     },
     {
       title: t('鐘舵��'),
@@ -515,7 +447,16 @@
   ]);
 
   const statusChange = async (value, record) => {
-    await Userstatus(record.userId, value).then((res) => {});
+    if (record?.dept) {
+      await Userstatus(record.userId, value).then((res) => {
+      });
+    } else {
+      record.status = "0";
+      Modal.warning({
+        title: '鎻愮ず',
+        content: '濡傛兂鍚敤鐢ㄦ埛锛岄渶杩涜閮ㄩ棬閰嶇疆.'
+      });
+    }
   };
 
   const handleCancel = (type) => {
@@ -524,9 +465,6 @@
     }
     if (type == 2) {
       deptvisible.value = false;
-    }
-    if (type == 2) {
-      resourcevisible.value = false;
     }
   };
 
@@ -542,45 +480,35 @@
     });
   };
 
-  const editResourceHandleOk = async () => {
-    let resources: Array = [],
-      dialogs: Array = [],
-      Knowledges: Array = [],
-      user: User = { userId: selectUser.value.userId };
-    checkStrictlyMenu.value.forEach((val) => {
-      resources.push(val.menuId);
-    });
-    user.resources = resources;
-
-    checkStrictlyKnowledge.value.forEach((val) => {
-      Knowledges.push(val.knowledgeId);
-    });
-    user.knowledges = Knowledges;
-
-    checkStrictlyDialog.value.forEach((val) => {
-      dialogs.push(val.dialogId);
-    });
-    user.dialogs = dialogs;
-
-    await UserEdit(user).then((res) => {
-      fetchData();
-    });
-  };
-
-  const editHandleOk = async () => {
-    if (editform.value.userId.length > 0) {
-      await UserEdit({
-        ...editform.value,
-      } as unknown as User).then((res) => {
-        fetchData();
-      });
+  const cb = async (err) => {
+    if (err) {
+      visible.value = true;
     } else {
-      await UserAdd({
-        ...editform.value,
-      } as unknown as User).then((res) => {
-        fetchData();
-      });
+      let uuu;
+      if (editform.value.userId.length > 0) {
+        await UserEdit({
+          ...editform.value,
+        } as unknown as User).then((res) => {
+          fetchData();
+          uuu=res.data;
+        });
+      } else {
+        await UserAdd({
+          ...editform.value,
+        } as unknown as User).then((res) => {
+          fetchData();
+          uuu=res.data;
+        });
+      }
+      deptvisible.value = true;
+      checkedKeys.value = [];
+      expandKdys.value = [];
+      checkStrictly.value = [];
+      selectUser.value = uuu;
     }
+  };
+  const editHandleOk = () => {
+    formRef.value.validate(cb);
   };
   const operation = async (t, record) => {
     if (t == 0) {
@@ -588,9 +516,11 @@
       visible.value = true;
       editform.value.userId = '';
       editform.value.userName = '';
+      editform.value.loginName = '';
       editform.value.nickName = '';
       editform.value.email = '';
       editform.value.phoneNumber = '';
+      editform.value.role = '';
     }
     //閲嶇疆瀵嗙爜
     if (t == 1) {
@@ -611,17 +541,21 @@
     //缂栬緫
     if (t == 2) {
       visible.value = true;
+      formRef.value?.resetFields();
       save.value = '缂栬緫';
       editform.value.userId = record.userId;
       editform.value.userName = record.userName;
-      editform.value.nickName = record.nickName;
+      editform.value.loginName = record.loginName;
       editform.value.email = record.email;
       editform.value.phoneNumber = record.phoneNumber;
+      if (record.roles?.length > 0) {
+        editform.value.role = record.roles[0].roleId;
+      }
     }
     //鍒犻櫎
     if (t == 3) {
       await UserDelete(record.userId).then((res) => {
-        if (res.code == 20000) {
+        if (res.code == 200) {
           fetchData();
         }
       });
@@ -629,36 +563,63 @@
     //鏉冮檺
     if (t == 4) {
       resourcevisible.value = true;
-      checkedKeysMenu.value = [];
-      expandKdysMenu.value = [];
       checkStrictlyMenu.value = [];
       checkStrictlyKnowledge.value = [];
-      checkedKeysKnowledge.value = [];
       checkStrictlyDialog.value = [];
-      checkedKeysDialog.value = [];
+      checkStrictlyAgent.value = [];
       selectUser.value = record;
-      record.resources.forEach((val) => {
-        checkStrictlyMenu.value.push({
-          menuId: val.menuId,
-          menuName: val.menuName,
+
+      let agents;
+      if (record.agents) {
+        agents = record.agents;
+      } else {
+        agents = record.roles ? record.roles[0].agents : null;
+      }
+      if (agents) {
+        agents.forEach((val) => {
+          checkStrictlyAgent.value.push({
+            agentId: val.id,
+            agentName: val.title,
+          });
         });
-        checkedKeysMenu.value.push(val.menuId);
-        expandKdysMenu.value.push(val.menuId);
-      });
-      record.knowledges.forEach((val) => {
-        checkStrictlyKnowledge.value.push({
-          knowledgeId: val.id,
-          knowledgeName: val.name,
+      }
+      let resources;
+      if (record.resources) {
+        resources = record.resources;
+      } else {
+        resources = record.roles ? record.roles[0].resources : null;
+      }
+      if (resources) {
+        resources.forEach((val) => {
+          checkStrictlyMenu.value.push({
+            menuId: val.menuId,
+            menuName: val.menuName,
+          });
         });
-        checkedKeysKnowledge.value.push(val.id);
-      });
-      record.dialogs.forEach((val) => {
-        checkStrictlyDialog.value.push({
-          dialogId: val.id,
-          dialogName: val.name,
+      }
+      let knowledges;
+      if (record.knowledges) {
+        knowledges = record.knowledges;
+      } else {
+        knowledges = record.roles ? record.roles[0].knowledges : null;
+      }
+      if (knowledges) {
+        knowledges.forEach((val) => {
+          checkStrictlyKnowledge.value.push({
+            knowledgeId: val.id,
+            knowledgeName: val.name,
+          });
         });
-        checkedKeysDialog.value.push(val.id);
-      });
+      }
+      let dialogs = record.roles ? record.roles[0].dialogs : null;
+      if (dialogs) {
+        dialogs.forEach((val) => {
+          checkStrictlyDialog.value.push({
+            dialogId: val.id,
+            dialogName: val.name,
+          });
+        });
+      }
     }
     //鏈烘瀯
     if (t == 5) {
@@ -668,14 +629,16 @@
       checkStrictly.value = [];
       selectUser.value = record;
       expandKdys.value.push('0');
-      record.dept.forEach((val) => {
-        checkStrictly.value.push({
-          deptId: val.deptId,
-          deptName: val.deptName,
+      if (record?.dept) {
+        record.dept.forEach((val) => {
+          checkStrictly.value.push({
+            deptId: val.deptId,
+            deptName: val.deptName,
+          });
+          checkedKeys.value.push(val.deptId);
+          expandKdys.value.push(val.deptId);
         });
-        checkedKeys.value.push(val.deptId);
-        expandKdys.value.push(val.deptId);
-      });
+      }
     }
   };
 
@@ -685,6 +648,26 @@
     setLoading(true);
     try {
       await UserList(params).then((res) => {
+        for (const user of res.rows) {
+          if (user.dept) {
+            for (const d of user.dept) {
+              if (user.deptName) {
+                user.deptName += d.deptName + ',';
+              } else {
+                user.deptName = d.deptName + ',';
+              }
+            }
+          }
+          if (user.roles) {
+            for (const r of user.roles) {
+              if (user.roleName) {
+                user.roleName += r.roleName + ',';
+              } else {
+                user.roleName = r.roleName + ',';
+              }
+            }
+          }
+        }
         renderData.value = res.rows;
         console.log(renderData);
         pagination.current = params.current;
@@ -713,22 +696,10 @@
       treeData.value = [...res.rows];
     });
   };
-  const MenuData = async (key) => {
-    await ResourceList(key).then((res) => {
-      treeDataMenu.value = [...res.rows];
-    });
-  };
 
-  KnowledgeList().then((res) => {
-    knowledgeList.value = res.rows;
-  });
-
-  DialogList().then((res) => {
-    DialogsList.value = res.rows;
-  });
   fetchData();
   OrganizationData('');
-  MenuData();
+  loadRole();
 
   const reset = () => {
     formModel.value = generateFormModel();
@@ -742,7 +713,7 @@
   };
 </script>
 
-<style scoped>
+<style scoped lang="less">
   .card-demo {
     width: 460px;
     margin-left: 24px;
@@ -752,4 +723,126 @@
   .card-demo:hover {
     transform: translateY(-4px);
   }
+  .table-page-search-wrapper {
+    padding-top: 10px;
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+    margin-bottom: 20px;
+    padding-bottom: 10px;
+    border-bottom: 1px solid #e8e8e8;
+    .search-wrapper {
+      display: flex;
+      .wrapper-icon {
+        display: flex;
+        align-items: center;
+        margin-left: 40px;
+        // margin-right: 40px;
+      }
+    }
+  }
+  .space_select_all {
+    display: flex;
+    justify-content: end;
+    margin-bottom: 15px;
+  }
+  .table_box {
+    display: flex;
+
+    border: 1px solid #e8e8e8;
+    border-bottom: none;
+    .row1_clo {
+      min-width: 200px;
+      display: flex;
+      padding-left: 20px;
+      border-right: 1px solid #e8e8e8;
+    }
+    .table_row1 {
+      width: 100%;
+      .row1_list {
+        display: flex;
+        min-height: 40px;
+        border-bottom: 1px solid #e8e8e8;
+        // line-height: 40px;
+      }
+    }
+    .row1_clo2 {
+      width: 100%;
+      border-top: none;
+      .row2_clo2_1 {
+        display: flex;
+        width: 100%;
+        min-height: 40px;
+        line-height: 40px;
+        border-bottom: 1px solid #e8e8e8;
+        .row1_clo2_1 {
+          border-right: 1px solid #e8e8e8;
+          min-width: 310px;
+          padding-left: 20px;
+        }
+        .row1_clo2_2 {
+          border-top: none;
+          border-right: none;
+          width: 100%;
+          display: flex;
+          flex-wrap: wrap;
+          div {
+            margin-left: 20px;
+          }
+        }
+      }
+    }
+    .row2_clo2_1:last-child {
+      border-bottom: none;
+    }
+  }
+</style>
+<style lang="less">
+  .ant-table-wrapper {
+    .ant-table-tbody {
+      tr {
+        td {
+          .ant-table-row-cell-break-word {
+            .ant-table-column-sorter {
+              display: none;
+            }
+          }
+        }
+      }
+    }
+
+    .search-wrapper {
+      display: flex;
+      .wrapper-icon {
+        display: flex;
+        align-items: center;
+        margin-left: 40px;
+        // margin-right: 40px;
+      }
+    }
+  }
+</style>
+<style lang="less">
+  .ant-table-wrapper {
+    .ant-table-tbody {
+      tr {
+        td {
+          .ant-table-row-cell-break-word {
+            .ant-table-column-sorter {
+              display: none;
+            }
+          }
+        }
+      }
+    }
+  }
+</style>
+<style lang="less" scoped>
+  .table-page-search-wrapper {
+    .ant-form-inline {
+      :deep(.ant-form-item) {
+        display: flex;
+      }
+    }
+  }
 </style>

--
Gitblit v1.8.0