zhupei@smartai.com 1 gadu atpakaļ
vecāks
revīzija
ecc76c17bc
1 mainītis faili ar 192 papildinājumiem un 160 dzēšanām
  1. 192 160
      src/modules/permission/role/index.vue

+ 192 - 160
src/modules/permission/role/index.vue

@@ -1,9 +1,22 @@
 <template>
   <a-card class="account-page-card">
-    <Action :btn_text="'新建角色'" @searchClick="searchClick" @resetClick="resetClick" @createClick="createClick"
-      @sizeChange="tableSizeChange" @refreshClick="refreshClick"></Action>
-    <DataTable :data="table_data" :columns="table_columns" row-key="roleId" :size="table_size" :loading="table_loading"
-      :pagination="pagination_props" @pageChange="handlePageChange">
+    <Action
+      :btn_text="'新建角色'"
+      @searchClick="searchClick"
+      @resetClick="resetClick"
+      @createClick="createClick"
+      @sizeChange="tableSizeChange"
+      @refreshClick="refreshClick"
+    ></Action>
+    <DataTable
+      :data="table_data"
+      :columns="table_columns"
+      row-key="roleId"
+      :size="table_size"
+      :loading="table_loading"
+      :pagination="pagination_props"
+      @pageChange="handlePageChange"
+    >
       <template #status="{ record }">
         <a-switch v-model="record.status" @change="statusChange(record)" checked-value="1" unchecked-value="0" />
       </template>
@@ -18,17 +31,30 @@
     </DataTable>
   </a-card>
 
-  <Modal :visible.sync="edit_visible" @ok="modalSave" @cancel="handleEdit(null, false)"
-    :title="is_edit_mode ? '编辑' : '新增'">
+  <Modal
+    :visible.sync="edit_visible"
+    @ok="modalSave"
+    @cancel="handleEdit(null, false)"
+    :title="is_edit_mode ? '编辑' : '新增'"
+  >
     <RoleForm :edit_form="edit_form" :is_edit_mode="is_edit_mode" />
   </Modal>
 
-  <PermissionConfigModal :visible.sync="permission_config_visible" :menu_list="menu_list" :record="current_record"
-    @ok="handlePermissionConfigSave" @cancel="handlePermissionConfig(null, false)" />
-
-  <DeptConfigModal :visible.sync="dept_config_visible" :dept_list="dept_list" :record="current_record"
-    @ok="handleDeptConfigSave" @cancel="handleDeptConfig(null, false)" />
+  <PermissionConfigModal
+    :visible.sync="permission_config_visible"
+    :menu_list="menu_list"
+    :record="current_record"
+    @ok="handlePermissionConfigSave"
+    @cancel="handlePermissionConfig(null, false)"
+  />
 
+  <DeptConfigModal
+    :visible.sync="dept_config_visible"
+    :dept_list="dept_list"
+    :record="current_record"
+    @ok="handleDeptConfigSave"
+    @cancel="handleDeptConfig(null, false)"
+  />
 </template>
 
 <script setup>
@@ -42,7 +68,7 @@ import PermissionConfigModal from './PermissionConfigModal.vue';
 import DeptConfigModal from './DeptConfigModal.vue';
 
 import { QueryRoleList, RoleStatusSwitch, DeleteRole, CreateRole, UpdateRole } from '../../../apis/permission/role';
-import { QueryMenuTree } from '../../../apis/permission/resource';
+import { QueryResourceTree } from '../../../apis/permission/resource';
 import { QueryDeptTree } from '../../../apis/permission/common';
 
 const keywords = ref('');
@@ -52,13 +78,13 @@ const table_columns = ref([
   { title: '序号', slotName: 'index' },
   { title: '角色名', dataIndex: 'roleName', titleSlotName: 'roleName' },
   { title: '状态', dataIndex: 'status', slotName: 'status' },
-  { title: '操作', dataIndex: 'operation', slotName: 'operationSlot' },
+  { title: '操作', dataIndex: 'operation', slotName: 'operationSlot' }
 ]);
 const pagination_props = ref({
   total: 10,
   current: 1,
-  pageSize: 12,
-})
+  pageSize: 12
+});
 const table_size = ref('medium');
 const table_loading = ref(false);
 
@@ -67,140 +93,139 @@ const edit_visible = ref(false);
 const is_edit_mode = ref(false);
 const edit_form = reactive({
   roleName: '',
-  remark: '',
+  remark: ''
 });
 
 // 权限配置相关
 const permission_config_visible = ref(false);
 const menu_list = ref([]);
 
