2024-01-12 14:49:24 +08:00
|
|
|
/*
|
|
|
|
|
* Author: 黎永顺
|
2024-01-12 14:49:57 +08:00
|
|
|
* name: 薪资档案页面重构-薪资档案编辑与查看
|
2024-01-12 14:49:24 +08:00
|
|
|
* Description:
|
2024-01-12 14:49:57 +08:00
|
|
|
* Date: 2024/1/11
|
2024-01-12 14:49:24 +08:00
|
|
|
*/
|
|
|
|
|
import React, { Component } from "react";
|
|
|
|
|
import { inject, observer } from "mobx-react";
|
2024-01-15 18:18:26 +08:00
|
|
|
import { WeaLocaleProvider, WeaSearchGroup, WeaSlideModal, WeaTools } from "ecCom";
|
|
|
|
|
import { Button, message, Modal } from "antd";
|
|
|
|
|
import { renderSalaryFilesForm } from "./form";
|
|
|
|
|
import { salaryFilesConditions } from "../../config";
|
|
|
|
|
import { getConditionDomkeys, toDecimal_n } from "../../../../util";
|
|
|
|
|
import * as API from "../../../../apis/archive";
|
|
|
|
|
import { savePaySet } from "../../../../apis/payrollFiles";
|
|
|
|
|
import SalaryItemChangeList from "../../../salaryFile/salaryItemChangeList";
|
|
|
|
|
import SalaryArchiveEditAdjLogRecord from "../../../salaryFile/salaryArchiveEditAdjLogRecord";
|
2024-01-12 14:49:24 +08:00
|
|
|
|
|
|
|
|
const getKey = WeaTools.getKey;
|
|
|
|
|
const getLabel = WeaLocaleProvider.getLabel;
|
|
|
|
|
|
2024-01-12 14:49:57 +08:00
|
|
|
@inject("payrollFilesStore")
|
2024-01-12 14:49:24 +08:00
|
|
|
@observer
|
|
|
|
|
class Index extends Component {
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
this.state = {
|
2024-01-15 18:18:26 +08:00
|
|
|
loading: false, conditions: [], formData: {}, salaryAdjustmentInfo: {},
|
|
|
|
|
salaryArchiveItems: [], //薪资档案项目
|
|
|
|
|
adjLogRecordDialog: { //薪资档案-调薪
|
|
|
|
|
visible: false, title: "", salaryArchiveId: ""
|
|
|
|
|
}
|
2024-01-12 14:49:24 +08:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentWillReceiveProps(nextProps, nextContext) {
|
|
|
|
|
if (nextProps.visible !== this.props.visible && nextProps.visible) {
|
2024-01-12 14:49:57 +08:00
|
|
|
document.querySelector(".salary-files-wrapper").classList.add("zIndex0-welfare-archive");
|
2024-01-15 18:18:26 +08:00
|
|
|
this.getArchiveForm(nextProps);
|
2024-01-12 14:49:24 +08:00
|
|
|
} else if (nextProps.visible !== this.props.visible && !nextProps.visible) {
|
2024-01-12 14:49:57 +08:00
|
|
|
document.querySelector(".salary-files-wrapper").classList.remove("zIndex0-welfare-archive");
|
2024-01-16 09:28:37 +08:00
|
|
|
nextProps.payrollFilesStore.initSalaryFileForm();
|
2024-01-12 14:49:24 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-15 18:18:26 +08:00
|
|
|
getArchiveForm = async (props) => {
|
|
|
|
|
const { payrollFilesStore: { salaryFileForm }, salaryArchiveId, runStatuses, showOperateBtn } = props;
|
|
|
|
|
const { data: salaryAdjustmentInfo } = (runStatuses === "fixed") ? await API.salaryAdjustmentInfo() : { data: {} };
|
|
|
|
|
const payload = { salaryArchiveId };
|
|
|
|
|
API.getArchiveForm(payload).then(({ status, data }) => {
|
|
|
|
|
if (status) {
|
|
|
|
|
const { baseInfo: { employee }, paySet: { data: paySetData }, adjustSalaryItems = [] } = data;
|
|
|
|
|
const adjustSalaryItemsFormData = _.reduce(adjustSalaryItems, (pre, cur) => ({
|
|
|
|
|
...pre, [cur["id"]]: cur["value"]
|
|
|
|
|
}), {});
|
|
|
|
|
const formData = { ...paySetData, ...employee, ...adjustSalaryItemsFormData };
|
|
|
|
|
this.setState({
|
|
|
|
|
salaryAdjustmentInfo,
|
|
|
|
|
salaryArchiveItems: _.map(adjustSalaryItems, o => ({
|
|
|
|
|
adjustValue: o.value, salaryItemId: o.id, pattern: o.pattern, dataType: o.dataType
|
|
|
|
|
})),
|
|
|
|
|
conditions: _.map(salaryFilesConditions, o => {
|
|
|
|
|
if (o.salaryFile) {
|
|
|
|
|
return {
|
|
|
|
|
...o, items: _.map(adjustSalaryItems, g => {
|
|
|
|
|
const otherParams = g.dataType === "number" ? { precision: g.pattern } : {};
|
|
|
|
|
return {
|
|
|
|
|
colSpan: 3, fieldcol: 14, label: g.name, labelcol: 10, ...otherParams,
|
|
|
|
|
conditionType: g.dataType === "number" ? "INPUTNUMBER" : "INPUT",
|
|
|
|
|
domkey: [g.id + ""], viewAttr: (runStatuses === "pending" && showOperateBtn) ? 2 : 1
|
|
|
|
|
};
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
...o, items: _.map(o.items, g => {
|
|
|
|
|
if (getKey(g) === "payStartDate") {
|
|
|
|
|
return {
|
|
|
|
|
...g, label: getLabel(g.lanId, g.label),
|
|
|
|
|
viewAttr: ((runStatuses === "pending" || runStatuses === "ext") && showOperateBtn) ? g.viewAttr : 1
|
|
|
|
|
};
|
|
|
|
|
} else if (getKey(g) === "payEndDate") {
|
|
|
|
|
return {
|
|
|
|
|
...g, label: getLabel(g.lanId, g.label),
|
|
|
|
|
viewAttr: (runStatuses === "stop" || !showOperateBtn) ? 1 : (runStatuses === "suspend" && showOperateBtn) ? 3 : g.viewAttr,
|
|
|
|
|
rules: (runStatuses === "suspend" && showOperateBtn) ? "required|string" : ""
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
...g, label: getLabel(g.lanId, g.label)
|
|
|
|
|
};
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
})
|
|
|
|
|
}, () => {
|
|
|
|
|
salaryFileForm.initFormFields(this.state.conditions);
|
|
|
|
|
_.map(getConditionDomkeys(this.state.conditions), k => {
|
|
|
|
|
salaryFileForm.updateFields({ [k]: formData[k] || "" });
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
save = async () => {
|
|
|
|
|
const { salaryArchiveItems } = this.state;
|
|
|
|
|
const {
|
|
|
|
|
payrollFilesStore: { salaryFileForm, setHasBeenModify },
|
|
|
|
|
salaryArchiveId, runStatuses
|
|
|
|
|
} = this.props;
|
|
|
|
|
const [salaryForm] = await Promise.all([salaryFileForm.validateForm()]);
|
|
|
|
|
if (salaryForm.isValid) {
|
|
|
|
|
const { payStartDate, payEndDate, ...extraParams } = salaryForm.getFormParams();
|
|
|
|
|
const payload = {
|
2024-01-26 09:57:30 +08:00
|
|
|
//status-非系统人员保存与定薪人员一样
|
|
|
|
|
salaryArchiveId, status: _.toUpper(runStatuses === "ext" ? "fixed" : runStatuses),
|
2024-01-15 18:18:26 +08:00
|
|
|
payStartDate, payEndDate,
|
|
|
|
|
salaryArchiveItems: _.map(salaryArchiveItems, o => ({
|
|
|
|
|
salaryItemId: o.salaryItemId,
|
|
|
|
|
adjustValue: (o.dataType === "number" && (extraParams[o.salaryItemId] || extraParams[o.salaryItemId] === 0)) ? toDecimal_n(extraParams[o.salaryItemId], o.pattern || 2) : extraParams[o.salaryItemId]
|
|
|
|
|
}))
|
|
|
|
|
};
|
|
|
|
|
this.setState({ loading: true });
|
|
|
|
|
savePaySet(payload).then(({ status, errormsg }) => {
|
|
|
|
|
this.setState({ loading: false });
|
|
|
|
|
if (status) {
|
|
|
|
|
setHasBeenModify(false);
|
|
|
|
|
message.success(getLabel(30700, "操作成功!"));
|
|
|
|
|
this.props.onClose(true);
|
|
|
|
|
} else {
|
|
|
|
|
message.error(errormsg);
|
|
|
|
|
}
|
|
|
|
|
}).catch(() => this.setState({ loading: false }));
|
|
|
|
|
} else {
|
|
|
|
|
salaryForm.showErrors();
|
|
|
|
|
this.forceUpdate();
|
|
|
|
|
}
|
|
|
|
|
};
|
2024-01-12 14:49:24 +08:00
|
|
|
renderTitle = () => {
|
2024-01-15 18:18:26 +08:00
|
|
|
const { loading, salaryAdjustmentInfo } = this.state, { runStatuses, showOperateBtn, salaryArchiveId } = this.props;
|
|
|
|
|
const { isShow, url } = salaryAdjustmentInfo;
|
2024-01-12 14:49:24 +08:00
|
|
|
return <div className="titleDialog">
|
|
|
|
|
<div className="titleCol titleLeftBox">
|
|
|
|
|
<div className="titleIcon"><i className="icon-coms-fa"/></div>
|
2024-01-12 14:49:57 +08:00
|
|
|
<div className="title">{getLabel(543312, "员工薪资档案")}</div>
|
2024-01-12 14:49:24 +08:00
|
|
|
</div>
|
|
|
|
|
<div className="titleCol titleRightBox">
|
|
|
|
|
{
|
2024-01-15 18:18:26 +08:00
|
|
|
runStatuses === "fixed" && showOperateBtn && isShow === "true" &&
|
|
|
|
|
<Button type="ghost" onClick={() => {
|
|
|
|
|
const linkUrl = url.indexOf("http") !== -1 ? url : `${window.location.origin}${url}`;
|
|
|
|
|
window.open(`${linkUrl}&salaryArchiveId=${salaryArchiveId}`, "_blank");
|
|
|
|
|
}}>{getLabel(543310, "发起调薪")}</Button>
|
|
|
|
|
}
|
|
|
|
|
{
|
2024-01-25 16:11:00 +08:00
|
|
|
(runStatuses === "fixed" || runStatuses === "ext") && showOperateBtn &&
|
2024-01-15 18:18:26 +08:00
|
|
|
<Button type="ghost" onClick={() => {
|
|
|
|
|
this.setState({
|
|
|
|
|
adjLogRecordDialog: {
|
|
|
|
|
...this.state.adjLogRecordDialog,
|
|
|
|
|
visible: true, title: getLabel(542686, "调薪"), salaryArchiveId
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}}>{getLabel(542686, "调薪")}</Button>
|
2024-01-12 14:49:57 +08:00
|
|
|
}
|
|
|
|
|
{
|
2024-01-15 18:18:26 +08:00
|
|
|
runStatuses !== "stop" && showOperateBtn &&
|
|
|
|
|
<Button type="primary" loading={loading} onClick={this.save}>{getLabel(537558, "保存")}</Button>
|
2024-01-12 14:49:24 +08:00
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
</div>;
|
|
|
|
|
};
|
2024-01-15 18:18:26 +08:00
|
|
|
handleClose = (visible = false) => {
|
|
|
|
|
const { payrollFilesStore: { hasBeenModify, setHasBeenModify }, onClose } = this.props;
|
2024-01-12 14:49:24 +08:00
|
|
|
if (hasBeenModify) {
|
|
|
|
|
Modal.confirm({
|
|
|
|
|
title: getLabel(131329, "信息确认"),
|
2024-01-12 14:49:57 +08:00
|
|
|
content: getLabel(545770, "确定放弃填写吗?放弃后数据将不会被保存!"),
|
2024-01-12 14:49:24 +08:00
|
|
|
onOk: () => {
|
2024-01-15 18:18:26 +08:00
|
|
|
onClose(visible);
|
|
|
|
|
setHasBeenModify(false);
|
2024-01-12 14:49:24 +08:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
2024-01-15 18:18:26 +08:00
|
|
|
onClose(visible);
|
|
|
|
|
setHasBeenModify(false);
|
2024-01-12 14:49:24 +08:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
render() {
|
2024-01-15 18:18:26 +08:00
|
|
|
const {
|
|
|
|
|
payrollFilesStore: { salaryFileForm, setHasBeenModify }, runStatuses, salaryArchiveId,
|
|
|
|
|
showOperateBtn, visible
|
|
|
|
|
} = this.props;
|
|
|
|
|
const { conditions, adjLogRecordDialog } = this.state;
|
2024-01-12 14:49:24 +08:00
|
|
|
return (
|
|
|
|
|
<WeaSlideModal
|
2024-01-12 14:49:57 +08:00
|
|
|
className="salary-files-edit-layout" {...this.props}
|
|
|
|
|
top={0} width={800} height={100} measureT="%" measureX="px" measureY="%"
|
2024-01-15 18:18:26 +08:00
|
|
|
direction={"right"} title={this.renderTitle()} onClose={() => this.handleClose(false)}
|
2024-01-12 14:49:57 +08:00
|
|
|
content={<div className="salary-files-edit-area">
|
2024-01-15 18:18:26 +08:00
|
|
|
{
|
|
|
|
|
renderSalaryFilesForm(salaryFileForm, conditions, setHasBeenModify)
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
runStatuses !== "pending" && visible &&
|
|
|
|
|
<WeaSearchGroup title={getLabel(543328, "薪资调整记录")} items={[]} needTigger showGroup>
|
|
|
|
|
<SalaryItemChangeList id={salaryArchiveId} selectedKey={runStatuses} showOperateBtn={showOperateBtn}/>
|
|
|
|
|
</WeaSearchGroup>
|
|
|
|
|
}
|
|
|
|
|
<SalaryArchiveEditAdjLogRecord
|
|
|
|
|
{...adjLogRecordDialog}
|
|
|
|
|
onCancel={() => this.setState({
|
|
|
|
|
adjLogRecordDialog: {
|
|
|
|
|
adjLogRecordDialog, visible: false, title: "", salaryArchiveId: ""
|
|
|
|
|
}
|
|
|
|
|
})}
|
|
|
|
|
/>
|
2024-01-12 14:49:24 +08:00
|
|
|
</div>}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Index;
|