+
+
@@ -224,18 +729,18 @@
export default {
data() {
return {
- time: '',
- day: '',
- year_s: '',
- month_s: '',
+ time: "",
+ day: "",
+ year_s: "",
+ month_s: "",
yearData: [],
monthData: [],
warningNum: 0,
warningNum2: 0,
- }
+ };
},
mounted() {
- this.$emit('on-mounted');
+ this.$emit("on-mounted");
let that = this;
var myDate = new Date();
let year = myDate.getFullYear();
@@ -254,32 +759,35 @@ export default {
// 动态绑定Class
bindClass(type) {
let classInfo = {
- socketDom: true, redColor: false,
- orangeColor: false, yellowColor: false, blueColor: true
+ socketDom: true,
+ redColor: false,
+ orangeColor: false,
+ yellowColor: false,
+ blueColor: true,
+ };
+ if (type == "") {
+ classInfo.redColor = true;
}
- if (type == '') {
- classInfo.redColor = true
- }
- return classInfo
+ return classInfo;
},
init() {
- var that = this
- if (typeof (WebSocket) === "undefined") {
- alert("您的浏览器不支持socket")
+ var that = this;
+ if (typeof WebSocket === "undefined") {
+ alert("您的浏览器不支持socket");
} else {
- this.ws = new WebSocket(this.path + tool.data.get("TOKEN"))
+ this.ws = new WebSocket(this.path + tool.data.get("TOKEN"));
//监听是否连接成功
this.ws.onopen = () => {
// console.log("socket连接成功");
setTimeout(() => {
- that.ws.send(JSON.stringify({ 'type': 'event' }))
- }, 500)
- }
+ that.ws.send(JSON.stringify({ type: "event" }));
+ }, 500);
+ };
//接听服务器发回的信息并处理展示
this.ws.onmessage = (msg) => {
- let data = JSON.parse(msg.data)
- console.log(data)
+ let data = JSON.parse(msg.data);
+ console.log(data);
that.getWraningNum();
// if(data.type=='event'){
// that.bindClass();
@@ -291,12 +799,12 @@ export default {
};
// 监听并处理error事件
this.ws.onerror = function (error) {
- console.log('ws断开,尝试重连')
+ console.log("ws断开,尝试重连");
setTimeout(() => {
this.ws = null;
- this.init()
- }, 5000)
- }
+ this.init();
+ }, 5000);
+ };
}
},
getMessage(msg) {
@@ -312,58 +820,66 @@ export default {
//获取报警事件数量
getWraningNum() {
let that = this;
- that.$API.ecm.event.list.req({ cates__code__in: 'consume_exceed', is_handled: 0, page: 1 }).then((res) => {
- that.warningNum = res.count;
- })
- that.$API.em.equipment.list.req({ tag: 'near_check', type: 20, page: 1 }).then((res) => {
- debugger;
- that.warningNum2 = res.count;
- })
+ that.$API.ecm.event.list
+ .req({
+ cates__code__in: "consume_exceed",
+ is_handled: 0,
+ page: 1,
+ })
+ .then((res) => {
+ that.warningNum = res.count;
+ });
+ that.$API.em.equipment.list
+ .req({ tag: "near_check", type: 20, page: 1 })
+ .then((res) => {
+ debugger;
+ that.warningNum2 = res.count;
+ });
},
getYearData() {
let that = this;
let obj = {};
obj.year_s = this.year_s;
- obj.type = 'year_s';
+ obj.type = "year_s";
obj.page = 0;
this.$API.enm.enstat.req(obj).then((res) => {
let yearData = {};
- res.forEach(item => {
+ res.forEach((item) => {
let label = item.mgroup_name;
yearData[label] = item;
});
that.yearData = yearData;
- })
+ });
},
getMonthData() {
let that = this;
let obj = {};
obj.year_s = this.year_s;
obj.month_s = this.month_s;
- obj.type = 'month_s';
+ obj.type = "month_s";
obj.page = 0;
that.$API.enm.enstat.req(obj).then((res) => {
let monthData = {};
- res.forEach(item => {
+ res.forEach((item) => {
let label = item.mgroup_name;
monthData[label] = item;
});
+ console.log("monthData", monthData);
that.monthData = monthData;
- })
+ });
},
showTime() {
- this.time = this.$TOOL.dateFormat(new Date(), 'hh:mm:ss')
- this.day = this.$TOOL.dateFormat(new Date(), 'yyyy年MM月dd日')
+ this.time = this.$TOOL.dateFormat(new Date(), "hh:mm:ss");
+ this.day = this.$TOOL.dateFormat(new Date(), "yyyy年MM月dd日");
},
interEvent() {
- this.$router.replace({ path: '/events' })
+ this.$router.replace({ path: "/events" });
},
interEquipment() {
- this.$router.replace({ path: '/em/equipmentc' })
+ this.$router.replace({ path: "/em/equipmentc" });
},
-
- }
-}
+ },
+};