import React from "react"; import { WeaCheckbox,WeaTools } from "ecCom"; import { inject, observer } from "mobx-react"; import { Icon, message, Upload } from "antd"; const Dragger = Upload.Dragger; @inject("taxAgentStore") @observer export default class ModalStep1 extends React.Component { constructor(props) { super(props); this.state = { datetime: "", taxAgentId: "", hasData: "0", fileList: WeaTools.ls.getJSONObj('fileList') || [] }; } componentWillMount() { // 初始化渲染页面 // const { taxAgentStore: {fetchTaxAgentOption} } = this.props; // fetchTaxAgentOption(); } 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); } else if (fileList && fileList.length === 0) { this.props.onFileIdChange(""); } this.setState({ fileList },()=>localStorage.setItem("fileList", JSON.stringify(this.state.fileList))); } render() { const { datetime, taxAgentId, hasData } = this.state; const { taxAgentStore: { taxAgentOption }, isInit, needimportSelected, params } = this.props; let downloadExtra = ""; if (isInit) { downloadExtra = hasData === "1" ? `&hasData=true` : `&hasData=false`; } const dragger = { accept: ".xlsx", name: "file", multiple: false, action: "/api/doc/upload/uploadFile", //上传地址 onChange: (info) => { this.handleChange(info); } }; return (
点击或将文件拖拽到此区域上传
支持单个或批量上传,严禁上传公司内部资料及其他违禁文件
1. 第一步,请选择导出的Excel文件或
{
(typeof this.props.templateLink) == "string" ?
{
let url = `${this.props.templateLink}${downloadExtra}`;
if (needimportSelected) {
try {
params && Object.keys(params).forEach((key) => {
if (!params[key] || params[key] == "") {
message.warning("请完善导入选项,再下载!");
throw new Error("请完善导入选项,再下载!");
} else {
if (url.indexOf("?") > 0) {
url = `${url}&${key}=${params[key]}`;
} else {
url = `${url}?${key}=${params[key]}`;
}
}
});
} catch (e) {
return;
}
}
window.open(url, "_blank");
}}>点击这里下载模板
:
{
this.props.templateLink(hasData === "1" ? `true` : `false`);
}}>点击这里下载模板
}
{this.props.headerSetCompoent && this.props.headerSetCompoent};
{
this.props.isInit &&
2. 第二步,请一定要确定Excel文档中的格式是模板中的格式,没有被修改掉;
3. 第三步,选择填写好的Excel文档,点击“下一步”按钮进行数据预览;
4. 第四步,如果以上步骤和Excel文档正确的话,数据会被正确导入,导入成功会有提示。如果有问题,则会提示Excel文档的错误之处。