/* * Author: 黎永顺 * name: 添加退差人员弹框 * Description: * Date: 2022/11/22 */ import React, { Component } from "react"; import { WeaDatePicker, WeaDialog, WeaFormItem, WeaSearchGroup, WeaSelect } from "ecCom"; import { Button, Modal } from "antd"; import RegSelect from "./regSelect"; import * as API from "../../../../apis/standingBook"; class RegAddEmployee extends Component { constructor(props) { super(props); this.state = { baseInfo: { billMonth: "", items: "", itemsAll: "" }, returnPersonInfo: { employee: "", employeeOptions: [] }, selectPersonInfo: { employee: "", employeeOptions: [] } }; } handleReset = () => { this.setState({ baseInfo: { billMonth: "", items: "", itemsAll: "" }, returnPersonInfo: { ...this.state.returnPersonInfo, employee: "" }, selectPersonInfo: { ...this.state.selectPersonInfo, employee: "" } }); }; handleSave = () => { const { baseInfo, returnPersonInfo, selectPersonInfo } = this.state; const { onSave } = this.props; if (_.isEmpty(baseInfo.billMonth) || _.isEmpty(baseInfo.items) || _.isEmpty(returnPersonInfo.employee)) { Modal.warning({ title: "信息确认", content: "必要信息不完整,红色*为必填项!" }); return; } const payload = { recessionMonthList: baseInfo.billMonth.split(","), projects: baseInfo.itemsAll ? ["0"] : baseInfo.items.split(","), includes: returnPersonInfo.employee, excludes: selectPersonInfo.employee }; onSave(payload); }; render() { const { baseInfo, returnPersonInfo, selectPersonInfo } = this.state; const { loading } = this.props; const buttons = [ 保存, 重置 ]; const baseItems = [ { com: Picker({ label: "退差月份", value: baseInfo.billMonth, onChange: (billMonth) => { this.setState({ baseInfo: { ...baseInfo, billMonth } }); } }) }, { com: SelectWithAll({ label: "退差项目", options: [ { key: "1", showname: "社保" }, { key: "2", showname: "公积金" }, { key: "3", showname: "企业年金及其他福利" } ], detailtype: 2, valueAll: baseInfo.itemsAll, value: baseInfo.items, onChangeAll: ({ selected }) => { if (selected) { this.setState({ baseInfo: { ...baseInfo, itemsAll: selected, items: "1,2,3" } }); } else { this.setState({ baseInfo: { ...baseInfo, itemsAll: selected, items: "" } }); } }, onChange: ({ selected }) => { const bool1 = selected.split(",").includes("1"); const bool2 = selected.split(",").includes("2"); const bool3 = selected.split(",").includes("3"); if (bool1 && bool2 && bool3) { this.setState({ baseInfo: { ...baseInfo, itemsAll: "0", items: selected } }); } else { this.setState({ baseInfo: { ...baseInfo, itemsAll: "", items: selected } }); } } }) } ]; const returnPersonItems = [ { com: this.setState({ returnPersonInfo: { ...returnPersonInfo, employee: selected } })} /> } ]; const selectPersonItems = [ { com: this.setState({ selectPersonInfo: { ...selectPersonInfo, employee: selected } })} /> } ]; return ( ); } } export default RegAddEmployee; export const Picker = payload => { const { label, onChange, value, viewAttr = 3, format = "YYYY-MM" } = payload; return ( ); }; export const SelectWithAll = payload => { const { label, onChange, value, valueAll, onChangeAll, options = [], viewAttr = 3, detailtype = 1 } = payload; return ( onChangeAll({ selected, showName })} style={{ width: "inherit" }} /> onChange({ type: label, selected, showName })} style={{ width: "inherit" }} /> ); };