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";
|
|
|
|
|
|
import * as Api from "../apis/columnPermission";
|
2022-11-10 16:10:21 +08:00
|
|
|
|
import { validDBKeys } from "../util";
|
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-10 16:10:21 +08:00
|
|
|
|
export class ColumnPermission extends HrmBaseStore {
|
|
|
|
|
|
isDBKeyValid = true;
|
|
|
|
|
|
getColumns = () => {
|
|
|
|
|
|
return cloneDeep(this.fieldDefColumns());
|
|
|
|
|
|
};
|
|
|
|
|
|
fieldDefColumns = () => {
|
|
|
|
|
|
const columns = [{
|
|
|
|
|
|
title: i18n.label.fieldLabel(), //列名
|
|
|
|
|
|
dataIndex: "fieldlabel", //列的id 对应数据
|
|
|
|
|
|
key: "fieldlabel", //前端渲染key值
|
|
|
|
|
|
useRecord: true,
|
|
|
|
|
|
colSpan: 1,
|
|
|
|
|
|
width: "15%",
|
|
|
|
|
|
com: [{
|
|
|
|
|
|
label: "",
|
|
|
|
|
|
type: "INPUT",
|
|
|
|
|
|
key: "fieldlabel",
|
|
|
|
|
|
viewAttr: "3",
|
|
|
|
|
|
otherParams: {
|
|
|
|
|
|
...window.inputType
|
|
|
|
|
|
}
|
|
|
|
|
|
}]
|
|
|
|
|
|
}, {
|
|
|
|
|
|
title: i18n.label.fieldName(),
|
|
|
|
|
|
dataIndex: "fieldname",
|
|
|
|
|
|
key: "fieldname",
|
|
|
|
|
|
useRecord: true,
|
|
|
|
|
|
colSpan: 1,
|
|
|
|
|
|
width: "15%",
|
|
|
|
|
|
com: [{
|
|
|
|
|
|
label: "",
|
|
|
|
|
|
type: "INPUT",
|
|
|
|
|
|
key: "fieldname",
|
|
|
|
|
|
viewAttr: "1",
|
|
|
|
|
|
otherParams: {
|
|
|
|
|
|
length: 25,
|
|
|
|
|
|
regExp: /^[a-zA-Z][a-zA-Z0-9]*$/,
|
|
|
|
|
|
filter: (val) => {
|
|
|
|
|
|
const {
|
|
|
|
|
|
isValid,
|
|
|
|
|
|
value
|
|
|
|
|
|
} = validDBKeys(val);
|
|
|
|
|
|
this.isDBKeyValid = isValid;
|
|
|
|
|
|
return value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}]
|
|
|
|
|
|
}, {
|
|
|
|
|
|
title: i18n.label.fieldType(),
|
|
|
|
|
|
dataIndex: "fieldType",
|
|
|
|
|
|
key: "fieldType",
|
|
|
|
|
|
useRecord: true,
|
|
|
|
|
|
colSpan: 1,
|
|
|
|
|
|
width: "45%",
|
|
|
|
|
|
com: [{
|
|
|
|
|
|
label: "",
|
|
|
|
|
|
type: "CUSTOMFIELD",
|
|
|
|
|
|
key: "fieldType",
|
|
|
|
|
|
viewAttr: "3",
|
|
|
|
|
|
options: ["peculiar"],
|
|
|
|
|
|
otherParams: {
|
|
|
|
|
|
customProps: {
|
|
|
|
|
|
"input.text": {
|
|
|
|
|
|
viewAttr: 3
|
|
|
|
|
|
},
|
|
|
|
|
|
"textarea": {
|
|
|
|
|
|
parent: {
|
|
|
|
|
|
type: "div",
|
|
|
|
|
|
style: {
|
|
|
|
|
|
display: "none"
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
style: {
|
|
|
|
|
|
display: "none"
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
"textarea.*": {
|
|
|
|
|
|
parent: {
|
|
|
|
|
|
type: "div",
|
|
|
|
|
|
style: {
|
|
|
|
|
|
display: "none"
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
style: {
|
|
|
|
|
|
display: "none"
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
"textarea.*.*": {
|
|
|
|
|
|
style: {
|
|
|
|
|
|
display: "none"
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
"select": {
|
|
|
|
|
|
options: [{
|
|
|
|
|
|
key: "select",
|
|
|
|
|
|
selected: true,
|
|
|
|
|
|
showname: i18n.label.selectComponent()
|
|
|
|
|
|
}]
|
|
|
|
|
|
},
|
|
|
|
|
|
"upload": {
|
|
|
|
|
|
options: [{
|
|
|
|
|
|
key: "file",
|
|
|
|
|
|
selected: true,
|
|
|
|
|
|
showname: i18n.label.uploadFile()
|
|
|
|
|
|
}]
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}]
|
|
|
|
|
|
}, {
|
|
|
|
|
|
title: i18n.label.enable(),
|
|
|
|
|
|
dataIndex: "enable",
|
|
|
|
|
|
key: "enable",
|
|
|
|
|
|
checkType: "checkbox",
|
|
|
|
|
|
colSpan: 1,
|
|
|
|
|
|
width: "7%"
|
|
|
|
|
|
}, {
|
|
|
|
|
|
title: i18n.label.required(),
|
|
|
|
|
|
dataIndex: "required",
|
|
|
|
|
|
key: "required",
|
|
|
|
|
|
checkType: "checkbox",
|
|
|
|
|
|
colSpan: 1,
|
|
|
|
|
|
width: "8%"
|
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
|
|
//人员卡片字段定义-添加【允许个人修改】列
|
|
|
|
|
|
if (this.moduleName === "resourcefielddefined") {
|
|
|
|
|
|
columns.push({
|
|
|
|
|
|
title: getLabel(510359, "允许个人修改"),
|
|
|
|
|
|
dataIndex: "isModify",
|
|
|
|
|
|
key: "isModify",
|
|
|
|
|
|
checkType: "checkbox",
|
|
|
|
|
|
colSpan: 1,
|
|
|
|
|
|
width: "11%"
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
// this.encryptEnable && columns.push({
|
|
|
|
|
|
// title: getLabel('526997', '加密设置'),
|
|
|
|
|
|
// dataIndex: 'canEncrypt',
|
|
|
|
|
|
// key: 'canEncrypt',
|
|
|
|
|
|
// com: [
|
|
|
|
|
|
// {
|
|
|
|
|
|
// type: 'custom',
|
|
|
|
|
|
// key: 'custom',
|
|
|
|
|
|
// render: (text, record, index, onEdit) => {
|
|
|
|
|
|
// const { canEncrypt } = record;
|
|
|
|
|
|
// if (canEncrypt == '1')
|
|
|
|
|
|
// return (
|
|
|
|
|
|
// <a onClick={() => this.onEncryptHandle(record)}>{getLabel('526997', '加密设置')}</a>
|
|
|
|
|
|
// )
|
|
|
|
|
|
// return null;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// ],
|
|
|
|
|
|
// colSpan: 1,
|
|
|
|
|
|
// width: '8%'
|
|
|
|
|
|
// });
|
|
|
|
|
|
return columns;
|
|
|
|
|
|
};
|
|
|
|
|
|
@observable refreshMainTabComponent = new Date().getTime();
|
|
|
|
|
|
@observable refreshFeildDef = new Date().getTime(); //当需要刷新主页面tab时,变更此值
|
|
|
|
|
|
@observable refreshForm = new Date().getTime();
|
|
|
|
|
|
@observable refreshEditGroupTabComponent = new Date().getTime(); //当需要刷新权限组编辑tab时,变更此值
|
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-09 14:03:32 +08:00
|
|
|
|
@observable authorized = true;
|
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-08 15:56:34 +08:00
|
|
|
|
authorized: false
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@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);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-10 16:10:21 +08:00
|
|
|
|
@action
|
|
|
|
|
|
onFieldDefChange = (datas) => {
|
|
|
|
|
|
let selectedData = {
|
|
|
|
|
|
enable: [],
|
|
|
|
|
|
required: []
|
|
|
|
|
|
};
|
|
|
|
|
|
if (this.moduleName === "resourcefielddefined") {
|
|
|
|
|
|
Object.assign(selectedData, {
|
|
|
|
|
|
isModify: []
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
datas.map((data, index) => {
|
|
|
|
|
|
if (data["enable"] === "1")
|
|
|
|
|
|
selectedData.enable.push(index);
|
|
|
|
|
|
if (data["required"] === "1")
|
|
|
|
|
|
selectedData.required.push(index);
|
|
|
|
|
|
if (data["isModify"] && data["isModify"] === "1" && this.moduleName === "resourcefielddefined") {
|
|
|
|
|
|
selectedData.isModify.push(index);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
this.tableEditConfig.fieldDef.datas = datas;
|
|
|
|
|
|
this.tableEditConfig.fieldDef.selectedData = selectedData;
|
|
|
|
|
|
this._feildDefSaveable = datas.length === 0;
|
|
|
|
|
|
if (datas.length === 0) {
|
|
|
|
|
|
// this.initData();
|
|
|
|
|
|
} else
|
|
|
|
|
|
this.refreshFeildDef = new Date().getTime();
|
|
|
|
|
|
};
|
|
|
|
|
|
@action
|
|
|
|
|
|
onFieldDefRowSelect = (sRowKeys, rows, dataIndex, selectedDatas) => {
|
|
|
|
|
|
if (dataIndex == null) {
|
|
|
|
|
|
this.feildDefTableSelectedRows = sRowKeys;
|
|
|
|
|
|
this.tableEditConfig.fieldDef.selectedRowKeys = sRowKeys;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if (selectedDatas != null && selectedDatas.hasOwnProperty(dataIndex)) {
|
|
|
|
|
|
const arr = selectedDatas[dataIndex];
|
|
|
|
|
|
this.tableEditConfig.fieldDef.datas.map((data, index) => {
|
|
|
|
|
|
if (dataIndex === "enable") {
|
|
|
|
|
|
data[dataIndex] = indexOf(arr, index) >= 0 ? "1" : "0";
|
|
|
|
|
|
if (data[dataIndex] === "0") {
|
|
|
|
|
|
data["required"] = "0";
|
|
|
|
|
|
remove(selectedDatas["required"], v => v === index);
|
|
|
|
|
|
data["isModify"] = "0";
|
|
|
|
|
|
remove(selectedDatas["isModify"], v => v === index);
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if (dataIndex === "required") {
|
|
|
|
|
|
data[dataIndex] = indexOf(arr, index) >= 0 ? "1" : "0";
|
|
|
|
|
|
if (data[dataIndex] === "1") {
|
|
|
|
|
|
data["enable"] = "1";
|
|
|
|
|
|
if (selectedDatas["enable"].indexOf(index) < 0)
|
|
|
|
|
|
selectedDatas["enable"].push(index);
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if (dataIndex === "isModify") {
|
|
|
|
|
|
data[dataIndex] = indexOf(arr, index) >= 0 ? "1" : "0";
|
|
|
|
|
|
if (data[dataIndex] === "1") {
|
|
|
|
|
|
data["enable"] = "1";
|
|
|
|
|
|
if (selectedDatas["enable"].indexOf(index) < 0)
|
|
|
|
|
|
selectedDatas["enable"].push(index);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else
|
|
|
|
|
|
data[dataIndex] = indexOf(arr, index) >= 0 ? "1" : "0";
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
this.tableEditConfig.fieldDef.selectedData = selectedDatas;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
this.processLinkage(selectedDatas);
|
|
|
|
|
|
this.refreshFeildDef = new Date().getTime();
|
|
|
|
|
|
};
|
|
|
|
|
|
processLinkage = (selectedDatas) => {
|
|
|
|
|
|
const { datas } = this.tableEditConfig.fieldDef;
|
|
|
|
|
|
|
|
|
|
|
|
const target = datas.find(data => data.fieldname === "accounttype");
|
|
|
|
|
|
|
|
|
|
|
|
if (!target) return;
|
|
|
|
|
|
|
|
|
|
|
|
const accounttype = target.isModify;
|
|
|
|
|
|
|
|
|
|
|
|
const belongto = datas.find(data => data.fieldname === "belongto").isModify;
|
|
|
|
|
|
|
|
|
|
|
|
if (belongto !== accounttype) {
|
|
|
|
|
|
datas.find(data => data.fieldname === "belongto").isModify = accounttype;
|
|
|
|
|
|
|
|
|
|
|
|
const belongtoIndex = datas.findIndex(data => data.fieldname === "belongto");
|
|
|
|
|
|
|
|
|
|
|
|
if (accounttype === "1") {
|
|
|
|
|
|
selectedDatas["isModify"].push(belongtoIndex);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
remove(selectedDatas["isModify"], v => v === belongtoIndex);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
@action
|
|
|
|
|
|
onFieldDefRowSelection = (rowSelection) => {
|
|
|
|
|
|
let sel = {
|
|
|
|
|
|
...rowSelection
|
|
|
|
|
|
};
|
|
|
|
|
|
sel.getCheckboxProps = (record) => {
|
|
|
|
|
|
let disabled = false;
|
|
|
|
|
|
switch (this.dropdownSelectedKey) {
|
|
|
|
|
|
case "2":
|
|
|
|
|
|
disabled = false;//复制时,checkbox全部启用
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "3":
|
|
|
|
|
|
disabled = record.id == null || record.checkProps.enable.viewAttr === 1;//移动到组时,checkbox根据id是否为空或是否引用启用按钮状态赋值
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
disabled = record.viewAttr === 1;//删除时,checkbox根据record.viewAttr赋值
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
|
|
|
disabled
|
|
|
|
|
|
};
|
|
|
|
|
|
};
|
|
|
|
|
|
return sel;
|
|
|
|
|
|
};
|
|
|
|
|
|
@action
|
|
|
|
|
|
onFieldDefDeleteOpr = (ks, ds) => {
|
|
|
|
|
|
let ids = [];
|
|
|
|
|
|
ds.map(d => {
|
|
|
|
|
|
if (has(d, "id"))
|
|
|
|
|
|
ids.push(d.id);
|
|
|
|
|
|
});
|
|
|
|
|
|
let params = {
|
|
|
|
|
|
id: ids.join(",")
|
|
|
|
|
|
};
|
|
|
|
|
|
if (this.selectedTreeNodeInfo != null)
|
|
|
|
|
|
params.groupType = this.selectedTreeNodeInfo.key;
|
|
|
|
|
|
params.groupId = this.activeTabInfo.tabInfo.groupid;
|
|
|
|
|
|
if (ids.length > 0) {
|
|
|
|
|
|
api.removeFieldDefinedInfo(this.moduleName, params).then(data => {
|
|
|
|
|
|
if (data.status === "1") {
|
|
|
|
|
|
// this.initData();
|
|
|
|
|
|
this.tableEditConfig.fieldDef.selectedRowKeys.length = 0;
|
|
|
|
|
|
message.success(i18n.message.deleteSuccess());
|
|
|
|
|
|
} else
|
|
|
|
|
|
message.error(data.message);
|
|
|
|
|
|
}, error => {
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.tableEditConfig.fieldDef.selectedRowKeys.length = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.feildDefTableSelectedRows.length = 0;
|
|
|
|
|
|
};
|
|
|
|
|
|
tableEditConfig = {
|
|
|
|
|
|
fieldDef: {
|
|
|
|
|
|
showTitle: true,
|
|
|
|
|
|
draggable: true,
|
|
|
|
|
|
deleteConfirm: true,
|
|
|
|
|
|
showAdd: true,
|
|
|
|
|
|
showDelete: true,
|
|
|
|
|
|
showCopy: true,
|
|
|
|
|
|
columns: this.getColumns(),
|
|
|
|
|
|
copyFilterProps: ["id", "fieldlabel", "fieldname", "com.fieldname", "com.fieldlabel"],
|
|
|
|
|
|
datas: [],
|
|
|
|
|
|
selectedData: {},
|
|
|
|
|
|
onChange: this.onFieldDefChange,
|
|
|
|
|
|
onRowSelect: this.onFieldDefRowSelect,
|
|
|
|
|
|
getRowSelection: this.onFieldDefRowSelection
|
|
|
|
|
|
// onDelete: this.onFieldDefDeleteOpr
|
|
|
|
|
|
// onEdit: this.onEdit,
|
|
|
|
|
|
// onAdd: this.onAdd
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2022-11-07 16:35:58 +08:00
|
|
|
|
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) {
|
|
|
|
|
|
if (!columns || !datas) {
|
|
|
|
|
|
this.tabTwoRelatedData.authorized = false;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.tabTwoRelatedData.authorized = true;
|
|
|
|
|
|
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() {
|
|
|
|
|
|
Promise.all(
|
|
|
|
|
|
[
|
|
|
|
|
|
Api.getFieldDefinedInfo()
|
|
|
|
|
|
]
|
|
|
|
|
|
).then(([{ data, status, message }]) => {
|
|
|
|
|
|
if (status === "1") {
|
|
|
|
|
|
const { datas, selectedData } = this.convertData(data, "fieldDef");
|
|
|
|
|
|
this.tableEditConfig.fieldDef.datas = datas;
|
|
|
|
|
|
this.tableEditConfig.fieldDef.columns = this.getColumns();
|
|
|
|
|
|
this.tableEditConfig.fieldDef.selectedData = selectedData;
|
|
|
|
|
|
this.refreshMainTabComponent = new Date().getTime();
|
|
|
|
|
|
} else
|
|
|
|
|
|
message.error(message);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
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-10 16:10:21 +08:00
|
|
|
|
saveCustomFiled = () => {
|
|
|
|
|
|
let data = cloneDeep(this.tableEditConfig.fieldDef.datas),
|
|
|
|
|
|
labelArr = [],
|
|
|
|
|
|
nameArr = [];
|
|
|
|
|
|
if (!this.isDBKeyValid) return;
|
|
|
|
|
|
const invalidEmpty = data.some((d, index) => {
|
|
|
|
|
|
d.key = index;
|
|
|
|
|
|
delete d.com;
|
|
|
|
|
|
delete d.checkProps;
|
|
|
|
|
|
delete d.viewAttr;
|
|
|
|
|
|
if (has(d, "fieldTypeObj")) {
|
|
|
|
|
|
if (Array.isArray(d.fieldTypeObj) && d.fieldTypeObj.length > 0 && d.fieldTypeObj[0] != "select")
|
|
|
|
|
|
d.fieldType = d.fieldTypeObj;
|
|
|
|
|
|
delete d.fieldTypeObj;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!Array.isArray(d.fieldType))
|
|
|
|
|
|
delete d.fieldType;
|
|
|
|
|
|
|
|
|
|
|
|
if (!has(d, "enable"))
|
|
|
|
|
|
d.enable = "0";
|
|
|
|
|
|
if (!has(d, "required"))
|
|
|
|
|
|
d.required = "0";
|
|
|
|
|
|
|
|
|
|
|
|
let fieldlabel = d.fieldlabel || "",
|
|
|
|
|
|
fieldname = d.fieldname || "";
|
|
|
|
|
|
if (fieldlabel === "" || (this.moduleName != "resourcefielddefined" && fieldname === "")) {
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
labelArr.push(getCurrentLabel(d.fieldlabel));
|
|
|
|
|
|
nameArr.push(d.fieldname);
|
|
|
|
|
|
return false;
|
|
|
|
|
|
});
|
|
|
|
|
|
let checkSame = false;
|
|
|
|
|
|
if (this.moduleName.indexOf("resource") >= 0)
|
|
|
|
|
|
checkSame = uniq(labelArr).length === data.length;
|
|
|
|
|
|
else
|
|
|
|
|
|
checkSame = uniq(labelArr).length === data.length && uniq(nameArr).length === data.length;
|
|
|
|
|
|
if (invalidEmpty) {
|
|
|
|
|
|
|
|
|
|
|
|
} else if (checkSame) {
|
|
|
|
|
|
let dataObj = {
|
|
|
|
|
|
groupId: this.activeTabInfo.tabInfo.groupid,
|
|
|
|
|
|
records: data
|
|
|
|
|
|
};
|
|
|
|
|
|
if (this.selectedTreeNodeInfo != null)
|
|
|
|
|
|
dataObj.groupType = this.selectedTreeNodeInfo.key;
|
|
|
|
|
|
let params = {
|
|
|
|
|
|
data: JSON.stringify(dataObj)
|
|
|
|
|
|
};
|
|
|
|
|
|
if (this.selectedTreeNodeInfo != null)
|
|
|
|
|
|
params.groupType = this.selectedTreeNodeInfo.key;
|
|
|
|
|
|
|
|
|
|
|
|
console.log('params',params);
|
|
|
|
|
|
Api.saveFieldDefinedInfo(params).then(data => {
|
|
|
|
|
|
if (data.status === "1") {
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
message.error(data.message);
|
|
|
|
|
|
}
|
|
|
|
|
|
}, error => {
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
message.error(i18n.confirm.displayOrDBFieldExist());
|
|
|
|
|
|
this.spinning = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
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
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setEnableRows(e) {
|
|
|
|
|
|
extendObservable(this.tabTwoRelatedData, {
|
|
|
|
|
|
selectedData: {
|
|
|
|
|
|
isused: e
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-07 16:35:58 +08:00
|
|
|
|
arrToJson(arr, rows) {
|
|
|
|
|
|
let json = {};
|
|
|
|
|
|
|
|
|
|
|
|
const _rows = isEmpty(arr) ? [] : rows;
|
|
|
|
|
|
|
|
|
|
|
|
_rows && _rows.map(index => {
|
2022-11-08 15:56:34 +08:00
|
|
|
|
arr[index].isused = "1";
|
2022-11-07 16:35:58 +08:00
|
|
|
|
});
|
|
|
|
|
|
arr.map((item, index) => {
|
2022-11-08 15:56:34 +08:00
|
|
|
|
if (!item.isused) item.isused = "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
|
|
|
|
}
|
|
|
|
|
|
}
|