时间筛选器快捷时间区间

Raod 2 years ago
parent 7cba8cac4b
commit b98013e313

@ -9,7 +9,8 @@
:style="styleObj" :style="styleObj"
v-model="timeValue" v-model="timeValue"
value-format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss"
type="daterange" :picker-options="datetimeRangePickerOptions"
type="datetimerange"
@[eventChange]="change" @[eventChange]="change"
/> />
</template> </template>
@ -18,7 +19,7 @@ import {
originWidgetLinkageLogic, originWidgetLinkageLogic,
targetWidgetLinkageLogic, targetWidgetLinkageLogic,
} from "@/views/bigscreenDesigner/designer/linkageLogic"; } from "@/views/bigscreenDesigner/designer/linkageLogic";
import miment from 'miment'
export default { export default {
name: "WidgetFormTime", name: "WidgetFormTime",
props: { props: {
@ -35,6 +36,51 @@ export default {
optionsStyle: {}, optionsStyle: {},
optionsData: {}, optionsData: {},
optionsSetup: {}, optionsSetup: {},
//
datetimeRangePickerOptions:{
shortcuts: [{
text: '今天',
onClick(picker) {
const end = new Date();
const start = new Date(new Date(new Date().getTime()).setHours(0, 0, 0, 0));
picker.$emit('pick', [start, end]);
}
},{
text: '昨天',
onClick(picker) {
const start=new Date(new Date(new Date().getTime()-24*60*60*1000).setHours(0, 0, 0, 0));
const end=new Date(new Date(new Date().getTime()-24*60*60*1000).setHours(23, 59, 59, 999));
picker.$emit('pick', [start, end]);
}
},{
text: '最近一周',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(miment().add(-1, 'ww').stamp());
picker.$emit('pick', [start, end]);
}
}, {
text: '最近一个月',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(miment().add(-1, 'MM').stamp());
picker.$emit('pick', [start, end]);
}
}, {
text: '最近三个月',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(miment().add(-3, 'MM').stamp());
picker.$emit('pick', [start, end]);
}
}],
// disabledDate(time){
// return time.getTime() > Date.now()
// }
}
}; };
}, },
computed: { computed: {

Loading…
Cancel
Save