瀏覽代碼

调整权限相关术语为“用户”,更新用户相关功能的权限验证,修正部分表单字段,优化权限检查逻辑,增加角色与资源相关的功能权限验证,改善状态切换逻辑及相关提示显示。

张涛 1 年之前
父節點
當前提交
eda924de08

+ 1 - 1
public/i18n/lang-zh.json

@@ -72,7 +72,7 @@
   },
   "permission": {
     "role": "角色",
-    "account": "账号",
+    "account": "用户",
     "organization": "机构",
     "resource": "资源",
     "group": "用户组"

+ 2 - 1
src/directive/hasPermi/index.js

@@ -3,9 +3,10 @@ import { localST_UserInfo } from '../../base/storage';
 function hasPermissionDirective(el, binding) {
   // 获取用户权限
   const { permissions } = JSON.parse(localST_UserInfo.getItem());
+
   // 获取按钮权限
   const btnPermission = binding.value;
-  if (!permissions.includes(btnPermission)) {
+  if (!permissions.includes('*:*:*') && !permissions.includes(btnPermission)) {
     el.style.display = 'none';
   }
 }

+ 17 - 12
src/modules/permission/account/index.vue

@@ -1,21 +1,23 @@
 <template>
   <a-card class="account-page-card">
-    <Action :btn_text="'新建账号'" @searchClick="searchClick" @resetClick="resetClick" @createClick="createClick"
-      @sizeChange="tableSizeChange" @refreshClick="refreshClick"></Action>
+    <Action :btn_text="'新建用户'" :btn_permission="'system:user:add'" @searchClick="searchClick" @resetClick="resetClick"
+      @createClick="createClick" @sizeChange="tableSizeChange" @refreshClick="refreshClick"></Action>
     <DataTable :data="table_data" :columns="table_columns" row-key="userId" :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>
       <template #operationSlot="{ record }">
-        <a-popconfirm content="确定重置该账号密码吗?" @ok="handleResetPassword(record)">
-          <a-button type="text">重制密码</a-button>
+        <a-popconfirm content="确定重置该用户密码吗?" @ok="handleResetPassword(record)">
+          <a-button v-hasPermi="'system:role:resetPassword'" type="text">重制密码</a-button>
         </a-popconfirm>
-        <a-button type="text" @click="handleEdit(record, true)">编辑</a-button>
-        <a-button type="text" @click="handleView(record, true)">查看权限</a-button>
-        <a-button type="text" @click="handleDeptConfig(record, true)">部门配置</a-button>
+        <a-button v-hasPermi="'system:user:edit'" type="text" @click="handleEdit(record, true)">编辑</a-button>
+        <a-button v-hasPermi="'system:user:viewPermission'" type="text"
+          @click="handleView(record, true)">查看权限</a-button>
+        <a-button v-hasPermi="'system:user:deptEdit'" type="text"
+          @click="handleDeptConfig(record, true)">部门配置</a-button>
         <a-popconfirm content="确定删除该条数据吗?" type="warning" @ok="handleDelete(record.userId)">
-          <a-button type="text" status="warning">删除</a-button>
+          <a-button v-hasPermi="'system:user:delete'" type="text" status="warning">删除</a-button>
         </a-popconfirm>
       </template>
     </DataTable>
@@ -45,7 +47,7 @@ import Modal from '../Modal.vue';
 import AccountForm from './AccountForm.vue';
 import ViewPermission from './ViewPermission.vue';
 import DeptConfigModal from './DeptConfigModal.vue';
-
+import { hasPermission } from '../../../utils/permission';
 import {
   QueryUserList, QueryUserDeptDetail, UpdateUserDept, AddUser,
   UpdateUser, QueryUserPermission, UserStatusSwitch, ResetPassword, DeleteUser
@@ -295,7 +297,7 @@ const modalSave = async () => {
   if (code === 200) {
     const action = is_edit_mode.value ? '编辑' : '新增';
     Message.success({
-      title: `${action}账号`,
+      title: `${action}用户`,
       content: `${action}成功`,
     });
     getUserList();
@@ -327,8 +329,11 @@ const getDeptTree = async () => {
 }
 
 onMounted(() => {
-  getUserList()
-  getDeptTree()
+  if (hasPermission('system:user:list')) {
+    getUserList()
+    getDeptTree()
+  }
+
 })
 </script>
 

+ 7 - 5
src/modules/permission/group/index.vue

@@ -1,16 +1,18 @@
 <template>
   <a-card class="account-page-card">
-    <Action :btn_text="'新建用户组'" @searchClick="searchClick" @resetClick="resetClick" @createClick="createClick"
-      @sizeChange="tableSizeChange" @refreshClick="refreshClick"></Action>
+    <Action :btn_text="'新建用户组'" :btn_permission="'system:group:add'" @searchClick="searchClick" @resetClick="resetClick"
+      @createClick="createClick" @sizeChange="tableSizeChange" @refreshClick="refreshClick"></Action>
     <DataTable :data="table_data" :columns="table_columns" row-key="groupId" :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>
       <template #operationSlot="{ record }">
-        <a-button type="text" @click="handleEdit(record, true)">编辑</a-button>
-        <a-button type="text" @click="handleMembertConfig(record, true)">成员管理</a-button>
-        <a-button type="text" @click="handlePermissionConfig(record, true)">权限管理</a-button>
+        <a-button v-hasPermi="'system:group:edit'" type="text" @click="handleEdit(record, true)">编辑</a-button>
+        <a-button v-hasPermi="'system:group:memberConfig'" type="text"
+          @click="handleMembertConfig(record, true)">成员管理</a-button>
+        <a-button v-hasPermi="'system:group:permissionConfig'" type="text"
+          @click="handlePermissionConfig(record, true)">权限管理</a-button>
         <a-popconfirm content="确定删除该条数据吗?" type="warning" @ok="handleDelete(record.groupId)">
           <a-button type="text" status="warning">删除</a-button>
         </a-popconfirm>

+ 4 - 4
src/modules/permission/org/OrgForm.vue

@@ -4,7 +4,7 @@
       <a-input v-model="org_form.parentName" />
     </a-form-item>
     <a-form-item field="status" label="机构状态">
-      <a-switch checked-value="0" unchecked-value="1" v-model="org_form.status"></a-switch>
+      <a-switch checked-value="1" unchecked-value="0" v-model="org_form.status"></a-switch>
     </a-form-item>
     <a-form-item field="deptName" label="机构名称"
       :rules="[{ required: true, message: '机构名称必填' }, { maxLength: 50, message: '长度不超过50' }]">
@@ -14,9 +14,9 @@
       :rules="[{ required: true, message: '联系人必填' }, { maxLength: 50, message: '长度不超过50' }]">
       <a-input v-model="org_form.leader" />
     </a-form-item>
-    <a-form-item field="orderNum" label="联系电话"
+    <a-form-item field="phone" label="联系电话"
       :rules="[{ required: true, message: '联系电话必填' }, { maxLength: 50, message: '长度不超过50' }]">
-      <a-input v-model="org_form.orderNum" />
+      <a-input v-model="org_form.phone" />
     </a-form-item>
     <a-form-item field="address" label="机构地址">
       <a-input v-model="org_form.address" />
@@ -42,7 +42,7 @@ const props = defineProps({
       status: 0,
       deptName: '',
       leader: '',
-      orderNum: '',
+      phone: '',
       address: ''
     })
   }

+ 9 - 6
src/modules/permission/org/index.vue

@@ -44,8 +44,11 @@ const org_form = reactive({
   status: 0,
   deptName: '',
   leader: '',
-  orderNum: '',
-  address: ''
+  phone: '',
+  address: '',
+
+  // 多余的参数
+  orderNum: 0,
 });
 
 const getDeptTree = async () => {
@@ -68,7 +71,7 @@ const onNodeClick = async (id) => {
   org_form.status = data.status;
   org_form.deptName = data.deptName;
   org_form.leader = data.leader;
-  org_form.orderNum = data.orderNum;
+  org_form.phone = data.phone;
   org_form.address = data.address;
 };
 const onAddBtnClick = (nodeData) => {
@@ -78,7 +81,7 @@ const onAddBtnClick = (nodeData) => {
   org_form.status = 0;
   org_form.deptName = '';
   org_form.leader = '';
-  org_form.orderNum = '';
+  org_form.phone = '';
   org_form.address = '';
 
   org_visible.value = true;
@@ -108,7 +111,7 @@ const orgFromSave = async () => {
   if (code === 200) {
     const action = is_edit_mode.value ? '编辑' : '新增';
     Message.success({
-      title: `${action}账号`,
+      title: `${action}用户`,
       content: `${action}成功`
     });
 
@@ -123,7 +126,7 @@ const orgFromReset = () => {
   org_form.status = 0;
   org_form.deptName = '';
   org_form.leader = '';
-  org_form.orderNum = '';
+  org_form.phone = '';
   org_form.address = '';
 };
 

+ 1 - 1
src/modules/permission/resource/ResourceForm.vue

@@ -4,7 +4,7 @@
       <a-input v-model="resource_form.parentName" />
     </a-form-item>
     <a-form-item field="status" label="资源状态">
-      <a-switch checked-value="0" unchecked-value="1" v-model="resource_form.status"></a-switch>
+      <a-switch checked-value="1" unchecked-value="0" v-model="resource_form.status"></a-switch>
     </a-form-item>
     <a-form-item field="menuName" label="资源名称"
       :rules="[{ required: true, message: '资源名称必填' }, { maxLength: 50, message: '长度不超过50' }]">

+ 4 - 3
src/modules/permission/resource/index.vue

@@ -63,7 +63,6 @@ const getResourceTree = async () => {
 const onNodeClick = async (id) => {
   const { data: { data } } = await QueryResourceDetail(id);
   resource_form.resourceId = id;
-
   resource_form.parentId = data.parentId;
   resource_form.parentName = data.parentName;
   resource_form.menuName = data.menuName;
@@ -79,7 +78,7 @@ const onNodeClick = async (id) => {
   resource_form.path = '';
 }
 const onAddBtnClick = (nodeData) => {
-  resource_form.resourceId = '';
+  resource_form.resourceId = null;
 
   resource_form.parentId = nodeData.menuId
   resource_form.parentName = nodeData.menuName;
@@ -111,6 +110,8 @@ const onDeleteBtnClick = async ({ menuId }) => {
 }
 
 const orgFromSave = async () => {
+  console.log('is_edit_mode.value', is_edit_mode.value)
+  console.log('resource_form.resourceId', resource_form.resourceId)
   const data = {
     ...resource_form,
     menuId: (is_edit_mode.value && resource_form.resourceId) ? resource_form.resourceId[0] : null
@@ -122,7 +123,7 @@ const orgFromSave = async () => {
   if (code === 200) {
     const action = is_edit_mode.value ? '编辑' : '新增';
     Message.success({
-      title: `${action}账号`,
+      title: `${action}用户`,
       content: `${action}成功`,
     });
 

+ 12 - 9
src/modules/permission/role/index.vue

@@ -9,12 +9,12 @@
       </template>
       <template #operationSlot="{ record }">
         <a-button v-hasPermi="'system:role:edit'" type="text" @click="handleEdit(record, true)">编辑</a-button>
-        <!-- TODO -->
-        <a-button v-hasPermi="'system:role:edit'" type="text"
+        <a-button v-hasPermi="'system:role:permissionEdit'" type="text"
           @click="handlePermissionConfig(record, true)">权限配置</a-button>
-        <a-button v-hasPermi="'system:role:edit'" type="text" @click="handleDeptConfig(record, true)">部门配置</a-button>
+        <a-button v-hasPermi="'system:role:deptEdit'" type="text"
+          @click="handleDeptConfig(record, true)">部门配置</a-button>
         <a-popconfirm content="确定删除该条数据吗?" type="warning" @ok="handleDelete(record.roleId)">
-          <a-button v-hasPermi="'system:role:remove'" type="text" status="warning">删除</a-button>
+          <a-button v-hasPermi="'system:role:delete'" type="text" status="warning">删除</a-button>
         </a-popconfirm>
       </template>
     </DataTable>
@@ -33,7 +33,7 @@
 </template>
 
 <script setup>
-import { ref, reactive, onMounted } from 'vue';
+import { ref, reactive, onMounted, h } from 'vue';
 import { Message } from '@arco-design/web-vue';
 import DataTable from '../../../views/permission/DataTable.vue';
 import Action from '../../../views/permission/Action.vue';
@@ -41,7 +41,7 @@ import Modal from '../Modal.vue';
 import RoleForm from './RoleForm.vue';
 import PermissionConfigModal from './PermissionConfigModal.vue';
 import DeptConfigModal from './DeptConfigModal.vue';
-
+import { hasPermission } from '../../../utils/permission';
 import { QueryRoleList, RoleStatusSwitch, DeleteRole, CreateRole, UpdateRole } from '../../../apis/permission/role';
 import { QueryResourceTree } from '../../../apis/permission/resource';
 import { QueryDeptTree } from '../../../apis/permission/common';
@@ -395,9 +395,12 @@ const getDeptTree = async () => {
 };
 
 onMounted(() => {
-  gerRoleList();
-  getMenuTree();
-  getDeptTree();
+  if (hasPermission('system:role:list')) {
+    gerRoleList();
+    getMenuTree();
+    getDeptTree();
+  }
+
 });
 </script>
 

+ 8 - 0
src/utils/permission.js

@@ -0,0 +1,8 @@
+import { localST_UserInfo } from '../base/storage';
+
+// 判断是否有该权限
+export const hasPermission = (str) => {
+  const { permissions } = JSON.parse(localST_UserInfo.getItem());
+  if (permissions.includes('*:*:*')) return true;
+  return permissions.includes(str);
+};

+ 1 - 1
src/views/Home.vue

@@ -21,7 +21,7 @@
       <li><router-link class="arco-link" to="/intelligent">智能体管理</router-link></li>
       <li><router-link class="arco-link" to="/permission">权限</router-link></li>
       <li><router-link class="arco-link" to="/permission/org">机构</router-link></li>
-      <li><router-link class="arco-link" to="/permission/account">账号</router-link></li>
+      <li><router-link class="arco-link" to="/permission/account">用户</router-link></li>
       <li><router-link class="arco-link" to="/permission/role">角色</router-link></li>
       <li><router-link class="arco-link" to="/permission/group">用户组</router-link></li>
       <li><router-link class="arco-link" to="/profile">个人中心</router-link></li>

+ 1 - 1
src/views/PermissionAccount.vue

@@ -1,6 +1,6 @@
 <template>
   <ContentContainer>
-    <BreadCrumbMenu :current_label="'账号'" />
+    <BreadCrumbMenu :current_label="'用户'" />
     <AccountPage />
   </ContentContainer>
 </template>