237 lines
9.3 KiB
JavaScript
237 lines
9.3 KiB
JavaScript
/*
|
|
* Author: 黎永顺
|
|
* name:工资单发放-重构页面新建编辑模板基础设置
|
|
* Description:
|
|
* Date: 2023/10/13
|
|
*/
|
|
import React, { Component } from "react";
|
|
import { WeaFormItem, WeaLocaleProvider, WeaTools } from "ecCom";
|
|
import { tempBaseSetConditions, tempBaseSetFbConditions } from "../conditions";
|
|
import { getSearchs } from "../../../../util";
|
|
import { getPayrollBaseForm, getReplenishRuleSetOptions } from "../../../../apis/payroll";
|
|
import { commonEnumList } from "../../../../apis/archive";
|
|
import { SendTimeComp } from "../../../payroll/stepForm/baseInformForm";
|
|
|
|
const getKey = WeaTools.getKey;
|
|
const getLabel = WeaLocaleProvider.getLabel;
|
|
|
|
class Index extends Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
conditions: [], salaryMonthOptions: [], fbConditions: [],
|
|
formData: {
|
|
autoSendDayOfMonth: "1",
|
|
autoSendTimeOfDay: "09:00",
|
|
autoSendCycleType: "1"
|
|
}
|
|
};
|
|
}
|
|
|
|
componentDidMount() {
|
|
this.commonEnumList();
|
|
this.props.visible && this.getPayrollBaseForm(this.props);
|
|
}
|
|
|
|
componentWillReceiveProps(nextProps, nextContext) {
|
|
if (nextProps.visible !== this.props.visible && nextProps.visible) this.getPayrollBaseForm(nextProps);
|
|
if (nextProps.visible !== this.props.visible && !nextProps.visible) {
|
|
nextProps.payrollStore.initPayrollTempForm();
|
|
nextProps.payrollStore.initPayrollTempFeedbackForm();
|
|
}
|
|
}
|
|
|
|
commonEnumList = () => {
|
|
commonEnumList({ enumClass: "com.engine.salary.enums.salarysend.SalaryAutoSendCycleTypeEnum" })
|
|
.then(({ status, data }) => {
|
|
if (status && !_.isEmpty(data)) {
|
|
this.setState({
|
|
salaryMonthOptions: _.map(data, it => ({ key: it.value.toString(), showname: it.defaultLabel }))
|
|
});
|
|
}
|
|
});
|
|
};
|
|
getPayrollBaseForm = (props) => {
|
|
const { tmplId: id, payrollStore: { payrollTempForm, payrollTempFeedbackForm } } = props;
|
|
getPayrollBaseForm({ id }).then(({ status, data }) => {
|
|
if (status) {
|
|
const { salaryTemplateBaseSet: { salarySobOptions } } = data;
|
|
this.setState({
|
|
conditions: _.map(tempBaseSetConditions, it => {
|
|
if (it.title === "baseSet") {
|
|
return {
|
|
...it, title: getLabel(82743, "基础信息"),
|
|
items: _.map(it.items, o => {
|
|
if (getKey(o) === "salarySobId") {
|
|
return {
|
|
...o, options: _.map(salarySobOptions, g => ({ key: g.id.toString(), showname: g.name }))
|
|
};
|
|
} else if (getKey(o) === "reissueRule") {
|
|
return {
|
|
...o, options: [
|
|
{ key: "0", showname: getLabel(332, "全部") },
|
|
{ key: "1", showname: getLabel(542696, "按规则") }
|
|
]
|
|
};
|
|
}
|
|
return { ...o };
|
|
})
|
|
};
|
|
} else if (it.title === "sendSet") {
|
|
return {
|
|
...it, title: getLabel(18905, "发送设置"),
|
|
items: _.map(it.items, o => {
|
|
if (getKey(o) === "autoSendStatus") {
|
|
return {
|
|
...o,
|
|
helpfulTitle: getLabel(544272, "开启后,还需在计划任务中配置定时任务,执行工资单定时发送任务;")
|
|
};
|
|
}
|
|
return { ...o };
|
|
})
|
|
};
|
|
}
|
|
}),
|
|
fbConditions: _.map(tempBaseSetFbConditions, it => {
|
|
if (it.title === "feedbackSet") {
|
|
return {
|
|
...it, title: getLabel(544092, "工资单确认反馈设置"),
|
|
items: _.map(it.items, o => {
|
|
if (getKey(o) === "autoAckDays") {
|
|
return {
|
|
...o,
|
|
helpfulTitle: getLabel(544273, "开启后,还需在计划任务中配置定时任务,执行自动确认任务;邮箱端查看工资单暂不支持确认及反馈;")
|
|
};
|
|
}
|
|
return { ...o };
|
|
})
|
|
};
|
|
}
|
|
})
|
|
}, () => {
|
|
payrollTempForm.initFormFields(this.state.conditions);
|
|
payrollTempFeedbackForm.initFormFields(this.state.fbConditions);
|
|
this.forceUpdate();
|
|
});
|
|
}
|
|
});
|
|
};
|
|
handleChange = async (params) => {
|
|
const { payrollStore: { payrollTempForm } } = this.props;
|
|
const key = _.keys(params)[0], salarySobId = payrollTempForm.getFormParams().salarySobId,
|
|
reissueRule = payrollTempForm.getFormParams().reissueRule;
|
|
const { data: replenishRuleOptions } = (reissueRule === "1" && salarySobId) ? await getReplenishRuleSetOptions({ salarySobId }) : [];
|
|
if (key === "reissueRule") {
|
|
this.setState({
|
|
conditions: _.map(this.state.conditions, it => {
|
|
if (it.title === getLabel(82743, "基础信息")) {
|
|
return {
|
|
...it, items: _.map(it.items, o => {
|
|
if (getKey(o) === "replenishRule") {
|
|
return {
|
|
...o, hide: params[key].value === "0",
|
|
rules: (!_.isEmpty(replenishRuleOptions) && reissueRule === "1") ? "required|string" : "",
|
|
viewAttr: (!_.isEmpty(replenishRuleOptions) && reissueRule === "1") ? 3 : 2,
|
|
options: _.map(replenishRuleOptions, t => ({ key: t.id, showname: t.content }))
|
|
};
|
|
}
|
|
return { ...o };
|
|
})
|
|
};
|
|
}
|
|
return { ...it };
|
|
})
|
|
}, () => {
|
|
payrollTempForm.initFormFields(this.state.conditions);
|
|
this.resetRequiredForm();
|
|
});
|
|
} else if (key === "salarySobId") {
|
|
this.setState({
|
|
conditions: _.map(this.state.conditions, it => {
|
|
if (it.title === getLabel(82743, "基础信息")) {
|
|
return {
|
|
...it, items: _.map(it.items, o => {
|
|
if (getKey(o) === "replenishRule") {
|
|
return {
|
|
...o, options: _.map(replenishRuleOptions, t => ({ key: t.id, showname: t.content })),
|
|
rules: (!_.isEmpty(replenishRuleOptions) && reissueRule === "1") ? "required|string" : "",
|
|
viewAttr: (!_.isEmpty(replenishRuleOptions) && reissueRule === "1") ? 3 : 2
|
|
};
|
|
}
|
|
return { ...o };
|
|
})
|
|
};
|
|
}
|
|
return { ...it };
|
|
})
|
|
}, () => {
|
|
payrollTempForm.initFormFields(this.state.conditions);
|
|
const salarySob = payrollTempForm.getFormDatas().salarySobId;
|
|
payrollTempForm.updateFields({
|
|
name: salarySob.valueSpan,
|
|
replenishName: salarySob.valueSpan + "-补发工资单"
|
|
});
|
|
this.resetRequiredForm();
|
|
});
|
|
}
|
|
this.forceUpdate();
|
|
};
|
|
resetRequiredForm = () => {
|
|
const { payrollStore: { payrollTempForm } } = this.props;
|
|
const reissueRule = payrollTempForm.getFormParams().reissueRule;
|
|
if (reissueRule === "0") payrollTempForm.updateFields({ replenishRule: "0" });
|
|
if (reissueRule === "1") payrollTempForm.updateFields({ replenishRule: "" });
|
|
};
|
|
handleFbChange = (params) => {
|
|
const { payrollStore: { payrollTempFeedbackForm } } = this.props;
|
|
const key = _.keys(params)[0];
|
|
if (key === "ackFeedbackStatus") {
|
|
this.setState({
|
|
fbConditions: _.map(this.state.fbConditions, it => {
|
|
if (it.title === getLabel(544092, "工资单确认反馈设置")) {
|
|
return {
|
|
...it, items: _.map(it.items, o => {
|
|
if (getKey(o) === "autoAckDays" || getKey(o) === "feedbackUrl") {
|
|
return {
|
|
...o, hide: params[key].value === "0"
|
|
};
|
|
}
|
|
return { ...o };
|
|
})
|
|
};
|
|
}
|
|
return { ...it };
|
|
})
|
|
}, () => {
|
|
payrollTempFeedbackForm.initFormFields(this.state.fbConditions);
|
|
const ackFeedbackStatus = payrollTempFeedbackForm.getFormParams().ackFeedbackStatus;
|
|
if (ackFeedbackStatus === "0") payrollTempFeedbackForm.updateFields({ autoAckDays: "7", feedbackUrl: "/" });
|
|
});
|
|
}
|
|
this.forceUpdate();
|
|
};
|
|
|
|
render() {
|
|
const { conditions, fbConditions, formData, salaryMonthOptions } = this.state;
|
|
const { payrollStore: { payrollTempForm, payrollTempFeedbackForm } } = this.props;
|
|
const autoSendStatus = payrollTempForm.getFormParams().autoSendStatus;
|
|
return (
|
|
<React.Fragment>
|
|
{!_.isEmpty(fbConditions) && getSearchs(payrollTempForm, conditions, 1, false, this.handleChange)}
|
|
{
|
|
autoSendStatus === "1" &&
|
|
<WeaFormItem className="sendTime-outer" label={getLabel(18961, "发送时间")} labelCol={{ span: 6 }}
|
|
wrapperCol={{ span: 16 }}>
|
|
<SendTimeComp salaryMonthOptions={salaryMonthOptions} value={{ ...formData }}
|
|
onChange={(v) => this.setState({ formData: { ...formData, ...v } })}
|
|
/>
|
|
</WeaFormItem>
|
|
}
|
|
{!_.isEmpty(fbConditions) && getSearchs(payrollTempFeedbackForm, fbConditions, 1, false, this.handleFbChange)}
|
|
</React.Fragment>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default Index;
|