salary-management-front/pc4mobx/hrmSalary/components/importModal/index.js

115 lines
3.4 KiB
JavaScript
Raw Normal View History

2022-03-04 15:23:07 +08:00
import React from 'react';
2022-03-10 09:40:31 +08:00
import { WeaSteps, WeaDatePicker, WeaInput, WeaSelect } from 'ecCom';
2022-05-30 17:30:53 +08:00
import { Upload, Icon, Modal, Row, Col, Button, message } from "antd";
2022-03-10 09:40:31 +08:00
import { inject, observer } from 'mobx-react';
2022-03-10 16:28:49 +08:00
import { toJS } from 'mobx';
2022-03-04 15:23:07 +08:00
import ModalStep1 from './modalStep1'
2022-03-07 19:33:56 +08:00
import ModalStep2 from './modalStep2'
import ModalStep3 from './modalStep3'
2022-03-04 15:23:07 +08:00
const Dragger = Upload.Dragger;
const Step = WeaSteps.Step;
2022-03-11 16:13:36 +08:00
@inject("taxAgentStore")
2022-03-10 09:40:31 +08:00
@observer
2022-03-04 15:23:07 +08:00
export default class ImportModal extends React.Component {
constructor(props) {
super(props)
this.state = {
2022-03-10 09:40:31 +08:00
fileId: ""
2022-03-04 15:23:07 +08:00
}
2022-05-12 17:04:33 +08:00
this.props.init && this.props.init()
2022-03-04 15:23:07 +08:00
}
2022-03-10 09:40:31 +08:00
componentWillMount() { // 初始化渲染页面
const { taxAgentStore: {fetchTaxAgentOption} } = this.props;
fetchTaxAgentOption();
}
2022-03-07 19:33:56 +08:00
nextStep() {
2022-03-11 16:13:36 +08:00
const { step } = this.props;
this.props.setStep(step + 1)
2022-03-07 19:33:56 +08:00
}
preStep() {
2022-03-11 16:13:36 +08:00
const { step } = this.props;
this.props.setStep(step - 1);
2022-03-07 19:33:56 +08:00
}
2022-03-10 09:40:31 +08:00
2022-03-11 16:13:36 +08:00
2022-03-10 09:40:31 +08:00
handleStep1Next() {
2022-05-30 17:30:53 +08:00
if(this.state.fileId) {
this.props.setStep(1)
} else {
message.warning("请上传文件")
}
2022-03-10 16:28:49 +08:00
}
handlePreviewDate() {
2022-03-11 16:13:36 +08:00
const { fileId } = this.state;
const { params } = this.props;
this.props.previewImport({
...params,
imageId: fileId
2022-03-10 16:28:49 +08:00
})
}
hanleImportData() {
2022-03-11 16:13:36 +08:00
const { fileId } = this.state;
const { params } = this.props;
this.props.importFile({
...params,
2022-03-10 09:40:31 +08:00
imageId: fileId,
2022-03-10 16:28:49 +08:00
})
2022-03-10 09:40:31 +08:00
}
2022-03-10 16:28:49 +08:00
2022-03-04 15:23:07 +08:00
render() {
2022-03-11 16:13:36 +08:00
const { step, slideDataSource } = this.props;
2022-03-07 19:33:56 +08:00
return (
<Modal title="数据导入" visible={this.props.visiable}
2022-03-04 15:23:07 +08:00
onCancel={this.props.onCancel}
width={850} className="cumDeductModal"
2022-03-07 19:33:56 +08:00
footer={null}
2022-03-04 15:23:07 +08:00
>
<div className="stepWrapper">
2022-03-10 09:40:31 +08:00
<WeaSteps current={step}>
2022-03-04 15:23:07 +08:00
<Step description="上传Excel" />
<Step description="数据预览" />
<Step description="导入数据" />
</WeaSteps>
</div>
{
2022-03-11 16:13:36 +08:00
this.props.step == 0 && (<ModalStep1
templateLink={this.props.templateLink}
2022-03-14 17:07:26 +08:00
headerSetCompoent={this.props.headerSetCompoent}
2022-04-27 11:14:20 +08:00
formComponent={this.props.renderFormComponent && this.props.renderFormComponent()}
2022-03-10 09:40:31 +08:00
onFileIdChange={(fileId) => {this.setState({fileId})}}
onStep1Next={() => {
this.handleStep1Next();
}}/>)
2022-03-07 19:33:56 +08:00
}
{
2022-03-11 16:13:36 +08:00
this.props.step == 1 && (<ModalStep2
2022-03-10 16:28:49 +08:00
onPreviewDate={() => this.handlePreviewDate()}
dataSource={slideDataSource}
2022-03-11 16:13:36 +08:00
columns={this.props.columns}
2022-04-21 14:59:34 +08:00
onStep2Next={() => {
this.nextStep();
this.hanleImportData()
}} onStep2Pre={() => {this.preStep()}}/>)
2022-03-07 19:33:56 +08:00
}
{
2022-03-11 16:13:36 +08:00
this.props.step == 2 && (<ModalStep3
2022-04-21 14:59:34 +08:00
// onImportData={() => this.hanleImportData()}
2022-03-11 16:13:36 +08:00
importResult={toJS(this.props.importResult)}
onFinish={() => {this.props.onFinish()}}/>)
2022-03-04 15:23:07 +08:00
}
2022-03-07 19:33:56 +08:00
</Modal>
)
2022-03-04 15:23:07 +08:00
}
}