This commit is contained in:
caozehui
2025-01-03 11:27:36 +08:00
parent 8a5bcca901
commit 938b9054d3
7 changed files with 356 additions and 250 deletions

View File

@@ -4,7 +4,7 @@ export namespace CheckData {
errorSysName: string,
dataRule: string,
deviceName: string,
monitorIdx: string,
chnNum: string,
}
/**
@@ -46,7 +46,7 @@ export namespace CheckData {
export interface ScriptItem{
scriptName: string,
scriptType?: string,
children?: ScriptItem1[]
children?: ScriptItem[]
}
// 用来描述 通道检测结果
export enum ChnCheckResultEnum {

View File

@@ -1,4 +1,5 @@
import http from "@/api";
import {CheckData} from "@/api/check/interface";
export const getBigTestItem = (planId: string) => {
return http.get(`/adPlan/getBigTestItem?planId=${planId}`, {loading: false});
@@ -28,7 +29,7 @@ export const getTreeData = (params: {
scriptType: string | null,
code: string
}) => {
return http.post("/result/treeData/", params, {loading: false});
return http.post<CheckData.ScriptItem[]>("/result/treeData/", params, {loading: true});
}
/**

View File

@@ -11,6 +11,7 @@ export const useCheckStore = defineStore("check", {
planId: String(""),
planCode: String(""),
scriptId: String(""),
errorSysId: String(""),
}),
getters: {},
@@ -34,6 +35,10 @@ export const useCheckStore = defineStore("check", {
setScriptId(scriptId: string) {
this.scriptId = scriptId
},
setErrorSysId(errorSysId: string) {
this.errorSysId = errorSysId
}
}
});

View File

@@ -121,8 +121,9 @@ const checkedScriptType = ref<string>('')
const currentScriptDsc = ref('');
// 右侧Tab选中项
const activeTab = ref<string>('resultTab')
// 检测结果表格数据
let checkResultTableData: CheckData.CheckResult = []
let checkResultTableData: CheckData.CheckResult[] = []
// 原始数据表格数据
let rawTableData: CheckData.RawDataItem[] = []
@@ -147,60 +148,21 @@ const handleNodeClick = async (data: any) => {
watch(() => formContent.chnNum, async (newVal, oldVal) => {
console.log("通道号", newVal);
switchItem.value = 0
await handleSwitchChange(0)
})
const handleSwitchChange = async (data: any) => {
console.log("切换不合格测试项、全部测试项", data);
if (data === 0) {
if (newVal) {
// 发起请求,查询该测试项的检测结果
const {data: treeDataTemp} = await getTreeData({
const {data: resTreeDataTemp}: { data: CheckData.ScriptItem[] } = await getTreeData({
scriptId: checkStore.scriptId,
deviceId,
devNum: formContent.chnNum + '',
scriptType,
code: checkStore.planCode
})
treeDataUnqualified = []
//filterTree(treeDataTemp,2)
//treeDataUnqualified=treeDataTemp
// treeDataUnqualified = [{
// "scriptName": "频率准确度检测",
// "children": [
// {
// "scriptName": "电压对频率测量的影响",
// "children": [
// {
// "scriptName": "输入:频率 50.05Hz Ua =10%Un...",
// "scriptType": '2346adafdf'
// },
// {
// "scriptName": "输入:频率 51.05Hz Ua =10%Un...",
// "scriptType": '1246adaafdf'
// },
// {
// "scriptName": "输入:频率 52.05Hz Ua =10%Un...",
// "scriptType": '2136ada3fdf'
// }
// ]
// },
// {
// "scriptName": "谐波对频率测量的影响",
// "children": [
// {
// "scriptName": "输入:频率 50.05Hz Ua =100%Un...",
// "scriptType": '234246adafdf'
// }
// ]
// }
// ]
// }]
} else {
// 发起请求,查询该测试项的检测结果
// const {data:treeDataAll} = await getTreeData({scriptId:checkStore.scriptId,deviceId, devNum: formContent.chnNum+'', scriptType,code:checkStore.planCode})
treeDataAll = []
treeDataAll = resTreeDataTemp
let treeDataTemp = JSON.parse(JSON.stringify(treeDataAll))
filterTree(treeDataTemp, 2)
treeDataUnqualified = treeDataTemp
// treeDataAll = [
// {
// "scriptName": "频率准确度检测",
@@ -251,7 +213,139 @@ const handleSwitchChange = async (data: any) => {
// ]
// }
// ]
// treeDataUnqualified = [{
// "scriptName": "频率准确度检测",
// "children": [
// {
// "scriptName": "电压对频率测量的影响",
// "children": [
// {
// "scriptName": "输入:频率 50.05Hz Ua =10%Un...",
// "scriptType": '2346adafdf'
// },
// {
// "scriptName": "输入:频率 51.05Hz Ua =10%Un...",
// "scriptType": '1246adaafdf'
// },
// {
// "scriptName": "输入:频率 52.05Hz Ua =10%Un...",
// "scriptType": '2136ada3fdf'
// }
// ]
// },
// {
// "scriptName": "谐波对频率测量的影响",
// "children": [
// {
// "scriptName": "输入:频率 50.05Hz Ua =100%Un...",
// "scriptType": '234246adafdf'
// }
// ]
// }
// ]
// }]
switchItem.value = 0
await handleSwitchChange(0)
}
})
const handleSwitchChange = async (data: any) => {
console.log("切换不合格测试项、全部测试项", data);
// let treeDataTemp = JSON.parse(JSON.stringify(treeDataAll))
// if (data === 0) {
// filterTree(treeDataTemp, 2)
// treeDataUnqualified = treeDataTemp
// treeDataUnqualified=[]
//treeDataUnqualified=treeDataTemp
// treeDataUnqualified = [{
// "scriptName": "频率准确度检测",
// "children": [
// {
// "scriptName": "电压对频率测量的影响",
// "children": [
// {
// "scriptName": "输入:频率 50.05Hz Ua =10%Un...",
// "scriptType": '2346adafdf'
// },
// {
// "scriptName": "输入:频率 51.05Hz Ua =10%Un...",
// "scriptType": '1246adaafdf'
// },
// {
// "scriptName": "输入:频率 52.05Hz Ua =10%Un...",
// "scriptType": '2136ada3fdf'
// }
// ]
// },
// {
// "scriptName": "谐波对频率测量的影响",
// "children": [
// {
// "scriptName": "输入:频率 50.05Hz Ua =100%Un...",
// "scriptType": '234246adafdf'
// }
// ]
// }
// ]
// }]
// }
// else {
// treeDataAll = treeDataTemp
// treeDataAll = []
// treeDataAll = [
// {
// "scriptName": "频率准确度检测",
// "children": [
// {
// "scriptName": "额定工作条件下的检测",
// "children": [
// {
// "scriptName": "输入:频率 42.5Hz...",
// "scriptType": '2246ada2fdf'
// },
// {
// "scriptName": "输入:频率 50.0Hz...",
// "scriptType": '2246a3dafdf'
// },
// {
// "scriptName": "输入:频率 50.05Hz....",
// "scriptType": '22246adafdf'
// }
// ]
// },
// {
// "scriptName": "电压对频率测量的影响",
// "children": [
// {
// "scriptName": "输入:频率 50.05Hz Ua =10%Un...",
// "scriptType": '224a6adafdf'
// },
// {
// "scriptName": "输入:频率 51.05Hz Ua =10%Un...",
// "scriptType": '2246aadafdf'
// },
// {
// "scriptName": "输入:频率 52.05Hz Ua =10%Un...",
// "scriptType": '2246adaffdf'
// }
// ]
// },
// {
// "scriptName": "谐波对频率测量的影响",
// "children": [
// {
// "scriptName": "输入:频率 50.05Hz Ua =100%Un...",
// "scriptType": '2246aadafdf'
// }
// ]
// }
// ]
// }
// ]
// }
defaultOperate()
await updateTableData()
@@ -278,6 +372,7 @@ const defaultOperate = () => {
const updateTableData = async () => {
console.log("左侧树被选中的叶子节点scriptType", checkedScriptType.value);
if (checkedScriptType.value) {
// 发起请求,查询该测试项的检测结果
// const result = await getTableData({checkStore.scriptId,deviceId, formContent.chnNum, scriptType})
@@ -417,6 +512,7 @@ const updateTableData = async () => {
}
]
}
}
const open = async (_deviceId: string, chnNum: string, _scriptType: string | null) => {
// console.log(checkStore.scriptId, _deviceId, chnNum, _scriptType);
@@ -424,7 +520,12 @@ const open = async (_deviceId: string, chnNum: string, _scriptType: string | nul
scriptType = _scriptType
// 发起后端请求,查询详细信息 当chnNum为-1时查询所有通道号
const {data: resFormContent} = await getFormData({planId: checkStore.planId, deviceId, chnNum, scriptType})
const {data: resFormContent}: { data: any } = await getFormData({
planId: checkStore.planId,
deviceId,
chnNum,
scriptType
})
// 数据处理
// let resFormContent = {
@@ -439,7 +540,7 @@ const open = async (_deviceId: string, chnNum: string, _scriptType: string | nul
// {value: '4', label: '0'}],
// }
chnList = resFormContent.chnList.map(item => ({
chnList = resFormContent.chnList.map((item: { value: string, label: string }) => ({
value: item.value,
label: item.label == '1' ? `${item.value}` : `${item.value}(不符合)`
}))
@@ -449,13 +550,11 @@ const open = async (_deviceId: string, chnNum: string, _scriptType: string | nul
Object.assign(formContent, {
...resFormContent,
dataRule: dataRuleName,
chnNum: chnList[0].value
chnNum: chnList.length > 0 ? chnList[0].value : '',
})
visible.value = true;
// console.log(filterTree(treeD, 1))
}
const close = () => {

View File

@@ -11,7 +11,7 @@
v-if="testStatus=='process' && activeIndex < checkTotal"
:disabled="activeIndex===0"
:icon="VideoPause"
@click="handlePauseTest">停止检测
@click="emit('sendPause')">停止检测
</el-button>
<el-button
type="primary"
@@ -33,7 +33,7 @@
type="warning"
v-if="testStatus=='paused' && activeIndex < checkTotal"
:icon="Refresh"
@click="handleResumeTest"
@click="emit('sendResume')"
>继续检测
</el-button>
<el-button type="text" :icon="InfoFilled" @click="showTestLog">检测项进度</el-button>
@@ -298,13 +298,13 @@ watch(testStatus, function (newValue, oldValue) {
startTimer() // todo 可移除
//emit('update:testStatus', 'process') // todo 可移除
}
if (newValue == 'paused' && oldValue == 'process') {
handlePauseOrContinue()
}
if (newValue === 'process' && oldValue == 'paused') {
activeIndex++
handlePauseOrContinue()
}
// if (newValue == 'paused' && oldValue == 'process') {
// handlePauseTest()
// }
// if (newValue === 'process' && oldValue == 'paused') {
//activeIndex++
//handleResumeTest()
// }
})
watch(webMsgSend, function (newValue, oldValue) {
@@ -388,6 +388,7 @@ watch(webMsgSend, function (newValue, oldValue) {
case 'Pause_Success':
ElMessage.success('暂停成功')
emit('update:testStatus', 'paused')
handlePauseTest()
break;
case 'Pause_Fail':
ElMessage.error('暂停失败')
@@ -395,6 +396,7 @@ watch(webMsgSend, function (newValue, oldValue) {
case 'Resume_Success':
ElMessage.success('开始继续检测')
emit('update:testStatus', 'process')
handleResumeTest()
break;
case 'Resume_Fail':
ElMessage.error('无法继续检测')
@@ -573,8 +575,6 @@ const updatePercentage = () => {
emit('update:testStatus', 'success')
ElMessageBox.alert('检测全部结束,你可以停留在此页面查看检测结果,或返回首页进行复检、报告生成和归档等操作', '检测完成', {
// if you want to disable its autofocus
// autofocus: false,
confirmButtonText: '确定',
})
clear();
@@ -767,7 +767,6 @@ const updateLog = (isStart: boolean) => {
// }
const updateCheckResultView = (scriptCode: string, isStart: boolean) => {
// debugger
let scriptType = scriptData.filter(item => item.code === scriptCode)[0]?.id
let temp = null
if (isStart) {
@@ -804,7 +803,6 @@ const getLoadingResult = (scriptType: string) => {
return tempScriptChnItem
}
// 模拟检测 todo 可移除
const getCheckResult = (scriptType: string) => {
// debugger
@@ -866,32 +864,6 @@ const getCheckResult = (scriptType: string) => {
return tempScriptChnItem
}
// 处理暂停、继续按钮点击事件
const handlePauseOrContinue = () => {
const currentTime = ref(new Date().toLocaleString());
if (testStatus.value == "paused") {
endData.value = new Date();
const Pausetime = endData.value.getTime() - startData.value.getTime();
timeDifference.value += Pausetime
testLogList.push({
type: 'info',
log: currentTime.value + ':暂停检测',
})
console.log('暂停中')
}
if (testStatus.value == "process") {
startData.value = new Date();
testLogList.push({
type: 'info',
log: currentTime.value + ':继续检测',
})
startTimer()
console.log('开始继续检测')
}
};
// 点击查看设备通道检测详情。参数1设备信息参数2通道号-1代表查看全部通道
const handleClick = (item: any, chnNum: string, scriptType: string) => {
let checkResultItem = checkResult.find(obj => obj.scriptType === scriptType)
@@ -939,7 +911,8 @@ const startTimer = () => {
requestId: 'yjc_ytxjy',
operateCode: "INIT_GATHER",
code: "2222"
})},2000)
})
}, 2000)
setTimeout(() => {
emit('update:webMsgSend', {
requestId: 'yjc_sbtxjy',
@@ -1109,13 +1082,26 @@ const startTimer = () => {
};
const handlePauseTest = () => {
// 发送暂停指令
emit('sendPause')
endData.value = new Date();
let diffTime = endData.value.getTime() - startData.value.getTime();
timeDifference.value += diffTime
testLogList.push({
type: 'info',
log: `${new Date().toLocaleString()}:暂停检测`,
})
console.log('暂停中')
};
const handleResumeTest = () => {
// 发送继续检测指令
emit('sendResume')
activeIndex++
startData.value = new Date();
testLogList.push({
type: 'info',
log: `${new Date().toLocaleString()}:继续检测`,
})
startTimer()
console.log('开始继续检测')
};
//完成检测

View File

@@ -270,6 +270,7 @@ const detectionOptions = ref([
TestStatus.value = 'start'
} else if (TestStatus.value == 'process') {
// 发送暂停指令
sendPause()
// pauseTest({deviceIds}).then(res => {
// console.log(res)
// if (res.code === 20000) {
@@ -279,9 +280,10 @@ const detectionOptions = ref([
// ElMessage.error(res.message)
// }
// })
TestStatus.value = 'paused'
} else if (TestStatus.value == 'paused') {
// 发送继续指令
sendResume()
// resumeTest({deviceIds}).then(res => {
// console.log(res)
// if (res.code === 20000) {
@@ -291,7 +293,7 @@ const detectionOptions = ref([
// ElMessage.error(res.message)
// }
// })
TestStatus.value = 'process'
}
break;
default:
@@ -348,9 +350,16 @@ const detectionOptions = ref([
const sendPause = () => {
console.log('发送暂停指令')
Object.assign(webMsgSend.value, {
requestId:'Pause_Success'
}) // todo 可移除
}
const sendResume = () => {
console.log('发送继续检测指令')
Object.assign(webMsgSend.value, {
requestId:'Resume_Success'
}) // todo 可移除
}
const getIcon = (index: number) => {

View File

@@ -51,15 +51,20 @@ const defaultProps = {
const searchForm = ref({
planName: '',
})
const defaultChecked = ref<number[]>([]) // 明确类型为 number[]
const defaultChecked = ref<string[]>([]) // 明确类型为 number[]
const getTreeData = (val: any) => {
defaultChecked.value = []
data.value = val
if (data.value.length > 0 && data.value[0].children.length > 0) {
defaultChecked.value.push(data.value[0].children[0].id as number)
let node = data.value[0].children[0]
defaultChecked.value.push(node.id)
checkStore.setPlanId(node.id)
checkStore.setPlanCode(node.code)
checkStore.setScriptId(node.scriptId)
checkStore.setErrorSysId(node.errorSysId)
console.log(checkStore.planId,checkStore.planCode,checkStore.scriptId,checkStore.errorSysId)
}
checkStore.setPlanId(defaultChecked.value[0])
checkStore.setPlanCode(data.value[0].code)
}
const filterText = ref('')
const treeRef = ref()
@@ -79,6 +84,7 @@ const handleNodeClick = (data: Plan.ResPlan) => {
checkStore.setPlanId(data.id)
checkStore.setPlanCode(data.code)
checkStore.setScriptId(data.scriptId)
checkStore.setErrorSysId(data.errorSysId)
updateSelectedTreeNode(data.id)
}
const filterNode = (value: string, data: any) => {