|
|
@ -13,11 +13,11 @@ |
|
|
|
@openChange="handleStartOpenChange" |
|
|
|
> |
|
|
|
<template slot="renderExtraFooter"> |
|
|
|
<a-button size="small" type="primary" ghost @click="setYesterday('startValue', 'startOpen')">昨天</a-button> |
|
|
|
<a-button class="ml-3" size="small" type="primary" ghost @click="setToday('startValue', 'startOpen')">今天</a-button> |
|
|
|
<a-button class="ml-3" size="small" type="primary" ghost @click="setMonday('startValue', 'startOpen')">本周</a-button> |
|
|
|
<a-button class="ml-3" size="small" type="primary" ghost @click="setMonthOne('startValue', 'startOpen')">本月</a-button> |
|
|
|
<a-button size="small" type="primary" ghost @click="setLastMonthOne('startValue', 'startOpen')">上月</a-button> |
|
|
|
<a-button size="small" type="primary" ghost @click="setYesterday('startOpen')">昨天</a-button> |
|
|
|
<a-button class="ml-3" size="small" type="primary" ghost @click="setToday('startOpen')">今天</a-button> |
|
|
|
<a-button class="ml-3" size="small" type="primary" ghost @click="setWeek('startOpen')">本周</a-button> |
|
|
|
<a-button class="ml-3" size="small" type="primary" ghost @click="setMonth('startOpen')">本月</a-button> |
|
|
|
<a-button size="small" type="primary" ghost @click="setLastMonth('startOpen')">上月</a-button> |
|
|
|
</template> |
|
|
|
</a-date-picker> |
|
|
|
<a-date-picker |
|
|
@ -32,11 +32,11 @@ |
|
|
|
@openChange="handleEndOpenChange" |
|
|
|
> |
|
|
|
<template slot="renderExtraFooter"> |
|
|
|
<a-button size="small" type="primary" ghost @click="setYesterday('endValue', 'endOpen')">昨天</a-button> |
|
|
|
<a-button class="ml-3" size="small" type="primary" ghost @click="setToday('endValue', 'endOpen')">今天</a-button> |
|
|
|
<a-button class="ml-3" size="small" type="primary" ghost @click="setSunday('endValue', 'endOpen')">本周</a-button> |
|
|
|
<a-button class="ml-3" size="small" type="primary" ghost @click="setMonthEnd('endValue', 'endOpen')">本月</a-button> |
|
|
|
<a-button size="small" type="primary" ghost @click="setLastMonthEnd('endValue', 'endOpen')">上月</a-button> |
|
|
|
<a-button size="small" type="primary" ghost @click="setYesterday('endOpen')">昨天</a-button> |
|
|
|
<a-button class="ml-3" size="small" type="primary" ghost @click="setToday('endOpen')">今天</a-button> |
|
|
|
<a-button class="ml-3" size="small" type="primary" ghost @click="setWeek('endOpen')">本周</a-button> |
|
|
|
<a-button class="ml-3" size="small" type="primary" ghost @click="setMonth('endOpen')">本月</a-button> |
|
|
|
<a-button size="small" type="primary" ghost @click="setLastMonth('endOpen')">上月</a-button> |
|
|
|
</template> |
|
|
|
</a-date-picker> |
|
|
|
</div> |
|
|
@ -95,88 +95,73 @@ export default { |
|
|
|
...mapMutations('home', ['setStartTime', 'setEndTime']), |
|
|
|
|
|
|
|
// 昨天 |
|
|
|
setYesterday(value, open) { |
|
|
|
this[value] = this.$moment(new Date().getTime() - 24 * 60 * 60 * 1000).format('YYYY-MM-DD'); |
|
|
|
setYesterday(open) { |
|
|
|
const day = this.$moment(new Date().getTime() - 24 * 60 * 60 * 1000).format('YYYY-MM-DD'); |
|
|
|
this.startValue = day; |
|
|
|
this.endValue = day; |
|
|
|
this[open] = false; |
|
|
|
if (open === 'startOpen' && !this.startOpen) { |
|
|
|
this.endOpen = true; |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 今天 |
|
|
|
setToday(value, open) { |
|
|
|
this[value] = this.$moment(new Date()).format('YYYY-MM-DD'); |
|
|
|
setToday(open) { |
|
|
|
const today = this.$moment(new Date()).format('YYYY-MM-DD'); |
|
|
|
this.startValue = today; |
|
|
|
this.endValue = today; |
|
|
|
this[open] = false; |
|
|
|
if (open === 'startOpen' && !this.startOpen) { |
|
|
|
this.endOpen = true; |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 本周一 |
|
|
|
setMonday(value, open) { |
|
|
|
var date = this.$moment(this.$moment().format('YYYY-MM-DD')); |
|
|
|
var dow = date.day(); |
|
|
|
var monday1 = date.subtract(dow - 1, 'days').format('YYYY-MM-DD'); //本周一 |
|
|
|
this[value] = monday1; |
|
|
|
setWeek(open) { |
|
|
|
const startWeek = this.$moment() |
|
|
|
.startOf('week') |
|
|
|
.format('YYYY-MM-DD'); |
|
|
|
this.startValue = startWeek; |
|
|
|
const endWeek = this.$moment() |
|
|
|
.endOf('week') |
|
|
|
.format('YYYY-MM-DD'); |
|
|
|
this.endValue = endWeek; |
|
|
|
this[open] = false; |
|
|
|
if (open === 'startOpen' && !this.startOpen) { |
|
|
|
/* if (open === 'startOpen' && !this.startOpen) { |
|
|
|
this.endOpen = true; |
|
|
|
} |
|
|
|
} */ |
|
|
|
}, |
|
|
|
|
|
|
|
// 本周日 |
|
|
|
setSunday(value, open) { |
|
|
|
/* setSunday(value, open) { |
|
|
|
var date = this.$moment(this.$moment().format('YYYY-MM-DD')); |
|
|
|
var dow = date.day(); |
|
|
|
var monday1 = date.subtract(dow - 7, 'days').format('YYYY-MM-DD'); //本周一 |
|
|
|
this[value] = monday1; |
|
|
|
this[open] = false; |
|
|
|
}, |
|
|
|
}, */ |
|
|
|
|
|
|
|
// 本月1号 |
|
|
|
setMonthOne(value, open) { |
|
|
|
setMonth(open) { |
|
|
|
const m = this.$moment() |
|
|
|
.startOf('month') |
|
|
|
.format('YYYY-MM-DD'); |
|
|
|
this[value] = m; |
|
|
|
this[open] = false; |
|
|
|
if (open === 'startOpen' && !this.startOpen) { |
|
|
|
this.endOpen = true; |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 本月最后一天 |
|
|
|
setMonthEnd(value, open) { |
|
|
|
this.startValue = m; |
|
|
|
const end = |
|
|
|
this.$moment() |
|
|
|
.endOf('month') |
|
|
|
.format('YYYY-MM-DD') + ' 23:59:59'; |
|
|
|
this[value] = end; |
|
|
|
this.endValue = end; |
|
|
|
this[open] = false; |
|
|
|
}, |
|
|
|
|
|
|
|
// 上月1号 |
|
|
|
setLastMonthOne(value, open) { |
|
|
|
setLastMonth(open) { |
|
|
|
const t = this.$moment().format('YYYY-MM-DD'); |
|
|
|
const afterM = this.$moment(t, 'YYYY-MM-DD') |
|
|
|
.subtract(1, 'months') |
|
|
|
.startOf('month') |
|
|
|
.format('YYYY-MM-DD'); |
|
|
|
this[value] = afterM; |
|
|
|
this[open] = false; |
|
|
|
if (open === 'startOpen' && !this.startOpen) { |
|
|
|
this.endOpen = true; |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 上月最后一天 |
|
|
|
setLastMonthEnd(value, open) { |
|
|
|
const t = this.$moment().format('YYYY-MM-DD'); |
|
|
|
const afterM = this.$moment(t, 'YYYY-MM-DD') |
|
|
|
this.startValue = afterM; |
|
|
|
const lastM = this.$moment(t, 'YYYY-MM-DD') |
|
|
|
.subtract(1, 'months') |
|
|
|
.endOf('month') |
|
|
|
.format('YYYY-MM-DD'); |
|
|
|
this[value] = afterM; |
|
|
|
this.endValue = lastM; |
|
|
|
this[open] = false; |
|
|
|
}, |
|
|
|
|
|
|
|