手动检测功能修改、一键检测功能修改(均未完成)

This commit is contained in:
caozehui
2025-02-25 10:17:33 +08:00
parent a0c7f79302
commit 280289af37
11 changed files with 1793 additions and 833 deletions

View File

@@ -90,6 +90,11 @@ export namespace CheckData {
deviceId: string; //装置序号Id deviceId: string; //装置序号Id
deviceName: string; //设备名称 deviceName: string; //设备名称
chnNum: number; //设备通道数 chnNum: number; //设备通道数
planId: string; //计划Id
devType: string; //设备类型
devVolt:number; //设备电压
devCurr:number; //设备电流
} }
// 用来描述检测脚本类型 // 用来描述检测脚本类型
@@ -173,6 +178,16 @@ export namespace CheckData {
type: 'info' | 'warning' | 'error' type: 'info' | 'warning' | 'error'
log: string log: string
} }
/**
* 定义手动检测时,勾选的测试项
*/
export interface SelectTestItem {
preTest: boolean,
timeTest: boolean,
channelsTest: boolean,
test: boolean
}
} }

View File

@@ -2,7 +2,7 @@ import http from "@/api";
import {CheckData} from "@/api/check/interface"; import {CheckData} from "@/api/check/interface";
export const getBigTestItem = (planId: string) => { export const getBigTestItem = (planId: string) => {
return http.get(`/adPlan/getBigTestItem?planId=${planId}`, {loading: false}); return http.get(`/adPlan/getBigTestItem?planId=${planId}`);
} }
/** /**

View File

@@ -1,6 +1,7 @@
import {defineStore} from "pinia"; import {defineStore} from "pinia";
import {CHECK_STORE_KEY} from "@/stores/constant"; import {CHECK_STORE_KEY} from "@/stores/constant";
import type {CheckData} from "@/api/check/interface"; import type {CheckData} from "@/api/check/interface";
import type {Plan} from '@/api/plan/interface'
export const useCheckStore = defineStore("check", { export const useCheckStore = defineStore("check", {
@@ -8,10 +9,8 @@ export const useCheckStore = defineStore("check", {
state: () => ({ state: () => ({
devices: Array<CheckData.Device>(), devices: Array<CheckData.Device>(),
planId: String(""), plan: Object<Plan.ResPlan>(),
planCode: String(""), selectTestItems: Object<CheckData.SelectTestItem>({preTest: true, timeTest: true, channelsTest: true, test: true}),
scriptId: String(""),
errorSysId: String(""),
}), }),
getters: {}, getters: {},
@@ -20,25 +19,19 @@ export const useCheckStore = defineStore("check", {
addDevices(device: CheckData.Device[]) { addDevices(device: CheckData.Device[]) {
this.devices.push(...device); this.devices.push(...device);
}, },
setPlan(plan: Plan.ResPlan) {
this.plan = plan
},
clearDevices() { clearDevices() {
this.devices = []; this.devices = [];
}, },
initSelectTestItems() {
setPlanId(planId: string) { this.selectTestItems.preTest = true
this.planId = planId this.selectTestItems.channelsTest = true
this.selectTestItems.test = true
}, },
setSelectTestItems(selectTestItems: CheckData.SelectTestItem) {
setPlanCode(planCode: string) { this.selectTestItems = selectTestItems
this.planCode = planCode
},
setScriptId(scriptId: string) {
this.scriptId = scriptId
},
setErrorSysId(errorSysId: string) {
this.errorSysId = errorSysId
} }
} }
}); });

View File

@@ -206,11 +206,11 @@ watch(() => formContent.chnNum, async (newVal, oldVal) => {
if (newVal) { if (newVal) {
// 发起请求,查询该测试项的检测结果 // 发起请求,查询该测试项的检测结果
const {data: resTreeDataTemp}: { data: CheckData.TreeItem[] } = await getTreeData({ const {data: resTreeDataTemp}: { data: CheckData.TreeItem[] } = await getTreeData({
scriptId: checkStore.scriptId, scriptId: checkStore.plan.scriptId,
devId: deviceId, devId: deviceId,
devNum: formContent.chnNum + '', devNum: formContent.chnNum + '',
scriptType: originScriptType, scriptType: originScriptType,
code: parseInt(checkStore.planCode) code: parseInt(checkStore.plan.code)
}) })
updateTreeFly(resTreeDataTemp, 4) updateTreeFly(resTreeDataTemp, 4)
updateTreeFly(resTreeDataTemp, 2) updateTreeFly(resTreeDataTemp, 2)
@@ -278,10 +278,10 @@ const updateTableData = async () => {
// 发起请求,查询该测试项的检测结果 // 发起请求,查询该测试项的检测结果
const {data} = await getTableData({ const {data} = await getTableData({
scriptType, scriptType,
scriptId: checkStore.scriptId, scriptId: checkStore.plan.scriptId,
devId: deviceId, devId: deviceId,
devNum: formContent.chnNum + '', devNum: formContent.chnNum + '',
code: parseInt(checkStore.planCode), code: parseInt(checkStore.plan.code),
index: parseInt(checkIndex.value), index: parseInt(checkIndex.value),
}) })
@@ -372,7 +372,7 @@ const open = async (_deviceId: string, chnNum: string, _scriptType: string | nul
// 发起后端请求,查询详细信息 当chnNum为-1时查询所有通道号 // 发起后端请求,查询详细信息 当chnNum为-1时查询所有通道号
const {data: resFormContent}: { data: any } = await getFormData({ const {data: resFormContent}: { data: any } = await getFormData({
planId: checkStore.planId, planId: checkStore.plan.id,
deviceId, deviceId,
chnNum, chnNum,
scriptType scriptType
@@ -471,10 +471,10 @@ const setCheckResultData = (data: CheckData.ResCheckResult | null) => {
const exportRawDataHandler = () => { const exportRawDataHandler = () => {
useDownload(exportRawData, '原始数据.xlsx', { useDownload(exportRawData, '原始数据.xlsx', {
scriptType, scriptType,
scriptId: checkStore.scriptId, scriptId: checkStore.plan.scriptId,
devId: deviceId, devId: deviceId,
devNum: formContent.chnNum + '', devNum: formContent.chnNum + '',
code: parseInt(checkStore.planCode), code: parseInt(checkStore.plan.code),
index: parseInt(checkIndex.value), index: parseInt(checkIndex.value),
}, false, '.xlsx') }, false, '.xlsx')
} }

View File

@@ -0,0 +1,978 @@
<template>
<div class="dialog" v-bind="dialogBig">
<div class="dialog-content">
<div class="right-title">
<!-- <div>系数校准表</div> -->
<div>{{ outputDsc }}</div>
<div>
<span style=" font-size: 18px;font-weight: 600;">
设备已合格 <span style="color: #67C23A">{{ qualified }}</span> / <span style="color: green">{{ total }}</span>
</span>
<!-- <el-button type="primary" loading
v-if="activeIndex > 0 && activeIndex < activeTotalNum">通道系数已校准3台/共3台</el-button>
<el-button type="primary" :disabled="true" v-if="activeIndex === activeTotalNum">通道系数已校准3台/共3台</el-button> -->
</div>
</div>
<div class="container">
<div class="dialog-left">
<el-steps direction="vertical" :active="active" :process-status="currentStepStatus" finish-status="success">
<el-step title="开始"/>
<el-step>
<template #title>
<span>大电压/电流系数下装</span><br/>
<span class="spanStyle">源输出为</span><br/>
<span class="spanStyle" v-if="active > 0">{{ big_V_Download }}</span><br/>
<span class="spanStyle" v-if="active > 0">{{ big_I_Download }}</span>
<el-icon v-if="active === 1 " class="loading-box">
<el-icon-loading/>
</el-icon>
</template>
</el-step>
<el-step>
<template #title>
<span>小电压/电流系数下装</span><br/>
<span class="spanStyle">源输出为</span><br/>
<span class="spanStyle" v-if="active > 1">{{ small_V_Download }}</span><br/>
<span class="spanStyle" v-if="active > 1">{{ small_I_Download }}</span>
<el-icon v-if="active === 2" class="loading-box">
<el-icon-loading/>
</el-icon>
</template>
</el-step>
<el-step>
<template #title>
<span>大电压/电流校准</span><br/>
<span class="spanStyle">源输出为</span><br/>
<span class="spanStyle" v-if="active > 2">{{ big_V_Adjust }}</span><br/>
<span class="spanStyle" v-if="active > 2">{{ big_I_Adjust }}</span>
<el-icon v-if="active === 3" class="loading-box">
<el-icon-loading/>
</el-icon>
</template>
</el-step>
<el-step>
<template #title>
<span>小电压/电流校准</span><br/>
<span class="spanStyle">源输出为</span><br/>
<span class="spanStyle" v-if="active > 3">{{ small_V_Adjust }}</span><br/>
<span class="spanStyle" v-if="active > 3">{{ small_I_Adjust }}</span>
<el-icon v-if="active === 4" class="loading-box">
<el-icon-loading/>
</el-icon>
</template>
</el-step>
<el-step title="结束"/>
</el-steps>
</div>
<div class="right-content">
<el-tabs type="border-card" v-model="editableTabsValue" :active-index="String(activeIndex)">
<el-tab-pane v-for="(device, index) in name" :key="index" :label="device">
<template #label>
<span class="custom-tabs-label">
<span>{{ device }}</span>
<el-icon v-if="errorStates[index]" class="icon-style">
<Failed/>
</el-icon>
</span>
</template>
<channelsTestTable
:tableData="getTableDataForChannel(index)"
:big_V_loading="big_V_loadingStates"
:curV="CurV">
</channelsTestTable>
</el-tab-pane>
</el-tabs>
</div>
</div>
</div>
</div>
</template>
<script lang="tsx" setup name="FactorTest">
import {type Device} from '@/api/device/interface/device';
import {Failed} from '@element-plus/icons-vue'
import {type Ref, ref, toRef, watch} from 'vue'
import {dialogBig} from '@/utils/elementBind'
import {ElMessageBox} from 'element-plus';
import {getCoefficientCheck} from '@/api/home/channelsTest/index'
import type {ChannelsTest} from '@/api/home/interface/channelsTest';
import type {Plan} from '@/api/plan/interface';
import {useCheckStore} from "@/stores/modules/check";
const checkStore = useCheckStore()
const activeIndex = ref(0)
const activeTotalNum = ref(4)
const qualified = ref(0)
const outputDsc = ref('电压误差为±0.1Un% 电流误差为±0.5%')
const total = ref(0)
const dialogVisible = ref(false)
const active = ref(0)
let timer1: NodeJS.Timeout | null = null; // 声明并初始化 timer1
let timer2: NodeJS.Timeout | null = null; // 同样声明并初始化 timer2
const name = ref<string[]>([])//系数校准所选设备名字数组
const channel = ref<number[]>([])//系数校准所选设备通道数组
const devIdArray = ref<string[]>([])//系数校准所选设备ID数组
const select_Plan = ref<Plan.ReqPlan>()
const planId = ref('')
const isButtonDisabled = ref(false);
const CurV = ref<number>()//额定电压
// 在 setup 函数中
const errorStates = ref(new Array(name.value.length).fill(false));
//const loadingStates = ref(new Array(name.value.length).fill(false)); // 初始化 loading 状态
const big_V_loadingStates = ref(false); // 初始化 大电压大电流下装loading 状态
const small_V_loadingStates = ref(false); // 初始化 小电压小电流下装loading 状态
const big_V_loadingStates2 = ref(false); // 初始化 大电压大电流校准loading 状态
const small_V_loadingStates2 = ref(false); // 初始化 小电压小电流校准loading 状态
const editableTabsValue = ref('0')
const big_V_Download = ref('')
const big_I_Download = ref('')
const small_V_Download = ref('')
const small_I_Download = ref('')
const big_V_Adjust = ref('')
const big_I_Adjust = ref('')
const small_V_Adjust = ref('')
const small_I_Adjust = ref('')
const props = defineProps({
webMsgSend: {
type: Object,
default: () => ({})
}
})
const tableDataMap = new Map<number, Ref<ChannelsTest.CoefficientVO[]>>([]);
const currentStepStatus = ref<'error' | 'finish' | 'wait' | 'success' | 'process'>('finish');
const webMsgSend = toRef(props, 'webMsgSend');
onBeforeMount(() => {
// 初始化
initData()
})
const initData = () => {
checkStore.devices[0]
CurV.value = checkStore.devices[0]?.devVolt || 57.74;
isButtonDisabled.value = false; // 恢复按钮
select_Plan.value = plan
planId.value = checkStore.devices[0]?.planId || '';
devIdArray.value = checkStore.devices.map(item => item.deviceId);
name.value = checkStore.devices.map(item => item.deviceName)
channel.value = checkStore.devices.map(item => item.chnNum)
dialogVisible.value = true;
total.value = name.value.length
// 初始化 loadingStates 为 false
// loadingStates.value = new Array(selection.length).fill(false);
errorStates.value = new Array(selection.length).fill(false);
for (let i = 0; i < channel.value.length; i++) {
const currentTableData = initializeTableData(dataTemplates, i);
tableDataMap.set(i, currentTableData)
}
//console.log('tableDataMap',tableDataMap);
}
watch(webMsgSend, function (newValue, oldValue) {
if (newValue.code == 10520) {
ElMessageBox.alert('报文解析异常!', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10521) {
ElMessageBox.alert('程控源參数有误!', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10522) {
ElMessageBox.alert('测试项解析有误!', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10523) {
ElMessageBox.alert('源连接失败!', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10524) {
ElMessageBox.alert('获取源控制权失败!', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10525) {
ElMessageBox.alert('重置源失败!', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10527) {
ElMessageBox.alert('源未进行初始化!', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10528) {
ElMessageBox.alert('目标源有误(该用户已控制其他源,在关闭前无法操作新的源)', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10529) {
ElMessageBox.alert('源状态有误,无法响应报文(例如源处于输出状态,无法响应初始化报文)', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10550) {
ElMessageBox.alert(`${newValue.data}设备连接异常!`, '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10551) {
ElMessageBox.alert(`${newValue.data}设备触发报告异常!`, '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10552) { //todo 10552之后还会发送消息吗
ElMessageBox.alert('存在已经初始化步骤,执行自动关闭,请重新发起检测', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else {
switch (newValue.requestId) {
case 'yjc_ytxjy':
switch (newValue.operateCode) {
case'INIT_GATHER':
if (newValue.code == -1) {
ElMessageBox.alert('源未知异常', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10523) {
ElMessageBox.alert('源连接失败', '源连接失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
}
}
break;
case 'YJC_xujy':
switch (newValue.operateCode) {
case 'OPER_GATHER':
if (newValue.code == 10552) {
ElMessageBox.alert('存在已经初始化步骤,执行自动关闭,请重新发起检测', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10520) {
ElMessageBox.alert('解析报文异常,执行自动关闭,请重新发起检测', '解析报文异常', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
}
break;
case 'DATA_REQUEST$02':
if (newValue.code == 25003) {
ElMessageBox.alert('相序校验未通过,执行自动关闭,请重新发起检测', '相序校验未通过', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
}
break;
}
break;
case 'yjc_sbtxjy':
switch (newValue.operateCode) {
case 'INIT_GATHER$01':
if (newValue.code == 10550) {
ElMessageBox.alert('设备连接异常', '设备连接异常', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10551) {
ElMessageBox.alert('设备触发报告异常', '设备触发报告异常', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10552) {
ElMessageBox.alert('存在已经初始化步骤,执行自动关闭,请重新发起检测', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10520) {
ElMessageBox.alert('解析报文异常,执行自动关闭,请重新发起检测', '解析报文异常', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
}
break;
}
break;
case 'Coefficient_Check':
console.log("Coefficient_Checkactive", active.value);
switch (newValue.operateCode) {
case 'big_end'://大电压,电流下装
active.value++;
big_V_Download.value = 'Ua=Ub=Uc=' + newValue.data.devVolt + 'V';
big_I_Download.value = 'Ia=Ib=Ic=' + newValue.data.devCurr + 'A';
tableLoading('small', '系数下装')
break;
}
switch (newValue.operateCode) {
case 'small_end'://小电压,电流下装
active.value++;
small_V_Download.value = 'Ua=Ub=Uc=' + newValue.data.devVolt + 'V';
small_I_Download.value = 'Ia=Ib=Ic=' + newValue.data.devCurr + 'A';
tableLoading('big', '系数校准')
break;
}
switch (newValue.operateCode) {
case 'big_comp_end'://大电压,电流校准
active.value++;
big_V_Adjust.value = 'Ua=Ub=Uc=' + newValue.data.devVolt + 'V';
big_I_Adjust.value = 'Ia=Ib=Ic=' + newValue.data.devCurr + 'A';
tableLoading('small', '系数校准')
break;
}
switch (newValue.operateCode) {
case 'small_comp_end'://小电压,电流校准
active.value++;
small_V_Adjust.value = 'Ua=Ub=Uc=' + newValue.data.devVolt + 'V';
small_I_Adjust.value = 'Ia=Ib=Ic=' + newValue.data.devCurr + 'A';
active.value++;
for (let i = 0; i < name.value.length; i++) {
const currentDataRef = tableDataMap.get(i);
if (currentDataRef) {
const currentData = currentDataRef.value;
// 检查当前数据中有无不合格字段
const hasError = checkForErrors(currentData);
if (hasError) {
} else {
qualified.value++;
}
updateErrorState(i, hasError);
}
}
//editableTabsValue.value = (tabNumber.value).toString();//显示下一个tab
isButtonDisabled.value = false; // 恢复按钮
break;
}
switch (newValue.operateCode) {
case 'DATA_CHNFACTOR$02'://表格
// 输出 key 为 0 的数组中的第一条 ChannelsTest.CoefficientVO 对象
for (let i = 0; i < name.value.length; i++) {
const targetArrayRef = tableDataMap.get(i);
if (targetArrayRef) {
const targetArray = targetArrayRef.value;
if (targetArray.length > 0) {
const firstCoefficientVO = targetArray.find(item => item.monitorNum === newValue.data.monitorNum &&
item.type === newValue.data.type &&
item.desc === newValue.data.desc &&
item.devName === newValue.data.devName);
if (firstCoefficientVO) { // 检查 firstCoefficientVO 是否存在
firstCoefficientVO.aVuData = parseFloat(newValue.data.aVuData).toFixed(4);
if (!isNaN(parseFloat(newValue.data.aVuXi)) && isFinite(newValue.data.aVuXi)) {
firstCoefficientVO.aVuXi = (parseFloat(newValue.data.aVuXi) / 10000).toFixed(4);
} else {
firstCoefficientVO.aVuXi = newValue.data.aVuXi;
}
firstCoefficientVO.bVuData = parseFloat(newValue.data.bVuData).toFixed(4);
if (!isNaN(parseFloat(newValue.data.bVuXi)) && isFinite(newValue.data.bVuXi)) {
firstCoefficientVO.bVuXi = (parseFloat(newValue.data.bVuXi) / 10000).toFixed(4);
} else {
firstCoefficientVO.bVuXi = newValue.data.bVuXi;
}
firstCoefficientVO.cVuData = parseFloat(newValue.data.cVuData).toFixed(4);
if (!isNaN(parseFloat(newValue.data.cVuXi)) && isFinite(newValue.data.cVuXi)) {
firstCoefficientVO.cVuXi = (parseFloat(newValue.data.cVuXi) / 10000).toFixed(4);
} else {
firstCoefficientVO.cVuXi = newValue.data.cVuXi;
}
firstCoefficientVO.aIeData = parseFloat(newValue.data.aIeData).toFixed(4);
if (!isNaN(parseFloat(newValue.data.aIeXi)) && isFinite(newValue.data.aIeXi)) {
firstCoefficientVO.aIeXi = (parseFloat(newValue.data.aIeXi) / 10000).toFixed(4);
} else {
firstCoefficientVO.aIeXi = newValue.data.aIeXi;
}
firstCoefficientVO.bIeData = parseFloat(newValue.data.bIeData).toFixed(4);
if (!isNaN(parseFloat(newValue.data.bIeXi)) && isFinite(newValue.data.bIeXi)) {
firstCoefficientVO.bIeXi = (parseFloat(newValue.data.bIeXi) / 10000).toFixed(4);
} else {
firstCoefficientVO.bIeXi = newValue.data.bIeXi;
}
firstCoefficientVO.cIeData = parseFloat(newValue.data.cIeData).toFixed(4);
if (!isNaN(parseFloat(newValue.data.cIeXi)) && isFinite(newValue.data.cIeXi)) {
firstCoefficientVO.cIeXi = (parseFloat(newValue.data.cIeXi) / 10000).toFixed(4);
} else {
firstCoefficientVO.cIeXi = newValue.data.cIeXi;
}
firstCoefficientVO.aV = newValue.data.aV;
firstCoefficientVO.bV = newValue.data.bV;
firstCoefficientVO.cV = newValue.data.cV;
firstCoefficientVO.aI = newValue.data.aI;
firstCoefficientVO.bI = newValue.data.bI;
firstCoefficientVO.cI = newValue.data.cI;
//console.log(newValue.data.devName + '对象:', firstCoefficientVO);
activeIndex.value++;
} else {
//console.log('未找到匹配的'+ newValue.data.devName+'对象');
}
} else {
//console.log(newValue.data.devName + '数组为空');
}
} else {
//console.log('未找到'+newValue.data.devName+'对应的数组');
}
}
break;
}
break;
case 'socket_timeout':
switch (newValue.operateCode) {
case 'VOLTAGE':
ElMessageBox.alert('连接超时!', '连接超时', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
break;
}
break;
case 'connect':
switch (newValue.operateCode) {
case "Source":
ElMessageBox.alert('源服务端连接失败', '源服务端连接失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
break;
case "Dev":
ElMessageBox.alert('设备服务端连接失败', '设备服务端连接失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
break;
}
break;
}
}
})
//出错系数检测初始化
const TableInit = () => {
console.log("TableInitactive", active.value);
isButtonDisabled.value = false; // 恢复按钮
for (let i = 0; i < channel.value.length; i++) {
const currentTableData = initializeTableData(dataTemplates, i);
tableDataMap.set(i, currentTableData)
// const targetArrayRef = tableDataMap.get(i);
// if (targetArrayRef) {
// const targetArray = targetArrayRef.value;
// if (targetArray.length > 0) {
// targetArray.forEach(item => item.loading =false)
// }
// }
}
activeIndex.value = 0
qualified.value = 0
active.value = 0
}
//按行图标转动
const tableLoading = (type: string, desc: string) => {
for (let i = 0; i < channel.value.length; i++) {
const targetArrayRef = tableDataMap.get(i);
if (targetArrayRef) {
const targetArray = targetArrayRef.value;
if (targetArray.length > 0) {
for (let j = 0; j < channel.value[i]; j++) {
const firstCoefficientVO = targetArray.find(item => item.monitorNum === (j + 1).toString() &&
item.type === type &&
item.desc === desc);
if (firstCoefficientVO) {
firstCoefficientVO.loading = true;
}
}
}
}
}
}
const dataTemplates: ChannelsTest.CoefficientVO[] = [
{
monitorNum: '1',
desc: '系数下装',
type: 'big',
aVuData: '—',
aVuXi: '—',
bVuData: '—',
bVuXi: '—',
cVuData: '—',
cVuXi: '—',
aIeData: '—',
aIeXi: '—',
bIeData: '—',
bIeXi: '—',
cIeData: '—',
cIeXi: '—',
loading: false,
devName: '',
aV: '—',
bV: '—',
cV: '—',
aI: '—',
bI: '—',
cI: '—',
},
{
monitorNum: '2',
desc: '系数下装',
type: 'small',
aVuData: '—',
aVuXi: '—',
bVuData: '—',
bVuXi: '—',
cVuData: '—',
cVuXi: '—',
aIeData: '—',
aIeXi: '—',
bIeData: '—',
bIeXi: '—',
cIeData: '—',
cIeXi: '—',
loading: false,
devName: '',
aV: '—',
bV: '—',
cV: '—',
aI: '—',
bI: '—',
cI: '—',
},
{
monitorNum: '3',
desc: '系数校准',
type: 'big',
aVuData: '—',
aVuXi: '—',
bVuData: '—',
bVuXi: '—',
cVuData: '—',
cVuXi: '—',
aIeData: '—',
aIeXi: '—',
bIeData: '—',
bIeXi: '—',
cIeData: '—',
cIeXi: '—',
loading: false,
devName: '',
aV: '—',
bV: '—',
cV: '—',
aI: '—',
bI: '—',
cI: '—',
},
{
monitorNum: '4',
desc: '系数校准',
type: 'small',
aVuData: '—',
aVuXi: '—',
bVuData: '—',
bVuXi: '—',
cVuData: '—',
cVuXi: '—',
aIeData: '—',
aIeXi: '—',
bIeData: '—',
bIeXi: '—',
cIeData: '—',
cIeXi: '—',
loading: false,
devName: '',
aV: '—',
bV: '—',
cV: '—',
aI: '—',
bI: '—',
cI: '—',
},
];
const dataTemplates2: ChannelsTest.CoefficientVO[] = [
{
monitorNum: '1',
desc: '系数下装',
type: 'big',
aVuData: '—',
aVuXi: '—',
bVuData: '—',
bVuXi: '—',
cVuData: '—',
cVuXi: '—',
aIeData: '—',
aIeXi: '—',
bIeData: '—',
bIeXi: '—',
cIeData: '—',
cIeXi: '—',
loading: false,
devName: ''
},
{
monitorNum: '2',
desc: '系数下装',
type: 'small',
aVuData: '—',
aVuXi: '—',
bVuData: '—',
bVuXi: '—',
cVuData: '—',
cVuXi: '—',
aIeData: '—',
aIeXi: '—',
bIeData: '—',
bIeXi: '—',
cIeData: '—',
cIeXi: '—',
loading: false,
devName: ''
},
{
monitorNum: '3',
desc: '系数校准',
type: 'big',
aVuData: '—',
aVuXi: '不合格',
bVuData: '—',
bVuXi: '—',
cVuData: '—',
cVuXi: '—',
aIeData: '—',
aIeXi: '—',
bIeData: '—',
bIeXi: '—',
cIeData: '—',
cIeXi: '—',
loading: false,
devName: ''
},
{
monitorNum: '4',
desc: '系数校准',
type: 'small',
aVuData: '—',
aVuXi: '—',
bVuData: '—',
bVuXi: '—',
cVuData: '—',
cVuXi: '—',
aIeData: '—',
aIeXi: '—',
bIeData: '—',
bIeXi: '—',
cIeData: '—',
cIeXi: '—',
loading: false,
devName: ''
},
];
// 更新错误状态的方法
const updateErrorState = (index: number, hasError: boolean) => {
errorStates.value[index] = hasError;
};
// 打开弹窗,可能是新增,也可能是编辑
const open = (selection: Device.ResPqDev[], plan: Plan.ReqPlan) => {
CurV.value = selection[0]?.devVolt || 57.74;
isButtonDisabled.value = false; // 恢复按钮
select_Plan.value = plan
planId.value = selection[0]?.planId || '';
devIdArray.value = selection.map(item => item.id);
name.value = selection.map(item => item.name)
channel.value = selection.map(item => item.devChns)
dialogVisible.value = true;
total.value = name.value.length
// 初始化 loadingStates 为 false
// loadingStates.value = new Array(selection.length).fill(false);
errorStates.value = new Array(selection.length).fill(false);
for (let i = 0; i < channel.value.length; i++) {
const currentTableData = initializeTableData(dataTemplates, i);
tableDataMap.set(i, currentTableData)
}
//console.log('tableDataMap',tableDataMap);
}
const emit = defineEmits<{
(e: 'quitClicked'): void;
(e: 'submitClicked', callback: (resolve: (value: boolean) => void) => void): void;
}>();
const handleCancel = () => {
// 清空 name, channel, total
name.value = [];
channel.value = [];
total.value = 0;
activeIndex.value = 0
qualified.value = 0
active.value = 0
dialogVisible.value = false
editableTabsValue.value = '0'
emit('quitClicked'); // 触发事件
}
const getTableDataForChannel = (index: number): any[] => {
const data = tableDataMap.get(index);
return data ? data.value : [];
}
watch(activeIndex, function (newValue, oldValue) {
if (activeIndex.value === 1) {
outputDsc.value = "电压误差为±0.1Un% 电流误差为±0.5%";
// 当前源输出为Ua=Ub=Uc=57.74V Ia=Ib=Ic=1A"
}
})
// 示例的 checkForErrors 函数,根据实际需求进行调整
const checkForErrors = (data: ChannelsTest.CoefficientVO[]): boolean => {
// 这里假设不合格字段的标准是 status 为 '不合格' 或 isValid 为 false
return data.some(item =>
item.aVuXi === '不合格' ||
item.bVuXi === '不合格' ||
item.cVuXi === '不合格' ||
item.aIeXi === '不合格' ||
item.bIeXi === '不合格' ||
item.cIeXi === '不合格'
);
};
const handleSubmit = async () => {
// 创建一个 Promise 来等待父组件的回调
const response = await new Promise<boolean>((resolve) => {
emit('submitClicked', resolve);
});
if (!response) {
return;
}
isButtonDisabled.value = true; // 禁用按钮
tableLoading('big', '系数下装')
await getCoefficientCheck({
userPageId: "cdf",
devIds: devIdArray.value,
planId: planId.value,
errorSysId: select_Plan.value?.errorSysId,
scriptId: select_Plan.value?.scriptId,
operateType: '0' // '0'为预检测、1为正式检测
})
active.value++;
// 初始化 loadingStates 为 true
// loadingStates.value = new Array(name.value.length).fill(true);
return;
// 初始化 currentTableData
let isTimer2Completed = false;
//"80b4b4f52a4c4064a18319525f8ac13c",
for (let i = 0; i < channel.value.length; i++) {
// 重置状态变量
active.value = 0;
//activeIndex.value = 0;
editableTabsValue.value = i.toString();
// 初始化并填充 currentTableData
const currentTableData = initializeTableData(dataTemplates2, i);
tableDataMap.set(i, currentTableData);
//activeIndex.value++;
// 清除之前的 timer1
clearInterval(timer1);
// 启动 timer1
timer1 = setInterval(() => {
active.value++;
if (active.value > 5) {
clearInterval(timer1);
}
}, 3000);
// 清除之前的 timer2
clearInterval(timer2);
// 启动 timer2
timer2 = setInterval(() => {
// 初始化并填充 currentTableData
const currentTableData = initializeTableData(i > 0 ? dataTemplates2 : dataTemplates2, i);
tableDataMap.set(i, currentTableData);
activeIndex.value++;
clearInterval(timer2);
const currentDataRef = tableDataMap.get(i);
if (currentDataRef) {
const currentData = currentDataRef.value;
// 检查当前数据中有无不合格字段
const hasError = checkForErrors(currentData);
if (hasError) {
} else {
qualified.value++;
}
updateErrorState(i, hasError);
}
// 设置标志变量为 true表示 timer2 已经完成
isTimer2Completed = true;
}, 3000);
// 等待 timer2 完成
while (!isTimer2Completed) {
// 这里可以添加一个短暂的等待,避免死循环
await new Promise(resolve => setTimeout(resolve, 100));
}
// 重置标志变量
isTimer2Completed = false;
}
};
// 提取初始化并填充 currentTableData 的函数
const initializeTableData = (templates: ChannelsTest.CoefficientVO[], index: number): Ref<ChannelsTest.CoefficientVO[]> => {
const currentTableData = ref<ChannelsTest.CoefficientVO[]>([]);
for (let j = 0; j < channel.value[index]; j++) {
templates.forEach((template) => {
// 使用解构赋值排除 id 和 MonitorIdx 属性
const {devName, monitorNum: __, ...rest} = template;
currentTableData.value.push({
monitorNum: (j + 1).toString(),
devName: name.value[index],
...rest,
});
});
}
return currentTableData;
};
// 对外映射
defineExpose({open})
</script>
<style scoped lang="scss">
/* 确保 el-icon-loading 的动画效果没有被覆盖 */
.loading-box {
animation: rotate 2s linear infinite;
font-size: 30px; /* 增大图标的大小 */
}
@keyframes rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.right-title {
display: flex;
flex-direction: row;
/* 横向排列 */
justify-content: space-between;
margin-bottom: 10px;
}
.custom-tabs-label .el-icon {
vertical-align: middle;
}
.custom-tabs-label span {
vertical-align: middle;
margin-left: 4px;
}
.dialog-content {
height: 510px;
}
.el-tabs--border-card {
height: 470px;
}
/* .el-icon svg {
color: #ff7171;
} */
.icon-style {
color: #ff7171;
}
.container {
display: flex;
}
.dialog-left {
flex: 1;
}
.right-content {
flex: 6;
}
.spanStyle {
font-size: 14px;
}
</style>

