Browse Source

feat: 权限逻辑处理

main
xuziqiang 5 months ago
parent
commit
bc80a22180
  1. 34
      hx-ai-intelligent/src/config/app.config.ts
  2. 2
      hx-ai-intelligent/src/router/equipmentControl.ts
  3. 2
      hx-ai-intelligent/src/router/equipmentManage.ts
  4. 2
      hx-ai-intelligent/src/router/home.ts
  5. 282
      hx-ai-intelligent/src/view/organizationManage/departmentManage/config.ts
  6. 1003
      hx-ai-intelligent/src/view/organizationManage/departmentManage/index.vue
  7. 21
      hx-ai-intelligent/src/view/organizationManage/usermanage/index.vue
  8. 2
      hx-ai-intelligent/vite.config.ts
  9. 4
      hx-op/src/config/app.config.ts
  10. 1
      lib/component/form/form/form-item.vue
  11. 4
      lib/saas/store/modules/app-config.ts
  12. 9
      lib/saas/store/modules/route.ts
  13. 1
      lib/saas/view/system/login.vue

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

@ -1,9 +1,9 @@
/** @format */ import { userInfo, userResource } from './../../../hx-op/src/api/user';
import { dateUtil } from '/nerv-lib/util/date-util';
import mockResource from './resource.json';
import { http } from '/nerv-lib/saas'; import { http } from '/nerv-lib/saas';
import { ref } from 'vue';
import { permission } from '/@/api/origanizemanage'; import { permission } from '/@/api/origanizemanage';
import { appConfigStore } from '/nerv-lib/saas/store/modules/app-config';
import { authorizationService } from '/nerv-base/store/modules/authorization-service';
import { isEmpty } from 'lodash-es';
// const { permissionVos } = sessionStorage.getItem('userInfo'); // const { permissionVos } = sessionStorage.getItem('userInfo');
// ? JSON.parse(sessionStorage.getItem('userInfo')!) // ? JSON.parse(sessionStorage.getItem('userInfo')!)
@ -59,7 +59,13 @@ export const appConfig = {
api: '/carbon-smart/user/login/logInInfo', api: '/carbon-smart/user/login/logInInfo',
placeholder: '请选择', placeholder: '请选择',
autoSelectFirst: true, autoSelectFirst: true,
onChange: (cur) => { onChange: async (cur, record) => {
console.log(cur, record);
const configStore = appConfigStore();
const useAuthorization = authorizationService();
const res = await configStore.userResource(record);
useAuthorization.updateUserResource(res.data);
// value.value = cur; // value.value = cur;
}, },
resultField: 'data.linkList', resultField: 'data.linkList',
@ -73,18 +79,24 @@ export const appConfig = {
userLoginApi: (params) => { userLoginApi: (params) => {
return http.post('/carbon-smart/user/login', { ...params }); return http.post('/carbon-smart/user/login', { ...params });
}, },
userResourceApi: () => { userResourceApi: (params) => {
return http.post('/carbon-smart/user/login/logInInfo').then((res) => { console.log(params, 'userResource');
return { data: res.data.permissionVos };
}); const userInfo = JSON.parse(sessionStorage.getItem('userInfo')!);
const ownOrgInfo = userInfo.linkList?.filter(({ isOwn }) => isOwn)[0];
return http
.post('/carbon-smart/user/login/logInPermission', !isEmpty(params) ? params : ownOrgInfo)
.then((res) => {
return res;
});
}, },
userInfoApi: () => { userInfoApi: () => {
return http.post('/carbon-smart/user/login/logInInfo').then((res) => { return http.post('/carbon-smart/user/login/logInInfo').then((res) => {
const info = res.data; const info = res.data;
const trD = transform(info, { const trD = transform(info, {
accountCode: 'userId', accountCode: 'userId',
accountName: 'realName', accountName: 'accountNo',
accountRealName: 'realName', accountRealName: 'accountNo',
orgId: 'orgId', orgId: 'orgId',
orgName: 'orgName', orgName: 'orgName',
projectId: 'projectId', projectId: 'projectId',

2
hx-ai-intelligent/src/router/equipmentControl.ts

@ -3,7 +3,7 @@ const equipmentControl = {
path: '/equipmentControl', path: '/equipmentControl',
name: 'EquipmentControl', name: 'EquipmentControl',
meta: { title: '设备群控', icon: 'dicizhishou', index: 4 }, meta: { title: '设备群控', icon: 'dicizhishou', index: 4 },
redirect: { name: 'homeIndex' }, redirect: { name: 'LightManage' },
children: [ children: [
{ {
path: 'lightManage', path: 'lightManage',

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

@ -3,7 +3,7 @@ const equipment = {
path: '/equipmentManage', path: '/equipmentManage',
name: 'EquipmentManage', name: 'EquipmentManage',
meta: { title: '设备管理', icon: 'dicizhishou', index: 1 }, meta: { title: '设备管理', icon: 'dicizhishou', index: 1 },
redirect: { name: 'homeIndex' }, redirect: { name: 'Ledger' },
children: [ children: [
{ {
path: 'ledger', path: 'ledger',

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

@ -10,7 +10,7 @@ const home = {
name: 'homeIndex', name: 'homeIndex',
meta: { title: '首页', hideChildren: true, icon: 'dicizhishou' }, meta: { title: '首页', hideChildren: true, icon: 'dicizhishou' },
component: () => import('/@/view/developing.vue'), component: () => import('/@/view/developing.vue'),
redirect: { name: 'homeIndex' }, // redirect: { name: 'homeIndex' },
// children: [ // children: [
// { // {
// path: 'index', // path: 'index',

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

@ -2,83 +2,75 @@ import { ref } from 'vue';
export const formConfig = (disabled: Boolean) => { export const formConfig = (disabled: Boolean) => {
return ref([ return ref([
{ label: '企业名称', field: 'orgName', show: false },
{ {
field: 'field111', label: '部门名称',
component: 'NsChildForm', field: 'deptName',
component: 'NsInput',
componentProps: { componentProps: {
schemas: [ disabled: disabled,
{ label: '企业名称', field: 'orgName', show: false }, placeholder: '请输入部门名称',
{ maxLength: 20,
label: '部门名称', },
field: 'deptName', rules: [
component: 'NsInput', {
componentProps: { required: true,
disabled: disabled, message: '请输入部门名称',
placeholder: '请输入部门名称', },
maxLength: 20, ],
}, },
rules: [ // {
{ // label: '上级部门',
required: true, // field: 'department',
message: '请输入部门名称', // component: 'NsSelect',
}, // componentProps: {
], // disabled: true,
}, // options: [
// { // {
// label: '上级部门', // label: '部门1',
// field: 'department', // value: 1,
// component: 'NsSelect', // },
// componentProps: { // {
// disabled: true, // label: '部门2',
// options: [ // value: 2,
// { // },
// label: '部门1', // ],
// value: 1, // },
// }, // },
// { {
// label: '部门2', label: '部门编码',
// value: 2, field: 'deptCode',
// }, component: 'NsInput',
// ], componentProps: {
// }, disabled: disabled,
// }, placeholder: '请输入部门编码',
{ maxLength: 20,
label: '部门编码', },
field: 'deptCode', rules: [
component: 'NsInput', {
componentProps: { required: true,
disabled: disabled, message: '请输入部门编码',
placeholder: '请输入部门编码', },
maxLength: 20, ],
}, },
rules: [ {
{ label: '排序',
required: true, field: 'sort',
message: '请输入部门编码', component: 'NsInput',
}, componentProps: {
], disabled: disabled,
}, placeholder: '请输入排序',
{ maxLength: 2,
label: '排序', },
field: 'sort', },
component: 'NsInput', {
componentProps: { field: 'remark',
disabled: disabled, label: '备注',
placeholder: '请输入排序', component: 'NsTextarea',
maxLength: 2, componentProps: {
}, disabled: disabled,
}, placeholder: '请输入',
{ maxLength: 300,
field: 'remark',
label: '备注',
component: 'NsTextarea',
componentProps: {
disabled: disabled,
placeholder: '请输入',
maxLength: 300,
},
},
],
}, },
}, },
]); ]);
@ -86,84 +78,76 @@ export const formConfig = (disabled: Boolean) => {
export const formConfig2 = (disabled2: Boolean) => { export const formConfig2 = (disabled2: Boolean) => {
return ref([ return ref([
{ label: '部门名称', field: 'deptName', show: false },
{ {
field: 'field111', label: '角色名称',
component: 'NsChildForm', field: 'zhName',
component: 'NsInput',
componentProps: { componentProps: {
schemas: [ disabled: disabled2,
{ label: '部门名称', field: 'deptName', show: false }, placeholder: '请输入角色名称',
maxLength: 20,
{ },
label: '角色名称', rules: [
field: 'zhName', {
component: 'NsInput', required: true,
componentProps: { message: '请输入角色名称',
disabled: disabled2, },
placeholder: '请输入角色名称', ],
maxLength: 20, },
}, // {
rules: [ // label: '上级领导',
{ // field: 'department',
required: true, // component: 'NsSelect',
message: '请输入角色名称', // componentProps: {
}, // disabled: true,
], // },
}, // },
// { {
// label: '上级领导', label: '节点编码',
// field: 'department', field: 'roleCode',
// component: 'NsSelect', component: 'NsInput',
// componentProps: { componentProps: {
// disabled: true, disabled: disabled2,
// }, placeholder: '请输入节点编码',
// }, maxLength: 20,
{ },
label: '节点编码', rules: [
field: 'roleCode', {
component: 'NsInput', required: true,
componentProps: { message: '请输入节点编码',
disabled: disabled2, },
placeholder: '请输入节点编码', ],
maxLength: 20, },
}, {
rules: [ label: '是否部门领导',
{ field: 'isLeader',
required: true, component: 'NsRadioGroup',
message: '请输入节点编码', componentProps: {
}, disabled: disabled2,
], radioType: 'radio',
}, options: [
{ { label: '是', value: 0 },
label: '是否部门领导', { label: '否', value: 1 },
field: 'isLeader',
component: 'NsRadioGroup',
componentProps: {
disabled: disabled2,
radioType: 'radio',
options: [
{ label: '是', value: 0 },
{ label: '否', value: 1 },
],
},
rules: [
{
required: true,
message: '请选择是否部门领导',
},
],
},
{
field: 'remark',
label: '备注',
component: 'NsTextarea',
componentProps: {
disabled: disabled2,
placeholder: '请输入',
maxLength: 300,
},
},
], ],
}, },
rules: [
{
required: true,
message: '请选择是否部门领导',
},
],
},
{
field: 'remark',
label: '备注',
component: 'NsTextarea',
componentProps: {
disabled: disabled2,
placeholder: '请输入',
maxLength: 300,
},
}, },
]); ]);
}; };

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

File diff suppressed because it is too large

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

@ -478,7 +478,7 @@
headerActions: [ headerActions: [
{ {
label: '新增', label: '新增',
name: 'RoleTypeAdd', name: 'userAdd',
type: 'primary', type: 'primary',
handle: () => { handle: () => {
addformvisible.value = true; addformvisible.value = true;
@ -504,26 +504,9 @@
columnActions: { columnActions: {
title: '操作', title: '操作',
actions: [ actions: [
// {
// label: '',
// name: 'RoleTypeEdit',
// // dynamicParams: 'uuid',
// handle: (record: any) => {
// console.log(record, 'record');
// formData2.value = record;
// opMap.type = 'edit';
// opMap.fuc = (formData2: any) => {
// Object.assign(
// mockData.value.filter((item) => item.id === record.id)[0],
// formData2,
// );
// };
// addformvisible.value = true;
// },
// },
{ {
label: '删除', label: '删除',
name: 'RoleTypeEdit', name: 'userAdd',
confirm: true, confirm: true,
handle: (record: any, name: any, reload: any) => { handle: (record: any, name: any, reload: any) => {
const id = record.roleId; const id = record.roleId;

2
hx-ai-intelligent/vite.config.ts

@ -12,7 +12,7 @@ const proxy = {
changeOrigin: true, changeOrigin: true,
}, },
'/carbon-smart': { '/carbon-smart': {
target: 'http://123.60.103.97:8224', target: 'http://192.168.112.144:8224',
changeOrigin: true, changeOrigin: true,
rewrite: (path) => path.replace(/^\/carbon-smart/, ''), rewrite: (path) => path.replace(/^\/carbon-smart/, ''),
}, },

4
hx-op/src/config/app.config.ts

@ -73,8 +73,8 @@ export const appConfig = {
const info = res.data; const info = res.data;
const trD = transform(info, { const trD = transform(info, {
accountCode: 'userId', accountCode: 'userId',
accountName: 'realName', accountName: 'accountNo',
accountRealName: 'realName', accountRealName: 'accountNo',
orgId: 'orgId', orgId: 'orgId',
orgName: 'orgName', orgName: 'orgName',
projectId: 'projectId', projectId: 'projectId',

1
lib/component/form/form/form-item.vue

@ -298,7 +298,6 @@
validateRef.value = text; validateRef.value = text;
}, },
}; };
console.log(on, 'checkON');
return { return {
...propsData, ...propsData,

4
lib/saas/store/modules/app-config.ts

@ -123,11 +123,11 @@ export const appConfigStore = defineStore({
return { data: {} }; return { data: {} };
} }
}, },
userResource() { userResource(params = {}) {
if (this.userResourceApi) { if (this.userResourceApi) {
return httpRequest({ return httpRequest({
api: this.userResourceApi, api: this.userResourceApi,
params: {}, params,
pathParams: {}, pathParams: {},
requestConfig, requestConfig,
}); });

9
lib/saas/store/modules/route.ts

@ -90,9 +90,9 @@ export const useRouteStore = defineStore({
}); });
// const initPcResource = { application: {}, menus: [] }; // const initPcResource = { application: {}, menus: [] };
let initPcResource = []; let initPcResource = [];
this.routeModule.sort((a, b) => { // this.routeModule.sort((a, b) => {
return a.route?.meta?.index - b.route?.meta?.index; // return a.route?.meta?.index - b.route?.meta?.index;
}); // });
const info = JSON.parse(JSON.stringify(this.routeModule)); const info = JSON.parse(JSON.stringify(this.routeModule));
initRouteMouleList(info); initRouteMouleList(info);
function initRouteMouleList(info) { function initRouteMouleList(info) {
@ -116,6 +116,9 @@ export const useRouteStore = defineStore({
}); });
} }
// initPcResource.application = appConfig.resourceInfo?.application as object; // initPcResource.application = appConfig.resourceInfo?.application as object;
console.log(info);
return;
initPcResource = appConfig.resourceInfo?.dealReosurceList initPcResource = appConfig.resourceInfo?.dealReosurceList
? appConfig.resourceInfo?.dealReosurceList(info) ? appConfig.resourceInfo?.dealReosurceList(info)
: info; : info;

1
lib/saas/view/system/login.vue

@ -105,7 +105,6 @@
loading.value = false; loading.value = false;
if (configStore.enablePermissions) { if (configStore.enablePermissions) {
const res = await configStore.userResource(); const res = await configStore.userResource();
console.log(res, 'cccccccccccccccccccccccccccccc');
if (configStore.customApplication) { if (configStore.customApplication) {
await useAuthorization.initMenuResource(); await useAuthorization.initMenuResource();

Loading…
Cancel
Save