import React from "react"; import { WeaCheckbox, WeaLocaleProvider, WeaTools } from "ecCom"; import { inject, observer } from "mobx-react"; import { Icon, message, Upload } from "antd"; const Dragger = Upload.Dragger; const getLabel = WeaLocaleProvider.getLabel; ; @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 (
{ this.props.formComponent &&
{getLabel(543201, "导入选项")}
{this.props.formComponent}
}
{getLabel(543202, "导入Excel")}

{getLabel(543203, "点击或将文件拖拽到此区域上传")}

{getLabel(543204, "支持单个或批量上传,严禁上传公司内部资料及其他违禁文件")}

{getLabel(27577, "操作步骤")}

{`1. ${getLabel(30907, "第一步")},${getLabel(543205, "请选择导出的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(`${getLabel(543199, "请完善导入选项")}, ${getLabel(543206, "再下载")}!`); throw new Error(`${getLabel(543199, "请完善导入选项")}, ${getLabel(543206, "再下载")}!`); } else { if (url.indexOf("?") > 0) { url = `${url}&${key}=${params[key]}`; } else { url = `${url}?${key}=${params[key]}`; } } }); } catch (e) { return; } } window.open(url, "_blank"); }}>{getLabel(543207, "点击这里下载模板")} : { this.props.templateLink(hasData === "1" ? `true` : `false`); }}>{getLabel(543207, "点击这里下载模板")} } {this.props.headerSetCompoent && this.props.headerSetCompoent}; { this.props.isInit && this.setState({ hasData })} /> }

{`2. ${getLabel(543211, "第二步")},${getLabel(543212, "请一定要确定Excel文档中的格式是模板中的格式")},${getLabel(543213, "没有被修改掉")};`}

{`3. ${getLabel(543216, "第三步")},${getLabel(543215, "选择填写好的Excel文档")},${getLabel(543214, "点击“下一步”按钮进行数据预览")};`}

{`4. ${getLabel(543217, "第四步")},${getLabel(543218, "如果以上步骤和Excel文档正确的话")},${getLabel(543219, "导入成功会有提示")},${getLabel(543220, "数据会被正确导入")}。${getLabel(543221, "如果有问题")},${getLabel(543222, "则会提示Excel文档的错误之处")}。`}

{getLabel(543223, "Excel文件说明")}
{`1. ${getLabel(543224, "后缀名为xls或者xlsx")};`}
{`2. ${getLabel(543225, "数据请勿放在合并的单元格中")};`}
{ this.props.isStandingBook && {`3. ${getLabel(543226, "账单月份格式必须为")}:YYYY-MM;`} }
); } }