Commit f3d50005 by 张杰

修复日期控件

1 parent 4e47ace5
......@@ -3,6 +3,7 @@ import Vue from 'vue'
import { Message, MessageBox, Loading } from 'element-ui'
import moment from 'moment'
let loadingInstance = ''
const EventBus = new Vue()
export const Util = {
/**
* 简单alert
......@@ -244,17 +245,30 @@ export const Util = {
}
// 通过url下载文件
export const downFileByPath = function(url){
if (!url) {
return false;
};
// let link = document.createElement('a')
// link.style.display = 'none'
// link.src = url
// link.target = '_blank'
// document.body.appendChild(link);
// link.click();
window.location.href = url
export const downFileByPath = function (url) {
if (!url) {
return false;
};
// let link = document.createElement('a')
// link.style.display = 'none'
// link.src = url
// link.target = '_blank'
// document.body.appendChild(link);
// link.click();
window.location.href = url
}
// 传递消息
export const broadcast = function (msg, data) {
EventBus.$emit(msg, data)
}
// 接收消息
export const received = function (msg, callBack) {
EventBus.$off(msg)
EventBus.$on(msg, function (row) {
callBack(row)
})
}
export const showModal = Util.msg
......
......@@ -12,7 +12,7 @@
<el-form-item label="离线时间:">
<!-- <el-date-picker v-model="searchForm.offDate" type="datetimerange" class="datatime_picker" unlink-panels range-separator="~" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd HH:mm:ss" :picker-options="offPickerOptions" @change="onChangeDate">
</el-date-picker> -->
<el-date-picker v-model="searchForm.offlineStartTime" class="sort_picker" type="datetime" unlink-panels placeholder="选择日期时间" value-format="yyyy-MM-dd HH:mm:ss" :picker-options="offPickerOptions" @change="onChangeDate">
<el-date-picker v-model="searchForm.offlineStartTime" class="sort_picker" type="datetime" unlink-panels placeholder="选择日期时间" value-format="yyyy-MM-dd HH:mm:ss" :picker-options="offPickerOptions">
</el-date-picker>
<span> ~ </span>
<el-date-picker v-model="searchForm.offlineEndTime" class="sort_picker" type="datetime" placeholder="选择日期时间" value-format="yyyy-MM-dd HH:mm:ss" disabled>
......@@ -91,7 +91,7 @@
import moment from "moment";
import GlsxOrganization from "@/components/glsx-organization";
import { GETOFFLINESEARCH, ALARM_OFFLINE_EXPORT } from "@/services/alarmCenter";
import { deepClone, showToast } from "@/utils/util";
import { deepClone, showToast, broadcast, received } from "@/utils/util";
import { offlineShortcuts, offlineActiveShortcuts } from "@/common";
import qs from "qs";
export default {
......@@ -111,7 +111,38 @@ export default {
showResult: false,
loading: false,
offPickerOptions: {
shortcuts: offlineShortcuts,
shortcuts: [
{
text: "近1天不在线",
onClick(picker) {
const start = moment()
.day(moment().day() - 1)
.format("YYYY-MM-DD HH:mm:ss");
picker.$emit("pick", start);
broadcast("change_off_time");
},
},
{
text: "近3天不在线",
onClick(picker) {
const start = moment()
.day(moment().day() - 3)
.format("YYYY-MM-DD HH:mm:ss");
picker.$emit("pick", start);
broadcast("change_off_time");
},
},
{
text: "近7天不在线",
onClick(picker) {
const start = moment()
.day(moment().day() - 7)
.format("YYYY-MM-DD HH:mm:ss");
picker.$emit("pick", start);
broadcast("change_off_time");
},
},
],
},
pickerOptions: {
shortcuts: offlineActiveShortcuts,
......@@ -123,6 +154,8 @@ export default {
};
},
created() {
received("change_off_time", this.onChangeDate);
let query = this.$route.query;
let end = moment().format("YYYY-MM-DD HH:mm:ss");
let start = moment()
......@@ -272,7 +305,7 @@ export default {
//history.pushState(oParams, "报警位置点", path);
},
onChangeDate(e) {
onChangeDate() {
let max = moment().format("YYYY-MM-DD HH:mm:ss");
this.$set(this.searchForm, "offlineEndTime", max);
},
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!