2022-08-03 17:54:47 +08:00
|
|
|
|
import React from "react";
|
2023-04-14 13:29:21 +08:00
|
|
|
|
import { WeaCheckbox, WeaLocaleProvider, WeaTools } from "ecCom";
|
2022-08-03 17:54:47 +08:00
|
|
|
|
import { inject, observer } from "mobx-react";
|
2022-10-17 10:03:01 +08:00
|
|
|
|
import { Icon, message, Upload } from "antd";
|
2022-03-04 15:23:07 +08:00
|
|
|
|
|
|
|
|
|
|
const Dragger = Upload.Dragger;
|
2023-04-14 13:29:21 +08:00
|
|
|
|
const getLabel = WeaLocaleProvider.getLabel;
|
|
|
|
|
|
;
|
2022-03-04 15:23:07 +08:00
|
|
|
|
|
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 {
|
2022-08-03 17:54:47 +08:00
|
|
|
|
constructor(props) {
|
|
|
|
|
|
super(props);
|
|
|
|
|
|
this.state = {
|
|
|
|
|
|
datetime: "",
|
|
|
|
|
|
taxAgentId: "",
|
|
|
|
|
|
hasData: "0",
|
2023-04-14 13:29:21 +08:00
|
|
|
|
fileList: WeaTools.ls.getJSONObj("fileList") || []
|
2022-08-03 17:54:47 +08:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
});
|
2022-03-08 16:45:33 +08:00
|
|
|
|
|
2022-08-03 17:54:47 +08:00
|
|
|
|
if (fileList && fileList.length > 0 && fileList[0].response && fileList[0].response.status === 1) {
|
|
|
|
|
|
this.props.onFileIdChange(fileList[0].response.data.fileid);
|
2022-10-17 10:03:01 +08:00
|
|
|
|
} else if (fileList && fileList.length === 0) {
|
|
|
|
|
|
this.props.onFileIdChange("");
|
2022-03-08 16:45:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-14 13:29:21 +08:00
|
|
|
|
this.setState({ fileList }, () => localStorage.setItem("fileList", JSON.stringify(this.state.fileList)));
|
2022-08-03 17:54:47 +08:00
|
|
|
|
}
|
2022-06-16 20:58:54 +08:00
|
|
|
|
|
2022-08-03 17:54:47 +08:00
|
|
|
|
render() {
|
|
|
|
|
|
const { datetime, taxAgentId, hasData } = this.state;
|
2022-09-29 15:45:23 +08:00
|
|
|
|
const { taxAgentStore: { taxAgentOption }, isInit, needimportSelected, params } = this.props;
|
2022-08-03 17:54:47 +08:00
|
|
|
|
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 (
|
2022-10-17 10:03:01 +08:00
|
|
|
|
<div style={{ display: "flex", flexFlow: "column" }}>
|
2022-09-13 16:39:15 +08:00
|
|
|
|
<div>
|
2022-08-03 17:54:47 +08:00
|
|
|
|
{
|
|
|
|
|
|
this.props.formComponent && <div className="stepInformItem">
|
|
|
|
|
|
<div className="stepInformTitle" style={{ margin: "10px 0 10px 0" }}>
|
2023-06-08 18:13:37 +08:00
|
|
|
|
{getLabel(543201, "导入选项")}
|
2022-08-03 17:54:47 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div className="formWrapper" style={{ border: "1px solid #eee", borderRadiu: "5px", padding: "10px" }}>
|
|
|
|
|
|
{this.props.formComponent}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2022-06-16 20:58:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-08-03 17:54:47 +08:00
|
|
|
|
<div className="stepInformItem">
|
|
|
|
|
|
<div className="stepInformTitle" style={{ margin: "10px 0 10px 0" }}>
|
2023-06-08 18:13:37 +08:00
|
|
|
|
{getLabel(543202, "导入Excel")}
|
2022-08-03 17:54:47 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<Dragger {...dragger} fileList={this.state.fileList}>
|
|
|
|
|
|
<div style={{ padding: "25px 0" }}>
|
|
|
|
|
|
<p className="ant-upload-drag-icon">
|
|
|
|
|
|
<Icon type="inbox"/>
|
|
|
|
|
|
</p>
|
2023-06-08 18:13:37 +08:00
|
|
|
|
<p className="ant-upload-text">{getLabel(543203, "点击或将文件拖拽到此区域上传")}</p>
|
2023-04-14 13:29:21 +08:00
|
|
|
|
<p
|
2023-06-08 18:13:37 +08:00
|
|
|
|
className="ant-upload-hint">{getLabel(543204, "支持单个或批量上传,严禁上传公司内部资料及其他违禁文件")}</p>
|
2022-08-03 17:54:47 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</Dragger>
|
|
|
|
|
|
</div>
|
2022-07-25 18:02:36 +08:00
|
|
|
|
|
2022-08-03 17:54:47 +08:00
|
|
|
|
</div>
|
2022-06-16 20:58:54 +08:00
|
|
|
|
|
2022-08-03 17:54:47 +08:00
|
|
|
|
<div className="stepInformItem">
|
|
|
|
|
|
<div className="stepInformTitle" style={{ margin: "10px 0 10px 0" }}>
|
2023-06-08 18:13:37 +08:00
|
|
|
|
{getLabel(27577, "操作步骤")}
|
2022-03-04 15:23:07 +08:00
|
|
|
|
</div>
|
2022-08-03 17:54:47 +08:00
|
|
|
|
|
|
|
|
|
|
<div style={{ lineHeight: "30px" }}>
|
2023-06-08 18:13:37 +08:00
|
|
|
|
<p>{`1. ${getLabel(30907, "第一步")},${getLabel(543205, "请选择导出的Excel文件或")}`}
|
2022-08-03 17:54:47 +08:00
|
|
|
|
{
|
|
|
|
|
|
(typeof this.props.templateLink) == "string" ?
|
2022-10-17 10:03:01 +08:00
|
|
|
|
<a href="javascript:void(0);" onClick={() => {
|
|
|
|
|
|
let url = `${this.props.templateLink}${downloadExtra}`;
|
|
|
|
|
|
if (needimportSelected) {
|
2022-09-29 15:45:23 +08:00
|
|
|
|
try {
|
|
|
|
|
|
params && Object.keys(params).forEach((key) => {
|
|
|
|
|
|
if (!params[key] || params[key] == "") {
|
2023-06-08 18:13:37 +08:00
|
|
|
|
message.warning(`${getLabel(543199, "请完善导入选项")}, ${getLabel(543206, "再下载")}!`);
|
|
|
|
|
|
throw new Error(`${getLabel(543199, "请完善导入选项")}, ${getLabel(543206, "再下载")}!`);
|
2022-10-17 10:03:01 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
if (url.indexOf("?") > 0) {
|
|
|
|
|
|
url = `${url}&${key}=${params[key]}`;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
url = `${url}?${key}=${params[key]}`;
|
2022-09-29 15:45:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-10-17 10:03:01 +08:00
|
|
|
|
window.open(url, "_blank");
|
2023-06-08 18:13:37 +08:00
|
|
|
|
}}>{getLabel(543207, "点击这里下载模板")}</a>
|
2022-08-03 17:54:47 +08:00
|
|
|
|
:
|
|
|
|
|
|
<a onClick={() => {
|
|
|
|
|
|
this.props.templateLink(hasData === "1" ? `true` : `false`);
|
2023-06-08 18:13:37 +08:00
|
|
|
|
}}>{getLabel(543207, "点击这里下载模板")}</a>
|
2022-08-03 17:54:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
{this.props.headerSetCompoent && this.props.headerSetCompoent};
|
|
|
|
|
|
{
|
|
|
|
|
|
this.props.isInit &&
|
|
|
|
|
|
<WeaCheckbox
|
|
|
|
|
|
value={hasData}
|
2023-06-08 18:13:37 +08:00
|
|
|
|
content={getLabel(543208, "导出现有数据")}
|
|
|
|
|
|
helpfulTip={`${getLabel(558, "提示")}:${getLabel(543210, "建议先导出现有最新数据")},${getLabel(543209, "修改后再导入")}`}
|
2022-08-03 17:54:47 +08:00
|
|
|
|
style={{ marginLeft: 10 }}
|
|
|
|
|
|
onChange={(hasData) => this.setState({ hasData })}
|
|
|
|
|
|
/>
|
|
|
|
|
|
}
|
|
|
|
|
|
</p>
|
2023-06-08 18:13:37 +08:00
|
|
|
|
<p>{`2. ${getLabel(543211, "第二步")},${getLabel(543212, "请一定要确定Excel文档中的格式是模板中的格式")},${getLabel(543213, "没有被修改掉")};`}</p>
|
|
|
|
|
|
<p>{`3. ${getLabel(543216, "第三步")},${getLabel(543215, "选择填写好的Excel文档")},${getLabel(543214, "点击“下一步”按钮进行数据预览")};`}</p>
|
2023-04-14 13:29:21 +08:00
|
|
|
|
<p>
|
2023-06-09 11:38:20 +08:00
|
|
|
|
{`4. ${getLabel(543217, "第四步")},${getLabel(543218, "如果以上步骤和Excel文档正确的话")},${getLabel(543219, "导入成功会有提示")},${getLabel(543220, "数据会被正确导入")}。${getLabel(543221, "如果有问题")},${getLabel(543222, "则会提示Excel文档的错误之处")}。`}
|
2023-04-14 13:29:21 +08:00
|
|
|
|
</p>
|
2022-08-03 17:54:47 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div className="stepInformItem">
|
|
|
|
|
|
<div className="stepInformTitle" style={{ margin: "10px 0 10px 0" }}>
|
2023-06-08 18:13:37 +08:00
|
|
|
|
{getLabel(543223, "Excel文件说明")}
|
2022-08-03 17:54:47 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div style={{ lineHeight: "30px" }}>
|
2023-06-08 18:13:37 +08:00
|
|
|
|
{`1. ${getLabel(543224, "后缀名为xls或者xlsx")};`}<br/>
|
|
|
|
|
|
{`2. ${getLabel(543225, "数据请勿放在合并的单元格中")};`}<br/>
|
2022-09-08 17:04:36 +08:00
|
|
|
|
{
|
|
|
|
|
|
this.props.isStandingBook &&
|
2023-06-08 18:13:37 +08:00
|
|
|
|
<span>{`3. ${getLabel(543226, "账单月份格式必须为")}:YYYY-MM;`}</span>
|
2022-09-08 17:04:36 +08:00
|
|
|
|
}
|
2022-08-03 17:54:47 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2022-07-25 18:02:36 +08:00
|
|
|
|
}
|