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

382 lines
16 KiB
JavaScript
Raw Normal View History

2023-04-11 13:41:56 +08:00
/*
* Author: 黎永顺
* name: 薪酬统计分析
* Description:
* Date: 2023/4/10
*/
import React, { Component } from "react";
import { inject, observer } from "mobx-react";
import { WeaDatePicker, WeaInputSearch, WeaLocaleProvider, WeaReqTop } from "ecCom";
import { Button, Dropdown, Menu } from "antd";
2023-04-17 17:32:16 +08:00
import { condition, reportCondition } from "./components/conditions";
import { commonEnumList, reportGetForm } from "../../apis/ruleconfig";
2023-04-12 10:47:51 +08:00
import { dimensionGetForm } from "../../apis/statistics";
import EmployeeDetails from "./components/employeeDetails";
import SalaryDetails from "./components/salaryDetails";
2023-04-11 13:41:56 +08:00
import StatisticsModal from "./components/statisticsModal";
import DimensionSlide from "./components/dimensionSlide";
2023-04-12 10:47:51 +08:00
import DimensionTable from "./components/dimensionTable";
2023-04-17 17:32:16 +08:00
import ReportList from "./components/reportList";
import ReportForm from "./components/reportForm";
import LogDialog from "../../components/logViewModal";
import moment from "moment";
2023-04-11 13:41:56 +08:00
import "./index.less";
2023-04-17 17:32:16 +08:00
const { getLabel } = WeaLocaleProvider;
2023-04-11 13:41:56 +08:00
@inject("taxAgentStore", "attendanceStore")
@observer
class Index extends Component {
constructor(props) {
super(props);
this.state = {
2023-04-12 10:47:51 +08:00
conditions: [],
convertConditions: [],
2023-04-18 13:24:12 +08:00
reportConditions: [],
2023-04-11 13:41:56 +08:00
selectedKey: "statistics",
2023-04-19 09:29:38 +08:00
reportName: "",
keyword: "",
year: moment().format("YYYY"),
dateRange: [
2025-12-23 15:04:40 +08:00
moment(new Date()).subtract(1, "months").format("YYYY-MM"),
moment(new Date()).subtract(1, "months").format("YYYY-MM")
],
showSearchAd: false,
isQuery: false,
2023-04-11 13:41:56 +08:00
slideReq: {
2023-04-12 10:47:51 +08:00
visible: false, formId: ""
2023-04-11 13:41:56 +08:00
},
modalReq: {
title: "", visible: false,
2023-04-19 09:29:38 +08:00
typeKey: "", id: ""
},
logDialogVisible: false, filterConditions: "[]"
2023-04-11 13:41:56 +08:00
};
}
2023-04-17 17:32:16 +08:00
componentDidMount() {
this.initReportFormCondition();
}
2023-04-19 09:29:38 +08:00
initReportFormCondition = (payload = {}) => {
2023-04-18 13:24:12 +08:00
const { attendanceStore: { reportForm } } = this.props;
2023-04-19 09:29:38 +08:00
reportGetForm(payload).then(({ status, data }) => {
2023-04-18 13:24:12 +08:00
if (status) {
2023-04-19 09:29:38 +08:00
const { statsDimOptions, data: detailData } = data;
if (_.isEmpty(payload)) {
this.setState({
reportConditions: _.map(reportCondition, item => {
return {
...item,
items: _.map(item.items, child => {
if (child.domkey[0] === "dimensionIds") {
return {
...child,
options: _.map(statsDimOptions, dimTypeItem => ({
key: dimTypeItem.id,
showname: dimTypeItem.content
}))
};
}
return { ...child };
})
};
})
}, () => {
reportForm.initFormFields(this.state.reportConditions);
});
} else {
reportForm.updateFields({
reportName: detailData.reportName,
dimensionIds: detailData.dimension.join(",")
});
}
2023-04-18 13:24:12 +08:00
}
2023-04-17 17:32:16 +08:00
});
};
2023-04-12 10:47:51 +08:00
initCondition = async () => {
const { attendanceStore: { statisticsForm } } = this.props;
const [dimTypeEnum, dimCodeList] = await Promise.all([this.commonEnumList(), this.dimensionGetForm()]);
const { data: dimTypeData } = dimTypeEnum, { data: dimCodeData } = dimCodeList;
const { baseForm: { statsDimOptions, groupDimOptions, data: dimTypeValue } } = dimCodeData;
this.setState({
conditions: _.map(condition, item => {
return {
...item,
items: _.map(item.items, child => {
if (child.domkey[0] === "dimType") {
return {
...child,
value: dimTypeValue.dimType,
options: _.map(dimTypeData, dimTypeItem => ({
key: dimTypeItem.value,
showname: dimTypeItem.defaultLabel
}))
};
}
if (child.domkey[0] === "setting4Qualitative") {
return {
...child,
options: _.map(statsDimOptions, dimCodeItem => ({
key: dimCodeItem.id,
showname: dimCodeItem.content
}))
};
}
if (child.domkey[0] === "dimCode") {
return {
...child,
options: _.map(groupDimOptions, dimCodeItem => ({
key: dimCodeItem.id,
showname: dimCodeItem.content
}))
};
}
return { ...child };
})
};
})
}, () => {
this.setState({ convertConditions: this.state.conditions });
statisticsForm.initFormFields(this.state.conditions);
});
};
commonEnumList = () => {
const payload = {
enumClass: "com.engine.salary.report.enums.SalaryStatisticsDimensionTypeEnum"
};
return commonEnumList(payload);
};
dimensionGetForm = () => {
return dimensionGetForm();
};
handleChangeCondition = (val, viewAttr) => {
2023-04-12 15:53:32 +08:00
const { attendanceStore: { statisticsForm } } = this.props;
2023-04-12 10:47:51 +08:00
const helpfulTitle = val === "RATION_GROUP_SPACING" ?
"例:\n" +
" 若所属字段为【工龄】分组设置为【0-5】【5-10】统计项为【税前薪资】对应的统计规则为【求和】 则统计结果为【工龄】为【0-5】的所有人的【税前薪资】求和【工龄】为【5-10】的所有人的【税前薪资】求和\n" +
"若未选择所属字段分组设置为【0-10,000.00】【10,000.00-20,000.00】;若统计项为【税前薪资】,对应的统计规则为【计数】; 则统计结果为【税前薪资】为【0-10,000.00】有多少人【税前薪资】为【10,000.00-20,000.00】有多少人;" :
val === "RATION_GROUP_INDIVIDUAL" ?
"例:\n" +
" 若所属字段为【职级】分组设置为【1】【2】【3】统计项为【税前薪资】对应的统计规则为【平均值】 则统计结果为【职级】为【1】的所有人的【税前薪资】的平均值【职级】为【2】的所有人的【税前薪资】的平均值【职级】为【3】的所有人的【税前薪资】的平均值\n" +
"若未选择所属字段分组设置为【1】【2】【3】若统计项为【绩效】对应的统计规则为【计数】 则统计结果为【绩效】为【1】有多少人绩效为【2】有多少人绩效为【3】有多少人" : "";
if (val === "QUALITATIVE") {
this.setState({
conditions: _.map(this.state.convertConditions, item => {
return {
...item,
items: _.map(_.filter(item.items, child => child.domkey[0] !== "dimCode"), it => {
if (it.domkey[0] === "dimType") {
return { ...it, value: val, viewAttr: viewAttr ? viewAttr : it.viewAttr };
}
return { ...it };
})
};
})
}, () => {
2023-04-12 15:53:32 +08:00
statisticsForm.setCondition(this.state.conditions);
2023-04-12 10:47:51 +08:00
});
} else {
this.setState({
conditions: _.map(this.state.convertConditions, item => {
return {
...item,
items: _.map(_.filter(item.items, child => child.domkey[0] !== "setting4Qualitative"), it => {
if (it.domkey[0] === "dimType") {
return { ...it, value: val, viewAttr: viewAttr ? viewAttr : it.viewAttr };
} else if (it.domkey[0] === "dimCode") {
return { ...it, helpfulTitle };
}
return { ...it };
})
};
})
}, () => {
2023-04-12 15:53:32 +08:00
statisticsForm.setCondition(this.state.conditions);
2023-04-12 10:47:51 +08:00
});
}
};
2023-04-19 09:29:38 +08:00
handleReqBtnsClick = (key, id = "") => {
2023-04-11 13:41:56 +08:00
if (key === "search") {
2023-04-19 09:29:38 +08:00
const { reportName } = this.state;
this.reportListRef.reportStatisticsReportList({ reportName });
2023-04-11 13:41:56 +08:00
} else {
const { modalReq } = this.state;
const title = key === "dimension" ?
<div className="dimensionTitle">
2023-04-17 17:32:16 +08:00
<span>{getLabel(111, "统计维度管理")}</span>
<Button type="primary" onClick={() => this.handleAddDimension()}>{getLabel(111, "新建统计维度")}</Button>
2023-04-11 13:41:56 +08:00
</div>
2023-04-19 09:29:38 +08:00
: getLabel(111, id ? "编辑报表" : "新建报表");
2023-04-11 13:41:56 +08:00
this.setState({
modalReq: {
2023-04-19 09:29:38 +08:00
...modalReq, id, title,
visible: true, typeKey: key
2023-04-11 13:41:56 +08:00
}
2023-04-19 09:29:38 +08:00
}, () => id && this.initReportFormCondition({ id }));
2023-04-11 13:41:56 +08:00
}
};
2023-04-19 09:29:38 +08:00
handleCancel = (refresh = false) => {
const { attendanceStore: { reportForm } } = this.props;
2023-04-11 13:41:56 +08:00
const { modalReq } = this.state;
this.setState({
modalReq: {
2023-04-19 09:29:38 +08:00
...modalReq, visible: false, id: ""
2023-04-11 13:41:56 +08:00
}
2023-04-19 09:29:38 +08:00
}, () => {
2023-05-12 10:18:39 +08:00
const { selectedKey, reportName, modalReq: { typeKey } } = this.state;
2023-04-19 09:29:38 +08:00
selectedKey === "statistics" && reportForm.resetForm();
2023-05-12 10:18:39 +08:00
typeKey === "dimension" && this.initReportFormCondition();
2023-04-19 09:29:38 +08:00
refresh && selectedKey === "statistics" && this.reportListRef.reportStatisticsReportList({ reportName });
2023-04-11 13:41:56 +08:00
});
};
2023-04-12 10:47:51 +08:00
handleAddDimension = (formId = "") => {
2023-04-11 13:41:56 +08:00
const { slideReq } = this.state;
this.setState({
slideReq: {
2023-04-12 10:47:51 +08:00
...slideReq, visible: true,
formId
2023-04-11 13:41:56 +08:00
}
});
};
2023-04-12 10:47:51 +08:00
handleClose = (initTable = false) => {
const { attendanceStore: { statisticsForm } } = this.props;
2023-04-11 13:41:56 +08:00
const { slideReq } = this.state;
this.setState({
slideReq: {
2023-04-12 10:47:51 +08:00
...slideReq, visible: false, formId: ""
2023-04-11 13:41:56 +08:00
}
2023-04-12 10:47:51 +08:00
}, () => {
statisticsForm.resetForm();
initTable && this.dimensionTableRef.dimensionList();
2023-04-11 13:41:56 +08:00
});
};
onDropMenuClick = (key, targetid = "") => {
switch (key) {
case "log":
this.setState({
logDialogVisible: true,
filterConditions: targetid ? `[{\"connectCondition\":\"AND\",\"columIndex\":\"targetid\",\"type\":\"=\",\"value\":\"${targetid}\"}]` : "[]"
});
break;
default:
break;
}
};
handleOpenAdvanceSearch = () => this.setState({ showSearchAd: true });
handleAdvanceSearch = () => this.setState({ isQuery: !this.state.isQuery });
onAdSearch = () => this.setState({ showSearchAd: false, isQuery: !this.state.isQuery });
handleExportSalaryList = (key) => this.salaryRef.wrappedInstance.handleExportSalaryList(key);
2023-04-11 13:41:56 +08:00
render() {
const {
2024-09-14 15:52:12 +08:00
taxAgentStore: { PageAndOptAuth },
attendanceStore: { statisticsForm, reportForm, tableStore }
} = this.props;
const {
selectedKey, modalReq, slideReq, conditions, reportConditions,
reportName, keyword, year, logDialogVisible, filterConditions,
dateRange, showSearchAd, isQuery
} = this.state;
2024-09-14 15:52:12 +08:00
const statisticsReportBtn = PageAndOptAuth.opts.includes("admin");
const buttons = selectedKey === "statistics" ? [
2023-04-17 17:32:16 +08:00
<Button type="primary" onClick={() => this.handleReqBtnsClick("addReport")}>{getLabel(111, "新建报表")}</Button>,
<Button type="ghost"
onClick={() => this.handleReqBtnsClick("dimension")}>{getLabel(111, "维度统计管理")}</Button>,
<WeaInputSearch placeholder={getLabel(111, "请输入报表名称")} className="search"
2023-04-19 09:29:38 +08:00
value={reportName}
onChange={reportName => this.setState({ reportName })}
2023-04-11 13:41:56 +08:00
onSearch={() => this.handleReqBtnsClick("search")}/>
] : selectedKey === "detail" ? [
<span className="employeeYearWrapper">
2024-09-20 16:30:12 +08:00
<span>{getLabel(111, "年度:")}</span>
<WeaDatePicker value={year} format="YYYY" onChange={year => this.setState({ year })}/>
</span>,
<WeaInputSearch placeholder={getLabel(111, "请输入姓名、工号、身份证号")} className="search"
value={keyword}
onChange={keyword => this.setState({ keyword })}
onSearch={() => this.employeeListRef.statisticsEmployeeList()}/>
] : [
<Dropdown.Button type="primary"
onClick={() => this.handleExportSalaryList("ALL")}
overlay={<Menu
onClick={({ key }) => this.handleExportSalaryList(key)}>
<Menu.Item
key="SELECTED">{getLabel(543715, "导出所选")}</Menu.Item>
</Menu>}>{getLabel(81272, "")}</Dropdown.Button>
];
let dropMenuDatas = [
{
key: "log", icon: <i className="iconfont icon-caozuorizhi32"/>,
content: getLabel(545781, "操作日志")
},
{
key: "BTN_COLUMN",
icon: <i className="icon-coms-Custom"/>,
content: getLabel(111, "显示列定制"),
onClick: () => {
this.salaryRef.wrappedInstance.handleSetDefCols();
2024-11-25 17:51:49 +08:00
// tableStore.setColSetVisible(true);
// tableStore.tableColSet(true);
}
}
2023-04-11 13:41:56 +08:00
];
const tabs = [
{ key: "statistics", title: getLabel(111, "统计表") },
{ key: "detail", title: getLabel(111, "员工明细") },
{ key: "salaryDetail", title: getLabel(111, "薪资明细") }
2023-04-11 13:41:56 +08:00
];
dropMenuDatas = selectedKey === "salaryDetail" ? dropMenuDatas.slice(-1) : dropMenuDatas.slice(0, 1);
2023-04-11 13:41:56 +08:00
return (
<WeaReqTop
title={getLabel(111, "薪酬统计报表")} icon={<i className="icon-coms-fa"/>} selectedKey={selectedKey}
iconBgcolor="#F14A2D" tabDatas={tabs} className="xc_tj_fx_wrapper"
buttons={(!statisticsReportBtn && selectedKey === "statistics") ? buttons.slice(-1) : buttons} buttonSpace={10}
2023-04-17 17:32:16 +08:00
onChange={selectedKey => this.setState({ selectedKey }, () => this.state.selectedKey === "statistics" && this.initReportFormCondition())}
showDropIcon={selectedKey !== "detail"} onDropMenuClick={this.onDropMenuClick} dropMenuDatas={dropMenuDatas}>
2023-04-19 09:29:38 +08:00
{
selectedKey === "statistics" ?
<ReportList
ref={dom => this.reportListRef = dom}
reportName={reportName}
onEdit={this.handleReqBtnsClick}
onFilterLog={(type, targetid) => this.onDropMenuClick(type, targetid)}
/> : selectedKey === "detail" ? <EmployeeDetails
ref={dom => this.employeeListRef = dom}
keyword={keyword} year={year}
onFilterLog={(type, targetid) => this.onDropMenuClick(type, targetid)}
/> : <SalaryDetails ref={dom => this.salaryRef = dom} dateRange={dateRange} isQuery={isQuery}
showSearchAd={showSearchAd} handleOpenAdvanceSearch={this.handleOpenAdvanceSearch}
handleAdvanceSearch={this.handleAdvanceSearch} onAdSearch={this.onAdSearch}
onCancel={() => this.setState({ showSearchAd: false })}
onChange={v => this.setState({ dateRange: v }, () => this.handleAdvanceSearch())}/>
2023-04-19 09:29:38 +08:00
}
<StatisticsModal {...modalReq} onCancel={this.handleCancel} form={reportForm} onClose={this.handleCancel}
onAddDimension={this.handleAddDimension}
>
2023-04-17 17:32:16 +08:00
{
modalReq.typeKey === "dimension" &&
<DimensionTable ref={dom => this.dimensionTableRef = dom}
onEdit={id => this.handleAddDimension(id)}
/>
}
{
modalReq.typeKey === "addReport" &&
2023-04-18 17:19:15 +08:00
<ReportForm form={reportForm} condition={reportConditions}/>
2023-04-17 17:32:16 +08:00
}
</StatisticsModal>
<DimensionSlide
{...slideReq} onCancel={this.handleClose}
form={statisticsForm} condition={conditions}
initCondition={this.initCondition} onChangeCondition={this.handleChangeCondition}
/>
{/*操作日志*/}
<LogDialog visible={logDialogVisible} logFunction="statreport" filterConditions={filterConditions}
onCancel={() => this.setState({ logDialogVisible: false })}/>
2023-04-11 13:41:56 +08:00
</WeaReqTop>
);
}
}
2025-12-23 15:04:40 +08:00
export default Index;