189 lines
6.7 KiB
JavaScript
189 lines
6.7 KiB
JavaScript
/*
|
|
* Author: 黎永顺
|
|
* name: 薪资核算详情
|
|
* Description:
|
|
* Date: 2023/9/13
|
|
*/
|
|
import React, { Component } from "react";
|
|
import { WeaLocaleProvider, WeaReqTop } from "ecCom";
|
|
import { Button, Dropdown, Menu, message, Modal } from "antd";
|
|
import { inject, observer } from "mobx-react";
|
|
import Layout from "./layout";
|
|
import { acctresultAccounting, getCalculateProgress } from "../../../apis/calculate";
|
|
import AdvanceInputBtn from "./components/advanceInputBtn";
|
|
import SalaryCalcPersonConfirm from "./components/salaryCalcPersonConfirm";
|
|
import SalaryEditCalc from "./components/salaryEditCalc";
|
|
import { convertToUrlString } from "../../../util/url";
|
|
import ProgressModal from "../../../components/progressModal";
|
|
import "./index.less";
|
|
|
|
const getLabel = WeaLocaleProvider.getLabel;
|
|
|
|
@inject("calculateStore")
|
|
@observer
|
|
class Index extends Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
selectedKey: "person", progressVisible: false, progress: 0,
|
|
accountExceptInfo: "" //核算报错信息,
|
|
};
|
|
this.calc = null;
|
|
this.timer = null;
|
|
}
|
|
|
|
componentDidMount() {
|
|
console.log(this.props);
|
|
}
|
|
|
|
handleMenuClick = ({ key }) => {
|
|
switch (key) {
|
|
case "calc_selected":
|
|
const { selectedRowKeys } = this.calc.calcTableRef.wrappedInstance.state;
|
|
if (_.isEmpty(selectedRowKeys)) {
|
|
message.warning(getLabel(543303, "请选择表格数据!"));
|
|
return;
|
|
}
|
|
this.doCacl(key, selectedRowKeys);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
};
|
|
doCacl = (key, selectedRowKeys = []) => {
|
|
Modal.confirm({
|
|
title: getLabel(131329, "信息确认"),
|
|
content: getLabel(543544, "点击核算,公式项将按照公式逻辑核算,核算结果将覆盖原数据"),
|
|
onOk: () => {
|
|
const { routeParams: { salaryAcctRecordId } } = this.props;
|
|
this.setState({ progress: 0 });
|
|
let payload = { salaryAcctRecordId };
|
|
if (key === "calc_selected") payload = _.assign(payload, { ids: selectedRowKeys });
|
|
acctresultAccounting(payload).then(() => {
|
|
this.setState({ progressVisible: true });
|
|
if (this.timer) clearInterval(this.timer);
|
|
this.timer = setInterval(() => {
|
|
getCalculateProgress(salaryAcctRecordId).then(({ data }) => {
|
|
let progress = data.progress;
|
|
if (progress === 1 && this.timer) {
|
|
clearInterval(this.timer);
|
|
this.timer = null;
|
|
this.setState({
|
|
progressVisible: false,
|
|
accountExceptInfo: data.message
|
|
});
|
|
message.success(getLabel(542321, "核算完成"));
|
|
this.calc.onAdSearch(false);
|
|
} else if (!data.status) {
|
|
clearInterval(this.timer);
|
|
this.timer = null;
|
|
this.setState({
|
|
progressVisible: false,
|
|
accountExceptInfo: data.message
|
|
});
|
|
message.error(data.message);
|
|
}
|
|
this.setState({ progress: Number(progress) * 100 });
|
|
});
|
|
}, 1000);
|
|
});
|
|
}
|
|
});
|
|
};
|
|
handleMoreMenuClick = ({ key }) => {
|
|
switch (key) {
|
|
case "exportAll":
|
|
const { calculateStore: { ECSearchForm }, routeParams: { salaryAcctRecordId } } = this.props;
|
|
const { consolidatedTaxation, ...extra } = ECSearchForm.getFormParams();
|
|
const payload = { ...extra, consolidatedTaxation: consolidatedTaxation === "0" ? "" : consolidatedTaxation };
|
|
const url = `/api/bs/hrmsalary/salaryacct/acctresult/export?salaryAcctRecordId=${salaryAcctRecordId}&ids=&${convertToUrlString(payload)}`;
|
|
window.open(`${window.ecologyContentPath || ""}${url}`, "_blank");
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
console.log(key);
|
|
};
|
|
renderReqBtns = () => {
|
|
const { selectedKey } = this.state;
|
|
let reqBtns = [];
|
|
switch (selectedKey) {
|
|
case "calc":
|
|
const menu = (
|
|
<Menu onClick={this.handleMenuClick}>
|
|
<Menu.Item key="calc_selected">{getLabel(543546, "核算所选人员")}</Menu.Item>
|
|
</Menu>
|
|
);
|
|
const moreMenu = (
|
|
<Menu onClick={this.handleMoreMenuClick}>
|
|
<Menu.Item key="import">{getLabel(32935, "导入")}</Menu.Item>
|
|
<Menu.Item key="exportAll">{getLabel(81272, "导出全部")}</Menu.Item>
|
|
<Menu.Item key="export_custom">{getLabel(544270, "自定义导出")}</Menu.Item>
|
|
<Menu.Item key="offlineCompare">{getLabel(543249, "线下对比")}</Menu.Item>
|
|
</Menu>
|
|
);
|
|
reqBtns = [
|
|
<Dropdown.Button onClick={() => this.doCacl("ALL")} overlay={menu} type="primary">
|
|
{getLabel(543545, "核算所有人")}
|
|
</Dropdown.Button>,
|
|
<Dropdown overlay={moreMenu}><Button type="ghost">{getLabel(17499, "更多")}</Button></Dropdown>,
|
|
<AdvanceInputBtn onOpenAdvanceSearch={() => this.calc.openAdvanceSearch()}
|
|
onAdvanceSearch={() => this.calc.onAdSearch(false)}/>
|
|
];
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return reqBtns;
|
|
};
|
|
renderContent = () => {
|
|
const { selectedKey, accountExceptInfo } = this.state;
|
|
let dom = null;
|
|
switch (selectedKey) {
|
|
case "person":
|
|
dom = <SalaryCalcPersonConfirm {...this.props}/>;
|
|
break;
|
|
case "calc":
|
|
dom = <SalaryEditCalc {...this.props} accountExceptInfo={accountExceptInfo} ref={dom => this.calc = dom}/>;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return dom;
|
|
};
|
|
|
|
render() {
|
|
const tabs = [
|
|
{ key: "person", title: getLabel(543547, "人员确认") },
|
|
{ key: "calc", title: getLabel(538011, "薪资核算") }
|
|
];
|
|
const { selectedKey, progressVisible, progress } = this.state;
|
|
return (
|
|
<Layout {...this.props}>
|
|
<div className="salary-calculate-do-calc">
|
|
<WeaReqTop
|
|
title={getLabel(538011, "薪资核算")} tabDatas={tabs} selectedKey={selectedKey}
|
|
buttonSpace={10} icon={<i className="icon-coms-fa"/>} iconBgcolor="#F14A2D"
|
|
onChange={key => this.setState({ selectedKey: key })}
|
|
buttons={this.renderReqBtns()}
|
|
>
|
|
<div className="salary-calculate-do-calc-content">{this.renderContent()}</div>
|
|
{
|
|
progressVisible &&
|
|
<ProgressModal
|
|
visible={progressVisible}
|
|
onCancel={() => {
|
|
this.setState({ progressVisible: false, progress: 0 }, () => clearInterval(this.timer));
|
|
}}
|
|
progress={parseFloat(progress).toFixed(2)}
|
|
/>
|
|
}
|
|
</WeaReqTop>
|
|
</div>
|
|
</Layout>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default Index;
|