parent
3007f5fdf2
commit
bc6da51424
@ -0,0 +1,63 @@
|
|||||||
|
import request from '@/utils/request.js';
|
||||||
|
export const search = (params) => {
|
||||||
|
return request({
|
||||||
|
url: '/uc/department/tree',
|
||||||
|
method: 'get',
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export const searchEmployee = (params) => {
|
||||||
|
return request({
|
||||||
|
url: '/uc/employee/department',
|
||||||
|
method: 'get',
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export const children = (params) => {
|
||||||
|
return request({
|
||||||
|
url: '/uc/department/child',
|
||||||
|
method: 'get',
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export const detail = (id) => {
|
||||||
|
return request({
|
||||||
|
url: '/uc/department/' + id,
|
||||||
|
method: 'get',
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export const create = (data) => {
|
||||||
|
return request({
|
||||||
|
url: '/uc/department',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export const update = (data) => {
|
||||||
|
return request({
|
||||||
|
url: '/uc/department/' + data.id,
|
||||||
|
method: 'put',
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export const remove = (idList) => {
|
||||||
|
return request({
|
||||||
|
url: '/uc/department',
|
||||||
|
method: 'delete',
|
||||||
|
params: { idList },
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export const addRole = (data) => {
|
||||||
|
return request({
|
||||||
|
url: '/uc/department/role',
|
||||||
|
method: 'put',
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export const delRole = (data) => {
|
||||||
|
return request({
|
||||||
|
url: '/uc/department/role',
|
||||||
|
method: 'delete',
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
@ -0,0 +1,23 @@
|
|||||||
|
export default [
|
||||||
|
{
|
||||||
|
path: '/uc',
|
||||||
|
name: 'UserCenter',
|
||||||
|
component: () => import('@/layouts/default.vue'),
|
||||||
|
meta: {
|
||||||
|
title: '权限中台',
|
||||||
|
icon: 'admin-fill',
|
||||||
|
layout: true,
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'dept',
|
||||||
|
name: 'DeptManagement',
|
||||||
|
component: () => import('@/views/permission/dept/index.vue'),
|
||||||
|
meta: {
|
||||||
|
title: '组织架构',
|
||||||
|
icon: 'organization-chart',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
@ -0,0 +1,90 @@
|
|||||||
|
import * as api from '@/api/permission/dept.js';
|
||||||
|
import { ElMessage, ElMessageBox } from '@/plugins/element-plus';
|
||||||
|
const state = () => ({
|
||||||
|
employeeCode: 'DeptEmployeeManagement',
|
||||||
|
roleCode: 'DeptRoleManagement',
|
||||||
|
condition1: {},
|
||||||
|
condition2: {},
|
||||||
|
list: [],
|
||||||
|
total: 0,
|
||||||
|
employeeList: [],
|
||||||
|
employeeTotal: 0,
|
||||||
|
opts: {
|
||||||
|
init: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const getters = {};
|
||||||
|
const mutations = {
|
||||||
|
setCondition1: (state, data) => (state.condition1 = data),
|
||||||
|
setCondition2: (state, data) => (state.condition2 = data),
|
||||||
|
setList: (state, data) => (state.list = data),
|
||||||
|
setTotal: (state, data) => (state.total = data),
|
||||||
|
setEmployeeList: (state, data) => (state.employeeList = data),
|
||||||
|
setEmployeeTotal: (state, data) => (state.employeeTotal = data),
|
||||||
|
setOpts: (state, data) => (state.opts = data),
|
||||||
|
};
|
||||||
|
const actions = {
|
||||||
|
search: async ({ state, commit }) => {
|
||||||
|
let res = await api.search(state.condition1);
|
||||||
|
commit('setList', res || []);
|
||||||
|
if (!res) {
|
||||||
|
ElMessage.error('查询失败');
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
},
|
||||||
|
searchEmployee: async ({ state, commit }) => {
|
||||||
|
let res = await api.searchEmployee(state.condition2);
|
||||||
|
commit('setEmployeeList', res || []);
|
||||||
|
if (!res) {
|
||||||
|
ElMessage.error('查询部门员工失败');
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
},
|
||||||
|
load: async ({ commit }) => {
|
||||||
|
commit('setOpts', {
|
||||||
|
init: true,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
detail: async (context, id) => {
|
||||||
|
let res = await api.detail(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');
|
||||||
|
} else {
|
||||||
|
ElMessage.error('保存失败');
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
},
|
||||||
|
remove: async ({ dispatch }, idList) => {
|
||||||
|
if (!idList.length) {
|
||||||
|
ElMessage.warning('请选择要删除的数据');
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
await ElMessageBox.confirm('数据删除后无法恢复,确定要删除吗?', '危险操作');
|
||||||
|
let res = await api.remove(idList.join(','));
|
||||||
|
if (res) {
|
||||||
|
ElMessage.success('删除成功');
|
||||||
|
dispatch('search');
|
||||||
|
} else {
|
||||||
|
ElMessage.error('删除失败');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.info('取消删除', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
export default {
|
||||||
|
state,
|
||||||
|
getters,
|
||||||
|
mutations,
|
||||||
|
actions,
|
||||||
|
};
|
Loading…
Reference in new issue