新增:隐患检查主页添加运行日志
This commit is contained in:
parent
ed64a9c5a3
commit
45e3a8b754
|
|
@ -11,6 +11,8 @@ const runCheckBtnRef = ref()
|
|||
const isRunningCheck = ref(false)
|
||||
const vidPaths = ref<string[]>([])
|
||||
|
||||
const processLog = ref<string[]>([])
|
||||
|
||||
interface RuleForm {
|
||||
vidPath: string
|
||||
function: string[]
|
||||
|
|
@ -76,20 +78,38 @@ async function runCheck(formEl: FormInstance | undefined) {
|
|||
}
|
||||
}
|
||||
|
||||
function formatTime(date: Date) {
|
||||
return `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')} ${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}:${date.getSeconds().toString().padStart(2, '0')}`
|
||||
}
|
||||
|
||||
async function runProcess() {
|
||||
isRunningCheck.value = true
|
||||
startTimer()
|
||||
const tasks: Promise<any>[] = []
|
||||
processLog.value = []
|
||||
processLog.value.push(`[${formatTime(new Date())}] 💬开始运行...`)
|
||||
|
||||
if (ruleForm.function.includes('runAudioRecognition')) {
|
||||
tasks.push(runApiAudio('recognize', 'GET', {
|
||||
path: vidPaths.value[vidPaths.value.indexOf(ruleForm.vidPath)],
|
||||
}).then((res) => {
|
||||
if (res === 'error')
|
||||
processLog.value.push(`[${formatTime(new Date())}] ❌️音频识别失败`)
|
||||
else
|
||||
processLog.value.push(`[${formatTime(new Date())}] ✅️音频识别完成`)
|
||||
return res
|
||||
}))
|
||||
}
|
||||
|
||||
if (ruleForm.function.includes('convertToMp4')) {
|
||||
tasks.push(runApiAudio('convert', 'GET', {
|
||||
path: vidPaths.value[vidPaths.value.indexOf(ruleForm.vidPath)],
|
||||
}).then((res) => {
|
||||
if (res === 'error')
|
||||
processLog.value.push(`[${formatTime(new Date())}] ❌️转码失败`)
|
||||
else
|
||||
processLog.value.push(`[${formatTime(new Date())}] ✅️转码完成`)
|
||||
return res
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
@ -98,21 +118,31 @@ async function runProcess() {
|
|||
run_sam3: ruleForm.function.includes('runSam3'),
|
||||
run_inspection: ruleForm.function.includes('runHazardCheck'),
|
||||
gen_report: ruleForm.function.includes('runGenerateReport'),
|
||||
}).then((res) => {
|
||||
if (res === 'error')
|
||||
processLog.value.push(`[${formatTime(new Date())}] ❌️隐患检测结果不存在或运行失败`)
|
||||
else
|
||||
processLog.value.push(`[${formatTime(new Date())}] ✅️隐患检测完成`)
|
||||
return res
|
||||
}))
|
||||
|
||||
await Promise.all(tasks).then((results) => {
|
||||
isRunningCheck.value = false
|
||||
stopTimer()
|
||||
processLog.value.push(`[${formatTime(new Date())}] 💬运行结束,耗时${timerDisplay.value}`)
|
||||
// 判定是否成功运行
|
||||
const lastRes = results[results.length - 1]
|
||||
if (lastRes !== 'error') {
|
||||
router.push({
|
||||
path: '/nav/hazardCheckResult',
|
||||
query: { vid_file: vidPaths.value[vidPaths.value.indexOf(ruleForm.vidPath)] },
|
||||
})
|
||||
for (const res of results) {
|
||||
// console.log('判定', String(res))
|
||||
if (res === 'error') {
|
||||
return
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
stopTimer()
|
||||
router.push({
|
||||
path: '/nav/hazardCheckResult',
|
||||
query: { vid_file: vidPaths.value[vidPaths.value.indexOf(ruleForm.vidPath)] },
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async function reloadFiles() {
|
||||
|
|
@ -213,6 +243,18 @@ onMounted(() => {
|
|||
>
|
||||
<el-text>{{ timerDisplay }}</el-text>
|
||||
</el-progress>
|
||||
<div v-if="processLog.length > 0" class="log-container">
|
||||
<div class="log-header">
|
||||
<el-text size="large">
|
||||
运行日志
|
||||
</el-text>
|
||||
</div>
|
||||
<div v-for="(item, index) in processLog" :key="index" class="log-item">
|
||||
<el-text :key="item" type="info">
|
||||
{{ item }}
|
||||
</el-text>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-main>
|
||||
</el-container>
|
||||
|
|
@ -231,4 +273,13 @@ onMounted(() => {
|
|||
gap: 16px;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.log-container {
|
||||
// text-align: left;
|
||||
margin-top: 20px;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
Loading…
Reference in New Issue