import React from "react"; import { WeaDatePicker, WeaDialog, WeaError, WeaFormItem, WeaHelpfulTip, WeaLocaleProvider, WeaSelect, WeaTextarea } from "ecCom"; import { Button, message } from "antd"; import { inject, observer } from "mobx-react"; import { taxdeclarationGetRate } from "../../apis/declare"; import moment from "moment"; import "./index.less"; const getLabel = WeaLocaleProvider.getLabel; @inject("declareStore", "taxAgentStore") @observer export default class GenerateModal extends React.Component { constructor(props) { super(props); this.state = { date: "", taxAgentId: "", description: "", loading: false }; this.timer = null; } // 生成申报表 handleGenerate = () => { const { declareStore: { saveDeclare } } = this.props; const { date, taxAgentId, description } = this.state; if (_.isEmpty(date) && _.isEmpty(taxAgentId)) { this.refs.weaError.showError(); this.refs.weaError1.showError(); return; } if (_.isEmpty(date)) { this.refs.weaError.showError(); return; } if (_.isEmpty(taxAgentId)) { this.refs.weaError1.showError(); return; } this.setState({ loading: true }); saveDeclare({ salaryMonth: moment(date).startOf("month").format("YYYY-MM-DD"), taxAgentId, description }).then((data) => { this.setState({ loading: false }); this.props.onCancel(); message.destroy(); message.loading(getLabel(111, "正在生成中..."), 0); this.timer = setInterval(async () => { const { status: resStatus, data: result } = await this.taxdeclarationGetRate(data); const { status: rateStatus, finish, msg } = result; if (resStatus && rateStatus) { if (finish) { message.destroy(); clearInterval(this.timer); message.success(msg || getLabel(22619, "保存成功!")); this.props.onGenerate(); } } else { clearInterval(this.timer); message.destroy(); message.warning(msg || getLabel(111, "生成申报表失败!")); this.props.onGenerate(); } }, 1000); }).catch(() => { message.destroy(); clearInterval(this.timer); this.setState({ loading: false }); }); }; taxdeclarationGetRate = (index) => { return taxdeclarationGetRate({ index }); }; render() { const { taxAgentStore: { taxAgentAdminOption } } = this.props; const { loading } = this.state; return ( this.props.onCancel()} initLoadCss className="generateWapper" title={ 申报 } buttons={ [] }>
{ if (_.isEmpty(value)) this.refs.weaError.showError(); this.setState({ date: value }); }} /> { if (_.isEmpty(taxAgentId)) this.refs.weaError1.showError(); this.setState({ taxAgentId }); }} /> this.setState({ description })} />
); } }