salary-management-front/pc4mobx/hrmSalary/pages/appConfig/moveInDialog.js

74 lines
2.1 KiB
JavaScript

/*
* 数据迁入
*
* @Author: 黎永顺
* @Date: 2024/8/12
* @Wechat:
* @Email: 971387674@qq.com
* @description:
*/
import React, { Component } from "react";
import { WeaLocaleProvider } from "ecCom";
import { message } from "antd";
import ImportDialog from "../../components/importDialog";
import * as API from "../../apis/ruleconfig";
const getLabel = WeaLocaleProvider.getLabel;
class MoveInDialog extends Component {
constructor(props) {
super(props);
this.state = {
importDialog: {
nextloading: false, importResult: {}, imageId: "",
customDragger: { showOperateDesc: false, accept: ".xml" }
}
};
}
componentWillReceiveProps(nextProps, nextContext) {
if (nextProps.visible !== this.props.visible && !nextProps.visible) {
this.setState({
importDialog: {
...this.state.importDialog,
importResult: {}, imageId: "",
customDragger: { showOperateDesc: false, accept: ".xml" }
}
});
}
}
handleImport = (payload) => {
const { importDialog } = this.state;
this.setState({ importDialog: { ...importDialog, nextloading: true } });
API.uploadConfig({ ...payload }).then(({ data, status, errormsg }) => {
this.setState({ importDialog: { ...importDialog, nextloading: false } });
if (status) {
this.setState({
importDialog: { ...importDialog, ...payload, importResult: data }
});
} else {
message.error(errormsg);
}
}).catch(() => this.setState({ importDialog: { ...importDialog, nextloading: false } }));
};
render() {
const { importDialog } = this.state;
return (
<ImportDialog
{...this.props} {...importDialog} excludeKey={1}
onResetImportResult={() => this.setState({
importDialog: {
...importDialog, importResult: {}, imageId: "", link: ""
}
})}
nextCallback={imageId => this.setState({ importDialog: { ...importDialog, imageId } })}
nextUplaodCallback={imageId => this.handleImport({ imageId })}
/>
);
}
}
export default MoveInDialog;