修改页面

master
zhaowei 3 years ago
parent 584adf83f9
commit 7d6bad04ab

@ -52,7 +52,7 @@
<img src="../../../assets/images/设置.png" class="iconImg" alt /> <img src="../../../assets/images/设置.png" class="iconImg" alt />
</div> </div>
<span class="span1">设备状态</span> <span class="span1">设备状态</span>
<span class="span1">{{item.status==0?'正常':'异常'}}</span> <span class="span1">{{item.status==1?'正常':'异常'}}</span>
<!-- <template slot-scope="scope"> <!-- <template slot-scope="scope">
<span class="span1" v-if="scope.row.stasus == '1'"></span> <span class="span1" v-if="scope.row.stasus == '1'"></span>
<span class="span1" v-else-if="scope.row.status == '0'">正常</span> <span class="span1" v-else-if="scope.row.status == '0'">正常</span>
@ -78,12 +78,12 @@
</el-col> </el-col>
</el-row> </el-row>
<div :class="item.status==0?'shadows':'active'" slot="reference"></div> <div :class="item.status==1?'shadows':'active'" slot="reference"></div>
</el-popover> </el-popover>
<div class="deleteIcon" @click="removeItem(index,deviceData)"> <div class="deleteIcon" @click="removeItem(index,deviceData)">
<img src="../../../assets/images/删除.png" class="deleteImg" alt /> <img src="../../../assets/images/删除.png" class="deleteImg" alt />
</div> </div>
<span class="deviceStatus">{{item.status==0?'正常':'异常'}}</span> <span class="deviceStatus">{{item.status==1?'正常':'异常'}}</span>
<span class="deviceNumber">{{item.deviceId}}</span> <span class="deviceNumber">{{item.deviceId}}</span>
<img src="../../../assets/images/喇叭.png" class="deviceImg" alt /> <img src="../../../assets/images/喇叭.png" class="deviceImg" alt />
@ -151,11 +151,10 @@ export default {
addDevice: false, addDevice: false,
form: { form: {
location: null, location: null,
deviceIp: null, deviceIp: null,
note: null, note: null,
volume:null, volume: null
}, },
rules: {}, rules: {},
deviceData: [] deviceData: []
@ -163,8 +162,62 @@ export default {
}, },
created() { created() {
this.getList(); this.getList();
this.initWebSocket();
}, },
methods: { methods: {
initWebSocket() {
if (typeof WebSocket == "undefined") {
console.log("您的浏览器不支持WebSocket");
} else {
console.log("您的浏览器支持WebSocket");
const a = "123:0";
const arr = a.split(":");
console.log(arr[0]);
if (this.socket != null) {
this.socket.close();
this.socket = null;
}
//WebSocket
this.socket = new WebSocket(
"ws://192.168.31.27:8080/websocket/message"
);
//
this.socket.onopen = function() {
console.log("websocket已打开");
};
//
listMusic(this.queryParams).then(result => {
this.deviceData = result.rows;
this.loading = false;
console.log(this.deviceData,888)
});
this.socket.onmessage = function(msg) {
// deviceId:0 status:'1'
console.log(msg.data);
const deviceMsg = msg.data.split(":");
// this.deviceData = msg.data;
console.log(999)
this.deviceData.forEach(element => {
if (element.deviceId === deviceMsg[0]) {
element.status = deviceMsg[1];
}
});
//
};
// console.log(this.deviceData,888)
//
this.socket.onclose = function() {
console.log("websocket已关闭");
};
//
this.socket.onerror = function() {
console.log("websocket发生了错误");
};
}
},
// //
getList() { getList() {
this.loading = true; this.loading = true;
@ -189,9 +242,7 @@ export default {
// this.deviceData.push({location}); // this.deviceData.push({location});
}, },
// //
deleteDevice(){ deleteDevice() {},
},
// //
removeItem(index, deviceData) { removeItem(index, deviceData) {
this.$modal this.$modal
@ -202,9 +253,7 @@ export default {
.then(() => { .then(() => {
this.$modal.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}) })
.catch(() => { .catch(() => {});
});
} }
} }
}; };

@ -37,8 +37,8 @@
<el-table-column prop="deviceIp" label="IP地址" width="130" height="25" align="center"></el-table-column> <el-table-column prop="deviceIp" label="IP地址" width="130" height="25" align="center"></el-table-column>
<el-table-column prop="status" label="设备状态" height="25" width="80" align="center"> <el-table-column prop="status" label="设备状态" height="25" width="80" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<span v-if="scope.row.status == '0'"></span> <span v-if="scope.row.status == '1'"></span>
<span v-else-if="scope.row.status == '1'">异常</span> <span v-else-if="scope.row.status == '0'">异常</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="note" label="音符" width="70" height="25" align="center"></el-table-column> <el-table-column prop="note" label="音符" width="70" height="25" align="center"></el-table-column>

@ -35,7 +35,7 @@ module.exports = {
proxy: { proxy: {
// detail: https://cli.vuejs.org/config/#devserver-proxy // detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_API]: { [process.env.VUE_APP_BASE_API]: {
target: `http://192.168.31.97:8080`, target: `http://192.168.31.27:8080`,
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: '' ['^' + process.env.VUE_APP_BASE_API]: ''

Loading…
Cancel
Save