trunk/pc4mobx/organization/components/columnSetting/index.js

107 lines
3.1 KiB
JavaScript
Raw Normal View History

2022-10-31 13:52:22 +08:00
import React, { Component } from "react";
2022-11-07 16:35:58 +08:00
import { WeaRightMenu, WeaTab, WeaTop } from "ecCom";
import { inject, observer } from "mobx-react";
2022-10-31 13:52:22 +08:00
import { Button } from "antd";
2022-11-10 18:50:45 +08:00
import PermissionItem from "./permissionItem";
import DefineShowItems from "./defineShowItems";
import CustomItem from "./customItem";
2022-10-31 13:52:22 +08:00
import { i18n } from "../../public/i18n";
2022-11-08 15:56:34 +08:00
import { renderNoright } from "../../util";
2022-10-31 13:52:22 +08:00
2022-11-10 18:50:45 +08:00
@inject("columnSetting")
2022-11-07 16:35:58 +08:00
@observer
2022-11-10 18:50:45 +08:00
class ColumnSetting extends Component {
2022-11-08 15:56:34 +08:00
componentDidMount() {
this.init();
}
init = () => {
2022-11-10 18:50:45 +08:00
const { columnSetting } = this.props;
columnSetting.getRight();
2022-11-08 15:56:34 +08:00
};
2022-10-31 13:52:22 +08:00
getTopMenuBtns = () => {
return [
2022-11-07 16:35:58 +08:00
<Button type="primary" onClick={this.save}>保存</Button>
2022-10-31 13:52:22 +08:00
];
};
getDropMenuDatas = () => {
return [
{
2022-11-07 16:35:58 +08:00
key: "save",
icon: <i className="icon-coms-Preservation"/>,
content: "保存"
2022-10-31 13:52:22 +08:00
}
];
};
2022-11-07 16:35:58 +08:00
getTabName = () => {
return [{
key: "0",
2022-11-10 16:10:21 +08:00
title: i18n.label.defineShowItems()
2022-11-07 16:35:58 +08:00
}, {
key: "1",
2022-11-10 18:50:45 +08:00
title: i18n.label.columnPermission()
2022-11-10 16:10:21 +08:00
}, {
key: "2",
2022-11-10 18:50:45 +08:00
title: i18n.label.columnCustom()
2022-11-07 16:35:58 +08:00
}];
};
save = () => {
2022-11-10 18:50:45 +08:00
const { columnSetting } = this.props;
const { selectedKey } = columnSetting;
2022-11-10 16:10:21 +08:00
selectedKey === "0" ?
2022-11-10 18:50:45 +08:00
columnSetting.userDefineCardItemSave() :
2022-11-10 16:10:21 +08:00
selectedKey === "1" ?
2022-11-10 18:50:45 +08:00
columnSetting.columnPermissionSave() : columnSetting.saveCustomFiled();
2022-11-07 16:35:58 +08:00
};
2022-10-31 13:52:22 +08:00
render() {
2022-11-10 18:50:45 +08:00
const { columnSetting } = this.props;
const { selectedKey, authorized } = columnSetting;
2022-11-08 17:43:26 +08:00
if (!authorized) {
return renderNoright();
}
2022-10-31 13:52:22 +08:00
return (
<div style={{ height: "100%" }}>
<WeaRightMenu
ecId={`${this && this.props && this.props.ecId || ""}_WeaRightMenu@k6oc4u`}
2022-11-10 16:10:21 +08:00
datas={[{
key: "save",
icon: <i className="icon-coms-Preservation"/>,
content: "保存"
}]}
onClick={key => (key && this[key]())}
2022-10-31 13:52:22 +08:00
>
<WeaTop
ecId={`${this && this.props && this.props.ecId || ""}_WeaTop@bj98s7`}
2022-11-10 18:50:45 +08:00
title={i18n.label.cardColumnSet()}
2022-10-31 13:52:22 +08:00
icon={<i className="icon-coms-hrm"/>}
iconBgcolor="#217346"
loading={true}
buttons={this.getTopMenuBtns()}
showDropIcon={true}
dropMenuDatas={this.getDropMenuDatas()}
2022-11-07 16:35:58 +08:00
onDropMenuClick={(e) => (e && this[e]())}
2022-10-31 13:52:22 +08:00
/>
2022-11-07 16:35:58 +08:00
<WeaTab
ecId={`${this && this.props && this.props.ecId || ""}_WeaTab@8mmoen`}
selectedKey={selectedKey}
datas={this.getTabName()}
keyParam="key"
2022-11-10 18:50:45 +08:00
onChange={(key) => columnSetting.setSelectedKey(key)}
2022-10-31 13:52:22 +08:00
/>
2022-11-07 16:35:58 +08:00
{
selectedKey === "0" ?
2022-11-10 16:10:21 +08:00
<DefineShowItems ecId={`${this && this.props && this.props.ecId || ""}_DefineShowItems@q1hmoj`}/> :
selectedKey === "1" ?
<PermissionItem ecId={`${this && this.props && this.props.ecId || ""}_SysShowItems@0wqtjk`}/> :
<CustomItem ecId={`${this && this.props && this.props.ecId || ""}_CustomItems@0wqtjk`}/>
2022-11-07 16:35:58 +08:00
}
2022-10-31 13:52:22 +08:00
</WeaRightMenu>
</div>
);
2022-11-10 18:50:45 +08:00
}
2022-10-31 13:52:22 +08:00
}
2022-11-10 18:50:45 +08:00
export default ColumnSetting;