From ac4341ea6b66ae02427d39d35f41d42d78b2eb2e Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期五, 14 二月 2025 10:08:32 +0800
Subject: [PATCH] #

---
 zy-asrs-admin/src/views/system/user/index.vue |  500 +++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 353 insertions(+), 147 deletions(-)

diff --git a/zy-asrs-admin/src/views/system/user/index.vue b/zy-asrs-admin/src/views/system/user/index.vue
index 37c97b1..d5db92f 100644
--- a/zy-asrs-admin/src/views/system/user/index.vue
+++ b/zy-asrs-admin/src/views/system/user/index.vue
@@ -6,6 +6,9 @@
 import { logout } from '@/config.js';
 import EditView from './edit.vue'
 import { formatMessage } from '@/utils/localeUtils.js';
+import {
+  DownOutlined,
+} from "@ant-design/icons-vue";
 const context = getCurrentInstance()?.appContext.config.globalProperties;
 
 const router = useRouter();
@@ -16,123 +19,140 @@
 const searchInput = ref("")
 const editChild = ref(null)
 
-let tableData = ref([]);
-getPage();
-
-const columns = [
-        {
-            title: '璐﹀彿',
-            dataIndex: 'username',
-            width: 140,
-        },
-        {
-            title: '瀵嗙爜',
-            dataIndex: 'password',
-            width: 140,
-        },
-        {
-            title: '鏄电О',
-            dataIndex: 'nickname',
-            width: 140,
-        },
-        {
-            title: '澶村儚',
-            dataIndex: 'avatar',
-            width: 140,
-        },
-        {
-            title: '宸ュ彿',
-            dataIndex: 'code',
-            width: 140,
-        },
-        {
-            title: '鎬у埆',
-            dataIndex: 'sex$',
-            width: 140,
-        },
-        {
-            title: '鎵嬫満鍙�',
-            dataIndex: 'phone',
-            width: 140,
-        },
-        {
-            title: '閭',
-            dataIndex: 'email',
-            width: 140,
-        },
-        {
-            title: '閭楠岃瘉',
-            dataIndex: 'emailVerified$',
-            width: 140,
-        },
-        {
-            title: '鎵�灞為儴闂�',
-            dataIndex: 'deptId$',
-            width: 140,
-        },
-        {
-            title: '鐪熷疄濮撳悕',
-            dataIndex: 'realName',
-            width: 140,
-        },
-        {
-            title: '韬唤璇佸彿',
-            dataIndex: 'idCard',
-            width: 140,
-        },
-        {
-            title: '鍑虹敓鏃ユ湡',
-            dataIndex: 'birthday',
-            width: 140,
-        },
-        {
-            title: '涓汉绠�浠�',
-            dataIndex: 'introduction',
-            width: 140,
-        },
-        {
-            title: '鐘舵��',
-            dataIndex: 'status$',
-            width: 140,
-        },
-        {
-            title: '娣诲姞鏃堕棿',
-            dataIndex: 'createTime$',
-            width: 140,
-        },
-        {
-            title: '娣诲姞浜哄憳',
-            dataIndex: 'createBy$',
-            width: 140,
-        },
-        {
-            title: '淇敼鏃堕棿',
-            dataIndex: 'updateTime$',
-            width: 140,
-        },
-        {
-            title: '淇敼浜哄憳',
-            dataIndex: 'updateBy$',
-            width: 140,
-        },
-        {
-            title: '澶囨敞',
-            dataIndex: 'memo',
-            width: 140,
-        },
-
-  {
-    title: '鎿嶄綔',
-    name: 'oper',
-    dataIndex: 'oper',
-    key: 'oper',
-  },
-];
-
 const state = reactive({
   selectedRowKeys: [],
   loading: false,
 });
