update
This commit is contained in:
parent
946e529ce2
commit
a05876d836
@ -11,7 +11,7 @@
|
||||
<el-col :span="8">
|
||||
<el-form-item :label="tLang('device', '机架号')" prop="label">
|
||||
<el-input v-model="form.label" :placeholder="tLang('common', '请输入') + tLang('device', '机架号')"
|
||||
:disabled="form.id !== null" />
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
|
@ -141,6 +141,7 @@ import StackBarChart from './component/stackBarChart.vue';
|
||||
import Progress from './component/Progress.vue';
|
||||
import LineChart from './component/lineChart.vue';
|
||||
import { useRoute,useRouter } from 'vue-router';
|
||||
import { connectWebsocket, closeWebsocket} from "@/utils/websocket";
|
||||
import { listDevice, deviceCheck, deviceRepair, deviceStatusById, deviceStatusChart,deviceRateChart,deviceElectChart } from '@/api/screen/micro'
|
||||
|
||||
|
||||
@ -240,6 +241,27 @@ function getdeviceElectChart() {
|
||||
function handleBack() {
|
||||
router.go(-1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//socket
|
||||
function getWebsocket(val) {
|
||||
try {
|
||||
let data = JSON.parse(val);
|
||||
|
||||
if (data.type == "status" && data.msg.id == id.value) {
|
||||
let obj = data.msg;
|
||||
devStatus.state = obj.status;
|
||||
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
function errWebsocket(val) {
|
||||
// headerref.value.HeadererrWebsocket(val)
|
||||
// console.log(val);
|
||||
}
|
||||
onMounted(() => {
|
||||
id.value = route.params.id;
|
||||
getDeviceCheck();
|
||||
@ -249,8 +271,11 @@ onMounted(() => {
|
||||
getDeviceStatusChart()
|
||||
getDeviceRateChart()
|
||||
getdeviceElectChart()
|
||||
connectWebsocket('','',getWebsocket, errWebsocket)
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
closeWebsocket()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
@ -174,6 +174,7 @@ import u157 from './image/u157.png'
|
||||
import u158 from './image/u158.png'
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css'
|
||||
import { getConfigKey } from "@/api/system/config";
|
||||
import { connectWebsocket, closeWebsocket} from "@/utils/websocket";
|
||||
import { listDevice, listElect, electMonitoring, deviceStatus, deviceRate,deviceCheck,deviceRepair } from '@/api/screen/micro'
|
||||
|
||||
let {proxy} = getCurrentInstance()
|
||||
@ -229,6 +230,22 @@ function getListDevice() {
|
||||
})
|
||||
}
|
||||
|
||||
let timer = 10000;
|
||||
|
||||
//节流
|
||||
function throttle(func, wait) {
|
||||
let lastTime = 0;
|
||||
|
||||
return function(...args) {
|
||||
const now = Date.now();
|
||||
|
||||
if (now - lastTime >= wait) {
|
||||
lastTime = now;
|
||||
func.apply(this, args);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let sortBarChartData = ref([])
|
||||
//获取设备能耗排行
|
||||
function getlistElect() {
|
||||
@ -322,6 +339,35 @@ function handlePush2item(row) {
|
||||
path: '/screen/devItem_' + row.id,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
//socket
|
||||
function getWebsocket(val) {
|
||||
try {
|
||||
let data = JSON.parse(val);
|
||||
|
||||
if (data.type == "status") {
|
||||
let obj = data.msg;
|
||||
let flag = false;
|
||||
devList.value.forEach(item => {
|
||||
if (item.id == obj.id) {
|
||||
item.state = obj.status
|
||||
// item.runTime = obj.runTime
|
||||
flag = true
|
||||
}
|
||||
})
|
||||
if (flag) {
|
||||
throttle(getdeviceStatus, timer)()
|
||||
}
|
||||
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
function errWebsocket(val) {
|
||||
// console.log(val);
|
||||
}
|
||||
onMounted(() => {
|
||||
getListDevice()
|
||||
getlistElect()
|
||||
@ -331,8 +377,11 @@ onMounted(() => {
|
||||
getdeviceCheck()
|
||||
getConfigKeyFun('screen.microFactory.title')
|
||||
|
||||
connectWebsocket('','',getWebsocket, errWebsocket)
|
||||
|
||||
})
|
||||
onUnmounted(() => {
|
||||
closeWebsocket()
|
||||
})
|
||||
</script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user