From 403adddce476e120c266d64fba24afd12fa86ac5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=90=91=E6=96=87=E5=8F=AF?= <1041367524@qq.com>
Date: Fri, 20 May 2022 15:20:04 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E5=91=98=E5=B7=A5=E8=A7=92=E8=89=B2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/auth.js | 2 +-
src/api/permission/employee.js | 13 ++
.../modules/permission/employee/employee.js | 22 +-
src/views/permission/employee/form.vue | 96 +++++++-
src/views/permission/menu/index.vue | 220 ++++++++++--------
src/views/permission/role/index.vue | 57 ++---
6 files changed, 276 insertions(+), 134 deletions(-)
diff --git a/src/api/auth.js b/src/api/auth.js
index d084057..1816ae7 100644
--- a/src/api/auth.js
+++ b/src/api/auth.js
@@ -26,7 +26,7 @@ export function getUserInfo() {
// 获取权限列表
export function getPermission(params) {
return request({
- url: '/u-admin/uc/ucPermission/listUserMenu',
+ url: '/uc/menu',
method: 'get',
params,
});
diff --git a/src/api/permission/employee.js b/src/api/permission/employee.js
index 4069c24..2acd82c 100644
--- a/src/api/permission/employee.js
+++ b/src/api/permission/employee.js
@@ -12,6 +12,19 @@ export const detail = (id) => {
method: 'get',
});
};
+export const searchPermission = (id) => {
+ return request({
+ url: '/uc/employee/role/' + id,
+ method: 'get',
+ });
+};
+export const savePermission = (id, data) => {
+ return request({
+ url: '/uc/employee/role/' + id,
+ method: 'put',
+ data,
+ });
+};
export const create = (data) => {
return request({
url: '/uc/employee',
diff --git a/src/store/modules/permission/employee/employee.js b/src/store/modules/permission/employee/employee.js
index 693f822..750b0f6 100644
--- a/src/store/modules/permission/employee/employee.js
+++ b/src/store/modules/permission/employee/employee.js
@@ -1,5 +1,6 @@
import * as deptAPI from '@/api/permission/dept.js';
import * as api from '@/api/permission/employee.js';
+import * as systemAPI from '@/api/permission/system.js';
import { ElMessage, ElMessageBox } from '@/plugins/element-plus';
const state = () => ({
code: 'EmployeeManagement',
@@ -8,6 +9,7 @@ const state = () => ({
total: 0,
opts: {
init: false,
+ system: [],
dept: [],
},
});
@@ -36,6 +38,7 @@ const actions = {
...state.opts,
init: true,
dept: await deptAPI.search({ hiddenDisable: true }),
+ system: await systemAPI.search(),
});
},
detail: async (context, id) => {
@@ -45,12 +48,27 @@ const actions = {
}
return res;
},
+ permission: async (context, id) => {
+ let res = await api.searchPermission(id);
+ if (!res) {
+ ElMessage.error('加载权限列表失败');
+ }
+ return res;
+ },
save: async ({ dispatch }, data) => {
let save = data.id ? api.update : api.create;
let res = await save(data);
if (res) {
- ElMessage.success('保存成功');
- dispatch('search');
+ if (!data.id) {
+ data.id = res;
+ }
+ res = await api.savePermission(data.id, { roleIds: data.roleIds });
+ if (res) {
+ ElMessage.success('保存成功');
+ dispatch('search');
+ } else {
+ ElMessage.error('保存角色失败');
+ }
} else {
ElMessage.error('保存失败');
}
diff --git a/src/views/permission/employee/form.vue b/src/views/permission/employee/form.vue
index 7fdb505..776db69 100644
--- a/src/views/permission/employee/form.vue
+++ b/src/views/permission/employee/form.vue
@@ -43,6 +43,49 @@
+ {{ item.systemName }}
+
+