栏目权限页面的编写
This commit is contained in:
parent
ddb59fa9f9
commit
62e8ef22c1
|
|
@ -12,3 +12,13 @@ export const hasRight = (params) => {
|
||||||
export const getTable = (params) => {
|
export const getTable = (params) => {
|
||||||
return WeaTools.callApi('/api/bs/hrmorganization/cardAccess/getTable', 'GET', params);
|
return WeaTools.callApi('/api/bs/hrmorganization/cardAccess/getTable', 'GET', params);
|
||||||
}
|
}
|
||||||
|
export const cardAccessSave = (params) => {
|
||||||
|
return fetch('/api/bs/hrmorganization/cardAccess/save', {
|
||||||
|
method: 'POST',
|
||||||
|
mode: 'cors',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify(params)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import React, { Component } from "react";
|
import React, { Component } from "react";
|
||||||
import { WeaTableNew } from "comsMobx";
|
import { WeaTableNew } from "comsMobx";
|
||||||
import { WeaCheckbox, WeaBrowser } from "ecCom";
|
import { WeaBrowser, WeaCheckbox } from "ecCom";
|
||||||
import { inject, observer } from "mobx-react";
|
import { inject, observer } from "mobx-react";
|
||||||
|
import { toJS } from "mobx";
|
||||||
|
|
||||||
const WeaTable = WeaTableNew.WeaTable;
|
const WeaTable = WeaTableNew.WeaTable;
|
||||||
|
|
||||||
|
|
@ -16,24 +17,47 @@ class PermissionItem extends Component {
|
||||||
const { columnPermission } = this.props;
|
const { columnPermission } = this.props;
|
||||||
columnPermission.loadTabOneRelatedData();
|
columnPermission.loadTabOneRelatedData();
|
||||||
};
|
};
|
||||||
|
changeSaveParams = (record, value, dataIndex) => {
|
||||||
|
const { columnPermission } = this.props;
|
||||||
|
const list = _.isEmpty(columnPermission.columnsPermissionData) ? toJS(columnPermission.tableStore.datas) : columnPermission.columnsPermissionData;
|
||||||
|
const dataSource = _.map([...list], it => {
|
||||||
|
if (record.id === it.id) {
|
||||||
|
return {
|
||||||
|
...it,
|
||||||
|
[dataIndex]: value
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return { ...it };
|
||||||
|
});
|
||||||
|
columnPermission.setColumnsPermissionData(dataSource);
|
||||||
|
};
|
||||||
renderRenderColumns = columns => {
|
renderRenderColumns = columns => {
|
||||||
columns.forEach((c, index) => {
|
columns.forEach((c, index) => {
|
||||||
if (c.dataIndex === "status" || c.dataIndex === "all_people" ||
|
if (c.dataIndex === "status" || c.dataIndex === "all_people" ||
|
||||||
c.dataIndex === "superior" || c.dataIndex === "all_superior") {
|
c.dataIndex === "superior" || c.dataIndex === "all_superior") {
|
||||||
c.render = function (text, record) {
|
c.render = (text, record) => {
|
||||||
return (
|
return (
|
||||||
<WeaCheckbox
|
<WeaCheckbox
|
||||||
// value={}
|
value={record[c.dataIndex]}
|
||||||
// onChange={value => {
|
onChange={value => {
|
||||||
// console.log(value);
|
this.changeSaveParams(record, value, c.dataIndex);
|
||||||
// }}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
} else if (c.dataIndex === "custom") {
|
} else if (c.dataIndex === "custom") {
|
||||||
c.render = function (text, record) {
|
c.render = (text, record) => {
|
||||||
return (
|
return (
|
||||||
<WeaBrowser type={267} inputStyle={{ width: 200 }} />
|
<WeaBrowser
|
||||||
|
inputStyle={{ width: 200 }}
|
||||||
|
type={65}
|
||||||
|
value={record[c.dataIndex]}
|
||||||
|
title="多角色"
|
||||||
|
linkUrl="/spa/hrm/engine.html#/hrmengine/roleInfo/info?id="
|
||||||
|
onChange={value => {
|
||||||
|
this.changeSaveParams(record, value, c.dataIndex);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
import * as mobx from "mobx";
|
import * as mobx from "mobx";
|
||||||
import { action, computed, extendObservable, observable } from "mobx";
|
import { action, computed, extendObservable, observable } from "mobx";
|
||||||
import { WeaTableNew } from 'comsMobx';
|
import { WeaTableNew } from "comsMobx";
|
||||||
import { message } from "antd";
|
import { message } from "antd";
|
||||||
import { WeaHelpfulTip } from "ecCom";
|
import { WeaHelpfulTip } from "ecCom";
|
||||||
import { isEmpty } from "lodash";
|
import { isEmpty } from "lodash";
|
||||||
import { i18n } from "../public/i18n";
|
import { i18n } from "../public/i18n";
|
||||||
import * as Api from "../apis/columnPermission";
|
import * as Api from "../apis/columnPermission";
|
||||||
|
|
||||||
const { TableStore } = WeaTableNew;
|
const { TableStore } = WeaTableNew;
|
||||||
|
|
||||||
const toJS = mobx.toJS;
|
const toJS = mobx.toJS;
|
||||||
|
|
||||||
export class ColumnPermission {
|
export class ColumnPermission {
|
||||||
@observable weaTopTitle = i18n.module.staffCardDisplay();
|
|
||||||
@observable tableStore = new TableStore();
|
@observable tableStore = new TableStore();
|
||||||
@observable btnMenu = [];
|
@observable columnsPermissionData = [];
|
||||||
@observable selectedKey = "0";
|
@observable selectedKey = "0";
|
||||||
@observable authorized = false;
|
@observable authorized = true;
|
||||||
@observable loading = true;
|
@observable loading = true;
|
||||||
@observable tabOneRelatedData = {
|
@observable tabOneRelatedData = {
|
||||||
datas: [], //datas受控
|
datas: [], //datas受控
|
||||||
|
|
@ -30,66 +30,16 @@ export class ColumnPermission {
|
||||||
authorized: false
|
authorized: false
|
||||||
};
|
};
|
||||||
|
|
||||||
@computed get cardItemsLength() {
|
|
||||||
let arr = [];
|
|
||||||
for (let i = 0; i < this.tabOneRelatedData.data.length; i++) {
|
|
||||||
let cardItemsLength = 0;
|
|
||||||
this.tabOneRelatedData.data[i].children.map(s => {
|
|
||||||
if (s.children.length > 0) {
|
|
||||||
cardItemsLength += s.children.length;
|
|
||||||
} else {
|
|
||||||
cardItemsLength += 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
arr.push(cardItemsLength);
|
|
||||||
}
|
|
||||||
return arr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@computed get menu() {
|
|
||||||
let topMenu = [];
|
|
||||||
let rightMenu = [];
|
|
||||||
this.btnMenu.map(item => {
|
|
||||||
(item.isTop == "1" || item.isBatch == "1") && topMenu.push(item);
|
|
||||||
!item.isBatch && rightMenu.push(item);
|
|
||||||
});
|
|
||||||
return {
|
|
||||||
topMenu,
|
|
||||||
rightMenu
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@computed get checkedItems() {
|
@computed get checkedItems() {
|
||||||
let arr = [];
|
const data = isEmpty(this.columnsPermissionData) ? toJS(this.tableStore.datas) : this.columnsPermissionData;
|
||||||
toJS(this.tabOneRelatedData.data).map(f => {
|
return this.arrColumnsToJson(data);
|
||||||
let fArr = [];
|
|
||||||
if (f.value) {
|
|
||||||
fArr.push(f.id);
|
|
||||||
f.children.map(s => {
|
|
||||||
if (s.value) {
|
|
||||||
fArr.push(
|
|
||||||
s.id
|
|
||||||
);
|
|
||||||
s.children.map(t => {
|
|
||||||
t.value && fArr.push(
|
|
||||||
t.id
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
arr.push(fArr.toString());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return arr.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@computed get tabTwoSaveParams() {
|
@computed get tabTwoSaveParams() {
|
||||||
let datas = this.tabTwoRelatedData.datas;
|
let datas = this.tabTwoRelatedData.datas;
|
||||||
let selectedData = this.tabTwoRelatedData.selectedData.isused;
|
let selectedData = this.tabTwoRelatedData.selectedData.isused;
|
||||||
|
|
||||||
let params = this.arrToJson(toJS(datas), toJS(selectedData));
|
let params = this.arrToJson(toJS(datas), toJS(selectedData));
|
||||||
params.rownum = datas.length;
|
params.rownum = datas.length;
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -196,23 +146,24 @@ export class ColumnPermission {
|
||||||
|
|
||||||
columnPermissionSave() {
|
columnPermissionSave() {
|
||||||
let params = {
|
let params = {
|
||||||
data: toJS(this.checkedItems)
|
...toJS(this.checkedItems)
|
||||||
};
|
};
|
||||||
Api.cardItemsSettingSave(params).then(res => {
|
Api.cardAccessSave(params).then(res => {
|
||||||
let {
|
console.log(res);
|
||||||
api_status,
|
// let {
|
||||||
sign
|
// api_status,
|
||||||
} = res;
|
// sign
|
||||||
|
// } = res;
|
||||||
if (api_status) {
|
//
|
||||||
if (sign == "1") {
|
// if (api_status) {
|
||||||
res.message && message.success(res.message);
|
// if (sign == "1") {
|
||||||
} else {
|
// res.message && message.success(res.message);
|
||||||
res.message && message.warning(res.message);
|
// } else {
|
||||||
}
|
// res.message && message.warning(res.message);
|
||||||
} else {
|
// }
|
||||||
message.error(res.message);
|
// } else {
|
||||||
}
|
// message.error(res.message);
|
||||||
|
// }
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
message.error(error);
|
message.error(error);
|
||||||
});
|
});
|
||||||
|
|
@ -242,6 +193,16 @@ export class ColumnPermission {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
arrColumnsToJson(arr, rows) {
|
||||||
|
let jsonColumn = {};
|
||||||
|
arr.map((item, index) => {
|
||||||
|
for (let key in item) {
|
||||||
|
jsonColumn[key + "_" + index] = item[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return jsonColumn;
|
||||||
|
}
|
||||||
|
|
||||||
arrToJson(arr, rows) {
|
arrToJson(arr, rows) {
|
||||||
let json = {};
|
let json = {};
|
||||||
|
|
||||||
|
|
@ -275,46 +236,11 @@ export class ColumnPermission {
|
||||||
this.authorized = right;
|
this.authorized = right;
|
||||||
}
|
}
|
||||||
|
|
||||||
setBtnMenu(btnMenu) {
|
|
||||||
this.btnMenu = btnMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
setSelectedKey(key) {
|
setSelectedKey(key) {
|
||||||
this.selectedKey = key;
|
this.selectedKey = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
setCardItemsData(data) {
|
setColumnsPermissionData(list) {
|
||||||
this.data = data;
|
this.columnsPermissionData = list;
|
||||||
}
|
|
||||||
|
|
||||||
setEnableRows(e) {
|
|
||||||
extendObservable(this.tabTwoRelatedData, {
|
|
||||||
selectedData: {
|
|
||||||
isused: e
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
setTableEditDatas(e) {
|
|
||||||
e.map(item => {
|
|
||||||
for (let key in item) {
|
|
||||||
if (key == "undefined") {
|
|
||||||
delete item[key];
|
|
||||||
}
|
|
||||||
if (!item["isused"]) {
|
|
||||||
item["isused"] = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
extendObservable(this.tabTwoRelatedData, {
|
|
||||||
datas: e
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
mobxDataReset() {
|
|
||||||
this.selectedKey = "0";
|
|
||||||
extendObservable(this.tabOneRelatedData, {
|
|
||||||
loading: true
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue