import React from "react"; import { Button, Col, Row } from "antd"; import { WeaBrowser, WeaCheckbox, WeaDialog, WeaSelect } from "ecCom"; import { inject, observer } from "mobx-react"; import "./index.less"; const employeeStatus = [ { key: "TRIAL", showname: "试用" }, { key: "FORMAL", showname: "正式" }, { key: "TEMPORARY", showname: "临时" }, { key: "DELAY", showname: "试用延期" }, { key: "FIRE", showname: "解雇" }, { key: "DEPARTURE", showname: "离职" }, { key: "RETIRED", showname: "退休" } ]; const objectOptions = [ { key: "EMPLOYEE", showname: "人员", selected: false }, { key: "SUBCOMPANY", showname: "分部", selected: false }, { key: "DEPT", showname: "部门", selected: false }, { key: "POSITION", showname: "岗位", selected: false } ]; @inject("ledgerStore") @observer export default class AddUserModal extends React.Component { constructor(props) { super(props); this.state = { selectedKey: "EMPLOYEE", radioValue: "", checkAll: "0", ids: "" }; } onRadioChange(radioValue) { 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" }); } }); } // 保存 handleSave() { const { ledgerStore: { saveLedgerPersonRange, salarySobId, includeType } } = this.props; saveLedgerPersonRange({ salarySobId: salarySobId, includeType: includeType, employeeStatus: this.state.radioValue.split(","), targetParams: this.state.ids .split(",") .map((id) => ({ targetType: this.state.selectedKey, targetId: id })) }); } // 重置 handleReset() { this.setState({ selectedKey: "EMPLOYEE", radioValue: "", checkAll: "0", ids: "" }); } render() { return ( { this.props.onCancel(); }} initLoadCss className="associatesWrapper" style={{ width: 600 }} title="关联人员" buttons={[ , ]}>
对象类型:
{ this.setState({ selectedKey: value, ids: "" }); }} />
{this.state.selectedKey == "EMPLOYEE" && ( { this.setState({ ids }); }} /> )} {this.state.selectedKey == "DEPT" && ( { this.setState({ ids }); }} /> )} {this.state.selectedKey == "SUBCOMPANY" && ( { this.setState({ ids }); }} /> )} {this.state.selectedKey == "POSITION" && ( { this.setState({ ids }); }} /> )}
选择员工状态: { if (checkAll === "1") { const checked = _.map(employeeStatus, it => it.key); this.setState({ checkAll: "1", radioValue: checked.join(",") }); } else { this.setState({ checkAll: "0", radioValue: "" }); } }}/> this.onRadioChange(e)} value={this.state.radioValue} options={employeeStatus} />
); } }