72 lines
2.4 KiB
JavaScript
72 lines
2.4 KiB
JavaScript
/*
|
|
* Author: 黎永顺
|
|
* name: 薪資核算-线下对比导入
|
|
* Description:
|
|
* Date: 2023/9/27
|
|
*/
|
|
import React, { Component } from "react";
|
|
import { WeaLocaleProvider } from "ecCom";
|
|
import ImportDialog from "../../../../components/importDialog";
|
|
import { importComparisonExcelAcctResult } from "../../../../apis/calculate";
|
|
|
|
const getLabel = WeaLocaleProvider.getLabel;
|
|
|
|
class SalaryCalcOcImport extends Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
importDialog: {
|
|
visible: false, title: "", nextloading: false, importResult: {}, imageId: "",
|
|
link: "/api/bs/hrmsalary/salaryacct/comparisonresult/importtemplate/export?salaryAcctRecordId=",
|
|
previewUrl: "/api/bs/hrmsalary/salaryacct/comparisonresult/preview",
|
|
extraPreview: { salaryAcctRecordId: "" }
|
|
}
|
|
};
|
|
}
|
|
|
|
componentWillReceiveProps(nextProps, nextContext) {
|
|
if (nextProps.visible !== this.props.visible) {
|
|
const { importDialog } = this.state;
|
|
this.setState({
|
|
importDialog: {
|
|
...this.state.importDialog,
|
|
link: `${importDialog.link}${nextProps.salaryAcctRecordId}`,
|
|
visible: nextProps.visible, importResult: {},
|
|
title: nextProps.title, imageId: "",
|
|
extraPreview: { salaryAcctRecordId: nextProps.salaryAcctRecordId }
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
handleImport = (payload) => {
|
|
const { importDialog } = this.state;
|
|
const { salaryAcctRecordId } = this.props;
|
|
this.setState({ importDialog: { ...importDialog, nextloading: true } });
|
|
importComparisonExcelAcctResult({ ...payload, 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 } }));
|
|
};
|
|
|
|
render() {
|
|
const { importDialog } = this.state;
|
|
return (
|
|
<ImportDialog
|
|
{...importDialog} onCancel={this.props.onCancel} exportDataDom={null}
|
|
onResetImportResult={() => this.setState(({
|
|
importDialog: { ...importDialog, importResult: {}, imageId: "" }
|
|
}))}
|
|
nextCallback={imageId => this.handleImport({ imageId })}
|
|
/>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default SalaryCalcOcImport;
|