/* * 浮动薪酬 * 薪资档案导入 * @Author: 黎永顺 * @Date: 2024/8/8 * @Wechat: * @Email: 971387674@qq.com * @description: */ import React, { Component } from "react"; import { WeaCheckbox, WeaLocaleProvider } from "ecCom"; import ImportDialog from "../../../../components/importDialog"; import * as API from "../../../../apis/variableSalary"; import { convertToUrlString } from "../../../../util/url"; const getLabel = WeaLocaleProvider.getLabel; class Index extends Component { constructor(props) { super(props); this.state = { importDialog: { nextloading: false, link: "/api/bs/hrmsalary/variableSalary/downloadTemplate", importResult: {}, imageId: "", hasData: false, previewUrl: "/api/bs/hrmsalary/variableSalary/preview" } }; } componentWillReceiveProps(nextProps, nextContext) { const { importDialog } = this.state; if (nextProps.visible !== this.props.visible && nextProps.visible) { const { baseTableStore: { VSalryForm }, salaryMonth } = nextProps; const payload = { salaryMonth, ...VSalryForm.getFormParams(), hasData: importDialog.hasData }; this.setState({ importDialog: { ...importDialog, link: `${importDialog.link}?${convertToUrlString(payload)}` } }); } else { this.setState({ importDialog: { nextloading: false, link: "/api/bs/hrmsalary/variableSalary/downloadTemplate", hasData: false, importResult: {}, imageId: "", previewUrl: "/api/bs/hrmsalary/variableSalary/preview" } }); } } handleImport = (payload) => { const { salaryMonth } = this.props; const { importDialog } = this.state; this.setState({ importDialog: { ...importDialog, nextloading: true } }); API.importVariableSalary({ ...payload, salaryMonth }).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 ( this.setState({ importDialog: { ...importDialog, importResult: {}, imageId: "", link: null } })} exportDataDom={ { const { baseTableStore: { VSalryForm }, salaryMonth } = this.props; const payload = { salaryMonth, ...VSalryForm.getFormParams(), hasData: val === "1" }; this.setState({ importDialog: { ...importDialog, hasData: val === "1", link: `/api/bs/hrmsalary/variableSalary/downloadTemplate?${convertToUrlString(payload)}` } }); }} /> } nextCallback={imageId => this.setState({ importDialog: { ...importDialog, imageId } })} nextUplaodCallback={imageId => this.handleImport({ imageId })} /> ); } } export default Index;