修改正式检测样式

This commit is contained in:
caozehui
2024-12-26 10:49:55 +08:00
parent 6ce58e86ad
commit af454e1a56
3 changed files with 380 additions and 167 deletions

View File

@@ -51,8 +51,11 @@ export namespace CheckData {
// 用来描述 通道检测结果 // 用来描述 通道检测结果
export enum ChnCheckResultEnum { export enum ChnCheckResultEnum {
UNKNOWN = -1, UNKNOWN = -1,
FAIL = 0, LOADING = 0,
SUCCESS = 1, FAIL = 1,
SUCCESS = 2,
UNCONNECTED=3,
ERRORDATA = 4
} }
//用来描述 某个脚本测试项对所有通道的检测结果 //用来描述 某个脚本测试项对所有通道的检测结果
@@ -72,8 +75,8 @@ export namespace CheckData {
* 用于描述 (设备)通道检测结果展示的按钮类型 * 用于描述 (设备)通道检测结果展示的按钮类型
*/ */
export interface ButtonResult { export interface ButtonResult {
resultType: 'info' | 'success' | 'danger', resultType: 'info' | 'info' | 'danger' | 'success' | 'warning'
resultValue: '-' | '' | '×' resultIcon: 'Minus' | 'Loading' | 'Close' | 'CircleCheckFilled' | 'WarnTriangleFilled'
} }
/** /**

View File

@@ -58,9 +58,9 @@
:type="row.devices[index1].chnResult[index2].resultType" :type="row.devices[index1].chnResult[index2].resultType"
size="small" size="small"
@click="handleClick(row.scriptId,item.deviceId,chnItem)" @click="handleClick(row.scriptId,item.deviceId,chnItem)"
> style="align-self: center; "
{{ row.devices[index1].chnResult[index2].resultValue }} :icon="row.devices[index1].chnResult[index2].resultIcon"
</el-button> />
</el-tooltip> </el-tooltip>
</template> </template>
</el-table-column> </el-table-column>
@@ -78,9 +78,8 @@
:type="row.devices[index].chnResult[0].resultType" :type="row.devices[index].chnResult[0].resultType"
size="small" size="small"
@click="handleClick(row.scriptId,item.deviceId,-1)" @click="handleClick(row.scriptId,item.deviceId,-1)"
> :icon="row.devices[index1].chnResult[index2].resultIcon"
{{ row.devices[index].chnResult[0].resultValue }} />
</el-button>
</el-tooltip> </el-tooltip>
</template> </template>
</el-table-column> </el-table-column>
@@ -149,8 +148,6 @@ const customColors = [{color: "#5cb87a", percentage: 100}]
const scriptData = reactive<CheckData.ScriptItem[]>([]) const scriptData = reactive<CheckData.ScriptItem[]>([])
// 用来保存被检设备 // 用来保存被检设备
const deviceList = reactive<CheckData.Device[]>([]) const deviceList = reactive<CheckData.Device[]>([])
// 用来保存定时器
const timer: any = ref("");
// 当前进行的测试项索引 // 当前进行的测试项索引
const activeIndex = ref(0) const activeIndex = ref(0)
// 百分比 // 百分比
@@ -199,12 +196,24 @@ const checkResultView = computed(() => {
if (chnSum.value <= MAX_CHN_SUM) { if (chnSum.value <= MAX_CHN_SUM) {
for (let j = 0; j < device.chnResult.length; j++) { for (let j = 0; j < device.chnResult.length; j++) {
if (device.chnResult[j] == CheckData.ChnCheckResultEnum.UNKNOWN) { switch (device.chnResult[j]) {
tempChnBtnResult.push({resultType: 'info', resultValue: '-'}) case CheckData.ChnCheckResultEnum.UNKNOWN:
} else if (device.chnResult[j] == CheckData.ChnCheckResultEnum.FAIL) { tempChnBtnResult.push({resultType: 'info', resultIcon: 'Minus'})
tempChnBtnResult.push({resultType: 'danger', resultValue: '×'}) break;
} else { case CheckData.ChnCheckResultEnum.LOADING:
tempChnBtnResult.push({resultType: 'success', resultValue: ''}) tempChnBtnResult.push({resultType: 'info', resultIcon: 'Loading'})
break;
case CheckData.ChnCheckResultEnum.FAIL:
tempChnBtnResult.push({resultType: 'danger', resultIcon: 'Close'})
break;
case CheckData.ChnCheckResultEnum.SUCCESS:
tempChnBtnResult.push({resultType: 'success', resultIcon: 'CircleCheckFilled'})
break;
case CheckData.ChnCheckResultEnum.UNCONNECTED:
tempChnBtnResult.push({resultType: 'warning', resultIcon: 'WarnTriangleFilled'})
break;
default:
break;
} }
} }
} else { } else {
@@ -212,12 +221,24 @@ const checkResultView = computed(() => {
if (device.chnResult.some(item => item == CheckData.ChnCheckResultEnum.FAIL)) { if (device.chnResult.some(item => item == CheckData.ChnCheckResultEnum.FAIL)) {
tempChnResult = CheckData.ChnCheckResultEnum.FAIL tempChnResult = CheckData.ChnCheckResultEnum.FAIL
} }
if (tempChnResult == CheckData.ChnCheckResultEnum.UNKNOWN) { switch (tempChnResult) {
tempChnBtnResult.push({resultType: 'info', resultValue: '-'}) case CheckData.ChnCheckResultEnum.UNKNOWN:
} else if (tempChnResult == CheckData.ChnCheckResultEnum.FAIL) { tempChnBtnResult.push({resultType: 'info', resultIcon: 'Minus'})
tempChnBtnResult.push({resultType: 'danger', resultValue: '×'}) break;
} else { case CheckData.ChnCheckResultEnum.LOADING:
tempChnBtnResult.push({resultType: 'success', resultValue: ''}) tempChnBtnResult.push({resultType: 'info', resultIcon: 'Loading'})
break;
case CheckData.ChnCheckResultEnum.FAIL:
tempChnBtnResult.push({resultType: 'danger', resultIcon: 'Close'})
break;
case CheckData.ChnCheckResultEnum.SUCCESS:
tempChnBtnResult.push({resultType: 'success', resultIcon: 'CircleCheckFilled'})
break;
case CheckData.ChnCheckResultEnum.UNCONNECTED:
tempChnBtnResult.push({resultType: 'warning', resultIcon: 'WarnTriangleFilled'})
break;
default:
break;
} }
} }
@@ -235,8 +256,8 @@ const checkResultView = computed(() => {
watch(testStatus, function (newValue, oldValue) { watch(testStatus, function (newValue, oldValue) {
if (newValue == 'start') { if (newValue == 'start') {
startTimer() // todo 可移除
emit('update:testStatus', 'process') emit('update:testStatus', 'process')
startTimer()
} }
if (newValue == 'paused' && oldValue == 'process') { if (newValue == 'paused' && oldValue == 'process') {
handlePauseOrContinue() handlePauseOrContinue()
@@ -249,42 +270,125 @@ watch(testStatus, function (newValue, oldValue) {
watch(webMsgSend, function (newValue, oldValue) { watch(webMsgSend, function (newValue, oldValue) {
if (activeIndex.value <= checkTotal.value) { if (activeIndex.value <= checkTotal.value) {
switch (newValue.requestId) { switch (newValue.requestId) {
case 'Test_Freq': case 'Test_Freq_Start':
console.log('检测开始') updateCheckResultView("Freq", true)
updateCheckResultView("Freq")
break; break;
case 'Test_VOL': case 'Test_Freq_End':
updateCheckResultView("VOL") updateCheckResultView("Freq", false)
activeIndex.value++;
if (testStatus.value != 'paused') {
startTimer()
}
break; break;
case 'Test_Harm_V': case 'Test_VOL_Start':
updateCheckResultView("Harm_V") updateCheckResultView("VOL", true)
break; break;
case 'Test_Harm_I': case 'Test_VOL_End':
updateCheckResultView("Harm_I") updateCheckResultView("VOL", false)
activeIndex.value++;
if (testStatus.value != 'paused') {
startTimer()
}
break; break;
case 'Test_Harm_P': case 'Test_Harm_V_Start':
updateCheckResultView("Harm_P") updateCheckResultView("Harm_V", true)
break; break;
case 'Test_InHarm_V': case 'Test_Harm_V_End':
updateCheckResultView("InHarm_V") updateCheckResultView("Harm_V", false)
activeIndex.value++;
if (testStatus.value != 'paused') {
startTimer()
}
break; break;
case 'Test_InHarm_I': case 'Test_Harm_I_Start':
updateCheckResultView("InHarm_I") updateCheckResultView("Harm_I", true)
break; break;
case 'Test_Dip': case 'Test_Harm_I_End':
updateCheckResultView("Dip") updateCheckResultView("Harm_I", false)
activeIndex.value++;
if (testStatus.value != 'paused') {
startTimer()
}
break; break;
case 'Test_CUR': case 'Test_Harm_P_Start':
updateCheckResultView("CUR") updateCheckResultView("Harm_P", true)
break; break;
case 'Test_MSQI_U': case 'Test_Harm_P_End':
updateCheckResultView("MSQI_U") updateCheckResultView("Harm_P", false)
activeIndex.value++;
if (testStatus.value != 'paused') {
startTimer()
}
break; break;
case 'Test_MSQI_I': case 'Test_InHarm_V_Start':
updateCheckResultView("MSQI_I") updateCheckResultView("InHarm_V", true)
break; break;
case 'Test_Flicker': case 'Test_InHarm_V_End':
updateCheckResultView("Flicker") updateCheckResultView("InHarm_V", false)
activeIndex.value++;
if (testStatus.value != 'paused') {
startTimer()
}
break;
case 'Test_InHarm_I_Start':
updateCheckResultView("InHarm_I", true)
break;
case 'Test_InHarm_I_End':
updateCheckResultView("InHarm_I", false)
activeIndex.value++;
if (testStatus.value != 'paused') {
startTimer()
}
break;
case 'Test_Dip_Start':
updateCheckResultView("Dip", true)
break;
case 'Test_Dip_End':
updateCheckResultView("Dip", false)
activeIndex.value++;
if (testStatus.value != 'paused') {
startTimer()
}
break;
case 'Test_CUR_Start':
updateCheckResultView("CUR", true)
break;
case 'Test_CUR_End':
updateCheckResultView("CUR", false)
activeIndex.value++;
if (testStatus.value != 'paused') {
startTimer()
}
break;
case 'Test_MSQI_U_Start':
updateCheckResultView("MSQI_U", true)
break;
case 'Test_MSQI_U_End':
updateCheckResultView("MSQI_U", false)
activeIndex.value++;
if (testStatus.value != 'paused') {
startTimer()
}
break;
case 'Test_MSQI_I_Start':
updateCheckResultView("MSQI_I", true)
break;
case 'Test_MSQI_I_End':
updateCheckResultView("MSQI_I", false)
activeIndex.value++;
if (testStatus.value != 'paused') {
startTimer()
}
break;
case 'Test_Flicker_Start':
updateCheckResultView("Flicker", true)
break;
case 'Test_Flicker_End':
updateCheckResultView("Flicker", false)
activeIndex.value++;
if (testStatus.value != 'paused') {
startTimer()
}
break; break;
case 'Test_Quit': case 'Test_Quit':
console.log('检测结束') console.log('检测结束')
@@ -292,14 +396,11 @@ watch(webMsgSend, function (newValue, oldValue) {
} }
updateLog() updateLog()
activeIndex.value++;
if (percentage.value < 100) { if (percentage.value < 100) {
percentage.value = Math.trunc(activeIndex.value / checkTotal.value * 100); percentage.value = Math.trunc(activeIndex.value / checkTotal.value * 100);
} else { } else {
percentage.value = 100; percentage.value = 100;
clearInterval(timer.value)
timer.value = null;
emit('update:testStatus', 'success') emit('update:testStatus', 'success')
ElMessageBox.alert('检测全部结束,你可以停留在此页面查看检测结果,或返回首页进行复检、报告生成和归档等操作', '检测完成', { ElMessageBox.alert('检测全部结束,你可以停留在此页面查看检测结果,或返回首页进行复检、报告生成和归档等操作', '检测完成', {
@@ -310,8 +411,6 @@ watch(webMsgSend, function (newValue, oldValue) {
clear(); clear();
} }
} else { } else {
clearInterval(timer.value)
timer.value = null;
emit('update:testStatus', 'success') emit('update:testStatus', 'success')
scrollToBottom(); scrollToBottom();
} }
@@ -694,14 +793,44 @@ function tableCell({row, columnIndex}) {
} }
} }
const updateCheckResultView = (scriptCode: string) => { const updateCheckResultView = (scriptCode: string, isStart: boolean) => {
let scriptId = scriptData.filter(item => item.code === scriptCode)[0]?.id let scriptId = scriptData.filter(item => item.code === scriptCode)[0]?.id
let temp = simulateCheck(scriptId) let temp = null
if (isStart) {
temp = getLoadingResult(scriptId)
} else {
temp = getCheckResult(scriptId)
}
updateCheckResult(temp) updateCheckResult(temp)
}; };
// 获取loading状态的结果
const getLoadingResult = (scriptId: string) => {
let devices = []
devices = deviceList.map(item => {
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
for (let i = 0; i < item.chnNum; i++) {
tempChnResult.push(CheckData.ChnCheckResultEnum.LOADING)
}
return {
deviceId: item.deviceId,
deviceName: item.deviceName,
chnResult: tempChnResult,
}
})
let tempScriptChnItem: CheckData.ScriptChnItem = {
scriptId,
devices,
}
return tempScriptChnItem
}
// 模拟检测 todo 可移除 // 模拟检测 todo 可移除
const simulateCheck = (scriptId: string) => { const getCheckResult = (scriptId: string) => {
let devices = [] let devices = []
devices = deviceList.map(item => { devices = deviceList.map(item => {
@@ -712,9 +841,9 @@ const simulateCheck = (scriptId: string) => {
} }
let randomNum = getRandomInt(item.chnNum * 2) let randomNum = getRandomInt(item.chnNum * 2)
if (activeIndex.value >= 4 && activeIndex.value <= 6) { if (activeIndex.value >= 2 && activeIndex.value <= 8) {
if (randomNum < item.chnNum) { if (randomNum < item.chnNum) {
tempChnResult[randomNum] = CheckData.ChnCheckResultEnum.FAIL tempChnResult[randomNum] = (randomNum % 2 === 0 ? 1 : 3)
errorCheckItem.push(scriptId) errorCheckItem.push(scriptId)
} }
@@ -748,7 +877,8 @@ const handlePauseOrContinue = () => {
type: 'info', type: 'info',
log: currentTime.value + ':暂停检测', log: currentTime.value + ':暂停检测',
}) })
pauseTimer() //pauseTimer()
console.log('暂停中')
} }
if (testStatus.value == "process") { if (testStatus.value == "process") {
startData.value = new Date(); startData.value = new Date();
@@ -756,7 +886,9 @@ const handlePauseOrContinue = () => {
type: 'info', type: 'info',
log: currentTime.value + ':继续检测', log: currentTime.value + ':继续检测',
}) })
resumeTimer() //resumeTimer()
startTimer()
console.log('开始继续检测')
} }
}; };
@@ -765,111 +897,181 @@ const handleClick = (scriptId: string, deviceId: any, chnNum: number) => {
dataCheckSingleChannelSingleTestPopupRef.value?.open(deviceId, chnNum, scriptId); dataCheckSingleChannelSingleTestPopupRef.value?.open(deviceId, chnNum, scriptId);
}; };
// todo 可移除
const startTimer = () => { const startTimer = () => {
if (activeIndex.value === 0) { if (activeIndex.value === 0) {
console.log('检测开始')
activeIndex.value++; activeIndex.value++;
} }
//if (timer.value !== null) return; // 如果定时器已经启动,则不再重复启动 console.log('开始检测第' + activeIndex.value + '项')
timer.value = setInterval(() => { switch (activeIndex.value) {
if (activeIndex.value <= checkTotal.value) { case 1:
switch (activeIndex.value) { emit('update:webMsgSend', {
case 1: requestId: 'Test_Freq_Start',
emit('update:webMsgSend', { params: {}
requestId: 'Test_Freq', })
params: {} setTimeout(() => {
}) emit('update:webMsgSend', {
break; requestId: 'Test_Freq_End',
case 2: params: {}
emit('update:webMsgSend', { })
requestId: 'Test_VOL', }, 2000);
params: {} break;
}) case 2:
break; emit('update:webMsgSend', {
case 3: requestId: 'Test_VOL_Start',
emit('update:webMsgSend', { params: {}
requestId: 'Test_Harm_V', })
params: {} setTimeout(() => {
}) emit('update:webMsgSend', {
break; requestId: 'Test_VOL_End',
case 4: params: {}
emit('update:webMsgSend', { })
requestId: 'Test_Harm_I', }, 2000);
params: {} break;
}) case 3:
break; emit('update:webMsgSend', {
case 5: requestId: 'Test_Harm_V_Start',
emit('update:webMsgSend', { params: {}
requestId: 'Test_Harm_P', })
params: {} setTimeout(() => {
}) emit('update:webMsgSend', {
break; requestId: 'Test_Harm_V_End',
case 6: params: {}
emit('update:webMsgSend', { })
requestId: 'Test_InHarm_V', }, 2000)
params: {} break;
}) case 4:
break; emit('update:webMsgSend', {
case 7: requestId: 'Test_Harm_I_Start',
emit('update:webMsgSend', { params: {}
requestId: 'Test_InHarm_I', })
params: {} setTimeout(() => {
}) emit('update:webMsgSend', {
break; requestId: 'Test_Harm_I_End',
case 8: params: {}
emit('update:webMsgSend', { })
requestId: 'Test_Dip', }, 2000)
params: {} break;
}) case 5:
break; emit('update:webMsgSend', {
case 9: requestId: 'Test_Harm_P_Start',
emit('update:webMsgSend', { params: {}
requestId: 'Test_CUR', })
params: {} setTimeout(() => {
}) emit('update:webMsgSend', {
break; requestId: 'Test_Harm_P_End',
case 10: params: {}
emit('update:webMsgSend', { })
requestId: 'Test_MSQI_U', }, 2000)
params: {} break;
}) case 6:
break; emit('update:webMsgSend', {
case 11: requestId: 'Test_InHarm_V_Start',
emit('update:webMsgSend', { params: {}
requestId: 'Test_MSQI_I', })
params: {} setTimeout(() => {
}) emit('update:webMsgSend', {
break; requestId: 'Test_InHarm_V_End',
case 12: params: {}
emit('update:webMsgSend', { })
requestId: 'Test_Flicker', }, 2000)
params: {} break;
}) case 7:
break; emit('update:webMsgSend', {
case 13: requestId: 'Test_InHarm_I_Start',
emit('update:webMsgSend', { params: {}
requestId: 'Test_Quit', })
params: {} setTimeout(() => {
}) emit('update:webMsgSend', {
break; requestId: 'Test_InHarm_I_End',
} params: {}
} })
}, 2000); }, 2000)
break;
case 8:
emit('update:webMsgSend', {
requestId: 'Test_Dip_Start',
params: {}
})
setTimeout(() => {
emit('update:webMsgSend', {
requestId: 'Test_Dip_End',
params: {}
})
}, 2000)
break;
case 9:
emit('update:webMsgSend', {
requestId: 'Test_CUR_Start',
params: {}
})
setTimeout(() => {
emit('update:webMsgSend', {
requestId: 'Test_CUR_End',
params: {}
})
}, 2000)
break;
case 10:
emit('update:webMsgSend', {
requestId: 'Test_MSQI_U_Start',
params: {}
})
setTimeout(() => {
emit('update:webMsgSend', {
requestId: 'Test_MSQI_U_End',
params: {}
})
}, 2000)
break;
case 11:
emit('update:webMsgSend', {
requestId: 'Test_MSQI_I_Start',
params: {}
})
setTimeout(() => {
emit('update:webMsgSend', {
requestId: 'Test_MSQI_I_End',
params: {}
}, 2000)
})
break;
case 12:
emit('update:webMsgSend', {
requestId: 'Test_Flicker_Start',
params: {}
})
setTimeout(() => {
emit('update:webMsgSend', {
requestId: 'Test_Flicker_End',
params: {}
})
}, 2000)
break;
case 13:
emit('update:webMsgSend', {
requestId: 'Test_Quit',
params: {}
})
break;
}
}; };
const pauseTimer = () => { // const pauseTimer = () => {
if (timer.value) { // if (timer.value) {
clearInterval(timer.value); // clearInterval(timer.value);
timer.value = null; // timer.value = null;
} // }
console.log('暂停中') // console.log('暂停中')
}; // };
const resumeTimer = () => { // const resumeTimer = () => {
if (!timer.value) { // if (!timer.value) {
startTimer(); // startTimer();
} // }
console.log('开始继续检测') // console.log('开始继续检测')
}; // };
//完成检测 //完成检测
const handleFinishTest = () => { const handleFinishTest = () => {
@@ -880,11 +1082,9 @@ const handleFinishTest = () => {
const handleReCheck = () => { const handleReCheck = () => {
activeIndex.value = 0; activeIndex.value = 0;
percentage.value = 0; percentage.value = 0;
// tableData.value.length = 0;
testLogList.value.length = 0; testLogList.value.length = 0;
errorCheckItem.length = 0; errorCheckItem.length = 0;
//tableData.value = JSON.parse(JSON.stringify(operatorTableData.value)); // resumeTimer()
resumeTimer()
}; };
function clear() { function clear() {
@@ -958,8 +1158,9 @@ function clear() {
font-size: 14px; font-size: 14px;
} }
} }
.drawer-container{
:deep(header.el-drawer__header){ .drawer-container {
:deep(header.el-drawer__header) {
color: #fff !important; color: #fff !important;
background-color: #003078 !important; background-color: #003078 !important;
@@ -967,12 +1168,18 @@ function clear() {
color: #ccc !important; color: #ccc !important;
} }
.el-drawer__title{ .el-drawer__title {
color: #fff !important; color: #fff !important;
} }
} }
} }
.custom-icon {
width: 16px; /* 调整宽度 */
height: 16px; /* 调整高度 */
color: #409EFF; /* 调整颜色 */
}
//:deep(.el-drawer .el-drawer__title){ //:deep(.el-drawer .el-drawer__title){
// background-color: #003078 !important; // background-color: #003078 !important;
//} //}

View File

@@ -243,7 +243,8 @@ const detectionOptions = ref([
// startTest({deviceIds}).then(res => { // startTest({deviceIds}).then(res => {
// console.log(res) // console.log(res)
// if (res.code === 20000) { // if (res.code === 20000) {
// TestStatus.value = 'process' // TestStatus.value = 'start'
// webMsgSend.value = ''
// } else { // } else {
// ElMessage.error(res.message) // ElMessage.error(res.message)
// } // }
@@ -254,6 +255,7 @@ const detectionOptions = ref([
// console.log(res) // console.log(res)
// if (res.code === 20000) { // if (res.code === 20000) {
// TestStatus.value = 'paused' // TestStatus.value = 'paused'
// webMsgSend.value = ''
// } else { // } else {
// ElMessage.error(res.message) // ElMessage.error(res.message)
// } // }
@@ -264,6 +266,7 @@ const detectionOptions = ref([
// console.log(res) // console.log(res)
// if (res.code === 20000) { // if (res.code === 20000) {
// TestStatus.value = 'process' // TestStatus.value = 'process'
// webMsgSend.value = ''
// } else { // } else {
// ElMessage.error(res.message) // ElMessage.error(res.message)
// } // }