报警信息开发完成
This commit is contained in:
parent
6971ad77f6
commit
cf83cdeb1d
@ -65,9 +65,21 @@ export const useMqtt = () => {
|
||||
}
|
||||
|
||||
const publish = (topic, message) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (client.value && connected.value) {
|
||||
client.value.publish(topic, message)
|
||||
client.value.publish(topic, message, { qos: 1 }, (error) => {
|
||||
if (error) {
|
||||
console.error('发送消息失败:', error)
|
||||
reject(error)
|
||||
} else {
|
||||
console.log('发送消息成功:', topic)
|
||||
resolve(true)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
reject(new Error('MQTT 客户端未连接'))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const disconnect = () => {
|
||||
|
@ -32,6 +32,10 @@ const options = [
|
||||
value: 'conductorDiameter',
|
||||
label: '导体直径',
|
||||
children: [
|
||||
{
|
||||
value: 'conductorDiameter',
|
||||
label: '导体直径'
|
||||
},
|
||||
{
|
||||
value: 'conductorDiameterX',
|
||||
label: '导体直径X'
|
||||
@ -46,30 +50,136 @@ const options = [
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
value: 'hotOuterDiameter',
|
||||
label: '热外径',
|
||||
children: [
|
||||
{
|
||||
value: 'hotOuterDiameter',
|
||||
label: '热外径'
|
||||
},
|
||||
{
|
||||
value: 'hotOuterDiameterX',
|
||||
label: '热外径X'
|
||||
},
|
||||
{
|
||||
value: 'hotOuterDiameterY',
|
||||
label: '热外径Y'
|
||||
},
|
||||
{
|
||||
value: 'hotOuterDiameterOval',
|
||||
label: '热外径椭圆度'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
value: 'coldOuterDiameter',
|
||||
label: '冷外径'
|
||||
},
|
||||
{
|
||||
value: 'totalThickness',
|
||||
label: '总厚度',
|
||||
children: [
|
||||
{
|
||||
value: 'totalThickness',
|
||||
label: '总厚度'
|
||||
},
|
||||
{
|
||||
value: 'totalThicknessMin',
|
||||
label: '总厚度最小厚度'
|
||||
},
|
||||
{
|
||||
value: 'totalThickness',
|
||||
label: '总厚度偏心'
|
||||
},
|
||||
{
|
||||
value: 'totalThicknessOval',
|
||||
label: '总厚度偏心度'
|
||||
},
|
||||
{
|
||||
value: 'totalThicknessMax',
|
||||
label: '总厚度同心度'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
value: 'innerShieldThickness',
|
||||
label: '内屏层厚度',
|
||||
children: [
|
||||
{
|
||||
value: 'innerShieldThickness',
|
||||
label: '内屏层厚度'
|
||||
},
|
||||
{
|
||||
value: 'innerShieldThicknessMin',
|
||||
label: '内屏层最小厚度'
|
||||
},
|
||||
{
|
||||
value: 'innerShieldThicknessMax',
|
||||
label: '内屏层偏心'
|
||||
},
|
||||
{
|
||||
value: 'innerShieldThicknessOval',
|
||||
label: '内屏层同心度'
|
||||
},
|
||||
{
|
||||
value: 'innerShieldThicknessMax',
|
||||
label: '内屏层偏心度'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
value: 'insulationThickness',
|
||||
label: '绝缘层厚度',
|
||||
children: [
|
||||
{
|
||||
value: 'insulationThickness',
|
||||
label: '绝缘层厚度'
|
||||
},
|
||||
{
|
||||
value: 'insulationThicknessMin',
|
||||
label: '绝缘层最小厚度'
|
||||
},
|
||||
{
|
||||
value: 'insulationThicknessMax',
|
||||
label: '绝缘层偏心'
|
||||
},
|
||||
{
|
||||
value: 'insulationThicknessOval',
|
||||
label: '绝缘层同心度'
|
||||
},
|
||||
{
|
||||
value: 'insulationThicknessMax',
|
||||
label: '绝缘层偏心度'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
value: 'outerShieldThickness',
|
||||
label: '外屏层厚度',
|
||||
children: [
|
||||
{
|
||||
value: 'outerShieldThickness',
|
||||
label: '外屏层厚度'
|
||||
},
|
||||
{
|
||||
value: 'outerShieldThicknessMin',
|
||||
label: '外屏层最小厚度'
|
||||
},
|
||||
{
|
||||
value: 'outerShieldThicknessMax',
|
||||
label: '外屏层偏心'
|
||||
},
|
||||
{
|
||||
value: 'outerShieldThicknessOval',
|
||||
label: '外屏层同心度'
|
||||
},
|
||||
{
|
||||
value: 'outerShieldThicknessMax',
|
||||
label: '外屏层偏心度'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
value: 'productionInfo',
|
||||
label: '生产线信息'
|
||||
|
@ -70,13 +70,47 @@ const drawCircles = () => {
|
||||
ctx.fillStyle = fillColor
|
||||
ctx.fill()
|
||||
}
|
||||
// for (let i = 0; i < 3; i++) {
|
||||
// // 绘制45-90度红色扇形
|
||||
// ctx.beginPath()
|
||||
// ctx.arc(centerX, centerY, radii[i], Math.PI / 4, Math.PI / 2)
|
||||
// ctx.arc(centerX, centerY, radii[i + 1], Math.PI / 2, Math.PI / 4, true)
|
||||
// ctx.closePath()
|
||||
//
|
||||
// if ((props.selectedLayer === 'inner' && i === 0) ||
|
||||
// (props.selectedLayer === 'middle' && i === 1) ||
|
||||
// (props.selectedLayer === 'outer' && i === 2)) {
|
||||
// ctx.fillStyle = '#FF0000'
|
||||
// } else {
|
||||
// ctx.fillStyle = '#F5F7FA'
|
||||
// }
|
||||
// ctx.fill()
|
||||
//
|
||||
// // 绘制其余部分为蓝色
|
||||
// ctx.beginPath()
|
||||
// ctx.arc(centerX, centerY, radii[i], 0, Math.PI / 4)
|
||||
// ctx.arc(centerX, centerY, radii[i + 1], Math.PI / 4, 0, true)
|
||||
// ctx.arc(centerX, centerY, radii[i], Math.PI / 2, Math.PI * 2)
|
||||
// ctx.arc(centerX, centerY, radii[i + 1], Math.PI * 2, Math.PI / 2, true)
|
||||
// ctx.closePath()
|
||||
//
|
||||
// if ((props.selectedLayer === 'inner' && i === 0) ||
|
||||
// (props.selectedLayer === 'middle' && i === 1) ||
|
||||
// (props.selectedLayer === 'outer' && i === 2)) {
|
||||
// ctx.fillStyle = '#1D4389'
|
||||
// } else {
|
||||
// ctx.fillStyle = '#F5F7FA'
|
||||
// }
|
||||
// ctx.fill()
|
||||
// }
|
||||
|
||||
// // // 绘制第一个圆环(固定位置)
|
||||
ctx.beginPath()
|
||||
ctx.arc(centerX, centerY, radii[0], 0, 2 * Math.PI)
|
||||
ctx.arc(centerX, centerY, radii[1], 0, 2 * Math.PI, true)
|
||||
ctx.closePath()
|
||||
ctx.fillStyle = props.selectedLayer === 'inner' ? '#1D4389' : '#F5F7FA'
|
||||
ctx.fill()
|
||||
// ctx.beginPath()
|
||||
// ctx.arc(centerX, centerY, radii[0], 0, 2 * Math.PI)
|
||||
// ctx.arc(centerX, centerY, radii[1], 0, 2 * Math.PI, true)
|
||||
// ctx.closePath()
|
||||
// ctx.fillStyle = props.selectedLayer === 'inner' ? '#1D4389' : '#F5F7FA'
|
||||
// ctx.fill()
|
||||
// 绘制第二个圆环(偏心位置)
|
||||
// console.log(centerX, centerY, radii[0], radii[1], radii[2])
|
||||
// angles.forEach((angle, index) => {
|
||||
|
@ -2,28 +2,30 @@
|
||||
<div class="device-status-table">
|
||||
<el-table :data="tableData" border style="width: 100%">
|
||||
<el-table-column prop="name" label="参数" align="center" />
|
||||
<el-table-column prop="arm1" label="扫描臂1" align="center">
|
||||
<el-table-column prop="scanner1" label="扫描臂1" align="center">
|
||||
<template #default="scope">
|
||||
<template v-if="scope.row.type === 'tag'">
|
||||
<el-tag :type="scope.row.arm1.type" effect="plain">
|
||||
{{ scope.row.arm1.value }}
|
||||
</el-tag>
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ scope.row.arm1 }}
|
||||
</template>
|
||||
<!-- <template v-if="scope.row.type === 'tag'">-->
|
||||
<!-- <el-tag :type="scope.row.scanner1.type" effect="plain">-->
|
||||
<!-- {{ scope.row.arm1.value }}-->
|
||||
<!-- </el-tag>-->
|
||||
<!-- </template>-->
|
||||
<!-- <template v-else>-->
|
||||
<!-- {{ scope.row.scanner1 }}-->
|
||||
<!-- </template>-->
|
||||
{{ scope.row.scanner1 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="arm2" label="扫描臂2" align="center">
|
||||
<el-table-column prop="scanner2" label="扫描臂2" align="center">
|
||||
<template #default="scope">
|
||||
<template v-if="scope.row.type === 'tag'">
|
||||
<el-tag :type="scope.row.arm2.type" effect="plain">
|
||||
{{ scope.row.arm2.value }}
|
||||
</el-tag>
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ scope.row.arm2 }}
|
||||
</template>
|
||||
<!-- <template v-if="scope.row.type === 'tag'">-->
|
||||
<!-- <el-tag :type="scope.row.scanner2.type" effect="plain">-->
|
||||
<!-- {{ scope.row.scanner2.value }}-->
|
||||
<!-- </el-tag>-->
|
||||
<!-- </template>-->
|
||||
<!-- <template v-else>-->
|
||||
<!-- {{ scope.row.scanner2 }}-->
|
||||
<!-- </template>-->
|
||||
{{ scope.row.scanner2 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -31,33 +33,43 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
|
||||
import { ref,watch} from 'vue'
|
||||
const props = defineProps({
|
||||
statusData: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
const tableData = computed(() => [
|
||||
{ name: '通信状态', arm1: props.statusData.arm1.communication, arm2: props.statusData.arm2.communication },
|
||||
{ name: '故障状态', arm1: props.statusData.arm1.fault, arm2: props.statusData.arm2.fault },
|
||||
{ name: '使能状态', arm1: props.statusData.arm1.enable, arm2: props.statusData.arm2.enable },
|
||||
{ name: '当前位置', arm1: props.statusData.arm1.position, arm2: props.statusData.arm2.position },
|
||||
{ name: '当前速度[r/min]', arm1: props.statusData.arm1.speed, arm2: props.statusData.arm2.speed },
|
||||
const tableData = ref([])
|
||||
watch(() => props.statusData, (newVal) => {
|
||||
tableData.value = [
|
||||
{ name: '电源通信状态', scanner1: props.statusData?.scanner1.power.communication_status === '1' ? '正常' : '异常',
|
||||
scanner2: props.statusData?.scanner2.power.communication_status === '1' ? '正常' : '异常' },
|
||||
{ name: '电源故障状态', scanner1:props.statusData.scanner1.power.failure_status === '1' ? '正常' : '异常',
|
||||
scanner2: props.statusData.scanner2.power.failure_status === '1' ? '正常' : '异常' },
|
||||
{ name: '电源使能状态', scanner1: props.statusData.scanner1.power.enable_status === 0 ? '未启用' : '启用',
|
||||
scanner2: props.statusData.scanner2.power.enable_status === 0 ? '未启用' : '启用' },
|
||||
{ name: '当前位置', scanner1: props.statusData.scanner1.motor.position === 0?'原位' : props.statusData.scanner1.motor.position === 1 ? '上过渡段' : props.statusData.scanner1.motor.position === 2 ? '扫描段' : '下过渡段',
|
||||
scanner2: props.statusData.scanner2.motor.position === 0 ? '原位' : props.statusData.scanner2.motor.position === 1 ? '上过渡段' : props.statusData.scanner2.motor.position === 2 ? '扫描段' : '下过渡段' },
|
||||
{ name: '当前速度[r/min]', scanner1: props.statusData.scanner1.motor.velocity, scanner2: props.statusData.scanner2.motor.velocity },
|
||||
{
|
||||
name: '射线电源开关',
|
||||
type: 'tag',
|
||||
arm1: props.statusData.arm1.powerSwitch,
|
||||
arm2: props.statusData.arm2.powerSwitch
|
||||
scanner1: props.statusData.scanner1.power.switch === 0 ? '关闭': '打开',
|
||||
scanner2: props.statusData.scanner2.power.switch === 0 ? '关闭': '打开'
|
||||
},
|
||||
{ name: '射线电源安全锁', arm1: props.statusData.arm1.safetyLock, arm2: props.statusData.arm2.safetyLock },
|
||||
{ name: '射线电源设定电压[V]', arm1: props.statusData.arm1.voltageSet, arm2: props.statusData.arm2.voltageSet },
|
||||
{ name: '射线电源反馈电压[V]', arm1: props.statusData.arm1.voltageFeedback, arm2: props.statusData.arm2.voltageFeedback },
|
||||
{ name: '射线电源反馈电流[μA]', arm1: props.statusData.arm1.currentFeedback, arm2: props.statusData.arm2.currentFeedback },
|
||||
{ name: '射线电源设定电流[μA]', arm1: props.statusData.arm1.currentSet, arm2: props.statusData.arm2.currentSet }
|
||||
])
|
||||
{ name: '射线电源安全锁', scanner1: props.statusData.scanner1.power.safety_lock === 0 ? '未锁' : '锁定',
|
||||
scanner2: props.statusData.scanner2.power.safety_lock === 0 ? '未锁' : '锁定' },
|
||||
{ name: '射线电源设定电压[V]', scanner1: props.statusData.scanner1.power.voltage_setting_value,
|
||||
scanner2: props.statusData.scanner2.power.voltage_setting_value },
|
||||
{ name: '射线电源反馈电压[V]', scanner1: props.statusData.scanner1.power.voltage_value,
|
||||
scanner2: props.statusData.scanner2.power.voltage_value },
|
||||
{ name: '射线电源反馈电流[μA]', scanner1: props.statusData.scanner1.power.current_value,
|
||||
scanner2: props.statusData.scanner2.power.current_value },
|
||||
{ name: '射线电源设定电流[μA]', scanner1: props.statusData.scanner1.power.current_setting_value,
|
||||
scanner2: props.statusData.scanner2.power.current_setting_value }
|
||||
]
|
||||
}, { deep: true })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
@ -2,9 +2,9 @@
|
||||
<div class="equipment-container">
|
||||
<div class="data-overview">
|
||||
<div class="data-left">
|
||||
<div class="equipment-name">设备名称(设备编码)</div>
|
||||
<el-button type="info" size="small">离线</el-button>
|
||||
<div style="margin-left:16px;color:#606266">时间显示</div>
|
||||
<div class="equipment-name">{{ deviceInfo?.deviceName }}({{deviceInfo?.deviceCode}})</div>
|
||||
<el-button type="info" size="small" v-if="deviceShowStatus">{{deviceShowStatus}}</el-button>
|
||||
<!-- <div style="margin-left:16px;color:#606266">时间显示</div>-->
|
||||
</div>
|
||||
<div class="action-buttons">
|
||||
<div class="button-group">
|
||||
@ -17,10 +17,10 @@
|
||||
<!-- </el-button>-->
|
||||
<el-button
|
||||
:type="mode === 'fast' ? 'primary' : ''"
|
||||
@click="handleModeChange('fast')"
|
||||
@click="handleModeChange()"
|
||||
>
|
||||
<el-icon><Timer /></el-icon>
|
||||
快速模式
|
||||
{{modeTypeMap[deviceMode]}}
|
||||
</el-button>
|
||||
|
||||
<el-button
|
||||
@ -111,7 +111,10 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="eccentricity-card" @click="openDialog">
|
||||
<el-icon><Plus></Plus></el-icon>
|
||||
<div style="display: flex;justify-content: center;align-content: center;cursor: pointer">
|
||||
<el-icon style="font-size: 50px;color:red"><Plus></Plus></el-icon>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -164,15 +167,15 @@
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="proxy.$t('equipment.deviceInfo')" name="second">
|
||||
<div class="device-status">
|
||||
<DeviceStatus v-if="!showBtn" :status-data="deviceStatus" />
|
||||
<DeviceSetting v-if="showBtn" @update="handleSettingUpdate" />
|
||||
<DeviceStatus :status-data="deviceStatus" />
|
||||
<!-- <DeviceSetting v-if="showBtn" @update="handleSettingUpdate" />-->
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<div class="btn" v-if="activeTwoName === 'second'">
|
||||
<el-button v-if="!showBtn" type="primary" @click="paramsHandle">{{proxy.$t('equipment.paramsSetting')}}</el-button>
|
||||
<el-button v-if="showBtn" type="primary" @click="paramsHandle">{{proxy.$t('button.return')}}</el-button>
|
||||
</div>
|
||||
<!-- <div class="btn" v-if="activeTwoName === 'second'">-->
|
||||
<!-- <el-button v-if="!showBtn" type="primary" @click="paramsHandle">{{proxy.$t('equipment.paramsSetting')}}</el-button>-->
|
||||
<!-- <el-button v-if="showBtn" type="primary" @click="paramsHandle">{{proxy.$t('button.return')}}</el-button>-->
|
||||
<!-- </div>-->
|
||||
</div>
|
||||
</div>
|
||||
<div class="chart-container" style="margin-top: 14px">
|
||||
@ -189,7 +192,9 @@
|
||||
<el-tab-pane :label="proxy.$t('equipment.warningInfo')" name="second">
|
||||
<div class="warning-container">
|
||||
<div class="warning-item" v-for="(item, index) in warningList" :key="index">
|
||||
{{item.title}}
|
||||
<template v-if="item.info">
|
||||
{{item.label}}:{{item.info}}
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
@ -313,6 +318,7 @@ import {ElMessageBox, ElMessage} from "element-plus";
|
||||
import { useMqtt } from '@/utils/mqttClient.js';
|
||||
import {useRoute} from 'vue-router';
|
||||
import AddMonitorData from './common/AddMonitorData.vue'
|
||||
const deviceShowStatus = ref('')
|
||||
const {
|
||||
connected,
|
||||
messageData,
|
||||
@ -321,8 +327,11 @@ const {
|
||||
disconnect,
|
||||
publish
|
||||
} = useMqtt()
|
||||
const deviceInfo = ref(null)
|
||||
const clientId = ref('vue-client-' + Math.random().toString(16).substring(2, 8))
|
||||
const deviceInfo = ref({})
|
||||
const deviceData = ref(null)
|
||||
const deviceMode = ref(null)
|
||||
const xRayStatus = ref(null)
|
||||
const { proxy } = getCurrentInstance();
|
||||
const route = useRoute()
|
||||
const deviceId = ref(null)
|
||||
@ -345,7 +354,6 @@ const dualChart2Ref = ref(null)
|
||||
const dualChart1PageRef = ref(null)
|
||||
const dualChart2PageRef = ref(null)
|
||||
const bowlCurvePageRef = ref(null)
|
||||
const xRayStatus = ref(false)
|
||||
const activeName = ref('first')
|
||||
const activeTwoName = ref('first')
|
||||
const activeThreeName = ref('first')
|
||||
@ -357,6 +365,11 @@ const chartTitle = ref({
|
||||
left: '扫描臂1 曲线',
|
||||
right: '扫描臂2 曲线'
|
||||
})
|
||||
const modeTypeMap = {
|
||||
'fast':'快速模式',
|
||||
'normal':'正常速度',
|
||||
'slow':'慢速模式'
|
||||
};
|
||||
const cardList = ref([
|
||||
{ title: '外屏层偏心度' },
|
||||
{ title: '内屏层偏心度' },
|
||||
@ -365,11 +378,9 @@ const cardList = ref([
|
||||
{ title: '内屏层厚度' },
|
||||
// { title: '绝缘层厚度' }
|
||||
])
|
||||
const warningList = ref([
|
||||
{ title: '设备1离线', status: 'offline' },
|
||||
{ title: '设备2离线', status: 'offline' },
|
||||
{ title: '设备3离线', status: 'offline' }
|
||||
])
|
||||
const warningList = ref([])
|
||||
const warningInserted = ref(false)
|
||||
|
||||
// 示意图数据
|
||||
const innerLayerData = ref([0.68, 0.85, 1.07, 1.18, 1.13, 0.97, 0.67, 0.98])
|
||||
const middleLayerData = ref([9.52, 9.95, 10.53, 11.04, 11.34, 11.15, 9.66, 10.40])
|
||||
@ -387,34 +398,7 @@ const temperatureData = ref({
|
||||
'2023-01-01 14:00:00'
|
||||
]
|
||||
})
|
||||
const deviceStatus = ref({
|
||||
arm1: {
|
||||
communication: '正常',
|
||||
fault: '正常',
|
||||
enable: '未使用',
|
||||
position: '下过渡段',
|
||||
speed: '0',
|
||||
powerSwitch: { value: '关闭', type: 'danger' },
|
||||
safetyLock: '打开',
|
||||
voltageSet: '55000',
|
||||
voltageFeedback: '15',
|
||||
currentFeedback: '2',
|
||||
currentSet: '1800'
|
||||
},
|
||||
arm2: {
|
||||
communication: '正常',
|
||||
fault: '正常',
|
||||
enable: '未使用',
|
||||
position: '下过渡段',
|
||||
speed: '0',
|
||||
powerSwitch: { value: '关闭', type: 'danger' },
|
||||
safetyLock: '打开',
|
||||
voltageSet: '55000',
|
||||
voltageFeedback: '0',
|
||||
currentFeedback: '2',
|
||||
currentSet: '1800'
|
||||
}
|
||||
})
|
||||
const deviceStatus = ref({})
|
||||
const addMonitorRef = ref(null)
|
||||
// 表格数据
|
||||
const tableData = ref([
|
||||
@ -443,8 +427,9 @@ const handleDataConfirm = (dataType) => {
|
||||
}
|
||||
// mqtt连接
|
||||
const mqttConnect = () => {
|
||||
console.log(clientId.value)
|
||||
connect('ws://123.57.81.127:8085/mqtt', { // 添加 /mqtt 路径
|
||||
clientId: 'vue-client-' + Math.random().toString(16).substring(2, 8),
|
||||
clientId: clientId.value,
|
||||
username: 'cepianyi',
|
||||
password: 'cpy123',
|
||||
protocol: 'ws',
|
||||
@ -454,7 +439,6 @@ const mqttConnect = () => {
|
||||
connectTimeout: 30 * 1000,
|
||||
path: '/mqtt'// 指定 WebSocket 路径
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
const deleteCard = (index) => {
|
||||
@ -536,7 +520,8 @@ const generateData = (type) => {
|
||||
}
|
||||
// 标签页切换
|
||||
const handleClick = (tab, event) => {
|
||||
console.log(tab.props.label,'----')
|
||||
// console.log(tab.props.label,'----')
|
||||
console.log(deviceStatus.value,'===')
|
||||
nextTick(() => {
|
||||
if(tab.props.label === '趋势图') {
|
||||
realtimeChartRef.value?.resize()
|
||||
@ -571,8 +556,34 @@ const handleDataUpdate = (data) => {
|
||||
console.log('数据更新:', data)
|
||||
}
|
||||
// 快速模式
|
||||
const handleModeChange = (newMode) => {
|
||||
mode.value = newMode
|
||||
const handleModeChange = () => {
|
||||
ElMessageBox.confirm(
|
||||
'是否确认切换模式?',
|
||||
'提示',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}
|
||||
).then(async() => {
|
||||
try {
|
||||
await publish(`v1/cpy/${deviceInfo.value.deviceCode}/control`, JSON.stringify({
|
||||
method: 'devinput',
|
||||
cid: clientId.value, // guid
|
||||
scanner: "global_dev",
|
||||
dev: 'device', // 高压源power电机 motor 采集板acquisition_board 射线xray 其他设备 device
|
||||
key: 'sports_mode',
|
||||
value: '' // 运动模式 fast快速 normal正常速度 slow慢速
|
||||
}))
|
||||
ElMessage.success('发送命令成功')
|
||||
initSubscribe()
|
||||
} catch (error) {
|
||||
ElMessage.error('发送命令失败')
|
||||
}
|
||||
|
||||
}).catch(() => {
|
||||
// 用户取消操作
|
||||
})
|
||||
}
|
||||
//x射线
|
||||
const handleXRayToggle = () => {
|
||||
@ -584,9 +595,31 @@ const handleXRayToggle = () => {
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}
|
||||
).then(() => {
|
||||
).then(async() => {
|
||||
try {
|
||||
// 这里可以调用接口来切换X射线状态
|
||||
xRayStatus.value = !xRayStatus.value
|
||||
await publish(`v1/cpy/${deviceInfo.value.deviceCode}/control`, JSON.stringify({
|
||||
method: 'devinput',
|
||||
cid:clientId.value,
|
||||
scanner:'scanner1',
|
||||
dev:'xray',
|
||||
key: "switch",
|
||||
value:"1" // 1开 0关
|
||||
}))
|
||||
await publish(`v1/cpy/${deviceInfo.value.deviceCode}/control`, JSON.stringify({
|
||||
method: 'devinput',
|
||||
cid:clientId.value,
|
||||
scanner:'scanner2',
|
||||
dev:'xray',
|
||||
key: "switch",
|
||||
value:"1" // 1开 0关
|
||||
}))
|
||||
ElMessage.success('发送命令成功')
|
||||
initSubscribe()
|
||||
} catch (error) {
|
||||
ElMessage.error('发送命令失败')
|
||||
}
|
||||
|
||||
}).catch(() => {
|
||||
// 用户取消操作
|
||||
})
|
||||
@ -597,21 +630,82 @@ const handleGenerateReport = () => {
|
||||
// 设备分享
|
||||
const handleDeviceShare = () => {
|
||||
}
|
||||
const initSubscribe = () => {
|
||||
// 设备信息
|
||||
subscribe(`v1/cpy/${deviceInfo.value?.deviceCode}/infos`, (message) => {
|
||||
console.log('设备信息消息:', message)
|
||||
// deviceData.value = message
|
||||
if(message){
|
||||
deviceMode.value = message.global_dev.device.sports_mode
|
||||
xRayStatus.value = message.scanner1.xray.enable_status
|
||||
deviceStatus.value = { ...message }
|
||||
if (!warningInserted.value) {
|
||||
warningList.value.push(
|
||||
{label:'scanner1采集板故障信息', info: message.scanner1.acquisition_board.failure_info},
|
||||
{label:'scanner1电源故障信息', info: message.scanner1.power.failure_info},
|
||||
{label:'scanner1射线故障信息', info: message.scanner1.xray.failure_info},
|
||||
{label:'scanner1电机通信状态', info: message.scanner1.motor.failure_info},
|
||||
{label:'scanner2采集板故障信息', info: message.scanner2.acquisition_board.failure_info},
|
||||
{label:'scanner2电源故障信息', info: message.scanner2.power.failure_info},
|
||||
{label:'scanner2射线故障信息', info: message.scanner2.xray.failure_info},
|
||||
{label:'scanner2电机通信状态', info: message.scanner2.motor.failure_info}
|
||||
)
|
||||
warningInserted.value = true
|
||||
}
|
||||
}})
|
||||
// 设备状态
|
||||
subscribe(`v1/cpycal/${deviceInfo.value?.deviceCode}/status`, (message) => {
|
||||
// console.log('设备状态消息:', message)
|
||||
if(message && message.running) {
|
||||
deviceShowStatus.value = proxy.$t('common.online')
|
||||
} else {
|
||||
deviceShowStatus.value = proxy.$t('common.offline')
|
||||
}
|
||||
})
|
||||
// 发设备温度
|
||||
|
||||
// 计算数据
|
||||
subscribe(`v1/cpy/${deviceInfo.value?.deviceCode}/calculation`, (message) => {
|
||||
// console.log('计算数据:', message)
|
||||
// deviceData.value = message
|
||||
// if(message){
|
||||
// deviceMode.value = message.global_dev.device.sports_mode
|
||||
// console.log(deviceMode.value)
|
||||
// xRayStatus.value = message.scanner1.xray.enable_status
|
||||
// }
|
||||
})
|
||||
publish(`v1/cpy/1/request`, JSON.stringify({
|
||||
method: 'temperature',
|
||||
}))
|
||||
// try {
|
||||
// publish(`v1/cpy/1/request`, JSON.stringify({
|
||||
// method: 'temperature',
|
||||
// }))
|
||||
// ElMessage.success('发送命令成功')
|
||||
//
|
||||
// } catch (error) {
|
||||
// ElMessage.error('发送命令失败')
|
||||
// }
|
||||
// subscribe(`v1/cpy/${clientId.value}/receive`, (message) => {
|
||||
// console.log('设备温度:', message)
|
||||
// })
|
||||
}
|
||||
// 获取设备详细信息
|
||||
const getDeviceDetail = async () => {
|
||||
try {
|
||||
const response = await getDeviceDetailApi(deviceId.value)
|
||||
console.log('设备信息:', deviceInfo.value)
|
||||
const res = await getDeviceDetailApi(deviceId.value)
|
||||
deviceInfo.value = res.data
|
||||
initSubscribe()
|
||||
} catch (error) {
|
||||
console.error('获取设备信息失败:', error)
|
||||
ElMessage.error(error.message)
|
||||
}
|
||||
}
|
||||
onMounted(() => {
|
||||
onMounted(async() => {
|
||||
if(route.query.id) {
|
||||
deviceId.value= route.query.id;
|
||||
mqttConnect()
|
||||
await getDeviceDetail()
|
||||
}
|
||||
|
||||
mqttConnect()
|
||||
generateData()
|
||||
})
|
||||
onBeforeUnmount(() => {
|
||||
|
@ -83,9 +83,6 @@
|
||||
<el-table-column :label="proxy.$t('equipment.lifespan')" width="140" align="center" prop="lifespan" />
|
||||
<el-table-column :label="proxy.$t('equipment.usedTime')" width="140" align="center" prop="usedTime" />
|
||||
<el-table-column :label="proxy.$t('equipment.deviceStatus')" align="center" prop="deviceStatus" width="100">
|
||||
<template #default="scope">
|
||||
{{statusFormat(scope.row.deviceStatus)}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="proxy.$t('equipment.serviceStatus')" align="center" prop="serviceStatus" width="100">
|
||||
</el-table-column>
|
||||
@ -333,6 +330,24 @@ const exportDevice = async() => {
|
||||
`equipment_${new Date().getTime()}.xlsx`
|
||||
);
|
||||
}
|
||||
const subscribeDeviceStatus = () => {
|
||||
if (deviceList.value.length > 0) {
|
||||
deviceList.value.forEach(item => {
|
||||
subscribe(`v1/cpycal/${item.deviceCode}/status`, (message) => {
|
||||
console.log('设备状态消息:', message)
|
||||
const index = deviceList.value.findIndex(device => device.deviceCode === item.deviceCode)
|
||||
if (index !== -1) {
|
||||
const updatedDevice = {
|
||||
...deviceList.value[index],
|
||||
serviceStatus: message.running ? proxy.$t('common.online') : proxy.$t('common.offline'),
|
||||
deviceStatus: message.running ? proxy.$t('common.online') : proxy.$t('common.offline')
|
||||
}
|
||||
deviceList.value.splice(index, 1, updatedDevice)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
// 获取客户列表
|
||||
const getCustomerList = async() => {
|
||||
const res = await getCustomerListApi(queryParamsCustomer);
|
||||
@ -345,20 +360,7 @@ const getList = async() => {
|
||||
if(res.code === 200) {
|
||||
deviceList.value = res.rows || []
|
||||
total.value = res.total
|
||||
if (deviceList.value.length > 0) {
|
||||
deviceList.value.map(item => {
|
||||
subscribe(`v1/cpycal/${item.deviceCode}/status`, (message) => {
|
||||
console.log('Received message:', message)
|
||||
const index = deviceList.value.findIndex(device => device.deviceCode === item.deviceCode)
|
||||
if (index !== -1) {
|
||||
deviceList.value[index] = {
|
||||
...deviceList.value[index],
|
||||
serviceStatus: message.running ? '在线' : '离线'
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
subscribeDeviceStatus()
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
@ -442,7 +444,6 @@ const handleEmqx = async (row) => {
|
||||
// 编辑
|
||||
const handleUpdate = async(row) => {
|
||||
const res = await getDeviceDetailApi(row.id)
|
||||
console.log(res.data,'===')
|
||||
if(res.code === 200) {
|
||||
dialog.title = proxy.$t('button.edit')
|
||||
dialog.visible = true
|
||||
|
Loading…
Reference in New Issue
Block a user