联调正式检测
This commit is contained in:
@@ -103,6 +103,7 @@ export namespace CheckData {
|
|||||||
devCurr: number; //设备电流
|
devCurr: number; //设备电流
|
||||||
factorFlag: number; //是否支持系数校准
|
factorFlag: number; //是否支持系数校准
|
||||||
checkResult:number; //检测结果
|
checkResult:number; //检测结果
|
||||||
|
chnNumList: object[]; //连线存储数据
|
||||||
}
|
}
|
||||||
|
|
||||||
// 用来描述检测脚本类型
|
// 用来描述检测脚本类型
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ export const useCheckStore = defineStore(CHECK_STORE_KEY, {
|
|||||||
showDetailType: 0, // 0:数据查询 1:误差体系跟换 2:正式检测
|
showDetailType: 0, // 0:数据查询 1:误差体系跟换 2:正式检测
|
||||||
temperature: 0,
|
temperature: 0,
|
||||||
humidity: 0,
|
humidity: 0,
|
||||||
|
chnNumList: [],//连线数据
|
||||||
}),
|
}),
|
||||||
getters: {},
|
getters: {},
|
||||||
actions: {
|
actions: {
|
||||||
@@ -37,6 +38,7 @@ export const useCheckStore = defineStore(CHECK_STORE_KEY, {
|
|||||||
this.selectTestItems.test = true
|
this.selectTestItems.test = true
|
||||||
},
|
},
|
||||||
setSelectTestItems(selectTestItems: CheckData.SelectTestItem) {
|
setSelectTestItems(selectTestItems: CheckData.SelectTestItem) {
|
||||||
|
console.log("🚀 ~ setSelectTestItems ~ selectTestItems:", selectTestItems)
|
||||||
this.selectTestItems = selectTestItems
|
this.selectTestItems = selectTestItems
|
||||||
},
|
},
|
||||||
setCheckType(checkType: number) {
|
setCheckType(checkType: number) {
|
||||||
@@ -54,6 +56,9 @@ export const useCheckStore = defineStore(CHECK_STORE_KEY, {
|
|||||||
setHumidity(humidity: number) {
|
setHumidity(humidity: number) {
|
||||||
this.humidity = humidity
|
this.humidity = humidity
|
||||||
},
|
},
|
||||||
|
setChnNum(chnNumList: string[]) {
|
||||||
|
this.chnNumList = chnNumList
|
||||||
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -190,7 +190,8 @@ export default class SocketService {
|
|||||||
* WebSocket连接配置
|
* WebSocket连接配置
|
||||||
*/
|
*/
|
||||||
private config: SocketConfig = {
|
private config: SocketConfig = {
|
||||||
url: 'ws://127.0.0.1:7777/hello',
|
// url: 'ws://127.0.0.1:7777/hello',
|
||||||
|
url: 'ws://192.168.1.124:7777/hello',
|
||||||
heartbeatInterval: 9000, // 9秒心跳间隔
|
heartbeatInterval: 9000, // 9秒心跳间隔
|
||||||
reconnectDelay: 5000, // 5秒重连延迟
|
reconnectDelay: 5000, // 5秒重连延迟
|
||||||
maxReconnectAttempts: 5, // 最多重连5次
|
maxReconnectAttempts: 5, // 最多重连5次
|
||||||
|
|||||||
@@ -201,7 +201,6 @@ interface DeviceData {
|
|||||||
const testDataStructure = ref<Record<string, DeviceData>>({});
|
const testDataStructure = ref<Record<string, DeviceData>>({});
|
||||||
|
|
||||||
watch(webMsgSend, function (newValue, oldValue) {
|
watch(webMsgSend, function (newValue, oldValue) {
|
||||||
console.log('webMsgSend', newValue)
|
|
||||||
if (testStatus.value !== 'waiting') {
|
if (testStatus.value !== 'waiting') {
|
||||||
if(newValue.code == 25004){
|
if(newValue.code == 25004){
|
||||||
ElMessage.error('接收数据超时!')
|
ElMessage.error('接收数据超时!')
|
||||||
|
|||||||
@@ -3,55 +3,87 @@
|
|||||||
<div class="dialog" v-bind="dialogBig">
|
<div class="dialog" v-bind="dialogBig">
|
||||||
<div class="dialog-title">
|
<div class="dialog-title">
|
||||||
<div class="timeView">
|
<div class="timeView">
|
||||||
<el-icon style="margin: 0px 5px;">
|
<el-icon style="margin: 0px 5px">
|
||||||
<Clock />
|
<Clock />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
<span>检测用时:{{ timeView }}</span>
|
<span>检测用时:{{ timeView }}</span>
|
||||||
</div>
|
</div>
|
||||||
<el-progress
|
<el-progress style="width: 82%; margin-right: 3%" :percentage="percentage" :color="customColors" />
|
||||||
style="width: 82%; margin-right: 3%;"
|
|
||||||
:percentage="percentage"
|
|
||||||
:color="customColors"/>
|
|
||||||
<el-button style="width: 10%" type="text" :icon="InfoFilled" @click="showTestLog">检测项进度</el-button>
|
<el-button style="width: 10%" type="text" :icon="InfoFilled" @click="showTestLog">检测项进度</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
{{ checkResultView }}
|
||||||
<div class="dialog-content">
|
<div class="dialog-content">
|
||||||
<el-table :data="checkResultView" row-key="scriptType" height="450px"
|
<el-table
|
||||||
:header-cell-style="{ background: 'var(--el-color-primary)', color: '#eee', textAlign: 'center' } " style="width: 100%"
|
:data="checkResultView"
|
||||||
border>
|
row-key="scriptType"
|
||||||
<el-table-column fixed prop="scriptName" label="检测项目" width="150px" align="center">
|
height="450px"
|
||||||
</el-table-column>
|
:header-cell-style="{ background: 'var(--el-color-primary)', color: '#eee', textAlign: 'center' }"
|
||||||
|
style="width: 100%"
|
||||||
|
border
|
||||||
|
>
|
||||||
|
<el-table-column
|
||||||
|
fixed
|
||||||
|
prop="scriptName"
|
||||||
|
label="检测项目"
|
||||||
|
width="150px"
|
||||||
|
align="center"
|
||||||
|
></el-table-column>
|
||||||
|
|
||||||
<template v-if="chnSum <= MAX_CHN_SUM">
|
<template v-if="chnSum <= MAX_CHN_SUM">
|
||||||
<el-table-column v-for="(item,index1) in deviceList" :key="item.deviceId" :label="item.deviceName"
|
<el-table-column
|
||||||
:min-width="110" align="center">
|
v-for="(item, index1) in deviceList"
|
||||||
<el-table-column v-for="(chnItem,index2) in item.chnNum" :key="`${item.deviceId}${chnItem}`"
|
:key="item.deviceId"
|
||||||
:label="'通道'+chnItem" align="center">
|
:label="item.deviceName"
|
||||||
|
:min-width="110"
|
||||||
|
align="center"
|
||||||
|
>
|
||||||
|
<el-table-column
|
||||||
|
v-for="(chnItem, index2) in checkStore.chnNumList"
|
||||||
|
:key="`${item.deviceId}${chnItem}`"
|
||||||
|
:label="'通道' + chnItem.label"
|
||||||
|
align="center"
|
||||||
|
>
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-tooltip
|
<el-tooltip
|
||||||
:content="row.devices[index1].chnResult[index2].icon==='More' ? '暂无数据'
|
:content="
|
||||||
: row.devices[index1].chnResult[index2].icon==='CircleCheckFilled' ? '符合'
|
row.devices[index1].chnResult[index2].icon === 'More'
|
||||||
: row.devices[index1].chnResult[index2].icon==='Close' ? '不符合'
|
? '暂无数据'
|
||||||
: row.devices[index1].chnResult[index2].icon==='WarnTriangleFilled' ? '数据异常'
|
: row.devices[index1].chnResult[index2].icon === 'CircleCheckFilled'
|
||||||
: row.devices[index1].chnResult[index2].icon==='Loading'? '检测中':'连接中断'"
|
? '符合'
|
||||||
placement="right">
|
: row.devices[index1].chnResult[index2].icon === 'Close'
|
||||||
|
? '不符合'
|
||||||
|
: row.devices[index1].chnResult[index2].icon ===
|
||||||
|
'WarnTriangleFilled'
|
||||||
|
? '数据异常'
|
||||||
|
: row.devices[index1].chnResult[index2].icon === 'Loading'
|
||||||
|
? '检测中'
|
||||||
|
: '连接中断'
|
||||||
|
"
|
||||||
|
placement="right"
|
||||||
|
>
|
||||||
<el-button
|
<el-button
|
||||||
:disabled="row.devices[index1].chnResult[index2].color===CheckData.ButtonColorEnum.INFO || row.devices[index1].chnResult[index2].color===CheckData.ButtonColorEnum.LOADING"
|
:disabled="
|
||||||
|
row.devices[index1].chnResult[index2].color ===
|
||||||
|
CheckData.ButtonColorEnum.INFO ||
|
||||||
|
row.devices[index1].chnResult[index2].color ===
|
||||||
|
CheckData.ButtonColorEnum.LOADING
|
||||||
|
"
|
||||||
:color="row.devices[index1].chnResult[index2].color"
|
:color="row.devices[index1].chnResult[index2].color"
|
||||||
size="small"
|
size="small"
|
||||||
@click="handleClick(item, chnItem, row.scriptType)"
|
@click="handleClick(item, chnItem, row.scriptType)"
|
||||||
style="align-self: center;"
|
style="align-self: center"
|
||||||
|
>
|
||||||
|
<el-icon
|
||||||
|
v-if="row.devices[index1].chnResult[index2].icon === 'Loading'"
|
||||||
|
class="loading-box"
|
||||||
|
style="color: #fff"
|
||||||
>
|
>
|
||||||
<el-icon v-if="row.devices[index1].chnResult[index2].icon==='Loading'" class="loading-box"
|
|
||||||
style="color: #fff">
|
|
||||||
<component :is="Loading" />
|
<component :is="Loading" />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
<el-icon v-else style="color: #fff">
|
<el-icon v-else style="color: #fff">
|
||||||
<component :is="row.devices[index1].chnResult[index2].icon" />
|
<component :is="row.devices[index1].chnResult[index2].icon" />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
</el-button>
|
</el-button>
|
||||||
|
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -59,15 +91,24 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-table>
|
</el-table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="drawer-container">
|
<div class="drawer-container">
|
||||||
<el-drawer v-model="drawer" title="检测项进度" direction="btt" :size="'38%'">
|
<el-drawer v-model="drawer" title="检测项进度" direction="btt" :size="'38%'">
|
||||||
<div ref="scrollContainerRef" style="height: 100%; overflow-y: auto;">
|
<div ref="scrollContainerRef" style="height: 100%; overflow-y: auto">
|
||||||
<p v-for="(item, index) in testLogList"
|
<p
|
||||||
|
v-for="(item, index) in testLogList"
|
||||||
:key="index"
|
:key="index"
|
||||||
:style="{color:item.type==='error'?'#F56C6C': item.type==='warning'?'#e6a23c':'var(--el-text-color-regular)'}">
|
:style="{
|
||||||
{{ item.log }}<br/>
|
color:
|
||||||
|
item.type === 'error'
|
||||||
|
? '#F56C6C'
|
||||||
|
: item.type === 'warning'
|
||||||
|
? '#e6a23c'
|
||||||
|
: 'var(--el-text-color-regular)'
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
{{ item.log }}
|
||||||
|
<br />
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
@@ -79,15 +120,16 @@
|
|||||||
<script lang="tsx" setup name="test">
|
<script lang="tsx" setup name="test">
|
||||||
import { InfoFilled, Loading } from '@element-plus/icons-vue'
|
import { InfoFilled, Loading } from '@element-plus/icons-vue'
|
||||||
import CompareDataCheckSingleChannelSingleTestPopup from './compareDataCheckSingleChannelSingleTestPopup.vue'
|
import CompareDataCheckSingleChannelSingleTestPopup from './compareDataCheckSingleChannelSingleTestPopup.vue'
|
||||||
import {computed, ComputedRef, onBeforeMount, reactive, ref, toRef, watch} from "vue";
|
import { computed, ComputedRef, onBeforeMount, reactive, ref, toRef, watch, onMounted } from 'vue'
|
||||||
import {dialogBig} from "@/utils/elementBind";
|
import { dialogBig } from '@/utils/elementBind'
|
||||||
import {CheckData} from "@/api/check/interface"
|
import { CheckData } from '@/api/check/interface'
|
||||||
import {useCheckStore} from "@/stores/modules/check";
|
import { useCheckStore } from '@/stores/modules/check'
|
||||||
import {ElMessage, ElMessageBox} from "element-plus";
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import {getBigTestItem} from "@/api/check/test";
|
import { getBigTestItem } from '@/api/check/test'
|
||||||
import {getAutoGenerate} from "@/api/user/login";
|
import { getAutoGenerate } from '@/api/user/login'
|
||||||
import {generateDevReport} from "@/api/plan/plan";
|
import { generateDevReport } from '@/api/plan/plan'
|
||||||
import { useModeStore } from '@/stores/modules/mode' // 引入模式 store
|
import { useModeStore } from '@/stores/modules/mode' // 引入模式 store
|
||||||
|
|
||||||
import { useDictStore } from '@/stores/modules/dict'
|
import { useDictStore } from '@/stores/modules/dict'
|
||||||
|
|
||||||
const checkStore = useCheckStore()
|
const checkStore = useCheckStore()
|
||||||
@@ -105,7 +147,7 @@ const props = defineProps({
|
|||||||
default: 'waiting'
|
default: 'waiting'
|
||||||
},
|
},
|
||||||
stepsActive: {
|
stepsActive: {
|
||||||
type: Number,
|
type: Number
|
||||||
},
|
},
|
||||||
webMsgSend: {
|
webMsgSend: {
|
||||||
type: Object,
|
type: Object,
|
||||||
@@ -113,12 +155,19 @@ const props = defineProps({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['update:testStatus', 'update:webMsgSend', 'sendPause', 'sendResume', 'sendReCheck', 'closeWebSocket']);
|
const emit = defineEmits([
|
||||||
|
'update:testStatus',
|
||||||
|
'update:webMsgSend',
|
||||||
|
'sendPause',
|
||||||
|
'sendResume',
|
||||||
|
'sendReCheck',
|
||||||
|
'closeWebSocket'
|
||||||
|
])
|
||||||
|
|
||||||
// 用来保存测试项进度抽屉是否打开
|
// 用来保存测试项进度抽屉是否打开
|
||||||
const drawer = ref(false)
|
const drawer = ref(false)
|
||||||
// 进度条颜色
|
// 进度条颜色
|
||||||
const customColors = [{color: "#91cc75", percentage: 100}]
|
const customColors = [{ color: '#91cc75', percentage: 100 }]
|
||||||
// 检测脚本数据
|
// 检测脚本数据
|
||||||
let scriptData: CheckData.ScriptItem[] = []
|
let scriptData: CheckData.ScriptItem[] = []
|
||||||
// 用来保存被检设备
|
// 用来保存被检设备
|
||||||
@@ -126,7 +175,7 @@ const deviceList = reactive<CheckData.Device[]>([])
|
|||||||
// 当前进行的测试项索引
|
// 当前进行的测试项索引
|
||||||
let activeIndex = 0
|
let activeIndex = 0
|
||||||
// 百分比
|
// 百分比
|
||||||
const percentage = ref(0);
|
const percentage = ref(0)
|
||||||
// 时间计数器
|
// 时间计数器
|
||||||
let timer: any = null
|
let timer: any = null
|
||||||
const timeCount = ref(0)
|
const timeCount = ref(0)
|
||||||
@@ -139,20 +188,21 @@ const timeDifference = ref(0)
|
|||||||
// 真正的检测结果(详细到通道)
|
// 真正的检测结果(详细到通道)
|
||||||
const checkResult = reactive<CheckData.ScriptChnItem[]>([])
|
const checkResult = reactive<CheckData.ScriptChnItem[]>([])
|
||||||
// 用来存放检测出现失败的测试项id。只要有一个通道检测不合格,则该检测项的id会被加入该数组。
|
// 用来存放检测出现失败的测试项id。只要有一个通道检测不合格,则该检测项的id会被加入该数组。
|
||||||
let errorCheckItem: Array<{ scriptType: string, type: CheckData.ChnCheckResultEnum }> = []
|
let errorCheckItem: Array<{ scriptType: string; type: CheckData.ChnCheckResultEnum }> = []
|
||||||
// 用来存放检测日志
|
// 用来存放检测日志
|
||||||
const testLogList = reactive<CheckData.LogItem[]>([{ type: 'info', log: '暂无数据,等待检测开始' }])
|
const testLogList = reactive<CheckData.LogItem[]>([{ type: 'info', log: '暂无数据,等待检测开始' }])
|
||||||
|
|
||||||
const testStatus = toRef(props, 'testStatus')
|
const testStatus = toRef(props, 'testStatus')
|
||||||
const webMsgSend = toRef(props, 'webMsgSend')
|
const webMsgSend = toRef(props, 'webMsgSend')
|
||||||
|
|
||||||
const scrollContainerRef = ref();
|
const scrollContainerRef = ref()
|
||||||
const dataCheckSingleChannelSingleTestPopupRef = ref<InstanceType<typeof CompareDataCheckSingleChannelSingleTestPopup>>()
|
const dataCheckSingleChannelSingleTestPopupRef =
|
||||||
|
ref<InstanceType<typeof CompareDataCheckSingleChannelSingleTestPopup>>()
|
||||||
|
|
||||||
// 总通道数
|
// 总通道数
|
||||||
const chnSum = computed(() => {
|
const chnSum = computed(() => {
|
||||||
let sum = 0
|
let sum = 0
|
||||||
deviceList.forEach((item) => {
|
deviceList.forEach(item => {
|
||||||
sum += item.chnNum
|
sum += item.chnNum
|
||||||
})
|
})
|
||||||
return sum
|
return sum
|
||||||
@@ -160,6 +210,8 @@ const chnSum = computed(() => {
|
|||||||
|
|
||||||
// 用来展示的检测结果
|
// 用来展示的检测结果
|
||||||
const checkResultView: ComputedRef<CheckData.ScriptChnViewItem[]> = computed(() => {
|
const checkResultView: ComputedRef<CheckData.ScriptChnViewItem[]> = computed(() => {
|
||||||
|
console.log('🚀 ~ tem.devices:', checkResult)
|
||||||
|
|
||||||
let result: CheckData.ScriptChnViewItem[] = checkResult.map(item => {
|
let result: CheckData.ScriptChnViewItem[] = checkResult.map(item => {
|
||||||
let temp: CheckData.ScriptChnViewItem = {
|
let temp: CheckData.ScriptChnViewItem = {
|
||||||
scriptType: item.scriptType,
|
scriptType: item.scriptType,
|
||||||
@@ -175,27 +227,33 @@ const checkResultView: ComputedRef<CheckData.ScriptChnViewItem[]> = computed(()
|
|||||||
switch (device.chnResult[j]) {
|
switch (device.chnResult[j]) {
|
||||||
case CheckData.ChnCheckResultEnum.UNKNOWN:
|
case CheckData.ChnCheckResultEnum.UNKNOWN:
|
||||||
tempChnBtnResult.push({ color: CheckData.ButtonColorEnum.INFO, icon: 'More' })
|
tempChnBtnResult.push({ color: CheckData.ButtonColorEnum.INFO, icon: 'More' })
|
||||||
break;
|
break
|
||||||
case CheckData.ChnCheckResultEnum.LOADING:
|
case CheckData.ChnCheckResultEnum.LOADING:
|
||||||
tempChnBtnResult.push({ color: CheckData.ButtonColorEnum.LOADING, icon: 'Loading' })
|
tempChnBtnResult.push({ color: CheckData.ButtonColorEnum.LOADING, icon: 'Loading' })
|
||||||
break;
|
break
|
||||||
case CheckData.ChnCheckResultEnum.SUCCESS:
|
case CheckData.ChnCheckResultEnum.SUCCESS:
|
||||||
tempChnBtnResult.push({color: CheckData.ButtonColorEnum.SUCCESS, icon: 'CircleCheckFilled'})
|
tempChnBtnResult.push({
|
||||||
break;
|
color: CheckData.ButtonColorEnum.SUCCESS,
|
||||||
|
icon: 'CircleCheckFilled'
|
||||||
|
})
|
||||||
|
break
|
||||||
case CheckData.ChnCheckResultEnum.FAIL:
|
case CheckData.ChnCheckResultEnum.FAIL:
|
||||||
tempChnBtnResult.push({ color: CheckData.ButtonColorEnum.DANGER, icon: 'Close' })
|
tempChnBtnResult.push({ color: CheckData.ButtonColorEnum.DANGER, icon: 'Close' })
|
||||||
break;
|
break
|
||||||
case CheckData.ChnCheckResultEnum.TIMEOUT:
|
case CheckData.ChnCheckResultEnum.TIMEOUT:
|
||||||
tempChnBtnResult.push({ color: CheckData.ButtonColorEnum.WARNING, icon: 'Link' })
|
tempChnBtnResult.push({ color: CheckData.ButtonColorEnum.WARNING, icon: 'Link' })
|
||||||
break;
|
break
|
||||||
case CheckData.ChnCheckResultEnum.ERRORDATA:
|
case CheckData.ChnCheckResultEnum.ERRORDATA:
|
||||||
tempChnBtnResult.push({color: CheckData.ButtonColorEnum.WARNING, icon: 'WarnTriangleFilled'})
|
tempChnBtnResult.push({
|
||||||
break;
|
color: CheckData.ButtonColorEnum.WARNING,
|
||||||
|
icon: 'WarnTriangleFilled'
|
||||||
|
})
|
||||||
|
break
|
||||||
case CheckData.ChnCheckResultEnum.NOT_PART_IN_ERROR:
|
case CheckData.ChnCheckResultEnum.NOT_PART_IN_ERROR:
|
||||||
tempChnBtnResult.push({ color: CheckData.ButtonColorEnum.INFO, icon: 'Minus' })
|
tempChnBtnResult.push({ color: CheckData.ButtonColorEnum.INFO, icon: 'Minus' })
|
||||||
break;
|
break
|
||||||
default:
|
default:
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -212,23 +270,24 @@ const checkResultView: ComputedRef<CheckData.ScriptChnViewItem[]> = computed(()
|
|||||||
})
|
})
|
||||||
|
|
||||||
watch(testStatus, function (newValue, oldValue) {
|
watch(testStatus, function (newValue, oldValue) {
|
||||||
if (newValue == 'start') {
|
console.log('🚀 ~ newValue:', newValue)
|
||||||
|
if (newValue == 'start' || newValue == 'waiting') {
|
||||||
if (!checkStore.selectTestItems.preTest && !checkStore.selectTestItems.channelsTest) {
|
if (!checkStore.selectTestItems.preTest && !checkStore.selectTestItems.channelsTest) {
|
||||||
ElMessage.success('初始化开始!')
|
ElMessage.success('初始化开始!')
|
||||||
emit('update:testStatus', 'test_init')
|
emit('update:testStatus', 'test_init')
|
||||||
|
if (checkStore.selectTestItems.test && checkStore.selectTestItems.preTest) {
|
||||||
testLogList.push({ type: 'info', log: `${new Date().toLocaleString()}:初始化开始!` })
|
testLogList.push({ type: 'info', log: `${new Date().toLocaleString()}:初始化开始!` })
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
emit('update:testStatus', 'process')
|
emit('update:testStatus', 'process')
|
||||||
}
|
}
|
||||||
|
// 开始计时
|
||||||
startTimeCount()
|
startTimeCount()
|
||||||
|
|
||||||
showTestLog()
|
showTestLog()
|
||||||
//startTimer() // todo 可移除
|
//startTimer() // todo 可移除
|
||||||
startData.value = new Date();
|
startData.value = new Date()
|
||||||
timeDifference.value = 0;
|
timeDifference.value = 0
|
||||||
}
|
} else if (newValue == 'error') {
|
||||||
|
|
||||||
if (newValue == 'recheck' || newValue == 'error' || newValue == 'test_init_fail' || newValue == 'connect_timeout' || newValue == 'pause_timeout' || oldValue == 'error_flow_end') {
|
|
||||||
stopTimeCount()
|
stopTimeCount()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -236,284 +295,68 @@ watch(testStatus, function (newValue, oldValue) {
|
|||||||
// 次数
|
// 次数
|
||||||
let count = 0
|
let count = 0
|
||||||
|
|
||||||
watch(webMsgSend, function (newValue, oldValue) {
|
watch(
|
||||||
console.log('webMsgSend', newValue)
|
webMsgSend,
|
||||||
if (testStatus.value !== 'waiting') {
|
function (newValue, oldValue) {
|
||||||
handleStartItem('V', 'newValue.desc')
|
if (testStatus.value == 'test_init') {
|
||||||
if (props.stepsActive === 4) {
|
// 正式检测
|
||||||
switch (newValue.requestId) {
|
|
||||||
case 'server_error':
|
|
||||||
if (newValue.operateCode === 'server_error' && count === 0) {
|
|
||||||
ElMessageBox.alert('服务端主动关闭连接!', '初始化失败', {
|
|
||||||
confirmButtonText: '确定',
|
|
||||||
type: 'error',
|
|
||||||
})
|
|
||||||
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:服务端主动关闭连接!`})
|
|
||||||
emit('update:testStatus', 'test_init_fail')
|
|
||||||
count++
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'device_error':
|
|
||||||
if (newValue.operateCode === 'device_error' && count === 0) {
|
|
||||||
ElMessageBox.alert('设备端主动关闭连接!', '初始化失败', {
|
|
||||||
confirmButtonText: '确定',
|
|
||||||
type: 'error',
|
|
||||||
})
|
|
||||||
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:设备端主动关闭连接!`})
|
|
||||||
emit('update:testStatus', 'test_init_fail')
|
|
||||||
count++
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'formal_real': // 正式测试
|
|
||||||
switch (newValue.operateCode) {
|
|
||||||
case "stop_timeout":
|
|
||||||
ElMessageBox.alert(`暂停时间已过10分钟,本次检测已失效,请重新发起检测!`, '暂停时间过长', {
|
|
||||||
confirmButtonText: '确定',
|
|
||||||
type: 'error',
|
|
||||||
})
|
|
||||||
emit('update:testStatus', 'pause_timeout')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'error_flow_end':
|
|
||||||
ElMessageBox.alert(`当前流程存在异常结束!`, '初始化失败', {
|
|
||||||
confirmButtonText: '确定',
|
|
||||||
type: 'error',
|
|
||||||
})
|
|
||||||
emit('update:testStatus', 'test_init_fail')
|
|
||||||
break
|
|
||||||
case 'socket_timeout':
|
|
||||||
switch (newValue.operateCode) {
|
|
||||||
case "VOLTAGE":
|
|
||||||
// todo 超时处理 页面按钮更新
|
|
||||||
ElMessageBox.alert('连接超时!', '连接超时', {
|
|
||||||
confirmButtonText: '确定',
|
|
||||||
type: 'error',
|
|
||||||
})
|
|
||||||
emit('update:testStatus', 'connect_timeout')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'connect':
|
|
||||||
switch (newValue.operateCode) {
|
|
||||||
case "Source":
|
|
||||||
ElMessageBox.alert('源通讯失败,请检查源连接情况!', '初始化失败', {
|
|
||||||
confirmButtonText: '确定',
|
|
||||||
type: 'error',
|
|
||||||
})
|
|
||||||
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:源通讯失败!`})
|
|
||||||
break;
|
|
||||||
case "Dev":
|
|
||||||
ElMessageBox.alert('设备通讯失败,请检查设备连接情况!', '初始化失败', {
|
|
||||||
confirmButtonText: '确定',
|
|
||||||
type: 'error',
|
|
||||||
})
|
|
||||||
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:设备通讯失败!`})
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
emit('update:testStatus', 'test_init_fail')
|
|
||||||
break;
|
|
||||||
case 'yjc_ytxjy':
|
|
||||||
switch (newValue.operateCode) {
|
|
||||||
case 'INIT_GATHER':
|
|
||||||
if (newValue.code == 10200) {
|
|
||||||
testLogList.push({type: 'info', log: `${new Date().toLocaleString()}:源初始化成功!`})
|
|
||||||
percentage.value = 1
|
|
||||||
}
|
|
||||||
if (newValue.code == -1) {
|
|
||||||
ElMessageBox.alert('源未知异常!', '初始化失败', {
|
|
||||||
confirmButtonText: '确定',
|
|
||||||
type: 'error',
|
|
||||||
})
|
|
||||||
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:源未知异常!`})
|
|
||||||
emit('update:testStatus', 'test_init_fail')
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'yjc_sbtxjy':
|
|
||||||
switch (newValue.operateCode) {
|
|
||||||
case 'INIT_GATHER$01':
|
|
||||||
if (newValue.code == 25001) {
|
|
||||||
testLogList.push({type: 'info', log: `${new Date().toLocaleString()}:设备通讯校验成功!`})
|
|
||||||
percentage.value = 2
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'yjc_xyjy':
|
|
||||||
switch (newValue.operateCode) {
|
|
||||||
case 'VERIFY_MAPPING$01':
|
|
||||||
if (newValue.code == 25001) {
|
|
||||||
ElMessage.success('初始化成功!')
|
|
||||||
testLogList.push({type: 'info', log: `${new Date().toLocaleString()}:协议校验成功!`})
|
|
||||||
timeDifference.value = +new Date().getTime() - startData.value.getTime();
|
|
||||||
testLogList.push({type: 'info', log: `${new Date().toLocaleString()}:初始化成功!`})
|
|
||||||
percentage.value = 3
|
|
||||||
|
|
||||||
activeIndex = getNextActiveIndex() + 2
|
|
||||||
//startTimer()
|
|
||||||
|
|
||||||
emit('update:testStatus', 'process')
|
|
||||||
} else if (newValue.code == 10200) {
|
|
||||||
let data = JSON.parse(newValue.data)
|
|
||||||
ElMessageBox.alert(`脚本与icd校验失败!icd名称:${data['icdType']} -> 校验项:${data['dataType']}`, '初始化失败', {
|
|
||||||
confirmButtonText: '确定',
|
|
||||||
type: 'error',
|
|
||||||
})
|
|
||||||
testLogList.push({
|
|
||||||
type: 'error',
|
|
||||||
log: `${new Date().toLocaleString()}:脚本与icd校验失败!icd名称:${data['icdType']} -> 校验项:${data['dataType']}`
|
|
||||||
})
|
|
||||||
emit('update:testStatus', 'test_init_fail')
|
|
||||||
} else if (newValue.code == 10500) {
|
|
||||||
ElMessageBox.alert(`装置中未找到该icd!`, '初始化失败', {
|
|
||||||
confirmButtonText: '确定',
|
|
||||||
type: 'error',
|
|
||||||
})
|
|
||||||
testLogList.push({
|
|
||||||
type: 'error',
|
|
||||||
log: `${new Date().toLocaleString()}:装置中未找到该icd!`
|
|
||||||
})
|
|
||||||
emit('update:testStatus', 'test_init_fail')
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'preStopTest':
|
|
||||||
if (newValue.operateCode == 'stop') {
|
|
||||||
ElMessage.success('暂停成功')
|
|
||||||
emit('update:testStatus', 'paused')
|
|
||||||
pauseSuccessCallback()
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'Resume_Success':
|
|
||||||
ElMessage.success('开始继续检测')
|
|
||||||
emit('update:testStatus', 'process')
|
|
||||||
handleResumeTest()
|
|
||||||
break;
|
|
||||||
case 'FREQ_Start':
|
|
||||||
handleStartItem('FREQ', newValue.desc)
|
|
||||||
break;
|
|
||||||
case 'FREQ_End':
|
|
||||||
handleEndItem('FREQ', newValue.desc, newValue.data)
|
|
||||||
break;
|
|
||||||
case 'V_Start':
|
|
||||||
handleStartItem('V', newValue.desc)
|
|
||||||
break;
|
|
||||||
case 'V_End':
|
|
||||||
handleEndItem('V', newValue.desc, newValue.data)
|
|
||||||
break;
|
|
||||||
case 'HV_Start':
|
|
||||||
handleStartItem('HV', newValue.desc)
|
|
||||||
break;
|
|
||||||
case 'HV_End':
|
|
||||||
handleEndItem('HV', newValue.desc, newValue.data)
|
|
||||||
break;
|
|
||||||
case 'HI_Start':
|
|
||||||
handleStartItem('HI', newValue.desc)
|
|
||||||
break;
|
|
||||||
case 'HI_End':
|
|
||||||
handleEndItem('HI', newValue.desc, newValue.data)
|
|
||||||
break;
|
|
||||||
case 'HP_Start':
|
|
||||||
handleStartItem('HP', newValue.desc)
|
|
||||||
break;
|
|
||||||
case 'HP_End':
|
|
||||||
handleEndItem('HP', newValue.desc, newValue.data)
|
|
||||||
break;
|
|
||||||
case 'HSV_Start':
|
|
||||||
handleStartItem('HSV', newValue.desc)
|
|
||||||
break;
|
|
||||||
case 'HSV_End':
|
|
||||||
handleEndItem('HSV', newValue.desc, newValue.data)
|
|
||||||
break;
|
|
||||||
case 'HSI_Start':
|
|
||||||
handleStartItem('HSI', newValue.desc)
|
|
||||||
break;
|
|
||||||
case 'HSI_End':
|
|
||||||
handleEndItem('HSI', newValue.desc, newValue.data)
|
|
||||||
break;
|
|
||||||
case 'VOLTAGE_Start':
|
|
||||||
handleStartItem('VOLTAGE', newValue.desc)
|
|
||||||
break;
|
|
||||||
case 'VOLTAGE_End':
|
|
||||||
handleEndItem('VOLTAGE', newValue.desc, newValue.data)
|
|
||||||
break;
|
|
||||||
case 'I_Start':
|
|
||||||
handleStartItem('I', newValue.desc)
|
|
||||||
break;
|
|
||||||
case 'I_End':
|
|
||||||
handleEndItem('I', newValue.desc, newValue.data)
|
|
||||||
break;
|
|
||||||
case 'IMBV_Start':
|
|
||||||
handleStartItem('IMBV', newValue.desc)
|
|
||||||
break;
|
|
||||||
case 'IMBV_End':
|
|
||||||
handleEndItem('IMBV', newValue.desc, newValue.data)
|
|
||||||
break;
|
|
||||||
case 'IMBA_Start':
|
|
||||||
handleStartItem('IMBA', newValue.desc)
|
|
||||||
break;
|
|
||||||
case 'IMBA_End':
|
|
||||||
handleEndItem('IMBA', newValue.desc, newValue.data)
|
|
||||||
break;
|
|
||||||
case 'F_Start':
|
|
||||||
handleStartItem('F', newValue.desc)
|
|
||||||
break;
|
|
||||||
case 'F_End':
|
|
||||||
handleEndItem('F', newValue.desc, newValue.data)
|
|
||||||
break;
|
|
||||||
case 'Quit':
|
|
||||||
console.log('检测结束')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, {deep: true})
|
|
||||||
|
|
||||||
const handleStartItem = (code: string, desc: string | undefined) => {
|
|
||||||
if (desc === undefined) {
|
|
||||||
console.log('开始检测项:', code)
|
|
||||||
updateCheckResultView(code, true) // 更新界面为加载状态
|
|
||||||
} else {
|
} else {
|
||||||
// 子测试项开始
|
// 预监测 正式检测
|
||||||
testLogList.push({ type: 'info', log: `${new Date().toLocaleString()}:${desc}准确度检测:开始` })
|
if (newValue.requestId == 'formal_real') {
|
||||||
}
|
switch (newValue.code) {
|
||||||
|
case 25001:
|
||||||
|
let result: CheckData.ScriptChnItem[] = []
|
||||||
|
scriptData.forEach(item => {
|
||||||
|
// 处理当前节点的数据
|
||||||
|
let temp: CheckData.ScriptChnItem = {
|
||||||
|
scriptType: item.id,
|
||||||
|
scriptName: item.scriptName,
|
||||||
|
devices: []
|
||||||
}
|
}
|
||||||
|
let message=JSON.parse(newValue.data)
|
||||||
|
|
||||||
const handleEndItem = (code: string, desc: string | undefined, devices: CheckData.DeviceCheckResult[] = []) => {
|
for (let i = 0; i < message?.length; i++) {
|
||||||
if (desc === undefined) {
|
|
||||||
|
temp.devices.push({
|
||||||
|
deviceId: message[i].deviceId,
|
||||||
|
deviceName: message[i].deviceName,
|
||||||
|
chnResult: message[i].chnResult
|
||||||
|
})
|
||||||
|
}
|
||||||
|
result.push(temp)
|
||||||
|
})
|
||||||
|
console.log("🚀 ~ result:", result)
|
||||||
|
|
||||||
|
Object.assign(checkResult, result)
|
||||||
|
|
||||||
|
stopTimeCount()
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
if (newValue.code != 10201) {
|
||||||
|
testLogList.push({
|
||||||
|
type: newValue.code == 10200 ? 'info' : 'error',
|
||||||
|
log: `${new Date().toLocaleString()}:` + newValue.data
|
||||||
|
})
|
||||||
|
if (newValue.code == 25003) {
|
||||||
|
stopTimeCount()
|
||||||
|
}
|
||||||
updatePercentage()
|
updatePercentage()
|
||||||
updateCheckResultView(code, false, devices)
|
|
||||||
updateLog(false)
|
|
||||||
if (testStatus.value != 'paused') {
|
|
||||||
activeIndex = getNextActiveIndex(code)
|
|
||||||
//startTimer()
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
let result = getResult(devices)
|
break
|
||||||
// if (desc.length > 150) {
|
|
||||||
// desc = desc.substring(0, 150) + '...'
|
|
||||||
// }
|
|
||||||
if (result === 1) {
|
|
||||||
testLogList.push({type: 'info', log: `${new Date().toLocaleString()}:${desc}检测结束:符合`})
|
|
||||||
}
|
|
||||||
if (result === 2) {
|
|
||||||
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:${desc}检测结束:不符合`})
|
|
||||||
}
|
|
||||||
if (result === 4) {
|
|
||||||
testLogList.push({type: 'warning', log: `${new Date().toLocaleString()}:${desc}检测结束:数据异常`})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{ deep: true }
|
||||||
|
)
|
||||||
|
|
||||||
// 更新进度条
|
// 更新进度条
|
||||||
const updatePercentage = async () => {
|
const updatePercentage = async () => {
|
||||||
if (activeIndex < checkTotal) {
|
if (testLogList.length - 1 < checkStore.chnNumList.length) {
|
||||||
percentage.value = Math.trunc(activeIndex / checkTotal * 100);
|
percentage.value = Math.trunc(((testLogList.length - 1) / checkStore.chnNumList.length) * 100)
|
||||||
} else {
|
} else {
|
||||||
percentage.value = 100;
|
percentage.value = 100
|
||||||
emit('update:testStatus', 'success')
|
emit('update:testStatus', 'success')
|
||||||
|
|
||||||
let { data: autoGenerate } = await getAutoGenerate()
|
let { data: autoGenerate } = await getAutoGenerate()
|
||||||
@@ -523,27 +366,62 @@ const updatePercentage = async () => {
|
|||||||
return item.deviceId
|
return item.deviceId
|
||||||
})
|
})
|
||||||
|
|
||||||
await generateDevReport({
|
// await generateDevReport({
|
||||||
'planId': checkStore.plan.id,
|
// planId: checkStore.plan.id,
|
||||||
'devIdList': devIdList,
|
// devIdList: devIdList,
|
||||||
'scriptId': checkStore.plan.scriptId,
|
// scriptId: checkStore.plan.scriptId,
|
||||||
'planCode': checkStore.plan.code + ''
|
// planCode: checkStore.plan.code + ''
|
||||||
})
|
// })
|
||||||
}
|
}
|
||||||
ElMessageBox.alert('检测全部结束,你可以停留在此页面查看检测结果,或返回首页进行复检、报告生成和归档等操作', '检测完成', {
|
stopTimeCount()
|
||||||
confirmButtonText: '确定',
|
ElMessageBox.alert(
|
||||||
})
|
'检测全部结束,你可以停留在此页面查看检测结果,或返回首页进行复检、报告生成和归档等操作',
|
||||||
|
'检测完成',
|
||||||
|
{
|
||||||
|
confirmButtonText: '确定'
|
||||||
|
}
|
||||||
|
)
|
||||||
// 关闭WebSocket连接
|
// 关闭WebSocket连接
|
||||||
emit('closeWebSocket')
|
emit('closeWebSocket')
|
||||||
//clear();
|
//clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// ========== 时间计数器管理函数 ==========
|
||||||
|
// 开始计时
|
||||||
|
const startTimeCount = () => {
|
||||||
|
if (!timer) {
|
||||||
|
timer = setInterval(() => {
|
||||||
|
timeCount.value = timeCount.value + 1
|
||||||
|
timeView.value = secondToTime(timeCount.value)
|
||||||
|
}, 1000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 停止计时
|
||||||
|
const stopTimeCount = () => {
|
||||||
|
if (timer) {
|
||||||
|
clearInterval(timer)
|
||||||
|
timer = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将秒数转换为 HH:MM:SS 格式
|
||||||
|
const secondToTime = (second: number) => {
|
||||||
|
let h: string | number = Math.floor(second / 3600) // 小时
|
||||||
|
let m: string | number = Math.floor((second - h * 3600) / 60) // 分钟
|
||||||
|
let s: string | number = Math.floor(second % 60) // 秒
|
||||||
|
|
||||||
|
// 补齐前导零
|
||||||
|
h = h < 10 ? '0' + h : h
|
||||||
|
m = m < 10 ? '0' + m : m
|
||||||
|
s = s < 10 ? '0' + s : s
|
||||||
|
return h + ':' + m + ':' + s
|
||||||
|
}
|
||||||
|
|
||||||
onBeforeMount(async () => {
|
onBeforeMount(async () => {
|
||||||
await initScriptData()
|
await initScriptData()
|
||||||
initDeviceList()
|
initDeviceList()
|
||||||
initCheckResult()
|
initCheckResult()
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const showTestLog = () => {
|
const showTestLog = () => {
|
||||||
@@ -552,7 +430,7 @@ const showTestLog = () => {
|
|||||||
|
|
||||||
// 初始化检测脚本数据
|
// 初始化检测脚本数据
|
||||||
const initScriptData = async () => {
|
const initScriptData = async () => {
|
||||||
const pattern = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? '';
|
const pattern = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? ''
|
||||||
let response: any = await getBigTestItem({
|
let response: any = await getBigTestItem({
|
||||||
reCheckType: checkStore.reCheckType,
|
reCheckType: checkStore.reCheckType,
|
||||||
planId: checkStore.plan.id,
|
planId: checkStore.plan.id,
|
||||||
@@ -564,14 +442,13 @@ const initScriptData = async () => {
|
|||||||
let temp = response.data.map((item: any) => {
|
let temp = response.data.map((item: any) => {
|
||||||
return {
|
return {
|
||||||
...item,
|
...item,
|
||||||
scriptName: item.scriptName,
|
scriptName: item.scriptName
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 保存脚本数据并设置总数
|
// 保存脚本数据并设置总数
|
||||||
scriptData.push(...temp)
|
scriptData.push(...temp)
|
||||||
checkTotal = scriptData.length
|
checkTotal = scriptData.length
|
||||||
|
|
||||||
}
|
}
|
||||||
// 初始化设备列表
|
// 初始化设备列表
|
||||||
const initDeviceList = () => {
|
const initDeviceList = () => {
|
||||||
@@ -588,9 +465,10 @@ const initCheckResult = () => {
|
|||||||
scriptName: item.scriptName,
|
scriptName: item.scriptName,
|
||||||
devices: []
|
devices: []
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < deviceList?.length; i++) {
|
for (let i = 0; i < deviceList?.length; i++) {
|
||||||
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
|
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
|
||||||
for (let j = 0; j < deviceList[i].chnNum; j++) {
|
for (let j = 0; j < checkStore.chnNumList.length; j++) {
|
||||||
tempChnResult.push(CheckData.ChnCheckResultEnum.UNKNOWN)
|
tempChnResult.push(CheckData.ChnCheckResultEnum.UNKNOWN)
|
||||||
}
|
}
|
||||||
temp.devices.push({
|
temp.devices.push({
|
||||||
@@ -601,11 +479,13 @@ const initCheckResult = () => {
|
|||||||
}
|
}
|
||||||
result.push(temp)
|
result.push(temp)
|
||||||
})
|
})
|
||||||
|
|
||||||
Object.assign(checkResult, result)
|
Object.assign(checkResult, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新检测结果(详细到通道)
|
// 更新检测结果(详细到通道)
|
||||||
const updateCheckResult = (data: CheckData.ScriptChnItem) => {
|
const updateCheckResult = (data: CheckData.ScriptChnItem) => {
|
||||||
|
console.log('🚀 ~ updateCheckResult ~ data:', data)
|
||||||
const { scriptType } = { ...data }
|
const { scriptType } = { ...data }
|
||||||
|
|
||||||
checkResult.forEach(item => {
|
checkResult.forEach(item => {
|
||||||
@@ -622,16 +502,17 @@ const updateCheckResult = (data: CheckData.ScriptChnItem) => {
|
|||||||
|
|
||||||
const scrollToBottom = () => {
|
const scrollToBottom = () => {
|
||||||
if (scrollContainerRef.value) {
|
if (scrollContainerRef.value) {
|
||||||
scrollContainerRef.value.scrollTop = scrollContainerRef.value.scrollHeight + 70;
|
scrollContainerRef.value.scrollTop = scrollContainerRef.value.scrollHeight + 70
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
watch(testLogList, () => {
|
|
||||||
scrollToBottom();
|
|
||||||
}, {deep: true})
|
|
||||||
|
|
||||||
|
watch(
|
||||||
|
testLogList,
|
||||||
|
() => {
|
||||||
|
scrollToBottom()
|
||||||
|
},
|
||||||
|
{ deep: true }
|
||||||
|
)
|
||||||
|
|
||||||
const setErrorCheckItem = (scriptType: string, devices: CheckData.DeviceCheckResult[]) => {
|
const setErrorCheckItem = (scriptType: string, devices: CheckData.DeviceCheckResult[]) => {
|
||||||
let type = 1
|
let type = 1
|
||||||
@@ -652,11 +533,11 @@ const setErrorCheckItem = (scriptType: string, devices: CheckData.DeviceCheckRes
|
|||||||
if (devices[i].chnResult.some(item => item === CheckData.ChnCheckResultEnum.TIMEOUT)) {
|
if (devices[i].chnResult.some(item => item === CheckData.ChnCheckResultEnum.TIMEOUT)) {
|
||||||
testLogList.push({
|
testLogList.push({
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
log: `${new Date().toLocaleString()} :${devices[i].deviceName}连接超时`,
|
log: `${new Date().toLocaleString()} :${devices[i].deviceName}连接超时`
|
||||||
})
|
})
|
||||||
ElMessageBox.alert('连接超时!', '连接超时', {
|
ElMessageBox.alert('连接超时!', '连接超时', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
type: 'error',
|
type: 'error'
|
||||||
})
|
})
|
||||||
emit('update:testStatus', 'connect_timeout')
|
emit('update:testStatus', 'connect_timeout')
|
||||||
}
|
}
|
||||||
@@ -666,8 +547,6 @@ const setErrorCheckItem = (scriptType: string, devices: CheckData.DeviceCheckRes
|
|||||||
errorCheckItem.push({ scriptType, type: type })
|
errorCheckItem.push({ scriptType, type: type })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const updateCheckResultView = (scriptCode: string, isStart: boolean, devices: CheckData.DeviceCheckResult[] = []) => {
|
const updateCheckResultView = (scriptCode: string, isStart: boolean, devices: CheckData.DeviceCheckResult[] = []) => {
|
||||||
let scriptType = scriptData.filter(item => item.code === scriptCode)[0]?.id
|
let scriptType = scriptData.filter(item => item.code === scriptCode)[0]?.id
|
||||||
let temp = null
|
let temp = null
|
||||||
@@ -681,14 +560,13 @@ const updateCheckResultView = (scriptCode: string, isStart: boolean, devices: Ch
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateCheckResult(temp)
|
updateCheckResult(temp)
|
||||||
};
|
}
|
||||||
|
|
||||||
// 获取loading状态的结果
|
// 获取loading状态的结果
|
||||||
const getLoadingResult = (scriptType: string) => {
|
const getLoadingResult = (scriptType: string) => {
|
||||||
let devices = []
|
let devices = []
|
||||||
|
|
||||||
devices = deviceList.map(item => {
|
devices = deviceList.map(item => {
|
||||||
|
|
||||||
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
|
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
|
||||||
for (let i = 0; i < item.chnNum; i++) {
|
for (let i = 0; i < item.chnNum; i++) {
|
||||||
tempChnResult.push(CheckData.ChnCheckResultEnum.LOADING)
|
tempChnResult.push(CheckData.ChnCheckResultEnum.LOADING)
|
||||||
@@ -697,19 +575,18 @@ const getLoadingResult = (scriptType: string) => {
|
|||||||
return {
|
return {
|
||||||
deviceId: item.deviceId,
|
deviceId: item.deviceId,
|
||||||
deviceName: item.deviceName,
|
deviceName: item.deviceName,
|
||||||
chnResult: tempChnResult,
|
chnResult: tempChnResult
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
let tempScriptChnItem: CheckData.ScriptChnItem = {
|
let tempScriptChnItem: CheckData.ScriptChnItem = {
|
||||||
scriptType,
|
scriptType,
|
||||||
devices,
|
devices
|
||||||
}
|
}
|
||||||
|
|
||||||
return tempScriptChnItem
|
return tempScriptChnItem
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const getResult = (devices: CheckData.DeviceCheckResult[] = []) => {
|
const getResult = (devices: CheckData.DeviceCheckResult[] = []) => {
|
||||||
let type = 1
|
let type = 1
|
||||||
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
|
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
|
||||||
@@ -726,7 +603,6 @@ const getResult = (devices: CheckData.DeviceCheckResult[] = []) => {
|
|||||||
return type
|
return type
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 点击查看(设备)通道检测详情。参数1:设备信息,参数2:通道号,-1:代表查看全部通道
|
// 点击查看(设备)通道检测详情。参数1:设备信息,参数2:通道号,-1:代表查看全部通道
|
||||||
const handleClick = (item: any, chnNum: number, scriptType: string) => {
|
const handleClick = (item: any, chnNum: number, scriptType: string) => {
|
||||||
// let checkResultItem = checkResult.find(obj => obj.scriptType === scriptType)
|
// let checkResultItem = checkResult.find(obj => obj.scriptType === scriptType)
|
||||||
@@ -762,46 +638,56 @@ const handleClick = (item: any, chnNum: number, scriptType: string) => {
|
|||||||
// if (flag === -1 || flag === 1) {
|
// if (flag === -1 || flag === 1) {
|
||||||
// checkStore.setShowDetailType(2)
|
// checkStore.setShowDetailType(2)
|
||||||
console.log('handleTest', item.deviceId, chnNum, scriptType)
|
console.log('handleTest', item.deviceId, chnNum, scriptType)
|
||||||
dataCheckSingleChannelSingleTestPopupRef.value?.open(item.deviceId, chnNum + '', scriptType);
|
dataCheckSingleChannelSingleTestPopupRef.value?.open(item.deviceId, chnNum + '', scriptType)
|
||||||
//}
|
//}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
const handlePause = () => {
|
const handlePause = () => {
|
||||||
//emit('sendPause')
|
//emit('sendPause')
|
||||||
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:当前测试小项正在执行中,将在该小项执行结束后暂停...`})
|
testLogList.push({
|
||||||
|
type: 'error',
|
||||||
|
log: `${new Date().toLocaleString()}:当前测试小项正在执行中,将在该小项执行结束后暂停...`
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const initializeParameters = () => {
|
||||||
|
percentage.value = 0
|
||||||
|
testLogList.splice(0, testLogList.length, { type: 'info', log: '暂无数据,等待检测开始' })
|
||||||
}
|
}
|
||||||
|
|
||||||
const pauseSuccessCallback = () => {
|
const pauseSuccessCallback = () => {
|
||||||
endData.value = new Date();
|
endData.value = new Date()
|
||||||
let diffTime = endData.value.getTime() - startData.value.getTime();
|
let diffTime = endData.value.getTime() - startData.value.getTime()
|
||||||
timeDifference.value += diffTime
|
timeDifference.value += diffTime
|
||||||
|
|
||||||
testLogList.push({
|
testLogList.push({
|
||||||
type: 'info',
|
type: 'info',
|
||||||
log: `${new Date().toLocaleString()}:暂停检测`,
|
log: `${new Date().toLocaleString()}:暂停检测`
|
||||||
})
|
})
|
||||||
stopTimeCount()
|
|
||||||
console.log('暂停中')
|
|
||||||
};
|
|
||||||
|
|
||||||
|
console.log('暂停中')
|
||||||
|
}
|
||||||
|
|
||||||
const handleResumeTest = () => {
|
const handleResumeTest = () => {
|
||||||
//activeIndex++
|
//activeIndex++
|
||||||
startData.value = new Date();
|
startData.value = new Date()
|
||||||
testLogList.push({ type: 'info', log: `${new Date().toLocaleString()}:开始重新检测!` })
|
testLogList.push({ type: 'info', log: `${new Date().toLocaleString()}:开始重新检测!` })
|
||||||
//startTimer()
|
//startTimer()
|
||||||
resumeTimeCount()
|
|
||||||
console.log('开始继续检测')
|
console.log('开始继续检测')
|
||||||
};
|
}
|
||||||
|
//
|
||||||
|
onMounted(() => {
|
||||||
|
initializeParameters()
|
||||||
|
})
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
handlePause
|
initializeParameters,
|
||||||
|
handlePause,
|
||||||
|
showTestLog,
|
||||||
|
startTimeCount
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|
||||||
:deep(.el-table .header-row) {
|
:deep(.el-table .header-row) {
|
||||||
background-color: #f5f7fa;
|
background-color: #f5f7fa;
|
||||||
}
|
}
|
||||||
@@ -810,8 +696,6 @@ defineExpose({
|
|||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.el-table .success-row {
|
.el-table .success-row {
|
||||||
--el-table-tr-bg-color: var(--el-color-success-light-9);
|
--el-table-tr-bg-color: var(--el-color-success-light-9);
|
||||||
}
|
}
|
||||||
@@ -824,7 +708,6 @@ defineExpose({
|
|||||||
}
|
}
|
||||||
|
|
||||||
.dialog-title {
|
.dialog-title {
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -889,7 +772,6 @@ defineExpose({
|
|||||||
transform: rotate(360deg);
|
transform: rotate(360deg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@@ -901,6 +783,4 @@ defineExpose({
|
|||||||
:deep(.el-table--default td) {
|
:deep(.el-table--default td) {
|
||||||
padding: 5px 0 !important;
|
padding: 5px 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,106 +1,172 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog :title="dialogTitle" width="1550px" :model-value="dialogVisible" :before-close="beforeClose" @close="handleClose" height="1000px" draggable>
|
<el-dialog
|
||||||
|
:title="dialogTitle"
|
||||||
|
width="1550px"
|
||||||
|
:model-value="dialogVisible"
|
||||||
|
:before-close="beforeClose"
|
||||||
|
@close="handleClose"
|
||||||
|
height="1000px"
|
||||||
|
draggable
|
||||||
|
>
|
||||||
<div class="steps-container">
|
<div class="steps-container">
|
||||||
<el-steps v-if="showSteps" class="test-head-steps" simple :active="stepsActiveIndex" process-status="finish" finish-status="success">
|
<el-steps
|
||||||
<el-step v-if="preTestSelected" title="预检测" :icon="stepsActive > 1 || stepsActiveIndex > stepsTotalNum - 1? SuccessFilled : Edit" @click="handleStepClick(1)"/>
|
v-if="showSteps"
|
||||||
|
class="test-head-steps"
|
||||||
|
simple
|
||||||
|
:active="stepsActiveIndex"
|
||||||
|
process-status="finish"
|
||||||
|
finish-status="success"
|
||||||
|
>
|
||||||
|
<el-step
|
||||||
|
v-if="preTestSelected"
|
||||||
|
title="预检测"
|
||||||
|
:icon="stepsActive > 1 || stepsActiveIndex > stepsTotalNum - 1 ? SuccessFilled : Edit"
|
||||||
|
@click="handleStepClick(1)"
|
||||||
|
/>
|
||||||
|
|
||||||
<el-step v-if="testSelected" title="正式检测" :icon="stepsActive > 2 || stepsActiveIndex > stepsTotalNum - 1? SuccessFilled : Coin" @click="handleStepClick(2)"/>
|
<el-step
|
||||||
|
v-if="testSelected"
|
||||||
|
title="正式检测"
|
||||||
|
:icon="stepsActive > 2 || stepsActiveIndex > stepsTotalNum - 1 ? SuccessFilled : Coin"
|
||||||
|
@click="handleStepClick(2)"
|
||||||
|
/>
|
||||||
<el-step title="检测完成" :icon="stepsActiveIndex > stepsTotalNum - 1 ? SuccessFilled : Key" />
|
<el-step title="检测完成" :icon="stepsActiveIndex > stepsTotalNum - 1 ? SuccessFilled : Key" />
|
||||||
</el-steps>
|
</el-steps>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<keep-alive>
|
<keep-alive>
|
||||||
<ComparePreTest v-if="preTestSelected && stepsActiveView==1" ref="preTestRef" v-model:testStatus="preTestStatus"
|
<ComparePreTest
|
||||||
:webMsgSend="webMsgSend" :mapping = "channelMapping"/>
|
v-if="preTestSelected && stepsActiveView == 1"
|
||||||
|
ref="preTestRef"
|
||||||
|
v-model:testStatus="preTestStatus"
|
||||||
|
:webMsgSend="webMsgSend"
|
||||||
|
:mapping="channelMapping"
|
||||||
|
/>
|
||||||
</keep-alive>
|
</keep-alive>
|
||||||
<keep-alive>
|
<keep-alive>
|
||||||
<CompareTest v-if="testSelected && stepsActiveView==2" ref="testRef" v-model:testStatus="TestStatus"
|
<CompareTest
|
||||||
:stepsActive="stepsActive"/>
|
v-if="testSelected && stepsActiveView == 2"
|
||||||
|
ref="testRef"
|
||||||
|
:webMsgSend="webMsgSend"
|
||||||
|
v-model:testStatus="TestStatus"
|
||||||
|
:stepsActive="stepsActive"
|
||||||
|
/>
|
||||||
</keep-alive>
|
</keep-alive>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<div>
|
<div>
|
||||||
<el-button type="primary" :icon="VideoPlay" v-if="ActiveStatue === 'waiting'" @click="handleSubmitFast">开始检测</el-button>
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
:icon="VideoPlay"
|
||||||
|
v-if="ActiveStatue === 'waiting' && !(testSelected && stepsActiveIndex == 2)"
|
||||||
|
@click="handleSubmitFast"
|
||||||
|
>
|
||||||
|
开始检测
|
||||||
|
</el-button>
|
||||||
<el-button type="primary" v-if="TestStatus === 'test_init'" disabled>
|
<el-button type="primary" v-if="TestStatus === 'test_init'" disabled>
|
||||||
<el-icon class="loading-box" style="color: #fff;margin-right: 8px;">
|
<el-icon class="loading-box" style="color: #fff; margin-right: 8px">
|
||||||
<component :is="Refresh" />
|
<component :is="Refresh" />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
初始化中
|
初始化中
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-button type="primary" v-if="TestStatus == 'process'" :icon="VideoPause" @click="handlePause()">
|
||||||
type="primary"
|
停止检测
|
||||||
v-if="TestStatus=='process'"
|
|
||||||
:icon="VideoPause"
|
|
||||||
@click="handlePause()">停止检测
|
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button type="warning" v-if="TestStatus === 'paused_ing'" disabled>
|
<el-button type="warning" v-if="TestStatus === 'paused_ing'" disabled>
|
||||||
<el-icon class="loading-box" style="color: #fff;margin-right: 8px;">
|
<el-icon class="loading-box" style="color: #fff; margin-right: 8px">
|
||||||
<component :is="Refresh" />
|
<component :is="Refresh" />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
暂停中
|
暂停中
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<el-button type="warning" v-if="TestStatus == 'paused'" :icon="VideoPlay" @click="sendResume">
|
||||||
|
继续检测
|
||||||
|
</el-button>
|
||||||
|
|
||||||
<el-button
|
<el-button
|
||||||
type="warning"
|
type="warning"
|
||||||
v-if="(TestStatus =='paused')"
|
|
||||||
:icon="VideoPlay"
|
:icon="VideoPlay"
|
||||||
@click="sendResume"
|
v-if="
|
||||||
>继续检测
|
nextStepText !== '下一步' &&
|
||||||
|
(ActiveStatue === 'success' ||
|
||||||
|
ActiveStatue === 'error' ||
|
||||||
|
ActiveStatue === 'test_init_fail' ||
|
||||||
|
ActiveStatue === 'connect_timeout' ||
|
||||||
|
ActiveStatue === 'pause_timeout' ||
|
||||||
|
ActiveStatue === 'waiting')
|
||||||
|
"
|
||||||
|
@click="handleSubmitAgain"
|
||||||
|
>
|
||||||
|
重新检测
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button type="warning" :icon="VideoPlay"
|
<el-button
|
||||||
v-if="nextStepText !== '下一步' && (ActiveStatue === 'success'||ActiveStatue==='error'||ActiveStatue==='test_init_fail'||ActiveStatue==='connect_timeout'||ActiveStatue==='pause_timeout')"
|
:type="ActiveStatue === 'success' ? 'primary' : 'danger'"
|
||||||
@click="handleSubmitAgain">重新检测
|
:icon="Right"
|
||||||
</el-button>
|
v-if="
|
||||||
<el-button :type="ActiveStatue==='success'?'primary':'danger'" :icon="Right"
|
nextStepText !== '下一步' &&
|
||||||
v-if="nextStepText !== '下一步' && (ActiveStatue === 'success'||ActiveStatue==='error'||ActiveStatue==='test_init_fail'||ActiveStatue==='connect_timeout'||ActiveStatue==='pause_timeout')"
|
(ActiveStatue === 'success' ||
|
||||||
@click="nextStep">
|
ActiveStatue === 'error' ||
|
||||||
|
ActiveStatue === 'test_init_fail' ||
|
||||||
|
ActiveStatue === 'connect_timeout' ||
|
||||||
|
ActiveStatue === 'pause_timeout')
|
||||||
|
"
|
||||||
|
@click="nextStep"
|
||||||
|
>
|
||||||
{{ nextStepText }}
|
{{ nextStepText }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button type="primary" @click="handleQuit" v-else>
|
<el-button type="primary" @click="handleQuit" v-else>退出检测</el-button>
|
||||||
退出检测
|
|
||||||
</el-button>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="tsx" setup name="testPopup">
|
<script lang="tsx" setup name="testPopup">
|
||||||
import {nextTick, reactive, ref, watch} from 'vue';
|
import { nextTick, reactive, ref, watch } from 'vue'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import {Coin, Edit, Key, Odometer, Refresh, Right, SuccessFilled, UploadFilled, VideoPause, VideoPlay} from '@element-plus/icons-vue'
|
import {
|
||||||
|
Coin,
|
||||||
|
Edit,
|
||||||
|
Key,
|
||||||
|
Odometer,
|
||||||
|
Refresh,
|
||||||
|
Right,
|
||||||
|
SuccessFilled,
|
||||||
|
UploadFilled,
|
||||||
|
VideoPause,
|
||||||
|
VideoPlay
|
||||||
|
} from '@element-plus/icons-vue'
|
||||||
import ComparePreTest from './comparePreTest.vue'
|
import ComparePreTest from './comparePreTest.vue'
|
||||||
import CompareTest from './compareTest.vue'
|
import CompareTest from './compareTest.vue'
|
||||||
import socketClient from '@/utils/webSocketClient';
|
import socketClient from '@/utils/webSocketClient'
|
||||||
import {useCheckStore} from "@/stores/modules/check";
|
import { useCheckStore } from '@/stores/modules/check'
|
||||||
import { pauseTest, resumeTest, startPreTest, contrastTest } from '@/api/socket/socket'
|
import { pauseTest, resumeTest, startPreTest, contrastTest } from '@/api/socket/socket'
|
||||||
import {useUserStore} from "@/stores/modules/user";
|
import { useUserStore } from '@/stores/modules/user'
|
||||||
import {JwtUtil} from "@/utils/jwtUtil";
|
import { JwtUtil } from '@/utils/jwtUtil'
|
||||||
|
// import {JwtUtil} from "@/utils/check";
|
||||||
|
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const checkStore = useCheckStore();
|
const checkStore = useCheckStore()
|
||||||
const nextStepText = ref('下一步');
|
|
||||||
|
const nextStepText = ref('下一步')
|
||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
|
|
||||||
const showSteps = ref(false)
|
const showSteps = ref(false)
|
||||||
const stepsTotalNum = ref(-1);//步骤总数
|
const stepsTotalNum = ref(-1) //步骤总数
|
||||||
const stepsActiveIndex = ref(1); //当前正在执行的步骤索引
|
const stepsActiveIndex = ref(1) //当前正在执行的步骤索引
|
||||||
const stepsActiveView = ref(1); //当前正在执行的步骤在(预处理、守时校验、系数校准、正式检测)中的排序,仅用于页面显示
|
const stepsActiveView = ref(1) //当前正在执行的步骤在(预处理、守时校验、系数校准、正式检测)中的排序,仅用于页面显示
|
||||||
const stepsActive = ref(-1); //当前正在执行的步骤在(预处理、守时校验、系数校准、正式检测)中的排序,实际记录步骤的状态,用于切换步骤
|
const stepsActive = ref(-1) //当前正在执行的步骤在(预处理、守时校验、系数校准、正式检测)中的排序,实际记录步骤的状态,用于切换步骤
|
||||||
const ActiveStatue = ref('waiting');//当前步骤状态
|
const ActiveStatue = ref('waiting') //当前步骤状态
|
||||||
const preTestStatus = ref('waiting');//预检测执行状态
|
const preTestStatus = ref('waiting') //预检测执行状态
|
||||||
const TestStatus = ref('waiting');//正式检测执行状态
|
const TestStatus = ref('waiting') //正式检测执行状态
|
||||||
const webMsgSend = ref();//webSocket推送的数据
|
const webMsgSend = ref() //webSocket推送的数据
|
||||||
|
|
||||||
|
|
||||||
const dialogTitle = ref('')
|
const dialogTitle = ref('')
|
||||||
const showComponent = ref(true)
|
const showComponent = ref(true)
|
||||||
const preTestRef = ref<InstanceType<typeof ComparePreTest> | null>(null)
|
const preTestRef = ref<InstanceType<typeof ComparePreTest> | null>(null)
|
||||||
const testRef = ref(null)
|
const testRef: any = ref(null)
|
||||||
|
|
||||||
const dataSocket = reactive({
|
const dataSocket = reactive({
|
||||||
socketServe: socketClient.Instance,
|
socketServe: socketClient.Instance
|
||||||
});
|
})
|
||||||
|
|
||||||
// 勾选的检测内容
|
// 勾选的检测内容
|
||||||
const preTestSelected = ref(true)
|
const preTestSelected = ref(true)
|
||||||
@@ -146,7 +212,15 @@ const standardDevIds = ref<[]>()
|
|||||||
const pairs = ref<any>()
|
const pairs = ref<any>()
|
||||||
const testAgain = ref(false) //重新检测按钮是否显示
|
const testAgain = ref(false) //重新检测按钮是否显示
|
||||||
const checkNumber = ref(0) //检测次数
|
const checkNumber = ref(0) //检测次数
|
||||||
const open = async (title: string,mapping:any,plan: string,login: string,devIdsArray: [],standardDevIdsArray: [],pair:any) => {
|
const open = async (
|
||||||
|
title: string,
|
||||||
|
mapping: any,
|
||||||
|
plan: string,
|
||||||
|
login: string,
|
||||||
|
devIdsArray: [],
|
||||||
|
standardDevIdsArray: [],
|
||||||
|
pair: any
|
||||||
|
) => {
|
||||||
if (checkStore.selectTestItems.preTest && !checkStore.selectTestItems.test) {
|
if (checkStore.selectTestItems.preTest && !checkStore.selectTestItems.test) {
|
||||||
testAgain.value = true
|
testAgain.value = true
|
||||||
}
|
}
|
||||||
@@ -158,21 +232,21 @@ const open = async (title: string,mapping:any,plan: string,login: string,devIdsA
|
|||||||
pairs.value = pair
|
pairs.value = pair
|
||||||
showSteps.value = true
|
showSteps.value = true
|
||||||
initOperate()
|
initOperate()
|
||||||
dialogTitle.value = title;
|
dialogTitle.value = title
|
||||||
dialogVisible.value = true;
|
dialogVisible.value = true
|
||||||
|
|
||||||
// 等待组件渲染完成
|
// 等待组件渲染完成
|
||||||
await nextTick();
|
await nextTick()
|
||||||
|
|
||||||
if (preTestRef.value) {
|
if (preTestRef.value) {
|
||||||
preTestRef.value.initializeParameters();
|
preTestRef.value.initializeParameters()
|
||||||
}
|
}
|
||||||
|
|
||||||
//开始创建webSocket客户端
|
//开始创建webSocket客户端
|
||||||
socketClient.Instance.connect();
|
socketClient.Instance.connect()
|
||||||
dataSocket.socketServe = socketClient.Instance;
|
dataSocket.socketServe = socketClient.Instance
|
||||||
dataSocket.socketServe.registerCallBack('aaa', (res: { code: number; }) => {
|
dataSocket.socketServe.registerCallBack('aaa', (res: { code: number }) => {
|
||||||
console.log('Received message:', res)
|
// console.log('Received message:', res)
|
||||||
// 处理来自服务器的消息
|
// 处理来自服务器的消息
|
||||||
if (res.code === 20000) {
|
if (res.code === 20000) {
|
||||||
//ElMessage.error(message.message)
|
//ElMessage.error(message.message)
|
||||||
@@ -180,7 +254,7 @@ const open = async (title: string,mapping:any,plan: string,login: string,devIdsA
|
|||||||
} else {
|
} else {
|
||||||
webMsgSend.value = res
|
webMsgSend.value = res
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//预检测-重新检测
|
//预检测-重新检测
|
||||||
@@ -198,12 +272,15 @@ const handleSubmitAgain = async () => {
|
|||||||
|
|
||||||
// 通知子组件清空并重新初始化
|
// 通知子组件清空并重新初始化
|
||||||
if (preTestRef.value) {
|
if (preTestRef.value) {
|
||||||
preTestRef.value.initializeParameters();
|
preTestRef.value.initializeParameters()
|
||||||
}
|
}
|
||||||
|
testRef.value && testRef.value.initializeParameters()
|
||||||
|
|
||||||
// 重置状态
|
// 重置状态
|
||||||
|
nextStepText.value = '下一步'
|
||||||
ActiveStatue.value = 'waiting'
|
ActiveStatue.value = 'waiting'
|
||||||
preTestStatus.value = 'waiting'
|
preTestStatus.value = 'waiting'
|
||||||
|
TestStatus.value = 'waiting'
|
||||||
|
|
||||||
await contrastTest({
|
await contrastTest({
|
||||||
planId: planId.value,
|
planId: planId.value,
|
||||||
@@ -212,11 +289,12 @@ const handleSubmitAgain = async () => {
|
|||||||
standardDevIds: standardDevIds.value,
|
standardDevIds: standardDevIds.value,
|
||||||
pairs: pairs.value,
|
pairs: pairs.value,
|
||||||
testItemList: [checkStore.selectTestItems.preTest, false, checkStore.selectTestItems.test],
|
testItemList: [checkStore.selectTestItems.preTest, false, checkStore.selectTestItems.test],
|
||||||
userId: userStore.userInfo.id,
|
|
||||||
|
userId: userStore.userInfo.id
|
||||||
})
|
})
|
||||||
|
|
||||||
preTestStatus.value = 'start'
|
preTestStatus.value = 'start'
|
||||||
};
|
}
|
||||||
|
|
||||||
//开始检测
|
//开始检测
|
||||||
const handleSubmitFast = async () => {
|
const handleSubmitFast = async () => {
|
||||||
@@ -236,14 +314,19 @@ const handleSubmitFast = async () => {
|
|||||||
standardDevIds: standardDevIds.value,
|
standardDevIds: standardDevIds.value,
|
||||||
pairs: pairs.value,
|
pairs: pairs.value,
|
||||||
testItemList: [checkStore.selectTestItems.preTest, false, checkStore.selectTestItems.test],
|
testItemList: [checkStore.selectTestItems.preTest, false, checkStore.selectTestItems.test],
|
||||||
userId: userStore.userInfo.id,
|
|
||||||
|
userId: userStore.userInfo.id
|
||||||
})
|
})
|
||||||
preTestStatus.value = 'start'
|
preTestStatus.value = 'start'
|
||||||
|
if (checkStore.selectTestItems.test) {
|
||||||
|
testRef.value.initializeParameters()
|
||||||
|
testRef.value.showTestLog()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
break
|
||||||
case 2:
|
case 2:
|
||||||
if (TestStatus.value == "waiting") {
|
if (TestStatus.value == 'waiting') {
|
||||||
// 如果没有预检测,直接进行正式检测需要先初始化
|
// 如果没有预检测,直接进行正式检测需要先初始化
|
||||||
if (!checkStore.selectTestItems.preTest && checkStore.selectTestItems.test) {
|
if (!checkStore.selectTestItems.preTest && checkStore.selectTestItems.test) {
|
||||||
await contrastTest({
|
await contrastTest({
|
||||||
@@ -253,7 +336,8 @@ const handleSubmitFast = async () => {
|
|||||||
standardDevIds: standardDevIds.value,
|
standardDevIds: standardDevIds.value,
|
||||||
pairs: pairs.value,
|
pairs: pairs.value,
|
||||||
testItemList: [checkStore.selectTestItems.preTest, false, checkStore.selectTestItems.test],
|
testItemList: [checkStore.selectTestItems.preTest, false, checkStore.selectTestItems.test],
|
||||||
userId: userStore.userInfo.id,
|
|
||||||
|
userId: userStore.userInfo.id
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
TestStatus.value = 'start'
|
TestStatus.value = 'start'
|
||||||
@@ -261,37 +345,47 @@ const handleSubmitFast = async () => {
|
|||||||
// 发送继续指令
|
// 发送继续指令
|
||||||
//sendResume()
|
//sendResume()
|
||||||
}
|
}
|
||||||
break;
|
break
|
||||||
default:
|
default:
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: 'quitClicked'): void;
|
(e: 'quitClicked'): void
|
||||||
}>();
|
}>()
|
||||||
|
|
||||||
watch(preTestStatus, function (newValue, oldValue) {
|
watch(preTestStatus, function (newValue, oldValue) {
|
||||||
console.log('预检测状态',newValue, oldValue);
|
console.log('预检测状态', newValue, oldValue)
|
||||||
ActiveStatue.value = newValue
|
ActiveStatue.value = newValue
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(TestStatus, function (newValue, oldValue) {
|
watch(TestStatus, function (newValue, oldValue) {
|
||||||
console.log('正式检测状态',newValue, oldValue);
|
console.log('正式检测状态', newValue, oldValue)
|
||||||
|
|
||||||
ActiveStatue.value = newValue
|
ActiveStatue.value = newValue
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(stepsActiveIndex, function (newValue, oldValue) {
|
watch(stepsActiveIndex, function (newValue, oldValue) {
|
||||||
console.log('步骤索引',newValue, oldValue);
|
console.log(
|
||||||
|
'🚀 ~ checkStore.selectTestItems.test && checkStore.selectTestItems.preTest && newValue == 2:',
|
||||||
|
checkStore.selectTestItems.test && checkStore.selectTestItems.preTest && newValue == 2
|
||||||
|
)
|
||||||
|
|
||||||
|
if (checkStore.selectTestItems.test && checkStore.selectTestItems.preTest && newValue == 2) {
|
||||||
|
setTimeout(() => {
|
||||||
|
testRef.value.initializeParameters()
|
||||||
|
testRef.value.showTestLog()
|
||||||
|
testRef.value.startTimeCount()
|
||||||
|
}, 500)
|
||||||
|
}
|
||||||
|
console.log('步骤索引', newValue, oldValue)
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(ActiveStatue, function (newValue, oldValue) {
|
watch(ActiveStatue, function (newValue, oldValue) {
|
||||||
console.log('当前步骤状态-----',newValue);
|
console.log('当前步骤状态-----', newValue)
|
||||||
console.log('stepsActiveIndex-----',stepsActiveIndex.value);
|
console.log('stepsActiveIndex-----', stepsActiveIndex.value)
|
||||||
console.log('stepsTotalNum----',stepsTotalNum.value);
|
console.log('stepsTotalNum----', stepsTotalNum.value)
|
||||||
if (newValue === 'error') {
|
if (newValue === 'error') {
|
||||||
stepsActiveIndex.value = stepsTotalNum.value + 1
|
stepsActiveIndex.value = stepsTotalNum.value + 1
|
||||||
nextStepText.value = '检测失败'
|
nextStepText.value = '检测失败'
|
||||||
@@ -299,6 +393,7 @@ watch(ActiveStatue, function (newValue, oldValue) {
|
|||||||
if (newValue === 'success' && stepsActiveIndex.value === stepsTotalNum.value - 1) {
|
if (newValue === 'success' && stepsActiveIndex.value === stepsTotalNum.value - 1) {
|
||||||
stepsActiveIndex.value += 2
|
stepsActiveIndex.value += 2
|
||||||
nextStepText.value = '检测完成'
|
nextStepText.value = '检测完成'
|
||||||
|
console.log('🚀 ~ nextStepText.value:', nextStepText.value)
|
||||||
}
|
}
|
||||||
if (newValue === 'test_init_fail') {
|
if (newValue === 'test_init_fail') {
|
||||||
stepsActiveIndex.value += 2
|
stepsActiveIndex.value += 2
|
||||||
@@ -317,20 +412,24 @@ watch(ActiveStatue, function (newValue, oldValue) {
|
|||||||
nextStep() // 实现自动点击,进入下一个测试内容
|
nextStep() // 实现自动点击,进入下一个测试内容
|
||||||
//handleSubmitFast()
|
//handleSubmitFast()
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const handleQuit = () => {
|
const handleQuit = () => {
|
||||||
console.log('handleQuit', ActiveStatue.value)
|
console.log('handleQuit', ActiveStatue.value)
|
||||||
if (ActiveStatue.value !== 'success' && ActiveStatue.value !== 'waiting' && ActiveStatue.value !== 'paused' && ActiveStatue.value !== 'test_init_fail' && ActiveStatue.value !== 'connect_timeout' && ActiveStatue.value !== 'pause_timeout') {
|
if (
|
||||||
beforeClose(() => {
|
ActiveStatue.value !== 'success' &&
|
||||||
})
|
ActiveStatue.value !== 'waiting' &&
|
||||||
|
ActiveStatue.value !== 'paused' &&
|
||||||
|
ActiveStatue.value !== 'test_init_fail' &&
|
||||||
|
ActiveStatue.value !== 'connect_timeout' &&
|
||||||
|
ActiveStatue.value !== 'pause_timeout'
|
||||||
|
) {
|
||||||
|
beforeClose(() => {})
|
||||||
} else {
|
} else {
|
||||||
handleClose()
|
handleClose()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const handlePause = () => {
|
const handlePause = () => {
|
||||||
sendPause()
|
sendPause()
|
||||||
testRef.value?.handlePause()
|
testRef.value?.handlePause()
|
||||||
@@ -345,8 +444,8 @@ const sendResume = () => {
|
|||||||
console.log('发起继续检测请求')
|
console.log('发起继续检测请求')
|
||||||
|
|
||||||
resumeTest({
|
resumeTest({
|
||||||
userPageId: "cdf",
|
userPageId: 'cdf',
|
||||||
devIds: checkStore.devices.map((item) => item.deviceId),
|
devIds: checkStore.devices.map(item => item.deviceId),
|
||||||
planId: checkStore.plan.id,
|
planId: checkStore.plan.id,
|
||||||
reCheckType: '2', // 0:'系数校验','1'为预检测、‘2‘为正式检测、'8'为不合格项复检
|
reCheckType: '2', // 0:'系数校验','1'为预检测、‘2‘为正式检测、'8'为不合格项复检
|
||||||
userId: userStore.userInfo.id,
|
userId: userStore.userInfo.id,
|
||||||
@@ -362,19 +461,23 @@ const sendReCheck = () => {
|
|||||||
console.log('发送重新检测指令')
|
console.log('发送重新检测指令')
|
||||||
startPreTest({
|
startPreTest({
|
||||||
userPageId: JwtUtil.getLoginName(),
|
userPageId: JwtUtil.getLoginName(),
|
||||||
devIds: checkStore.devices.map((item) => item.deviceId),
|
devIds: checkStore.devices.map(item => item.deviceId),
|
||||||
planId: checkStore.plan.id,
|
planId: checkStore.plan.id,
|
||||||
reCheckType: '2', // 0:'系数校验','1'为预检测、‘2‘为正式检测、'8'为不合格项复检
|
reCheckType: '2', // 0:'系数校验','1'为预检测、‘2‘为正式检测、'8'为不合格项复检
|
||||||
userId: userStore.userInfo.id,
|
userId: userStore.userInfo.id,
|
||||||
temperature: checkStore.temperature,
|
temperature: checkStore.temperature,
|
||||||
humidity: checkStore.humidity,
|
humidity: checkStore.humidity,
|
||||||
testItemList: [checkStore.selectTestItems.preTest, checkStore.selectTestItems.channelsTest, checkStore.selectTestItems.test]
|
testItemList: [
|
||||||
|
checkStore.selectTestItems.preTest,
|
||||||
|
checkStore.selectTestItems.channelsTest,
|
||||||
|
checkStore.selectTestItems.test
|
||||||
|
]
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
console.log(res)
|
console.log(res)
|
||||||
if (res.code === 'A001014') {
|
if (res.code === 'A001014') {
|
||||||
ElMessageBox.alert('装置配置异常', '初始化失败', {
|
ElMessageBox.alert('装置配置异常', '初始化失败', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
type: 'error',
|
type: 'error'
|
||||||
})
|
})
|
||||||
TestStatus.value = 'test_init_fail'
|
TestStatus.value = 'test_init_fail'
|
||||||
}
|
}
|
||||||
@@ -387,7 +490,13 @@ const closeWebSocket = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const nextStep = () => {
|
const nextStep = () => {
|
||||||
if (stepsActiveIndex.value == stepsTotalNum.value + 1 || ActiveStatue.value === 'error' || ActiveStatue.value === 'test_init_fail' || ActiveStatue.value === 'connect_timeout' || ActiveStatue.value === 'pause_timeout') {
|
if (
|
||||||
|
stepsActiveIndex.value == stepsTotalNum.value + 1 ||
|
||||||
|
ActiveStatue.value === 'error' ||
|
||||||
|
ActiveStatue.value === 'test_init_fail' ||
|
||||||
|
ActiveStatue.value === 'connect_timeout' ||
|
||||||
|
ActiveStatue.value === 'pause_timeout'
|
||||||
|
) {
|
||||||
handleClose()
|
handleClose()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -401,7 +510,7 @@ const nextStep = () => {
|
|||||||
console.log('selectTestItemsKey1')
|
console.log('selectTestItemsKey1')
|
||||||
stepsActiveView.value = idx
|
stepsActiveView.value = idx
|
||||||
stepsActive.value = idx
|
stepsActive.value = idx
|
||||||
console.log('stepsActiveView.value999', stepsActiveView.value)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (checkStore.selectTestItems[selectTestItemsKey] && tempStep != 0) {
|
if (checkStore.selectTestItems[selectTestItemsKey] && tempStep != 0) {
|
||||||
@@ -426,10 +535,10 @@ function clearData() {
|
|||||||
stepsTotalNum.value = -1
|
stepsTotalNum.value = -1
|
||||||
stepsActiveIndex.value = 1
|
stepsActiveIndex.value = 1
|
||||||
stepsActiveView.value = -1
|
stepsActiveView.value = -1
|
||||||
preTestStatus.value = "waiting"
|
preTestStatus.value = 'waiting'
|
||||||
TestStatus.value = "waiting"
|
TestStatus.value = 'waiting'
|
||||||
ActiveStatue.value = "waiting"
|
ActiveStatue.value = 'waiting'
|
||||||
nextStepText.value = "下一步"
|
nextStepText.value = '下一步'
|
||||||
}
|
}
|
||||||
|
|
||||||
const beforeClose = (done: () => void) => {
|
const beforeClose = (done: () => void) => {
|
||||||
@@ -437,9 +546,8 @@ const beforeClose = (done: () => void) => {
|
|||||||
ElMessageBox.confirm('检测未完成,是否退出当前检测流程?', '提示', {
|
ElMessageBox.confirm('检测未完成,是否退出当前检测流程?', '提示', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning',
|
type: 'warning'
|
||||||
}
|
}).then(() => {
|
||||||
).then(() => {
|
|
||||||
handleClose()
|
handleClose()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@@ -450,11 +558,11 @@ const beforeClose = (done: () => void) => {
|
|||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
showSteps.value = false
|
showSteps.value = false
|
||||||
dataSocket.socketServe.closeWs()
|
dataSocket.socketServe.closeWs()
|
||||||
dialogVisible.value = false;
|
dialogVisible.value = false
|
||||||
clearData()
|
clearData()
|
||||||
showComponent.value = false;
|
showComponent.value = false
|
||||||
|
|
||||||
emit('quitClicked'); // 触发事件
|
emit('quitClicked') // 触发事件
|
||||||
}
|
}
|
||||||
|
|
||||||
// 对外映射
|
// 对外映射
|
||||||
@@ -462,7 +570,6 @@ defineExpose({open})
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|
||||||
.test-head-steps {
|
.test-head-steps {
|
||||||
::v-deep .el-step {
|
::v-deep .el-step {
|
||||||
.el-step__head.is-success {
|
.el-step__head.is-success {
|
||||||
@@ -485,24 +592,31 @@ defineExpose({open})
|
|||||||
}
|
}
|
||||||
|
|
||||||
.steps-container :deep(.el-step__title) {
|
.steps-container :deep(.el-step__title) {
|
||||||
font-size: 20px !important; /* 设置标题字体大小 */
|
font-size: 20px !important;
|
||||||
|
/* 设置标题字体大小 */
|
||||||
vertical-align: baseline !important;
|
vertical-align: baseline !important;
|
||||||
display: inline-block; /* 确保文字和图标在同一行 */
|
display: inline-block;
|
||||||
line-height: 1; /* 调整行高以确保底部对齐 */
|
/* 确保文字和图标在同一行 */
|
||||||
|
line-height: 1;
|
||||||
|
/* 调整行高以确保底部对齐 */
|
||||||
}
|
}
|
||||||
|
|
||||||
.steps-container :deep(.el-step__icon-inner) {
|
.steps-container :deep(.el-step__icon-inner) {
|
||||||
font-size: 18px !important;
|
font-size: 18px !important;
|
||||||
vertical-align: baseline !important;
|
vertical-align: baseline !important;
|
||||||
display: inline-block; /* 确保文字和图标在同一行 */
|
display: inline-block;
|
||||||
line-height: 1; /* 调整行高以确保底部对齐 */
|
/* 确保文字和图标在同一行 */
|
||||||
|
line-height: 1;
|
||||||
|
/* 调整行高以确保底部对齐 */
|
||||||
}
|
}
|
||||||
|
|
||||||
.steps-container :deep(.el-step__icon) {
|
.steps-container :deep(.el-step__icon) {
|
||||||
font-size: 18px !important;
|
font-size: 18px !important;
|
||||||
vertical-align: baseline !important;
|
vertical-align: baseline !important;
|
||||||
display: inline-block; /* 确保文字和图标在同一行 */
|
display: inline-block;
|
||||||
line-height: 1; /* 调整行高以确保底部对齐 */
|
/* 确保文字和图标在同一行 */
|
||||||
|
line-height: 1;
|
||||||
|
/* 调整行高以确保底部对齐 */
|
||||||
}
|
}
|
||||||
|
|
||||||
.loading-box {
|
.loading-box {
|
||||||
@@ -513,6 +627,7 @@ defineExpose({open})
|
|||||||
from {
|
from {
|
||||||
transform: rotate(0deg);
|
transform: rotate(0deg);
|
||||||
}
|
}
|
||||||
|
|
||||||
to {
|
to {
|
||||||
transform: rotate(360deg);
|
transform: rotate(360deg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog title="设备通道配对" v-model='dialogVisible' v-bind="dialogBig" >
|
<el-dialog title="设备通道配对" v-model="dialogVisible" v-bind="dialogBig">
|
||||||
<div class="flow-container" style="overflow: hidden; position: relative" :style="{ height: dialogHeight + 'px' }">
|
<div
|
||||||
|
class="flow-container"
|
||||||
|
style="overflow: hidden; position: relative"
|
||||||
|
:style="{ height: dialogHeight + 'px' }"
|
||||||
|
>
|
||||||
<!-- <el-button @click="logConnections">打印当前配对</el-button> -->
|
<!-- <el-button @click="logConnections">打印当前配对</el-button> -->
|
||||||
<VueFlow
|
<VueFlow
|
||||||
:nodes="nodes"
|
:nodes="nodes"
|
||||||
@@ -22,8 +26,7 @@
|
|||||||
@connect-end="handleConnectEnd"
|
@connect-end="handleConnectEnd"
|
||||||
@pane-ready="onPaneReady"
|
@pane-ready="onPaneReady"
|
||||||
v-on:pane-mouse-move="false"
|
v-on:pane-mouse-move="false"
|
||||||
>
|
></VueFlow>
|
||||||
</VueFlow>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 底部操作按钮 -->
|
<!-- 底部操作按钮 -->
|
||||||
@@ -37,27 +40,24 @@
|
|||||||
|
|
||||||
<!-- 手动检测-勾选检测项弹窗 -->
|
<!-- 手动检测-勾选检测项弹窗 -->
|
||||||
<SelectTestItemPopup ref="selectTestItemPopupRef" @openTestDialog="openTestDialog"></SelectTestItemPopup>
|
<SelectTestItemPopup ref="selectTestItemPopupRef" @openTestDialog="openTestDialog"></SelectTestItemPopup>
|
||||||
<CompareTestPopup ref='testPopup'></CompareTestPopup>
|
<CompareTestPopup ref="testPopup"></CompareTestPopup>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { h, ref } from 'vue'
|
import { h, ref } from 'vue'
|
||||||
import { VueFlow, useVueFlow } from '@vue-flow/core'
|
import { VueFlow, useVueFlow } from '@vue-flow/core'
|
||||||
import { dialogBig } from "@/utils/elementBind";
|
import { dialogBig } from '@/utils/elementBind'
|
||||||
import { Platform, Flag } from '@element-plus/icons-vue'
|
import { Platform, Flag } from '@element-plus/icons-vue'
|
||||||
import { Device } from '@/api/device/interface/device';
|
import { Device } from '@/api/device/interface/device'
|
||||||
import { StandardDevice } from '@/api/device/interface/standardDevice';
|
import { StandardDevice } from '@/api/device/interface/standardDevice'
|
||||||
import SelectTestItemPopup from "@/views/home/components/selectTestItemPopup.vue";
|
import SelectTestItemPopup from '@/views/home/components/selectTestItemPopup.vue'
|
||||||
import CompareTestPopup from './compareTestPopup.vue'
|
import CompareTestPopup from './compareTestPopup.vue'
|
||||||
import { ElMessage } from 'element-plus';
|
import { ElMessage } from 'element-plus'
|
||||||
import CustomEdge from './RemoveableEdge.vue' // 导入自定义连接线组件
|
import CustomEdge from './RemoveableEdge.vue' // 导入自定义连接线组件
|
||||||
import { jwtUtil } from "@/utils/jwtUtil";
|
import { jwtUtil } from '@/utils/jwtUtil'
|
||||||
import {useCheckStore} from "@/stores/modules/check";
|
import { useCheckStore } from '@/stores/modules/check'
|
||||||
|
|
||||||
|
const checkStore = useCheckStore()
|
||||||
|
|
||||||
|
|
||||||
const checkStore = useCheckStore();
|
|
||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
const selectTestItemPopupRef = ref<InstanceType<typeof SelectTestItemPopup>>()
|
const selectTestItemPopupRef = ref<InstanceType<typeof SelectTestItemPopup>>()
|
||||||
const testPopup = ref()
|
const testPopup = ref()
|
||||||
@@ -79,7 +79,9 @@ const onPaneReady = () => {
|
|||||||
|
|
||||||
// 提取公共的label渲染函数
|
// 提取公共的label渲染函数
|
||||||
const createLabel = (text: string, type: string) => {
|
const createLabel = (text: string, type: string) => {
|
||||||
return h('div', {
|
return h(
|
||||||
|
'div',
|
||||||
|
{
|
||||||
style: {
|
style: {
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
@@ -91,7 +93,8 @@ const createLabel = (text: string, type: string) => {
|
|||||||
padding: '8px',
|
padding: '8px',
|
||||||
backgroundColor: '#f9f9f9'
|
backgroundColor: '#f9f9f9'
|
||||||
}
|
}
|
||||||
}, [
|
},
|
||||||
|
[
|
||||||
h(Platform, {
|
h(Platform, {
|
||||||
style: {
|
style: {
|
||||||
width: '20px',
|
width: '20px',
|
||||||
@@ -101,11 +104,14 @@ const createLabel = (text: string, type: string) => {
|
|||||||
}),
|
}),
|
||||||
h('div', null, '设备名称:' + text),
|
h('div', null, '设备名称:' + text),
|
||||||
h('div', null, '设备类型:' + type)
|
h('div', null, '设备类型:' + type)
|
||||||
]) as any
|
]
|
||||||
|
) as any
|
||||||
}
|
}
|
||||||
|
|
||||||
const createLabel3 = (text: string) => {
|
const createLabel3 = (text: string) => {
|
||||||
return h('div', {
|
return h(
|
||||||
|
'div',
|
||||||
|
{
|
||||||
style: {
|
style: {
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
@@ -116,7 +122,8 @@ const createLabel3 = (text: string) => {
|
|||||||
padding: '8px',
|
padding: '8px',
|
||||||
backgroundColor: '#f9f9f9'
|
backgroundColor: '#f9f9f9'
|
||||||
}
|
}
|
||||||
}, [
|
},
|
||||||
|
[
|
||||||
h(Flag, {
|
h(Flag, {
|
||||||
style: {
|
style: {
|
||||||
width: '20px',
|
width: '20px',
|
||||||
@@ -125,10 +132,10 @@ const createLabel3 = (text: string) => {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
text
|
text
|
||||||
]) as any
|
]
|
||||||
|
) as any
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const handleConnectStart = (params: any) => {
|
const handleConnectStart = (params: any) => {
|
||||||
onPaneReady()
|
onPaneReady()
|
||||||
}
|
}
|
||||||
@@ -138,14 +145,12 @@ const handleConnectEnd = (params: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleConnect = (params: any) => {
|
const handleConnect = (params: any) => {
|
||||||
console.log('连接信息:', params);
|
console.log('连接信息:', params)
|
||||||
const sourceNode = nodes.value.find(node => node.id === params.source)
|
const sourceNode = nodes.value.find(node => node.id === params.source)
|
||||||
const targetNode = nodes.value.find(node => node.id === params.target)
|
const targetNode = nodes.value.find(node => node.id === params.target)
|
||||||
|
|
||||||
// 连接规则验证
|
// 连接规则验证
|
||||||
const isValidConnection =
|
const isValidConnection = sourceNode?.type === 'input' && targetNode?.type === 'output'
|
||||||
sourceNode?.type === 'input' &&
|
|
||||||
targetNode?.type === 'output'
|
|
||||||
|
|
||||||
if (!isValidConnection) {
|
if (!isValidConnection) {
|
||||||
removeEdge(params)
|
removeEdge(params)
|
||||||
@@ -154,47 +159,46 @@ const handleConnect = (params: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 过滤掉当前连接,检查是否还有重复的
|
// 过滤掉当前连接,检查是否还有重复的
|
||||||
const existingEdges = edges.value.filter(edge =>
|
const existingEdges = edges.value.filter(edge => edge.source === params.source || edge.target === params.target)
|
||||||
edge.source === params.source || edge.target === params.target
|
|
||||||
);
|
|
||||||
|
|
||||||
// 如果同源或同目标的连接超过1个,说明有重复
|
// 如果同源或同目标的连接超过1个,说明有重复
|
||||||
if (existingEdges.length > 1) {
|
if (existingEdges.length > 1) {
|
||||||
const duplicateSource = existingEdges.filter(edge => edge.source === params.source).length > 1;
|
const duplicateSource = existingEdges.filter(edge => edge.source === params.source).length > 1
|
||||||
const duplicateTarget = existingEdges.filter(edge => edge.target === params.target).length > 1;
|
const duplicateTarget = existingEdges.filter(edge => edge.target === params.target).length > 1
|
||||||
|
|
||||||
if (duplicateSource) {
|
if (duplicateSource) {
|
||||||
removeEdge(params);
|
removeEdge(params)
|
||||||
ElMessage.warning('该被检通道已经连接,不能重复连接');
|
ElMessage.warning('该被检通道已经连接,不能重复连接')
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (duplicateTarget) {
|
if (duplicateTarget) {
|
||||||
removeEdge(params);
|
removeEdge(params)
|
||||||
ElMessage.warning('该标准通道已经连接,不能重复连接');
|
ElMessage.warning('该标准通道已经连接,不能重复连接')
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除不合法连接
|
// 删除不合法连接
|
||||||
const removeEdge = (params: any) => {
|
const removeEdge = (params: any) => {
|
||||||
const edgeIndex = edges.value.findIndex(edge =>
|
const edgeIndex = edges.value.findIndex(edge => edge.source === params.source && edge.target === params.target)
|
||||||
edge.source === params.source && edge.target === params.target
|
|
||||||
)
|
|
||||||
if (edgeIndex !== -1) {
|
if (edgeIndex !== -1) {
|
||||||
edges.value.splice(edgeIndex, 1)
|
edges.value.splice(edgeIndex, 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const nodes = ref([])
|
const nodes = ref([])
|
||||||
const planId = ref('')
|
const planId = ref('')
|
||||||
const devIds = ref<string[]>()
|
const devIds = ref<string[]>()
|
||||||
const standardDevIds = ref<string[]>()
|
const standardDevIds = ref<string[]>()
|
||||||
|
|
||||||
const open = async (device: Device.ResPqDev[], standardDev: StandardDevice.ResPqStandardDevice[],fatherPlanId: string) => {
|
const open = async (
|
||||||
console.log('device:', device);
|
device: Device.ResPqDev[],
|
||||||
|
standardDev: StandardDevice.ResPqStandardDevice[],
|
||||||
|
fatherPlanId: string
|
||||||
|
) => {
|
||||||
|
console.log('device:', device)
|
||||||
edges.value = []
|
edges.value = []
|
||||||
devIds.value = device.map(d => d.id)
|
devIds.value = device.map(d => d.id)
|
||||||
standardDevIds.value = standardDev.map(d => d.id)
|
standardDevIds.value = standardDev.map(d => d.id)
|
||||||
@@ -204,32 +208,57 @@ const open = async (device: Device.ResPqDev[], standardDev: StandardDevice.ResPq
|
|||||||
onPaneReady()
|
onPaneReady()
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleNext = () => {
|
const handleNext = async () => {
|
||||||
if (edges.value.length === 0) {
|
if (edges.value.length === 0) {
|
||||||
ElMessage.warning('请先完成通道配对')
|
ElMessage.warning('请先完成通道配对')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// const sourceKey = edge.source.replace('被检通道-', '').replace('-', '_');
|
||||||
|
let chnNumList: object[] = []
|
||||||
|
await edges.value.forEach(edge => {
|
||||||
|
const match = edge.source.split('-')
|
||||||
|
|
||||||
|
if (match) {
|
||||||
|
chnNumList.push({
|
||||||
|
deviceId: match[1],
|
||||||
|
label: match[2]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
console.log('🚀 ~ handleNext ~ edges.value:', edges.value)
|
||||||
|
|
||||||
|
await checkStore.setChnNum(chnNumList)
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
selectTestItemPopupRef.value?.open()
|
selectTestItemPopupRef.value?.open()
|
||||||
}
|
}
|
||||||
|
|
||||||
const openTestDialog = async () => {
|
const openTestDialog = async () => {
|
||||||
// 转换连接信息,只保留设备ID和通道号
|
// 转换连接信息,只保留设备ID和通道号
|
||||||
const connections = edges.value.reduce((map, edge) => {
|
const connections = edges.value.reduce(
|
||||||
|
(map, edge) => {
|
||||||
// 从source中提取设备ID和通道号: 被检通道-{deviceId}-{channelNum} => {deviceId}-{channelNum}
|
// 从source中提取设备ID和通道号: 被检通道-{deviceId}-{channelNum} => {deviceId}-{channelNum}
|
||||||
const sourceKey = edge.source.replace('被检通道-', '').replace('-', '_');
|
const sourceKey = edge.source.replace('被检通道-', '').replace('-', '_')
|
||||||
|
|
||||||
// 从target中提取设备ID和通道号: 标准通道-{deviceId}-{channelNum} => {deviceId}-{channelNum}
|
// 从target中提取设备ID和通道号: 标准通道-{deviceId}-{channelNum} => {deviceId}-{channelNum}
|
||||||
const targetValue = edge.target.replace('标准通道-', '').replace('-', '_');
|
const targetValue = edge.target.replace('标准通道-', '').replace('-', '_')
|
||||||
|
|
||||||
map[sourceKey] = targetValue;
|
|
||||||
return map;
|
|
||||||
}, {} as Record<string, string>);
|
|
||||||
|
|
||||||
|
map[sourceKey] = targetValue
|
||||||
|
return map
|
||||||
|
},
|
||||||
|
{} as Record<string, string>
|
||||||
|
)
|
||||||
|
|
||||||
generateChannelMapping()
|
generateChannelMapping()
|
||||||
|
|
||||||
testPopup.value?.open(dialogTitle.value,channelMapping.value,planId.value,jwtUtil.getLoginName(),devIds.value,standardDevIds.value,connections)
|
testPopup.value?.open(
|
||||||
|
dialogTitle.value,
|
||||||
|
channelMapping.value,
|
||||||
|
planId.value,
|
||||||
|
jwtUtil.getLoginName(),
|
||||||
|
devIds.value,
|
||||||
|
standardDevIds.value,
|
||||||
|
connections
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 转换 edges.value 为 channelMapping 格式
|
// 转换 edges.value 为 channelMapping 格式
|
||||||
@@ -303,7 +332,7 @@ const createNodes = (device: Device.ResPqDev[], standardDev: StandardDevice.ResP
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
const newNodes: any[] = []
|
const newNodes: any[] = []
|
||||||
const deviceChannelGroups: { deviceId: string; centerY: number; }[] = []
|
const deviceChannelGroups: { deviceId: string; centerY: number }[] = []
|
||||||
const standardChannelGroups: any[] = []
|
const standardChannelGroups: any[] = []
|
||||||
|
|
||||||
const deviceWidth = 0
|
const deviceWidth = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user