You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
1.9 KiB
JavaScript
74 lines
1.9 KiB
JavaScript
import {makeAutoObservable} from "mobx";
|
|
import moment from "moment";
|
|
/**
|
|
* 管理搜索组件的状态
|
|
*/
|
|
class DatePickerStore {
|
|
|
|
constructor(rootStore) {
|
|
this.rootStore = rootStore;
|
|
makeAutoObservable(this);
|
|
}
|
|
|
|
start_date = moment().startOf('week').subtract(7, 'days');
|
|
end_date = moment().endOf('week').subtract(7, 'days');
|
|
start_date_cp = false;
|
|
end_date_cp = false;
|
|
|
|
onChange_dataPicker = (dates) => {
|
|
this.start_date = dates[0];
|
|
this.end_date = dates[1];
|
|
};
|
|
|
|
onChange_dataPicker_cp = (dates) => {
|
|
if (dates) {
|
|
this.start_date_cp = dates[0];
|
|
this.end_date_cp = dates[1];
|
|
} else {
|
|
this.start_date_cp = false;
|
|
this.end_date_cp = false;
|
|
}
|
|
};
|
|
|
|
// 计算上一个时间段
|
|
previous_date() {
|
|
return [moment(this.start_date).subtract(this.end_date.diff(this.start_date, 'days') + 1, 'days'), moment(this.start_date).subtract(1, 'days')];
|
|
}
|
|
|
|
// 去年同期
|
|
previous_year() {
|
|
return [moment(this.start_date).subtract(1, 'year'), moment(this.end_date).subtract(1, 'year')];
|
|
}
|
|
|
|
|
|
formValues = {
|
|
'DepartmentList': { 'key': 'ALL', 'label': '所有小组' },
|
|
'WebCode': { 'key': 'ALL', 'label': '所有来源' },
|
|
'IncludeTickets': { 'key': '1', 'label': '含门票' },
|
|
'DateType': { 'key': 'confirmDate', 'label': '确认日期' },
|
|
'year': this.start_date,
|
|
// 'months': [moment(), moment()],
|
|
'dates': [this.start_date, this.end_date],
|
|
};
|
|
|
|
formValuesToSub = {
|
|
DepartmentList: 'ALL',
|
|
WebCode: 'ALL',
|
|
IncludeTickets: '1',
|
|
DateType: 'confirmDate',
|
|
Date1: this.start_date.format('YYYY-MM-DD'),
|
|
Date2: this.end_date.format('YYYY-MM-DD 23:59:59'),
|
|
};
|
|
|
|
setFormValues(data){
|
|
this.formValues = data;
|
|
}
|
|
|
|
setFormValuesToSub(data){
|
|
this.formValuesToSub = data;
|
|
}
|
|
}
|
|
|
|
export default DatePickerStore;
|
|
|