+
+let currentDept = ref(null);
+let tableData = ref([]);
+getPage();
+
+const columns = [
+  {
+    title: formatMessage('db.sys_user.username', '璐﹀彿'),
+    dataIndex: 'username',
+    width: 140,
+    ellipsis: true,
+  },
+  {
+    title: formatMessage('db.sys_user.nickname', '鏄电О'),
+    dataIndex: 'nickname',
+    width: 140,
+    ellipsis: true,
+  },
+  // {
+  //   title: formatMessage('db.sys_user.avatar', '澶村儚'),
+  //   dataIndex: 'avatar',
+  //   width: 140,
+  //   ellipsis: true,
+  // },
+  // {
+  //   title: formatMessage('db.sys_user.code', '宸ュ彿'),
+  //   dataIndex: 'code',
+  //   width: 140,
+  //   ellipsis: true,
+  // },
+  {
+    title: formatMessage('db.sys_user.sex', '鎬у埆'),
+    dataIndex: 'sex$',
+    width: 140,
+    ellipsis: true,
+  },
+  {
+    title: formatMessage('db.sys_user.phone', '鎵嬫満鍙�'),
+    dataIndex: 'phone',
+    width: 140,
+    ellipsis: true,
+  },
+  // {
+  //   title: formatMessage('db.sys_user.email', '閭'),
+  //   dataIndex: 'email',
+  //   width: 140,
+  //   ellipsis: true,
+  // },
+  // {
+  //   title: formatMessage('db.sys_user.email_verified', '閭楠岃瘉'),
+  //   dataIndex: 'emailVerified$',
+  //   width: 140,
+  //   ellipsis: true,
+  // },
+  {
+    title: formatMessage('db.sys_user.dept_id', '閮ㄩ棬'),
+    dataIndex: 'deptId$',
+    width: 140,
+    ellipsis: true,
+  },
+  // {
+  //   title: formatMessage('db.sys_user.real_name', '鐪熷疄濮撳悕'),
+  //   dataIndex: 'realName',
+  //   width: 140,
+  //   ellipsis: true,
+  // },
+  // {
+  //   title: formatMessage('db.sys_user.id_card', '韬唤璇佸彿'),
+  //   dataIndex: 'idCard',
+  //   width: 140,
+  //   ellipsis: true,
+  // },
+  // {
+  //   title: formatMessage('db.sys_user.birthday', '鍑虹敓鏃ユ湡'),
+  //   dataIndex: 'birthday',
+  //   width: 140,
+  //   ellipsis: true,
+  // },
+  // {
+  //   title: formatMessage('db.sys_user.introduction', '涓汉绠�浠�'),
+  //   dataIndex: 'introduction',
+  //   width: 140,
+  //   ellipsis: true,
+  // },
+  {
+    title: formatMessage('db.sys_user.status', '鐘舵��'),
+    dataIndex: 'status$',
+    width: 140,
+    ellipsis: true,
+  },
+  // {
+  //   title: formatMessage('db.sys_user.create_time', '娣诲姞鏃堕棿'),
+  //   dataIndex: 'createTime$',
+  //   width: 140,
+  //   ellipsis: true,
+  // },
+  // {
+  //   title: formatMessage('db.sys_user.create_by', '娣诲姞浜哄憳'),
+  //   dataIndex: 'createBy$',
+  //   width: 140,
+  //   ellipsis: true,
+  // },
+  // {
+  //   title: formatMessage('db.sys_user.update_time', '淇敼鏃堕棿'),
+  //   dataIndex: 'updateTime$',
+  //   width: 140,
+  //   ellipsis: true,
+  // },
+  // {
+  //   title: formatMessage('db.sys_user.update_by', '淇敼浜哄憳'),
+  //   dataIndex: 'updateBy$',
+  //   width: 140,
+  //   ellipsis: true,
+  // },
+  // {
+  //   title: formatMessage('db.sys_user.memo', '澶囨敞'),
+  //   dataIndex: 'memo',
+  //   width: 140,
+  //   ellipsis: true,
+  // },
+
+  {
+    title: formatMessage('common.operation', '鎿嶄綔'),
+    name: 'oper',
+    dataIndex: 'oper',
+    key: 'oper',
+    width: 240,
+  },
+];
+
 const hasSelected = computed(() => state.selectedRowKeys.length > 0);
 const start = () => {
   state.loading = true;
@@ -148,15 +168,20 @@
 };
 
 function getPage() {
-  post('/api/user/page', {
+  state.loading = true;
+
+  post('/api/user/page1', {
     current: currentPage,
     pageSize: pageSize,
-    condition: searchInput.value
+    condition: searchInput.value,
+    deptId: currentDept?.value?.id,
   }).then((resp) => {
     let result = resp.data;
     if (result.code == 200) {
       let data = result.data;
       tableData.value = data;
+
+      state.loading = false;
     } else if (result.code === 401) {
       message.error(result.msg);
       logout()
@@ -178,15 +203,21 @@
     content: formatMessage('page.delete.confirm', '纭畾鍒犻櫎璇ラ」鍚楋紵'),
     maskClosable: true,
     onOk: async () => {
-      post('/api/user/remove/' + rows.map((row) => row.id).join(','), {}).then(resp => {
-        let result = resp.data;
-        if (result.code === 200) {
-          message.success(result.msg);
-        } else {
-          message.error(result.msg);
-        }
-        getPage()
-      })
+      const hide = message.loading(formatMessage('common.loading', '璇锋眰涓�'));
+      try {
+        post('/api/user/remove/' + rows.map((row) => row.id).join(','), {}).then(resp => {
+          let result = resp.data;
+          if (result.code === 200) {
+            message.success(result.msg);
+          } else {
+            message.error(result.msg);
+          }
+          getPage()
+          hide()
+        })
+      } catch (error) {
+        message.error(formatMessage('common.fail', '璇锋眰澶辫触'));
+      }
     },
   });
 }
@@ -198,6 +229,86 @@
     return true;
   })
 };
