UPDATE: 处理控制台警告问题

This commit is contained in:
贾同学
2025-10-10 13:23:40 +08:00
parent 8e0b3be438
commit b319a89501
45 changed files with 6390 additions and 6341 deletions

View File

@@ -18,7 +18,7 @@
v-model="formContent.errorSysId"
placeholder="请选择误差体系"
autocomplete="off"
@change="handleErrorSysChange"
@change="handleErrorSysChange"
>
<el-option
v-for="option in pqErrorList"
@@ -39,8 +39,13 @@
<el-option v-for="item in chnList" :key="item" :label="item" :value="item" />
</el-select>
</el-form-item>
<el-form-item label="检测次数" >
<el-select v-model="formContent.num" clearable @change="handleNumChange" :disabled="sourceKey == 1">
<el-form-item label="检测次数">
<el-select
v-model="formContent.num"
clearable
@change="handleNumChange"
:disabled="sourceKey == 1"
>
<el-option
v-for="item in chnMapList[formContent.chnNum]"
:key="item"
@@ -67,48 +72,48 @@
node-key="id"
ref="treeRef"
@node-click="handleNodeClick"
>
</el-tree>
></el-tree>
</div>
<div class="content-right">
<div class="content-right-title">
<div class="content-right-title">
<div style="width: 840px">
<span class="content-right-title-text">当前检测项目</span>
<!-- 当code为'wave_data'时显示下拉框 -->
<el-select
v-if="isWaveData"
v-model="selectedScriptName"
<el-select
v-if="isWaveData"
v-model="selectedScriptName"
style="width: 200px"
@change="handleScriptNameChange"
>
<el-option
v-for="item in scriptNameOptions"
:key="item.value"
:label="item.label"
:value="item.value"
<el-option
v-for="item in scriptNameOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
<!-- 否则显示原来的文本 -->
<span v-else style="color: var(--el-color-primary)">{{ rowList.scriptName }}</span>
</div>
<el-form-item
style="margin: 0 auto; margin-bottom: 0px !important; width: 200px; position: absolute; left: 50%; transform: translateX(-50%);"
label="录波次数"
style="
margin: 0 auto;
margin-bottom: 0px !important;
width: 200px;
position: absolute;
left: 50%;
transform: translateX(-50%);
"
label="录波次数"
v-if="isWaveData"
>
<el-select v-model="waveNumber" @change="handleWaveNumberChange">
<el-option
v-for="i in waveNumCount"
:key="i"
:label="i"
:value="i"
/>
<el-select v-model="waveNumber" @change="handleWaveNumberChange">
<el-option v-for="i in waveNumCount" :key="i" :label="i" :value="i" />
</el-select>
</el-form-item>
<el-form-item
style="margin-left: 280px; margin-bottom: 0px !important; width: 300px"
label="测试项"
label="测试项"
>
<el-select v-model="currentCheckItem">
<el-option
@@ -128,7 +133,6 @@
:currentCheckItem="currentCheckItem"
:currentScriptTypeName="currentScriptTypeName"
v-if="activeTab === 'resultTab'"
/>
</el-tab-pane>
<el-tab-pane label="原始数据" name="rawDataTab">
@@ -148,7 +152,7 @@
</template>
<script setup lang="ts">
import { dialogBig } from '@/utils/elementBind'
import { reactive, ref, watch, computed, nextTick } from 'vue'
import { computed, reactive, ref } from 'vue'
import CompareDataCheckResultTable from './compareDataCheckResultTable.vue'
import CompareDataCheckRawDataTable from './compareDataCheckRawDataTable.vue'
import { CheckData } from '@/api/check/interface'
@@ -157,16 +161,20 @@ import { Histogram, Postcard } from '@element-plus/icons-vue'
import { getPqErrSysList } from '@/api/plan/plan'
import { useModeStore } from '@/stores/modules/mode' // 引入模式 store
import { useDictStore } from '@/stores/modules/dict'
import { getContrastFormContent, getContrastResult, getScriptList,reCalculate ,changeErrorSystem,deleteTempTable} from '@/api/check/test'
import {
changeErrorSystem,
deleteTempTable,
getContrastFormContent,
getContrastResult,
getScriptList,
reCalculate
} from '@/api/check/test'
import { ElMessage } from 'element-plus'
import {ResultEnum} from "@/enums/httpEnum";
import { ResultEnum } from '@/enums/httpEnum'
const { appendToBody } = withDefaults(
defineProps<{
appendToBody: boolean
}>(),
{ appendToBody: true }
)
const { appendToBody = true } = defineProps<{
appendToBody: boolean
}>()
const checkStore = useCheckStore()
const modeStore = useModeStore()
@@ -192,7 +200,7 @@ const selectedScriptName = ref('')
const pattern = ref('')
// 添加以下内容
const isWaveData = ref(false)
const scriptNameOptions = ref<{label: string, value: string}[]>([])
const scriptNameOptions = ref<{ label: string; value: string }[]>([])
// 表单数据
const formContent = reactive<CheckData.DataCheck>({
@@ -230,10 +238,9 @@ const currentRawTableData = computed(() => {
return Array.isArray(data) ? data : []
})
const open = async (row: any, chnNum: string, deviceId: string | null, source: number) => {
isWaveData.value = false
pattern.value = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? ''//获取数据字典中对应的id
pattern.value = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? '' //获取数据字典中对应的id
rowList.value = {}
formContent.deviceId = deviceId || ''
formContent.chnNum = chnNum
@@ -241,14 +248,14 @@ const open = async (row: any, chnNum: string, deviceId: string | null, source: n
// 获取基本信息
await getBasicInformation(row.scriptType)
if (source == 1) {
// 正式检测进入页面 - 创建新的对象避免引用共享
// 正式检测进入页面 - 创建新的对象避免引用共享
rowList.value = {
scriptName: row.scriptName,
scriptType: row.scriptType,
// 复制其他需要的属性
devices: row.devices ? [...row.devices] : []
scriptName: row.scriptName,
scriptType: row.scriptType,
// 复制其他需要的属性
devices: row.devices ? [...row.devices] : []
}
}
}
// 检测数据查询进入---不区分检测数据查询和正式检测
await initScriptData()
visible.value = true
@@ -259,15 +266,15 @@ const open = async (row: any, chnNum: string, deviceId: string | null, source: n
// 获取误差体系
let { data: resPqErrorList } = await getPqErrSysList()
Object.assign(pqErrorList, resPqErrorList)
initGetResult()
}
const initGetResult = async () => {
// 判断是否为录波数据
const isLuoboData = (sourceKey.value == 1 && rowList.value.scriptName == "录波数据") ||
(sourceKey.value == 2 && scriptData.value[0]?.code == "wave_data");
const isLuoboData =
(sourceKey.value == 1 && rowList.value.scriptName == '录波数据') ||
(sourceKey.value == 2 && scriptData.value[0]?.code == 'wave_data')
if (isLuoboData) {
isWaveData.value = true
// 设置录波数据相关的选项
@@ -275,7 +282,7 @@ const initGetResult = async () => {
label: item.scriptName,
value: item.scriptName
}))
// 默认选中第一个选项
if (scriptNameOptions.value.length > 0) {
selectedScriptName.value = scriptNameOptions.value[0].value
@@ -292,7 +299,6 @@ const initGetResult = async () => {
}
}
// 查询大项树
const initScriptData = async () => {
let response: any = await getScriptList({
@@ -300,7 +306,7 @@ const initScriptData = async () => {
chnNum: formContent.chnNum,
num: formContent.num
})
// 格式化脚本数据
let temp = response.data.map((item: any) => {
return {
@@ -313,11 +319,10 @@ const initScriptData = async () => {
scriptData.value = temp
// 查找code为"录波"的项
let luoboItem = response.data.find((item: any) => item.code === 'wave_data');
let luoboItem = response.data.find((item: any) => item.code === 'wave_data')
// 如果找到了"录波"项则使用其subitems否则使用空数组
let temp2 = [];
let temp2 = []
if (luoboItem && luoboItem.subItems) {
// 格式化脚本数据
temp2 = luoboItem.subItems.map((item: any) => {
return {
@@ -328,10 +333,8 @@ const initScriptData = async () => {
}
selectScript.value = temp2
// 只有在sourceKey == 2时才设置rowList和tree相关属性
if (sourceKey.value === 2 && temp.length > 0) {
rowList.value.scriptName = temp[0].scriptName
rowList.value.scriptType = temp[0].id
selectedScriptName.value = temp[0].scriptName
@@ -339,8 +342,6 @@ const initScriptData = async () => {
treeRef.value?.setCurrentKey(temp[0].id)
}, 0)
}
}
// 获取基本信息
@@ -348,14 +349,14 @@ const getBasicInformation = async (scriptType: any) => {
checkResultData.value = []
rawTableData.value = []
const scriptType2 = ref('')
if(sourceKey.value == 1){
scriptType2.value = scriptType
}else{
scriptType2.value = ''
}
//确保scriptData已初始化
if (sourceKey.value == 1) {
scriptType2.value = scriptType
} else {
scriptType2.value = ''
}
//确保scriptData已初始化
// if (scriptData.value.length === 0) {
// await initScriptData()
// }
@@ -369,19 +370,19 @@ const getBasicInformation = async (scriptType: any) => {
num: formContent.num == '' ? null : parseInt(formContent.num),
patternId: pattern.value
})
formContent.dataRule = res.data.dataRule
formContent.deviceName = res.data.deviceName
formContent.errorSysId = res.data.errorSysId
chnMapList.value = res.data.chnMap
let chnMap: string[] = []
for (let key in res.data.chnMap) {
chnMap.push(key)
}
chnList.value = chnMap
formContent.chnNum = formContent.chnNum == null ? chnList.value[0] : formContent.chnNum
// 设置检测次数默认值为chnMap数组的最后一位
if (chnMapList.value[formContent.chnNum] && chnMapList.value[formContent.chnNum].length > 0) {
// 获取当前通道号对应的检测次数数组,并设置为最后一个值(最大值)
@@ -389,8 +390,6 @@ const getBasicInformation = async (scriptType: any) => {
formContent.num = numList[numList.length - 1]
}
waveNumCount.value = res.data.waveNumTotal
} catch (error) {
console.error('获取基本信息失败:', error)
}
@@ -414,7 +413,7 @@ const handleNumChange = async (value: string) => {
const handleCommonChange = async () => {
// 重新初始化脚本数据(更新左侧树)
await initScriptData()
// 触发当前选中节点的点击事件,保持界面状态一致
if (sourceKey.value === 2 && scriptData.value.length > 0) {
// 查找当前选中的节点
@@ -431,7 +430,7 @@ const handleCommonChange = async () => {
const tempNode = {
scriptName: rowList.value.scriptName,
id: rowList.value.scriptType,
code: rowList.value.scriptName === "录波数据" ? 'wave_data' : ''
code: rowList.value.scriptName === '录波数据' ? 'wave_data' : ''
}
handleNodeClick(tempNode)
}
@@ -450,7 +449,7 @@ const updateCheckNumForChn = (chnNum: string) => {
const handleNodeClick = (data: any) => {
rowList.value.scriptName = data.scriptName
rowList.value.scriptType = data.id
// 判断是否为录波数据
if (data.code === 'wave_data') {
isWaveData.value = true
@@ -464,19 +463,17 @@ const handleNodeClick = (data: any) => {
// 每次选中录波数据时都重置为第一个选项并触发getResults
if (scriptNameOptions.value.length > 0) {
selectedScriptName.value = scriptNameOptions.value[0].value
// 更新rowList并触发getResults
rowList.value.scriptName = selectedScriptName.value
const selectedItem = selectScript.value.find(item => item.scriptName === selectedScriptName.value)
if (selectedItem) {
rowList.value.scriptType = selectedItem.id
getResults('wave_data')
}
}
} else {
isWaveData.value = false
getResults(data.code)
}
@@ -495,8 +492,8 @@ const getResults = async (code: any) => {
deviceId: formContent.deviceId,
chnNum: formContent.chnNum,
num: formContent.num == '' ? null : formContent.num,
waveNum: isWaveDataRequest ? waveNumber.value : null,
isWave: isWaveDataRequest ,
waveNum: isWaveDataRequest ? waveNumber.value : null,
isWave: isWaveDataRequest,
patternId: pattern.value
}).then((res: any) => {
let list: string[] = []
@@ -507,8 +504,6 @@ const getResults = async (code: any) => {
tesList.value = list
checkResultData.value = res.data.resultMap
rawTableData.value = res.data.rawDataMap
})
}
@@ -541,39 +536,35 @@ const close = async () => {
}
const handleErrorSysChange = async () => {
changeErrorSystem({
planId: checkStore.plan.id,
scriptId: '',
errorSysId: formContent.errorSysId,
deviceId: formContent.deviceId,
code: checkStore.plan.code + '',
patternId: dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? '',
}).then((res) => {
if (res.code === ResultEnum.SUCCESS) {
ElMessage.success('切换误差体系成功')
handleChnNumChange(formContent.chnNum)
}
})
changeErrorSystem({
planId: checkStore.plan.id,
scriptId: '',
errorSysId: formContent.errorSysId,
deviceId: formContent.deviceId,
code: checkStore.plan.code + '',
patternId: dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? ''
}).then(res => {
if (res.code === ResultEnum.SUCCESS) {
ElMessage.success('切换误差体系成功')
handleChnNumChange(formContent.chnNum)
}
})
}
const handleReCalculate = async () => {
reCalculate({
planId: checkStore.plan.id,
scriptId: '',
errorSysId: formContent.errorSysId,
deviceId: formContent.deviceId,
code: checkStore.plan.code + '',
patternId: dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? '',
}).then((res) => {
if (res.code === ResultEnum.SUCCESS) {
ElMessage.success('重新计算成功!')
handleChnNumChange(formContent.chnNum)
}
})
reCalculate({
planId: checkStore.plan.id,
scriptId: '',
errorSysId: formContent.errorSysId,
deviceId: formContent.deviceId,
code: checkStore.plan.code + '',
patternId: dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? ''
}).then(res => {
if (res.code === ResultEnum.SUCCESS) {
ElMessage.success('重新计算成功!')
handleChnNumChange(formContent.chnNum)
}
})
}
defineExpose({