修改薪资核算查询日期报错的bug

This commit is contained in:
liyongshun 2022-06-29 14:02:06 +08:00
parent 23c6ad30ed
commit 5f66d08a39
1 changed files with 44 additions and 13 deletions

View File

@ -2,7 +2,15 @@ import React from "react";
import { inject, observer } from "mobx-react";
import { toJS } from "mobx";
import { Button, Table, DatePicker, Dropdown, Menu, Modal } from "antd";
import {
Button,
Table,
DatePicker,
Dropdown,
Menu,
Modal,
message
} from "antd";
import {
WeaTop,
@ -86,17 +94,37 @@ export default class Calculate extends React.Component {
}
handleRangePickerChange(value) {
let range = value.map(item => moment(item).format("YYYY-MM"));
const isNil = _.every(value, it => !_.isNil(it));
let range = isNil && value.map(item => moment(item).format("YYYY-MM"));
const { calculateStore: { getSalaryAcctList } } = this.props;
this.setState({
startDate: range[0],
endDate: range[1]
});
getSalaryAcctList({
name: this.state.searchValue,
startMonthStr: range[0],
endMonthStr: range[1]
});
if (isNil && !_.isEmpty(value)) {
this.setState(
{
startDate: range[0],
endDate: range[1]
},
() => {
getSalaryAcctList({
name: this.state.searchValue,
startMonthStr: range[0],
endMonthStr: range[1]
});
}
);
} else {
this.setState(
{
startDate: moment(new Date())
.subtract(5, "months")
.startOf("month")
.format("YYYY-MM"),
endDate: moment(new Date()).startOf("month").format("YYYY-MM")
},
() => {
message.error("目前可查询的最大时间范围为6个月 请重新选择");
}
);
}
}
// 列表项核算回调
@ -160,7 +188,10 @@ export default class Calculate extends React.Component {
record.operate,
it => it.text == "核算" || it.text == "重新核算"
);
const notAccountBtn = _.filter(record.operate, it => it.text != "核算" && it.text != "重新核算");
const notAccountBtn = _.filter(
record.operate,
it => it.text != "核算" && it.text != "重新核算"
);
let operateBtn = [];
if (!_.isEmpty(accountBtn)) {
operateBtn.push(
@ -327,7 +358,7 @@ export default class Calculate extends React.Component {
<div
style={{ display: "inline-block", position: "relative", top: 2 }}>
<RangePicker
defaultValue={[this.state.startDate, this.state.endDate]}
value={[this.state.startDate, this.state.endDate]}
picker="month"
format="yyyy-MM"
onChange={value => this.handleRangePickerChange(value)}