Browse Source

feat: 部门联调

main
xuziqiang 4 months ago
parent
commit
61218104d3
  1. 8
      hx-ai-intelligent/src/api/origanizemanage.ts
  2. 2
      hx-ai-intelligent/src/config/app.config.ts
  3. 6
      hx-ai-intelligent/src/router/equipmentManage.ts
  4. 7
      hx-ai-intelligent/src/router/home.ts
  5. 21
      hx-ai-intelligent/src/router/organizationManage.ts
  6. 20
      hx-ai-intelligent/src/view/organizationManage/departmentManage/config.ts
  7. 251
      hx-ai-intelligent/src/view/organizationManage/departmentManage/index.vue
  8. 2
      hx-ai-intelligent/src/view/organizationManage/usermanage/config.ts
  9. 71
      hx-ai-intelligent/src/view/organizationManage/usermanage/index.vue
  10. 12
      lib/saas/router/helper/route-helper.ts
  11. 7
      lib/util/http/axios.ts

8
hx-ai-intelligent/src/api/origanizemanage.ts

@ -6,6 +6,7 @@ export enum permission {
export enum origanizemanage {
userList = '/carbon-smart/api/user/queryUserByPage',
addUser = '/carbon-smart/api/user/save',
editUser = '/carbon-smart/api/user/edit',
frozen = '/carbon-smart/api/user/frozen',
resetPwd = '/carbon-smart/api/user/resetPwd',
del = '/carbon-smart/api/user/del',
@ -19,4 +20,11 @@ export enum department {
dartList = `${BASE_URL}/api/user/queryDeptTree`,
deptSave = `${BASE_URL}/api/dept/save`,
deptEdit = `${BASE_URL}/api/dept/edit`,
deptDel = `${BASE_URL}/api/dept/del`,
addPermission = `${BASE_URL}/api/dept/addPermission`,
addRolePermission = `${BASE_URL}/api/dept/addRolePermission`,
delRole = `${BASE_URL}/api/dept/delRole`,
addRole = `${BASE_URL}/api/dept/addRole`,
editRole = `${BASE_URL}/api/dept/editRole`,
queryRoleTree = `${BASE_URL}/api/dept/queryRoleTree`,
}

2
hx-ai-intelligent/src/config/app.config.ts

@ -15,7 +15,7 @@ const transform = (data, map) => {
export const appConfig = {
projectType: 'web',
baseApi: '/api',
enablePermissions: true,
enablePermissions: false,
// themeColor: '#eee',
siderPosition: 'left',
baseHeader: '/parkingManage',

6
hx-ai-intelligent/src/router/equipmentManage.ts

@ -20,7 +20,7 @@ const equipment = {
meta: {
title: '设备台账',
keepAlive: true,
backApi: [],
// backApi: [],
},
},
],
@ -39,7 +39,7 @@ const equipment = {
meta: {
title: '分组管理',
keepAlive: true,
backApi: [],
// backApi: [],
},
},
],
@ -58,7 +58,7 @@ const equipment = {
meta: {
title: '能耗映射',
keepAlive: true,
backApi: [],
// backApi: [],
},
},
],

7
hx-ai-intelligent/src/router/home.ts

@ -19,12 +19,7 @@ const home = {
meta: {
title: '首页',
keepAlive: true,
backApi: [
{
method: 'GET',
url: '/api/objs/FeedbackWeb/feedBackList',
},
],
// backApi: [],
},
},
],

21
hx-ai-intelligent/src/router/organizationManage.ts

@ -19,12 +19,7 @@ const organizationManage = {
meta: {
title: '企业管理',
keepAlive: true,
backApi: [
{
method: 'GET',
url: '/api/objs/FeedbackWeb/feedBackList',
},
],
// backApi: [],
},
},
],
@ -43,12 +38,7 @@ const organizationManage = {
meta: {
title: '用户管理',
keepAlive: true,
backApi: [
{
method: 'GET',
url: '/api/objs/FeedbackWeb/feedBackList',
},
],
// backApi: [],
},
},
],
@ -67,12 +57,7 @@ const organizationManage = {
meta: {
title: '部门/权限',
keepAlive: true,
backApi: [
{
method: 'GET',
url: '/api/objs/FeedbackWeb/feedBackList',
},
],
// backApi: [],
},
},
],

