Commit f3d50005 by 张杰

修复日期控件

1 parent 4e47ace5
...@@ -3,6 +3,7 @@ import Vue from 'vue' ...@@ -3,6 +3,7 @@ import Vue from 'vue'
import { Message, MessageBox, Loading } from 'element-ui' import { Message, MessageBox, Loading } from 'element-ui'
import moment from 'moment' import moment from 'moment'
let loadingInstance = '' let loadingInstance = ''
const EventBus = new Vue()
export const Util = { export const Util = {
/** /**
* 简单alert * 简单alert
...@@ -244,7 +245,7 @@ export const Util = { ...@@ -244,7 +245,7 @@ export const Util = {
} }
// 通过url下载文件 // 通过url下载文件
export const downFileByPath = function(url){ export const downFileByPath = function (url) {
if (!url) { if (!url) {
return false; return false;
}; };
...@@ -257,6 +258,19 @@ export const downFileByPath = function(url){ ...@@ -257,6 +258,19 @@ export const downFileByPath = function(url){
window.location.href = url 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 export const showModal = Util.msg
export const showToast = Util.Info export const showToast = Util.Info
export const showLoading = Util.loading export const showLoading = Util.loading
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<el-form-item label="离线时间:"> <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 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> -->
<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> </el-date-picker>
<span> ~ </span> <span> ~ </span>
<el-date-picker v-model="searchForm.offlineEndTime" class="sort_picker" type="datetime" placeholder="选择日期时间" value-format="yyyy-MM-dd HH:mm:ss" disabled> <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 @@ ...@@ -91,7 +91,7 @@
import moment from "moment"; import moment from "moment";
import GlsxOrganization from "@/components/glsx-organization"; import GlsxOrganization from "@/components/glsx-organization";
import { GETOFFLINESEARCH, ALARM_OFFLINE_EXPORT } from "@/services/alarmCenter"; 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 { offlineShortcuts, offlineActiveShortcuts } from "@/common";
import qs from "qs"; import qs from "qs";
export default { export default {
...@@ -111,7 +111,38 @@ export default { ...@@ -111,7 +111,38 @@ export default {
showResult: false, showResult: false,
loading: false, loading: false,
offPickerOptions: { 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: { pickerOptions: {
shortcuts: offlineActiveShortcuts, shortcuts: offlineActiveShortcuts,
...@@ -123,6 +154,8 @@ export default { ...@@ -123,6 +154,8 @@ export default {
}; };
}, },
created() { created() {
received("change_off_time", this.onChangeDate);
let query = this.$route.query; let query = this.$route.query;
let end = moment().format("YYYY-MM-DD HH:mm:ss"); let end = moment().format("YYYY-MM-DD HH:mm:ss");
let start = moment() let start = moment()
...@@ -272,7 +305,7 @@ export default { ...@@ -272,7 +305,7 @@ export default {
//history.pushState(oParams, "报警位置点", path); //history.pushState(oParams, "报警位置点", path);
}, },
onChangeDate(e) { onChangeDate() {
let max = moment().format("YYYY-MM-DD HH:mm:ss"); let max = moment().format("YYYY-MM-DD HH:mm:ss");
this.$set(this.searchForm, "offlineEndTime", max); 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!