|
|
@ -71,7 +71,12 @@ |
|
|
|
<InitWarn v-if="showFailModal" :visible="showFailModal" title="检测失败" :message="failMessage" |
|
|
|
icon="/src/assets/Warn.svg" cancelText="返回" confirmText="确认" @close="showFailModal = false" |
|
|
|
@confirm="checkIfResetCompleted" /> |
|
|
|
|
|
|
|
<InitWarn v-if="idCardInserted" :visible="idCardInserted" title="检测到id卡插入" message="是否保存id卡信息" cancelText="返回" |
|
|
|
icon="/src/assets/update-pin-icon.svg" confirmText="确认保存" @close="idCardInserted = false" @confirm="saveIdInfo" /> |
|
|
|
<InitWarn v-if="showErrorModal" :visible="showErrorModal" title="错误提示" :message="ErrorMessage" |
|
|
|
icon="/src/assets/Warn.svg" cancelText="返回" confirmText="确认" @close="confirmError" @confirm="confirmError" /> |
|
|
|
<InitWarn v-if="showWarnModal" :visible="showWarnModal" title="注意" :message="WarnMessage" cancelText="返回" |
|
|
|
icon="/src/assets/update-pin-icon.svg" confirmText="确认" @close="confirmWarn" @confirm="confirmWarn" /> |
|
|
|
|
|
|
|
</template> |
|
|
|
|
|
|
@ -79,9 +84,9 @@ |
|
|
|
<script setup lang="ts"> |
|
|
|
import { ref, onMounted, onBeforeUnmount } from 'vue'; |
|
|
|
import { Time, InitWarn, LoadingModal } from './components/Consumables'; |
|
|
|
import { getCheckList, startWork, pauseWork, continueWork, stopWork, pollAllAppEvents } from '../../services/index'; |
|
|
|
import { getCheckList, startWork, pauseWork, continueWork, stopWork, pollAllAppEvents, getInitState, initDevice, saveMountedCardInfo, openBuzzer, closeBuzzer } from '../../services/index'; |
|
|
|
import { CheckItem, User } from '../../types/Index'; |
|
|
|
|
|
|
|
import { useConsumablesStore } from '../../store'; |
|
|
|
const selectedTab = ref(sessionStorage.getItem('selectedTab') || '常规'); |
|
|
|
const lineWidth = ref(0); |
|
|
|
const lineLeft = ref(0); |
|
|
@ -91,81 +96,95 @@ const showAlreadyModal = ref(false); |
|
|
|
const showFailModal = ref(false); |
|
|
|
const checkData = ref<CheckItem[]>([]); |
|
|
|
const failItems = ref<CheckItem[]>([]); |
|
|
|
|
|
|
|
const consumableStore = useConsumablesStore(); |
|
|
|
// 新增的变量 |
|
|
|
const user = ref<User>(JSON.parse(sessionStorage.getItem('token') || '{}') as unknown as User) |
|
|
|
console.log(user.value); |
|
|
|
const isTesting = ref(false); // 用于控制按钮的显示 |
|
|
|
const isPaused = ref(false); // 用于控制是否暂停测试 |
|
|
|
const username = ref<string>(user.value.account) |
|
|
|
const failMessage = ref(''); // 存储动态生成的错误信息 |
|
|
|
const idCardInserted = ref(false) // id卡插入状态 |
|
|
|
//事件状态 |
|
|
|
const EventText = ref<string>('闲置...') |
|
|
|
const showWarnModal = ref(false) |
|
|
|
const ErrorMessage = ref<string>('') |
|
|
|
const showErrorModal = ref(false) |
|
|
|
const WarnMessage = ref<string>('') |
|
|
|
interface EventType { |
|
|
|
typeName: string, |
|
|
|
timestamp: number |
|
|
|
projectInfo?: { |
|
|
|
id: number, |
|
|
|
projName: string, |
|
|
|
lotId: string, |
|
|
|
expiryDate: number, |
|
|
|
projId: 1, |
|
|
|
palteCode: number, |
|
|
|
updateChipVersion: number |
|
|
|
}, |
|
|
|
error?: { |
|
|
|
code: string, |
|
|
|
prompt?: { |
|
|
|
type: string, |
|
|
|
projName?: string, |
|
|
|
exmsg?: string, |
|
|
|
mid?: string, |
|
|
|
cmdId?: string, |
|
|
|
actionStep?: string |
|
|
|
info: string, |
|
|
|
detailInfos: string[], |
|
|
|
stackInfo: null |
|
|
|
} |
|
|
|
actionStep?: string, |
|
|
|
actionStepName?: string |
|
|
|
} |
|
|
|
// 处理 A8kEcodeContextListPromptEvent 类型的特殊逻辑 |
|
|
|
const handleA8kEcodeContextListPromptEvent = (error: any): string => { |
|
|
|
switch (error.code) { |
|
|
|
case "APPE_CONSUME_NOT_ENOUGH": |
|
|
|
return `${error.projName}耗材不足`; |
|
|
|
case "CODEERROR": |
|
|
|
return `额外的错误${error.exmsg}`; |
|
|
|
case "LOW_ERROR_CHECKCODE_IS_ERROR": |
|
|
|
return "校验码错误"; |
|
|
|
default: |
|
|
|
return ''; // 默认返回空字符串 |
|
|
|
} |
|
|
|
}; |
|
|
|
// const handleA8kEcodeContextListPromptEvent = (error: any): string => { |
|
|
|
// switch (error.code) { |
|
|
|
// case "APPE_CONSUME_NOT_ENOUGH": |
|
|
|
// return `${error.projName}耗材不足`; |
|
|
|
// case "CODEERROR": |
|
|
|
// return `额外的错误${error.exmsg}`; |
|
|
|
// case "LOW_ERROR_CHECKCODE_IS_ERROR": |
|
|
|
// return "校验码错误"; |
|
|
|
// default: |
|
|
|
// return ''; // 默认返回空字符串 |
|
|
|
// } |
|
|
|
// }; |
|
|
|
|
|
|
|
const getEventText = (data: EventType | EventType[]): string => { |
|
|
|
let eventName = ''; |
|
|
|
|
|
|
|
// 定义一个映射表来减少重复的 if 判断 |
|
|
|
const eventTypeMap: { [key: string]: string } = { |
|
|
|
"AppIDCardMountEvent": "id卡已插入", |
|
|
|
"AppIDCardUnmountEvent": "id卡已拔出", |
|
|
|
"AppTubeholderSettingUpdateEvent": "试管架设置已更新", |
|
|
|
"A8kEcodeContextListPromptEvent": "设备暂停", |
|
|
|
}; |
|
|
|
// const eventTypeMap: { [key: string]: string } = { |
|
|
|
// "AppIDCardMountEvent": "id卡已插入", |
|
|
|
// "AppIDCardUnmountEvent": "id卡已拔出", |
|
|
|
// "AppTubeholderSettingUpdateEvent": "试管架设置已更新", |
|
|
|
// "A8kEcodeContextListPromptEvent": "设备暂停", |
|
|
|
// }; |
|
|
|
|
|
|
|
// 判断 data 是单个对象还是数组 |
|
|
|
const processEvent = (item: EventType) => { |
|
|
|
// 如果映射表中有对应的事件名称,直接赋值 |
|
|
|
const eventText = eventTypeMap[item.typeName]; |
|
|
|
if (eventText) { |
|
|
|
eventName = eventText; |
|
|
|
} else if (item.typeName === "AppWarningNotifyEvent" && item.error?.code === "USR_NOT_EXIT") { |
|
|
|
// 特定的错误处理 |
|
|
|
eventName = "用户不存在"; |
|
|
|
} else if (item.typeName === "A8kEcodeContextListPromptEvent" && item.error) { |
|
|
|
// 处理 A8kEcodeContextListPromptEvent 类型的特殊逻辑 |
|
|
|
eventName = handleA8kEcodeContextListPromptEvent(item.error); |
|
|
|
} else if (item.typeName === "DoA8kStepActionEvent" && item.error) { |
|
|
|
// 处理步骤执行事件 |
|
|
|
eventName = `步骤${item.error.actionStep}已执行`; |
|
|
|
const processEvent = async (item: EventType) => { |
|
|
|
|
|
|
|
//id卡已插入 |
|
|
|
if (item.typeName === "AppIDCardMountEvent") { |
|
|
|
consumableStore.isIdCardInserted = true; |
|
|
|
idCardInserted.value = true; |
|
|
|
eventName = "id卡已插入" |
|
|
|
} else if (item.typeName === "AppIDCardUnmountEvent") { |
|
|
|
consumableStore.isIdCardInserted = false; |
|
|
|
eventName = "id卡已拔出" |
|
|
|
} else if (item.typeName === "DoA8kStepActionEvent") { |
|
|
|
eventName = item.actionStepName! |
|
|
|
} else if (item.typeName === "AppPromptEvents") { |
|
|
|
//如果propmt是个数组,进行遍历处理事件 |
|
|
|
if (Array.isArray(item.prompt)) { |
|
|
|
console.log("propmt是个数组") |
|
|
|
item.prompt.forEach(async (item) => { |
|
|
|
if (item.type === "Error") { |
|
|
|
showErrorModal.value = true |
|
|
|
ErrorMessage.value = item.info |
|
|
|
await openBuzzer() |
|
|
|
} else if (item.type === "Warn") { |
|
|
|
showWarnModal.value = true |
|
|
|
WarnMessage.value = item.info |
|
|
|
} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
console.log("propmt不是数组", item) |
|
|
|
} |
|
|
|
} else if (item.typeName === "AppTubeholderSettingUpdateEvent ") { |
|
|
|
eventName = "试管架配置更新" |
|
|
|
//剩余逻辑待补充 |
|
|
|
} |
|
|
|
else { |
|
|
|
eventName = "闲置..." |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
if (Array.isArray(data)) { |
|
|
|
// 如果是数组,遍历处理每个 item |
|
|
|
data.forEach(processEvent); |
|
|
@ -188,9 +207,28 @@ const getEvent = async () => { |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
//确认错误事件 |
|
|
|
const confirmError = async () => { |
|
|
|
showErrorModal.value = false |
|
|
|
//关闭蜂鸣器 |
|
|
|
await closeBuzzer() |
|
|
|
} |
|
|
|
//确认警告事件 |
|
|
|
const confirmWarn = async () => { |
|
|
|
|
|
|
|
showWarnModal.value = false |
|
|
|
return |
|
|
|
} |
|
|
|
//保存id卡信息 |
|
|
|
const saveIdInfo = async () => { |
|
|
|
const res = await saveMountedCardInfo(); |
|
|
|
if (res.success) { |
|
|
|
console.log("保存id卡信息成功") |
|
|
|
idCardInserted.value = false; |
|
|
|
} |
|
|
|
} |
|
|
|
// 定义轮询间隔,10秒钟轮询一次 |
|
|
|
const pollingInterval = 10000; |
|
|
|
const pollingInterval = 500; |
|
|
|
let pollingTimer: ReturnType<typeof setInterval>; |
|
|
|
|
|
|
|
onMounted(() => { |
|
|
@ -214,7 +252,10 @@ const generateErrorMessages = (data: CheckItem[]): string[] => { |
|
|
|
// 开始测试 |
|
|
|
const startTest = async () => { |
|
|
|
const res = await startWork(); |
|
|
|
await checkIfResetCompleted() |
|
|
|
const isCheck = sessionStorage.getItem('testStarted'); |
|
|
|
if (!isCheck) { |
|
|
|
await checkIfResetCompleted() |
|
|
|
} |
|
|
|
if (res.success) { |
|
|
|
isTesting.value = true; |
|
|
|
} |
|
|
@ -235,7 +276,6 @@ const stopTest = async () => { |
|
|
|
const res = await stopWork(); |
|
|
|
if (res.success) { |
|
|
|
isTesting.value = false; |
|
|
|
sessionStorage.removeItem('testStarted'); // 清除标记 |
|
|
|
} |
|
|
|
}; |
|
|
|
//继续测试 |
|
|
@ -247,8 +287,8 @@ const continueTest = async () => { |
|
|
|
} |
|
|
|
}; |
|
|
|
const handleConfirm = async () => { |
|
|
|
console.log('用户确认操作'); |
|
|
|
showModal.value = false; // 关闭初始弹窗 |
|
|
|
await initDevice(); // 初始化设备 |
|
|
|
await checkIfResetCompleted(); // 检测是否复位完成 |
|
|
|
}; |
|
|
|
|
|
|
@ -257,19 +297,28 @@ const checkIfResetCompleted = async () => { |
|
|
|
showLoadingModal.value = true; // 显示 LoadingModal |
|
|
|
// 模拟 2 秒延时 |
|
|
|
await new Promise(resolve => setTimeout(resolve, 2000)); |
|
|
|
await getCheckData(); // 重新获取检查数据 |
|
|
|
|
|
|
|
const failedItems = checkData.value.filter(item => !item.pass); |
|
|
|
if (failedItems.length > 0) { |
|
|
|
const errorMessages = generateErrorMessages(failedItems); |
|
|
|
console.log('生成的错误信息:', errorMessages); |
|
|
|
failItems.value = failedItems; // 更新失败的检查项 |
|
|
|
failMessage.value = errorMessages.join('\n'); // 更新错误信息 |
|
|
|
showLoadingModal.value = false; // 隐藏 LoadingModal |
|
|
|
showFailModal.value = true; // 显示失败弹窗 |
|
|
|
} else { |
|
|
|
showLoadingModal.value = false; // 隐藏 LoadingModal |
|
|
|
showAlreadyModal.value = true; // 显示已完成弹窗 |
|
|
|
//通过获取初始化状态来判断是否初始化成功 |
|
|
|
const initState = await getInitState(); |
|
|
|
if (initState.ecode === "SUC") { |
|
|
|
if (initState.data.passed) { |
|
|
|
sessionStorage.setItem('testStarted', "true"); |
|
|
|
showLoadingModal.value = false; |
|
|
|
showAlreadyModal.value = true; |
|
|
|
} else { |
|
|
|
await getCheckData(); // 重新获取检查数据 |
|
|
|
const failedItems = checkData.value.filter(item => !item.pass); |
|
|
|
if (failedItems.length > 0) { |
|
|
|
const errorMessages = generateErrorMessages(failedItems); |
|
|
|
console.log('生成的错误信息:', errorMessages); |
|
|
|
failItems.value = failedItems; // 更新失败的检查项 |
|
|
|
failMessage.value = errorMessages.join('\n'); // 更新错误信息 |
|
|
|
showLoadingModal.value = false; // 隐藏 LoadingModal |
|
|
|
showFailModal.value = true; // 显示失败弹窗 |
|
|
|
} else { |
|
|
|
showLoadingModal.value = false; // 隐藏 LoadingModal |
|
|
|
showAlreadyModal.value = true; // 显示已完成弹窗 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
@ -345,8 +394,8 @@ onMounted(() => { |
|
|
|
#index-container { |
|
|
|
margin: 0; |
|
|
|
padding: 0; |
|
|
|
width: 75rem; |
|
|
|
height: 120.125rem; |
|
|
|
width: 1200px; |
|
|
|
height: 1920px; |
|
|
|
background-color: #fff; |
|
|
|
position: relative; |
|
|
|
box-sizing: border-box; |
|
|
@ -377,7 +426,7 @@ onMounted(() => { |
|
|
|
|
|
|
|
.nav-bar { |
|
|
|
width: 100%; |
|
|
|
height: 5.1875rem; |
|
|
|
height: 83px; |
|
|
|
margin-bottom: 5px; |
|
|
|
display: flex; |
|
|
|
justify-content: space-between; |
|
|
@ -452,7 +501,7 @@ onMounted(() => { |
|
|
|
|
|
|
|
.footer-info { |
|
|
|
width: 1200px; |
|
|
|
height: 3.25rem; |
|
|
|
height: 52px; |
|
|
|
display: flex; |
|
|
|
justify-content: space-between; |
|
|
|
align-items: center; |
|
|
|