+
+let openResetPass = ref(false);
+let currentResetPass = ref(null);
+let newPassword = ref("");
+const handleResetPass = (item) => {
+  openResetPass.value = true;
+  currentResetPass.value = item;
+}
+
+const handleResetPassSubmit = (e) => {
+  if (newPassword.value == '') {
+    message.warning(formatMessage('login.rule.password', '璇疯緭鍏ュ瘑鐮�'))
+    return;
+  }
+
+  post('/api/user/reset/pwd', {
+    id: currentResetPass.value.id,
+    password: newPassword.value
+  }).then((resp) => {
+    let result = resp.data;
+    if (result.code == 200) {
+      message.success(result.msg);
+      openResetPass.value = false;
+      currentResetPass.value = null;
+      newPassword.value = "";
+    } else if (result.code === 401) {
+      message.error(result.msg);
+      logout()
+    } else {
+      message.error(result.msg);
+    }
+  })
+}
+
+let openAssignRole = ref(false);
+let currentAssignRole = ref(null);
+let assignRoleData = ref([]);
+let currentCheckRole = ref([]);
+const handleAssignRole = (item) => {
+  openAssignRole.value = true;
+  currentAssignRole.value = item;
+  currentCheckRole.value = item.userRoleIds;
+}
+
+const handleAssignRoleSubmit = (e) => {
+  post('/api/user/update', {
+    id: currentAssignRole.value.id,
+    roleIds: currentCheckRole.value,
+  }).then((resp) => {
+    let result = resp.data;
+    if (result.code == 200) {
+      message.success(result.msg);
+      openAssignRole.value = false;
+      currentAssignRole.value = null;
+      currentCheckRole.value = [];
+      getPage()
+    } else if (result.code === 401) {
+      message.error(result.msg);
+      logout()
+    } else {
+      message.error(result.msg);
+    }
+  })
+}
+
+getAssignRoleData();
+function getAssignRoleData() {
+  post('/api/role/query', {}).then((resp) => {
+    let result = resp.data;
+    if (result.code == 200) {
+      let data = result.data;
+      assignRoleData.value = data;
+    } else if (result.code === 401) {
+      message.error(result.msg);
+      logout()
+    } else {
+      message.error(result.msg);
+    }
+  })
+}
 
 const onSearch = () => {
   // console.log('search');
@@ -214,6 +325,47 @@
   getPage()
 }
 
+let deptExpandedKeys = ref([]);
+let deptData = ref([]);
+let searchDept = ref("");
+getDeptData()
+function getDeptData() {
+  post('/api/dept/tree', {
+    current: currentPage,
+    pageSize: pageSize,
+    condition: searchDept.value
+  }).then((resp) => {
+    let result = resp.data;
+    if (result.code == 200) {
+      let data = result.data;
+      deptData.value = [{
+        id: null,
+        name: '鍏ㄩ儴',
+        children: data
+      }]
+    } else if (result.code === 401) {
+      message.error(result.msg);
+      logout()
+    } else {
+      message.error(result.msg);
+    }
+
+    deptExpandedKeys.value = ['0-0']
+  })
+}
+
+const handleDeptSelected = (selectedKeys, e) => {
+  currentDept.value = {
+    id: e.node.id,
+    name: e.node.name,
+  };
+  getPage()
+}
+
+const handleSearchDept = (e) => {
+  getDeptData()
+}
+
 </script>
 
 <script>
@@ -223,30 +375,84 @@
 </script>
 
 <template>
-  <div>
-    <EditView ref="editChild" @tableReload="handleTableReload" />
-    <div class="table-header">
-      <a-input-search v-model:value="searchInput" :placeholder="formatMessage('page.input', '璇疯緭鍏�')"
-        style="width: 200px;" @search="onSearch" />
-      <div class="table-header-right">
-        <a-button @click="handleEdit(null)" type="primary">{{ formatMessage('page.add', '娣诲姞') }}</a-button>
-        <a-button @click="handleExport">{{ formatMessage('page.export', '瀵煎嚭') }}</a-button>
-      </div>
-    </div>
-    <a-table :row-selection="{ selectedRowKeys: state.selectedRowKeys, onChange: onSelectChange }"
-      :data-source="tableData.records" :defaultExpandAllRows="false" :key="TABLE_KEY" rowKey="id"
-      :pagination="{ total: tableData.total, onChange: onPageChange }"
-      :scroll="{ y: 768, scrollToFirstRowOnChange: true }" :columns="columns">
-      <template #bodyCell="{ column, text, record }">
-        <template v-if="column.dataIndex === 'oper'">
-          <div style="display: flex;justify-content: space-evenly;">
-            <a-button type="link" primary @click="handleEdit(record)">{{ formatMessage('page.edit', '缂栬緫') }}</a-button>
-            <a-button type="link" danger @click="handleDel([record])">{{ formatMessage('page.delete', '鍒犻櫎')
-              }}</a-button>
-          </div>
+  <div style="display: flex;">
+    <a-card :title="formatMessage('common.dept', '閮ㄩ棬')" style="flex: 3;margin-right: 30px;">
+      <a-input v-model:value="searchDept" @change="handleSearchDept" :placeholder="formatMessage('page.input', '璇疯緭鍏�')"
+        style="margin-bottom: 8px" />
+      <a-tree v-model:expandedKeys="deptExpandedKeys" @select="handleDeptSelected" :tree-data="deptData" blockNode>
+        <template #title="{ name }">
+          <span>{{ name }}</span>
         </template>
