From ff3dd0ea604a5d2d0124afeaeca689fdd325dd5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Mon, 25 Sep 2023 15:35:11 +0800 Subject: [PATCH] =?UTF-8?q?feature/2.9.42309.01-=E8=96=AA=E8=B5=84?= =?UTF-8?q?=E6=A0=B8=E7=AE=97=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=94=B9=E9=80=A0=EF=BC=88=E9=A1=B5=E9=9D=A2=E7=BC=96?= =?UTF-8?q?=E8=BE=91=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../importDialog/components/impStep1.js | 11 +- .../importDialog/components/impStep2.js | 4 +- .../components/salaryEditCalcImport/index.js | 129 ++++++++++++++++-- .../hrmSalary/pages/calculate/doCalc/index.js | 10 +- 4 files changed, 132 insertions(+), 22 deletions(-) diff --git a/pc4mobx/hrmSalary/components/importDialog/components/impStep1.js b/pc4mobx/hrmSalary/components/importDialog/components/impStep1.js index 6ab09b3e..209125fb 100644 --- a/pc4mobx/hrmSalary/components/importDialog/components/impStep1.js +++ b/pc4mobx/hrmSalary/components/importDialog/components/impStep1.js @@ -61,8 +61,15 @@ class ImpStep1 extends Component {
{`1. ${getLabel(30907, "第一步")},${getLabel(543205, "请选择导出的Excel文件或")}`} - {getLabel(543207, "点击这里下载模板")} + { + typeof this.props.link === "string" ? + {getLabel(543207, "点击这里下载模板")} : + {getLabel(543207, "点击这里下载模板")} + } + {this.props.exportDataDom}
{`2. ${getLabel(543211, "第二步")},${getLabel(543212, "请一定要确定Excel文档中的格式是模板中的格式")},${getLabel(543213, "没有被修改掉")};`}
diff --git a/pc4mobx/hrmSalary/components/importDialog/components/impStep2.js b/pc4mobx/hrmSalary/components/importDialog/components/impStep2.js index 8a7373d4..71c6e099 100644 --- a/pc4mobx/hrmSalary/components/importDialog/components/impStep2.js +++ b/pc4mobx/hrmSalary/components/importDialog/components/impStep2.js @@ -21,8 +21,8 @@ class ImpStep2 extends Component { } init = () => { - const { previewUrl, imageId } = this.props; - const payload = { imageId }; + const { previewUrl, imageId, extraPreview = {} } = this.props; + const payload = { imageId, ...extraPreview }; this.setState({ loading: true }); postFetch(previewUrl, payload).then(({ status, data }) => { this.setState({ loading: false }); diff --git a/pc4mobx/hrmSalary/pages/calculate/doCalc/components/salaryEditCalcImport/index.js b/pc4mobx/hrmSalary/pages/calculate/doCalc/components/salaryEditCalcImport/index.js index 44fa954e..c41f294f 100644 --- a/pc4mobx/hrmSalary/pages/calculate/doCalc/components/salaryEditCalcImport/index.js +++ b/pc4mobx/hrmSalary/pages/calculate/doCalc/components/salaryEditCalcImport/index.js @@ -5,9 +5,12 @@ * Date: 2023/9/18 */ import React, { Component } from "react"; -import { WeaLocaleProvider } from "ecCom"; -import { Badge, Button } from "antd"; +import { WeaCheckbox, WeaLocaleProvider } from "ecCom"; +import { Badge, Button, message } from "antd"; import ImportDialog from "../../../../../components/importDialog"; +import { cacheImportField, getImportField, importAcctResult } from "../../../../../apis/calculate"; +import AddHeaderFieldsModal from "../../../../calculateDetail/acctResult/importModal/addHeaderFieldsModal"; +import { convertToUrlString, getURLParameters } from "../../../../../util/url"; const getLabel = WeaLocaleProvider.getLabel; @@ -16,24 +19,85 @@ class Index extends Component { super(props); this.state = { salaryItemIds: "", //选择的导入表单项 + exportTempUrl: "", //导出模板url + headerFieldsDialog: { visible: false, itemsByGroup: [], selectItems: "" }, importDialog: { visible: false, title: "", nextloading: false, - link: "", importResult: {}, imageId: "" + link: null, importResult: {}, imageId: "", + previewUrl: "/api/bs/hrmsalary/salaryacct/acctresult/preview", + extraPreview: { salaryAcctRecordId: "", salaryItemIds: "" } } }; } - componentWillReceiveProps(nextProps, nextContext) { + async componentWillReceiveProps(nextProps, nextContext) { if (nextProps.visible !== this.props.visible) { + if (nextProps.salaryAcctRecordId && nextProps.visible) { + const { data } = await getImportField({ salaryAcctRecordId: nextProps.salaryAcctRecordId }); + const { checkItems, itemsByGroup } = data; + const payload = { + exportData: false, salaryAcctRecordId: nextProps.salaryAcctRecordId, + salaryItemIds: checkItems.join(",") + }; + this.setState({ + exportTempUrl: `/api/bs/hrmsalary/salaryacct/acctresult/importtemplate/export?${convertToUrlString(payload)}`, + importDialog: { + ...this.state.importDialog, + extraPreview: { salaryAcctRecordId: nextProps.salaryAcctRecordId, salaryItemIds: checkItems.join(",") } + }, + headerFieldsDialog: { + ...this.state.headerFieldsDialog, + selectItems: checkItems.join(","), + itemsByGroup: _.map(itemsByGroup, item => { + return { + ...item, + salaryItems: _.map(item.salaryItems, it => ({ + ...it, + checked: false + })) + }; + }) + } + }); + } this.setState({ importDialog: { - ...this.state.importDialog, + ...this.state.importDialog, link: this.handleExportTemp, visible: nextProps.visible, title: nextProps.title } }); } } + handleImport = (payload) => { + const { headerFieldsDialog: { selectItems: salaryItemIds }, importDialog } = this.state; + const { salaryAcctRecordId } = this.props; + this.setState({ importDialog: { ...importDialog, nextloading: true } }); + importAcctResult({ ...payload, salaryItemIds, salaryAcctRecordId }) + .then(({ data, status }) => { + this.setState({ importDialog: { ...importDialog, nextloading: false } }); + if (status) { + this.setState({ + importDialog: { ...importDialog, ...payload, importResult: data } + }); + } + }).catch(() => this.setState({ importDialog: { ...importDialog, nextloading: false } })); + }; + handleExportTemp = () => { + const { headerFieldsDialog: { selectItems }, exportTempUrl } = this.state; + if (!selectItems) { + message.error(getLabel(111, "请选择表头字段")); + } else { + window.open(exportTempUrl, "_blank"); + } + }; + handleSelectedField = () => { + this.setState({ + headerFieldsDialog: { + ...this.state.headerFieldsDialog, visible: true + } + }); + }; /* * Author: 黎永顺 * Description:表单选项 @@ -41,25 +105,60 @@ class Index extends Component { * Date: 2023/9/18 */ renderFormComponent = () => { + const { selectItems } = this.state.headerFieldsDialog; return