import React from "react"; import { WeaSteps } from "ecCom"; import { message, Modal, Upload } from "antd"; import { inject, observer } from "mobx-react"; import { toJS } from "mobx"; import ModalStep1 from "./modalStep1"; import ModalStep2 from "./modalStep2"; import ModalStep3 from "./modalStep3"; const Dragger = Upload.Dragger; const Step = WeaSteps.Step; @inject("taxAgentStore") @observer export default class ImportModal extends React.Component { constructor(props) { super(props); this.state = { fileId: "" }; this.props.init && this.props.init(); } componentWillMount() { // 初始化渲染页面 // const { taxAgentStore: {fetchTaxAgentOption} } = this.props; // fetchTaxAgentOption(); } nextStep() { const { step } = this.props; this.props.setStep(step + 1); } preStep() { const { step } = this.props; this.props.setStep(step - 1); } validateDate() { // const { params } = this.props; let flag = true; try { // params && Object.keys(params).forEach((key) => { // if (!params[key] || params[key] == "") { // message.warning("请完善导入选项"); // throw new Error("请完善导入选项"); // } // }); } catch (e) { flag = false; } return flag; } handleStep1Next() { if (!this.validateDate()) { return; } if (this.state.fileId) { this.props.setStep(1); } else { message.warning("请上传文件"); } } handlePreviewDate() { const { fileId } = this.state; const { params, isStandingBook } = this.props; if(!isStandingBook){ this.props.previewImport({ ...params, imageId: fileId }); }else{ this.props.previewImport({ imageId: fileId }); } } hanleImportData() { const { fileId } = this.state; const { params, isStandingBook } = this.props; if(!isStandingBook){ this.props.importFile({ ...params, imageId: fileId }); }else{ this.props.importFile({ imageId: String(fileId) }); } } render() { const { step, slideDataSource, isInit, isStandingBook } = this.props; return (
{ this.props.step == 0 && ( { this.setState({ fileId }); }} onStep1Next={() => { this.handleStep1Next(); }}/>) } { this.props.step == 1 && ( this.handlePreviewDate()} dataSource={slideDataSource} columns={this.props.columns} onStep2Next={() => { this.nextStep(); this.hanleImportData(); }} onStep2Pre={() => { this.preStep(); }}/>) } { this.props.step == 2 && ( this.hanleImportData()} importResult={toJS(this.props.importResult)} onFinish={() => { this.props.onFinish(); }}/>) }
); } }