栏目权限新增自定义项
This commit is contained in:
parent
daea5ba97b
commit
6b3f35374c
|
|
@ -15,3 +15,10 @@ export const getTable = (params) => {
|
||||||
export const cardAccessSave = (params) => {
|
export const cardAccessSave = (params) => {
|
||||||
return WeaTools.callApi('/api/bs/hrmorganization/cardAccess/save', 'POST', params);
|
return WeaTools.callApi('/api/bs/hrmorganization/cardAccess/save', 'POST', params);
|
||||||
}
|
}
|
||||||
|
export const getFieldDefinedInfo = (params) => {
|
||||||
|
return WeaTools.callApi('/api/hrm/subcompanyfielddefined/getFieldDefinedInfo', 'GET', {is_multilang_set: true,groupId:6});
|
||||||
|
}
|
||||||
|
export const saveFieldDefinedInfo = (params) => {
|
||||||
|
return WeaTools.callApi('', 'POST', params);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
import React, { Component } from "react";
|
||||||
|
import { WeaTableEdit } from "ecCom";
|
||||||
|
import { inject, observer } from "mobx-react";
|
||||||
|
|
||||||
|
@inject("columnPermission")
|
||||||
|
@observer
|
||||||
|
class CustomItem extends Component {
|
||||||
|
componentDidMount() {
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
init = () => {
|
||||||
|
const { columnPermission } = this.props;
|
||||||
|
columnPermission.loadTabThreeRelatedData();
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { columnPermission } = this.props, { tableEditConfig, refreshMainTabComponent } = columnPermission;
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<WeaTableEdit
|
||||||
|
ecId={`${this && this.props && this.props.ecId || ""}_WeaTableEdit@5fu5eh`}
|
||||||
|
rowKey={"fieldidrowKey"}
|
||||||
|
{...tableEditConfig['fieldDef']}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CustomItem;
|
||||||
|
|
@ -47,14 +47,17 @@ class PermissionItem extends Component {
|
||||||
};
|
};
|
||||||
} else if (c.dataIndex === "custom") {
|
} else if (c.dataIndex === "custom") {
|
||||||
c.render = (text, record) => {
|
c.render = (text, record) => {
|
||||||
|
const custom = record[c.dataIndex].split(",");
|
||||||
|
const customspan = record[`${c.dataIndex}span`].split(",");
|
||||||
|
const replaceDatas = _.map(custom, (item, index) => ({ id: custom[index], name: customspan[index] }));
|
||||||
return (
|
return (
|
||||||
<WeaBrowser
|
<WeaBrowser
|
||||||
inputStyle={{ width: 200 }}
|
inputStyle={{ width: 200 }}
|
||||||
type={65}
|
type={65}
|
||||||
isSingle={false}
|
isSingle={false}
|
||||||
value={record[c.dataIndex]}
|
|
||||||
title="多角色"
|
title="多角色"
|
||||||
linkUrl="/spa/hrm/engine.html#/hrmengine/roleInfo/info?id="
|
linkUrl="/spa/hrm/engine.html#/hrmengine/roleInfo/info?id="
|
||||||
|
replaceDatas={replaceDatas}
|
||||||
onChange={value => {
|
onChange={value => {
|
||||||
this.changeSaveParams(record, value, c.dataIndex);
|
this.changeSaveParams(record, value, c.dataIndex);
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import { inject, observer } from "mobx-react";
|
||||||
import { Button } from "antd";
|
import { Button } from "antd";
|
||||||
import PermissionItem from "./components/permissionItem";
|
import PermissionItem from "./components/permissionItem";
|
||||||
import DefineShowItems from "./components/defineShowItems";
|
import DefineShowItems from "./components/defineShowItems";
|
||||||
|
import CustomItem from "./components/customItem";
|
||||||
import { i18n } from "../../public/i18n";
|
import { i18n } from "../../public/i18n";
|
||||||
import { renderNoright } from "../../util";
|
import { renderNoright } from "../../util";
|
||||||
|
|
||||||
|
|
@ -36,16 +37,22 @@ class ColumnPermission extends Component {
|
||||||
getTabName = () => {
|
getTabName = () => {
|
||||||
return [{
|
return [{
|
||||||
key: "0",
|
key: "0",
|
||||||
title: i18n.label.permissionManagement()
|
title: i18n.label.defineShowItems()
|
||||||
}, {
|
}, {
|
||||||
key: "1",
|
key: "1",
|
||||||
title: i18n.label.defineShowItems()
|
title: i18n.label.permissionManagement()
|
||||||
|
}, {
|
||||||
|
key: "2",
|
||||||
|
title: i18n.label.custom()
|
||||||
}];
|
}];
|
||||||
};
|
};
|
||||||
save = () => {
|
save = () => {
|
||||||
const { columnPermission } = this.props;
|
const { columnPermission } = this.props;
|
||||||
const { selectedKey } = columnPermission;
|
const { selectedKey } = columnPermission;
|
||||||
selectedKey === "0" ? columnPermission.columnPermissionSave() : columnPermission.userDefineCardItemSave();
|
selectedKey === "0" ?
|
||||||
|
columnPermission.userDefineCardItemSave() :
|
||||||
|
selectedKey === "1" ?
|
||||||
|
columnPermission.columnPermissionSave() : columnPermission.saveCustomFiled();
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
@ -58,8 +65,12 @@ class ColumnPermission extends Component {
|
||||||
<div style={{ height: "100%" }}>
|
<div style={{ height: "100%" }}>
|
||||||
<WeaRightMenu
|
<WeaRightMenu
|
||||||
ecId={`${this && this.props && this.props.ecId || ""}_WeaRightMenu@k6oc4u`}
|
ecId={`${this && this.props && this.props.ecId || ""}_WeaRightMenu@k6oc4u`}
|
||||||
datas={[]}
|
datas={[{
|
||||||
onClick={key => console.log(key)}
|
key: "save",
|
||||||
|
icon: <i className="icon-coms-Preservation"/>,
|
||||||
|
content: "保存"
|
||||||
|
}]}
|
||||||
|
onClick={key => (key && this[key]())}
|
||||||
>
|
>
|
||||||
<WeaTop
|
<WeaTop
|
||||||
ecId={`${this && this.props && this.props.ecId || ""}_WeaTop@bj98s7`}
|
ecId={`${this && this.props && this.props.ecId || ""}_WeaTop@bj98s7`}
|
||||||
|
|
@ -81,9 +92,10 @@ class ColumnPermission extends Component {
|
||||||
/>
|
/>
|
||||||
{
|
{
|
||||||
selectedKey === "0" ?
|
selectedKey === "0" ?
|
||||||
<PermissionItem
|
<DefineShowItems ecId={`${this && this.props && this.props.ecId || ""}_DefineShowItems@q1hmoj`}/> :
|
||||||
ecId={`${this && this.props && this.props.ecId || ""}_SysShowItems@0wqtjk`}/> :
|
selectedKey === "1" ?
|
||||||
<DefineShowItems ecId={`${this && this.props && this.props.ecId || ""}_DefineShowItems@q1hmoj`}/>
|
<PermissionItem ecId={`${this && this.props && this.props.ecId || ""}_SysShowItems@0wqtjk`}/> :
|
||||||
|
<CustomItem ecId={`${this && this.props && this.props.ecId || ""}_CustomItems@0wqtjk`}/>
|
||||||
}
|
}
|
||||||
</WeaRightMenu>
|
</WeaRightMenu>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
import React, { Component } from "react";
|
|
||||||
import { WeaRightMenu, WeaTop } from "ecCom";
|
|
||||||
import { Button } from "antd";
|
|
||||||
import { i18n } from "../../public/i18n";
|
|
||||||
|
|
||||||
class FeatureDefine extends Component {
|
|
||||||
getTopMenuBtns = () => {
|
|
||||||
return [
|
|
||||||
<Button type="primary">新建</Button>,
|
|
||||||
<Button type="ghost">修改</Button>
|
|
||||||
];
|
|
||||||
};
|
|
||||||
getDropMenuDatas = () => {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
key: "add",
|
|
||||||
icon: <i className="icon-search"/>,
|
|
||||||
content: "新建"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "edit",
|
|
||||||
icon: <i className="icon-search"/>,
|
|
||||||
content: "修改",
|
|
||||||
onClick: key => alert(`点击了搜索 key = ${key}`)
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
render() {
|
|
||||||
return (
|
|
||||||
<div style={{ height: "100%" }}>
|
|
||||||
<WeaRightMenu
|
|
||||||
ecId={`${this && this.props && this.props.ecId || ""}_WeaRightMenu@k6oc4u`}
|
|
||||||
datas={[]}
|
|
||||||
onClick={key => console.log(key)}
|
|
||||||
>
|
|
||||||
<WeaTop
|
|
||||||
ecId={`${this && this.props && this.props.ecId || ""}_WeaTop@bj98s7`}
|
|
||||||
title={i18n.label.personCardFun()}
|
|
||||||
icon={<i className="icon-coms-hrm"/>}
|
|
||||||
iconBgcolor="#217346"
|
|
||||||
loading={true}
|
|
||||||
buttons={this.getTopMenuBtns()}
|
|
||||||
showDropIcon={true}
|
|
||||||
dropMenuDatas={this.getDropMenuDatas()}
|
|
||||||
onDropMenuClick={(e) => console.log(e)}
|
|
||||||
/>
|
|
||||||
</WeaRightMenu>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default FeatureDefine;
|
|
||||||
|
|
@ -34,7 +34,6 @@ import ResourceBasicInfo from "./components/resource/ResourceBasicInfo";
|
||||||
import ResourceCard from "./components/resource/ResourceCard";
|
import ResourceCard from "./components/resource/ResourceCard";
|
||||||
import ManagerDetach from "./components/detach/ManagerDetach";
|
import ManagerDetach from "./components/detach/ManagerDetach";
|
||||||
import ColumnPermission from "./components/columnPermission";
|
import ColumnPermission from "./components/columnPermission";
|
||||||
import FeatureDefine from "./components/featureDefine";
|
|
||||||
|
|
||||||
import stores from "./stores";
|
import stores from "./stores";
|
||||||
import "./style/index";
|
import "./style/index";
|
||||||
|
|
@ -101,7 +100,6 @@ const Routes = (
|
||||||
<Route key="resourceCard" path="resourceCard/:id" component={ResourceCard} />
|
<Route key="resourceCard" path="resourceCard/:id" component={ResourceCard} />
|
||||||
<Route key="managerDetach" path="managerDetach" component={ManagerDetach} />
|
<Route key="managerDetach" path="managerDetach" component={ManagerDetach} />
|
||||||
<Route key="columnPermission" path="columnPermission" component={ColumnPermission} />
|
<Route key="columnPermission" path="columnPermission" component={ColumnPermission} />
|
||||||
<Route key="featureDefine" path="featureDefine" component={FeatureDefine} />
|
|
||||||
</Route>
|
</Route>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -566,6 +566,7 @@ export const i18n = {
|
||||||
sysShowItems: () => getLabel(32980, '系统显示栏目'),
|
sysShowItems: () => getLabel(32980, '系统显示栏目'),
|
||||||
permissionManagement: () => getLabel(32980, '权限管理'),
|
permissionManagement: () => getLabel(32980, '权限管理'),
|
||||||
defineShowItems: () => getLabel(32744, '自定义显示栏目'),
|
defineShowItems: () => getLabel(32744, '自定义显示栏目'),
|
||||||
|
custom: () => getLabel(32743, '自定义'),
|
||||||
childItems: () => getLabel(32749, '子栏目'),
|
childItems: () => getLabel(32749, '子栏目'),
|
||||||
sysadminRemind: () => getLabel(386231, '管理员提醒'),
|
sysadminRemind: () => getLabel(386231, '管理员提醒'),
|
||||||
staffRemind: () => getLabel(386232, '员工提醒'),
|
staffRemind: () => getLabel(386232, '员工提醒'),
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,182 @@
|
||||||
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 HrmBaseStore from "./baseStore";
|
||||||
import { WeaTableNew } from "comsMobx";
|
import { WeaTableNew } from "comsMobx";
|
||||||
import { message } from "antd";
|
import { message } from "antd";
|
||||||
import { WeaHelpfulTip } from "ecCom";
|
import { WeaHelpfulTip, WeaInputLocale } from "ecCom";
|
||||||
import { isEmpty } from "lodash";
|
import { cloneDeep, has, indexOf, isEmpty, remove, uniq } from "lodash";
|
||||||
import { i18n } from "../public/i18n";
|
import { i18n } from "../public/i18n";
|
||||||
import * as Api from "../apis/columnPermission";
|
import * as Api from "../apis/columnPermission";
|
||||||
|
import { validDBKeys } from "../util";
|
||||||
|
|
||||||
|
const getCurrentLabel = WeaInputLocale.getCurrentLabel;
|
||||||
const { TableStore } = WeaTableNew;
|
const { TableStore } = WeaTableNew;
|
||||||
|
|
||||||
const toJS = mobx.toJS;
|
const toJS = mobx.toJS;
|
||||||
|
|
||||||
export class ColumnPermission {
|
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时,变更此值
|
||||||
@observable tableStore = new TableStore();
|
@observable tableStore = new TableStore();
|
||||||
@observable columnsPermissionData = [];
|
@observable columnsPermissionData = [];
|
||||||
@observable selectedKey = "0";
|
@observable selectedKey = "0";
|
||||||
|
|
@ -58,6 +223,175 @@ export class ColumnPermission {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
loadTabOneRelatedData() {
|
loadTabOneRelatedData() {
|
||||||
this.tabOneRelatedData.loading = true;
|
this.tabOneRelatedData.loading = true;
|
||||||
Promise.all(
|
Promise.all(
|
||||||
|
|
@ -144,26 +478,34 @@ export class ColumnPermission {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
columnPermissionSave() {
|
columnPermissionSave() {
|
||||||
let params = {
|
let params = {
|
||||||
...toJS(this.checkedItems)
|
...toJS(this.checkedItems)
|
||||||
};
|
};
|
||||||
Api.cardAccessSave(params).then(res => {
|
Api.cardAccessSave(params).then(({ code, msg }) => {
|
||||||
console.log(res);
|
if (code === 200) {
|
||||||
// let {
|
this.loadTabOneRelatedData();
|
||||||
// api_status,
|
message.success(msg || "操作成功");
|
||||||
// sign
|
} else {
|
||||||
// } = res;
|
message.error(msg || "操作失败");
|
||||||
//
|
}
|
||||||
// if (api_status) {
|
|
||||||
// if (sign == "1") {
|
|
||||||
// res.message && message.success(res.message);
|
|
||||||
// } else {
|
|
||||||
// res.message && message.warning(res.message);
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// message.error(res.message);
|
|
||||||
// }
|
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
message.error(error);
|
message.error(error);
|
||||||
});
|
});
|
||||||
|
|
@ -193,9 +535,76 @@ export class ColumnPermission {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
arrColumnsToJson(arr, rows) {
|
arrColumnsToJson(arr, rows) {
|
||||||
let jsonColumn = {
|
let jsonColumn = {
|
||||||
rownum:arr.length
|
rownum: arr.length
|
||||||
};
|
};
|
||||||
arr.map((item, index) => {
|
arr.map((item, index) => {
|
||||||
for (let key in item) {
|
for (let key in item) {
|
||||||
|
|
@ -205,6 +614,30 @@ export class ColumnPermission {
|
||||||
return jsonColumn;
|
return jsonColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
arrToJson(arr, rows) {
|
arrToJson(arr, rows) {
|
||||||
let json = {};
|
let json = {};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue