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";
|
2023-05-24 15:13:31 +08:00
|
|
|
|
import { WeaDatePicker, WeaInputSearch, WeaLocaleProvider, WeaReqTop } from "ecCom";
|
2023-04-11 13:41:56 +08:00
|
|
|
|
import { Button } 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";
|
2023-05-24 15:13:31 +08:00
|
|
|
|
import EmployeeDetails from "./components/employeeDetails";
|
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";
|
2023-05-24 15:13:31 +08:00
|
|
|
|
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: "",
|
2023-05-24 15:13:31 +08:00
|
|
|
|
keyword: "",
|
|
|
|
|
|
year: moment().format("YYYY"),
|
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: ""
|
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
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
render() {
|
2023-04-28 10:00:10 +08:00
|
|
|
|
const { taxAgentStore: { statisticsReportBtn }, attendanceStore: { statisticsForm, reportForm } } = this.props;
|
2023-05-24 15:13:31 +08:00
|
|
|
|
const { selectedKey, modalReq, slideReq, conditions, reportConditions, reportName, keyword, year } = this.state;
|
|
|
|
|
|
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")}/>
|
2023-05-24 15:13:31 +08:00
|
|
|
|
] : [
|
|
|
|
|
|
<span className="employeeYearWrapper">
|
|
|
|
|
|
<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()}/>
|
2023-04-11 13:41:56 +08:00
|
|
|
|
];
|
|
|
|
|
|
const tabs = [
|
2023-05-24 15:13:31 +08:00
|
|
|
|
{ key: "statistics", title: getLabel(111, "统计表") },
|
|
|
|
|
|
{ key: "detail", title: getLabel(111, "员工明细") }
|
2023-04-11 13:41:56 +08:00
|
|
|
|
];
|
|
|
|
|
|
return (
|
|
|
|
|
|
<WeaReqTop
|
2023-05-24 15:13:31 +08:00
|
|
|
|
title={getLabel(111, "薪酬统计报表")} icon={<i className="icon-coms-fa"/>} selectedKey={selectedKey}
|
|
|
|
|
|
iconBgcolor="#F14A2D" tabDatas={tabs} className="xc_tj_fx_wrapper" showDropIcon={false}
|
|
|
|
|
|
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())}
|
2023-04-11 13:41:56 +08:00
|
|
|
|
>
|
2023-04-19 09:29:38 +08:00
|
|
|
|
{
|
2023-05-24 15:13:31 +08:00
|
|
|
|
selectedKey === "statistics" ?
|
|
|
|
|
|
<ReportList
|
|
|
|
|
|
ref={dom => this.reportListRef = dom}
|
|
|
|
|
|
reportName={reportName}
|
|
|
|
|
|
onEdit={this.handleReqBtnsClick}
|
|
|
|
|
|
/> : <EmployeeDetails
|
|
|
|
|
|
ref={dom => this.employeeListRef = dom}
|
|
|
|
|
|
keyword={keyword} year={year}
|
|
|
|
|
|
/>
|
2023-04-19 09:29:38 +08:00
|
|
|
|
}
|
2023-11-07 16:21:17 +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}
|
|
|
|
|
|
/>
|
2023-04-11 13:41:56 +08:00
|
|
|
|
</WeaReqTop>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default Index;
|