-
 // 部门配置相关
 const dept_config_visible = ref(false);
 const current_record = ref(null);
 const dept_list = ref([
   {
-    "address": null,
-    "children": [
+    address: null,
+    children: [
       {
-        "address": "",
-        "children": [],
-        "code": null,
-        "createTime": "Thu, 12 Sep 2024 14:56:43 GMT",
-        "deptId": "2af7cb5e-1178-4adc-8abb-9780f7543081",
-        "deptName": "成都",
-        "email": "",
-        "iconCls": null,
-        "leader": "成都",
-        "orderNum": 0,
-        "parentId": "0",
-        "parentName": "总部",
-        "phone": "成都",
-        "roles": [],
-        "status": "",
-        "updateTime": "Thu, 12 Sep 2024 14:56:43 GMT"
+        address: '',
+        children: [],
+        code: null,
+        createTime: 'Thu, 12 Sep 2024 14:56:43 GMT',
+        deptId: '2af7cb5e-1178-4adc-8abb-9780f7543081',
+        deptName: '成都',
+        email: '',
+        iconCls: null,
+        leader: '成都',
+        orderNum: 0,
+        parentId: '0',
+        parentName: '总部',
+        phone: '成都',
+        roles: [],
+        status: '',
+        updateTime: 'Thu, 12 Sep 2024 14:56:43 GMT'
       },
       {
-        "address": null,
-        "children": [],
-        "code": null,
-        "createTime": "Sun, 22 May 2022 09:59:33 GMT",
-        "deptId": "5477d9a9-e41e-485f-bb08-697e8facef88",
-        "deptName": "南京分公司",
-        "email": "ss@ada.com",
-        "iconCls": null,
-        "leader": "dd",
-        "orderNum": 0,
-        "parentId": "0",
-        "parentName": "总部",
-        "phone": "18905189016",
-        "roles": [],
-        "status": "0",
-        "updateTime": "Tue, 12 Nov 2024 03:05:10 GMT"
+        address: null,
+        children: [],
+        code: null,
+        createTime: 'Sun, 22 May 2022 09:59:33 GMT',
+        deptId: '5477d9a9-e41e-485f-bb08-697e8facef88',
+        deptName: '南京分公司',
+        email: 'ss@ada.com',
+        iconCls: null,
+        leader: 'dd',
+        orderNum: 0,
+        parentId: '0',
+        parentName: '总部',
+        phone: '18905189016',
+        roles: [],
+        status: '0',
+        updateTime: 'Tue, 12 Nov 2024 03:05:10 GMT'
       },
       {
-        "address": null,
-        "children": [
+        address: null,
+        children: [
           {
-            "address": "",
-            "children": [
+            address: '',
+            children: [
               {
-                "address": "",
-                "children": [],
-                "code": null,
-                "createTime": "Tue, 12 Nov 2024 03:09:57 GMT",
-                "deptId": "c6ae93de-2436-4090-b567-ec4835c74112",
-                "deptName": "成都",
-                "email": "",
-                "iconCls": null,
-                "leader": "柔柔弱弱",
-                "orderNum": 0,
-                "parentId": "f86724f0-94d9-445c-9d95-3ec2540da0f8",
-                "parentName": "太平洋派出所",
-                "phone": "1234242342",
-                "roles": [],
-                "status": "",
-                "updateTime": "Tue, 12 Nov 2024 06:58:15 GMT"
+                address: '',
+                children: [],
+                code: null,
+                createTime: 'Tue, 12 Nov 2024 03:09:57 GMT',
+                deptId: 'c6ae93de-2436-4090-b567-ec4835c74112',
+                deptName: '成都',
+                email: '',
+                iconCls: null,
+                leader: '柔柔弱弱',
+                orderNum: 0,
+                parentId: 'f86724f0-94d9-445c-9d95-3ec2540da0f8',
+                parentName: '太平洋派出所',
+                phone: '1234242342',
+                roles: [],
+                status: '',
+                updateTime: 'Tue, 12 Nov 2024 06:58:15 GMT'
               }
             ],
-            "code": null,
-            "createTime": "Thu, 05 Sep 2024 03:15:13 GMT",
-            "deptId": "f86724f0-94d9-445c-9d95-3ec2540da0f8",
-            "deptName": "太平洋派出所",
-            "email": "",
-            "iconCls": null,
-            "leader": "12",
-            "orderNum": 0,
-            "parentId": "ce627e90-57d6-4ed4-a789-1f3dd467ae7d",
-            "parentName": "上海分公司",
-            "phone": "12",
-            "roles": [
+            code: null,
+            createTime: 'Thu, 05 Sep 2024 03:15:13 GMT',
+            deptId: 'f86724f0-94d9-445c-9d95-3ec2540da0f8',
+            deptName: '太平洋派出所',
+            email: '',
+            iconCls: null,
+            leader: '12',
+            orderNum: 0,
+            parentId: 'ce627e90-57d6-4ed4-a789-1f3dd467ae7d',
+            parentName: '上海分公司',
+            phone: '12',
+            roles: [
               {
-                "deptId": "f86724f0-94d9-445c-9d95-3ec2540da0f8",
-                "roleId": "19f00d46-8f1b-45b5-b7b7-6197d7b8cb33",
-                "roleName": "管理员1"
+                deptId: 'f86724f0-94d9-445c-9d95-3ec2540da0f8',
+                roleId: '19f00d46-8f1b-45b5-b7b7-6197d7b8cb33',
+                roleName: '管理员1'
               }
             ],
-            "status": "0",
-            "updateTime": "Tue, 12 Nov 2024 06:58:07 GMT"
+            status: '0',
+            updateTime: 'Tue, 12 Nov 2024 06:58:07 GMT'
           }
         ],
-        "code": null,
-        "createTime": "Tue, 24 May 2022 23:54:10 GMT",
-        "deptId": "ce627e90-57d6-4ed4-a789-1f3dd467ae7d",
-        "deptName": "上海分公司",
-        "email": null,
-        "iconCls": null,
-        "leader": "jack",
-        "orderNum": 0,
-        "parentId": "0",
-        "parentName": "总部",
-        "phone": null,
-        "roles": [
+        code: null,
+        createTime: 'Tue, 24 May 2022 23:54:10 GMT',
+        deptId: 'ce627e90-57d6-4ed4-a789-1f3dd467ae7d',
+        deptName: '上海分公司',
+        email: null,
+        iconCls: null,
+        leader: 'jack',
+        orderNum: 0,
+        parentId: '0',
+        parentName: '总部',
+        phone: null,
+        roles: [
           {
-            "deptId": "ce627e90-57d6-4ed4-a789-1f3dd467ae7d",
-            "roleId": "301ca518-2ed0-4092-a2ee-e46c24a42c8a",
-            "roleName": "普通"
+            deptId: 'ce627e90-57d6-4ed4-a789-1f3dd467ae7d',
+            roleId: '301ca518-2ed0-4092-a2ee-e46c24a42c8a',
+            roleName: '普通'
           }
         ],
-        "status": "0",
-        "updateTime": "Wed, 18 Sep 2024 09:58:16 GMT"
+        status: '0',
+        updateTime: 'Wed, 18 Sep 2024 09:58:16 GMT'
       }
     ],
-    "code": null,
-    "createTime": "Mon, 28 Nov 2016 10:34:54 GMT",
-    "deptId": "0",
-    "deptName": "总部",
-    "email": null,
-    "iconCls": "ext-icon-bricks",
-    "leader": null,
-    "orderNum": 100,
-    "parentId": "",
-    "parentName": "",
-    "phone": null,
-    "roles": [],
-    "status": "0",
-    "updateTime": "Mon, 28 Nov 2016 10:35:12 GMT"
+    code: null,
+    createTime: 'Mon, 28 Nov 2016 10:34:54 GMT',
+    deptId: '0',
+    deptName: '总部',
+    email: null,
+    iconCls: 'ext-icon-bricks',
+    leader: null,
+    orderNum: 100,
+    parentId: '',
+    parentName: '',
+    phone: null,
+    roles: [],
+    status: '0',
+    updateTime: 'Mon, 28 Nov 2016 10:35:12 GMT'
   }
 ]);
 
@@ -208,38 +233,37 @@ const gerRoleList = async () => {
   const params = {
     keyword: keywords.value,
     current: pagination_props.value.current,
-    pageSize: pagination_props.value.pageSize,
+    pageSize: pagination_props.value.pageSize
   };
-  table_loading.value = true
+  table_loading.value = true;
   const { code, data } = await QueryRoleList(params);
   if (code === 200) {
-
     pagination_props.value.total = data.total;
     table_data.value = data.rows;
 
-    table_loading.value = false
+    table_loading.value = false;
   } else {
-    table_loading.value = false
+    table_loading.value = false;
   }
-}
+};
 
 const searchClick = (value) => {
   keywords.value = value;
   gerRoleList();
-}
+};
 const resetClick = () => {
   keywords.value = '';
   gerRoleList();
-}
+};
 const createClick = () => {
   edit_form.roleName = '';
   edit_form.remark = '';
   is_edit_mode.value = false;
   edit_visible.value = true;
-}
+};
 const refreshClick = () => {
-  console.log('刷新')
-}
+  console.log('刷新');
+};
 
 // 切换页码
 const handlePageChange = (current) => {
@@ -249,22 +273,24 @@ const handlePageChange = (current) => {
 
 // TODO功能 状态切换拦截
 const beforeStatusChange = async () => {
-  await new Promise((resolve, reject) => setTimeout(() => {
-    resolve()
-  }, 1000))
-}
+  await new Promise((resolve, reject) =>
+    setTimeout(() => {
+      resolve();
+    }, 1000)
+  );
+};
 
 // 用户状态切换
 const statusChange = async (record) => {
   const params = {
     roleId: record.roleId,
-    status: record.status,
+    status: record.status
   };
-  const { code } = await RoleStatusSwitch(params)
+  const { code } = await RoleStatusSwitch(params);
   if (code === 200) {
     Message.success({
       title: '成功',
-      content: '状态切换成功.',
+      content: '状态切换成功.'
     });
   }
 };
@@ -279,7 +305,7 @@ const handleEdit = (record, visible) => {
   }
 
   edit_visible.value = visible;
-}
+};
 // 权限配置
 const handlePermissionConfig = async (record, visible) => {
   if (record) {
@@ -287,23 +313,23 @@ const handlePermissionConfig = async (record, visible) => {
     current_record.value = record;
   }
   permission_config_visible.value = visible;
-}
+};
 
 const handlePermissionConfigSave = async (checked_menu) => {
   permission_config_visible.value = false;
   const params = {
     roleId: edit_form.roleId,
     menuIds: checked_menu,
-    editType: 2,
+    editType: 2
   };
   const { code } = await UpdateRole(params);
   if (code === 200) {
     Message.success({
       title: '权限配置',
-      content: '权限配置成功',
+      content: '权限配置成功'
     });
   }
-}
+};
 
 // 部门配置
 const handleDeptConfig = async (record, visible) => {
@@ -317,23 +343,23 @@ const handleDeptConfig = async (record, visible) => {
     // }
   }
   dept_config_visible.value = visible;
-}
+};
 
 const handleDeptConfigSave = async (dept_ids) => {
   dept_config_visible.value = false;
   const params = {
     roleId: edit_form.roleId,
     depts: dept_ids,
-    editType: 3,
+    editType: 3
   };
   const { code } = await UpdateRole(params);
   if (code === 200) {
     Message.success({
       title: '部门配置',
-      content: '部门配置成功',
+      content: '部门配置成功'
     });
   }
-}
+};
 
 // 删除用户
 const handleDelete = async (roleId) => {
@@ -341,18 +367,18 @@ const handleDelete = async (roleId) => {
   if (code === 200) {
     Message.success({
       title: '删除用户',
-      content: '删除成功',
+      content: '删除成功'
     });
     gerRoleList();
   }
-}
+};
 const modalSave = async () => {
   edit_visible.value = false;
   const data = {
     roleId: is_edit_mode.value ? edit_form.roleId : undefined,
     roleName: edit_form.roleName,
     editType: is_edit_mode.value ? 1 : undefined,
-    remark: edit_form.remark,
+    remark: edit_form.remark
   };
 
   const apiCall = is_edit_mode.value ? UpdateRole : CreateRole;
@@ -362,36 +388,42 @@ const modalSave = async () => {
     const action = is_edit_mode.value ? '编辑' : '新增';
     Message.success({
       title: `${action}用户`,
-      content: `${action}成功`,
+      content: `${action}成功`
     });
     gerRoleList();
   }
-}
+};
 
 const tableSizeChange = (size) => {
   table_size.value = size;
-}
+};
 
 // 获取菜单树
 const getMenuTree = async () => {
-  const { code, data: { rows } } = await QueryMenuTree();
+  const {
+    code,
+    data: { rows }
+  } = await QueryResourceTree();
   if (code === 200) {
     menu_list.value = rows;
   }
-}
+};
 // 获取部门树
 const getDeptTree = async () => {
-  const { code, data: { rows } } = await QueryDeptTree();
+  const {
+    code,
+    data: { rows }
+  } = await QueryDeptTree();
   if (code == 200) {
     dept_list.value = rows;
   }
-}
+};
 
 onMounted(() => {
-  gerRoleList()
-  getMenuTree()
-  getDeptTree()
-})
+  gerRoleList();
+  getMenuTree();
+  getDeptTree();
+});
 </script>
 
 <style lang="css" scoped>