View File

@@ -0,0 +1,85 @@
<template>
<el-dialog title="选择测试内容" v-model='dialogVisible' @close="handleClose" v-bind="dialogSmall">
<div>
<el-form ref="dialogFormRef" :model="formContent">
<el-form-item prop="preTest" :label-width="50">
<el-checkbox v-model="formContent.preTest" label="预检测"/>
</el-form-item>
<el-form-item v-if="checkStore.plan.timeCheck===1" prop="timeTest" :label-width="50">
<el-checkbox v-model="formContent.timeTest" label="守时检测"/>
</el-form-item>
<el-form-item prop="channelsTest" :label-width="50">
<el-checkbox v-model="formContent.channelsTest" label="系数校准"/>
</el-form-item>
<el-form-item prop="test" :label-width="50">
<el-checkbox v-model="formContent.test" label="正式检测"/>
</el-form-item>
</el-form>
</div>
<template #footer>
<span class="dialog-footer">
<el-button @click="handleClose">取消</el-button>
<el-button type="primary" @click="handleStart">开始测试</el-button>
</span>
</template>
</el-dialog>
</template>
<script setup lang='tsx' name='selectTestItemPopup'>
import {dialogSmall} from "@/utils/elementBind";
import {ref} from "vue";
import {useCheckStore} from "@/stores/modules/check";
import type {CheckData} from "@/api/check/interface";
const emit = defineEmits(['openTestDialog'])
const checkStore = useCheckStore();
const dialogFormRef = ref()
const dialogVisible = ref(false)
const formContent = reactive<CheckData.SelectTestItem>({preTest: true, timeTest: false, channelsTest: false, test: false})
const open = async () => {
resetFormContent()
checkStore.setSelectTestItems(formContent)
dialogVisible.value = true
}
// 清空表单内容
const resetFormContent = () => {
Object.assign(formContent, {preTest: true, channelsTest: false, timeTest: false, test: false})
}
const handleStart = () => {
let count = 0
for (let key in formContent) {
if (formContent[key]) {
count++
}
}
if (count === 0) {
ElMessage.warning('请选择测试内容!')
} else {
checkStore.setSelectTestItems({...formContent})
handleClose()
emit('openTestDialog')
}
}
// 关闭弹窗
const handleClose = () => {
dialogVisible.value = false
// 清空dialogForm中的值
resetFormContent()
dialogFormRef.value?.resetFields()
}
defineExpose({open})
</script>
<style scoped lang="scss">
</style>