-      </template>
-    </a-table>
+      </a-tree>
+    </a-card>
+
+    <a-card style="flex: 10;">
+      <EditView ref="editChild" @tableReload="handleTableReload" />
+      <div class="table-header">
+        <a-input-search v-model:value="searchInput" :placeholder="formatMessage('page.input', '璇疯緭鍏�')"
+          style="width: 200px;" @search="onSearch" />
+        <div class="table-header-right">
+          <a-button @click="handleEdit(null)" type="primary">{{ formatMessage('page.add', '娣诲姞') }}</a-button>
+          <a-button @click="handleExport">{{ formatMessage('page.export', '瀵煎嚭') }}</a-button>
+        </div>
+      </div>
+      <a-table :row-selection="{ selectedRowKeys: state.selectedRowKeys, onChange: onSelectChange }"
+        :data-source="tableData.records" :defaultExpandAllRows="false" :key="TABLE_KEY" rowKey="id"
+        :pagination="{ total: tableData.total, onChange: onPageChange }"
+        :scroll="{ y: 768, scrollToFirstRowOnChange: true }" :columns="columns" :loading="state.loading">
+        <template #bodyCell="{ column, text, record }">
+          <template v-if="column.dataIndex === 'oper'">
+            <div style="display: flex;justify-content: space-evenly;">
+              <a-button type="link" primary> <a-dropdown>
+                  <a class="ant-dropdown-link" @click.prevent>
+                    {{ formatMessage('common.operation', '鎿嶄綔') }}
+                    <DownOutlined />
+                  </a>
+                  <template #overlay>
+                    <a-menu>
+                      <a-menu-item>
+                        <a-button type="link" primary @click="handleResetPass(record)">
+                          {{ formatMessage('page.reset.pwd', '閲嶇疆瀵嗙爜') }}
+                        </a-button>
+                      </a-menu-item>
+                      <a-menu-item>
+                        <a-button type="link" primary @click="handleAssignRole(record)">
+                          {{ formatMessage('page.assign.role', '鍒嗛厤瑙掕壊') }}
+                        </a-button>
+                      </a-menu-item>
+                    </a-menu>
+                  </template>
+                </a-dropdown>
+              </a-button>
+              <a-button type="link" primary @click="handleEdit(record)">
+                {{ formatMessage('page.edit', '缂栬緫') }}
+              </a-button>
+              <a-button type="link" danger @click="handleDel([record])">
+                {{ formatMessage('page.delete', '鍒犻櫎') }}
+              </a-button>
+            </div>
+          </template>
+        </template>
+      </a-table>
+    </a-card>
+
+    <a-modal v-model:open="openResetPass" :title="formatMessage('page.reset.pwd', '閲嶇疆瀵嗙爜')" @ok="handleResetPassSubmit">
+      <a-form style="display: flex;justify-content: center;flex-wrap: wrap;" autocomplete="off">
+        <a-form-item :label="formatMessage('personal.security.new.pwd', '鏂板瘑鐮�')">
+          <a-input v-model:value="newPassword" />
+        </a-form-item>
+      </a-form>
+    </a-modal>
+
+    <a-modal v-model:open="openAssignRole" :title="formatMessage('page.assign.role', '鍒嗛厤瑙掕壊')"
+      @ok="handleAssignRoleSubmit">
+      <a-form style="display: flex;justify-content: center;flex-wrap: wrap;" autocomplete="off">
+        <a-form-item :label="formatMessage('page.assign.role', '瑙掕壊')">
+          <a-select v-model:value="currentCheckRole" :options="assignRoleData" mode="multiple" style="width: 380px;">
+          </a-select>
+        </a-form-item>
+      </a-form>
+    </a-modal>
   </div>
 </template>
 

--
Gitblit v1.9.1