diff --git a/pc4mobx/hrmSalary/pages/calculate/index.js b/pc4mobx/hrmSalary/pages/calculate/index.js index 2613fc8a..6d6f5004 100644 --- a/pc4mobx/hrmSalary/pages/calculate/index.js +++ b/pc4mobx/hrmSalary/pages/calculate/index.js @@ -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 {