栏目权限页面的编写

This commit is contained in:
黎永顺 2022-11-08 15:56:34 +08:00
parent 69441eca6c
commit 1a1441ac95
4 changed files with 190 additions and 151 deletions

View File

@ -6,3 +6,9 @@ export const getTableEdit = (params) => {
export const userDefineCardItemSave = (params) => {
return WeaTools.callApi('/api/hrm/carddisplay/saveCustomCard', 'POST', params);
}
export const hasRight = (params) => {
return WeaTools.callApi('/api/bs/hrmorganization/cardAccess/hasRight', 'POST', params);
}
export const getTable = (params) => {
return WeaTools.callApi('/api/bs/hrmorganization/cardAccess/getTable', 'POST', params);
}

View File

@ -1,87 +1,103 @@
import React, { Component } from "react";
import { toJS } from 'mobx';
import { inject, observer } from "mobx-react";
import { WeaTableEdit } from "ecCom";
@inject("columnPermission")
@observer
class PermissionItem extends Component {
componentDidMount() {
this.init();
}
init = () => {
const { columnPermission } = this.props;
columnPermission.loadTabOneRelatedData();
};
render() {
const columns = [
{
title: "栏目",
dataIndex: "column",
key: "column",
com: [
{ label: "", type: "TEXT", viewAttr: 1, key: "column" }
]
},
{
title: "是否启用",
dataIndex: "isused",
key: "isused",
com: [
{
type: "CHECKBOX",
key: "isused",
viewAttr: 1
}
]
},
{
title: "所有人可见",
dataIndex: "all",
key: "all",
com: [
{
type: "CHECKBOX",
key: "all"
}
]
},
{
title: "上级可见",
dataIndex: "highVisible",
key: "highVisible",
com: [
{
type: "CHECKBOX",
key: "highVisible"
}
]
},
{
title: "所有上级可见",
dataIndex: "allVisible",
key: "allVisible",
com: [
{
type: "CHECKBOX",
key: "allVisible"
}
]
},
{
title: "查看自定义",
dataIndex: "customRole",
key: "customRole",
com: [
{ label: "", type: "TEXT", viewAttr: 1, key: "customRole" }
]
}
];
const datas = [
{
id: "1",
column: "基本信息",
isused: false,
all: false,
highVisible: true,
allVisible: false,
customRole: "角色1"
}
];
const { columnPermission } = this.props, { tabOneRelatedData } = columnPermission;
const { datas, columns } = tabOneRelatedData;
// const columns = [
// {
// title: "栏目",
// dataIndex: "column",
// key: "column",
// com: [
// { label: "", type: "TEXT", viewAttr: 1, key: "column" }
// ]
// },
// {
// title: "是否启用",
// dataIndex: "isused",
// key: "isused",
// com: [
// {
// type: "CHECKBOX",
// key: "isused",
// viewAttr: 1
// }
// ]
// },
// {
// title: "所有人可见",
// dataIndex: "all",
// key: "all",
// com: [
// {
// type: "CHECKBOX",
// key: "all"
// }
// ]
// },
// {
// title: "上级可见",
// dataIndex: "highVisible",
// key: "highVisible",
// com: [
// {
// type: "CHECKBOX",
// key: "highVisible"
// }
// ]
// },
// {
// title: "所有上级可见",
// dataIndex: "allVisible",
// key: "allVisible",
// com: [
// {
// type: "CHECKBOX",
// key: "allVisible"
// }
// ]
// },
// {
// title: "查看自定义",
// dataIndex: "customRole",
// key: "customRole",
// com: [
// { label: "", type: "TEXT", viewAttr: 1, key: "customRole" }
// ]
// }
// ];
// const datas = [
// {
// id: "1",
// column: "基本信息",
// isused: false,
// all: false,
// highVisible: true,
// allVisible: false,
// customRole: "角色1"
// }
// ];
return (
<div>
<WeaTableEdit
columns={columns}
datas={datas}
columns={toJS(columns)}
datas={toJS(datas)}
showAdd={false}
showCopy={false}
showDelete={false}

View File

@ -5,10 +5,20 @@ import { Button } from "antd";
import PermissionItem from "./components/permissionItem";
import DefineShowItems from "./components/defineShowItems";
import { i18n } from "../../public/i18n";
import { renderNoright } from "../../util";
@inject("columnPermission")
@observer
class ColumnPermission extends Component {
componentDidMount() {
this.init();
}
init = () => {
const { columnPermission } = this.props;
columnPermission.getRight();
};
getTopMenuBtns = () => {
return [
<Button type="primary" onClick={this.save}>保存</Button>
@ -40,7 +50,10 @@ class ColumnPermission extends Component {
render() {
const { columnPermission } = this.props;
const { selectedKey } = columnPermission;
const { selectedKey, authorized } = columnPermission;
// if (!authorized) {
// return renderNoright();
// }
return (
<div style={{ height: "100%" }}>
<WeaRightMenu

View File

@ -1,20 +1,22 @@
import { observable, action, computed, extendObservable } from 'mobx';
import { message } from 'antd'
import { WeaHelpfulTip } from 'ecCom';
import {isEmpty} from "lodash";
import { i18n } from '../public/i18n';
import * as mobx from 'mobx';
import * as Api from '../apis/columnPermission';
import * as mobx from "mobx";
import { action, computed, extendObservable, observable } from "mobx";
import { message } from "antd";
import { WeaHelpfulTip } from "ecCom";
import { isEmpty } from "lodash";
import { i18n } from "../public/i18n";
import * as Api from "../apis/columnPermission";
const toJS = mobx.toJS;
export class ColumnPermission {
@observable weaTopTitle = i18n.module.staffCardDisplay();
@observable btnMenu = [];
@observable selectedKey = '0';
@observable selectedKey = "0";
@observable authorized = false;
@observable loading = true;
@observable tabOneRelatedData = {
data: [],
datas: [], //datas受控
columns: [],
loading: true
};
@observable tabTwoRelatedData = {
@ -22,7 +24,7 @@ export class ColumnPermission {
columns: [],
loading: true,
selectedData: {}, //selectedData受控
authorized: false,
authorized: false
};
@computed get cardItemsLength() {
@ -45,13 +47,13 @@ export class ColumnPermission {
let topMenu = [];
let rightMenu = [];
this.btnMenu.map(item => {
(item.isTop == '1' || item.isBatch == '1') && topMenu.push(item);
(item.isTop == "1" || item.isBatch == "1") && topMenu.push(item);
!item.isBatch && rightMenu.push(item);
});
return {
topMenu,
rightMenu
}
};
}
@computed get checkedItems() {
@ -63,13 +65,13 @@ export class ColumnPermission {
f.children.map(s => {
if (s.value) {
fArr.push(
s.id,
)
s.id
);
s.children.map(t => {
t.value && fArr.push(
t.id
)
})
);
});
}
});
arr.push(fArr.toString());
@ -90,21 +92,13 @@ export class ColumnPermission {
@action
getRight() {
this.loading = true;
Api.getRight().then(res => {
let {
api_status,
btnMenu,
hasRight
} = res;
if (api_status) {
if (hasRight) {
this.setRight(true);
btnMenu !== undefined && this.setBtnMenu(btnMenu);
}
this.loading = false;
Api.hasRight().then(res => {
let { code, data, msg } = res;
const { hasRight } = data;
if (code === 200) {
this.setRight(hasRight);
} else {
message.error(res.message);
message.error(msg);
}
}).catch(error => {
message.error(error);
@ -115,28 +109,34 @@ export class ColumnPermission {
this.tabOneRelatedData.loading = true;
Promise.all(
[
Api.getCardItemsData(),
Api.getTable()
]
).then(res => {
res.map((rs, index) => {
if (index == 0) {
let {
api_status,
data
} = rs;
if (api_status) {
data !== undefined && extendObservable(this.tabOneRelatedData, {
data: data
});
extendObservable(this.tabOneRelatedData, {
loading: false
});
} else {
message.error(rs.message);
}
}
console.log('res', res);
extendObservable(this.tabOneRelatedData, {
datas: [],
columns: [],
loading: false
});
// res.map((rs, index) => {
// if (index == 0) {
// let {
// api_status,
// data
// } = rs;
//
// if (api_status) {
// data !== undefined && extendObservable(this.tabOneRelatedData, {
// data: data
// });
// extendObservable(this.tabOneRelatedData, {
// loading: false
// });
// } else {
// message.error(rs.message);
// }
// }
// });
}).catch(error => {
message.error(error);
});
@ -146,7 +146,7 @@ export class ColumnPermission {
this.tabTwoRelatedData.loading = true;
Promise.all(
[
Api.getTableEdit(),
Api.getTableEdit()
]
).then(res => {
res.map((rs, index) => {
@ -165,24 +165,28 @@ export class ColumnPermission {
}
this.tabTwoRelatedData.authorized = true;
columns.map((c, index) => {
if (c.key === 'itemurl') {
if (c.key === "itemurl") {
c.title = <span>
<span>{c.title}</span>
<span style={{marginLeft: 10}}>
<WeaHelpfulTip ecId={`${this && this.props && this.props.ecId || ''}_WeaHelpfulTip@4vdvfp@${index}`} title='自定义页面链接地址可以为外网地址http://www.baidu.com
<span style={{ marginLeft: 10 }}>
<WeaHelpfulTip
ecId={`${this && this.props && this.props.ecId || ""}_WeaHelpfulTip@4vdvfp@${index}`}
title="自定义页面链接地址可以为外网地址http://www.baidu.com
也可以是内部地址/test.jsp可以带上参数传参像这样/test.jsp?a=1&b=2
也可以写占位符{#id}传人员id像这样/test.jsp?a=1&b={#id}&mypara2={#id}
即使不写占位符默认也会收到1个固定的参数hrmResourceID=人员id'/>
即使不写占位符默认也会收到1个固定的参数hrmResourceID=人员id"/>
</span>
</span>
} else if (c.key === 'itemnum') {
</span>;
} else if (c.key === "itemnum") {
c.title = <span>
<span>{c.title}</span>
<span style={{marginLeft: 10}}>
<WeaHelpfulTip ecId={`${this && this.props && this.props.ecId || ''}_WeaHelpfulTip@wotuuk@${index}`} title='填写类的全路径例如com.engine.hrm.cmd.hrmcarditem.GetTabNumDemoCmd,类中包含execute方法返回int型数据
填写不正确的路径并启用对应tab页title将会出现error字样'/>
<span style={{ marginLeft: 10 }}>
<WeaHelpfulTip
ecId={`${this && this.props && this.props.ecId || ""}_WeaHelpfulTip@wotuuk@${index}`}
title="填写类的全路径例如com.engine.hrm.cmd.hrmcarditem.GetTabNumDemoCmd,类中包含execute方法返回int型数据
填写不正确的路径并启用对应tab页title将会出现error字样"/>
</span>
</span>
</span>;
}
});
@ -210,15 +214,15 @@ export class ColumnPermission {
columnPermissionSave() {
let params = {
data: toJS(this.checkedItems)
}
};
Api.cardItemsSettingSave(params).then(res => {
let {
api_status,
sign,
sign
} = res;
if (api_status) {
if (sign == '1') {
if (sign == "1") {
res.message && message.success(res.message);
} else {
res.message && message.warning(res.message);
@ -238,11 +242,11 @@ export class ColumnPermission {
Api.userDefineCardItemSave(params).then(res => {
let {
api_status,
sign,
sign
} = res;
if (api_status) {
if (sign == '1') {
if (sign == "1") {
res.message && message.success(res.message);
} else {
res.message && message.warning(res.message);
@ -261,14 +265,14 @@ export class ColumnPermission {
const _rows = isEmpty(arr) ? [] : rows;
_rows && _rows.map(index => {
arr[index].isused = '1';
arr[index].isused = "1";
});
arr.map((item, index) => {
if (!item.isused) item.isused = '0';
if (!item.isused) item.isused = "0";
for (let key in item) {
json[key + '_' + index] = item[key];
json[key + "_" + index] = item[key];
}
})
});
return json;
}
@ -276,7 +280,7 @@ export class ColumnPermission {
verify(arr) {
for (let i = 0; i < arr.length; i++) {
if (!arr[i].itemname || !arr[i].itemurl) {
const temp = i18n.message.requiredInfoIsNotFull().replace('{param}', i + 1);
const temp = i18n.message.requiredInfoIsNotFull().replace("{param}", i + 1);
message.warning(temp);
return false;
}
@ -311,11 +315,11 @@ export class ColumnPermission {
setTableEditDatas(e) {
e.map(item => {
for (let key in item) {
if (key == 'undefined') {
if (key == "undefined") {
delete item[key];
}
if (!item['isused']) {
item['isused'] = '';
if (!item["isused"]) {
item["isused"] = "";
}
}
});
@ -325,7 +329,7 @@ export class ColumnPermission {
}
mobxDataReset() {
this.selectedKey = '0';
this.selectedKey = "0";
extendObservable(this.tabOneRelatedData, {
loading: true
});