import React from "react"; import { Button, Col, message, Row, Select } from "antd"; import moment from "moment"; import { WeaDatePicker, WeaDialog, WeaError, WeaInput, WeaSelect } from "ecCom"; import SelectItemModal from "../../../components/selectItemsModal"; import SelectItemsWrapper from "../../../components/selectItemsModal/selectItemsWrapper"; import { inject, observer } from "mobx-react"; import { notNull } from "../../../util/validate"; const { Option } = Select; @inject("attendanceStore") @observer export default class RefereAttendFormModal extends React.Component { constructor(props) { super(props); this.state = { headerSetVisible: false, inited: false, request: { salarySobId: "", salaryYearMonth: moment(new Date()).format("YYYY-MM"), employeeIds: [], description: "" } }; } handleHeaderSet() { this.setState({ headerSetVisible: true }); this.props.onHeaderSet(); } componentWillMount() { const { attendanceStore: { getLedgerList } } = this.props; getLedgerList().then(() => { this.setState({ inited: true }); }); } // 请求参数改变事件 handleRequestChange(params) { const { request } = this.state; let result = { ...request, ...params }; this.setState({ request: result }); } // 同步点击回调 handleSync() { const { attendanceStore: { syncAttendanceRefer, checkOperation } } = this.props; if (!this.validate()) { return; } const { salarySobId, salaryYearMonth: salaryYearMonthStr } = this.state.request; const payload = { salaryYearMonthStr, salarySobId }; checkOperation(payload).then(({ status, data, errorMsg }) => { if (status && data) { syncAttendanceRefer(this.state.request).then(() => { this.props.onCancel(); }); } else { message.warning("已经核算过不可操作"); } }); } // 校验数据 validate() { const { request } = this.state; if (!notNull(request.salarySobId) && !notNull(request.salaryYearMonth)) { this.refs.weaError.showError(); this.refs.weaError1.showError(); return false; } if (!notNull(request.salarySobId)) { this.refs.weaError1.showError(); return false; } if (!notNull(request.salaryYearMonth)) { this.refs.weaError.showError(); return false; } return true; } render() { const { attendanceStore: { importLedgerList } } = this.props; return ( { this.handleSync(); }}>同步, ]} visible={this.props.visible} onCancel={this.props.onCancel}> 薪资所属月: { if (value === "") this.refs.weaError.showError(); this.handleRequestChange({ salaryYearMonth: value }); }} /> 薪资账套: { this.state.inited && ({ key: it.id, showname: it.content }))] } onChange={(value) => { if (value === "") this.refs.weaError1.showError(); this.handleRequestChange({ salarySobId: value }); }}/> } 备注 { this.handleRequestChange({ description: value }); }}/> { this.props.onShowChecked(value); }} onRestoreDefault={() => { this.props.onRestoreDefault(); }} onSetDefault={() => { this.props.onSetDefault(); }} onSearch={(value) => { this.props.onSearch(value); }} onSave={(value) => { this.props.onSave(value); }} visible={this.state.headerSetVisible} onCancel={() => this.setState({ headerSetVisible: false })}> { this.props.onChange(value); }}/> ); } }