salary-management-front/pc4mobx/hrmSalary/pages/dataAcquisition/cumDeduct/components/salaryCumDeductChooseTaxPer...

83 lines
2.7 KiB
JavaScript

/*
* Author: 黎永顺
* name: 个税对接-在线获取
* Description:
* Date: 2023/9/5
*/
import React, { Component } from "react";
import { inject, observer } from "mobx-react";
import { WeaDialog, WeaLocaleProvider } from "ecCom";
import { Button, message } from "antd";
import { getSearchs } from "../../../../util";
import { cumTaxPeriodCondition } from "../columns";
import { onlineRequest } from "../../../../apis/cumDeduct";
import { onlineActualAddUpAdvanceTax } from "../../../../apis/cumSituation";
const getLabel = WeaLocaleProvider.getLabel;
const APIFox = {
online: onlineRequest,
advance: onlineActualAddUpAdvanceTax
};
@inject("cumDeductStore")
@observer
class SalaryCumDeductChooseTaxPeriodDialog extends Component {
constructor(props) {
super(props);
this.state = {
loading: false
};
}
componentWillReceiveProps(nextProps, nextContext) {
const { cumDeductStore: { cumTaxPeriodForm, changeCumTaxPeriodForm } } = nextProps;
if (nextProps.visible !== this.props.visible && nextProps.visible) {
cumTaxPeriodForm.initFormFields(cumTaxPeriodCondition);
}
if (nextProps.visible !== this.props.visible && !nextProps.visible) {
cumTaxPeriodForm.resetForm();
changeCumTaxPeriodForm();
}
}
save = () => {
const { cumDeductStore: { cumTaxPeriodForm }, type } = this.props;
cumTaxPeriodForm.validateForm().then(f => {
const { declareMonth } = cumTaxPeriodForm.getFormParams();
if (f.isValid) {
this.setState({ loading: true });
APIFox[type]({ declareMonth: declareMonth + "-01" }).then(({ status, errormsg }) => {
this.setState({ loading: false });
if (status) {
message.success(getLabel(111, "获取成功!"));
this.props.onCancel();
} else {
message.error(errormsg);
}
}).catch(() => this.setState({ loading: false }));
} else {
f.showErrors();
}
});
};
render() {
const { loading } = this.state;
const { cumDeductStore: { cumTaxPeriodForm } } = this.props;
return (
<WeaDialog
{...this.props} className="paymentDialog" initLoadCss
style={{ width: 550 }}
buttons={[<Button type="primary" loading={loading} onClick={this.save}>{getLabel(33703, "确认")}</Button>]}
bottomLeft={getLabel(111, "点击保存后,稍后请点击【获取结果下载】下载获取结果。获取的数据将覆盖列表原本数据(有则覆盖无则新增)。")}
>
<div className="paymentDialogContent">
{getSearchs(cumTaxPeriodForm, cumTaxPeriodCondition, 1, false)}
</div>
</WeaDialog>
);
}
}
export default SalaryCumDeductChooseTaxPeriodDialog;