2023-04-23 11:28:18 +08:00
|
|
|
/*
|
|
|
|
|
* Author: 黎永顺
|
|
|
|
|
* name: 统计数据范围及规则设置
|
|
|
|
|
* Description:
|
|
|
|
|
* Date: 2023/4/21
|
|
|
|
|
*/
|
|
|
|
|
import React, { Component } from "react";
|
|
|
|
|
import { toJS } from "mobx";
|
|
|
|
|
import {
|
|
|
|
|
WeaButtonIcon,
|
|
|
|
|
WeaError,
|
|
|
|
|
WeaFormItem,
|
|
|
|
|
WeaHelpfulTip,
|
|
|
|
|
WeaLocaleProvider,
|
|
|
|
|
WeaRangePicker,
|
|
|
|
|
WeaSearchGroup,
|
|
|
|
|
WeaSelect,
|
|
|
|
|
WeaSlideModal,
|
|
|
|
|
WeaTable
|
|
|
|
|
} from "ecCom";
|
|
|
|
|
import CustomStatisticsItemsModal from "./customStatisticsItemsModal";
|
|
|
|
|
import moment from "moment";
|
2023-04-24 09:28:25 +08:00
|
|
|
import { Button, message, Modal } from "antd";
|
2023-04-23 11:28:18 +08:00
|
|
|
import { condition } from "./condition";
|
|
|
|
|
import { getSearchs } from "../../../util";
|
2023-04-24 09:28:25 +08:00
|
|
|
import {
|
2023-04-24 16:25:07 +08:00
|
|
|
reportStatisticsGetSearchCondition,
|
2023-04-24 09:28:25 +08:00
|
|
|
reportStatisticsItemDelete,
|
2023-04-24 16:25:07 +08:00
|
|
|
reportStatisticsSaveSearchCondition,
|
2023-04-24 09:28:25 +08:00
|
|
|
statisticsItemList
|
|
|
|
|
} from "../../../apis/statistics";
|
|
|
|
|
import { commonEnumList } from "../../../apis/ruleconfig";
|
2023-04-23 11:28:18 +08:00
|
|
|
import "../index.less";
|
|
|
|
|
|
|
|
|
|
const { getLabel } = WeaLocaleProvider;
|
|
|
|
|
|
|
|
|
|
class StatisticalMicroSettingsSlide extends Component {
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
this.state = {
|
|
|
|
|
loading: false,
|
|
|
|
|
selectedRowKeys: [],
|
|
|
|
|
conditions: [],
|
2023-04-24 09:28:25 +08:00
|
|
|
dataSource: [],
|
|
|
|
|
unitTypeList: [],
|
|
|
|
|
salaryMonth: [],
|
2023-04-23 11:28:18 +08:00
|
|
|
statisticalItemPayload: {
|
2023-04-24 09:28:25 +08:00
|
|
|
visible: false, id: "", dimension: "",
|
|
|
|
|
statisticsItemId: ""
|
2023-04-23 11:28:18 +08:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentWillReceiveProps(nextProps, nextContext) {
|
|
|
|
|
if (nextProps.taxAgentAdminOption !== this.props.taxAgentAdminOption && !_.isEmpty(nextProps.taxAgentAdminOption)) {
|
|
|
|
|
const conditions = _.map(condition, item => {
|
|
|
|
|
return {
|
|
|
|
|
...item,
|
|
|
|
|
items: _.map(item.items, child => {
|
|
|
|
|
if (child.domkey[0] === "taxAgent") {
|
|
|
|
|
return {
|
|
|
|
|
...child,
|
|
|
|
|
options: toJS(nextProps.taxAgentAdminOption)
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return { ...child };
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
this.setState({ conditions });
|
|
|
|
|
nextProps.form.initFormFields(condition);
|
|
|
|
|
}
|
2023-04-24 09:28:25 +08:00
|
|
|
if (nextProps.id !== this.props.id && !_.isEmpty(nextProps.id)) {
|
2023-04-24 16:25:07 +08:00
|
|
|
this.reportStatisticsGetSearchCondition(nextProps.id);
|
2023-04-24 09:28:25 +08:00
|
|
|
this.statisticsItemList(nextProps.id).then(r => {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (nextProps.visible !== this.props.visible && !nextProps.visible) {
|
|
|
|
|
nextProps.form.resetForm();
|
|
|
|
|
this.setState({ selectedRowKeys: [] });
|
|
|
|
|
}
|
2023-04-23 11:28:18 +08:00
|
|
|
}
|
|
|
|
|
|
2023-04-24 16:25:07 +08:00
|
|
|
reportStatisticsGetSearchCondition = (id) => {
|
|
|
|
|
const { conditions } = this.state;
|
|
|
|
|
const { form } = this.props;
|
|
|
|
|
reportStatisticsGetSearchCondition({ id }).then(({ status, data }) => {
|
|
|
|
|
if (status && !_.isEmpty(data)) {
|
|
|
|
|
const { salaryEndMonth, salaryStartMonth, ...formData } = data.data;
|
|
|
|
|
this.setState({
|
|
|
|
|
salaryMonth: [salaryStartMonth || moment().startOf("year").format("YYYY-MM"), salaryEndMonth || moment().format("YYYY-MM")]
|
|
|
|
|
});
|
|
|
|
|
const fields = _.map(conditions[0].items, it => it.domkey[0]);
|
|
|
|
|
fields.map(item => {
|
|
|
|
|
const value = item.indexOf("hiredate") !== -1 ? {
|
|
|
|
|
value: formData["hiredate"] || []
|
|
|
|
|
} : {
|
|
|
|
|
value: !_.isNil(formData[item]) ? _.map(formData[item], val => val.id).join(",") : "",
|
|
|
|
|
valueSpan: !_.isNil(formData[item]) ? _.map(formData[item], val => val.name).join(",") : "",
|
|
|
|
|
valueObj: !_.isNil(formData[item]) ? formData[item] : []
|
|
|
|
|
};
|
|
|
|
|
const key = item.indexOf("hiredate") !== -1 ? "hiredate1__hiredate2" : item;
|
|
|
|
|
form.updateFields({
|
|
|
|
|
[key]: value
|
|
|
|
|
});
|
|
|
|
|
});
|
2023-04-24 09:28:25 +08:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
2023-04-24 16:25:07 +08:00
|
|
|
reportStatisticsSaveSearchCondition = () => {
|
2023-04-24 09:28:25 +08:00
|
|
|
const { salaryMonth, dataSource } = this.state;
|
2023-04-24 16:25:07 +08:00
|
|
|
const { form, id, dimension, onClose } = this.props;
|
2023-04-23 11:28:18 +08:00
|
|
|
const [salaryStartMonth, salaryEndMonth] = salaryMonth;
|
2023-04-24 16:25:07 +08:00
|
|
|
const { department, employee, position, subCompany, taxAgent, ...extra } = form.getFormDatas();
|
2023-04-24 09:28:25 +08:00
|
|
|
const { value, valueSpan } = taxAgent;
|
2023-04-23 11:28:18 +08:00
|
|
|
if (!salaryEndMonth && !salaryStartMonth) {
|
|
|
|
|
this.refs.weaError.showError();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const payload = {
|
|
|
|
|
dimension, id,
|
2023-04-24 16:25:07 +08:00
|
|
|
hiredate: extra["hiredate1__hiredate2"].value || [],
|
2023-04-24 09:28:25 +08:00
|
|
|
department: _.map(department.valueObj, it => ({ id: it.id, name: it.name })),
|
|
|
|
|
employee: _.map(employee.valueObj, it => ({ id: it.id, name: it.name })),
|
|
|
|
|
position: _.map(position.valueObj, it => ({ id: it.id, name: it.name })),
|
|
|
|
|
subCompany: _.map(subCompany.valueObj, it => ({ id: it.id, name: it.name })),
|
|
|
|
|
taxAgent: value ? _.map(value.split(","), (it, idx) => ({ id: it, name: valueSpan.split(",")[idx] })) : [],
|
|
|
|
|
items: dataSource,
|
2023-04-24 16:25:07 +08:00
|
|
|
salaryEndMonth: salaryEndMonth + "-01",
|
|
|
|
|
salaryStartMonth: salaryStartMonth + "-01"
|
2023-04-23 11:28:18 +08:00
|
|
|
};
|
|
|
|
|
this.setState({ loading: true });
|
2023-04-24 16:25:07 +08:00
|
|
|
reportStatisticsSaveSearchCondition(payload).then(({ status, errormsg }) => {
|
2023-04-23 11:28:18 +08:00
|
|
|
this.setState({ loading: false });
|
2023-04-24 09:28:25 +08:00
|
|
|
if (status) {
|
2023-04-24 16:25:07 +08:00
|
|
|
onClose(true);
|
2023-04-24 09:28:25 +08:00
|
|
|
message.success(getLabel(111, "保存成功"));
|
|
|
|
|
} else {
|
|
|
|
|
message.error(errormsg);
|
|
|
|
|
}
|
2023-04-23 11:28:18 +08:00
|
|
|
}).catch(() => this.setState({ loading: false }));
|
|
|
|
|
};
|
2023-04-24 09:28:25 +08:00
|
|
|
reportStatisticsItemDelete = () => {
|
|
|
|
|
Modal.confirm({
|
|
|
|
|
title: getLabel(111, "信息确认"),
|
|
|
|
|
content: getLabel(111, "确认要删除吗?"),
|
|
|
|
|
onOk: () => {
|
|
|
|
|
const { selectedRowKeys } = this.state;
|
|
|
|
|
reportStatisticsItemDelete(selectedRowKeys).then(({ status, errormsg }) => {
|
|
|
|
|
if (status) {
|
|
|
|
|
message.success(getLabel(111, "删除成功"));
|
|
|
|
|
this.setState({
|
|
|
|
|
selectedRowKeys: []
|
|
|
|
|
}, () => {
|
|
|
|
|
this.statisticsItemList(this.props.id).then(r => {
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
message.error(errormsg || getLabel(111, "删除失败"));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
statisticsItemList = async (statisticsReportId = "") => {
|
|
|
|
|
const { data: unitTypeList } = await this.commonEnumList();
|
|
|
|
|
statisticsItemList({ statisticsReportId }).then(({ status, data }) => {
|
|
|
|
|
if (status) {
|
|
|
|
|
this.setState({
|
|
|
|
|
dataSource: data,
|
|
|
|
|
unitTypeList: _.map(unitTypeList, it => ({ key: it.value.toString(), showname: it.defaultLabel }))
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
commonEnumList = () => {
|
|
|
|
|
const payload = {
|
|
|
|
|
enumClass: "com.engine.salary.report.enums.UnitTypeEnum"
|
|
|
|
|
};
|
|
|
|
|
return commonEnumList(payload);
|
|
|
|
|
};
|
2023-04-23 11:28:18 +08:00
|
|
|
renderGroupTitle = () => {
|
|
|
|
|
return <div className="groupTitleWrapper">
|
|
|
|
|
<span>{getLabel(111, "统计数据范围")}</span>
|
|
|
|
|
<span>{getLabel(111, "统计满足以下所有条件的人员薪资核算数据,不选则默认为选择全部")}</span>
|
|
|
|
|
</div>;
|
|
|
|
|
};
|
|
|
|
|
renderProjectTitle = () => {
|
2023-04-24 09:28:25 +08:00
|
|
|
const { selectedRowKeys } = this.state;
|
2023-04-23 11:28:18 +08:00
|
|
|
const { id, dimension } = this.props;
|
|
|
|
|
return <div className="groupPorjectTitleWrapper">
|
|
|
|
|
<div>
|
|
|
|
|
<span>{getLabel(111, "统计项目")}</span>
|
|
|
|
|
<WeaHelpfulTip width={200} placement="topLeft"
|
|
|
|
|
title={getLabel(111, "统计列表的统计项排序与本列表统计项的顺序一致")}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
2023-04-24 09:28:25 +08:00
|
|
|
<WeaButtonIcon
|
|
|
|
|
buttonType="del" type="primary" disabled={_.isEmpty(selectedRowKeys)}
|
|
|
|
|
onClick={this.reportStatisticsItemDelete}
|
|
|
|
|
/>
|
2023-04-23 11:28:18 +08:00
|
|
|
<WeaButtonIcon
|
|
|
|
|
buttonType="add" type="primary"
|
|
|
|
|
onClick={() => this.setState({
|
2023-04-24 09:28:25 +08:00
|
|
|
statisticalItemPayload: {
|
|
|
|
|
visible: true, id, dimension,
|
|
|
|
|
statisticsItemId: ""
|
|
|
|
|
}
|
2023-04-23 11:28:18 +08:00
|
|
|
})}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
render() {
|
2023-04-24 09:28:25 +08:00
|
|
|
const {
|
|
|
|
|
salaryMonth, conditions, selectedRowKeys, loading,
|
|
|
|
|
statisticalItemPayload, dataSource, unitTypeList
|
|
|
|
|
} = this.state;
|
|
|
|
|
const { id, dimension } = this.props;
|
2023-04-23 11:28:18 +08:00
|
|
|
const columns = [
|
|
|
|
|
{
|
|
|
|
|
title: "统计项名称",
|
2023-04-24 09:28:25 +08:00
|
|
|
dataIndex: "itemName",
|
|
|
|
|
render: (txt, record) => {
|
|
|
|
|
return (
|
|
|
|
|
<a href="javascript: void(0);" onClick={() => this.setState({
|
|
|
|
|
statisticalItemPayload: { visible: true, id, dimension, statisticsItemId: record.id }
|
|
|
|
|
})}>{txt}</a>
|
|
|
|
|
);
|
|
|
|
|
}
|
2023-04-23 11:28:18 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: "统计单位",
|
|
|
|
|
dataIndex: "unitType",
|
2023-04-24 09:28:25 +08:00
|
|
|
render: (txt, record) => {
|
|
|
|
|
return <WeaSelect
|
|
|
|
|
value={!_.isNil(txt) ? txt.toString() : ""} options={unitTypeList} style={{ width: 150 }}
|
|
|
|
|
onChange={unitType => this.customStatisticsItemsRef.reportStatisticsItemSave({ id: record.id, unitType })}
|
|
|
|
|
/>;
|
2023-04-23 11:28:18 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
const rowSelection = {
|
|
|
|
|
selectedRowKeys,
|
|
|
|
|
onChange: (selectedRowKeys) => {
|
2023-04-24 09:28:25 +08:00
|
|
|
this.setState({ selectedRowKeys });
|
2023-04-23 11:28:18 +08:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
return (
|
|
|
|
|
<WeaSlideModal
|
|
|
|
|
className="microSlideWrapper"
|
|
|
|
|
{...this.props}
|
2023-04-24 16:25:07 +08:00
|
|
|
onClose={() => this.props.onClose()}
|
2023-04-23 11:28:18 +08:00
|
|
|
top={0}
|
|
|
|
|
measureT="%"
|
|
|
|
|
width={800}
|
|
|
|
|
measureX="px"
|
|
|
|
|
height={100}
|
|
|
|
|
measureY="%"
|
|
|
|
|
direction={"right"}
|
2023-04-24 16:25:07 +08:00
|
|
|
title={<TitleDialog loading={loading} onSave={this.reportStatisticsSaveSearchCondition}/>}
|
2023-04-23 11:28:18 +08:00
|
|
|
content={
|
|
|
|
|
<React.Fragment>
|
|
|
|
|
<WeaSearchGroup title={getLabel(111, "统计时间范围")} col={2} showGroup needTigger>
|
|
|
|
|
<WeaFormItem label={getLabel(111, "薪资所属月")} labelCol={{ span: 8 }} wrapperCol={{ span: 16 }}>
|
|
|
|
|
<WeaError tipPosition="bottom" ref="weaError" error={getLabel(111, "此项必填")}>
|
|
|
|
|
<WeaRangePicker
|
|
|
|
|
value={salaryMonth} viewAttr={3} format="YYYY-MM"
|
|
|
|
|
onChange={v => this.setState({ salaryMonth: v })}
|
|
|
|
|
/>
|
|
|
|
|
</WeaError>
|
|
|
|
|
</WeaFormItem>
|
|
|
|
|
</WeaSearchGroup>
|
|
|
|
|
{
|
|
|
|
|
getSearchs(this.props.form, conditions, 2, false, () => {
|
|
|
|
|
}, this.renderGroupTitle())
|
|
|
|
|
}
|
|
|
|
|
<WeaSearchGroup title={this.renderProjectTitle()} showGroup needTigger>
|
|
|
|
|
<WeaTable
|
2023-04-24 09:28:25 +08:00
|
|
|
rowKey="id"
|
2023-04-23 11:28:18 +08:00
|
|
|
columns={columns}
|
2023-04-24 09:28:25 +08:00
|
|
|
dataSource={dataSource}
|
2023-04-23 11:28:18 +08:00
|
|
|
draggable={true}
|
2023-04-24 18:30:47 +08:00
|
|
|
onDrop={datas => this.setState({
|
|
|
|
|
dataSource: _.map(datas, (it, idx) => ({ ...it, indexValue: idx.toString() }))
|
|
|
|
|
})}
|
2023-04-23 11:28:18 +08:00
|
|
|
pagination={false}
|
|
|
|
|
rowSelection={rowSelection}
|
|
|
|
|
/>
|
2023-04-24 09:28:25 +08:00
|
|
|
<CustomStatisticsItemsModal
|
|
|
|
|
ref={dom => this.customStatisticsItemsRef = dom}
|
|
|
|
|
{...statisticalItemPayload}
|
|
|
|
|
onCancel={(isRefresh) => this.setState({
|
|
|
|
|
statisticalItemPayload: {
|
|
|
|
|
visible: false,
|
|
|
|
|
id: "",
|
|
|
|
|
dimension: "",
|
|
|
|
|
statisticsItemId: ""
|
|
|
|
|
}
|
|
|
|
|
}, () => isRefresh && this.statisticsItemList(this.props.id))}
|
2023-04-23 11:28:18 +08:00
|
|
|
/>
|
|
|
|
|
</WeaSearchGroup>
|
|
|
|
|
</React.Fragment>
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default StatisticalMicroSettingsSlide;
|
|
|
|
|
const TitleDialog = (props) => {
|
|
|
|
|
return <div className="titleDialog">
|
|
|
|
|
<div className="titleCol">
|
|
|
|
|
<div className="titleLeftBox">
|
|
|
|
|
<div className="titleIcon"><i className="icon-coms-fa"/></div>
|
|
|
|
|
<div className="title">{getLabel(111, "统计数据范围及规则设置")}</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="titleCol titleRightBox">
|
|
|
|
|
<Button type="primary" loading={props.loading} onClick={props.onSave}>{getLabel(111, "保存")}</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>;
|
|
|
|
|
};
|