import React from "react"; import { Button, Col, Row } from "antd"; import { WeaBrowser, WeaCheckbox, WeaDialog, WeaError, WeaSelect } from "ecCom"; import "../ledger/index.less"; export default class AddTaxAgentModal extends React.Component { constructor(props) { super(props); this.state = { selectedKey: "EMPLOYEE", checkboxValue: "", checkAll: "0", ids: "" }; } onCheckboxChange = (checkboxValue) => { const { employeeStatus } = this.props; const checked = _.map(employeeStatus, it => it.id); this.setState({ checkboxValue }, () => { const { checkboxValue } = this.state; const bool = _.every(checked, it => checkboxValue.indexOf(it) !== -1); if (bool) { this.setState({ checkAll: "1" }); }else{ this.setState({ checkAll: "0" }); } }); }; // 保存 handleSave = () => { const { onTaxAgentSave } = this.props; const { checkboxValue, ids, selectedKey } = this.state; const payload = { employeeStatus: checkboxValue.split(","), targetParams: _.map(ids.split(","), (it) => ({ targetType: selectedKey, targetId: it })) }; if (_.isEmpty(ids) && _.isEmpty(checkboxValue)) { this.refs.weaError.showError(); this.refs.weaError1.showError(); return; } if (_.isEmpty(ids)) { this.refs.weaError.showError(); return; } if (_.isEmpty(checkboxValue)) { this.refs.weaError1.showError(); return; } onTaxAgentSave && onTaxAgentSave(payload); }; // 重置 handleReset = () => { this.setState({ selectedKey: "EMPLOYEE", checkboxValue: "", checkAll: '0', ids: "" }); }; render() { const { employeeStatus, targetTypeList, visible, onCancel, loading } = this.props; return ( { this.handleReset(); onCancel(); }} style={{ width: 600 }} initLoadCss className="associatesWrapper" title="关联人员" buttons={[ , ]}>
对象类型
({ ...it, key: it.id, showname: it.name, selected: false }))} value={this.state.selectedKey} onChange={(value) => { 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.id); this.setState({ checkAll: '1', checkboxValue: checked.join(",") }); } else { this.setState({ checkAll: '0', checkboxValue: '' }); } }}/> ({ showname: it.name, key: it.id }))} value={this.state.checkboxValue} onChange={(value) => this.onCheckboxChange(value)} />
); } }