2024-01-23 10:51:38 +08:00
|
|
|
/*
|
|
|
|
|
* Author: 黎永顺
|
|
|
|
|
* name: 社保福利台账重构
|
|
|
|
|
* version: 1.0
|
|
|
|
|
* Description:
|
|
|
|
|
* Date: 2024/1/23
|
|
|
|
|
*/
|
|
|
|
|
import React, { Component } from "react";
|
2024-01-23 15:38:03 +08:00
|
|
|
import { inject, observer } from "mobx-react";
|
|
|
|
|
import { WeaLocaleProvider, WeaTop } from "ecCom";
|
2024-01-24 15:37:09 +08:00
|
|
|
import { Button, message } from "antd";
|
|
|
|
|
import * as API from "../../../apis/standingBook";
|
|
|
|
|
import { getCalculateProgress } from "../../../apis/calculate";
|
2024-01-23 15:38:03 +08:00
|
|
|
import WelfareRecordQuery from "./components/welfareRecordQuery";
|
2024-01-23 19:05:57 +08:00
|
|
|
import WelfareRecordList from "./components/welfareRecordList";
|
|
|
|
|
import Accountdialog from "./components/accountDialog";
|
2024-01-24 15:37:09 +08:00
|
|
|
import ProgressModal from "../../../components/progressModal";
|
|
|
|
|
import { convertToUrlString } from "../../../util/url";
|
2024-01-23 19:05:57 +08:00
|
|
|
import moment from "moment";
|
2024-01-23 15:38:03 +08:00
|
|
|
import "./index.less";
|
2024-01-23 10:51:38 +08:00
|
|
|
|
|
|
|
|
const getLabel = WeaLocaleProvider.getLabel;
|
|
|
|
|
|
2024-01-23 15:38:03 +08:00
|
|
|
@inject("standingBookStore", "taxAgentStore")
|
|
|
|
|
@observer
|
2024-01-23 10:51:38 +08:00
|
|
|
class StandingBook extends Component {
|
2024-01-23 19:05:57 +08:00
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
this.state = {
|
|
|
|
|
queryForm: {
|
|
|
|
|
startTime: moment(new Date()).subtract(1, "year").startOf("year").format("YYYY-MM"),
|
|
|
|
|
endTime: moment(new Date()).endOf("year").format("YYYY-MM"),
|
2024-01-24 13:50:45 +08:00
|
|
|
taxAgents: ""
|
2024-01-24 15:37:09 +08:00
|
|
|
}, progressVisible: false, progress: 0,
|
2024-01-23 19:05:57 +08:00
|
|
|
accountDialog: { visible: false, title: "", loading: false, options: [] }
|
|
|
|
|
};
|
|
|
|
|
this.wfListRef = null;
|
2024-01-24 15:37:09 +08:00
|
|
|
this.timer = null;
|
2024-01-23 19:05:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Author: 黎永顺
|
|
|
|
|
* Description: 社保福利台账重构-核算
|
|
|
|
|
* Params:
|
|
|
|
|
* Date: 2024/1/23
|
|
|
|
|
*/
|
2024-01-24 15:37:09 +08:00
|
|
|
handleAccount = async (formVal) => {
|
2024-01-23 19:05:57 +08:00
|
|
|
const { billMonth, ...extra } = formVal;
|
|
|
|
|
const payload = {
|
|
|
|
|
billMonth: moment(billMonth).format("YYYY-MM"),
|
|
|
|
|
...extra
|
|
|
|
|
};
|
2024-01-24 15:37:09 +08:00
|
|
|
this.setState({ accountDialog: { ...this.state.accountDialog, loading: true } });
|
|
|
|
|
const { data: creator, status, errormsg } = await API.save(payload);
|
|
|
|
|
if (status) {
|
|
|
|
|
this.setState({
|
|
|
|
|
accountDialog: { ...this.state.accountDialog, loading: false },
|
|
|
|
|
progressVisible: true
|
|
|
|
|
}, () => {
|
|
|
|
|
this.timer = setInterval(() => {
|
|
|
|
|
getCalculateProgress(moment(billMonth).format("YYYY-MM")).then(({ status, data }) => {
|
|
|
|
|
if (status) {
|
|
|
|
|
if (!data.status) {
|
|
|
|
|
clearInterval(this.timer);
|
|
|
|
|
this.setState({ progressVisible: false, progress: 0 });
|
|
|
|
|
message.error(data.message);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (this.state.progress !== 100) {
|
|
|
|
|
this.setState({
|
|
|
|
|
progress: (Number(data.progress).toFixed(2)) * 100
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
clearInterval(this.timer);
|
|
|
|
|
this.setState({ progressVisible: false, progress: 0 }, () => {
|
|
|
|
|
message.success(getLabel(543232, "核算成功"));
|
|
|
|
|
this.setState({
|
|
|
|
|
accountDialog: { ...this.state.accountDialog, visible: false }
|
|
|
|
|
}, () => {
|
|
|
|
|
this.wfListRef.wrappedInstance.getWelfareRecordList();
|
|
|
|
|
const calcPayload = { ...payload, creator };
|
|
|
|
|
window.open(`/spa/hrmSalary/static/index.html#/main/hrmSalary/socialSecurityBenefits/standingBookDetail?${convertToUrlString(calcPayload)}`);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
clearInterval(this.timer);
|
|
|
|
|
this.setState({ progressVisible: false, progress: 0 });
|
|
|
|
|
}
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
clearInterval(this.timer);
|
|
|
|
|
this.setState({ progressVisible: false, progress: 0 });
|
|
|
|
|
});
|
|
|
|
|
}, 600);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
message.error(errormsg);
|
|
|
|
|
clearInterval(this.timer);
|
|
|
|
|
this.setState({
|
|
|
|
|
accountDialog: { ...this.state.accountDialog, loading: false },
|
|
|
|
|
progressVisible: false, progress: 0
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-01-23 19:05:57 +08:00
|
|
|
};
|
|
|
|
|
|
2024-01-23 10:51:38 +08:00
|
|
|
render() {
|
2024-01-23 19:05:57 +08:00
|
|
|
const { accountDialog, queryForm } = this.state;
|
2024-01-23 15:38:03 +08:00
|
|
|
const { taxAgentStore: { showOperateBtn } } = this.props;
|
2024-01-23 19:05:57 +08:00
|
|
|
const rightBtns = [<Button type="primary" onClick={() => this.setState({
|
|
|
|
|
accountDialog: { ...accountDialog, visible: true, title: getLabel(538780, "核算") }
|
|
|
|
|
})}>{getLabel(538780, "核算")}</Button>];
|
2024-01-23 10:51:38 +08:00
|
|
|
return (
|
2024-01-23 15:38:03 +08:00
|
|
|
<div className="salary-welfare-record">
|
|
|
|
|
<WeaTop title={getLabel(538002, "社保福利台账")} icon={<i className="icon-coms-fa"/>}
|
|
|
|
|
iconBgcolor="#F14A2D" buttons={showOperateBtn ? rightBtns : []}>
|
|
|
|
|
<div className="salary-welfare-record-content">
|
2024-01-24 15:37:09 +08:00
|
|
|
<WelfareRecordQuery
|
|
|
|
|
onSearch={(payload) => {
|
|
|
|
|
this.setState({
|
|
|
|
|
queryForm: { ...queryForm, ...payload }
|
|
|
|
|
}, () => this.wfListRef.wrappedInstance.getWelfareRecordList());
|
|
|
|
|
}}
|
|
|
|
|
onPutAccountOptions={options => this.setState({ accountDialog: { ...accountDialog, options } })}
|
|
|
|
|
/>
|
2024-01-23 19:05:57 +08:00
|
|
|
<WelfareRecordList ref={dom => this.wfListRef = dom} queryForm={queryForm}/>
|
2024-01-23 15:38:03 +08:00
|
|
|
</div>
|
2024-01-23 19:05:57 +08:00
|
|
|
<Accountdialog {...accountDialog}
|
|
|
|
|
onCancel={() => this.setState({
|
2024-01-24 15:37:09 +08:00
|
|
|
accountDialog: { ...accountDialog, visible: false, title: "", loading: false }
|
2024-01-23 19:05:57 +08:00
|
|
|
})} onOk={this.handleAccount}
|
|
|
|
|
/>
|
2024-01-24 15:37:09 +08:00
|
|
|
{/*核算进度条*/}
|
|
|
|
|
{
|
|
|
|
|
this.state.progressVisible &&
|
|
|
|
|
<ProgressModal visible={this.state.progressVisible} progress={this.state.progress}
|
|
|
|
|
onCancel={() => {
|
|
|
|
|
this.setState({ progressVisible: false, progress: 0 }, () => clearInterval(this.timer));
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
}
|
2024-01-23 15:38:03 +08:00
|
|
|
</WeaTop>
|
2024-01-23 10:51:38 +08:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default StandingBook;
|