salary-management-front/pc4mobx/hrmSalary/pages/ledger/addUserModal.js

221 lines
6.2 KiB
JavaScript
Raw Normal View History

2022-06-02 17:11:28 +08:00
import React from "react";
import { Button, Col, Row } from "antd";
2022-11-10 09:19:09 +08:00
import { WeaBrowser, WeaCheckbox, WeaDialog, WeaSelect } from "ecCom";
2022-06-02 17:11:28 +08:00
import { inject, observer } from "mobx-react";
import "./index.less";
2022-03-25 16:41:59 +08:00
2022-11-10 09:19:09 +08:00
const employeeStatus = [
{ key: "TRIAL", showname: "试用" },
{ key: "FORMAL", showname: "正式" },
{ key: "TEMPORARY", showname: "临时" },
{ key: "DELAY", showname: "试用延期" },
{ key: "FIRE", showname: "解雇" },
{ key: "DEPARTURE", showname: "离职" },
{ key: "RETIRED", showname: "退休" }
];
2022-03-25 16:41:59 +08:00
const objectOptions = [
2022-06-02 17:11:28 +08:00
{
key: "EMPLOYEE",
showname: "人员",
selected: false
2022-06-02 17:11:28 +08:00
},
{
key: "SUBCOMPANY",
showname: "分部",
selected: false
2022-06-02 17:11:28 +08:00
},
{
key: "DEPT",
showname: "部门",
selected: false
2022-06-02 17:11:28 +08:00
},
{
key: "POSITION",
showname: "岗位",
selected: false
}
2022-06-02 17:11:28 +08:00
];
2022-03-25 16:41:59 +08:00
2022-06-02 17:11:28 +08:00
@inject("ledgerStore")
2022-03-25 16:41:59 +08:00
@observer
export default class AddUserModal extends React.Component {
2022-06-02 17:11:28 +08:00
constructor(props) {
super(props);
this.state = {
selectedKey: "EMPLOYEE",
2022-10-10 15:02:46 +08:00
radioValue: "",
2022-11-10 09:19:09 +08:00
checkAll: "0",
ids: ""
2022-06-02 17:11:28 +08:00
};
}
2022-03-25 16:41:59 +08:00
onRadioChange(radioValue) {
2022-11-10 09:19:09 +08:00
const checked = _.map(employeeStatus, it => it.key);
this.setState({ radioValue }, () => {
const { radioValue } = this.state;
const bool = _.every(checked, it => radioValue.indexOf(it) !== -1);
if (bool) {
this.setState({
checkAll: "1"
});
} else {
this.setState({
checkAll: "0"
});
}
});
2022-06-02 17:11:28 +08:00
}
2022-03-25 16:41:59 +08:00
2022-06-02 17:11:28 +08:00
// 保存
handleSave() {
const {
ledgerStore: { saveLedgerPersonRange, salarySobId, includeType }
2022-06-02 17:11:28 +08:00
} = this.props;
saveLedgerPersonRange({
salarySobId: salarySobId,
includeType: includeType,
2022-11-10 09:19:09 +08:00
employeeStatus: this.state.radioValue.split(","),
2022-06-02 17:11:28 +08:00
targetParams: this.state.ids
.split(",")
.map((id) => ({ targetType: this.state.selectedKey, targetId: id }))
2022-06-02 17:11:28 +08:00
});
}
2022-03-25 16:41:59 +08:00
2022-06-02 17:11:28 +08:00
// 重置
handleReset() {
this.setState({
selectedKey: "EMPLOYEE",
2022-10-10 15:02:46 +08:00
radioValue: "",
2022-11-10 09:19:09 +08:00
checkAll: "0",
ids: ""
2022-06-02 17:11:28 +08:00
});
}
2022-04-06 14:26:16 +08:00
2022-06-02 17:11:28 +08:00
render() {
return (
<WeaDialog
2022-06-02 17:11:28 +08:00
visible={this.props.visible}
onCancel={() => {
this.props.onCancel();
}}
initLoadCss
className="associatesWrapper"
style={{ width: 600 }}
2022-06-02 17:11:28 +08:00
title="关联人员"
buttons={[
<Button
type="primary"
onClick={() => {
this.handleSave();
}}>
保存
</Button>,
<Button
type="default"
onClick={() => {
this.handleReset();
}}>
重置
</Button>
]}>
<div style={{ padding: "16px 60px" }}>
2022-06-02 17:11:28 +08:00
<Row style={{ lineHeight: "40px" }}>
<Col span={5}>对象类型:</Col>
2022-06-02 17:11:28 +08:00
<Col span={16}>
2022-11-10 09:19:09 +08:00
<div style={{ display: "inline-block", verticalAlign: "top", marginRight: 10 }}>
2022-06-02 17:11:28 +08:00
<WeaSelect
options={objectOptions}
value={this.state.selectedKey}
onChange={(value) => {
this.setState({ selectedKey: value, ids: "" });
}}
/>
</div>
<div style={{ display: "inline-block", verticalAlign: "middle" }}>
{this.state.selectedKey == "EMPLOYEE" && (
<WeaBrowser
type={17}
viewAttr={3}
2022-06-02 17:11:28 +08:00
title={"人员选择"}
isSingle={false}
inputStyle={{ width: 200 }}
value={this.state.ids}
2022-06-02 17:11:28 +08:00
onChange={(ids, names, datas) => {
this.setState({ ids });
}}
/>
)}
{this.state.selectedKey == "DEPT" && (
<WeaBrowser
type={57}
viewAttr={3}
2022-06-02 17:11:28 +08:00
title={"部门选择"}
isSingle={false}
value={this.state.ids}
2022-06-02 17:11:28 +08:00
inputStyle={{ width: 200 }}
onChange={(ids, names, datas) => {
this.setState({ ids });
}}
/>
)}
{this.state.selectedKey == "SUBCOMPANY" && (
<WeaBrowser
type={164}
viewAttr={3}
2022-06-02 17:11:28 +08:00
title={"分部选择"}
isSingle={false}
value={this.state.ids}
2022-06-02 17:11:28 +08:00
inputStyle={{ width: 200 }}
onChange={(ids, names, datas) => {
this.setState({ ids });
}}
/>
)}
{this.state.selectedKey == "POSITION" && (
<WeaBrowser
type={278}
viewAttr={3}
2022-06-02 17:11:28 +08:00
title={"岗位选择"}
isSingle={false}
value={this.state.ids}
2022-06-02 17:11:28 +08:00
inputStyle={{ width: 200 }}
onChange={(ids, names, datas) => {
this.setState({ ids });
}}
/>
)}
</div>
</Col>
</Row>
<Row style={{ lineHeight: "40px" }}>
<Col span={5}>选择员工状态:</Col>
2022-06-02 17:11:28 +08:00
<Col span={16}>
2022-11-10 09:19:09 +08:00
<WeaCheckbox value={this.state.checkAll} content="全选" onChange={(checkAll) => {
if (checkAll === "1") {
const checked = _.map(employeeStatus, it => it.key);
this.setState({
checkAll: "1",
radioValue: checked.join(",")
});
} else {
this.setState({
checkAll: "0",
radioValue: ""
});
}
}}/>
<WeaSelect
viewAttr={3}
2022-10-10 15:02:46 +08:00
detailtype={2}
2022-06-02 17:11:28 +08:00
onChange={(e) => this.onRadioChange(e)}
value={this.state.radioValue}
2022-11-10 09:19:09 +08:00
options={employeeStatus}
/>
2022-06-02 17:11:28 +08:00
</Col>
</Row>
</div>
</WeaDialog>
2022-06-02 17:11:28 +08:00
);
}
}