salary-management-front/pc4mobx/hrmSalary/pages/reportView/index.js

181 lines
6.4 KiB
JavaScript
Raw Normal View History

2023-04-20 15:36:51 +08:00
/*
* Author: 黎永顺
* name: 薪酬报表查看
* Description:
* Date: 2023/4/20
*/
import React, { Component } from "react";
2023-04-23 11:28:18 +08:00
import { inject, observer } from "mobx-react";
2024-07-16 15:59:38 +08:00
import { WeaLeftRightLayout, WeaLoadingGlobal, WeaLocaleProvider, WeaSelect, WeaTop } from "ecCom";
2023-04-23 11:28:18 +08:00
import { message, Modal } from "antd";
2023-04-20 15:36:51 +08:00
import LeftTab from "./components/leftTab";
2023-04-23 11:28:18 +08:00
import ReportContent from "./components/reportContent";
2023-11-09 16:27:33 +08:00
import StatisticalMicroSettingsSlide, { getSalaryMonthValue } from "./components/statisticalMicroSettingsSlide";
2024-07-16 15:59:38 +08:00
import { exportDataReport, reportGetForm, reportStatisticsReportSave } from "../../apis/ruleconfig";
2023-11-09 16:27:33 +08:00
import TopBtns from "./components/topBtns";
2023-04-20 15:36:51 +08:00
import "./index.less";
2023-04-20 15:36:51 +08:00
const { getLabel } = WeaLocaleProvider;
2023-04-23 11:28:18 +08:00
@inject("taxAgentStore", "attendanceStore")
@observer
2023-04-20 15:36:51 +08:00
class Index extends Component {
constructor(props) {
super(props);
this.state = {
report: {},
2023-04-23 11:28:18 +08:00
dimensionList: [],
statisticalPayload: {
visible: false, id: "", dimension: ""
}
2023-04-20 15:36:51 +08:00
};
}
componentDidMount() {
this.reportGetForm();
}
reportGetForm = () => {
reportGetForm().then(({ status, data }) => {
if (status) {
const { statsDimOptions } = data;
this.setState({
dimensionList: _.map(statsDimOptions, it => ({ key: it.id, showname: it.content }))
});
}
});
};
2023-04-23 11:28:18 +08:00
/*
* Author: 黎永顺
* Description: 统计维度切换
* Params:
* Date: 2023/4/20
*/
handleChangeDimension = (dimensionId, dimension) => {
const { report } = this.state;
Modal.confirm({
title: getLabel(111, "信息确认"),
content: getLabel(111, "确认要更改统计维度吗?"),
onOk: () => {
const payload = {
id: report.id,
reportName: report.reportName,
dimensionIds: dimensionId.split(",")
};
reportStatisticsReportSave(payload).then(({ status, errormsg }) => {
this.setState({ loading: false });
if (status) {
message.success(getLabel(111, "切换成功"));
this.setState({
report: {
...report, dimensionId,
dimension
}
}, () => this.leftTabRef.updateReportList(this.state.report));
} else {
message.error(errormsg || getLabel(111, "切换失败"));
this.setState({ report: { ...report } });
}
});
},
onCancel: () => {
this.setState({ report: { ...report } });
}
});
};
2023-04-24 18:30:47 +08:00
/*
* Author: 黎永顺
* Description: 导出报表数据
* Params:
* Date: 2023/4/24
*/
exportData = () => {
2024-07-16 15:59:38 +08:00
if (this.reportRef.state.loading) {
message.info(getLabel(111, "列表正在加载中,请稍后"));
return;
}
2023-04-24 18:30:47 +08:00
const { report } = this.state;
2023-11-09 16:27:33 +08:00
const { id, dimensionId, isShare, timeType, salaryEndMonth: end, salaryStartMonth: start } = report;
const [salaryStartMonth, salaryEndMonth] = getSalaryMonthValue(timeType);
const payload = {
id, dimensionId, isShare,
salaryStartMonth: (salaryStartMonth || start) + "-01", salaryEndMonth: (salaryEndMonth || end) + "-01"
};
2024-07-16 15:59:38 +08:00
WeaLoadingGlobal.start();
const promise = exportDataReport(payload);
2023-04-24 18:30:47 +08:00
};
2023-04-20 15:36:51 +08:00
render() {
2023-04-23 11:28:18 +08:00
const { report, dimensionList, statisticalPayload } = this.state;
const { isShare } = report;
const { attendanceStore: { settingForm }, taxAgentStore: { taxAgentOption, showOperateBtn } } = this.props;
2023-04-20 15:36:51 +08:00
return (
<WeaTop
title={getLabel(111, "报表查看")} icon={<i className="icon-coms-fa"/>}
iconBgcolor="#F14A2D" className="reportViewWrapper"
buttons={(showOperateBtn && !isShare) ? [<TopBtns/>] : []}
2023-04-20 15:36:51 +08:00
>
<WeaLeftRightLayout
leftWidth={210}
2023-04-24 09:28:25 +08:00
leftCom={
<LeftTab
ref={dom => this.leftTabRef = dom}
onChangeTab={report =>
this.setState({
2023-11-09 15:36:13 +08:00
report: !_.isNil(report) ? report : this.state.report,
2023-04-24 09:28:25 +08:00
statisticalPayload: { visible: false, id: "", dimension: "" }
})}
/>
}
2023-04-20 15:36:51 +08:00
>
<div className="rightLayout">
<div className="layoutHeader">
<div className="layoutRow">
<div className="layoutCol"><span className="leftColTitle">{report.reportName}</span></div>
<div className="layoutCol layoutColRight">
<div className="rightColTitle">
<div className="dimension">
<span>{getLabel(111, "统计维度")}</span>
<WeaSelect value={report.dimensionId} options={dimensionList} disabled={isShare}
2023-04-23 11:28:18 +08:00
onChange={(key, showname) => this.handleChangeDimension(key, showname)}/>
2023-04-20 15:36:51 +08:00
</div>
2023-04-23 11:28:18 +08:00
<div className="iconWrapper">
<i
className="icon-coms02-currency"
2023-04-24 18:30:47 +08:00
title={getLabel(111, "统计数据范围及规则设置")}
onClick={() => {
if (this.reportRef.state.loading) {
message.info(getLabel(111, "列表正在加载中,请稍后"));
} else {
this.setState({
statisticalPayload: { visible: true, id: report.id, dimension: report.dimensionId }
});
}
}}
2023-04-23 11:28:18 +08:00
/>
2023-04-24 18:30:47 +08:00
<i className="icon-coms-export" onClick={this.exportData} title={getLabel(111, "导出")}/>
2023-04-23 11:28:18 +08:00
</div>
{/*统计数据范围及规则设置弹框*/}
<StatisticalMicroSettingsSlide
{...statisticalPayload} form={settingForm}
taxAgentAdminOption={taxAgentOption} isShare={isShare}
2023-04-24 16:25:07 +08:00
onClose={(isRefresh) => this.setState({
2023-04-23 11:28:18 +08:00
statisticalPayload: { visible: false, id: "", dimension: "" }
2023-11-09 15:36:13 +08:00
}, () => isRefresh && this.leftTabRef.reportStatisticsReportList())}
2023-04-23 11:28:18 +08:00
/>
2023-04-20 15:36:51 +08:00
</div>
</div>
</div>
</div>
{/* 内容区 */}
2023-04-23 11:28:18 +08:00
<ReportContent ref={dom => this.reportRef = dom} report={report}/>
2023-04-20 15:36:51 +08:00
</div>
</WeaLeftRightLayout>
</WeaTop>
);
}
}
export default Index;