salary-management-front/pc4mobx/hrmSalary/pages/declareDetail/components/taxDeclareDetailImportDialo...

84 lines
2.7 KiB
JavaScript

/*
* Author: 黎永顺
* name: 个税申报表详情-导入
* Description:
* Date: 2023/12/28
*/
import React, { Component } from "react";
import { WeaLocaleProvider } from "ecCom";
import { message } from "antd";
import ImportDialog from "../../../components/importDialog";
import * as API from "../../../apis/declare";
const getLabel = WeaLocaleProvider.getLabel;
class TaxDeclareDetailImportDialog extends Component {
constructor(props) {
super(props);
this.state = {
importDialog: {
visible: false, title: "", nextloading: false,
link: null, importResult: {}, imageId: "", taxDeclarationId: "",
previewUrl: "/api/bs/hrmsalary/taxdeclaration/preview",
extraPreview: { taxDeclarationId: "" }
}
};
}
handleImportTaxDeclare = (taxDeclarationId) => {
this.setState({
importDialog: {
...this.state.importDialog, link: this.handleExportTemp,
taxDeclarationId, visible: true, title: getLabel(24023, "数据导入"),
extraPreview: { taxDeclarationId }
}
});
};
handleImport = (payload) => {
const { importDialog } = this.state;
const { taxDeclarationId } = importDialog;
this.setState({ importDialog: { ...importDialog, nextloading: true } });
API.taxdeclarationImportData({ ...payload, taxDeclarationId })
.then(({ data, status }) => {
this.setState({ importDialog: { ...importDialog, nextloading: false } });
if (status) {
this.setState({
importDialog: { ...importDialog, ...payload, importResult: data }
}, () => this.props.onSuccess());
}
}).catch(() => this.setState({ importDialog: { ...importDialog, nextloading: false } }));
};
handleExportTemp = () => {
const { importDialog: { taxDeclarationId } } = this.state;
message.destroy();
message.loading(getLabel(111, "下载中"), 0);
const promise = API.taxdeclarationExportTemplate({ taxDeclarationId });
message.destroy();
};
handleCancel = () => {
this.setState({
importDialog: {
visible: false, title: "", nextloading: false,
link: null, importResult: {}, imageId: "", taxDeclarationId: "",
previewUrl: "/api/bs/hrmsalary/taxdeclaration/preview"
}
});
};
render() {
const { importDialog } = this.state;
return (
<ImportDialog
{...importDialog} onCancel={this.handleCancel}
onResetImportResult={() => this.setState(({
importDialog: { ...importDialog, importResult: {}, imageId: "" }
}))}
nextCallback={imageId => this.setState({ importDialog: { ...importDialog, imageId } })}
nextUplaodCallback={imageId => this.handleImport({ imageId })}
/>
);
}
}
export default TaxDeclareDetailImportDialog;