|
@@ -6,9 +6,15 @@
|
|
|
<div class="filterSec">
|
|
|
<span>站点:</span>
|
|
|
<select name="" id="">
|
|
|
- <option value="">请选择</option>
|
|
|
- <option value="">站点一</option>
|
|
|
- <option value="">站点一</option>
|
|
|
+ <option
|
|
|
+ :value="item.StationID"
|
|
|
+ v-for="item in siteList"
|
|
|
+ :key="item.StationID"
|
|
|
+ >
|
|
|
+ {{ item.StationName }}
|
|
|
+ </option>
|
|
|
+ <!-- <option value="">站点一</option>
|
|
|
+ <option value="">站点一</option> -->
|
|
|
</select>
|
|
|
</div>
|
|
|
|
|
@@ -34,24 +40,87 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
title: "智慧安防数据分析看板",
|
|
|
+
|
|
|
+ siteList: [],
|
|
|
+ homeData: [],
|
|
|
+ flag: true,
|
|
|
+ // websocket,
|
|
|
};
|
|
|
},
|
|
|
-mounted(){
|
|
|
- this.navs()
|
|
|
-},
|
|
|
- computed: {
|
|
|
-
|
|
|
+ mounted() {
|
|
|
+ // this.navs();
|
|
|
+ },
|
|
|
+ computed: {},
|
|
|
+
|
|
|
+ created() {
|
|
|
+ this.initWebSocket();
|
|
|
+ },
|
|
|
+ onload() {},
|
|
|
+ destroyed() {
|
|
|
+ this.websock.close(); //离开路由之后断开websocket连接
|
|
|
},
|
|
|
+
|
|
|
methods: {
|
|
|
goRecordTime() {
|
|
|
this.$router.push("/recordTime");
|
|
|
},
|
|
|
- navs() {
|
|
|
- switch (this.$route.name) {
|
|
|
- case "recordTime":
|
|
|
- return [(this.title = '电子巡检记录列表')];
|
|
|
+ initWebSocket() {
|
|
|
+ //初始化weosocket
|
|
|
+ const wsuri = "ws://172.16.120.210:6001";
|
|
|
+ this.websock = new WebSocket(wsuri);
|
|
|
+ this.websock.onmessage = this.websocketonmessage;
|
|
|
+ this.websock.onopen = this.websocketonopen;
|
|
|
+ this.websock.onerror = this.websocketonerror;
|
|
|
+ this.websock.onclose = this.websocketclose;
|
|
|
+ },
|
|
|
+ websocketonopen() {
|
|
|
+ //连接建立之后执行send方法发送数据
|
|
|
+ let actions = { CMD: "getStationInfo" };
|
|
|
+ this.websocketsend(JSON.stringify(actions));
|
|
|
+ },
|
|
|
+ websocketonerror() {
|
|
|
+ //连接建立失败重连
|
|
|
+ this.initWebSocket();
|
|
|
+ },
|
|
|
+ websocketonmessage(e) {
|
|
|
+ //数据接收
|
|
|
+ if (e.data.search("{") != -1) {
|
|
|
+ const redata = JSON.parse(e.data);
|
|
|
+ console.log(redata);
|
|
|
+
|
|
|
+ // 初始化获取站点下拉数据
|
|
|
+ if (redata.CMD == "getStationInfo") {
|
|
|
+ this.siteList = redata.RESULT;
|
|
|
+ // console.log(this.siteList)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果有站点选项,发送请求获取站点信息页数据
|
|
|
+ if (this.flag) {
|
|
|
+ if (this.siteList[0].StationID) {
|
|
|
+ this.websocketsend(
|
|
|
+ JSON.stringify({
|
|
|
+ CMD: "getStationDetail",
|
|
|
+ StationID: "7c9c30af-6132-43d1-98fb-020395183094",
|
|
|
+ })
|
|
|
+ );
|
|
|
+ this.flag = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (redata.CMD == "getStationDetail") {
|
|
|
+ this.homeData = redata.RESULT.LIST;
|
|
|
+ console.log(this.homeData);
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
+ websocketsend(Data) {
|
|
|
+ //数据发送
|
|
|
+ this.websock.send(Data);
|
|
|
+ },
|
|
|
+
|
|
|
+ websocketclose(e) {
|
|
|
+ //关闭
|
|
|
+ console.log("断开连接", e);
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|