View File

@@ -2,16 +2,16 @@
<div class='table_info'> <div class='table_info'>
<!-- :request-api="getTableList" --> <!-- :request-api="getTableList" -->
<ProTable <ProTable
ref='proTable' ref='proTable'
:columns='columns' :columns='columns'
@drag-sort='sortTable' @drag-sort='sortTable'
:default-sort="{ prop: 'check_State', order: 'ascending' }" :default-sort="{ prop: 'check_State', order: 'ascending' }"
:stripe='true' :stripe='true'
:pagination='false' :pagination='false'
:key='tableKey' :key='tableKey'
@selection-change='handleSelectionChange' @selection-change='handleSelectionChange'
:request-api='getTableList' :request-api='getTableList'
:toolButton='false' :toolButton='false'
> >
<!-- :height="tableHeight" --> <!-- :height="tableHeight" -->
<!-- 表格 header 按钮 --> <!-- 表格 header 按钮 -->
@@ -23,35 +23,35 @@
<el-form-item label='检测状态' v-if='form.activeTabs != 3 && form.activeTabs != 4 && form.activeTabs != 5'> <el-form-item label='检测状态' v-if='form.activeTabs != 3 && form.activeTabs != 4 && form.activeTabs != 5'>
<el-select v-model='form.checkStatus' clearable> <el-select v-model='form.checkStatus' clearable>
<el-option <el-option
v-for='(item, index) in checkStatus' v-for='(item, index) in checkStatus'
:label='item.label' :label='item.label'
:value='item.id' :value='item.id'
:key='index' :key='index'
v-show='shouldShowOption(item)' v-show='shouldShowOption(item)'
></el-option> ></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label='检测结果'> <el-form-item label='检测结果'>
<el-select v-model='form.checkResult' clearable> <el-select v-model='form.checkResult' clearable>
<el-option <el-option
v-for='(item, index) in checkResult' v-for='(item, index) in checkResult'
:label='item.label' :label='item.label'
:value='item.id' :value='item.id'
:key='index' :key='index'
v-show='shouldShowOption(item)' v-show='shouldShowOption(item)'
></el-option> ></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label='报告状态'> <el-form-item label='报告状态'>
<el-select v-model='form.checkReportStatus' clearable> <el-select v-model='form.checkReportStatus' clearable>
<el-option <el-option
v-for='(item, index) in checkReportStatus' v-for='(item, index) in checkReportStatus'
:label='item.label' :label='item.label'
:value='item.id' :value='item.id'
:key='index' :key='index'
v-show='shouldShowOption(item)' v-show='shouldShowOption(item)'
></el-option> ></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
@@ -61,36 +61,29 @@
</el-button </el-button
> >
<el-button :icon="Delete" @click="handleRefresh" <el-button :icon="Delete" @click="handleRefresh"
>重置</el-button >重置
</el-button
> >
<!-- :disabled='!scope.isSelected' --> <!-- :disabled='!scope.isSelected' -->
<el-button <el-button
type='primary' type='primary'
:icon='Clock' :icon='Clock'
@click="handleTest('手动检测')" @click="handleTest('手动检测')"
v-if='form.activeTabs === 0' v-if='form.activeTabs === 0'
>手动检测 >手动检测
</el-button </el-button
> >
<!-- :disabled='!scope.isSelected' --> <!-- :disabled='!scope.isSelected' -->
<el-button <el-button
type='primary' type='primary'
:icon='ChatLineRound' :icon='ChatLineRound'
@click="handleTest('自动检测')" @click="handleTest('一键检测')"
v-if='form.activeTabs === 0' v-if='form.activeTabs === 0'
>自动检测 >一键检测
</el-button </el-button>
> <!-- <el-button type='primary' :icon='ChatLineSquare' @click="handleTest('不合格项复检')" v-if='form.activeTabs === 2'>不合格项复检</el-button>-->
<el-button type='primary' :icon='ChatLineSquare' @click="handleTest('不合格项复检')" <!-- <el-button type='primary' :icon='ChatDotSquare' @click="handleTest('全部复检')" v-if='form.activeTabs === 2'>全部复检</el-button>-->
v-if='form.activeTabs === 2'
>不合格项复检
</el-button
>
<el-button type='primary' :icon='ChatDotSquare' @click="handleTest('全部复检')" v-if='form.activeTabs === 2'
>全部复检
</el-button
>
<!-- :disabled='!scope.isSelected' --> <!-- :disabled='!scope.isSelected' -->
<!-- <el-button type="primary" :icon="Download" @click="handleTest('批量下载')" v-if="form.activeTabs === 3" <!-- <el-button type="primary" :icon="Download" @click="handleTest('批量下载')" v-if="form.activeTabs === 3"
@@ -102,9 +95,7 @@
> --> > -->
<!-- :disabled="!scope.isSelected || scope.selectedList.filter((item) => item.check_State === '检测完成').length === 0" --> <!-- :disabled="!scope.isSelected || scope.selectedList.filter((item) => item.check_State === '检测完成').length === 0" -->
<el-button type='primary' :icon='Notebook' @click="handleTest('批量归档')" v-if='form.activeTabs === 4' <el-button type='primary' :icon='Notebook' @click="handleTest('批量归档')" v-if='form.activeTabs === 4'>归档</el-button>
>归档
</el-button>
<!-- <el-button type="primary" :icon="CirclePlus" @click="addDevice('设备新增')" v-if="form.activeTabs === 0" <!-- <el-button type="primary" :icon="CirclePlus" @click="addDevice('设备新增')" v-if="form.activeTabs === 0"
>设备新增</el-button> --> >设备新增</el-button> -->
@@ -118,11 +109,11 @@
<!-- 表格操作 --> <!-- 表格操作 -->
<template #operation='scope'> <template #operation='scope'>
<el-button <el-button
type='primary' type='primary'
link link
:icon='View' :icon='View'
@click="openDrawer('查看', scope.row)" @click="openDrawer('查看', scope.row)"
v-if='form.activeTabs === 3 && form.activeChildTabs === 1' v-if='form.activeTabs === 3 && form.activeChildTabs === 1'
>查看 >查看
</el-button> </el-button>
@@ -142,21 +133,21 @@
</el-dropdown> </el-dropdown>
</div> --> </div> -->
<el-button <el-button
type='primary' type='primary'
link link
:icon='Download' :icon='Download'
@click="openDrawer('报告下载', scope.row)" @click="openDrawer('报告下载', scope.row)"
v-if='form.activeTabs === 3 && form.activeChildTabs === 0 && scope.row.reportState === 1' v-if='form.activeTabs === 3 && form.activeChildTabs === 0 && scope.row.reportState === 1'
>报告下载 >报告下载
</el-button> </el-button>
<el-button <el-button
type='primary' type='primary'
link link
:icon='Postcard' :icon='Postcard'
@click="openDrawer('报告生成', scope.row)" @click="openDrawer('报告生成', scope.row)"
v-if='form.activeTabs === 3 ' v-if='form.activeTabs === 3 '
>报告生成 >报告生成
</el-button> </el-button>
<!-- <el-button <!-- <el-button
@@ -177,20 +168,20 @@
</el-button> </el-button>
<el-button <el-button
type='primary' type='primary'
link link
:icon='PieChart' :icon='PieChart'
@click="openDrawer('检测数据查询', scope.row)" @click="openDrawer('检测数据查询', scope.row)"
v-if='form.activeTabs === 5' v-if='form.activeTabs === 5'
>检测数据查询 >检测数据查询
</el-button> </el-button>
<el-button <el-button
type='primary' type='primary'
link link
:icon='Switch' :icon='Switch'
@click="openDrawer('误差体系更换', scope.row)" @click="openDrawer('误差体系更换', scope.row)"
v-if='form.activeTabs === 5' v-if='form.activeTabs === 5'
>误差体系更换 >误差体系更换
</el-button> </el-button>
@@ -225,37 +216,39 @@
:dialogTitle="dialogTitle" :dialogTitle="dialogTitle"
@update:visible="dialogFormVisible = $event" @update:visible="dialogFormVisible = $event"
/> --> /> -->
<TestPopup ref='testPopup' @quitClicked='handleQuitClicked' ></TestPopup> <TestPopup ref='testPopup' @quitClicked='handleQuitClicked'></TestPopup>
<reportPopup <reportPopup
:visible='reportDialogVisible' :visible='reportDialogVisible'
@update:visible='reportDialogVisible = $event' @update:visible='reportDialogVisible = $event'
></reportPopup> ></reportPopup>
<dataCheckPopup ref='dataCheckPopupRef' /> <dataCheckPopup ref='dataCheckPopupRef'/>
<dataCheckChangeErrSysPopup <dataCheckChangeErrSysPopup
:visible='dataCheckChangeErrSysDialogVisible' :visible='dataCheckChangeErrSysDialogVisible'
@update:visible='dataCheckChangeErrSysDialogVisible = $event' @update:visible='dataCheckChangeErrSysDialogVisible = $event'
></dataCheckChangeErrSysPopup> ></dataCheckChangeErrSysPopup>
<matchPopup <matchPopup
:visible='matchDialogVisible' :visible='matchDialogVisible'
@update:visible='matchDialogVisible = $event' @update:visible='matchDialogVisible = $event'
></matchPopup> ></matchPopup>
<!--系数校准--> <!--系数校准-->
<ChannelsTest ref='channelsTest' :webMsgSend='webMsgSend' @quitClicked='handleQuitClicked' @submitClicked = 'handleSubmitClicked'></ChannelsTest> <ChannelsTest ref='channelsTest' :webMsgSend='webMsgSend' @quitClicked='handleQuitClicked' @submitClicked='handleSubmitClicked'></ChannelsTest>
<!-- 手动检测-勾选检测项弹窗 -->
<SelectTestItemPopup ref="selectTestItemPopupRef" @openTestDialog="openTestDialog"></SelectTestItemPopup>
</div> </div>
</template> </template>
<script setup lang='tsx' name='useProTable'> <script setup lang='tsx' name='useProTable'>
import { useRouter } from 'vue-router' import {useRouter} from 'vue-router'
import type { Device } from '@/api/device/interface/device' import type {Device} from '@/api/device/interface/device'
import { useHandleData } from '@/hooks/useHandleData' import {useHandleData} from '@/hooks/useHandleData'
import { ElMessage, ElMessageBox, ElLoading, Action } from 'element-plus' import {ElMessage, ElMessageBox, ElLoading, Action} from 'element-plus'
import ProTable from '@/components/ProTable/index.vue' import ProTable from '@/components/ProTable/index.vue'
import { type ProTableInstance, type ColumnProps } from '@/components/ProTable/interface' import {type ProTableInstance, type ColumnProps} from '@/components/ProTable/interface'
import { import {
Search, Search,
View, View,
@@ -273,27 +266,28 @@ import {
CirclePlus, CirclePlus,
Odometer, Odometer,
} from '@element-plus/icons-vue' } from '@element-plus/icons-vue'
import { getPlanList } from '@/api/plan/planList' import {getPlanList} from '@/api/plan/planList'
import deviceDataList from '@/api/device/device/deviceData' import deviceDataList from '@/api/device/device/deviceData'
import TestPopup from './testPopup.vue' import TestPopup from './testPopup.vue'
import reportPopup from './reportPopup.vue' import reportPopup from './reportPopup.vue'
import dataCheckPopup from './dataCheckSingleChannelSingleTestPopup.vue' import dataCheckPopup from './dataCheckSingleChannelSingleTestPopup.vue'
import dataCheckChangeErrSysPopup from './dataCheckChangeErrSysPopup.vue' import dataCheckChangeErrSysPopup from './dataCheckChangeErrSysPopup.vue'
import { generateDevReport, getBoundPqDevList } from '@/api/plan/plan.ts' import {generateDevReport, getBoundPqDevList} from '@/api/plan/plan.ts'
import { onBeforeMount, onMounted, reactive, ref, watch } from 'vue' import {onBeforeMount, onMounted, reactive, ref, watch} from 'vue'
import { useDictStore } from '@/stores/modules/dict' import {useDictStore} from '@/stores/modules/dict'
import ChannelsTest from './channelsTest.vue' import ChannelsTest from './channelsTest.vue'
import { useModeStore } from '@/stores/modules/mode' // 引入模式 store import {useModeStore} from '@/stores/modules/mode' // 引入模式 store
import { useCheckStore } from '@/stores/modules/check' import {useCheckStore} from '@/stores/modules/check'
import { CheckData } from '@/api/check/interface' import {CheckData} from '@/api/check/interface'
import socketClient from '@/utils/webSocketClient' import socketClient from '@/utils/webSocketClient'
import auth from '@/directives/modules/auth' import auth from '@/directives/modules/auth'
import { useAuthStore } from '@/stores/modules/auth' import {useAuthStore} from '@/stores/modules/auth'
import { useDownload } from '@/hooks/useDownload' import {useDownload} from '@/hooks/useDownload'
import { downloadDevData } from '@/api/plan/plan.ts' import {downloadDevData} from '@/api/plan/plan.ts'
import { documentedPqDev } from '@/api/device/device' import {documentedPqDev} from '@/api/device/device'
import { getPqDev } from '@/api/device/device/index.ts' import {getPqDev} from '@/api/device/device/index.ts'
import { ResultEnum } from '@/enums/httpEnum' import {ResultEnum} from '@/enums/httpEnum'
import SelectTestItemPopup from "@/views/home/components/selectTestItemPopup.vue";
const dictStore = useDictStore() const dictStore = useDictStore()
const checkStore = useCheckStore() const checkStore = useCheckStore()
@@ -309,6 +303,7 @@ const tableHeight = ref(0)
const reportDialogVisible = ref(false) const reportDialogVisible = ref(false)
const dataCheckPopupRef = ref<InstanceType<typeof dataCheckPopup>>() const dataCheckPopupRef = ref<InstanceType<typeof dataCheckPopup>>()
const selectTestItemPopupRef = ref<InstanceType<typeof SelectTestItemPopup>>()
const dataCheckChangeErrSysDialogVisible = ref(false) const dataCheckChangeErrSysDialogVisible = ref(false)
const matchDialogVisible = ref(false) const matchDialogVisible = ref(false)
@@ -337,8 +332,8 @@ const shouldShowOption = (item) => {
//开始创建webSocket客户端 //开始创建webSocket客户端
const dataSocket = reactive({ const dataSocket = reactive({
socketServe: socketClient.Instance, socketServe: socketClient.Instance,
}); });
tableHeight.value = window.innerHeight - 600 tableHeight.value = window.innerHeight - 600
const deviceData = ref<Device.ResPqDev[]>([]) const deviceData = ref<Device.ResPqDev[]>([])
@@ -513,7 +508,7 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
return true return true
}, },
}, },
{ type: 'index', fixed: 'left', width: 70, label: '序号' }, {type: 'index', fixed: 'left', width: 70, label: '序号'},
{ {
prop: 'name', prop: 'name',
label: '设备名称', label: '设备名称',
@@ -556,7 +551,7 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
isShow: checkStateShow, isShow: checkStateShow,
render: scope => { render: scope => {
return ( return (
scope.row.checkState === 0 ? '未检' : scope.row.checkState === 1 ? '检测中' : '检测完成' scope.row.checkState === 0 ? '未检' : scope.row.checkState === 1 ? '检测中' : '检测完成'
) )
}, },
}, },
@@ -609,12 +604,12 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
return '' return ''
}, },
}, },
{ prop: 'operation', label: '操作', fixed: 'right', minWidth: 200, isShow: operationShow }, {prop: 'operation', label: '操作', fixed: 'right', minWidth: 200, isShow: operationShow},
]) ])
// 跳转详情页 // 跳转详情页
const toDetail = () => { const toDetail = () => {
router.push( router.push(
`/proTable/useProTable/detail/${Math.random().toFixed(3)}?params=detail-page`, `/proTable/useProTable/detail/${Math.random().toFixed(3)}?params=detail-page`,
) )
} }
//重置查询条件 //重置查询条件
@@ -635,7 +630,7 @@ const handleSelectionChange = (selection: any[]) => {
channelsSelection.value = selection channelsSelection.value = selection
devNum = selection.length devNum = selection.length
devChannelsNum = 0 devChannelsNum = 0
for (let i = 0; i < selection.length; i++) { for (let i = 0; i < selection.length; i++) {
devChannelsNum += selection[i].devChns devChannelsNum += selection[i].devChns
} }
@@ -651,8 +646,11 @@ const handleSelectionChange = (selection: any[]) => {
return { return {
deviceId: item.id, deviceId: item.id,
deviceName: item.name, deviceName: item.name,
deviceType: item.devType,
chnNum: item.devChns, chnNum: item.devChns,
planId: item.planId,
deviceType: item.devType,
devVolt: item.devVolt,
devCurr: item.devCurr,
} }
}) })
@@ -845,17 +843,18 @@ const addDevice = (val: string) => {
path: '/machine/device', path: '/machine/device',
}) })
} }
const handleTest = async (val: string) => { const handleTest = async (val: string) => {
if (devNum == 0) { if (devNum == 0) {
ElMessageBox.confirm( ElMessageBox.confirm(
'请先选择被检设备', '请先选择被检设备',
'提示', '提示',
{ {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning', type: 'warning',
}, },
) )
return return
} }
@@ -864,13 +863,13 @@ const handleTest = async (val: string) => {
const isDevVoltConsistent = new Set(checkDevVolt).size === 1 const isDevVoltConsistent = new Set(checkDevVolt).size === 1
if (!isDevVoltConsistent) { if (!isDevVoltConsistent) {
ElMessageBox.confirm( ElMessageBox.confirm(
'所勾选设备额定电压不一致,请重新选择', '所勾选设备额定电压不一致,请重新选择',
'提示', '提示',
{ {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning', type: 'warning',
}, },
) )
return return
} }
@@ -879,19 +878,19 @@ const handleTest = async (val: string) => {
const isDevCurrConsistent = new Set(checkDevCurr).size === 1 const isDevCurrConsistent = new Set(checkDevCurr).size === 1
if (!isDevCurrConsistent) { if (!isDevCurrConsistent) {
ElMessageBox.confirm( ElMessageBox.confirm(
'所勾选设备额定电流不一致,请重新选择', '所勾选设备额定电流不一致,请重新选择',
'提示', '提示',
{ {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning', type: 'warning',
}, },
) )
return return
} }
if (val === '手动检测' || val === '自动检测' || val === '不合格项复检' || val === '全部复检') { if (val === '手动检测' || val === '一键检测' || val === '系数校准') {
// if (devNum > 6) { // if (devNum > 6) {
// ElMessageBox.confirm( // ElMessageBox.confirm(
// '每次检测最多只能选择6台设备请重新选择', // '每次检测最多只能选择6台设备请重新选择',
@@ -904,125 +903,115 @@ const handleTest = async (val: string) => {
// ) // )
// return // return
// } // }
if (devChannelsNum > 12) { // if (devTestedNum == 0) {
ElMessageBox.confirm( // ElMessageBox.confirm('请先选择检测完成状态的被检设备', '提示',
'每次检测最多只能检测12个设备通道请重新选择', // {
'提示', // confirmButtonText: '确定',
{ // cancelButtonText: '取消',
confirmButtonText: '确定', // type: 'warning',
cancelButtonText: '取消', // })
type: 'warning', // return
}, // }
)
return
}
if (testType === 'reTest') {
ElMessageBox.confirm(
'请选择复检检测方式',
'设备复检',
{
distinguishCancelAndClose: true,
confirmButtonText: '不合格项复检',
cancelButtonText: '全部复检',
type: 'warning',
},
)
.then(() => {
ElMessage.success('不合格项复检')
dialogTitle.value = val
testPopup.value?.open(channelsSelection.value, dialogTitle.value, props.isTimeCheck)// 打开对话框
})
.catch((action: Action) => {
ElMessage.success('全部复检')
dialogTitle.value = val
testPopup.value?.open(channelsSelection.value, dialogTitle.value, props.isTimeCheck) // 打开对话框
})
} else {
dialogTitle.value = val
testPopup.value?.open(channelsSelection.value, dialogTitle.value, props.isTimeCheck)
}
return
}
if (val === '系数校准') {
const checkStates = channelsSelection.value.map(item => item.checkState) const checkStates = channelsSelection.value.map(item => item.checkState)
const allCheckStatesEqual = new Set(checkStates).size <= 1 const allCheckStatesEqual = new Set(checkStates).size <= 1
if (!allCheckStatesEqual) { if (!allCheckStatesEqual) {
ElMessageBox.confirm( ElMessageBox.confirm(
'所勾选设备检测状态不一致,请重新选择', '所勾选设备检测状态不一致,请重新选择',
'提示', '提示',
{ {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning', type: 'warning',
}, },
) )
return return
} }
if (devChannelsNum > 12) {
const factorFlagArray = ref<string[]>([]) // 初始化为空数组
for (let i = 0; i < channelsSelection.value.length; i++) {
const factorFlag = channelsSelection.value[i].factorFlag
if (factorFlag !== undefined && factorFlag !== null && factorFlag === 0) {
factorFlagArray.value.push(channelsSelection.value[i].name.toString())
}
}
if (factorFlagArray.value.length > 0) {
const factorFlags = factorFlagArray.value.join(', ')
ElMessageBox.confirm( ElMessageBox.confirm(
factorFlags + '设备不支持系数校准,请重新选择', '每次检测最多只能检测12个设备通道,请重新选择',
'提示', '提示',
{ {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning', type: 'warning',
}, },
) )
return return
} }
// // 检查 socketClient.Instance 是否存在 dialogTitle.value = val
// if (!socketClient.Instance) { if (val === '手动检测') {
// console.error('WebSocket 客户端实例不存在'); if (testType === 'reTest') {
// return; ElMessageBox.confirm('请选择复检检测方式', '设备复检',
// } {
distinguishCancelAndClose: true,
confirmButtonText: '不合格项复检',
socketClient.Instance.connect(); cancelButtonText: '全部复检',
dataSocket.socketServe = socketClient.Instance; type: 'warning',
dataSocket.socketServe.registerCallBack('aaa', (res: { code: number; }) => { })
// 处理来自服务器的消息 .then(() => {
//console.log('Received message:', res) ElMessage.success('不合格项复检')
// 根据需要在这里添加更多的处理逻辑 selectTestItemPopupRef.value?.open()
if (res.code === 20000) { })
ElMessage.error(message.message) .catch((action: Action) => {
loading.close() ElMessage.success('全部复检')
selectTestItemPopupRef.value?.open()
})
} else { } else {
webMsgSend.value = res selectTestItemPopupRef.value?.open()
}
} else if (val === '系数校准') {
const factorFlagArray = ref<string[]>([]) // 初始化为空数组
for (let i = 0; i < channelsSelection.value.length; i++) {
const factorFlag = channelsSelection.value[i].factorFlag
if (factorFlag !== undefined && factorFlag !== null && factorFlag === 0) {
factorFlagArray.value.push(channelsSelection.value[i].name.toString())
}
}
if (factorFlagArray.value.length > 0) {
const factorFlags = factorFlagArray.value.join(', ')
ElMessageBox.confirm(
factorFlags + '设备不支持系数校准,请重新选择',
'提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
},
)
return
} }
})
channelsTest.value?.open(channelsSelection.value, props.plan) // // 检查 socketClient.Instance 是否存在
return // if (!socketClient.Instance) {
} // console.error('WebSocket 客户端实例不存在');
// return;
// }
if (devTestedNum == 0) { socketClient.Instance.connect();
ElMessageBox.confirm( dataSocket.socketServe = socketClient.Instance;
'请先选择检测完成状态的被检设备', dataSocket.socketServe.registerCallBack('aaa', (res: { code: number; }) => {
'提示', // 处理来自服务器的消息
{ //console.log('Received message:', res)
confirmButtonText: '确定', // 根据需要在这里添加更多的处理逻辑
cancelButtonText: '取消', if (res.code === 20000) {
type: 'warning', ElMessage.error(message.message)
}, loading.close()
) } else {
return webMsgSend.value = res
}
})
channelsTest.value?.open(channelsSelection.value, props.plan)
return
} else {
checkStore.initSelectTestItems()
openTestDialog()
}
} }
if (val === '批量下载') { if (val === '批量下载') {
reportDialogVisible.value = true reportDialogVisible.value = true
return return
} }
@@ -1046,8 +1035,10 @@ const handleTest = async (val: string) => {
emit('batchGenerateClicked') // 触发事件 emit('batchGenerateClicked') // 触发事件
} }
}
const openTestDialog = () => {
testPopup.value?.open(channelsSelection.value, dialogTitle.value)
} }
// 打开 drawer(新增、查看、编辑) // 打开 drawer(新增、查看、编辑)
@@ -1063,14 +1054,14 @@ const openDrawer = async (title: string, row: any) => {
if (title === '报告生成') { if (title === '报告生成') {
await generateDevReport({ 'planId': checkStore.planId, 'devId': row.id }) await generateDevReport({'planId': checkStore.plan.id, 'devId': row.id})
emit('batchGenerateClicked') // 触发事件 emit('batchGenerateClicked') // 触发事件
ElMessage.success({ message: `报告生成成功!` }) ElMessage.success({message: `报告生成成功!`})
} }
if (title === '报告下载') { if (title === '报告下载') {
await useDownload(downloadDevData, row.createId, { await useDownload(downloadDevData, row.createId, {
planId: checkStore.planId, planId: checkStore.plan.id,
devId: row.id, devId: row.id,
}, false, '.docx') }, false, '.docx')
emit('batchGenerateClicked') // 触发事件 emit('batchGenerateClicked') // 触发事件
@@ -1116,12 +1107,12 @@ function formatDate(date: Date) {
// 监听 props.id 的变化 // 监听 props.id 的变化
watch( watch(
() => props.id, () => props.id,
(newId) => { (newId) => {
handleRefresh() handleRefresh()
// 调用获取数据的方法 // 调用获取数据的方法
}, },
{ immediate: true }, // 立即执行一次 {immediate: true}, // 立即执行一次
) )
onBeforeMount(async () => { onBeforeMount(async () => {
@@ -1153,7 +1144,7 @@ const handleSubmitClicked = async (resolve: (value: boolean) => void) => {
} }
}; };
defineExpose({ changeActiveTabs }) defineExpose({changeActiveTabs})
</script> </script>
<style lang='scss' scoped> <style lang='scss' scoped>
/* 当屏幕宽度小于或等于1300像素时 */ /* 当屏幕宽度小于或等于1300像素时 */

View File

@@ -1,159 +1,163 @@
<template> <template>
<div class="dialog" v-bind="dialogBig"> <div>
<div class="dialog-title"> <div class="dialog" v-bind="dialogBig">
<div class="timeView"> <div class="dialog-title">
<el-icon style="margin: 0px 5px;"><Clock /></el-icon> <div class="timeView">
<span>检测用时{{ timeView }}</span> <el-icon style="margin: 0px 5px;">
</div> <Clock/>
<el-progress
style="width: 50%; margin-right: 15px;"
:percentage="percentage"
:color="customColors"/>
<div style="width: 12%">
<el-button type="primary" v-if="testStatus=='test_init'" disabled @click="handlePause()">
<el-icon class="loading-box" style="color: #fff;margin-right: 8px;">
<component :is="Refresh"/>
</el-icon> </el-icon>
初始化中 <span>检测用时{{ timeView }}</span>
</el-button> </div>
<el-progress
style="width: 50%; margin-right: 15px;"
:percentage="percentage"
:color="customColors"/>
<el-button <div style="width: 12%">
type="primary" <el-button type="primary" v-if="testStatus=='test_init'" disabled @click="handlePause()">
v-if="testStatus=='process' && percentage < 100" <el-icon class="loading-box" style="color: #fff;margin-right: 8px;">
:icon="VideoPause" <component :is="Refresh"/>
@click="handlePause()">停止检测 </el-icon>
</el-button> 初始化中
<el-button type="warning" v-if="testStatus === 'paused_ing' && percentage < 100" disabled> </el-button>
<el-icon class="loading-box" style="margin-right: 8px;">
<component :is="Refresh"/> <el-button
</el-icon> type="primary"
暂停中 v-if="testStatus=='process' && percentage < 100"
</el-button> :icon="VideoPause"
<!-- <el-button--> @click="handlePause()">停止检测
<!-- type="primary"--> </el-button>
<!-- v-if="testStatus=='test_init'"--> <el-button type="warning" v-if="testStatus === 'paused_ing' && percentage < 100" disabled>
<!-- :icon="VideoPause"--> <el-icon class="loading-box" style="margin-right: 8px;">
<!-- disabled>初始化中--> <component :is="Refresh"/>
<!-- </el-button>--> </el-icon>
<!-- <el-button--> 暂停中
<!-- type="danger"--> </el-button>
<!-- v-if="testStatus=='test_init_fail'"--> <!-- <el-button-->
<!-- :icon="Failed"--> <!-- type="primary"-->
<!-- disabled>初始化失败--> <!-- v-if="testStatus=='test_init'"-->
<!-- </el-button>--> <!-- :icon="VideoPause"-->
<!-- <el-button--> <!-- disabled>初始化中-->
<!-- type="danger"--> <!-- </el-button>-->
<!-- v-if="testStatus=='connect_timeout'"--> <!-- <el-button-->
<!-- :icon="Failed"--> <!-- type="danger"-->
<!-- disabled>连接超时--> <!-- v-if="testStatus=='test_init_fail'"-->
<!-- </el-button>--> <!-- :icon="Failed"-->
<el-button <!-- disabled>初始化失败-->
type="primary" <!-- </el-button>-->
:icon="RefreshLeft" <!-- <el-button-->
v-if="testStatus === 'test_recheck'" <!-- type="danger"-->
@click="emit('sendReCheck')">重新检测 <!-- v-if="testStatus=='connect_timeout'"-->
</el-button> <!-- :icon="Failed"-->
<!-- disabled>连接超时-->
<!-- </el-button>-->
<el-button
type="primary"
:icon="RefreshLeft"
v-if="testStatus === 'test_recheck'"
@click="emit('sendReCheck')">重新检测
</el-button>
<el-button type="success" v-if="percentage >= 100" :icon="Check" disabled>检测完成</el-button> <el-button type="success" v-if="percentage >= 100" :icon="Check" disabled>检测完成</el-button>
<el-button <el-button
type="warning" type="warning"
v-if="(testStatus=='paused' || testStatus === 'pause_timeout') && percentage < 100" v-if="(testStatus=='paused' || testStatus === 'pause_timeout') && percentage < 100"
:icon="VideoPlay" :icon="VideoPlay"
:disabled="testStatus === 'pause_timeout'" :disabled="testStatus === 'pause_timeout'"
@click="emit('sendResume')" @click="emit('sendResume')"
>继续检测 >继续检测
</el-button> </el-button>
</div>
<el-button style="width: 10%" type="text" :icon="InfoFilled" @click="showTestLog">检测项进度</el-button>
</div> </div>
<el-button style="width: 10%" type="text" :icon="InfoFilled" @click="showTestLog">检测项进度</el-button>
</div>
<div class="dialog-content"> <div class="dialog-content">
<el-table :data="checkResultView" row-key="scriptType" height="450px" <el-table :data="checkResultView" row-key="scriptType" height="450px"
:header-cell-style="{ background: '#003078', color: '#eee', textAlign: 'center' } " style="width: 100%" :header-cell-style="{ background: '#003078', color: '#eee', textAlign: 'center' } " style="width: 100%"
border> border>
<el-table-column fixed prop="scriptName" label="检测项目" width="150px" align="center"> <el-table-column fixed prop="scriptName" label="检测项目" width="150px" align="center">
</el-table-column>
<template v-if="chnSum<=MAX_CHN_SUM">
<el-table-column v-for="(item,index1) in deviceList" :key="item.deviceId" :label="item.deviceName"
:min-width="110" align="center">
<el-table-column v-for="(chnItem,index2) in item.chnNum" :key="`${item.deviceId}${chnItem}`"
:label="'通道'+chnItem" align="center">
<template #default="{row}">
<el-tooltip
:content="row.devices[index1].chnResult[index2].color===CheckData.ButtonColorEnum.INFO ? '暂无数据' : '点击查看详情'"
placement="top">
<el-button
: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"
size="small"
@click="handleClick(item,chnItem,row.scriptType)"
style="align-self: center;"
>
<el-icon v-if="row.devices[index1].chnResult[index2].icon==='Loading'" class="loading-box"
style="color: #fff">
<component :is="Loading"/>
</el-icon>
<el-icon v-else style="color: #fff">
<component :is="row.devices[index1].chnResult[index2].icon"/>
</el-icon>
</el-button>
</el-tooltip>
</template>
</el-table-column>
</el-table-column> </el-table-column>
</template>
<!-- <template v-else>--> <template v-if="chnSum<=MAX_CHN_SUM">
<!-- <el-table-column v-for="(item,index1) in deviceList" :key="item.deviceId" :label="item.deviceName" :min-width="110" align="center">--> <el-table-column v-for="(item,index1) in deviceList" :key="item.deviceId" :label="item.deviceName"
<!-- <template #default="{row}">--> :min-width="110" align="center">
<!-- <el-tooltip--> <el-table-column v-for="(chnItem,index2) in item.chnNum" :key="`${item.deviceId}${chnItem}`"
<!-- :content="row.devices[index1].chnResult[0].color===CheckData.ButtonColorEnum.INFO ? '暂无数据' : '点击查看详情'"--> :label="'通道'+chnItem" align="center">
<!-- placement="top">--> <template #default="{row}">
<!-- <el-button--> <el-tooltip
<!-- :disabled="row.devices[index1].chnResult[0].color===CheckData.ButtonColorEnum.INFO || row.devices[index1].chnResult[0].color===CheckData.ButtonColorEnum.LOADING"--> :content="row.devices[index1].chnResult[index2].color===CheckData.ButtonColorEnum.INFO ? '暂无数据' : '点击查看详情'"
<!-- :color="row.devices[index1].chnResult[0].color"--> placement="top">
<!-- size="small"--> <el-button
<!-- @click="handleClick(item,-1,row.scriptType)"--> :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"
<!-- <el-icon v-if="row.devices[index1].chnResult[0].icon==='Loading'" class="loading-box"--> size="small"
<!-- style="color: #fff">--> @click="handleClick(item,chnItem,row.scriptType)"
<!-- <component :is="Loading"/>--> style="align-self: center;"
<!-- </el-icon>--> >
<!-- <el-icon v-else style="color: #fff">--> <el-icon v-if="row.devices[index1].chnResult[index2].icon==='Loading'" class="loading-box"
<!-- <component :is="row.devices[index1].chnResult[0].icon"/>--> style="color: #fff">
<!-- </el-icon>--> <component :is="Loading"/>
<!-- </el-button>--> </el-icon>
<!-- </el-tooltip>--> <el-icon v-else style="color: #fff">
<!-- </template>--> <component :is="row.devices[index1].chnResult[index2].icon"/>
<!-- </el-table-column>--> </el-icon>
<!-- </template>--> </el-button>
</el-table> </el-tooltip>
</template>
</el-table-column>
</el-table-column>
</template>
<!-- <template v-else>-->
<!-- <el-table-column v-for="(item,index1) in deviceList" :key="item.deviceId" :label="item.deviceName" :min-width="110" align="center">-->
<!-- <template #default="{row}">-->
<!-- <el-tooltip-->
<!-- :content="row.devices[index1].chnResult[0].color===CheckData.ButtonColorEnum.INFO ? '暂无数据' : '点击查看详情'"-->
<!-- placement="top">-->
<!-- <el-button-->
<!-- :disabled="row.devices[index1].chnResult[0].color===CheckData.ButtonColorEnum.INFO || row.devices[index1].chnResult[0].color===CheckData.ButtonColorEnum.LOADING"-->
<!-- :color="row.devices[index1].chnResult[0].color"-->
<!-- size="small"-->
<!-- @click="handleClick(item,-1,row.scriptType)"-->
<!-- >-->
<!-- <el-icon v-if="row.devices[index1].chnResult[0].icon==='Loading'" class="loading-box"-->
<!-- style="color: #fff">-->
<!-- <component :is="Loading"/>-->
<!-- </el-icon>-->
<!-- <el-icon v-else style="color: #fff">-->
<!-- <component :is="row.devices[index1].chnResult[0].icon"/>-->
<!-- </el-icon>-->
<!-- </el-button>-->
<!-- </el-tooltip>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- </template>-->
</el-table>
</div>
</div>
<div class="drawer-container">
<el-drawer v-model="drawer" title="检测项进度" direction="btt">
<div ref="scrollContainerRef" style="height: 100%; overflow-y: auto;">
<p v-for="(item, index) in testLogList"
:key="index"
:style="{color:item.type==='error'?'#F56C6C': item.type==='warning'?'#e6a23c':'var(--el-text-color-regular)'}">
{{ item.log }}<br/>
</p>
</div>
</el-drawer>
</div> </div>
<resultPopup
:visible="resultDialogVisible"
@update:visible="resultDialogVisible = $event"
></resultPopup>
<dataCheckSingleChannelSingleTestPopup ref="dataCheckSingleChannelSingleTestPopupRef"/>
</div> </div>
<div class="drawer-container">
<el-drawer v-model="drawer" title="检测项进度" direction="btt">
<div ref="scrollContainerRef" style="height: 100%; overflow-y: auto;">
<p v-for="(item, index) in testLogList"
:key="index"
:style="{color:item.type==='error'?'#F56C6C': item.type==='warning'?'#e6a23c':'var(--el-text-color-regular)'}">
{{ item.log }}<br/>
</p>
</div>
</el-drawer>
</div>
<resultPopup
:visible="resultDialogVisible"
@update:visible="resultDialogVisible = $event"
></resultPopup>
<dataCheckSingleChannelSingleTestPopup ref="dataCheckSingleChannelSingleTestPopupRef"/>
</template> </template>
<script lang="tsx" setup name="test"> <script lang="tsx" setup name="test">
import {Check, Failed, InfoFilled, Loading, Timer, Refresh, RefreshLeft, VideoPause, VideoPlay} from '@element-plus/icons-vue' import {Check, Failed, InfoFilled, Loading, Timer, Refresh, RefreshLeft, VideoPause, VideoPlay} from '@element-plus/icons-vue'
@@ -469,25 +473,25 @@ watch(webMsgSend, function (newValue, oldValue) {
break; break;
} }
break; break;
case 'connect': // case 'connect':
switch (newValue.operateCode) { // switch (newValue.operateCode) {
case "Source": // case "Source":
ElMessageBox.alert('源通讯失败,请检查源连接情况!', '初始化失败', { // ElMessageBox.alert('源通讯失败,请检查源连接情况!', '初始化失败', {
confirmButtonText: '确定', // confirmButtonText: '确定',
type: 'error', // type: 'error',
}) // })
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:源通讯失败!`}) // testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:源通讯失败!`})
break; // break;
case "Dev": // case "Dev":
ElMessageBox.alert('设备通讯失败,请检查设备连接情况!', '初始化失败', { // ElMessageBox.alert('设备通讯失败,请检查设备连接情况!', '初始化失败', {
confirmButtonText: '确定', // confirmButtonText: '确定',
type: 'error', // type: 'error',
}) // })
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:设备通讯失败!`}) // testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:设备通讯失败!`})
break; // break;
} // }
emit('update:testStatus', 'test_init_fail') // emit('update:testStatus', 'test_init_fail')
break; // break;
case 'yjc_ytxjy': case 'yjc_ytxjy':
switch (newValue.operateCode) { switch (newValue.operateCode) {
case 'INIT_GATHER': case 'INIT_GATHER':
@@ -715,7 +719,7 @@ const showTestLog = () => {
// 初始化检测脚本数据 // 初始化检测脚本数据
const initScriptData = async () => { const initScriptData = async () => {
let response: any = await getBigTestItem(checkStore.planId) let response: any = await getBigTestItem(checkStore.plan.id)
let temp = response.data.map(item => { let temp = response.data.map(item => {
return { return {
@@ -782,7 +786,7 @@ 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;
} }
}; };
@@ -929,28 +933,28 @@ function getErrorCheckItem(scriptType: string) {
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
// devices = [ devices = [
// { {
// chnResult: [3, 4], chnResult: [1, 1, 1, 1],
// deviceId: "80b4b4f52a4c4064a18319525f8ac13c", deviceId: "3250a0ff180845cc8885da4ff628261e",
// deviceName: "240002" deviceName: "测试装置-0122-02"
// }, },
// { // {
// chnResult: [1, 1, 1, 1], // chnResult: [1, 1, 1, 1],
// deviceId: "df23a4178d194467a432ddf45e835e48", // deviceId: "df23a4178d194467a432ddf45e835e48",
// deviceName: "240003" // deviceName: "240003"
// }, // },
// { // {
// chnResult: [1, 1, 1, 1], // chnResult: [1, 1, 1, 1],
// deviceId: "ae5a7628260349c0a5e7c86c81fbd417", // deviceId: "ae5a7628260349c0a5e7c86c81fbd417",
// deviceName: "240004" // deviceName: "240004"
// } // }
// { // {
// chnResult: [1, 1, 1, 1], // chnResult: [1, 1, 1, 1],
// deviceId: "461813a4f30f4a34a1a273ecd0379458", // deviceId: "461813a4f30f4a34a1a273ecd0379458",
// deviceName: "25011407" // deviceName: "25011407"
// } // }
// ] ]
let temp = null let temp = null
if (isStart) { if (isStart) {
temp = getLoadingResult(scriptType) temp = getLoadingResult(scriptType)
@@ -1178,46 +1182,46 @@ const startTimer = () => {
case 8: case 8:
todoItem('HSI') todoItem('HSI')
break; break;
// case 9: // case 9:
// emit('update:webMsgSend', { // emit('update:webMsgSend', {
// requestId: 'I_Start' // requestId: 'I_Start'
// }) // })
// setTimeout(() => { // setTimeout(() => {
// emit('update:webMsgSend', { // emit('update:webMsgSend', {
// requestId: 'I_End' // requestId: 'I_End'
// }) // })
// }, 2000) // }, 2000)
// break; // break;
// case 10: // case 10:
// emit('update:webMsgSend', { // emit('update:webMsgSend', {
// requestId: 'IMBV_Start' // requestId: 'IMBV_Start'
// }) // })
// setTimeout(() => { // setTimeout(() => {
// emit('update:webMsgSend', { // emit('update:webMsgSend', {
// requestId: 'IMBV_End' // requestId: 'IMBV_End'
// }) // })
// }, 2000) // }, 2000)
// break; // break;
// case 11: // case 11:
// emit('update:webMsgSend', { // emit('update:webMsgSend', {
// requestId: 'IMBA_Start' // requestId: 'IMBA_Start'
// }) // })
// setTimeout(() => { // setTimeout(() => {
// emit('update:webMsgSend', { // emit('update:webMsgSend', {
// requestId: 'IMBA_End' // requestId: 'IMBA_End'
// }) // })
// }, 2000) // }, 2000)
// break; // break;
// case 12: // case 12:
// emit('update:webMsgSend', { // emit('update:webMsgSend', {
// requestId: 'F_Start' // requestId: 'F_Start'
// }) // })
// setTimeout(() => { // setTimeout(() => {
// emit('update:webMsgSend', { // emit('update:webMsgSend', {
// requestId: 'F_End' // requestId: 'F_End'
// }) // })
// }, 2000) // }, 2000)
// break; // break;
case 9: case 9:
emit('update:webMsgSend', { emit('update:webMsgSend', {
requestId: 'Quit' requestId: 'Quit'
@@ -1262,8 +1266,8 @@ const todoItem = (code: string) => {
desc: '输入频率t=42.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ', desc: '输入频率t=42.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ',
data: [{ data: [{
chnResult: [1, 1, 1, 1], chnResult: [1, 1, 1, 1],
deviceId: "461813a4f30f4a34a1a273ecd0379458", deviceId: "3250a0ff180845cc8885da4ff628261e",
deviceName: "25011407" deviceName: "测试装置-0122-02"
}] }]
}) })
} }
@@ -1283,8 +1287,8 @@ const todoItem = (code: string) => {
desc: '输入频率t=45.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ', desc: '输入频率t=45.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ',
data: [{ data: [{
chnResult: [1, 1, 1, 1], chnResult: [1, 1, 1, 1],
deviceId: "461813a4f30f4a34a1a273ecd0379458", deviceId: "3250a0ff180845cc8885da4ff628261e",
deviceName: "25011407" deviceName: "测试装置-0122-02"
}] }]
}) })
} }
@@ -1303,9 +1307,9 @@ const todoItem = (code: string) => {
requestId: `${code}_End`, requestId: `${code}_End`,
desc: '输入频率t=50.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ', desc: '输入频率t=50.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ',
data: [{ data: [{
chnResult: [1, 2, 1, 1], chnResult: [1, 1, 1, 1],
deviceId: "461813a4f30f4a34a1a273ecd0379458", deviceId: "3250a0ff180845cc8885da4ff628261e",
deviceName: "25011407" deviceName: "测试装置-0122-02"
}] }]
}) })
} }
@@ -1316,8 +1320,8 @@ const todoItem = (code: string) => {
requestId: `${code}_End`, requestId: `${code}_End`,
data: [{ data: [{
chnResult: [1, 2, 1, 1], chnResult: [1, 2, 1, 1],
deviceId: "461813a4f30f4a34a1a273ecd0379458", deviceId: "3250a0ff180845cc8885da4ff628261e",
deviceName: "25011407" deviceName: "测试装置-0122-02"
}] }]
}) })
} }
@@ -1331,7 +1335,7 @@ const handleResumeTest = () => {
type: 'info', type: 'info',
log: `${new Date().toLocaleString()}:继续检测`, log: `${new Date().toLocaleString()}:继续检测`,
}) })
//startTimer() startTimer()
resumeTimeCount() resumeTimeCount()
console.log('开始继续检测') console.log('开始继续检测')
}; };

