240112temp2
This commit is contained in:
parent
2ae026a657
commit
12531b4ab3
|
|
@ -8,6 +8,7 @@ import React, { Component } from "react";
|
|||
import { inject, observer } from "mobx-react";
|
||||
import { WeaLoadingGlobal, WeaLocaleProvider } from "ecCom";
|
||||
import { WeaTableNew } from "comsMobx";
|
||||
import SalaryFilesEditSlide from "../salaryFilesEditSlide";
|
||||
import { toJS } from "mobx";
|
||||
import { message, Spin } from "antd";
|
||||
import * as API from "../../../../apis/payrollFiles";
|
||||
|
|
@ -37,8 +38,10 @@ class Index extends Component {
|
|||
super(props);
|
||||
this.state = {
|
||||
dataSource: [], columns: [], loading: false, selectedRowKeys: [],
|
||||
pageInfo: { current: 1, pageSize: 10, total: 0 }
|
||||
pageInfo: { current: 1, pageSize: 10, total: 0 },
|
||||
salaryFilesEditSlide: { visible: false, salaryArchiveId: "" }
|
||||
};
|
||||
this.SFSlideRef = null;
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
|
|
@ -60,7 +63,7 @@ class Index extends Component {
|
|||
if ((nextProps.selectedKey !== this.props.selectedKey)) {
|
||||
this.setState({
|
||||
dataSource: [], columns: [], loading: false, selectedRowKeys: [],
|
||||
welfareEditSlide: { ...this.state.welfareEditSlide, visible: false }
|
||||
salaryFilesEditSlide: { ...this.state.salaryFilesEditSlide, visible: false }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -95,6 +98,17 @@ class Index extends Component {
|
|||
const { interfaceParams } = params;
|
||||
this.handleSalaryOpts(_.camelCase(id), interfaceParams);
|
||||
break;
|
||||
case "CHANGE-SALARY":
|
||||
case "VIEW":
|
||||
case "EDIT":
|
||||
const { record: { id: salaryArchiveId } } = params;
|
||||
this.setState({
|
||||
salaryFilesEditSlide: {
|
||||
...this.state.salaryFilesEditSlide, visible: true, salaryArchiveId,
|
||||
runStatuses: this.props.selectedKey
|
||||
}
|
||||
});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
@ -172,7 +186,7 @@ class Index extends Component {
|
|||
};
|
||||
|
||||
render() {
|
||||
const { loading, dataSource } = this.state;
|
||||
const { loading, dataSource, salaryFilesEditSlide } = this.state;
|
||||
const { payrollFilesStore: { tableStore } } = this.props;
|
||||
const dom = document.querySelector(".wea-new-top-req-content");
|
||||
let height = 280;
|
||||
|
|
@ -195,6 +209,12 @@ class Index extends Component {
|
|||
needScroll={true}
|
||||
columns={this.getColumns()}
|
||||
/>
|
||||
{/* 编辑查看员工薪资档案*/}
|
||||
<SalaryFilesEditSlide {...salaryFilesEditSlide} ref={dom => this.SFSlideRef = dom}
|
||||
onClose={(isFresh) => this.setState({
|
||||
salaryFilesEditSlide: { ...salaryFilesEditSlide, visible: false }
|
||||
}, () => isFresh && this.getSalaryFileList(this.props))}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,18 @@
|
|||
/*
|
||||
* Author: 黎永顺
|
||||
* name:社保福利档案页面重构-查看编辑弹框
|
||||
* name: 薪资档案页面重构-薪资档案编辑与查看
|
||||
* Description:
|
||||
* Date: 2023/11/6
|
||||
* Date: 2024/1/11
|
||||
*/
|
||||
import React, { Component } from "react";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import { WeaLocaleProvider, WeaSlideModal, WeaTools } from "ecCom";
|
||||
import * as API from "../../../../../apis/welfareArchive";
|
||||
import { getTaxAgentSelectList } from "../../../../../apis/taxAgent";
|
||||
import { getWelfareSearchsForm, welfareConditions } from "../../config";
|
||||
import { getConditionDomkeys, toDecimal_n } from "../../../../../util";
|
||||
import { Button, message, Modal } from "antd";
|
||||
import { Button, Modal } from "antd";
|
||||
|
||||
const getKey = WeaTools.getKey;
|
||||
const getLabel = WeaLocaleProvider.getLabel;
|
||||
|
||||
@inject("archivesStore")
|
||||
@inject("payrollFilesStore")
|
||||
@observer
|
||||
class Index extends Component {
|
||||
constructor(props) {
|
||||
|
|
@ -28,255 +24,38 @@ class Index extends Component {
|
|||
|
||||
componentWillReceiveProps(nextProps, nextContext) {
|
||||
if (nextProps.visible !== this.props.visible && nextProps.visible) {
|
||||
document.querySelector(".salary-welfare-archive").classList.add("zIndex0-welfare-archive");
|
||||
const promise = this.getBaseForm(nextProps);
|
||||
document.querySelector(".salary-files-wrapper").classList.add("zIndex0-welfare-archive");
|
||||
} else if (nextProps.visible !== this.props.visible && !nextProps.visible) {
|
||||
const { archivesStore: { initWelfareProfileForm } } = nextProps;
|
||||
document.querySelector(".salary-welfare-archive").classList.remove("zIndex0-welfare-archive");
|
||||
initWelfareProfileForm();
|
||||
document.querySelector(".salary-files-wrapper").classList.remove("zIndex0-welfare-archive");
|
||||
}
|
||||
}
|
||||
|
||||
getBaseForm = async (props) => {
|
||||
const { data: taxAgentList } = await getTaxAgentSelectList();
|
||||
const {
|
||||
archivesStore: { welfareProfileForm }, socialBase, fundBase, otherBase, runStatuses,
|
||||
employeeId, paymentOrganization, socialBaseData, fundBaseData, othersBaseData
|
||||
} = props;
|
||||
let socialComData = {}, fundComData = {}, otherComData = {};
|
||||
if (!_.isNil(socialBase.comItems) && !_.isNil(socialBase.comData)) {
|
||||
_.forEach(getConditionDomkeys(socialBase.comItems), o => {
|
||||
socialComData = {
|
||||
...socialComData,
|
||||
[`${o}_com`]: socialBase.comData[o]
|
||||
};
|
||||
});
|
||||
}
|
||||
if (!_.isNil(fundBase.comItems) && !_.isNil(fundBase.comData)) {
|
||||
_.forEach(getConditionDomkeys(fundBase.comItems), o => {
|
||||
fundComData = {
|
||||
...fundComData,
|
||||
[`${o}_com`]: fundBase.comData[o]
|
||||
};
|
||||
});
|
||||
}
|
||||
if (!_.isNil(otherBase.comItems) && !_.isNil(otherBase.comData)) {
|
||||
_.forEach(getConditionDomkeys(otherBase.comItems), o => {
|
||||
otherComData = {
|
||||
...otherComData,
|
||||
[`${o}_com`]: otherBase.comData[o]
|
||||
};
|
||||
});
|
||||
}
|
||||
const payload = { employeeId, paymentOrganization, welfareTypeEnum: "" };
|
||||
API.getBaseForm(payload).then(({ status, data }) => {
|
||||
if (status) {
|
||||
const { data: result } = data;
|
||||
const formData = {
|
||||
...result, ...socialBaseData, ...fundBaseData, ...othersBaseData,
|
||||
...socialBase.data, ...fundBase.data, ...otherBase.data,
|
||||
...socialComData, ...fundComData, ...otherComData
|
||||
};
|
||||
this.setState({
|
||||
formData,
|
||||
conditions: _.map(welfareConditions, o => {
|
||||
if (o.title === "basic") {
|
||||
return {
|
||||
...o, title: getLabel(542699, "员工基本信息"),
|
||||
viewAttr: runStatuses === "4,5" ? 1 : o.viewAttr,
|
||||
items: _.map(o.items, g => {
|
||||
return { ...g, label: getLabel(g.lanId, g.label) };
|
||||
})
|
||||
};
|
||||
} else if (o.title === "taxAgent") {
|
||||
return {
|
||||
...o, title: getLabel(537996, "个税扣缴义务人"),
|
||||
items: _.map(o.items, g => {
|
||||
return {
|
||||
...g, label: getLabel(g.lanId, g.label),
|
||||
options: _.map(taxAgentList, j => ({ key: j.id, showname: j.content }))
|
||||
};
|
||||
})
|
||||
};
|
||||
} else if (o.title === "social" || o.title === "fund" || o.title === "others") {
|
||||
const title = o.title === "social" ? getLabel(543194, "社保基础信息") : o.title === "fund" ? getLabel(543197, "公积金基础信息") : getLabel(543198, "其他福利基础信息");
|
||||
return {
|
||||
...o, title,
|
||||
items: _.map(o.items, g => {
|
||||
if (getKey(g) === "socialSchemeId" || getKey(g) === "fundSchemeId" || getKey(g) === "otherSchemeId" || _.lowerCase(getKey(g)).indexOf("take") !== -1) {
|
||||
const key = _.lowerCase(getKey(g)).indexOf("take") !== -1 ? "underTake" : getKey(g);
|
||||
return {
|
||||
...g, label: getLabel(g.lanId, g.label),
|
||||
viewAttr: runStatuses === "4,5" ? 1 : g.viewAttr,
|
||||
options: _.find(props[`${o.title}Items`], j => j.domkey[0] === key).options
|
||||
};
|
||||
}
|
||||
return {
|
||||
...g, label: getLabel(g.lanId, g.label),
|
||||
viewAttr: runStatuses === "4,5" ? 1 : g.viewAttr
|
||||
};
|
||||
})
|
||||
};
|
||||
}
|
||||
return {
|
||||
...o, items: _.map(o.items, g => {
|
||||
return {
|
||||
...g, label: getLabel(g.lanId, g.label),
|
||||
viewAttr: runStatuses === "4,5" ? 1 : g.viewAttr
|
||||
};
|
||||
})
|
||||
};
|
||||
})
|
||||
}, () => {
|
||||
welfareProfileForm.initFormFields(this.state.conditions);
|
||||
_.map(getConditionDomkeys(this.state.conditions), k => {
|
||||
if (k === "paymentOrganization") {
|
||||
welfareProfileForm.updateFields({ [k]: paymentOrganization.toString() });
|
||||
} else if (_.lowerCase(k).indexOf("social") !== -1 || k === "schemeAccount") {
|
||||
welfareProfileForm.updateFields({ [k]: formData["SOCIAL_SECURITY"][k] ? formData["SOCIAL_SECURITY"][k].toString() : "" });
|
||||
} else if (_.lowerCase(k).indexOf("fund") !== -1) {
|
||||
welfareProfileForm.updateFields({ [k]: formData["ACCUMULATION_FUND"][k] ? formData["ACCUMULATION_FUND"][k].toString() : "" });
|
||||
} else if (_.lowerCase(k).indexOf("other") !== -1) {
|
||||
welfareProfileForm.updateFields({ [k]: formData["OTHER"][k] ? formData["OTHER"][k].toString() : "" });
|
||||
} else {
|
||||
welfareProfileForm.updateFields({ [k]: formData[k] || "" });
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
covertPayload = (welfareType, underTakeType, paymentForm, paymentComForm) => {
|
||||
const { archivesStore: { welfareProfileForm } } = this.props;
|
||||
const welfareData = welfareProfileForm.getFormParams();
|
||||
const { formData } = this.state;
|
||||
return {
|
||||
baseForm: JSON.stringify({
|
||||
...formData[welfareType], ..._.reduce(_.keys(formData[welfareType]), (pre, cur) => {
|
||||
if (welfareData[cur]) return { ...pre, [cur]: welfareData[cur] };
|
||||
return { ...pre };
|
||||
}, {}),
|
||||
underTake: welfareData[`${underTakeType}UnderTake`]
|
||||
}),
|
||||
paymentForm: !_.isEmpty(paymentForm) ? JSON.stringify(_.reduce(paymentForm, (pre, cur) => {
|
||||
if (formData[cur] || formData[cur] === 0) return { ...pre, [cur]: toDecimal_n(formData[cur], 2).toString() };
|
||||
return { ...pre, [cur]: "0" };
|
||||
}, {})) : "",
|
||||
paymentComForm: !_.isEmpty(paymentComForm) ? JSON.stringify(_.reduce(paymentComForm, (pre, cur) => {
|
||||
if (formData[`${cur}_com`] || formData[`${cur}_com`] === 0) return {
|
||||
...pre,
|
||||
[cur]: toDecimal_n(formData[`${cur}_com`], 2).toString()
|
||||
};
|
||||
return { ...pre, [cur]: "0" };
|
||||
}, {})) : "",
|
||||
welfareType, validate: welfareData[`${underTakeType}SchemeId`] ? !!welfareData[`${underTakeType}StartTime`] : true
|
||||
};
|
||||
};
|
||||
save = async () => {
|
||||
const socailPayload = this.covertPayload("SOCIAL_SECURITY", "social", getConditionDomkeys(this.props.socialBase.items), getConditionDomkeys(this.props.socialBase.comItems || [])),
|
||||
fundPayload = this.covertPayload("ACCUMULATION_FUND", "fund", getConditionDomkeys(this.props.fundBase.items), getConditionDomkeys(this.props.fundBase.comItems || [])),
|
||||
otherPayload = this.covertPayload("OTHER", "other", getConditionDomkeys(this.props.otherBase.items), getConditionDomkeys(this.props.otherBase.comItems || []));
|
||||
if (!(socailPayload.validate && fundPayload.validate && otherPayload.validate)) {
|
||||
message.warning(getLabel(111, "请维护起始缴纳月!"));
|
||||
return;
|
||||
}
|
||||
this.setState({ loading: true });
|
||||
const [{
|
||||
status: socialStatus,
|
||||
errormsg: socialErrorMsg = "!"
|
||||
}, {
|
||||
status: fundStatus,
|
||||
errormsg: fundErrorMsg = "!"
|
||||
}, {
|
||||
status: otherStatus,
|
||||
errormsg: otherErrorMsg = "!"
|
||||
}] = await Promise.all([API.save(socailPayload), API.save(fundPayload), API.save(otherPayload)]);
|
||||
this.setState({ loading: false });
|
||||
if (socialStatus && fundStatus && otherStatus) {
|
||||
message.success(getLabel(30700, "操作成功!"));
|
||||
this.props.onClose(true);
|
||||
} else {
|
||||
message.error(socialErrorMsg + fundErrorMsg + otherErrorMsg);
|
||||
}
|
||||
};
|
||||
updateFormData = (baseData) => this.setState({ formData: { ...this.state.formData, ...baseData } });
|
||||
handleFormChange = (val) => {
|
||||
const changeKey = _.keys(val)[0], changeVal = val[changeKey].value;
|
||||
const { archivesStore: { setHasBeenModify }, onChangeProgramme, employeeId, paymentOrganization } = this.props;
|
||||
setHasBeenModify(true);
|
||||
if (changeKey === "socialSchemeId" || changeKey === "fundSchemeId" || changeKey === "otherSchemeId") {
|
||||
this.setState({
|
||||
conditions: _.map(this.state.conditions, o => {
|
||||
if (
|
||||
(o.typename === "SOCIAL_SECURITY" && changeKey === "socialSchemeId") ||
|
||||
(o.typename === "ACCUMULATION_FUND" && changeKey === "fundSchemeId") ||
|
||||
(o.typename === "OTHER" && changeKey === "otherSchemeId")
|
||||
) {
|
||||
return {
|
||||
...o, items: _.map(o.items, g => {
|
||||
if (getKey(g).indexOf("StartTime") !== -1) {
|
||||
return {
|
||||
...g, viewAttr: changeVal ? 3 : g.viewAttr
|
||||
};
|
||||
}
|
||||
return { ...g };
|
||||
})
|
||||
};
|
||||
}
|
||||
return { ...o };
|
||||
})
|
||||
});
|
||||
onChangeProgramme(changeKey.slice(0, changeKey.indexOf("SchemeId")), changeVal, {
|
||||
employeeId,
|
||||
paymentOrganization
|
||||
});
|
||||
}
|
||||
};
|
||||
handleExtraChange = (key, value) => this.setState({ formData: { ...this.state.formData, [key]: value } });
|
||||
handleSameChange = (baseItems, value) => {
|
||||
let newFormDatas = {}, hasCompromise = false;
|
||||
baseItems.forEach((formLabel) => {
|
||||
const { min, max } = formLabel;
|
||||
newFormDatas[getKey(formLabel)] = toDecimal_n(value, 2) || "";
|
||||
if (min !== "0.000" && value !== "" && Number(value) < Number(min)) {
|
||||
hasCompromise = true;
|
||||
newFormDatas[getKey(formLabel)] = toDecimal_n(Number(min), 2);
|
||||
}
|
||||
if (max !== "0.000" && value !== "" && Number(value) > Number(max)) {
|
||||
hasCompromise = true;
|
||||
newFormDatas[getKey(formLabel)] = toDecimal_n(Number(max), 2);
|
||||
}
|
||||
});
|
||||
if (hasCompromise) {
|
||||
message.warning(getLabel("111", "超出所选缴纳方案设置的基数上下限范围,将自动按基数上下限填充。"));
|
||||
}
|
||||
this.setState({ formData: { ...this.state.formData, ...newFormDatas } });
|
||||
};
|
||||
handleNoPaymentChange = (type, value) => this.setState({
|
||||
formData: { ...this.state.formData, [type]: { ...this.state.formData[type], nonPayment: value } }
|
||||
});
|
||||
renderTitle = () => {
|
||||
const { loading } = this.state;
|
||||
const { runStatuses } = this.props;
|
||||
return <div className="titleDialog">
|
||||
<div className="titleCol titleLeftBox">
|
||||
<div className="titleIcon"><i className="icon-coms-fa"/></div>
|
||||
<div className="title">{getLabel(543191, "员工福利档案")}</div>
|
||||
<div className="title">{getLabel(543312, "员工薪资档案")}</div>
|
||||
</div>
|
||||
<div className="titleCol titleRightBox">
|
||||
{
|
||||
runStatuses !== "4,5" &&
|
||||
<Button type="primary" onClick={this.save} loading={loading}>{getLabel(537558, "保存")}</Button>
|
||||
runStatuses === "fixed" &&
|
||||
<Button type="ghost">{getLabel(542686, "调薪")}</Button>
|
||||
}
|
||||
{
|
||||
runStatuses !== "stop" &&
|
||||
<Button type="primary" loading={loading}>{getLabel(537558, "保存")}</Button>
|
||||
}
|
||||
</div>
|
||||
</div>;
|
||||
};
|
||||
handleClose = () => {
|
||||
const { archivesStore: { hasBeenModify }, onClose } = this.props;
|
||||
const { payrollFilesStore: { hasBeenModify }, onClose } = this.props;
|
||||
if (hasBeenModify) {
|
||||
Modal.confirm({
|
||||
title: getLabel(131329, "信息确认"),
|
||||
content: getLabel(111, "确定放弃填写吗?放弃后数据将不会被保存!"),
|
||||
content: getLabel(545770, "确定放弃填写吗?放弃后数据将不会被保存!"),
|
||||
onOk: () => {
|
||||
onClose();
|
||||
}
|
||||
|
|
@ -287,20 +66,14 @@ class Index extends Component {
|
|||
};
|
||||
|
||||
render() {
|
||||
const { archivesStore: { welfareProfileForm } } = this.props;
|
||||
const { conditions, formData } = this.state;
|
||||
const { payrollFilesStore } = this.props;
|
||||
return (
|
||||
<WeaSlideModal
|
||||
className="salary-welfare-archive-edit-layout" {...this.props}
|
||||
top={0} width={800} height={100} measureT={"%"} measureX={"px"} measureY={"%"}
|
||||
className="salary-files-edit-layout" {...this.props}
|
||||
top={0} width={800} height={100} measureT="%" measureX="px" measureY="%"
|
||||
direction={"right"} title={this.renderTitle()} onClose={this.handleClose}
|
||||
content={<div className="salary-welfare-archive-edit-area">
|
||||
{
|
||||
getWelfareSearchsForm(
|
||||
welfareProfileForm, conditions, this.handleFormChange, this.handleNoPaymentChange, this.handleExtraChange,
|
||||
this.handleSameChange, formData, this.props
|
||||
)
|
||||
}
|
||||
content={<div className="salary-files-edit-area">
|
||||
|
||||
</div>}
|
||||
/>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -185,4 +185,82 @@
|
|||
}
|
||||
}
|
||||
|
||||
//薪资档案页面重构-编辑查看抽屉页面
|
||||
.salary-files-edit-layout {
|
||||
.titleDialog {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0 46px 0 16px;
|
||||
|
||||
.titleCol {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.titleLeftBox {
|
||||
.titleIcon {
|
||||
color: #fff;
|
||||
margin: 0;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
font-size: 22px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: #F14A2D;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 14px;
|
||||
color: #333;
|
||||
padding-left: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
.titleRightBox {
|
||||
justify-content: flex-end;
|
||||
|
||||
button:last-child {
|
||||
margin-left: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.wea-slide-modal-title {
|
||||
border-bottom: 1px solid #e5e5e5 !important;
|
||||
}
|
||||
|
||||
.wea-slide-modal-content {
|
||||
height: 100%;
|
||||
|
||||
.salary-files-edit-area {
|
||||
background: #f6f6f6;
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
padding: 16px;
|
||||
|
||||
.wea-search-group, .wea-form-cell {
|
||||
padding: 0;
|
||||
|
||||
.wea-form-item {
|
||||
padding: 5px 16px;
|
||||
|
||||
.wea-form-item-label {
|
||||
color: #666;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.wea-form-cell-wrapper {
|
||||
background: #FFF;
|
||||
border: 1px solid #e5e5e5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ class Index extends Component {
|
|||
id="atdTable"
|
||||
/>
|
||||
</Spin>
|
||||
{/* 编辑产看员工福利档案*/}
|
||||
{/* 编辑查看员工福利档案*/}
|
||||
<WelfareEditArchiveSlide {...welfareEditSlide} ref={dom => this.archiveSlideRef = dom}
|
||||
onClose={(isFresh) => this.setState({
|
||||
welfareEditSlide: { ...welfareEditSlide, visible: false }
|
||||
|
|
|
|||
Loading…
Reference in New Issue