产品-工资单模板定时发放添加薪资所属月
This commit is contained in:
parent
d2fe01c759
commit
e501aa293e
|
|
@ -2,10 +2,12 @@ import React from "react";
|
|||
import { WeaCheckbox, WeaFormItem, WeaInput, WeaLocaleProvider, WeaSearchGroup, WeaSelect, WeaTimePicker } from "ecCom";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import { getReplenishRuleSetOptions } from "../../../apis/payroll";
|
||||
import { commonEnumList } from "../../../apis/payrollFiles";
|
||||
import moment from "moment";
|
||||
import { toJS } from "mobx";
|
||||
import "./index.less";
|
||||
|
||||
|
||||
const getLabel = WeaLocaleProvider.getLabel;
|
||||
@inject("payrollStore")
|
||||
@observer
|
||||
|
|
@ -16,6 +18,7 @@ export default class BaseInformForm extends React.Component {
|
|||
inited: false,
|
||||
options: [],
|
||||
replenishRuleOptions: [],
|
||||
salaryMonthOptions: [],
|
||||
request: {}
|
||||
};
|
||||
}
|
||||
|
|
@ -24,6 +27,7 @@ export default class BaseInformForm extends React.Component {
|
|||
const { payrollStore } = this.props;
|
||||
const { getPayrollBaseForm } = payrollStore;
|
||||
const templateBaseData = window.localStorage.getItem("template-basedata") || "{}";
|
||||
this.commonEnumList();
|
||||
getPayrollBaseForm(this.props.id).then(data => {
|
||||
this.setState(
|
||||
{
|
||||
|
|
@ -73,9 +77,19 @@ export default class BaseInformForm extends React.Component {
|
|||
}
|
||||
});
|
||||
};
|
||||
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 }))
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
render() {
|
||||
const { request, options, replenishRuleOptions } = this.state;
|
||||
const { request, options, replenishRuleOptions, salaryMonthOptions } = this.state;
|
||||
const {
|
||||
salarySob,
|
||||
name,
|
||||
|
|
@ -87,7 +101,8 @@ export default class BaseInformForm extends React.Component {
|
|||
emailStatus,
|
||||
autoSendStatus,
|
||||
autoSendDayOfMonth,
|
||||
autoSendTimeOfDay
|
||||
autoSendTimeOfDay,
|
||||
autoSendCycleType
|
||||
} = request;
|
||||
|
||||
return (
|
||||
|
|
@ -185,7 +200,8 @@ export default class BaseInformForm extends React.Component {
|
|||
this.handleChange({
|
||||
autoSendStatus: value === "1",
|
||||
autoSendDayOfMonth: value === "1" ? "1" : null,
|
||||
autoSendTimeOfDay: value === "1" ? "09:00" : null
|
||||
autoSendTimeOfDay: value === "1" ? "09:00" : null,
|
||||
autoSendCycleType: 0
|
||||
});
|
||||
}}/>
|
||||
</WeaFormItem>
|
||||
|
|
@ -193,9 +209,11 @@ export default class BaseInformForm extends React.Component {
|
|||
autoSendStatus &&
|
||||
<WeaFormItem label={getLabel(111, "发送时间")} labelCol={{ span: 6 }} wrapperCol={{ span: 18 }}>
|
||||
<SendTimeComp
|
||||
salaryMonthOptions={salaryMonthOptions}
|
||||
value={{
|
||||
autoSendDayOfMonth,
|
||||
autoSendTimeOfDay
|
||||
autoSendTimeOfDay,
|
||||
autoSendCycleType
|
||||
}}
|
||||
onChange={this.handleChange}
|
||||
/>
|
||||
|
|
@ -208,18 +226,23 @@ export default class BaseInformForm extends React.Component {
|
|||
}
|
||||
|
||||
const SendTimeComp = (props) => {
|
||||
const { value, onChange } = props;
|
||||
const { autoSendDayOfMonth, autoSendTimeOfDay } = value;
|
||||
const { value, onChange, salaryMonthOptions } = props;
|
||||
const { autoSendDayOfMonth, autoSendTimeOfDay, autoSendCycleType } = value;
|
||||
|
||||
const handleChangeSendtime = (key, val) => {
|
||||
onChange({ autoSendDayOfMonth, autoSendTimeOfDay, [key]: val });
|
||||
onChange({ autoSendDayOfMonth, autoSendTimeOfDay, autoSendCycleType, [key]: val });
|
||||
};
|
||||
return <div className="customTimeCompWrapper">
|
||||
<div>
|
||||
<span>{getLabel(111, "每月")}</span>
|
||||
<span>{getLabel(542604, "薪资所属月")}</span>
|
||||
<WeaSelect
|
||||
value={autoSendCycleType.toString()}
|
||||
options={salaryMonthOptions}
|
||||
onChange={v => handleChangeSendtime("autoSendCycleType", Number(v))}
|
||||
/>
|
||||
<WeaSelect
|
||||
value={!_.isNil(autoSendDayOfMonth) ? autoSendDayOfMonth : "1"}
|
||||
options={_.map(getDay(), item => ({ key: item, showname: item }))}
|
||||
options={_.map(getDay(autoSendCycleType), item => ({ key: item, showname: item }))}
|
||||
onChange={v => handleChangeSendtime("autoSendDayOfMonth", v)}
|
||||
/>
|
||||
<span>{getLabel(16992, "号")}</span>
|
||||
|
|
@ -229,15 +252,14 @@ const SendTimeComp = (props) => {
|
|||
</div>;
|
||||
};
|
||||
|
||||
const getDay = () => {
|
||||
const getDay = (num = 1) => {
|
||||
let days = [];
|
||||
let day = getDaysInMonth(moment().year(), moment().month() + 1);
|
||||
let day = getDaysInMonth(moment().year(), moment().month() + num);
|
||||
for (let i = 1; i <= day; i++) {
|
||||
days.push(i);
|
||||
}
|
||||
return days;
|
||||
};
|
||||
|
||||
const getDaysInMonth = (year, month) => {
|
||||
month = parseInt(month, 10);
|
||||
let d = new Date(year, month, 0);
|
||||
|
|
|
|||
Loading…
Reference in New Issue