20
hx-ai-intelligent/src/view/organizationManage/departmentManage/config.ts

@ -59,7 +59,7 @@ export const formConfig = (disabled: Boolean) => {
},
{
label: '排序',
field: 'order',
field: 'sort',
component: 'NsInput',
componentProps: {
disabled: disabled,
@ -92,7 +92,7 @@ export const formConfig2 = (disabled2: Boolean) => {
schemas: [
{
label: '角色名称',
field: 'departname',
field: 'zhName',
component: 'NsInput',
componentProps: {
disabled: disabled2,
@ -106,14 +106,14 @@ export const formConfig2 = (disabled2: Boolean) => {
},
],
},
{
label: '上级领导',
field: 'department',
component: 'NsSelect',
componentProps: {
disabled: true,
},
},
// {
// label: '上级领导',
// field: 'department',
// component: 'NsSelect',
// componentProps: {
// disabled: true,
// },
// },
{
label: '节点编码',
field: 'code',

251
hx-ai-intelligent/src/view/organizationManage/departmentManage/index.vue

@ -6,16 +6,26 @@
<div class="ns-table-title">部门管理</div>
<a-row>
<a-col :span="12" class="tree">
<ns-button style="margin: 10px" type="primary" @click="addApartment">新增部门</ns-button>
<ns-button type="primary" @click="addApartmentSon">新增子部门</ns-button>
<ns-button style="margin: 10px" type="primary" @click="deleteApartment">删除</ns-button>
<ns-button :disabled="disabled" style="margin: 10px" type="primary" @click="addApartment"
>新增部门</ns-button
>
<ns-button :disabled="disabled" type="primary" @click="addApartmentSon"
>新增子部门</ns-button
>
<ns-button
:disabled="disabled"
style="margin: 10px"
type="primary"
@click="deleteApartment"
>删除</ns-button
>
<a-tree
v-if="apartmentTreeData?.length"
:tree-data="apartmentTreeData"
defaultExpandAll
@select="SelectApartmentTree">
<template #title="data">
{{ data.deptInfo.deptName }}
{{ data.deptInfo?.deptName }}
</template>
</a-tree>
</a-col>
@ -51,12 +61,20 @@
<div class="ns-table-title">角色管理</div>
<a-row>
<a-col :span="12" class="tree">
<ns-button style="margin: 10px" type="primary" @click="addUser">新增角色</ns-button>
<ns-button type="primary" @click="addUserSon">新增子角色</ns-button>
<ns-button style="margin: 10px" type="primary" @click="deleteUser">删除</ns-button>
<a-tree :tree-data="userTreeData" defaultExpandAll @select="SelectUserTree">
<ns-button :disabled="disabled2" style="margin: 10px" type="primary" @click="addUser"
>新增角色</ns-button
>
<ns-button :disabled="disabled2" type="primary" @click="addUserSon">新增子角色</ns-button>
<ns-button :disabled="disabled2" style="margin: 10px" type="primary" @click="deleteUser"
>删除</ns-button
>
<a-tree
v-if="userTreeData.length"
:tree-data="userTreeData"
defaultExpandAll
@select="SelectUserTree">
<template #title="data">
{{ data }}
{{ data.zhName }}
</template>
</a-tree>
</a-col>
@ -94,10 +112,11 @@
import { Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { http } from '/nerv-lib/util/http';
import { uuid } from '@antv/x6/lib/util/string/uuid';
import { cloneDeep } from 'lodash-es';
import { formConfig, formConfig2 } from './config';
import { department } from '/@/api/origanizemanage';
import { permission } from '/@/api/origanizemanage';
import { NsMessage } from '/nerv-lib/component';
export default defineComponent({
name: 'AuthorityManageIndex',
@ -119,39 +138,10 @@
const formSchema2 = formConfig2(disabled2 as any);
const orgId = JSON.parse(sessionStorage.getItem('userInfo')).orgId;
const projectId = JSON.parse(sessionStorage.getItem('userInfo')).projectId;
watch(ApartcheckedKeys, () => {
console.log('checkedKeys', ApartcheckedKeys.value);
});
watch(UsercheckedKeys, () => {
console.log('checkedKeys', UsercheckedKeys.value);
});
//
const getDepartList = (params) => {
return http.post(department.dartList, params);
};
getDepartList({ orgId: 1 }).then((res) => {
apartmentTreeData.value = res.data;
});
const opMap: any = {
type: 'add',
fuc: () => {},
record: {},
};
const userAdminTreeData = ref([]);
const apartmentTreeData = ref([]);
const userTreeData = ref([
{
title: '产品总监',
key: '0-0',
children: [
{ title: '产品经理', key: '0-0-0', info: { departname: '产品经理' } },
{ title: '产品助理', key: '0-0-1', info: { departname: '产品助理' } },
],
},
]);
const userTreeData = ref([]);
const apartmentAdminTreeData = [
{
@ -174,17 +164,40 @@
],
},
];
watch(ApartcheckedKeys, () => {
console.log('checkedKeys', ApartcheckedKeys.value);
});
watch(UsercheckedKeys, () => {
console.log('checkedKeys', UsercheckedKeys.value);
});
const userAdminTreeData = ref([
{
title: '产品总监',
key: '0-0',
children: [
{ title: '产品经理1', key: '0-0-0' },
{ title: '产品经理2', key: '0-0-1' },
],
},
]);
//
const getDepartList = (params) => {
return http.post(department.dartList, params);
};
getDepartList({ orgId }).then((res) => {
apartmentTreeData.value = res.data;
});
const getTree = () => {
getDepartList({ orgId }).then((res) => {
apartmentTreeData.value = res.data;
NsMessage.success('操作成功');
});
};
const getUserTree = (params = { deptId: 2 }) => {
http.post(department.queryRoleTree, params).then((res) => {
userTreeData.value = res.data;
});
};
getUserTree({ deptId: 2 });
const opMap: any = {
type: 'add',
fuc: () => {},
record: {},
callback: null,
};
function fetch(api, params) {
return http.post(api, params);
@ -192,9 +205,14 @@
const addApartment = () => {
disabled.value = false;
opMap.type = 'add';
opMap.type = 'addDept';
formData.value = {};
opMap.fuc = (params) => {
fetch(department.deptSave, { ...params, orgId, projectId });
return http.post(department.deptSave, {
...params,
orgId,
projectId,
});
};
return;
};
@ -204,7 +222,7 @@
opMap.type = 'addson';
formData.value = {};
opMap.fuc = (params) => {
fetch(department.deptSave, {
return http.post(department.deptSave, {
...params,
orgId,
projectId,
@ -215,30 +233,58 @@
const addUser = () => {
disabled2.value = false;
opMap.type = 'addUser';
formData.value = {};
opMap.fuc = (params) => {
delete params.roleId;
return http.post(department.addRole, {
...params,
orgId,
projectId,
enName: 'leader',
roleNote: 'wqe',
});
};
};
const addUserSon = () => {
disabled.value = false;
opMap.type = 'addson';
opMap.type = 'addUserSon';
formData.value = {};
opMap.fuc = (params) => {
delete params.roleId;
delete params.proleId;
return http.post(department.addRole, {
...params,
proleId: 4,
orgId,
projectId,
enName: 'leader',
roleNote: 'wqe',
});
};
};
const deleteApartment = () => {
//
// opMap.type = 'deptDelete';
// opMap.fuc = (params) => {
// return http.post(department.deptDel, params).then(() => {
// NsMessage.success('');
// });
// };
Modal.confirm({
title: '是否确认删除',
icon: createVNode(ExclamationCircleOutlined),
content: createVNode('div', { style: 'color:red;' }, ''),
onOk() {
function deepDel(data = apartmentTreeData.value[0].children) {
data.map((item, index) => {
if (item.key === selectKey.value) data.splice(index, 1);
});
}
deepDel();
console.log(selectKey.value);
http.post(department.deptDel, { deptId: selectRef.value.deptInfo.deptId }).then(() => {
getTree();
clearData();
});
},
onCancel() {
console.log('Cancel');
},
class: 'test',
});
};
@ -248,38 +294,46 @@
icon: createVNode(ExclamationCircleOutlined),
content: createVNode('div', { style: 'color:red;' }, ''),
onOk() {
function deepDel(data = userTreeData.value[0].children) {
data.map((item, index) => {
if (item.key === selectKey2.value) data.splice(index, 1);
});
}
deepDel();
console.log(selectKey2.value);
},
onCancel() {
console.log('Cancel');
http.post(department.delRole, { roleId: selectRef2.value.roleId }).then(() => {
getUserTree();
});
},
class: 'test',
});
};
const clearData = () => {
selectRef.value = {};
formData.value = {};
opMap.type = '';
opMap.fuc = '';
selectKey.value = '';
};
//
const SelectApartmentTree = (selectedKeys: any, info: any) => {
console.log(selectedKeys, info);
disabled.value = false;
console.log(selectedKeys, 'selectedKeys');
console.log(info.node.dataRef, 'info');
const { selected } = info;
disabled.value = !selected;
console.log(info, 'info');
selectKey.value = selectedKeys[0];
selectRef.value = info.node.dataRef;
formData.value = info.node.dataRef.deptInfo;
formData.value = cloneDeep(info.node.dataRef.deptInfo);
opMap.type = 'editDpet';
opMap.fuc = (params) => {
return http.post(department.deptEdit, params);
};
getUserTree({ deptId: selectRef.value.deptInfo.deptId });
};
//
const SelectUserTree = (selectedKeys: any, info: any) => {
disabled2.value = false;
const { selected } = info;
disabled2.value = !selected;
console.log(selectedKeys, 'selectedKeys');
console.log(info.node.dataRef.info, 'info');
console.log(info, 'info');
selectKey2.value = selectedKeys[0];
selectRef2.value = info.node.dataRef;
formData2.value = info.node.dataRef.info;
formData2.value = cloneDeep(info.node.dataRef);
};
const CancelApartment = () => {
@ -305,27 +359,27 @@
// disabled.value = !disabled.value;
// console.log(formData.value.name, 'formData');
console.log(opMap.type, 'opMap.type');
if (opMap.type === 'add') {
console.log(opMap.type, 'ApartmentSure');
const opArr = ['addDept', 'editDpet'];
if (opArr.includes(opMap.type)) {
console.log(formRef.value, formData);
opMap.fuc && opMap.fuc(formData.value);
opMap.fuc &&
opMap.fuc(formData.value).then(() => {
getTree();
});
} else if (selectRef.value && opMap.type === 'addson')
opMap.fuc && opMap.fuc(formData.value);
else {
console.log('ss');
else if (opMap.type === 'deptDelete') {
opMap.fuc && opMap.fuc({ ...formData.value, selectRef: selectRef.value });
}
};
const UserSure = () => {
disabled2.value = !disabled2.value;
opMap.fuc && opMap.fuc(formData2.value);
console.log(formData2.value, 'formData2');
console.log(opMap.type, 'opMap.type');
if (opMap.type === 'add') {
userTreeData.value[0].children.push({
title: formData2.value.departname,
key: 'a2',
info: { ...formData2.value },
});
const typeArr = ['addUserSon', 'addUser'];
if (typeArr.includes(opMap.type)) {
opMap.fuc && opMap.fuc(formData2.value);
} else if (selectRef2.value && opMap.type === 'addson')
selectRef2.value['children'] = [
{
@ -379,16 +433,19 @@
display: flex;
flex: 1;
}
.left {
width: 50%;
height: calc(100vh-50px);
border-right: 5px solid rgb(229, 235, 240);
}
.tree {
width: 400px;
height: 89vh;
border-right: 2px solid rgb(229, 235, 240);
}
.right {
width: 50%;
}
@ -397,6 +454,7 @@
height: 50vh;
border-bottom: 5px solid rgb(229, 235, 240);
}
.ns-table-title {
text-align: left;
height: 46px;
@ -408,9 +466,11 @@
width: 100%;
border-bottom: 2px solid rgb(229, 235, 240);
}
.table {
width: 2000px;
}
.admin {
text-align: left;
height: 42px;
@ -421,6 +481,7 @@
padding-left: 16px;
width: calc(100% + 32px);
}
.form {
margin: 20px;
}

2
hx-ai-intelligent/src/view/organizationManage/usermanage/config.ts

@ -98,7 +98,7 @@ const options = ref([]);
const getUserPerList = (transform, params = {}) => {
return http.post(origanizemanage.queryUserPerList, { ...params }).then((res) => {
return res.data.map((item) => {
return res.data?.map((item) => {
item = { ...item, ...transform(item) };
return item;
});

71
hx-ai-intelligent/src/view/organizationManage/usermanage/index.vue

@ -64,11 +64,10 @@
class="drawerTable"
:model="data"
:pagination="false"
ref="mainRef"
rowKey="uuid" />
<template #footer>
<a-button style="margin-right: 8px" @click="onClose">取消</a-button>
<a-button type="primary" @click="onEdit">确定</a-button>
<a-button :disabled="!dynamicDisabled" type="primary" @click="onEdit">确定</a-button>
</template>
</a-drawer>
@ -79,12 +78,12 @@
cancelText="取消"
@ok="handleOk"
@cancel="handleClose">
<ns-form :schemas="formSchema2" :model="formData2" formLayout="vertical" />
<ns-form ref="modalFormRef" :schemas="formSchema2" :model="formData2" formLayout="vertical" />
</a-modal>
</div>
</template>
<script lang="ts">
import { createVNode, defineComponent, reactive, ref } from 'vue';
import { computed, createVNode, defineComponent, nextTick, reactive, ref } from 'vue';
import { http } from '/nerv-lib/util/http';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { cloneDeep } from 'lodash-es';
@ -100,6 +99,7 @@
let formData = ref({});
let formData2 = ref({ userRoleList: [1, 1, 3] });
const formRef = ref();
const modalFormRef = ref();
const visible = ref(false);
const addformvisible = ref(false);
const searchValue = ref<string>('');
@ -112,6 +112,9 @@
const userAuthList = ref([]);
const orgId = JSON.parse(sessionStorage.getItem('userInfo')).orgId;
const dynamicDisabled = computed(() => {
return formRef.value?.validateResult && userAuthList.value?.length;
});
const fetch = (api, params = { orgId }) => {
return http.post(api, params);
};
@ -147,8 +150,10 @@
};
const tableFetch = (params) => {
console.log(mainRef.value);
tableConfig.value.params = {
...tableConfig.value.params,
...mainRef.value.params,
...params,
};
@ -168,6 +173,8 @@
const onClose = () => {
visible.value = false;
formData.value = {};
userAuthList.value.splice(0);
};
const onEdit = () => {
@ -184,19 +191,21 @@
};
const handleOk = () => {
console.log(formData2.value, 'formData2.value');
console.log(casData.value, 'formData2.value');
if (casData.value?.length !== 3) {
NsMessage.error('未选择角色');
}
const str = casData.value.map((item) => item?.label).join('/');
userAuthList.value.push({
userAuthList: cloneDeep(casData.value),
deptRoleInfoList: str,
roleId: casData.value[2].value,
roleName: casData.value[2].label,
});
addformvisible.value = false;
} as never);
handleClose();
};
const handleClose = () => {
addformvisible.value = false;
modalFormRef.value.reset();
};
const tableConfig = ref({
@ -213,9 +222,10 @@
handle: () => {
opMap.type = 'add';
opMap.fuc = (formData: any) => {
console.log(formData, 'formData');
http.post(origanizemanage.addUser, formData).then(() => {
mainRef.value?.nsTableRef.reload();
visible.value = false;
NsMessage.success('操作成功');
});
};
visible.value = true;
@ -297,11 +307,11 @@
},
{
title: '部门/角色',
dataIndex: 'deptRoleInfoList',
dataIndex: 'userRoleInfos',
customRender: ({ value }) => {
if (!value) return '-';
return createVNode('div', {}, [
createVNode('span', {}, value[0]),
createVNode('span', {}, value[0]?.deptRoleInfoList),
value.length > 1 &&
createVNode(
'a',
@ -309,7 +319,9 @@
onClick: () =>
NsModal.info({
icon: null,
content: createVNode('div', { innerHTML: value.join('<br>') }),
content: createVNode('div', {
innerHTML: value.map((item) => item?.deptRoleInfoList).join('<br>'),
}),
}),
},
`+${value.length}`,
@ -331,14 +343,18 @@
name: 'RoleTypeEdit',
// dynamicParams: 'uuid',
handle: (record: any) => {
console.log(record, 'record');
formData.value = record;
userAuthList.value.splice(0);
setTimeout(() => {
formData.value = record;
userAuthList.value.push(...record.userRoleInfos);
}, 10);
opMap.type = 'edit';
opMap.fuc = (formData: any) => {
Object.assign(
mockData.value.filter((item) => item.id === record.id)[0],
formData,
);
http.post(origanizemanage.editUser, formData).then(() => {
mainRef.value?.nsTableRef.reload();
visible.value = false;
NsMessage.success('操作成功');
});
};
visible.value = true;
},
@ -449,11 +465,6 @@
name: 'RoleTypeAdd',
type: 'primary',
handle: () => {
// opMap.type = 'add';
// opMap.fuc = (formData2: any) => {
// console.log(formData2, 'formData2');
// userAuthList.value.push(cloneDeep(formData2));
// };
addformvisible.value = true;
},
},
@ -464,11 +475,11 @@
dataIndex: 'userRoleList',
customRender: ({ record }) => {
if (record) {
const res = record.userAuthList.reduce((pre, cur) => {
pre.push(cur.label);
return pre;
}, []);
return res.join('/');
// const res = record.userAuthList.reduce((pre, cur) => {
// pre.push(cur.label);
// return pre;
// }, []);
return record.deptRoleInfoList;
}
return '-';
},
@ -537,6 +548,8 @@
onSearch2,
handleOk,
handleClose,
dynamicDisabled,
modalFormRef,
};
},
});

12
lib/saas/router/helper/route-helper.ts

@ -1,11 +1,11 @@
import { RouteRecordRaw } from 'vue-router';
import { getComponent } from '/nerv-base/router/helper/view-helper';
import { ModuleMenu } from '/nerv-base/router/types';
import { RouteMenu, sortMenu } from '/nerv-base/router/helper/menu-helper';
import { isNumber } from 'lodash-es';
const transForm = (data) => {
return JSON.stringify(data || []);
};
export function transformRouteToMenu(route: RouteRecordRaw, parentCode = '') {
const { children, ...extend } = route;
if (extend.component) {
@ -41,12 +41,12 @@ export function transformRouteToMenu(route: RouteRecordRaw, parentCode = '') {
function dealBackApi(e: any) {
if (e.meta?.hideChildren) {
if (e.children !== undefined) {
return e.children[0].meta?.backApi || [];
return transForm(e.children[0].meta?.backApi);
} else {
return e.meta?.backApi ? e.meta?.backApi : [];
return transForm(e.meta?.backApi);
}
}
return e.meta?.backApi || [];
return transForm(e.meta?.backApi);
}
function dealOp(e: any) {

7
lib/util/http/axios.ts

@ -87,12 +87,17 @@ export class NSAxios {
// config.url = newUrl;
return config;
}, undefined);
const errCodeArr = [13, 1];
this.instance.interceptors.response.use(
(res: AxiosResponse) => {
console.log('success', res);
// todo
const code = res?.data?.retcode;
const msg = res?.data?.msg;
if (errCodeArr.includes(code)) {
NsMessage.error({ content: msg, key: this.errorMsgKey });
return Promise.reject(res);
}
return res;
},
(error: any) => {

Loading…
Cancel
Save