View File

@@ -1,34 +1,30 @@
<template> <template>
<el-dialog :title="dialogTitle" :model-value="dialogVisible" :before-close="beforeClose" @close="handleCancel" width="1200px" height="1000px" <el-dialog :title="dialogTitle" :model-value="dialogVisible" :before-close="beforeClose" @close="handleClose" width="1200px" height="1000px"
draggable> draggable>
<div class="steps-container"> <div class="steps-container">
<!-- simple --> <el-steps class="test-head-steps" simple :active="stepsActiveIndex-1" process-status="finish" finish-status="success">
<!-- :style="{color:node.label=='未检'?'#F56C6C':node.label=='检测中'?'#E6A23C':'#67C23A'}" --> <el-step v-if="preTestSelected" title="预检测" :icon="stepsActive === 1? SuccessFilled :Edit" @click="handleStepClick(1)"/>
<el-steps class="test-head-steps" simple :active="stepsActiveIndex" process-status="finish" finish-status="success"> <el-step v-if="timeTestSelected" title="守时检测" :icon="stepsActive === 2? SuccessFilled :UploadFilled" @click="handleStepClick(2)"/>
<!-- style="height:100px" --> <el-step v-if="channelsTestSelected" title="系数校准" :icon="stepsActive === 3? SuccessFilled :Odometer" @click="handleStepClick(3)"/>
<!-- <el-step title="预检测" :icon="getIcon(0)" /> --> <el-step v-if="testSelected" title="正式检测" :icon="stepsActive === 4? SuccessFilled :Coin" @click="handleStepClick(4)"/>
<el-step title="检测" :icon="stepsActiveIndex > 1 ? SuccessFilled :Edit"/> <el-step title="检测完成" :icon="stepsActiveIndex > stepsTotalNum ? SuccessFilled :Key"/>
<el-step title="守时检测" :icon="stepsActiveIndex > 1 ? SuccessFilled :UploadFilled" v-if="isTimeCheck"/>
<!-- <el-step title="系数校准" :icon="stepsActiveIndex > 2 ? SuccessFilled :Odometer" /> -->
<el-step title="正式检测" :icon="stepsActiveIndex > 3 ? SuccessFilled :Coin"/>
<el-step title="检测完成" :icon="stepsActiveIndex > 4 ? SuccessFilled :Key"/>
</el-steps> </el-steps>
</div> </div>
<preTest ref="preTestRef" v-if="stepsActiveIndex === 0" v-model:testStatus="preTestStatus" :webMsgSend="webMsgSend"></preTest>
<timeTest v-if="stepsActiveIndex === 1 && isTimeCheck" v-model:testStatus="timeTestStatus"></timeTest> <preTest v-if="showComponent" v-show="preTestSelected && stepsActiveView==1" ref="preTestRef" v-model:testStatus="preTestStatus" :webMsgSend="webMsgSend"/>
<!-- <channelsTest v-if="stepsActiveIndex === 2" v-model:testStatus="channelsTestStatus"></channelsTest> --> <timeTest v-if="showComponent" v-show="timeTestSelected && stepsActiveView==2" v-model:testStatus="timeTestStatus"/>
<test v-if="stepsActiveIndex >= 2" v-model:testStatus="TestStatus" :webMsgSend="webMsgSend" @update:webMsgSend="webMsgSend=$event" <!-- <channelsTest v-if="stepsActiveIndex === 3" v-model:testStatus="channelsTestStatus"></channelsTest>-->
@sendPause="sendPause" @sendResume="sendResume" @sendReCheck="sendReCheck"></test> <factorTest v-if="showComponent" v-show="channelsTestSelected && stepsActiveView==3" v-model:testStatus="channelsTestStatus"/>
<test v-if="showComponent" v-show="testSelected && stepsActiveView==4" v-model:testStatus="TestStatus" :webMsgSend="webMsgSend"
@update:webMsgSend="webMsgSend=$event" @sendPause="sendPause" @sendResume="sendResume" @sendReCheck="sendReCheck"/>
<template #footer> <template #footer>
<div> <div>
<!-- <el-button @click="handleCancel"> </el-button> --> <el-button type="primary" :icon="DArrowRight" v-if="stepsActiveIndex < stepsTotalNum && ActiveStatue != 'success'" @click="nextStep">跳过
<el-button type="primary" :icon="DArrowRight" v-if="stepsActiveIndex < 2 && ActiveStatue != 'success'" :disabled="skipDisabled"
@click="nextStep">跳过
</el-button> </el-button>
<el-button type="primary" :icon="VideoPlay" v-if="ActiveStatue === 'waiting'" @click="handleSubmit" :disabled="btnState">开始检测</el-button> <el-button type="primary" :icon="VideoPlay" v-if="ActiveStatue === 'waiting'" @click="handleSubmit" :disabled="btnState">开始检测</el-button>
<el-button type="primary" v-if="TestStatus === 'process'" @click="handleSubmit" disabled> <el-button type="primary" v-if="ActiveStatue === 'process'" @click="handleSubmit" 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>
@@ -61,108 +57,27 @@
</template> </template>
<script lang="tsx" setup name="testPopup"> <script lang="tsx" setup name="testPopup">
import {h, reactive, ref, watch} from 'vue'; import {reactive, ref, watch} from 'vue';
import {ElMessage, ElMessageBox} from 'element-plus' import {ElMessage, ElMessageBox} from 'element-plus'
//import IndicatorTypeDialog from "@/views/machine/errorSystem/components/IndicatorTypeDialog.vue"; // 导入子组件 import {Coin, DArrowRight, Edit, Key, Odometer, Refresh, RefreshLeft, Right, SuccessFilled, UploadFilled, VideoPlay} from '@element-plus/icons-vue'
import {
Close,
Coin,
DArrowRight,
Edit,
Key,
Odometer,
Refresh,
Right,
SuccessFilled,
UploadFilled,
VideoPlay,
RefreshLeft, Loading
} from '@element-plus/icons-vue'
import preTest from './preTest.vue' import preTest from './preTest.vue'
import timeTest from './timeTest.vue' import timeTest from './timeTest.vue'
import factorTest from './factorTest.vue'
import test from './test.vue'
import {Device} from '@/api/device/interface/device'; import {Device} from '@/api/device/interface/device';
import socketClient from '@/utils/webSocketClient'; import socketClient from '@/utils/webSocketClient';
import {useCheckStore} from "@/stores/modules/check"; import {useCheckStore} from "@/stores/modules/check";
import {startPreTest, pauseTest, resumeTest} from '@/api/socket/socket' import {pauseTest, startPreTest} from '@/api/socket/socket'
import {showFullScreenLoading} from "@/components/Loading/fullScreen";
//import SvgIcon from '@/components/SvgIcon.vue';
// import preTestIcon from '@/assets/icons/preTest.svg'
// const preTestIcon = `
// <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6 h-6">
// </svg>
// `;
// const props = defineProps<{
// visible: boolean;
// dialogTitle: string;
// formData: {
// id: string;//误差体系表Id
// name: string;//误差体系名称
// standard_Name:string;//参照标准名称
// standard_Time:string;//标准推行时间
// dev_Level:string;//使用设备等级
// enable:number;//状态0-不启用 1-启用
// state:number;//0-删除 1-正常
// };
// }>();
// const emit = defineEmits<{
// (e: 'update:visible', value: boolean): void;
// (e: 'submit', data: any): void;
// }>();
const btnState = ref(false) const btnState = ref(false)
const checkStore = useCheckStore(); const checkStore = useCheckStore();
const skipDisabled = ref(false);
const nextStepText = ref('下一步'); const nextStepText = ref('下一步');
const dialogVisible = ref(false) const dialogVisible = ref(false)
//定义与预检测配置数组
const detectionOptions = ref([
{
id: 0,
name: "源通讯检测",//判断源通讯是否正常
selected: true,
},
{
id: 1,
name: "设备通讯检测",//判断设备的IP、Port、识别码、秘钥是否正常
selected: true,
},
{
id: 2,
name: "协议校验",//ICD报告触发测试
selected: true,
},
{
id: 3,
name: "相序校验",//判断装置的接线是否正确
selected: true,
},
// {
// id: 4,
// name: "守时校验",//判断装置24小时内的守时误差是否小于1s
// selected: true,
// },
// {
// id: 5,
// name: "通道系数校准",//通过私有协议与装置进行通讯,校准三相电压电流的通道系数
// selected: true,
// },
// {
// id: 6,
// name: "实时数据比对",
// },
// {
// id: 7,
// name: "录波数据比对",
// },
]);
const stepsTotalNum = ref(4);//步骤总数 const stepsTotalNum = ref(-1);//步骤总数
const stepsActiveIndex = ref(0); //当前正在执行的步骤索引 const stepsActiveIndex = ref(1); //当前正在执行的步骤索引
const stepsActiveView = ref(-1); //当前正在执行的步骤在(预处理、守时校验、系数校准、正式检测)中的排序,仅用于页面显示
const stepsActive = ref(-1); //当前正在执行的步骤在(预处理、守时校验、系数校准、正式检测)中的排序,实际记录步骤的状态
const ActiveStatue = ref('waiting');//当前步骤状态 const ActiveStatue = ref('waiting');//当前步骤状态
const preTestStatus = ref('waiting');//预检测执行状态 const preTestStatus = ref('waiting');//预检测执行状态
const timeTestStatus = ref('waiting');//守时校验执行状态 const timeTestStatus = ref('waiting');//守时校验执行状态
@@ -170,50 +85,86 @@ const channelsTestStatus = 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 isTimeCheck = ref(false) const showComponent = ref(true)
const preTestRef = ref(null); const preTestRef = ref(null)
// const devIdArr = ref([])
// const planId = ref('')
const dataSocket = reactive({ const dataSocket = reactive({
socketServe: socketClient.Instance, socketServe: socketClient.Instance,
}); });
// 打开弹窗,可能是新增,也可能是编辑
const open = (selection: Device.ResPqDev[], title: string, time: boolean) => {
// 勾选的检测内容
const preTestSelected = ref(false)
const timeTestSelected = ref(false)
const channelsTestSelected = ref(false)
const testSelected = ref(false)
const checkStates = selection.map(item => item.checkState); const initOperate = () => {
// devIdArr.value = selection.map(item => item.id); showComponent.value = true
// planId.value =selection[0].planId // 初始化勾选的检测内容
// console.log('wwwwwwwwwwwwwwwww',selection) preTestSelected.value = checkStore.selectTestItems.preTest
timeTestSelected.value = checkStore.selectTestItems.timeTest
channelsTestSelected.value = checkStore.selectTestItems.channelsTest
testSelected.value = checkStore.selectTestItems.test
const allCheckStatesEqual = new Set(checkStates).size <= 1; let count = 0
for (let key in checkStore.selectTestItems) {
if (checkStore.selectTestItems[key]) {
count++
}
}
stepsTotalNum.value = count + 1
if (!allCheckStatesEqual) { if (preTestSelected.value) {
ElMessageBox.confirm( stepsActiveView.value = 1
'所勾选设备检测状态不一致,请重新选择', stepsActive.value = 1
'提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
)
return return
} }
if (timeTestSelected.value) {
stepsActiveView.value = 2
stepsActive.value = 2
return
}
if (channelsTestSelected.value) {
stepsActiveView.value = 3
stepsActive.value = 3
return
}
if (testSelected.value) {
stepsActiveView.value = 4
stepsActive.value = 4
return
}
}
const open = (selection: Device.ResPqDev[], title: string) => {
initOperate()
// const checkStates = selection.map(item => item.checkState);
//
// const allCheckStatesEqual = new Set(checkStates).size <= 1;
//
// debugger
// if (!allCheckStatesEqual) {
// ElMessageBox.confirm('所勾选设备检测状态不一致,请重新选择', '提示',
// {
// confirmButtonText: '确定',
// cancelButtonText: '取消',
// type: 'warning',
// }
// )
// return
// }
dialogTitle.value = title; dialogTitle.value = title;
dialogVisible.value = true; dialogVisible.value = true;
isTimeCheck.value = time
if (preTestRef.value) { if (preTestRef.value) {
preTestRef.value.initializeParameters(); preTestRef.value.initializeParameters();
} }
preTestStatus.value = 'waiting';//预检测执行状态 ActiveStatue.value = 'waiting'
preTestStatus.value = 'waiting'
//开始创建webSocket客户端 //开始创建webSocket客户端
socketClient.Instance.connect(); socketClient.Instance.connect();
@@ -222,43 +173,30 @@ const open = (selection: Device.ResPqDev[], title: string, time: boolean) => {
// 处理来自服务器的消息 // 处理来自服务器的消息
// 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)
loading.close() // loading.close()
} else { } else {
webMsgSend.value = res webMsgSend.value = res
} }
}); });
} }
let loading; // let loading;
const handleSubmit = () => { const handleSubmit = () => {
skipDisabled.value = true
//btnState.value = true
console.log('=============', stepsActiveIndex.value) console.log('=============', stepsActiveIndex.value)
let deviceIds = checkStore.devices.map((item) => item.deviceId) let deviceIds = checkStore.devices.map((item) => item.deviceId)
let planId = checkStore.planId let planId = checkStore.plan.id
if (!dataSocket.socketServe.connected) {
if(!dataSocket.socketServe.connected){
ElMessage.error('webSocket连接中断') ElMessage.error('webSocket连接中断')
return return
} }
switch (stepsActive.value) {
switch (stepsActiveIndex.value) { case 1:
case 0:
// preTestStatus.value = 'start'
startPreTest({ startPreTest({
userPageId: "cdf", userPageId: "cdf",
devIds: deviceIds, devIds: deviceIds,
@@ -275,35 +213,29 @@ const handleSubmit = () => {
}) })
preTestStatus.value = 'start' preTestStatus.value = 'start'
break; break;
case 1: case 2:
timeTestStatus.value = 'start' timeTestStatus.value = 'start'
break; break;
// case 2: case 3:
// channelsTestStatus.value = 'start' channelsTestStatus.value = 'start'
// break; break;
case 2: case 4:
if (TestStatus.value == "waiting") { if (TestStatus.value == "waiting") {
startPreTest({ // startPreTest({
userPageId: "cdf", // userPageId: "cdf",
devIds: deviceIds, // devIds: deviceIds,
planId: planId, // planId: planId,
operateType: '2' // '1'为预检测、2为正式检测 // operateType: '2' // '1'为预检测、2为正式检测
}).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'
} // }
/* if (res.code === 20000) { // })
TestStatus.value = 'start'
webMsgSend.value = ''
} else {
ElMessage.error(res.message)
}*/
})
TestStatus.value = 'start' TestStatus.value = 'start'
} else if (TestStatus.value == 'paused') { } else if (TestStatus.value == 'paused') {
// 发送继续指令 // 发送继续指令
@@ -311,20 +243,15 @@ const handleSubmit = () => {
} else if (TestStatus.value == 'test_recheck') { } else if (TestStatus.value == 'test_recheck') {
// 发送重新检测指令 // 发送重新检测指令
sendReCheck() sendReCheck()
} else if (TestStatus.value == 'success') {
handleClose()
}else if (TestStatus.value == 'success') {
emit('quitClicked'); // 触发事件
} }
break; break;
default: default:
break; break;
} }
}; };
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'quitClicked'): void; (e: 'quitClicked'): void;
}>(); }>();
@@ -351,34 +278,24 @@ watch(TestStatus, function (newValue, oldValue) {
}) })
watch(ActiveStatue, function (newValue, oldValue) { watch(ActiveStatue, function (newValue, oldValue) {
if (newValue === 'error' && stepsActive.value === 1) {
if (newValue === 'success' || newValue === 'error') { stepsActiveIndex.value = stepsTotalNum.value + 2
skipDisabled.value = false
}
if (newValue === 'success' && stepsActiveIndex.value === stepsTotalNum.value - 2) {
stepsActiveIndex.value++;
stepsActiveIndex.value++;
nextStepText.value = '检测完成'
}
if (newValue === 'error' && stepsActiveIndex.value === stepsTotalNum.value - 3) {
stepsActiveIndex.value++;
stepsActiveIndex.value++;
nextStepText.value = '检测失败' nextStepText.value = '检测失败'
} }
if (newValue === 'test_init_fail' && stepsActiveIndex.value === stepsTotalNum.value - 2) { if (newValue === 'success' && stepsActive.value === 4) {
stepsActiveIndex.value++; stepsActiveIndex.value += 2
stepsActiveIndex.value++; nextStepText.value = '检测完成'
}
if (newValue === 'test_init_fail' && stepsActive.value === 4) {
stepsActiveIndex.value += 2
nextStepText.value = '初始化失败' nextStepText.value = '初始化失败'
} }
if (newValue === 'connect_timeout' && stepsActiveIndex.value === stepsTotalNum.value - 2) { if (newValue === 'connect_timeout' && stepsActive.value === 4) {
stepsActiveIndex.value++; stepsActiveIndex.value += 2
stepsActiveIndex.value++;
nextStepText.value = '连接超时' nextStepText.value = '连接超时'
} }
if (newValue === 'pause_timeout' && stepsActiveIndex.value === stepsTotalNum.value - 2) { if (newValue === 'pause_timeout' && stepsActive.value === 4) {
stepsActiveIndex.value++; stepsActiveIndex.value += 2
stepsActiveIndex.value++;
nextStepText.value = '结束测试' nextStepText.value = '结束测试'
} }
}) })
@@ -388,133 +305,131 @@ const sendPause = () => {
TestStatus.value = 'paused_ing' TestStatus.value = 'paused_ing'
pauseTest() pauseTest()
setTimeout(() => {
Object.assign(webMsgSend.value, {
requestId: 'preStopTest',
operateCode: 'stop'
})
}, 5000)
} }
const sendResume = () => { 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.planId, // planId: checkStore.plan.id,
operateType: '2' // '1'为预检测、2为正式检测 // operateType: '2' // '1'为预检测、2为正式检测
}).then(res => { // }).then(res => {
Object.assign(webMsgSend.value, { // Object.assign(webMsgSend.value, {
requestId: 'Resume_Success' // requestId: 'Resume_Success'
}) // })
// })
Object.assign(webMsgSend.value, {
requestId: 'Resume_Success'
}) })
} }
const sendReCheck = () => { const sendReCheck = () => {
console.log('发送重新检测指令') console.log('发送重新检测指令')
startPreTest({ // startPreTest({
userPageId: "cdf", // userPageId: "cdf",
devIds: checkStore.devices.map((item) => item.deviceId), // devIds: checkStore.devices.map((item) => item.deviceId),
planId: checkStore.planId, // planId: checkStore.plan.id,
operateType: '2' // 0:'系数校验''1'为预检测、2为正式检测 // operateType: '2' // 0:'系数校验''1'为预检测、2为正式检测
}).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'
} // }
}) // })
TestStatus.value = 'start' TestStatus.value = 'start'
} }
const getIcon = (index: number) => {
if (stepsActiveIndex.value > index) return SuccessFilled;
switch (index) {
case 0:
return h(<svg-icon name="preTest"></svg-icon>);
case 1:
return UploadFilled;
case 2:
return Odometer;
case 3:
return Coin;
case 4:
return Key;
default:
return null;
}
};
const nextStep = () => { const nextStep = () => {
if (stepsActiveIndex.value < stepsTotalNum.value && ActiveStatue.value != 'error') { if (stepsActiveIndex.value == stepsTotalNum.value + 1 || ActiveStatue.value === 'error') {
stepsActiveIndex.value++ handleClose()
if (!isTimeCheck.value) {//不具备守时检测,预检测后直接跳正式检测 return
stepsActiveIndex.value++
}
ActiveStatue.value = 'waiting'
} else if (stepsActiveIndex.value === stepsTotalNum.value || ActiveStatue.value === 'error') {
//emit('update:visible', false); // 关闭对话框
clearData()
dialogVisible.value = false;
} }
}; if (ActiveStatue.value != 'error') {
ActiveStatue.value = 'waiting'
let tempStep = stepsActiveIndex.value
let idx = 1
stepsActiveIndex.value++
for (let selectTestItemsKey in checkStore.selectTestItems) {
if (tempStep == 0 && checkStore.selectTestItems[selectTestItemsKey]) {
stepsActiveView.value = idx
stepsActive.value = idx
return
}
if (checkStore.selectTestItems[selectTestItemsKey] && tempStep != 0) {
tempStep--
}
idx++
}
}
// if (stepsActiveIndex.value < stepsTotalNum.value && ActiveStatue.value != 'error') {
// stepsActiveIndex.value++
// if (!checkStore.selectTestItems.timeTest) { // 不具备守时检测
// stepsActiveIndex.value++
// }
//
// ActiveStatue.value = 'waiting'
// } else if (stepsActiveIndex.value === stepsTotalNum.value || ActiveStatue.value === 'error') {
// //emit('update:visible', false); // 关闭对话框
// clearData()
// dialogVisible.value = false;
// }
}
const handleStepClick = (step: number) => {
if (step > stepsActive.value) {
return
} else {
stepsActiveView.value = step
}
}
function clearData() { function clearData() {
stepsActiveIndex.value = 0; stepsTotalNum.value = -1
stepsActiveIndex.value = 1
stepsActiveView.value = -1
preTestStatus.value = "waiting" preTestStatus.value = "waiting"
timeTestStatus.value = "waiting" timeTestStatus.value = "waiting"
channelsTestStatus.value = "waiting" channelsTestStatus.value = "waiting"
TestStatus.value = "waiting" TestStatus.value = "waiting"
ActiveStatue.value = "waiting" ActiveStatue.value = "waiting"
skipDisabled.value = false
nextStepText.value = "下一步" nextStepText.value = "下一步"
} }
const beforeClose = (done: () => void) => { const beforeClose = (done: () => void) => {
console.log(stepsActiveIndex.value, stepsTotalNum.value)
if (stepsActiveIndex.value < stepsTotalNum.value) { if (stepsActiveIndex.value < stepsTotalNum.value) {
ElMessageBox.confirm( ElMessageBox.confirm('检测未完成,是否退出当前检测流程?', '提示', {
'检测未完成,是否退出当前检测流程?',
'提示',
{
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning', type: 'warning',
} }
) ).then(() => {
.then(() => { handleClose()
clearData() })
// todo 关闭弹窗,终止整个检测流程
//emit('update:visible', false); // 关闭对话框
dialogVisible.value = false;
})
} else { } else {
clearData() handleClose()
//emit('update:visible', false); // 关闭对话框
dialogVisible.value = false;
} }
// ElMessageBox.confirm('Are you sure to close this dialog?')
// .then(() => {
// done()
// })
// .catch(() => {
// // catch error
// })
} }
const handleCancel = () => {
const handleClose = () => {
dataSocket.socketServe.closeWs() dataSocket.socketServe.closeWs()
dialogVisible.value = false;
clearData()
showComponent.value = false;
emit('quitClicked'); // 触发事件 emit('quitClicked'); // 触发事件
// clearData() }
// emit('update:visible', false); // 关闭对话框
};
// // 当 props.visible 改变时,更新 formData
// watch(() => props.visible, (newVal) => {
// if (!newVal) {
// // 这里可以重置表单数据,如果需要的话
// }
// });
// 对外映射 // 对外映射
defineExpose({open}) defineExpose({open})
@@ -526,13 +441,6 @@ defineExpose({open})
max-height: 840px !important; max-height: 840px !important;
} }
// :deep(.dialog-big){
// max-height: 840px !important;
// }
// :deep(.el-dialog__body){
// max-height: 840px !important;
// }
.steps-container :deep(.test-head-steps) { .steps-container :deep(.test-head-steps) {
height: 80px; height: 80px;
margin-bottom: 10px; margin-bottom: 10px;

View File

@@ -67,10 +67,7 @@ const getTreeData = (val: any) => {
if (item.children.length > 0) { if (item.children.length > 0) {
let node = item.children[0]; let node = item.children[0];
defaultChecked.value.push(node.id); defaultChecked.value.push(node.id);
checkStore.setPlanId(node.id); checkStore.setPlan(node);
checkStore.setPlanCode(node.code);
checkStore.setScriptId(node.scriptId);
checkStore.setErrorSysId(node.errorSysId);
// 高亮显示第一个节点 // 高亮显示第一个节点
// 使用 nextTick 确保在 DOM 更新后调用 setCurrentKey // 使用 nextTick 确保在 DOM 更新后调用 setCurrentKey
nextTick(() => { nextTick(() => {
@@ -135,11 +132,8 @@ const handleNodeClick = (data: Plan.ResPlan) => {
} }
idd.value = data.id idd.value = data.id
checkStore.setPlanId(data.id) checkStore.setPlan(data);
checkStore.setPlanCode(data.code)
checkStore.setScriptId(data.scriptId)
checkStore.setErrorSysId(data.errorSysId)
updateSelectedTreeNode(data.id) updateSelectedTreeNode(data.id)
} }
const filterNode = (value: string, data: any) => { const filterNode = (value: string, data: any) => {

View File

@@ -95,7 +95,7 @@
<el-tab-pane :label='tabLabel1' :style='{ height: tabPaneHeight}'> <el-tab-pane :label='tabLabel1' :style='{ height: tabPaneHeight}'>
<!-- 列表数据 --> <!-- 列表数据 -->
<div class='container_table' :style='{ height: tableHeight }'> <div class='container_table' :style='{ height: tableHeight }'>
<Table ref='tableRef1' :id='currentId' :isTimeCheck='isTimeCheck' :plan = 'select_Plan' @batchGenerateClicked="handleBatchGenerate"></Table> <Table ref='tableRef1' :id='currentId' :plan = 'select_Plan' @batchGenerateClicked="handleBatchGenerate"></Table>
</div> </div>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
@@ -145,7 +145,6 @@ const tabsHeight = ref('calc(100vh - 522px)') // 初始高度
const tabPaneHeight = ref('calc(100% - 5px)') // 初始高度 const tabPaneHeight = ref('calc(100% - 5px)') // 初始高度
const tableHeight = ref('calc(100% - 50px)') // 初始高度 const tableHeight = ref('calc(100% - 50px)') // 初始高度
const isTimeCheck = ref<boolean>(false)
const planList = ref<ResultData<Plan.ReqPlan[]>>() const planList = ref<ResultData<Plan.ReqPlan[]>>()
const select_Plan = ref<Plan.ReqPlan>() const select_Plan = ref<Plan.ReqPlan>()
const isLabelLineShow = ref(true) const isLabelLineShow = ref(true)
@@ -302,14 +301,7 @@ const getPieData = async (id: string) => {
planName.value = '所选计划:' + plan.name planName.value = '所选计划:' + plan.name
select_Plan.value = plan select_Plan.value = plan
if (plan) {
//isTimeCheck.value = plan.timeCheck === 1; // 将 1 转换为 true0 转换为 false
isTimeCheck.value = false // 将 1 转换为 true0 转换为 false ----目前不用守时检测,先去除
} else {
// 处理未找到计划的情况
isTimeCheck.value = false // 或者其他默认值
}
const pqDevList_Result2 = await getBoundPqDevList({ 'planId': id, 'checkStateList': [0, 1, 2, 3] }) const pqDevList_Result2 = await getBoundPqDevList({ 'planId': id, 'checkStateList': [0, 1, 2, 3] })
boundPqDevList.value = pqDevList_Result2.data as Device.ResPqDev[] boundPqDevList.value = pqDevList_Result2.data as Device.ResPqDev[]
// 遍历 boundPqDevList 并更新计数对象 // 遍历 boundPqDevList 并更新计数对象