2022-11-08 15:56:34 +08:00
|
|
|
|
import * as mobx from "mobx";
|
|
|
|
|
|
import { action, computed, extendObservable, observable } from "mobx";
|
2022-11-10 16:10:21 +08:00
|
|
|
|
import HrmBaseStore from "./baseStore";
|
2022-11-09 14:03:32 +08:00
|
|
|
|
import { WeaTableNew } from "comsMobx";
|
2022-11-08 15:56:34 +08:00
|
|
|
|
import { message } from "antd";
|
2022-11-10 16:10:21 +08:00
|
|
|
|
import { WeaHelpfulTip, WeaInputLocale } from "ecCom";
|
|
|
|
|
|
import { cloneDeep, has, indexOf, isEmpty, remove, uniq } from "lodash";
|
2022-11-08 15:56:34 +08:00
|
|
|
|
import { i18n } from "../public/i18n";
|
2022-11-10 18:50:45 +08:00
|
|
|
|
import * as Api from "../apis/columnSetting";
|
2022-11-10 16:10:21 +08:00
|
|
|
|
import { validDBKeys } from "../util";
|
2022-11-11 17:09:18 +08:00
|
|
|
|
import { saveFieldDefinedInfo } from "../apis/columnSetting";
|
2022-11-09 14:03:32 +08:00
|
|
|
|
|
2022-11-10 16:10:21 +08:00
|
|
|
|
const getCurrentLabel = WeaInputLocale.getCurrentLabel;
|
2022-11-08 17:43:26 +08:00
|
|
|
|
const { TableStore } = WeaTableNew;
|
2022-11-08 15:56:34 +08:00
|
|
|
|
|
2022-11-07 16:35:58 +08:00
|
|
|
|
const toJS = mobx.toJS;
|
|
|
|
|
|
|
2022-11-11 17:09:18 +08:00
|
|
|
|
export class ColumnSetting {
|
2022-11-08 17:43:26 +08:00
|
|
|
|
@observable tableStore = new TableStore();
|
2022-11-09 14:03:32 +08:00
|
|
|
|
@observable columnsPermissionData = [];
|
2022-11-08 15:56:34 +08:00
|
|
|
|
@observable selectedKey = "0";
|
2022-11-17 11:34:05 +08:00
|
|
|
|
@observable authorized = '';
|
2022-11-07 16:35:58 +08:00
|
|
|
|
@observable loading = true;
|
|
|
|
|
|
@observable tabOneRelatedData = {
|
2022-11-08 15:56:34 +08:00
|
|
|
|
datas: [], //datas受控
|
|
|
|
|
|
columns: [],
|
2022-11-07 16:35:58 +08:00
|
|
|
|
loading: true
|
|
|
|
|
|
};
|
|
|
|
|
|
@observable tabTwoRelatedData = {
|
|
|
|
|
|
datas: [], //datas受控
|
|
|
|
|
|
columns: [],
|
|
|
|
|
|
loading: true,
|
|
|
|
|
|
selectedData: {}, //selectedData受控
|
|
|
|
|
|
};
|
2022-11-11 17:09:18 +08:00
|
|
|
|
@observable tabThreeRelatedData = {
|
|
|
|
|
|
datas: [], //datas受控
|
|
|
|
|
|
columns: [],
|
|
|
|
|
|
loading: true,
|
|
|
|
|
|
selectedData: {} //selectedData受控
|
|
|
|
|
|
};
|
2022-11-07 16:35:58 +08:00
|
|
|
|
|
|
|
|
|
|
@computed get checkedItems() {
|
2022-11-09 14:03:32 +08:00
|
|
|
|
const data = isEmpty(this.columnsPermissionData) ? toJS(this.tableStore.datas) : this.columnsPermissionData;
|
|
|
|
|
|
return this.arrColumnsToJson(data);
|
2022-11-07 16:35:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@computed get tabTwoSaveParams() {
|
|
|
|
|
|
let datas = this.tabTwoRelatedData.datas;
|
|
|
|
|
|
let selectedData = this.tabTwoRelatedData.selectedData.isused;
|
|
|
|
|
|
let params = this.arrToJson(toJS(datas), toJS(selectedData));
|
|
|
|
|
|
params.rownum = datas.length;
|
|
|
|
|
|
return params;
|
|
|
|
|
|
}
|
2022-11-11 17:09:18 +08:00
|
|
|
|
@computed get tabThreeSaveParams() {
|
|
|
|
|
|
let datas = this.tabThreeRelatedData.datas;
|
|
|
|
|
|
let selectedData = this.tabThreeRelatedData.selectedData.status;
|
|
|
|
|
|
let params = this.arrToJson(toJS(datas), toJS(selectedData), 'status');
|
|
|
|
|
|
params.rownum = datas.length;
|
|
|
|
|
|
return params;
|
|
|
|
|
|
}
|
2022-11-07 16:35:58 +08:00
|
|
|
|
|
|
|
|
|
|
@action
|
|
|
|
|
|
getRight() {
|
2022-11-08 15:56:34 +08:00
|
|
|
|
Api.hasRight().then(res => {
|
|
|
|
|
|
let { code, data, msg } = res;
|
|
|
|
|
|
const { hasRight } = data;
|
|
|
|
|
|
if (code === 200) {
|
|
|
|
|
|
this.setRight(hasRight);
|
2022-11-07 16:35:58 +08:00
|
|
|
|
} else {
|
2022-11-08 15:56:34 +08:00
|
|
|
|
message.error(msg);
|
2022-11-07 16:35:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
|
message.error(error);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
loadTabOneRelatedData() {
|
|
|
|
|
|
this.tabOneRelatedData.loading = true;
|
|
|
|
|
|
Promise.all(
|
|
|
|
|
|
[
|
2022-11-08 15:56:34 +08:00
|
|
|
|
Api.getTable()
|
2022-11-07 16:35:58 +08:00
|
|
|
|
]
|
2022-11-08 17:43:26 +08:00
|
|
|
|
).then(([res]) => {
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
res.data.datas && this.tableStore.getDatas(res.data.datas, 1);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
message.warning(res.msg);
|
|
|
|
|
|
}
|
2022-11-07 16:35:58 +08:00
|
|
|
|
}).catch(error => {
|
|
|
|
|
|
message.error(error);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
loadTabTwoRelatedData() {
|
|
|
|
|
|
this.tabTwoRelatedData.loading = true;
|
|
|
|
|
|
Promise.all(
|
|
|
|
|
|
[
|
2022-11-08 15:56:34 +08:00
|
|
|
|
Api.getTableEdit()
|
2022-11-07 16:35:58 +08:00
|
|
|
|
]
|
|
|
|
|
|
).then(res => {
|
|
|
|
|
|
res.map((rs, index) => {
|
|
|
|
|
|
if (index == 0) {
|
|
|
|
|
|
let {
|
|
|
|
|
|
api_status,
|
|
|
|
|
|
datas,
|
|
|
|
|
|
columns,
|
|
|
|
|
|
selectedData
|
|
|
|
|
|
} = rs;
|
|
|
|
|
|
|
|
|
|
|
|
if (api_status) {
|
|
|
|
|
|
columns.map((c, index) => {
|
2022-11-08 15:56:34 +08:00
|
|
|
|
if (c.key === "itemurl") {
|
2022-11-07 16:35:58 +08:00
|
|
|
|
c.title = <span>
|
|
|
|
|
|
<span>{c.title}</span>
|
2022-11-08 15:56:34 +08:00
|
|
|
|
<span style={{ marginLeft: 10 }}>
|
|
|
|
|
|
<WeaHelpfulTip
|
|
|
|
|
|
ecId={`${this && this.props && this.props.ecId || ""}_WeaHelpfulTip@4vdvfp@${index}`}
|
|
|
|
|
|
title="自定义页面链接地址可以为外网地址,如:http://www.baidu.com
|
2022-11-07 16:35:58 +08:00
|
|
|
|
也可以是内部地址,如:/test.jsp,可以带上参数传参,像这样:/test.jsp?a=1&b=2
|
|
|
|
|
|
也可以写占位符{#id}传人员id,像这样:/test.jsp?a=1&b={#id}&mypara2={#id}
|
2022-11-08 15:56:34 +08:00
|
|
|
|
即使不写占位符,默认也会收到1个固定的参数:hrmResourceID=人员id"/>
|
2022-11-07 16:35:58 +08:00
|
|
|
|
</span>
|
2022-11-08 15:56:34 +08:00
|
|
|
|
</span>;
|
|
|
|
|
|
} else if (c.key === "itemnum") {
|
2022-11-07 16:35:58 +08:00
|
|
|
|
c.title = <span>
|
|
|
|
|
|
<span>{c.title}</span>
|
2022-11-08 15:56:34 +08:00
|
|
|
|
<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)字样。"/>
|
2022-11-07 16:35:58 +08:00
|
|
|
|
</span>
|
2022-11-08 15:56:34 +08:00
|
|
|
|
</span>;
|
2022-11-07 16:35:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
extendObservable(this.tabTwoRelatedData, {
|
|
|
|
|
|
datas: datas,
|
|
|
|
|
|
columns: columns
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
selectedData && extendObservable(this.tabTwoRelatedData, {
|
|
|
|
|
|
selectedData: selectedData
|
|
|
|
|
|
});
|
|
|
|
|
|
extendObservable(this.tabTwoRelatedData, {
|
|
|
|
|
|
loading: false
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
message.error(rs.message);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
|
message.error(error);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-10 16:10:21 +08:00
|
|
|
|
loadTabThreeRelatedData() {
|
2022-11-11 17:09:18 +08:00
|
|
|
|
this.tabThreeRelatedData.loading = true;
|
2022-11-10 16:10:21 +08:00
|
|
|
|
Promise.all(
|
|
|
|
|
|
[
|
2022-11-11 17:09:18 +08:00
|
|
|
|
Api.getCardButtonTable()
|
2022-11-10 16:10:21 +08:00
|
|
|
|
]
|
2022-11-11 17:09:18 +08:00
|
|
|
|
).then(result => {
|
|
|
|
|
|
result.map((item, index) => {
|
|
|
|
|
|
if (index === 0) {
|
|
|
|
|
|
let { code, data, msg } = item;
|
|
|
|
|
|
if (code === 200) {
|
|
|
|
|
|
const { columns, datas, selectedData } = data;
|
|
|
|
|
|
if (!columns || !datas) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2022-11-14 10:42:44 +08:00
|
|
|
|
|
|
|
|
|
|
columns.map((c, index) => {
|
|
|
|
|
|
if (c.key === "url") {
|
|
|
|
|
|
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
|
|
|
|
|
|
也可以是内部地址,如:/test.jsp,可以带上参数传参,像这样:/test.jsp?a=1&b=2
|
2022-11-17 11:34:05 +08:00
|
|
|
|
也可以写占位符${id}传人员id,像这样:/test.jsp?a=1&b=${id}&mypara2=${id}"/>
|
2022-11-14 10:42:44 +08:00
|
|
|
|
</span>
|
|
|
|
|
|
</span>;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2022-11-11 17:09:18 +08:00
|
|
|
|
extendObservable(this.tabThreeRelatedData, {
|
|
|
|
|
|
datas: datas,
|
|
|
|
|
|
columns: columns
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
selectedData && extendObservable(this.tabThreeRelatedData, {
|
|
|
|
|
|
selectedData: selectedData
|
|
|
|
|
|
});
|
|
|
|
|
|
extendObservable(this.tabThreeRelatedData, {
|
|
|
|
|
|
loading: false
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
message.error(msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2022-11-10 16:10:21 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-07 16:35:58 +08:00
|
|
|
|
columnPermissionSave() {
|
|
|
|
|
|
let params = {
|
2022-11-09 14:03:32 +08:00
|
|
|
|
...toJS(this.checkedItems)
|
2022-11-08 15:56:34 +08:00
|
|
|
|
};
|
2022-11-10 16:10:21 +08:00
|
|
|
|
Api.cardAccessSave(params).then(({ code, msg }) => {
|
|
|
|
|
|
if (code === 200) {
|
|
|
|
|
|
this.loadTabOneRelatedData();
|
|
|
|
|
|
message.success(msg || "操作成功");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
message.error(msg || "操作失败");
|
|
|
|
|
|
}
|
2022-11-07 16:35:58 +08:00
|
|
|
|
}).catch(error => {
|
|
|
|
|
|
message.error(error);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
userDefineCardItemSave() {
|
|
|
|
|
|
if (!this.verify(toJS(this.tabTwoRelatedData.datas))) return;
|
|
|
|
|
|
let params = this.tabTwoSaveParams;
|
|
|
|
|
|
|
|
|
|
|
|
Api.userDefineCardItemSave(params).then(res => {
|
|
|
|
|
|
let {
|
|
|
|
|
|
api_status,
|
2022-11-08 15:56:34 +08:00
|
|
|
|
sign
|
2022-11-07 16:35:58 +08:00
|
|
|
|
} = res;
|
|
|
|
|
|
|
|
|
|
|
|
if (api_status) {
|
2022-11-08 15:56:34 +08:00
|
|
|
|
if (sign == "1") {
|
2022-11-07 16:35:58 +08:00
|
|
|
|
res.message && message.success(res.message);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
res.message && message.warning(res.message);
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
message.error(res.message);
|
|
|
|
|
|
}
|
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
|
message.error(error);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2022-11-11 17:09:18 +08:00
|
|
|
|
customItemSave() {
|
|
|
|
|
|
let params = this.tabThreeSaveParams;
|
|
|
|
|
|
Api.saveFieldDefinedInfo(params).then(res => {
|
2022-11-14 10:42:44 +08:00
|
|
|
|
let { code, msg } = res;
|
|
|
|
|
|
if (code === 200) {
|
|
|
|
|
|
message.success(msg || "操作成功");
|
|
|
|
|
|
this.loadTabThreeRelatedData();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
message.error(msg);
|
|
|
|
|
|
}
|
2022-11-11 17:09:18 +08:00
|
|
|
|
}).catch(error => {
|
|
|
|
|
|
message.error(error);
|
2022-11-10 16:10:21 +08:00
|
|
|
|
});
|
2022-11-11 17:09:18 +08:00
|
|
|
|
}
|
2022-11-10 16:10:21 +08:00
|
|
|
|
|
2022-11-09 14:03:32 +08:00
|
|
|
|
arrColumnsToJson(arr, rows) {
|
2022-11-09 17:02:55 +08:00
|
|
|
|
let jsonColumn = {
|
2022-11-10 16:10:21 +08:00
|
|
|
|
rownum: arr.length
|
2022-11-09 17:02:55 +08:00
|
|
|
|
};
|
2022-11-09 14:03:32 +08:00
|
|
|
|
arr.map((item, index) => {
|
|
|
|
|
|
for (let key in item) {
|
|
|
|
|
|
jsonColumn[key + "_" + index] = item[key];
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
return jsonColumn;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-10 16:10:21 +08:00
|
|
|
|
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
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2022-11-11 17:09:18 +08:00
|
|
|
|
setCustomTableEditDatas(e) {
|
|
|
|
|
|
e.map(item => {
|
|
|
|
|
|
for (let key in item) {
|
|
|
|
|
|
if (key == "undefined") {
|
|
|
|
|
|
delete item[key];
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!item["status"]) {
|
|
|
|
|
|
item["status"] = "";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
extendObservable(this.tabThreeRelatedData, {
|
|
|
|
|
|
datas: e
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2022-11-10 16:10:21 +08:00
|
|
|
|
|
|
|
|
|
|
setEnableRows(e) {
|
|
|
|
|
|
extendObservable(this.tabTwoRelatedData, {
|
|
|
|
|
|
selectedData: {
|
|
|
|
|
|
isused: e
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2022-11-14 10:42:44 +08:00
|
|
|
|
setEnableThreeRows(e) {
|
|
|
|
|
|
extendObservable(this.tabThreeRelatedData, {
|
|
|
|
|
|
selectedData: {
|
|
|
|
|
|
status: e
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2022-11-10 16:10:21 +08:00
|
|
|
|
|
2022-11-11 17:09:18 +08:00
|
|
|
|
arrToJson(arr, rows, rowKey="isused") {
|
2022-11-07 16:35:58 +08:00
|
|
|
|
let json = {};
|
|
|
|
|
|
const _rows = isEmpty(arr) ? [] : rows;
|
|
|
|
|
|
_rows && _rows.map(index => {
|
2022-11-11 17:09:18 +08:00
|
|
|
|
arr[index][rowKey] = "1";
|
2022-11-07 16:35:58 +08:00
|
|
|
|
});
|
|
|
|
|
|
arr.map((item, index) => {
|
2022-11-11 17:09:18 +08:00
|
|
|
|
if (!item[rowKey]) item[rowKey] = "0";
|
2022-11-07 16:35:58 +08:00
|
|
|
|
for (let key in item) {
|
2022-11-08 15:56:34 +08:00
|
|
|
|
json[key + "_" + index] = item[key];
|
2022-11-07 16:35:58 +08:00
|
|
|
|
}
|
2022-11-08 15:56:34 +08:00
|
|
|
|
});
|
2022-11-07 16:35:58 +08:00
|
|
|
|
|
|
|
|
|
|
return json;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
verify(arr) {
|
|
|
|
|
|
for (let i = 0; i < arr.length; i++) {
|
|
|
|
|
|
if (!arr[i].itemname || !arr[i].itemurl) {
|
2022-11-08 15:56:34 +08:00
|
|
|
|
const temp = i18n.message.requiredInfoIsNotFull().replace("{param}", i + 1);
|
2022-11-07 16:35:58 +08:00
|
|
|
|
message.warning(temp);
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setRight(right) {
|
|
|
|
|
|
this.authorized = right;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setSelectedKey(key) {
|
|
|
|
|
|
this.selectedKey = key;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-09 14:03:32 +08:00
|
|
|
|
setColumnsPermissionData(list) {
|
|
|
|
|
|
this.columnsPermissionData = list;
|
2022-11-07 16:35:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|