薪酬統計新功能开发
This commit is contained in:
parent
8fe5f201c6
commit
167caa4f5b
|
|
@ -5,18 +5,27 @@
|
||||||
* Date: 2023/4/11
|
* Date: 2023/4/11
|
||||||
*/
|
*/
|
||||||
import React, { Component } from "react";
|
import React, { Component } from "react";
|
||||||
import { WeaDialog } from "ecCom";
|
import { WeaDialog, WeaSearchGroup } from "ecCom";
|
||||||
import { Button, message } from "antd";
|
import { Button, message, Modal } from "antd";
|
||||||
import { dimensionGetForm, dimensionSave } from "../../../apis/statistics";
|
import { dimensionGetForm, dimensionSave } from "../../../apis/statistics";
|
||||||
import { getSearchs } from "../../../util";
|
import { getSearchs } from "../../../util";
|
||||||
|
import GroupSpacingEditTable from "./groupSpacingEditTable";
|
||||||
|
import GroupIndividualEditTable from "./groupIndividualEditTable";
|
||||||
import "../index.less";
|
import "../index.less";
|
||||||
|
|
||||||
|
const keyObj = {
|
||||||
|
"RATION_GROUP_SPACING": "setting4RationGroupSpacing",
|
||||||
|
"RATION_GROUP_INDIVIDUAL": "setting4RationGroupIndividual"
|
||||||
|
};
|
||||||
|
|
||||||
class DimensionSlide extends Component {
|
class DimensionSlide extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
loading: false,
|
loading: false,
|
||||||
date: ""
|
dimType: "QUALITATIVE",
|
||||||
|
setting4RationGroupSpacing: [],
|
||||||
|
setting4RationGroupIndividual: []
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -32,72 +41,131 @@ class DimensionSlide extends Component {
|
||||||
});
|
});
|
||||||
nextProps.onChangeCondition("QUALITATIVE");
|
nextProps.onChangeCondition("QUALITATIVE");
|
||||||
}
|
}
|
||||||
|
if (nextProps.visible !== this.props.visible && !nextProps.visible) {
|
||||||
|
this.setState({
|
||||||
|
loading: false,
|
||||||
|
dimType: "QUALITATIVE",
|
||||||
|
setting4RationGroupSpacing: [],
|
||||||
|
setting4RationGroupIndividual: []
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
dimensionGetForm = (payload) => {
|
dimensionGetForm = (payload) => {
|
||||||
dimensionGetForm(payload).then(({ status, data }) => {
|
dimensionGetForm(payload).then(({ status, data }) => {
|
||||||
if (status) {
|
if (status) {
|
||||||
const { baseForm: { data: formData } } = data;
|
const { baseForm: { data: formData } } = data;
|
||||||
const fields = _.map(this.props.condition[0].items, it => {
|
const setting = JSON.parse(formData.setting);
|
||||||
return it.domkey[0];
|
|
||||||
});
|
|
||||||
fields.map(item => {
|
|
||||||
if (item !== "setting4Qualitative") {
|
|
||||||
this.props.form.updateFields({
|
|
||||||
[item]: formData[item] || ""
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.props.form.updateFields({
|
|
||||||
setting4Qualitative: formData.statsDim
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.props.onChangeCondition(formData["dimType"], 1);
|
this.props.onChangeCondition(formData["dimType"], 1);
|
||||||
|
this.setState({
|
||||||
|
dimType: formData.dimType,
|
||||||
|
[keyObj[formData["dimType"]]]: setting
|
||||||
|
}, () => {
|
||||||
|
const fields = _.map(this.props.condition[0].items, it => {
|
||||||
|
return it.domkey[0];
|
||||||
|
});
|
||||||
|
fields.map(item => {
|
||||||
|
if (item !== "setting4Qualitative") {
|
||||||
|
this.props.form.updateFields({
|
||||||
|
[item]: formData[item] || ""
|
||||||
|
});
|
||||||
|
} else if (item === "setting4Qualitative" && formData.statsDim) {
|
||||||
|
this.props.form.updateFields({
|
||||||
|
setting4Qualitative: formData.statsDim
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
handleSave = () => {
|
handleSave = () => {
|
||||||
|
const { dimType } = this.state;
|
||||||
const { condition, onCancel, formId } = this.props;
|
const { condition, onCancel, formId } = this.props;
|
||||||
this.props.form.validateForm().then(f => {
|
const { setting4Qualitative, dimCode, ...extraParams } = this.props.form.getFormParams();
|
||||||
console.log(f);
|
let payload = { id: formId, ...extraParams };
|
||||||
console.log(this.props.form.getFormParams());
|
if (dimType === "QUALITATIVE") {
|
||||||
if (f.isValid) {
|
if (!setting4Qualitative || !extraParams.dimName) {
|
||||||
console.log(this.props.form.getFormParams());
|
Modal.warning({
|
||||||
|
title: "信息确认",
|
||||||
|
content: "必要信息不完整,红色*为必填项!"
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
const { setting4Qualitative, ...extraParams } = this.props.form.getFormParams();
|
|
||||||
const options = _.find(condition[0].items, item => item.domkey[0] === "setting4Qualitative").options;
|
|
||||||
const obj = _.find(options, item => item.key === setting4Qualitative);
|
|
||||||
const payload = {
|
|
||||||
id: formId,
|
|
||||||
...extraParams,
|
|
||||||
setting4Qualitative: { id: obj.key, name: obj.showname }
|
|
||||||
};
|
|
||||||
this.setState({ loading: true });
|
|
||||||
dimensionSave(payload).then(({ status, errormsg }) => {
|
|
||||||
this.setState({ loading: false });
|
|
||||||
if (status) {
|
|
||||||
message.success("保存成功");
|
|
||||||
onCancel(true);
|
|
||||||
this.props.form.resetForm();
|
|
||||||
} else {
|
|
||||||
message.error(errormsg || "保存失败");
|
|
||||||
}
|
|
||||||
}).catch(() => this.setState({ loading: false }));
|
|
||||||
} else {
|
|
||||||
f.showErrors();
|
|
||||||
this.setState({ date: new Date() });
|
|
||||||
}
|
}
|
||||||
});
|
const tjOptions = _.find(condition[0].items, item => item.domkey[0] === "setting4Qualitative").options;
|
||||||
|
const tjObj = _.find(tjOptions, item => item.key === setting4Qualitative);
|
||||||
|
payload = { ...payload, setting4Qualitative: { id: tjObj.key, name: tjObj.showname } };
|
||||||
|
} else {
|
||||||
|
if (!extraParams.dimName) {
|
||||||
|
Modal.warning({
|
||||||
|
title: "信息确认",
|
||||||
|
content: "必要信息不完整,红色*为必填项!"
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (dimType === "RATION_GROUP_SPACING") {
|
||||||
|
const { setting4RationGroupSpacing } = this.state;
|
||||||
|
const bool = _.every(setting4RationGroupSpacing, it => it.startValue !== "" && it.endValue !== "" && it.startValue <= it.endValue);
|
||||||
|
if (_.isEmpty(setting4RationGroupSpacing) || !bool) {
|
||||||
|
message.warning("请完善分组设置相关数据!分组设置不能为空,起始值结束值必填,且起始值需小于结束值!");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
payload = {
|
||||||
|
...payload, dimCode,
|
||||||
|
setting4RationGroupSpacing: _.map(setting4RationGroupSpacing, (it, index) => ({
|
||||||
|
id: index + 1,
|
||||||
|
endValue: it.endValue,
|
||||||
|
startValue: it.startValue,
|
||||||
|
includeEnd: it.includeEnd === "1",
|
||||||
|
includeStart: it.includeStart === "1"
|
||||||
|
}))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} else if (dimType === "RATION_GROUP_INDIVIDUAL") {
|
||||||
|
const { setting4RationGroupIndividual } = this.state;
|
||||||
|
const bool = _.every(setting4RationGroupIndividual, it => it.value !== "");
|
||||||
|
if (_.isEmpty(setting4RationGroupIndividual) || !bool) {
|
||||||
|
message.warning("请完善分组设置相关数据!分组设置不能为空,且数值必填");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
payload = {
|
||||||
|
...payload, dimCode,
|
||||||
|
setting4RationGroupIndividual: _.map(setting4RationGroupIndividual, (it, index) => ({ id: index + 1, ...it }))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.setState({ loading: true });
|
||||||
|
dimensionSave(payload).then(({ status, errormsg }) => {
|
||||||
|
this.setState({ loading: false });
|
||||||
|
if (status) {
|
||||||
|
message.success("保存成功");
|
||||||
|
onCancel(true);
|
||||||
|
this.props.form.resetForm();
|
||||||
|
} else {
|
||||||
|
message.error(errormsg || "保存失败");
|
||||||
|
}
|
||||||
|
}).catch(() => this.setState({ loading: false }));
|
||||||
};
|
};
|
||||||
formItemChange = (formObj) => {
|
formItemChange = (formObj) => {
|
||||||
const { onChangeCondition } = this.props;
|
const { onChangeCondition } = this.props;
|
||||||
const filedKey = _.keys(formObj)[0];
|
const filedKey = _.keys(formObj)[0];
|
||||||
if (filedKey === "dimType") onChangeCondition(formObj[filedKey].value);
|
if (filedKey === "dimType") {
|
||||||
|
this.setState({
|
||||||
|
dimType: formObj[filedKey].value,
|
||||||
|
setting4RationGroupSpacing: [],
|
||||||
|
setting4RationGroupIndividual: []
|
||||||
|
}, () => onChangeCondition(formObj[filedKey].value));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
handleConvertGroupDatasource = (data) => {
|
||||||
|
const { dimType } = this.state;
|
||||||
|
this.setState({ [keyObj[dimType]]: data });
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { loading } = this.state;
|
const { loading, dimType, setting4RationGroupSpacing, setting4RationGroupIndividual } = this.state;
|
||||||
const { form, condition } = this.props;
|
const { form, condition } = this.props;
|
||||||
return (
|
return (
|
||||||
<WeaDialog
|
<WeaDialog
|
||||||
|
|
@ -113,6 +181,21 @@ class DimensionSlide extends Component {
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{getSearchs(form, condition, 1, false, this.formItemChange)}
|
{getSearchs(form, condition, 1, false, this.formItemChange)}
|
||||||
|
{
|
||||||
|
dimType !== "QUALITATIVE" &&
|
||||||
|
<WeaSearchGroup title="分组设置" showGroup>
|
||||||
|
{
|
||||||
|
dimType === "RATION_GROUP_SPACING" &&
|
||||||
|
<GroupSpacingEditTable onChange={this.handleConvertGroupDatasource}
|
||||||
|
setting4RationGroupSpacing={setting4RationGroupSpacing}/>
|
||||||
|
}
|
||||||
|
{
|
||||||
|
dimType === "RATION_GROUP_INDIVIDUAL" &&
|
||||||
|
<GroupIndividualEditTable onChange={this.handleConvertGroupDatasource}
|
||||||
|
setting4RationGroupIndividual={setting4RationGroupIndividual}/>
|
||||||
|
}
|
||||||
|
</WeaSearchGroup>
|
||||||
|
}
|
||||||
</WeaDialog>
|
</WeaDialog>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* Author: 黎永顺
|
||||||
|
* name: 分组设置-定量-单项式分组编辑表格
|
||||||
|
* Description:
|
||||||
|
* Date: 2023/4/12
|
||||||
|
*/
|
||||||
|
import React, { Component } from "react";
|
||||||
|
import { WeaTableEdit } from "ecCom";
|
||||||
|
|
||||||
|
class GroupIndividualEditTable extends Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
dataSource: []
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
const { setting4RationGroupIndividual } = this.props;
|
||||||
|
this.setState({
|
||||||
|
dataSource: setting4RationGroupIndividual
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
handleChangeTableData = (dataSource) => {
|
||||||
|
const { onChange } = this.props;
|
||||||
|
this.setState({ dataSource }, () => onChange(this.state.dataSource));
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { dataSource } = this.state;
|
||||||
|
const columns = [
|
||||||
|
{
|
||||||
|
title: "分组设置值",
|
||||||
|
dataIndex: "value",
|
||||||
|
key: "value",
|
||||||
|
com: [
|
||||||
|
{ label: "", key: "value", type: "INPUTNUMBER" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
return (
|
||||||
|
<WeaTableEdit
|
||||||
|
draggable={true} columns={columns} datas={dataSource}
|
||||||
|
showCopy={false} deleteConfirm onChange={this.handleChangeTableData}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default GroupIndividualEditTable;
|
||||||
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*
|
||||||
|
* Author: 黎永顺
|
||||||
|
* name: 分组设置-定量-组距式分组编辑表格
|
||||||
|
* Description:
|
||||||
|
* Date: 2023/4/12
|
||||||
|
*/
|
||||||
|
import React, { Component } from "react";
|
||||||
|
import { WeaTableEdit } from "ecCom";
|
||||||
|
|
||||||
|
class GroupSpacingEditTable extends Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
dataSource: []
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
const { setting4RationGroupSpacing } = this.props;
|
||||||
|
this.setState({
|
||||||
|
dataSource: _.map(setting4RationGroupSpacing, item => {
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
includeStart: item.includeStart ? "1" : "0",
|
||||||
|
includeEnd: item.includeEnd ? "1" : "0"
|
||||||
|
};
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
handleChangeTableData = (dataSource) => {
|
||||||
|
const { onChange } = this.props;
|
||||||
|
this.setState({ dataSource }, () => onChange(this.state.dataSource));
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { dataSource } = this.state;
|
||||||
|
const columns = [
|
||||||
|
{
|
||||||
|
title: "起始值",
|
||||||
|
dataIndex: "startValue",
|
||||||
|
key: "startValue",
|
||||||
|
com: [
|
||||||
|
{ label: "", key: "startValue", type: "INPUTNUMBER" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "含",
|
||||||
|
dataIndex: "includeStart",
|
||||||
|
key: "includeStart",
|
||||||
|
com: [
|
||||||
|
{
|
||||||
|
type: "CHECKBOX",
|
||||||
|
key: "includeStart",
|
||||||
|
otherParams: { content: "含" }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "至",
|
||||||
|
dataIndex: "to",
|
||||||
|
key: "to",
|
||||||
|
com: [
|
||||||
|
{ label: "", type: "TEXT" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "结束值",
|
||||||
|
dataIndex: "endValue",
|
||||||
|
key: "endValue",
|
||||||
|
com: [
|
||||||
|
{ label: "", key: "endValue", type: "INPUTNUMBER" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "含",
|
||||||
|
dataIndex: "includeEnd",
|
||||||
|
key: "includeEnd",
|
||||||
|
com: [
|
||||||
|
{
|
||||||
|
type: "CHECKBOX",
|
||||||
|
key: "includeEnd",
|
||||||
|
otherParams: { content: "含" }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
return (
|
||||||
|
<WeaTableEdit
|
||||||
|
draggable={true} deleteConfirm columns={columns}
|
||||||
|
datas={_.map(dataSource, item => ({ ...item, to: "至" }))}
|
||||||
|
showCopy={false} onChange={this.handleChangeTableData}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default GroupSpacingEditTable;
|
||||||
|
|
@ -92,8 +92,7 @@ class Index extends Component {
|
||||||
return dimensionGetForm();
|
return dimensionGetForm();
|
||||||
};
|
};
|
||||||
handleChangeCondition = (val, viewAttr) => {
|
handleChangeCondition = (val, viewAttr) => {
|
||||||
const { attendanceStore: { statisticsForm, initStatisticsForm } } = this.props;
|
const { attendanceStore: { statisticsForm } } = this.props;
|
||||||
console.log(val);
|
|
||||||
const helpfulTitle = val === "RATION_GROUP_SPACING" ?
|
const helpfulTitle = val === "RATION_GROUP_SPACING" ?
|
||||||
"例:\n" +
|
"例:\n" +
|
||||||
" 若:所属字段为【工龄】,分组设置为【0-5】,【5-10】;统计项为【税前薪资】,对应的统计规则为【求和】; 则统计结果为:【工龄】为【0-5】的所有人的【税前薪资】求和,【工龄】为【5-10】的所有人的【税前薪资】求和;\n" +
|
" 若:所属字段为【工龄】,分组设置为【0-5】,【5-10】;统计项为【税前薪资】,对应的统计规则为【求和】; 则统计结果为:【工龄】为【0-5】的所有人的【税前薪资】求和,【工龄】为【5-10】的所有人的【税前薪资】求和;\n" +
|
||||||
|
|
@ -117,7 +116,7 @@ class Index extends Component {
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
}, () => {
|
}, () => {
|
||||||
initStatisticsForm(this.state.conditions);
|
statisticsForm.setCondition(this.state.conditions);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
|
@ -135,8 +134,7 @@ class Index extends Component {
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
}, () => {
|
}, () => {
|
||||||
initStatisticsForm(this.state.conditions);
|
statisticsForm.setCondition(this.state.conditions);
|
||||||
// statisticsForm.initFormFields(this.state.conditions);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { action, observable } from "mobx";
|
import { observable } from "mobx";
|
||||||
import { WeaForm } from "comsMobx";
|
import { WeaForm } from "comsMobx";
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -7,11 +7,4 @@ export class AttendanceStore {
|
||||||
@observable refenceform = new WeaForm();
|
@observable refenceform = new WeaForm();
|
||||||
//薪酬统计 新增form
|
//薪酬统计 新增form
|
||||||
@observable statisticsForm = new WeaForm();
|
@observable statisticsForm = new WeaForm();
|
||||||
|
|
||||||
@action
|
|
||||||
initStatisticsForm = (condition) => {
|
|
||||||
this.statisticsForm && this.statisticsForm.updateIsFormInit(false);
|
|
||||||
this.statisticsForm = new WeaForm();
|
|
||||||
this.statisticsForm.setCondition(condition, true);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue