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

155 lines
6.7 KiB
JavaScript
Raw Normal View History

2022-03-04 15:23:07 +08:00
import React from 'react'
import { WeaSteps, WeaDatePicker, WeaInput, WeaSelect, message, WeaCheckbox } from 'ecCom';
2022-03-08 16:45:33 +08:00
import { inject, observer } from 'mobx-react';
2022-03-04 15:23:07 +08:00
import { Upload, Icon, Row, Col, Button } from "antd";
2022-03-07 19:33:56 +08:00
import uploadImg from './upload.svg'
2022-03-04 15:23:07 +08:00
const Dragger = Upload.Dragger;
2022-03-08 16:45:33 +08:00
@inject("taxAgentStore")
@observer
2022-03-04 15:23:07 +08:00
export default class ModalStep1 extends React.Component {
constructor(props) {
super(props)
this.state = {
datetime: "",
taxAgentId: "",
2022-06-16 20:58:54 +08:00
hasData: "0",
fileList: []
2022-03-04 15:23:07 +08:00
}
}
2022-03-08 16:45:33 +08:00
componentWillMount() { // 初始化渲染页面
const { taxAgentStore: {fetchTaxAgentOption} } = this.props;
fetchTaxAgentOption();
}
2022-06-16 20:58:54 +08:00
handleChange(info) {
let fileList = info.fileList;
// 1. 上传列表数量的限制
// 只显示最近上传的一个,旧的会被新的顶掉
fileList = fileList.slice(-1);
// 2. 读取远程路径并显示链接
fileList = fileList.map((file) => {
if (file.response) {
// 组件会将 file.url 作为链接进行展示
file.url = file.response.url;
}
return file;
});
// 3. 按照服务器返回信息筛选成功上传的文件
fileList = fileList.filter((file) => {
if (file.response) {
return file.response.status === 1;
}
return true;
});
if(fileList && fileList.length > 0 && fileList[0].response && fileList[0].response.status === 1) {
this.props.onFileIdChange(fileList[0].response.data.fileid)
}
this.setState({ fileList });
}
2022-03-04 15:23:07 +08:00
render() {
const { datetime, taxAgentId, hasData } = this.state
2022-06-14 11:32:35 +08:00
const { taxAgentStore: {taxAgentOption}, isInit } = this.props;
let downloadExtra= '';
if(isInit){
downloadExtra= hasData === '1' ? `&hasData=true` : `&hasData=false`;
}
2022-03-10 09:40:31 +08:00
const dragger = {
name: 'file',
multiple: false,
2022-04-18 09:31:06 +08:00
action: "/api/doc/upload/uploadFile", //上传地址
2022-03-10 09:40:31 +08:00
onChange: (info) => {
2022-06-16 20:58:54 +08:00
this.handleChange(info)
2022-03-10 09:40:31 +08:00
},
};
2022-03-04 15:23:07 +08:00
return (
2022-03-07 19:33:56 +08:00
<div style={{ height: "550px", display: "flex", flexFlow: "column"}}>
<div style={{ flex: "1", overflow: "scroll" }}>
2022-04-01 10:24:55 +08:00
{
this.props.formComponent && <div className="stepInformItem">
<div className="stepInformTitle" style={{ margin: "10px 0 10px 0" }}>
导入选项
</div>
<div className="formWrapper" style={{ border: "1px solid #eee", borderRadiu: "5px", padding: "10px" }}>
{this.props.formComponent}
</div>
2022-03-07 19:33:56 +08:00
</div>
2022-04-01 10:24:55 +08:00
}
2022-03-04 15:23:07 +08:00
2022-03-07 19:33:56 +08:00
<div className="stepInformItem">
<div className="stepInformTitle" style={{ margin: "10px 0 10px 0" }}>
导入excel
2022-03-04 15:23:07 +08:00
</div>
2022-03-07 19:33:56 +08:00
<div>
2022-06-16 20:58:54 +08:00
<Dragger {...dragger} fileList={this.state.fileList}>
2022-03-07 19:33:56 +08:00
<div style={{ padding: '25px 0' }}>
<p className="ant-upload-drag-icon">
<Icon type="inbox" />
</p>
<p className="ant-upload-text">点击或将文件拖拽到此区域上传</p>
<p className="ant-upload-hint">支持单个或批量上传严禁上传公司内部资料及其他违禁文件</p>
</div>
</Dragger>
</div>
2022-03-04 15:23:07 +08:00
</div>
2022-03-07 19:33:56 +08:00
<div className="stepInformItem">
<div className="stepInformTitle" style={{ margin: "10px 0 10px 0" }}>
操作步骤
</div>
2022-03-04 15:23:07 +08:00
2022-03-07 19:33:56 +08:00
<div style={{ lineHeight: "30px" }}>
<p>1. 第一步请选择导出的Excel文件或
2022-04-25 14:32:51 +08:00
{
(typeof this.props.templateLink) == "string" ?
2022-06-14 11:32:35 +08:00
<a href={`${this.props.templateLink}${downloadExtra}`}>点击这里下载模板</a>
2022-04-25 14:32:51 +08:00
:
<a onClick={() => {this.props.templateLink()}}>点击这里下载模板</a>
}
{this.props.headerSetCompoent && this.props.headerSetCompoent };
2022-06-14 11:18:37 +08:00
{
this.props.isInit &&
<WeaCheckbox
value={hasData}
content="导出现有数据"
helpfulTip="提示:建议先导出现有最新数据,修改后再导入"
style={{ marginLeft: 10 }}
onChange={(hasData)=> this.setState({hasData})}
/>
}
2022-03-14 17:07:26 +08:00
</p>
2022-03-07 19:33:56 +08:00
<p>2. 第二步请一定要确定Excel文档中的格式是模板中的格式没有被修改掉</p>
<p>3. 第三步选择填写好的Excel文档点击下一步按钮进行数据预览</p>
<p>4. 第四步如果以上步骤和Excel文档正确的话数据会被正确导入导入成功会有提示如果有问题则会提示Excel文档的错误之处</p>
</div>
2022-03-04 15:23:07 +08:00
</div>
2022-03-07 19:33:56 +08:00
<div className="stepInformItem">
<div className="stepInformTitle" style={{ margin: "10px 0 10px 0" }}>
Excel文件说明
</div>
<div style={{ lineHeight: "30px" }}>
1. 后缀名为xls或者xlsx<br />
2. 数据请勿放在合并的单元格中<br />
</div>
2022-03-04 15:23:07 +08:00
</div>
2022-03-07 19:33:56 +08:00
</div>
<div className="footerBtnWrapper" style={{ overflow: "hidden", height: "30px" }}>
<Button type="primary" style={{ float: "right" }} onClick={this.props.onStep1Next}>下一步</Button>
2022-03-04 15:23:07 +08:00
</div>
</div>
)
}
}