From 61218104d3c74c822be92c351f89a18333ec5f09 Mon Sep 17 00:00:00 2001 From: xuziqiang <1344691446@qq.com> Date: Tue, 4 Jun 2024 19:22:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=83=A8=E9=97=A8=E8=81=94=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hx-ai-intelligent/src/api/origanizemanage.ts | 8 + hx-ai-intelligent/src/config/app.config.ts | 2 +- hx-ai-intelligent/src/router/equipmentManage.ts | 6 +- hx-ai-intelligent/src/router/home.ts | 7 +- hx-ai-intelligent/src/router/organizationManage.ts | 21 +- .../organizationManage/departmentManage/config.ts | 20 +- .../organizationManage/departmentManage/index.vue | 251 +++++++++++++-------- .../view/organizationManage/usermanage/config.ts | 2 +- .../view/organizationManage/usermanage/index.vue | 71 +++--- lib/saas/router/helper/route-helper.ts | 12 +- lib/util/http/axios.ts | 7 +- 11 files changed, 237 insertions(+), 170 deletions(-) diff --git a/hx-ai-intelligent/src/api/origanizemanage.ts b/hx-ai-intelligent/src/api/origanizemanage.ts index be8b35f..4d02876 100644 --- a/hx-ai-intelligent/src/api/origanizemanage.ts +++ b/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`, } diff --git a/hx-ai-intelligent/src/config/app.config.ts b/hx-ai-intelligent/src/config/app.config.ts index 112f30b..5a871c2 100644 --- a/hx-ai-intelligent/src/config/app.config.ts +++ b/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', diff --git a/hx-ai-intelligent/src/router/equipmentManage.ts b/hx-ai-intelligent/src/router/equipmentManage.ts index 20e2842..1161e1b 100644 --- a/hx-ai-intelligent/src/router/equipmentManage.ts +++ b/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: [], }, }, ], diff --git a/hx-ai-intelligent/src/router/home.ts b/hx-ai-intelligent/src/router/home.ts index fc4dc14..c4e935a 100644 --- a/hx-ai-intelligent/src/router/home.ts +++ b/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: [], }, }, ], diff --git a/hx-ai-intelligent/src/router/organizationManage.ts b/hx-ai-intelligent/src/router/organizationManage.ts index 6592192..23c8f2d 100644 --- a/hx-ai-intelligent/src/router/organizationManage.ts +++ b/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: [], }, }, ], diff --git a/hx-ai-intelligent/src/view/organizationManage/departmentManage/config.ts b/hx-ai-intelligent/src/view/organizationManage/departmentManage/config.ts index 75d1868..ffd1c1f 100644 --- a/hx-ai-intelligent/src/view/organizationManage/departmentManage/config.ts +++ b/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', diff --git a/hx-ai-intelligent/src/view/organizationManage/departmentManage/index.vue b/hx-ai-intelligent/src/view/organizationManage/departmentManage/index.vue index e82fa4d..4cf69cd 100644 --- a/hx-ai-intelligent/src/view/organizationManage/departmentManage/index.vue +++ b/hx-ai-intelligent/src/view/organizationManage/departmentManage/index.vue @@ -6,16 +6,26 @@
部门管理
- 新增部门 - 新增子部门 - 删除 + 新增部门 + 新增子部门 + 删除 @@ -51,12 +61,20 @@
角色管理
- 新增角色 - 新增子角色 - 删除 - + 新增角色 + 新增子角色 + 删除 + @@ -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; } diff --git a/hx-ai-intelligent/src/view/organizationManage/usermanage/config.ts b/hx-ai-intelligent/src/view/organizationManage/usermanage/config.ts index 87ccdbb..c6381c7 100644 --- a/hx-ai-intelligent/src/view/organizationManage/usermanage/config.ts +++ b/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; }); diff --git a/hx-ai-intelligent/src/view/organizationManage/usermanage/index.vue b/hx-ai-intelligent/src/view/organizationManage/usermanage/index.vue index abb47eb..4bc6592 100644 --- a/hx-ai-intelligent/src/view/organizationManage/usermanage/index.vue +++ b/hx-ai-intelligent/src/view/organizationManage/usermanage/index.vue @@ -64,11 +64,10 @@ class="drawerTable" :model="data" :pagination="false" - ref="mainRef" rowKey="uuid" /> @@ -79,12 +78,12 @@ cancelText="取消" @ok="handleOk" @cancel="handleClose"> - +