salary-management-front/pc4mobx/hrmSalary/pages/calculate/doCalc/components/salaryEditCalc/salaryCalcLayout.js

97 lines
3.3 KiB
JavaScript

/*
* Author: 黎永顺
* name: 薪资核算-layout
* Description:
* Date: 2024/4/26
*/
import React, { Component } from "react";
import { WeaCheckbox, WeaDialog, WeaLocaleProvider } from "ecCom";
import { Button, message, Spin } from "antd";
import * as API from "../../../../../apis/calculate";
import "./index.less";
const getLabel = WeaLocaleProvider.getLabel;
class SalaryCalcLayout extends Component {
constructor(props) {
super(props);
this.state = {
fieldInformationConfirm: { visible: false, data: {} }, userConfirmed: "0", show: false
};
}
componentDidMount() {
this.getCompareSobConfig();
}
getCompareSobConfig = () => {
const { fieldInformationConfirm } = this.state;
const { routeParams: { salaryAcctRecordId: id } } = this.props;
API.getCompareSobConfig({ id }).then(({ status, data }) => {
if (status && data) {
this.setState({
fieldInformationConfirm: { ...fieldInformationConfirm, visible: data }
});
} else {
this.setState({ show: true }, () => this.props.init());
}
}).catch(() => this.setState({ show: true }, () => this.props.init()));
};
onOk = () => {
const { fieldInformationConfirm } = this.state;
const { routeParams: { salaryAcctRecordId: id } } = this.props;
API.updateSobConfig({ id }).then(({ status, errormsg }) => {
if (status) {
message.success(getLabel(30700, "操作成功!"));
this.setState({
show: true,
fieldInformationConfirm: { ...fieldInformationConfirm, visible: false }
}, () => {
this.props.init();
this.props.onConfirm();
});
} else {
message.error(errormsg);
}
});
};
render() {
const { fieldInformationConfirm, userConfirmed, show } = this.state;
const buttons = [
<Button type="primary" onClick={this.onOk}
disabled={userConfirmed === "0"}>{getLabel(111, "是,更新账套设置")}</Button>,
<Button type="ghost" onClick={() => this.setState({
show: true,
fieldInformationConfirm: { ...fieldInformationConfirm, visible: false }
}, () => this.props.init())}>{getLabel(111, "否,忽略该提示")}</Button>
];
return (
<React.Fragment>
{
show ? this.props.children : <div className="loadingLayout"><Spin/></div>
}
<WeaDialog
title={getLabel(131329, "信息确认")} visible={fieldInformationConfirm.visible} initLoadCss hasScroll
style={{ width: 380 }} className="infoConfirmDialog" buttons={buttons} onCancel={() =>
this.setState({
show: true,
fieldInformationConfirm: { ...fieldInformationConfirm, visible: false }
}, () => this.props.init())}>
<div className="confirm-content">
<div className="contract">
{getLabel("111", "账套发生变更,是否需要更新账套设置?更新后核算将按照最新的账套进行核算,请谨慎操作。")}
</div>
<div className="confirm-container">
<WeaCheckbox value={userConfirmed} content={getLabel("111", "已认真阅读,知晓风险")}
onChange={v => this.setState({ userConfirmed: v })}/>
</div>
</div>
</WeaDialog>
</React.Fragment>
);
}
}
export default SalaryCalcLayout;