预见测
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
<template>
|
||||
<el-button v-if="tableData.length > 0" type="primary" @click="exportData" style="margin-bottom: 10px">导出</el-button>
|
||||
<div class="table-main" max-height="282px">
|
||||
<el-table v-if="tableData.length > 0" :data="tableData" stripe border :header-cell-style="{ textAlign: 'center' } "
|
||||
:cell-style="{ textAlign: 'center' }" max-height="282px"
|
||||
style="width: 100%;">
|
||||
<el-table-column type="index" label="序号" width="70" fixed="left"/>
|
||||
<el-table-column prop="time" label="数据时间"/>
|
||||
<el-table-column v-if="!isThreePhase && phaseA==1" prop="dataA" :label="'A相'+(unit==''?'':'('+unit+')')"/>
|
||||
<el-table-column v-if="!isThreePhase && phaseB==1" prop="dataB" :label="'B相'+(unit==''?'':'('+unit+')')"/>
|
||||
<el-table-column v-if="!isThreePhase && phaseC==1" prop="dataC" :label="'C相'+(unit==''?'':'('+unit+')')"/>
|
||||
<el-table-column v-if="!isThreePhase && phaseT === 1" prop="dataT" :label="tableHeader+(unit==''?'':'('+unit+')')"/>
|
||||
<el-table-column v-if="isThreePhase" prop="dataB" :label="'负序不平衡度'+(unit==''?'':'('+unit+')')"/>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script lang="tsx" setup>
|
||||
import {CheckData} from "@/api/check/interface";
|
||||
import {computed} from "vue";
|
||||
|
||||
const {tableData, currentScriptTypeName} = defineProps<{
|
||||
tableData: CheckData.RawDataItem[]
|
||||
currentScriptTypeName: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits(['exportRawDataHandler'])
|
||||
|
||||
const unit = computed(() => {
|
||||
return tableData.length > 0 ? tableData[0].unit : '';
|
||||
})
|
||||
|
||||
const phaseA = computed(() => {
|
||||
return tableData[0].dataA == '/' ? 0 : 1
|
||||
})
|
||||
const phaseB = computed(() => {
|
||||
return tableData[0].dataB == '/' ? 0 : 1
|
||||
})
|
||||
const phaseC = computed(() => {
|
||||
return tableData[0].dataC == '/' ? 0 : 1
|
||||
})
|
||||
|
||||
const phaseT = computed(() => {
|
||||
return tableData[0].dataT == '/' ? 0 : 1
|
||||
})
|
||||
|
||||
const tableHeader = computed(() => {
|
||||
if (phaseT.value === 1) {
|
||||
let index = currentScriptTypeName.indexOf('=');
|
||||
return currentScriptTypeName.substring(0, index);
|
||||
}
|
||||
return currentScriptTypeName
|
||||
})
|
||||
|
||||
const isThreePhase = computed(() => {
|
||||
return currentScriptTypeName.includes('三相电压不平衡度') || currentScriptTypeName.includes('三相电流不平衡度')
|
||||
})
|
||||
|
||||
const exportData = () => {
|
||||
emit('exportRawDataHandler')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,180 @@
|
||||
<template>
|
||||
|
||||
<div class="table-main">
|
||||
<el-table v-if="tableData.length > 0" :data="tableData" height="357px" :header-cell-style="{ textAlign: 'center' } "
|
||||
:cell-style="{ textAlign: 'center' }">
|
||||
<!-- <el-table-column prop="chnNum" label="通道号" width="80">-->
|
||||
<!-- <template #default="{row}">-->
|
||||
<!-- {{ '通道' + row.chnNum }}-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
<el-table-column label="A相" v-if="phaseA === 1">
|
||||
<el-table-column prop="stdA" :label="'标准值'+(outerUnit==''?'':'('+outerUnit+')')"/>
|
||||
<el-table-column prop="dataA" :label="'被检值'+(outerUnit==''?'':'('+outerUnit+')')"/>
|
||||
<el-table-column prop="isDataA" label="检测结果">
|
||||
<template #default="scope">
|
||||
<el-tooltip effect="dark" placement="bottom">
|
||||
<template #content>
|
||||
误差范围:{{ scope.row.maxErrorA }} <br/>
|
||||
误差值:{{ scope.row.errorA }} {{ scope.row.errorA !== '/' ? innerUnitA : '' }}
|
||||
</template>
|
||||
<el-tag type="success" v-if="scope.row.isDataA === 1">符合</el-tag>
|
||||
<el-tag type="danger" v-if="scope.row.isDataA === 2">不符合</el-tag>
|
||||
<el-tag type="warning" v-if="scope.row.isDataA === 4">/</el-tag>
|
||||
<el-tag type="info" v-if="scope.row.isDataA === 5">-</el-tag>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table-column>
|
||||
<el-table-column label="B相" v-if="phaseB === 1">
|
||||
<el-table-column prop="stdB" :label="'标准值'+(outerUnit==''?'':'('+outerUnit+')')"/>
|
||||
<el-table-column prop="dataB" :label="'被检值'+(outerUnit==''?'':'('+outerUnit+')')"/>
|
||||
<el-table-column prop="isDataB" label="检测结果">
|
||||
<template #default="scope">
|
||||
<el-tooltip effect="dark" placement="bottom">
|
||||
<template #content>
|
||||
误差范围:{{ scope.row.maxErrorB }}<br/>
|
||||
误差值:{{ scope.row.errorB }} {{ scope.row.errorB !== '/' ? innerUnitB : '' }}
|
||||
</template>
|
||||
<el-tag type="success" v-if="scope.row.isDataB === 1">符合</el-tag>
|
||||
<el-tag type="danger" v-if="scope.row.isDataB === 2">不符合</el-tag>
|
||||
<el-tag type="warning" v-if="scope.row.isDataB === 4">/</el-tag>
|
||||
<el-tag type="info" v-if="scope.row.isDataA === 5">-</el-tag>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table-column>
|
||||
<el-table-column label="C相" v-if="phaseC === 1">
|
||||
<el-table-column prop="stdC" :label="'标准值'+(outerUnit==''?'':'('+outerUnit+')')"/>
|
||||
<el-table-column prop="dataC" :label="'被检值'+(outerUnit==''?'':'('+outerUnit+')')"/>
|
||||
<el-table-column prop="isDataC" label="检测结果">
|
||||
<template #default="scope">
|
||||
<el-tooltip effect="dark" placement="bottom">
|
||||
<template #content>
|
||||
误差范围: {{ scope.row.maxErrorC }}<br/>
|
||||
误差值:{{ scope.row.errorC }} {{ scope.row.errorC !== '/' ? innerUnitC : '' }}
|
||||
</template>
|
||||
<el-tag type="success" v-if="scope.row.isDataC === 1">符合</el-tag>
|
||||
<el-tag type="danger" v-if="scope.row.isDataC === 2">不符合</el-tag>
|
||||
<el-tag type="warning" v-if="scope.row.isDataC === 4">/</el-tag>
|
||||
<el-tag type="info" v-if="scope.row.isDataA === 5">-</el-tag>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column :label="tableHeader" v-if="phaseT === 1">
|
||||
<el-table-column prop="stdT" :label="'标准值'+(outerUnit==''?'':'('+outerUnit+')')"/>
|
||||
<el-table-column prop="dataT" :label="'被检值'+(outerUnit==''?'':'('+outerUnit+')')"/>
|
||||
<el-table-column prop="isDataT" label="检测结果">
|
||||
<template #default="scope">
|
||||
<el-tooltip effect="dark" placement="bottom">
|
||||
<template #content>
|
||||
误差范围: {{ scope.row.maxErrorT }}<br/>
|
||||
误差值:{{ scope.row.errorT }} {{ scope.row.errorT !== '/' ? innerUnitT : '' }}
|
||||
</template>
|
||||
<el-tag type="success" v-if="scope.row.isDataT === 1">符合</el-tag>
|
||||
<el-tag type="danger" v-if="scope.row.isDataT === 2">不符合</el-tag>
|
||||
<el-tag type="warning" v-if="scope.row.isDataT === 4">/</el-tag>
|
||||
<el-tag type="info" v-if="scope.row.isDataA === 5">-</el-tag>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script lang="tsx" setup>
|
||||
import {defineProps} from 'vue';
|
||||
import {CheckData} from "@/api/check/interface";
|
||||
|
||||
const {tableData, currentScriptTypeName} = defineProps<{
|
||||
tableData: CheckData.CheckResult[],
|
||||
currentScriptTypeName: string
|
||||
}>();
|
||||
|
||||
|
||||
const outerUnit = computed(() => {
|
||||
return tableData.length > 0 ? tableData[0].unit : '';
|
||||
})
|
||||
|
||||
const innerUnitA = computed(() => {
|
||||
return tableData.length > 0 ? tableData[0].unitA : '';
|
||||
})
|
||||
const innerUnitB = computed(() => {
|
||||
return tableData.length > 0 ? tableData[0].unitB : '';
|
||||
})
|
||||
const innerUnitC = computed(() => {
|
||||
return tableData.length > 0 ? tableData[0].unitC : '';
|
||||
})
|
||||
const innerUnitT = computed(() => {
|
||||
return tableData.length > 0 ? tableData[0].unitT : '';
|
||||
})
|
||||
|
||||
const phaseA = computed(() => {
|
||||
return tableData.length <= 0 || tableData[0].dataA == null || tableData[0].dataA == "/" ? 0 : 1
|
||||
})
|
||||
const phaseB = computed(() => {
|
||||
return tableData.length <= 0 || tableData[0].dataB == null || tableData[0].dataB == "/" ? 0 : 1
|
||||
})
|
||||
const phaseC = computed(() => {
|
||||
return tableData.length <= 0 || tableData[0].dataC == null || tableData[0].dataC == "/" ? 0 : 1
|
||||
})
|
||||
|
||||
const phaseT = computed(() => {
|
||||
return tableData.length <= 0 || tableData[0].dataT == null || tableData[0].dataT == "/" ? 0 : 1
|
||||
})
|
||||
|
||||
const tableHeader = computed(() => {
|
||||
if (phaseT.value === 1) {
|
||||
let index = currentScriptTypeName.indexOf('=');
|
||||
return currentScriptTypeName.substring(0, index);
|
||||
}
|
||||
return currentScriptTypeName
|
||||
})
|
||||
|
||||
// const maxErrorStr = computed((data) => {
|
||||
// let result = tableData[0].maxError ?? '/'
|
||||
// let idx = result.indexOf('~');
|
||||
// if (idx > 0) {
|
||||
// result = result.substring(0, idx) + outerUnit.value + result.substring(idx, result.length) + outerUnit.value;
|
||||
// }
|
||||
// return result;
|
||||
// })
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
.form-grid {
|
||||
display: flex;
|
||||
flex-direction: row; /* 横向排列 */
|
||||
flex-wrap: wrap; /* 允许换行 */
|
||||
}
|
||||
|
||||
.form-grid .el-form-item {
|
||||
flex: 1 1 30%; /* 控件宽度 */
|
||||
margin-right: 20px; /* 控件间距 */
|
||||
}
|
||||
|
||||
.form-grid .el-form-item:last-child {
|
||||
margin-right: 0; /* 最后一个控件不需要右边距 */
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
margin-bottom: 10px; /* 调整这里的值以增加或减少间距 */
|
||||
}
|
||||
|
||||
.el-tabs {
|
||||
margin-bottom: 20px; /* 添加底部边距 */
|
||||
}
|
||||
|
||||
.el-table th, .el-table td {
|
||||
text-align: center; /* 所有单元格文字居中 */
|
||||
}
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,702 @@
|
||||
<template>
|
||||
<el-dialog :append-to-body="appendToBody" class="dialog" title="数据查询" :model-value='visible' @close="close"
|
||||
v-bind="dialogBig" :draggable="false" width="1400px">
|
||||
<div class="data-check-dialog">
|
||||
<div class="data-check-head">
|
||||
<el-form :model='formContent' label-width="auto" class="form-three ">
|
||||
<el-form-item label="误差体系">
|
||||
<el-select :disabled="checkStore.showDetailType===2 || checkStore.showDetailType===0" v-model="formContent.errorSysId" placeholder="请选择误差体系" autocomplete="off"
|
||||
@change="handleErrorSysChange">
|
||||
<el-option
|
||||
v-for="(option) in pqErrorList"
|
||||
:key="option.id"
|
||||
:label="option.name"
|
||||
:value="option.id"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="数据原则">
|
||||
<el-input v-model='formContent.dataRule' :disabled="true"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备名称">
|
||||
<el-input v-model='formContent.deviceName' :disabled="true"/>
|
||||
</el-form-item>
|
||||
<el-form-item label='通道号'>
|
||||
<el-select v-model="formContent.chnNum">
|
||||
<el-option v-for="item in chnList" :key="item.value" :label="item.label" :value="item.value"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="checkStore.showDetailType===1">
|
||||
<el-button type="primary" :icon="Postcard" @click="handleGenerateReport">报告生成</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="checkStore.showDetailType===0">
|
||||
<el-button type="primary" :icon="Histogram" @click="handleReCalculate">重新计算</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="data-check-body">
|
||||
<div class="content-right">
|
||||
<div class="content-right-title">
|
||||
<el-form-item label='测试项'>
|
||||
<el-cascader
|
||||
v-model="currentCheckItem"
|
||||
:options="checkListLevel"
|
||||
:props="{expandTrigger: 'click' as const}"
|
||||
placement="bottom-end"
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="content-right-Tabs">
|
||||
<el-tabs type="border-card" v-model="activeTab">
|
||||
<el-tab-pane label="检测结果" name="resultTab">
|
||||
<CompareDataCheckResultTable :tableData="checkResultData" :currentScriptTypeName="currentScriptTypeName"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="原始数据" name="rawDataTab">
|
||||
<CompareDataCheckRawDataTable :tableData="rawTableData" :currentScriptTypeName="currentScriptTypeName" @exportRawDataHandler="exportRawDataHandler"/>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
</template>
|
||||
<script setup lang='ts'>
|
||||
import {dialogBig} from '@/utils/elementBind'
|
||||
import {reactive, ref, watch} from 'vue'
|
||||
import CompareDataCheckResultTable from './compareDataCheckResultTable.vue'
|
||||
import CompareDataCheckRawDataTable from './compareDataCheckRawDataTable.vue'
|
||||
import {CheckData} from "@/api/check/interface";
|
||||
import {useCheckStore} from "@/stores/modules/check";
|
||||
import {changeErrorSystem, deleteTempTable, exportRawData, getFormData, getTableData, getTreeData, reCalculate} from "@/api/check/test";
|
||||
import {generateDevReport, getPqErrSysList} from '@/api/plan/plan'
|
||||
import {useDownload} from "@/hooks/useDownload";
|
||||
import {Histogram, Postcard} from "@element-plus/icons-vue";
|
||||
import {ResultEnum} from "@/enums/httpEnum";
|
||||
import {ElMessage} from "element-plus";
|
||||
|
||||
const {appendToBody} = withDefaults(defineProps<{
|
||||
appendToBody: boolean
|
||||
}>(), {appendToBody: true})
|
||||
|
||||
|
||||
const checkStore = useCheckStore()
|
||||
|
||||
const visible = ref(false)
|
||||
const treeRef = ref()
|
||||
const searchValue = ref<string>('')
|
||||
const pqErrorList = reactive<{ id: string; name: string; }[]>([])
|
||||
watch(searchValue, (val) => {
|
||||
treeRef.value!.filter(val)
|
||||
})
|
||||
|
||||
// 表单数据
|
||||
const formContent = reactive<CheckData.DataCheck>({
|
||||
scriptName: '',
|
||||
errorSysId: '',
|
||||
dataRule: '',
|
||||
deviceName: '',
|
||||
chnNum: '',
|
||||
})
|
||||
// 原始误差体系id
|
||||
let originErrorSysId: string = ''
|
||||
let planCode: string = ''
|
||||
// 当前选中的检测项
|
||||
const currentCheckItem = ref<any>()
|
||||
|
||||
// 带有层级的检测项列表
|
||||
const checkListLevel = reactive<{ value: string, label: string, children: { value: string, label: string }[] }[]>([])
|
||||
|
||||
let deviceId: string = ''
|
||||
let originScriptType: string | null = null
|
||||
let scriptType: string | null = null
|
||||
|
||||
// 通道下拉列表
|
||||
let chnList: any[] = []
|
||||
|
||||
|
||||
// 左侧树数据
|
||||
const treeDataAll = reactive<CheckData.TreeItem[]>([])
|
||||
|
||||
// 左侧树被选中的叶子节点id
|
||||
const checkIndex = ref<string>('')
|
||||
|
||||
// 当前检测项目名称
|
||||
const currentScriptTypeName = ref('')
|
||||
// 当前检测项目描述
|
||||
const currentDesc = ref('');
|
||||
// 右侧Tab选中项
|
||||
const activeTab = ref<string>('resultTab')
|
||||
|
||||
//存放相应的表格数据
|
||||
const resTableData = reactive<{ resultData: Map<string, any>, rawData: Map<string, any> }>({resultData: new Map(), rawData: new Map()})
|
||||
|
||||
// 检测结果表格数据
|
||||
const checkResultData = reactive<CheckData.CheckResult[]>([])
|
||||
|
||||
|
||||
// 原始数据表格数据
|
||||
const rawTableData = reactive<CheckData.RawDataItem[]>([])
|
||||
|
||||
|
||||
|
||||
const handleErrorSysChange = async () => {
|
||||
console.log("切换误差体系", formContent.errorSysId);
|
||||
changeErrorSystem({
|
||||
planId: checkStore.plan.id,
|
||||
scriptId: checkStore.plan.scriptId,
|
||||
errorSysId: formContent.errorSysId,
|
||||
deviceId: deviceId,
|
||||
code: checkStore.plan.code + '',
|
||||
}).then((res) => {
|
||||
if (res.code === ResultEnum.SUCCESS) {
|
||||
ElMessage.success('切换误差体系成功')
|
||||
if (originErrorSysId != formContent.errorSysId) {
|
||||
planCode = checkStore.plan.code + "_temp"
|
||||
} else {
|
||||
planCode = checkStore.plan.code + ''
|
||||
}
|
||||
if (formContent.chnNum != chnList[0].value) {
|
||||
formContent.chnNum = chnList[0].value
|
||||
} else {
|
||||
handleChnNumChange()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
watch(() => formContent.chnNum, async (newVal, oldVal) => {
|
||||
// console.log("通道号", newVal);
|
||||
if (newVal != '') {
|
||||
handleChnNumChange()
|
||||
}
|
||||
})
|
||||
|
||||
const handleChnNumChange = async () => {
|
||||
console.log("通道号", formContent.chnNum);
|
||||
// 发起请求,查询该测试项的检测结果
|
||||
const {data: resTreeDataTemp}: { data: CheckData.TreeItem[] } = await getTreeData({
|
||||
scriptId: checkStore.plan.scriptId,
|
||||
devId: deviceId,
|
||||
devNum: formContent.chnNum + '',
|
||||
scriptType: originScriptType,
|
||||
code: planCode
|
||||
})
|
||||
updateTreeFly(resTreeDataTemp, 4)
|
||||
updateTreeFly(resTreeDataTemp, 2)
|
||||
|
||||
treeDataAll.length = 0
|
||||
|
||||
Object.assign(treeDataAll, resTreeDataTemp)
|
||||
|
||||
defaultOperate()
|
||||
await updateTableData()
|
||||
activeTab.value = 'resultTab'
|
||||
}
|
||||
|
||||
|
||||
watch(currentCheckItem, (newVal, oldVal) => {
|
||||
if (newVal !== '') {
|
||||
let key = newVal[0]
|
||||
if (newVal.length == 2) {
|
||||
key += "_" + newVal[1]
|
||||
}
|
||||
console.log("当前检测项", key);
|
||||
doCurrentCheckItemUpdate(key)
|
||||
} else {
|
||||
activeTab.value = 'resultTab'
|
||||
}
|
||||
})
|
||||
|
||||
// 默认操作
|
||||
const defaultOperate = () => {
|
||||
let node = getDefaultNode(treeDataAll)
|
||||
|
||||
if (node) {
|
||||
currentScriptTypeName.value = node.scriptTypeName
|
||||
currentDesc.value = node.sourceDesc
|
||||
checkIndex.value = node.index
|
||||
defaultExpandedKeys = [node.index]
|
||||
|
||||
treeRef.value?.setCurrentKey(node.index);
|
||||
scriptType = node.scriptType ?? scriptType
|
||||
} else {
|
||||
currentScriptTypeName.value = ''
|
||||
currentDesc.value = ''
|
||||
checkIndex.value = ''
|
||||
defaultExpandedKeys = []
|
||||
}
|
||||
}
|
||||
|
||||
const updateTableData = async () => {
|
||||
console.log("左侧树被选中的叶子节点checkIndex", checkIndex.value);
|
||||
if (checkIndex.value !== '') {
|
||||
|
||||
checkListLevel.length = 0
|
||||
checkResultData.length = 0
|
||||
rawTableData.length = 0
|
||||
currentCheckItem.value = ''
|
||||
|
||||
// console.log("更新表格数据");
|
||||
// 发起请求,查询该测试项的检测结果
|
||||
const {data} = await getTableData({
|
||||
scriptType,
|
||||
scriptId: checkStore.plan.scriptId,
|
||||
devId: deviceId,
|
||||
devNum: formContent.chnNum + '',
|
||||
code: planCode,
|
||||
index: parseInt(checkIndex.value),
|
||||
})
|
||||
|
||||
let keys1 = Object.keys(data.resultData)
|
||||
let resultData = new Map()
|
||||
for (let key of keys1) {
|
||||
let children = []
|
||||
let label = key
|
||||
if ((key.includes('谐波') || key.includes('简谐波')) && key !== '谐波有功功率') {
|
||||
for (let item of data.resultData[key]) {
|
||||
let num = formatHarmNum(item.harmNum + '')
|
||||
label = item.isData === 1 ? `${num}` : item.isData === 4 ? `${num}(/)` : item.isData === 5 ? `${num}(-)` : `${num}(不符合)`
|
||||
children.push({label: label, value: num})
|
||||
resultData.set(key + "_" + num, item)
|
||||
}
|
||||
checkListLevel.push({label: key, value: key, children: children})
|
||||
} else {
|
||||
label = data.resultData[key][0].isData === 1 ? `${key}` : data.resultData[key][0].isData === 4 ? `${key}(/)` : data.resultData[key][0].isData === 5 ? `${key}(-)` : `${key}(不符合)`
|
||||
resultData.set(key, data.resultData[key][0])
|
||||
checkListLevel.push({label: label, value: key, children: []})
|
||||
let temp = checkListLevel.find(item => item.label.includes('电压幅值'))
|
||||
if (temp) {
|
||||
checkListLevel.splice(checkListLevel.indexOf(temp), 1)
|
||||
checkListLevel.unshift(temp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let keys2 = Object.keys(data.rawData)
|
||||
let rawData = new Map()
|
||||
for (let key of keys2) {
|
||||
if ((key.includes('谐波') || key.includes('简谐波')) && key !== '谐波有功功率') {
|
||||
for (let item of data.rawData[key]) {
|
||||
let num = formatHarmNum(item.harmNum + '')
|
||||
let value = rawData.get(key + "_" + num)
|
||||
if (!value) {
|
||||
rawData.set(key + "_" + num, [item])
|
||||
} else {
|
||||
value.push(item)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rawData.set(key, data.rawData[key])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
resTableData.resultData = resultData
|
||||
resTableData.rawData = rawData
|
||||
|
||||
toAngleLast()
|
||||
|
||||
if (checkListLevel.length !== 0) {
|
||||
if (checkListLevel[0].children.length !== 0) {
|
||||
currentCheckItem.value = [checkListLevel[0].value + '', checkListLevel[0].children[0].value + '']
|
||||
} else {
|
||||
currentCheckItem.value = [checkListLevel[0].value + '']
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
checkResultData.length = 0
|
||||
rawTableData.length = 0
|
||||
}
|
||||
}
|
||||
|
||||
const doCurrentCheckItemUpdate = (newVal: string) => {
|
||||
let resCheckResult: CheckData.ResCheckResult = resTableData.resultData.get(newVal)
|
||||
setCheckResultData(resCheckResult)
|
||||
|
||||
let tempRawData = resTableData.rawData.get(newVal)
|
||||
if (tempRawData) {
|
||||
setRawData(tempRawData)
|
||||
} else {
|
||||
setRawData([])
|
||||
}
|
||||
|
||||
activeTab.value = 'resultTab'
|
||||
}
|
||||
|
||||
const open = async (_deviceId: string, chnNum: string, _scriptType: string | null) => {
|
||||
planCode = checkStore.plan.code + ''
|
||||
deviceId = _deviceId
|
||||
originScriptType = _scriptType
|
||||
scriptType = _scriptType
|
||||
|
||||
// // 发起后端请求,查询详细信息 当chnNum为-1时,查询所有通道号
|
||||
// const {data: resFormContent}: { data: any } = await getFormData({
|
||||
// planId: checkStore.plan.id,
|
||||
// deviceId,
|
||||
// chnNum,
|
||||
// scriptType
|
||||
// })
|
||||
|
||||
// chnList = resFormContent.chnList.map((item: { value: string, label: string }) => ({
|
||||
// value: item.value,
|
||||
// label: item.value
|
||||
// //label: item.label == '1' ? `${item.value}` : item.label == '2' ? `${item.value}(不符合)` : `${item.value}`
|
||||
// }))
|
||||
|
||||
// Object.assign(formContent, {
|
||||
// ...resFormContent,
|
||||
// chnNum: chnList.length > 0 ? chnList[0].value : '',
|
||||
// })
|
||||
// originErrorSysId = formContent.errorSysId
|
||||
|
||||
// pqErrorList.length = 0
|
||||
// let {data: resPqErrorList} = await getPqErrSysList()
|
||||
// Object.assign(pqErrorList, resPqErrorList)
|
||||
|
||||
visible.value = true;
|
||||
}
|
||||
|
||||
const handleGenerateReport = async () => {
|
||||
await generateDevReport({'planId': checkStore.plan.id, 'devIdList': [deviceId],'scriptId':checkStore.plan.scriptId,'planCode':planCode})
|
||||
ElMessage.success({message: `报告生成成功!`})
|
||||
}
|
||||
|
||||
const handleReCalculate = async () => {
|
||||
reCalculate({
|
||||
planId: checkStore.plan.id,
|
||||
scriptId: checkStore.plan.scriptId,
|
||||
errorSysId: formContent.errorSysId,
|
||||
deviceId: deviceId,
|
||||
code: checkStore.plan.code + ''
|
||||
}).then((res) => {
|
||||
ElMessage.success('重新计算成功!')
|
||||
// if (originErrorSysId != formContent.errorSysId) {
|
||||
// planCode = checkStore.plan.code + "_temp"
|
||||
// } else {
|
||||
// planCode = checkStore.plan.code + ''
|
||||
// }
|
||||
if (formContent.chnNum != chnList[0].value) {
|
||||
formContent.chnNum = chnList[0].value
|
||||
} else {
|
||||
handleChnNumChange()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const close = async () => {
|
||||
//数据清空
|
||||
Object.assign(formContent, {
|
||||
scriptName: '',
|
||||
errorSysName: '',
|
||||
dataRule: '',
|
||||
deviceName: '',
|
||||
chnNum: '',
|
||||
})
|
||||
treeDataAll.length = 0
|
||||
// harmNumList.length = 0
|
||||
// currentHarmNum.value = '-1'
|
||||
currentCheckItem.value = ''
|
||||
checkResultData.length = 0
|
||||
rawTableData.length = 0
|
||||
//checkList.length = 0
|
||||
defaultExpandedKeys = []
|
||||
checkIndex.value = ''
|
||||
activeTab.value = 'resultTab'
|
||||
currentScriptTypeName.value = ''
|
||||
currentDesc.value = ''
|
||||
pqErrorList.length = 0
|
||||
planCode = ''
|
||||
|
||||
visible.value = false;
|
||||
|
||||
if (checkStore.showDetailType === 1) {
|
||||
await deleteTempTable(checkStore.plan.code + '')
|
||||
}
|
||||
};
|
||||
|
||||
const setCheckResultData = (data: CheckData.ResCheckResult | null) => {
|
||||
let result: CheckData.CheckResult[] = []
|
||||
if (data == null || data == undefined) {
|
||||
Object.assign(checkResultData, [])
|
||||
return
|
||||
}
|
||||
if (data.dataA != null && data.dataB != null && data.dataC != null) {
|
||||
result.push({
|
||||
// stdA: numberToFixed(data.dataA.resultData),
|
||||
// dataA: numberToFixed(data.dataA.data),
|
||||
stdA: dataToShow(data.dataA.resultData),
|
||||
dataA: dataToShow(data.dataA.data),
|
||||
errorA: data.dataA.errorData == null ? '/' : data.dataA.errorData + '',
|
||||
maxErrorA: toMaxErrorStr(data.dataA.radius, data.dataA.unit),
|
||||
unitA: data.dataA.unit,
|
||||
isDataA: data.dataA.isData,
|
||||
// stdB: numberToFixed(data.dataB.resultData),
|
||||
// dataB: numberToFixed(data.dataB.data),
|
||||
stdB: dataToShow(data.dataB.resultData),
|
||||
dataB: dataToShow(data.dataB.data),
|
||||
errorB: data.dataB.errorData == null ? '/' : data.dataB.errorData + '',
|
||||
maxErrorB: toMaxErrorStr(data.dataB.radius, data.dataB.unit),
|
||||
isDataB: data.dataB.isData,
|
||||
unitB: data.dataB.unit,
|
||||
// stdC: numberToFixed(data.dataC.resultData),
|
||||
// dataC: numberToFixed(data.dataC.data),
|
||||
stdC: dataToShow(data.dataC.resultData),
|
||||
dataC: dataToShow(data.dataC.data),
|
||||
errorC: data.dataC.errorData == null ? '/' : data.dataC.errorData + '',
|
||||
maxErrorC: toMaxErrorStr(data.dataC.radius, data.dataC.unit),
|
||||
isDataC: data.dataC.isData,
|
||||
unitC: data.dataC.unit,
|
||||
|
||||
maxError: data.radius,
|
||||
unit: data.unit,
|
||||
result: data.isData,
|
||||
})
|
||||
}
|
||||
|
||||
if (data.dataT != null && data.dataA == null && data.dataB == null && data.dataC == null) {
|
||||
result.push({
|
||||
// stdT: numberToFixed(data.dataT.resultData),
|
||||
// dataT: numberToFixed(data.dataT.data),
|
||||
stdT: dataToShow(data.dataT.resultData),
|
||||
dataT: dataToShow(data.dataT.data),
|
||||
errorT: data.dataT.errorData == null ? '/' : data.dataT.errorData + '',
|
||||
maxErrorT: toMaxErrorStr(data.dataT.radius, data.dataT.unit),
|
||||
isDataT: data.dataT?.isData,
|
||||
unitT: data.dataT.unit,
|
||||
|
||||
maxError: data.radius,
|
||||
unit: data.unit,
|
||||
result: data.isData,
|
||||
})
|
||||
}
|
||||
Object.assign(checkResultData, result)
|
||||
console.log("检测结果", checkResultData);
|
||||
}
|
||||
|
||||
const exportRawDataHandler = () => {
|
||||
useDownload(exportRawData, '原始数据', {
|
||||
scriptType,
|
||||
scriptId: checkStore.plan.scriptId,
|
||||
devId: deviceId,
|
||||
devNum: formContent.chnNum + '',
|
||||
code: checkStore.plan.code + '',
|
||||
index: parseInt(checkIndex.value),
|
||||
}, false, '.xlsx')
|
||||
}
|
||||
|
||||
const formatHarmNum = (num: string) => {
|
||||
// debugger
|
||||
if (num.includes('.5')) {
|
||||
return num
|
||||
} else {
|
||||
num = num.replace('.0', '')
|
||||
return num
|
||||
}
|
||||
}
|
||||
|
||||
const setRawData = (data: CheckData.RawDataItem[]) => {
|
||||
data.forEach((item: CheckData.RawDataItem) => {
|
||||
item.dataA = dataToShow(item.dataA)
|
||||
item.dataB = dataToShow(item.dataB)
|
||||
item.dataC = dataToShow(item.dataC)
|
||||
item.dataT = dataToShow(item.dataT)
|
||||
})
|
||||
rawTableData.length = 0
|
||||
Object.assign(rawTableData, data)
|
||||
console.log("原始数据", rawTableData)
|
||||
}
|
||||
const dataToShow = (num: number): string => {
|
||||
if (num == null || num == undefined) {
|
||||
return '/'
|
||||
}
|
||||
return num+''
|
||||
}
|
||||
|
||||
|
||||
const toMaxErrorStr = (oldMaxErroe: any, unit: any) => {
|
||||
let result = oldMaxErroe ?? '/'
|
||||
let idx = result.indexOf('~');
|
||||
if (idx > 0) {
|
||||
let left = result.substring(0, idx)
|
||||
let right = result.substring(idx, result.length)
|
||||
result = left + unit + right + unit;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
const findFirstLeafNode = (node: any): any => {
|
||||
if (!node.children || node.children.length === 0) {
|
||||
return node;
|
||||
}
|
||||
|
||||
return findFirstLeafNode(node.children[0]);
|
||||
}
|
||||
const getDefaultNode = (data: any[]) => {
|
||||
if (!data || data.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const firstElement = data[0];
|
||||
|
||||
return findFirstLeafNode(firstElement);
|
||||
}
|
||||
|
||||
const toAngleLast = () => {
|
||||
let angleIndex = -1
|
||||
for (let i = 0; i < checkListLevel.length; i++) {
|
||||
if (checkListLevel[i].value.toString().includes('相角')) {
|
||||
angleIndex = i
|
||||
break
|
||||
}
|
||||
}
|
||||
if (angleIndex != -1) {
|
||||
let temp = checkListLevel[angleIndex]
|
||||
checkListLevel.splice(angleIndex, 1)
|
||||
checkListLevel.push(temp)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
const filter = (treeData: any[], fly: number) => {
|
||||
for (let i = treeData.length - 1; i >= 0; i--) {
|
||||
let node = treeData[i]
|
||||
if (node.fly !== fly) {
|
||||
if (node.children && node.children.length > 0) {
|
||||
filter(node.children, fly)
|
||||
// 检查 children 是否被全部移除
|
||||
if (node.children.length === 0) {
|
||||
treeData.splice(i, 1);
|
||||
}
|
||||
} else {
|
||||
treeData.splice(i, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const updateTreeFly = (treeData: any[], fly: number) => {
|
||||
// 递归函数
|
||||
function recursiveUpdate(node: any, targetFly: number) {
|
||||
//if (!node) return false; // 如果节点不存在,返回 false
|
||||
|
||||
// 如果当前节点是叶子节点且 fly 字段等于 targetFly
|
||||
if (!node.children || node.children.length === 0) {
|
||||
if (node.fly === targetFly) {
|
||||
node.fly = targetFly; // 确保叶子节点的 fly 字段被设置为 targetFly
|
||||
return true; // 返回 true 表示找到并更新了
|
||||
}
|
||||
return false; // 否则返回 false
|
||||
}
|
||||
|
||||
// 递归更新子节点
|
||||
let updated = false;
|
||||
for (let child of node.children) {
|
||||
if (recursiveUpdate(child, targetFly)) {
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果有子节点被更新了,则更新当前节点的 fly 字段
|
||||
if (updated) {
|
||||
node.fly = targetFly;
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
|
||||
for (let i = 0; i < treeData.length; i++) {
|
||||
// 调用递归函数从根节点开始更新
|
||||
recursiveUpdate(treeData[i], fly);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
defineExpose({
|
||||
open
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.dialog {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow-y: hidden;
|
||||
overflow-x: hidden;
|
||||
|
||||
|
||||
.data-check-dialog {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow-y: hidden;
|
||||
|
||||
.data-check-head {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.data-check-body {
|
||||
height: 500px;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
.content-left-tree {
|
||||
width: 18%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
max-height: 495px;
|
||||
|
||||
padding: 10px 0.5% 0px 0.5%;
|
||||
border: 1px solid #ccc;
|
||||
overflow-y: auto;
|
||||
overflow-x: auto;
|
||||
|
||||
.content-tree {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin-top: 10px;
|
||||
|
||||
.custom-tree-node {
|
||||
overflow-x: hidden !important;
|
||||
white-space: nowrap !important;
|
||||
text-overflow: ellipsis !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.content-right {
|
||||
width: 82%;
|
||||
margin-left: 10px;
|
||||
flex: 1;
|
||||
|
||||
.content-right-title {
|
||||
display: flex;
|
||||
padding: 10px 0;
|
||||
margin-top: 10px;
|
||||
line-height: 1.5;
|
||||
|
||||
.content-right-title-text {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.content-right-Tabs {
|
||||
box-sizing: border-box;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
max-height: 400px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -87,11 +87,11 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<RealTimeData ref="realTimeDataRef"/>
|
||||
<RealTimeData ref="realTimeDataRef" />
|
||||
</template>
|
||||
<script lang="tsx" setup name="preTest">
|
||||
import {ElMessage, ElMessageBox, StepProps} from "element-plus";
|
||||
import {defineExpose, ref, toRef, watch} from 'vue';
|
||||
import {defineExpose, PropType, ref, toRef, watch} from 'vue';
|
||||
import RealTimeData from './realTimeDataAlign.vue'
|
||||
|
||||
const realTimeDataRef = ref()
|
||||
@@ -183,6 +183,10 @@ const props = defineProps({
|
||||
webMsgSend: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
mapping: {
|
||||
type: Object as PropType<Record<string, Record<string, string>>>,
|
||||
default: () => ({})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -192,7 +196,10 @@ const webMsgSend = toRef(props, 'webMsgSend');
|
||||
const ts = ref('');
|
||||
|
||||
watch(webMsgSend, function (newValue, oldValue) {
|
||||
console.log('newValue.requestId', newValue.requestId)
|
||||
console.log('testStatus.value', testStatus.value)
|
||||
if (testStatus.value !== 'waiting') {
|
||||
console.log('newValue.requestId', newValue.requestId)
|
||||
switch (newValue.requestId) {
|
||||
case 'yjc_sbtxjy':
|
||||
switch (newValue.operateCode) {
|
||||
@@ -227,7 +234,7 @@ watch(webMsgSend, function (newValue, oldValue) {
|
||||
step6.value = 'error'
|
||||
} else if (newValue.code == 10552) {
|
||||
//ElMessage.error("存在已经初始化步骤,已经自动关闭,请重新发起检测!")
|
||||
step2InitLog.value = [{
|
||||
step1InitLog.value = [{
|
||||
type: 'wait',
|
||||
log: '存在已经初始化步骤,执行自动关闭,请重新发起检测!',
|
||||
}];
|
||||
@@ -491,7 +498,7 @@ watch(webMsgSend, function (newValue, oldValue) {
|
||||
log: '源服务端连接失败!',
|
||||
}];
|
||||
ts.value = 'error'
|
||||
step5.value = 'error'
|
||||
step6.value = 'error'
|
||||
break;
|
||||
case "Dev":
|
||||
step2.value = 'error'
|
||||
@@ -500,7 +507,7 @@ watch(webMsgSend, function (newValue, oldValue) {
|
||||
log: '设备服务端连接失败!',
|
||||
}];
|
||||
ts.value = 'error'
|
||||
step5.value = 'error'
|
||||
step6.value = 'error'
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -513,7 +520,7 @@ watch(webMsgSend, function (newValue, oldValue) {
|
||||
type: 'error',
|
||||
})
|
||||
ts.value = 'error'
|
||||
step5.value = 'error'
|
||||
step6.value = 'error'
|
||||
break;
|
||||
case 'socket_timeout':
|
||||
ElMessageBox.alert(`设备连接异常,请检查设备连接情况!`, '检测失败', {
|
||||
@@ -521,7 +528,7 @@ watch(webMsgSend, function (newValue, oldValue) {
|
||||
type: 'error',
|
||||
})
|
||||
ts.value = 'error'
|
||||
step5.value = 'error'
|
||||
step6.value = 'error'
|
||||
break;
|
||||
case 'server_error':
|
||||
ElMessageBox.alert('服务端主动关闭连接!', '初始化失败', {
|
||||
@@ -529,7 +536,7 @@ watch(webMsgSend, function (newValue, oldValue) {
|
||||
type: 'error',
|
||||
})
|
||||
ts.value = 'error'
|
||||
step5.value = 'error'
|
||||
step6.value = 'error'
|
||||
break;
|
||||
case 'device_error':
|
||||
ElMessageBox.alert('设备主动关闭连接!', '初始化失败', {
|
||||
@@ -537,7 +544,7 @@ watch(webMsgSend, function (newValue, oldValue) {
|
||||
type: 'error',
|
||||
})
|
||||
ts.value = 'error'
|
||||
step5.value = 'error'
|
||||
step6.value = 'error'
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -622,7 +629,7 @@ function initializeParameters() {
|
||||
}
|
||||
|
||||
const openDialog = () => {
|
||||
realTimeDataRef.value.open()
|
||||
realTimeDataRef.value.open(props.mapping)
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
|
||||
@@ -35,8 +35,9 @@
|
||||
: row.devices[index1].chnResult[index2].icon==='WarnTriangleFilled' ? '数据异常'
|
||||
: row.devices[index1].chnResult[index2].icon==='Loading'? '检测中':'连接中断'"
|
||||
placement="right">
|
||||
<!-- :disabled="row.devices[index1].chnResult[index2].color===CheckData.ButtonColorEnum.INFO || row.devices[index1].chnResult[index2].color===CheckData.ButtonColorEnum.LOADING" -->
|
||||
<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)"
|
||||
@@ -72,13 +73,13 @@
|
||||
</el-drawer>
|
||||
</div>
|
||||
|
||||
<dataCheckSingleChannelSingleTestPopup ref="dataCheckSingleChannelSingleTestPopupRef"/>
|
||||
<CompareDataCheckSingleChannelSingleTestPopup ref="dataCheckSingleChannelSingleTestPopupRef"/>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="tsx" setup name="test">
|
||||
import {InfoFilled, Loading} from '@element-plus/icons-vue'
|
||||
import dataCheckSingleChannelSingleTestPopup from './dataCheckSingleChannelSingleTestPopup.vue'
|
||||
import {computed, reactive, ref, toRef, watch} from "vue";
|
||||
import CompareDataCheckSingleChannelSingleTestPopup from './compareDataCheckSingleChannelSingleTestPopup.vue'
|
||||
import {computed, onBeforeMount, reactive, ref, toRef, watch} from "vue";
|
||||
import {dialogBig} from "@/utils/elementBind";
|
||||
import {CheckData} from "@/api/check/interface"
|
||||
import {useCheckStore} from "@/stores/modules/check";
|
||||
@@ -942,40 +943,40 @@ const getResult = (devices: CheckData.DeviceCheckResult[] = []) => {
|
||||
|
||||
// 点击查看(设备)通道检测详情。参数1:设备信息,参数2:通道号,-1:代表查看全部通道
|
||||
const handleClick = (item: any, chnNum: number, scriptType: string) => {
|
||||
let checkResultItem = checkResult.find(obj => obj.scriptType === scriptType)
|
||||
let flag = -1
|
||||
if (checkResultItem) {
|
||||
let device = checkResultItem.devices.find(obj => obj.deviceId === item.deviceId)
|
||||
if (device) {
|
||||
let chnResult = device.chnResult
|
||||
if (chnNum === -1) {
|
||||
if (chnResult.findIndex(obj => obj === CheckData.ChnCheckResultEnum.TIMEOUT) !== -1) {
|
||||
flag = 0
|
||||
}
|
||||
if (chnResult.findIndex(obj => obj === CheckData.ChnCheckResultEnum.ERRORDATA) !== -1) {
|
||||
flag = 1
|
||||
}
|
||||
} else {
|
||||
if (chnResult[chnNum - 1] === CheckData.ChnCheckResultEnum.TIMEOUT) {
|
||||
flag = 0
|
||||
}
|
||||
if (chnResult[chnNum - 1] === CheckData.ChnCheckResultEnum.ERRORDATA) {
|
||||
flag = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// let checkResultItem = checkResult.find(obj => obj.scriptType === scriptType)
|
||||
// let flag = -1
|
||||
// if (checkResultItem) {
|
||||
// let device = checkResultItem.devices.find(obj => obj.deviceId === item.deviceId)
|
||||
// if (device) {
|
||||
// let chnResult = device.chnResult
|
||||
// if (chnNum === -1) {
|
||||
// if (chnResult.findIndex(obj => obj === CheckData.ChnCheckResultEnum.TIMEOUT) !== -1) {
|
||||
// flag = 0
|
||||
// }
|
||||
// if (chnResult.findIndex(obj => obj === CheckData.ChnCheckResultEnum.ERRORDATA) !== -1) {
|
||||
// flag = 1
|
||||
// }
|
||||
// } else {
|
||||
// if (chnResult[chnNum - 1] === CheckData.ChnCheckResultEnum.TIMEOUT) {
|
||||
// flag = 0
|
||||
// }
|
||||
// if (chnResult[chnNum - 1] === CheckData.ChnCheckResultEnum.ERRORDATA) {
|
||||
// flag = 1
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if (flag === 0) {
|
||||
ElMessageBox.alert('连接超时,请检查设备通讯是否正常', '连接超时', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
if (flag === -1 || flag === 1) {
|
||||
checkStore.setShowDetailType(2)
|
||||
// if (flag === 0) {
|
||||
// ElMessageBox.alert('连接超时,请检查设备通讯是否正常', '连接超时', {
|
||||
// confirmButtonText: '确定',
|
||||
// type: 'warning',
|
||||
// })
|
||||
// }
|
||||
// if (flag === -1 || flag === 1) {
|
||||
// checkStore.setShowDetailType(2)
|
||||
dataCheckSingleChannelSingleTestPopupRef.value?.open(item.deviceId, chnNum + '', scriptType);
|
||||
}
|
||||
//}
|
||||
};
|
||||
|
||||
// todo 可移除
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
</div>
|
||||
|
||||
<ComparePreTest v-if="showComponent&&preTestSelected" v-show="preTestSelected && stepsActiveView==1" ref="preTestRef" v-model:testStatus="preTestStatus"
|
||||
:webMsgSend="webMsgSend"/>
|
||||
:webMsgSend="webMsgSend" :mapping = "channelMapping"/>
|
||||
<CompareTest v-if="showComponent&&testSelected" ref="testRef" v-show="testSelected && stepsActiveView==2" v-model:testStatus="TestStatus"
|
||||
:stepsActive="stepsActive"/>
|
||||
<template #footer>
|
||||
@@ -66,7 +66,7 @@ import ComparePreTest from './comparePreTest.vue'
|
||||
import CompareTest from './compareTest.vue'
|
||||
import socketClient from '@/utils/webSocketClient';
|
||||
import {useCheckStore} from "@/stores/modules/check";
|
||||
import {pauseTest, resumeTest, startPreTest} from '@/api/socket/socket'
|
||||
import {pauseTest, resumeTest, startPreTest,contrastTest} from '@/api/socket/socket'
|
||||
import {useUserStore} from "@/stores/modules/user";
|
||||
|
||||
|
||||
@@ -131,8 +131,19 @@ const initOperate = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const open = (title: string,sourceIds: string[]) => {
|
||||
|
||||
const channelMapping = ref<Record<string, Record<string, string>>>({})
|
||||
const planId = ref('')
|
||||
const loginName = ref('')
|
||||
const devIds = ref<[]>()
|
||||
const standardDevIds = ref<[]>()
|
||||
const pairs = ref<any>()
|
||||
const open = (title: string,mapping:any,plan: string,login: string,devIdsArray: [],standardDevIdsArray: [],pair:any) => {
|
||||
channelMapping.value = mapping
|
||||
planId.value = plan
|
||||
loginName.value = login
|
||||
devIds.value = devIdsArray
|
||||
standardDevIds.value = standardDevIdsArray
|
||||
pairs.value = pair
|
||||
showSteps.value = true
|
||||
initOperate()
|
||||
dialogTitle.value = title;
|
||||
@@ -157,10 +168,7 @@ const open = (title: string,sourceIds: string[]) => {
|
||||
});
|
||||
}
|
||||
|
||||
const handleSubmitFast = () => {
|
||||
let deviceIds = checkStore.devices.map((item) => item.deviceId)
|
||||
let planId = checkStore.plan.id
|
||||
|
||||
const handleSubmitFast = async () => {
|
||||
if (!dataSocket.socketServe.connected) {
|
||||
ElMessage.error('webSocket连接中断!')
|
||||
return
|
||||
@@ -170,54 +178,25 @@ const handleSubmitFast = () => {
|
||||
case 1:
|
||||
if (preTestStatus.value == 'waiting') {
|
||||
if (checkStore.selectTestItems.preTest) {
|
||||
startPreTest({
|
||||
userPageId: "cdf",
|
||||
devIds: deviceIds,
|
||||
planId: planId,
|
||||
operateType: checkStore.reCheckType == 1 ? '1' : '2',
|
||||
userId: userStore.userInfo.id,
|
||||
temperature: checkStore.temperature,
|
||||
humidity: checkStore.humidity,
|
||||
testItemList: [checkStore.selectTestItems.preTest, checkStore.selectTestItems.channelsTest, checkStore.selectTestItems.test]
|
||||
}).then(res => {
|
||||
if (res.code === 'A001014') {
|
||||
ElMessageBox.alert('装置配置异常', '检测失败', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'error',
|
||||
})
|
||||
preTestStatus.value = 'error'
|
||||
}
|
||||
})
|
||||
await contrastTest({
|
||||
planId: planId.value,
|
||||
loginName: loginName.value,
|
||||
devIds: devIds.value,
|
||||
standardDevIds: standardDevIds.value,
|
||||
pairs:pairs.value
|
||||
})
|
||||
preTestStatus.value = 'start'
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (TestStatus.value == "waiting") {
|
||||
if (!checkStore.selectTestItems.preTest && !checkStore.selectTestItems.channelsTest && checkStore.selectTestItems.test) {
|
||||
startPreTest({
|
||||
userPageId: "cdf",
|
||||
devIds: deviceIds,
|
||||
planId: planId,
|
||||
operateType: checkStore.reCheckType == 1 ? '1' : '2',
|
||||
userId: userStore.userInfo.id,
|
||||
temperature: checkStore.temperature,
|
||||
humidity: checkStore.humidity,
|
||||
testItemList: [checkStore.selectTestItems.preTest, checkStore.selectTestItems.channelsTest, checkStore.selectTestItems.test]
|
||||
}).then(res => {
|
||||
if (res.code === 'A001014') {
|
||||
ElMessageBox.alert('装置配置异常', '初始化失败', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'error',
|
||||
})
|
||||
TestStatus.value = 'test_init_fail'
|
||||
}
|
||||
})
|
||||
}
|
||||
//if (!checkStore.selectTestItems.preTest && !checkStore.selectTestItems.channelsTest && checkStore.selectTestItems.test) {
|
||||
//}
|
||||
TestStatus.value = 'start'
|
||||
} else if (TestStatus.value == 'paused') {
|
||||
// 发送继续指令
|
||||
sendResume()
|
||||
//sendResume()
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -300,7 +279,7 @@ const sendResume = () => {
|
||||
userPageId: "cdf",
|
||||
devIds: checkStore.devices.map((item) => item.deviceId),
|
||||
planId: checkStore.plan.id,
|
||||
operateType: '2', // 0:'系数校验','1'为预检测、‘2‘为正式检测、'8'为不合格项复检
|
||||
reCheckType: '2', // 0:'系数校验','1'为预检测、‘2‘为正式检测、'8'为不合格项复检
|
||||
userId: userStore.userInfo.id,
|
||||
temperature: checkStore.temperature,
|
||||
humidity: checkStore.humidity
|
||||
@@ -316,7 +295,7 @@ const sendReCheck = () => {
|
||||
userPageId: "cdf",
|
||||
devIds: checkStore.devices.map((item) => item.deviceId),
|
||||
planId: checkStore.plan.id,
|
||||
operateType: '2', // 0:'系数校验','1'为预检测、‘2‘为正式检测、'8'为不合格项复检
|
||||
reCheckType: '2', // 0:'系数校验','1'为预检测、‘2‘为正式检测、'8'为不合格项复检
|
||||
userId: userStore.userInfo.id,
|
||||
temperature: checkStore.temperature,
|
||||
humidity: checkStore.humidity,
|
||||
|
||||
@@ -51,7 +51,7 @@ import SelectTestItemPopup from "@/views/home/components/selectTestItemPopup.vue
|
||||
import CompareTestPopup from './compareTestPopup.vue'
|
||||
import { ElMessage } from 'element-plus';
|
||||
import CustomEdge from './RemoveableEdge.vue' // 导入自定义连接线组件
|
||||
import {contrastTest} from '@/api/socket/socket'
|
||||
|
||||
import { jwtUtil } from "@/utils/jwtUtil";
|
||||
|
||||
|
||||
@@ -200,17 +200,15 @@ function logConnections() {
|
||||
}
|
||||
|
||||
const nodes = ref([])
|
||||
const sourceIdArray = ref<string[]>()
|
||||
const planId = ref('')
|
||||
const devIds = ref<string[]>()
|
||||
const standardDevIds = ref<string[]>()
|
||||
|
||||
const open = async (device: Device.ResPqDev[], standardDev: StandardDevice.ResPqStandardDevice[],sourceIds: string[],fatherPlanId: string) => {
|
||||
const open = async (device: Device.ResPqDev[], standardDev: StandardDevice.ResPqStandardDevice[],fatherPlanId: string) => {
|
||||
edges.value = []
|
||||
devIds.value = device.map(d => d.id)
|
||||
standardDevIds.value = standardDev.map(d => d.id)
|
||||
planId.value = fatherPlanId
|
||||
sourceIdArray.value = sourceIds
|
||||
nodes.value = createNodes(device, standardDev)
|
||||
dialogVisible.value = true
|
||||
onPaneReady()
|
||||
@@ -222,32 +220,69 @@ const handleNext = () => {
|
||||
return
|
||||
}
|
||||
dialogVisible.value = false
|
||||
selectTestItemPopupRef.value?.open(sourceIdArray.value)
|
||||
selectTestItemPopupRef.value?.open()
|
||||
}
|
||||
|
||||
const openTestDialog = async () => {
|
||||
|
||||
// 转换连接信息,只保留设备ID和通道号
|
||||
const connections = edges.value.reduce((map, edge) => {
|
||||
// 从source中提取设备ID和通道号: 被检通道-{deviceId}-{channelNum} => {deviceId}-{channelNum}
|
||||
const sourceKey = edge.source.replace('被检通道-', '');
|
||||
|
||||
const sourceKey = edge.source.replace('被检通道-', '').replace('-', '_');
|
||||
|
||||
// 从target中提取设备ID和通道号: 标准通道-{deviceId}-{channelNum} => {deviceId}-{channelNum}
|
||||
const targetValue = edge.target.replace('标准通道-', '');
|
||||
const targetValue = edge.target.replace('标准通道-', '').replace('-', '_');
|
||||
|
||||
map[sourceKey] = targetValue;
|
||||
return map;
|
||||
}, {} as Record<string, string>);
|
||||
|
||||
console.log('通道配对信息:', connections);
|
||||
await contrastTest({
|
||||
planId: planId.value,
|
||||
loginName: jwtUtil.getLoginName(),
|
||||
devIds: devIds.value,
|
||||
standardDevIds: standardDevIds.value,
|
||||
pairs:connections
|
||||
|
||||
generateChannelMapping()
|
||||
testPopup.value?.open(dialogTitle.value,channelMapping.value,planId.value,jwtUtil.getLoginName(),devIds.value,standardDevIds.value,connections)
|
||||
}
|
||||
|
||||
// 转换 edges.value 为 channelMapping 格式
|
||||
const channelMapping = ref<Record<string, Record<string, string>>>({})
|
||||
|
||||
// 生成映射关系的方法
|
||||
const generateChannelMapping = () => {
|
||||
const mapping: Record<string, Record<string, string>> = {}
|
||||
|
||||
edges.value.forEach(edge => {
|
||||
// 解析 source 节点信息(被检通道)
|
||||
const sourceParts = edge.source.split('-')
|
||||
const sourceDeviceId = sourceParts[1]
|
||||
const sourceChannel = sourceParts[2]
|
||||
|
||||
// 解析 target 节点信息(标准通道)
|
||||
const targetParts = edge.target.split('-')
|
||||
const targetDeviceId = targetParts[1]
|
||||
const targetChannel = targetParts[2]
|
||||
|
||||
// 查找对应的节点以获取显示名称
|
||||
const sourceDeviceNode = nodes.value.find(node => node.id === sourceDeviceId)
|
||||
const targetDeviceNode = nodes.value.find(node => node.id === targetDeviceId)
|
||||
|
||||
if (sourceDeviceNode && targetDeviceNode) {
|
||||
// 提取设备显示文本
|
||||
const sourceDeviceText = sourceDeviceNode.data.label.children[1].children
|
||||
const targetDeviceText = targetDeviceNode.data.label.children[1].children
|
||||
|
||||
// 构造键名
|
||||
const sourceKey = `${sourceDeviceText}`.replace('设备名称:', '')
|
||||
const targetValue = `${targetDeviceText}通道${targetChannel}`.replace('设备名称:', '')
|
||||
|
||||
// 初始化对象
|
||||
if (!mapping[sourceKey]) {
|
||||
mapping[sourceKey] = {}
|
||||
}
|
||||
|
||||
// 添加映射关系
|
||||
mapping[sourceKey][`通道${sourceChannel}`] = targetValue
|
||||
}
|
||||
})
|
||||
testPopup.value?.open(dialogTitle.value,sourceIdArray.value)
|
||||
|
||||
channelMapping.value = mapping
|
||||
}
|
||||
|
||||
const createNodes = (device: Device.ResPqDev[], standardDev: StandardDevice.ResPqStandardDevice[]) => {
|
||||
@@ -398,9 +433,8 @@ const createNodes = (device: Device.ResPqDev[], standardDev: StandardDevice.ResP
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
console.log(newNodes)
|
||||
|
||||
//页面高度取决于设备通道
|
||||
dialogHeight.value = Math.max(yPosition.value, yPosition2.value)
|
||||
|
||||
return newNodes
|
||||
}
|
||||
|
||||
@@ -745,7 +745,7 @@ const handleSubmit = async () => {
|
||||
planId: planId.value,
|
||||
errorSysId: select_Plan.value?.errorSysId,
|
||||
scriptId: select_Plan.value?.scriptId,
|
||||
operateType: '0', // '0'为预检测、‘1‘为正式检测
|
||||
reCheckType: '0', // '0'为预检测、‘1‘为正式检测
|
||||
userId:userStore.userInfo.id
|
||||
})*/
|
||||
active.value++;
|
||||
|
||||
@@ -30,6 +30,9 @@
|
||||
:value="`通道${channel.devNum}`">
|
||||
</el-option>
|
||||
</el-select>
|
||||
<span style="margin-left: 20px; font-size: 14px; color: var(--el-color-primary);">
|
||||
被检设备:{{ deviceName }}-{{ selectedChannels[deviceName] }} ---> 标准设备:{{ formatStandardChannelLabel(getMappedStandardChannel(deviceName, selectedChannels[deviceName])) }}
|
||||
</span>
|
||||
</el-form-item>
|
||||
<el-button type="primary" @click="exportData">导出数据</el-button>
|
||||
</div>
|
||||
@@ -48,7 +51,7 @@
|
||||
<el-table-column prop="Uc1" label="C相(V)">
|
||||
</el-table-column>
|
||||
</el-table-column>
|
||||
<el-table-column :label="`${getMappedStandardChannel(deviceName, selectedChannels[deviceName])}`">
|
||||
<el-table-column :label="formatStandardChannelLabel(getMappedStandardChannel(deviceName, selectedChannels[deviceName]))">
|
||||
<el-table-column prop="Ua2" label="A相(V)">
|
||||
</el-table-column>
|
||||
<el-table-column prop="Ub2" label="B相(V)">
|
||||
@@ -64,16 +67,17 @@
|
||||
|
||||
<script setup lang='tsx' name='realTimeDataAlign'>
|
||||
import { dialogBig } from "@/utils/elementBind";
|
||||
import { ref } from "vue";
|
||||
import { PropType, ref } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { CircleCheck, CircleClose } from '@element-plus/icons-vue';
|
||||
|
||||
const dialogVisible = ref(false);
|
||||
const activeTab = ref('channel1');
|
||||
|
||||
|
||||
// 重构后的 testDataStructure
|
||||
const testDataStructure = ref({
|
||||
"被检设备1": {
|
||||
"被检1": {
|
||||
devName: "被检设备1",
|
||||
channelDataList: [
|
||||
{
|
||||
@@ -150,7 +154,7 @@ const testDataStructure = ref({
|
||||
}
|
||||
]
|
||||
},
|
||||
"被检设备2": {
|
||||
"被检2": {
|
||||
devName: "被检设备2",
|
||||
channelDataList: [
|
||||
{
|
||||
@@ -234,13 +238,13 @@ const selectedChannels = ref<Record<string, string>>({});
|
||||
|
||||
// 通道映射关系:被检设备通道 -> 标准设备通道
|
||||
const channelMapping = ref<Record<string, Record<string, string>>>({
|
||||
'被检设备1': {
|
||||
'通道1': '标准设备1通道1',
|
||||
'被检1': {
|
||||
'通道1': '标准设备1通道2',
|
||||
'通道2': '标准设备2通道4',
|
||||
},
|
||||
'被检设备2': {
|
||||
'通道1': '标准设备1通道1',
|
||||
'通道3': '标准设备2通道4'
|
||||
'被检2': {
|
||||
'通道1': '标准设备1通道3',
|
||||
'通道3': '标准设备2通道1'
|
||||
}
|
||||
});
|
||||
|
||||
@@ -264,13 +268,17 @@ const hasIncompleteData = (deviceName: string) => {
|
||||
|
||||
// 获取映射的标准设备通道
|
||||
const getMappedStandardChannel = (deviceName: string, dutChannel: string) => {
|
||||
if (!channelMapping.value[deviceName]) {
|
||||
// 默认值
|
||||
return dutChannel === '通道1' ? '标准设备1通道1' : '标准设备2通道4';
|
||||
}
|
||||
return channelMapping.value[deviceName][dutChannel] || '标准设备1通道1';
|
||||
|
||||
return channelMapping.value[deviceName][dutChannel];
|
||||
};
|
||||
|
||||
|
||||
// 格式化标准设备通道标签,将设备名称和通道号用"-"连接
|
||||
const formatStandardChannelLabel = (standardChannel: string) => {
|
||||
// 如果是"标准设备X通道Y"格式,则转换为"标准设备X-通道Y"
|
||||
return standardChannel.replace(/(标准设备\d+)(通道\d+)/, '$1-$2');
|
||||
};
|
||||
|
||||
// 处理被检设备通道切换
|
||||
const handleDutChannelChange = (deviceName: string) => {
|
||||
// 更新指定设备的表格数据,但不改变tab图标状态
|
||||
@@ -331,7 +339,10 @@ const initAllTableData = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const open = async () => {
|
||||
const open = async (mapping : Record<string, Record<string, string>>) => {
|
||||
console.log('mapping11111111:', mapping);
|
||||
console.log('mapping22222222:',channelMapping);
|
||||
//channelMapping.value = mapping;
|
||||
dialogVisible.value = true;
|
||||
// 初始化数据和状态
|
||||
initAllTableData();
|
||||
|
||||
@@ -742,7 +742,7 @@ const handleTest2 = () => {
|
||||
if (matchedItem) {
|
||||
dataSources.value = matchedItem.datasourceIds
|
||||
}
|
||||
deviceConnectionPopupRef.value?.open(channelsSelection.value, pqStandardDevList.value, dataSources.value,props.id)
|
||||
deviceConnectionPopupRef.value?.open(channelsSelection.value, pqStandardDevList.value,props.id)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -201,7 +201,7 @@ const handleSubmitFast = () => {
|
||||
startPreTest({
|
||||
devIds: deviceIds,
|
||||
planId: planId,
|
||||
operateType: checkStore.reCheckType == 1 ? '1' : '2',
|
||||
reCheckType: checkStore.reCheckType == 1 ? '1' : '2',
|
||||
userId: userStore.userInfo.id,
|
||||
temperature: checkStore.temperature,
|
||||
humidity: checkStore.humidity,
|
||||
@@ -228,7 +228,7 @@ const handleSubmitFast = () => {
|
||||
startPreTest({
|
||||
devIds: deviceIds,
|
||||
planId: planId,
|
||||
operateType: checkStore.reCheckType == 1 ? '1' : '2',
|
||||
reCheckType: checkStore.reCheckType == 1 ? '1' : '2',
|
||||
userId: userStore.userInfo.id,
|
||||
temperature: checkStore.temperature,
|
||||
humidity: checkStore.humidity,
|
||||
@@ -253,7 +253,7 @@ const handleSubmitFast = () => {
|
||||
startPreTest({
|
||||
devIds: deviceIds,
|
||||
planId: planId,
|
||||
operateType: checkStore.reCheckType == 1 ? '1' : '2',
|
||||
reCheckType: checkStore.reCheckType == 1 ? '1' : '2',
|
||||
userId: userStore.userInfo.id,
|
||||
temperature: checkStore.temperature,
|
||||
humidity: checkStore.humidity,
|
||||
@@ -376,7 +376,7 @@ const sendResume = () => {
|
||||
userPageId: "cdf",
|
||||
devIds: checkStore.devices.map((item) => item.deviceId),
|
||||
planId: checkStore.plan.id,
|
||||
operateType: '2', // 0:'系数校验','1'为预检测、‘2‘为正式检测、'8'为不合格项复检
|
||||
reCheckType: '2', // 0:'系数校验','1'为预检测、‘2‘为正式检测、'8'为不合格项复检
|
||||
userId: userStore.userInfo.id,
|
||||
temperature: checkStore.temperature,
|
||||
humidity: checkStore.humidity
|
||||
@@ -391,7 +391,7 @@ const sendReCheck = () => {
|
||||
startPreTest({
|
||||
devIds: checkStore.devices.map((item) => item.deviceId),
|
||||
planId: checkStore.plan.id,
|
||||
operateType: '2', // 0:'系数校验','1'为预检测、‘2‘为正式检测、'8'为不合格项复检
|
||||
reCheckType: '2', // 0:'系数校验','1'为预检测、‘2‘为正式检测、'8'为不合格项复检
|
||||
userId: userStore.userInfo.id,
|
||||
temperature: checkStore.temperature,
|
||||
humidity: checkStore.humidity,
|
||||
|
||||
Reference in New Issue
Block a user