155 lines
4.8 KiB
Vue
155 lines
4.8 KiB
Vue
|
|
<template>
|
||
|
|
<ContentWrap>
|
||
|
|
<el-alert
|
||
|
|
title="任务按样件逐件执行。先完成接收、夹具与扫描方案准备,再确认装夹并开始每一件。"
|
||
|
|
type="info"
|
||
|
|
:closable="false"
|
||
|
|
class="mb-16px"
|
||
|
|
/>
|
||
|
|
<el-form inline :model="query" @submit.prevent="search">
|
||
|
|
<el-form-item label="任务编号"
|
||
|
|
><el-input v-model="query.taskNo" clearable @keyup.enter="search"
|
||
|
|
/></el-form-item>
|
||
|
|
<el-form-item label="状态"
|
||
|
|
><el-select v-model="query.status" clearable class="!w-160px"
|
||
|
|
><el-option
|
||
|
|
v-for="status in statuses"
|
||
|
|
:key="status"
|
||
|
|
:value="status"
|
||
|
|
:label="statusLabel(status)" /></el-select
|
||
|
|
></el-form-item>
|
||
|
|
<el-form-item
|
||
|
|
><el-button type="primary" @click="search">搜索</el-button
|
||
|
|
><el-button @click="load">刷新</el-button
|
||
|
|
><el-button @click="push('/lab/task/import')">任务导入</el-button></el-form-item
|
||
|
|
>
|
||
|
|
</el-form>
|
||
|
|
</ContentWrap>
|
||
|
|
<ContentWrap>
|
||
|
|
<el-table v-loading="loading" :data="rows">
|
||
|
|
<el-table-column label="任务编号" prop="taskNo" min-width="180" />
|
||
|
|
<el-table-column label="任务名称" prop="taskName" min-width="180" show-overflow-tooltip />
|
||
|
|
<el-table-column label="外部任务编号" prop="externalTaskNo" min-width="160" />
|
||
|
|
<el-table-column label="扫描方案 / 测试用例" min-width="200"
|
||
|
|
><template #default="{ row }">{{
|
||
|
|
row.caseName || row.testCaseId || '待关联'
|
||
|
|
}}</template></el-table-column
|
||
|
|
>
|
||
|
|
<el-table-column label="完成件数" width="110"
|
||
|
|
><template #default="{ row }"
|
||
|
|
>{{ row.completedCount || 0 }} / {{ row.quantity || 0 }}</template
|
||
|
|
></el-table-column
|
||
|
|
>
|
||
|
|
<el-table-column label="状态" width="130"
|
||
|
|
><template #default="{ row }"
|
||
|
|
><el-tag
|
||
|
|
:type="
|
||
|
|
row.status === 'COMPLETED'
|
||
|
|
? 'success'
|
||
|
|
: ['FAILED', 'BLOCKED', 'STOP_PENDING'].includes(row.status)
|
||
|
|
? 'danger'
|
||
|
|
: 'info'
|
||
|
|
"
|
||
|
|
>{{ statusLabel(row.status) }}</el-tag
|
||
|
|
></template
|
||
|
|
></el-table-column
|
||
|
|
>
|
||
|
|
<el-table-column label="负责人" width="120"
|
||
|
|
><template #default="{ row }">{{
|
||
|
|
row.ownerName || (row.ownerId ? row.ownerId : '未领取')
|
||
|
|
}}</template></el-table-column
|
||
|
|
>
|
||
|
|
<el-table-column label="操作" width="150" fixed="right"
|
||
|
|
><template #default="{ row }"
|
||
|
|
><el-button
|
||
|
|
link
|
||
|
|
type="primary"
|
||
|
|
@click="push({ name: 'LabScanTaskWorkbench', params: { id: String(row.id) } })"
|
||
|
|
>{{
|
||
|
|
['COMPLETED', 'CANCELLED'].includes(row.status) ? '查看记录' : '准备与执行'
|
||
|
|
}}</el-button
|
||
|
|
></template
|
||
|
|
></el-table-column
|
||
|
|
>
|
||
|
|
</el-table>
|
||
|
|
<Pagination
|
||
|
|
:total="total"
|
||
|
|
v-model:page="query.pageNo"
|
||
|
|
v-model:limit="query.pageSize"
|
||
|
|
@pagination="load"
|
||
|
|
/>
|
||
|
|
</ContentWrap>
|
||
|
|
</template>
|
||
|
|
<script setup lang="ts">
|
||
|
|
import * as ScanApi from '@/api/lab/scan-task'
|
||
|
|
import { statusLabel } from '@/views/lab/scan-task/scanForm.mjs'
|
||
|
|
defineOptions({ name: 'LabExecution' })
|
||
|
|
const { push } = useRouter()
|
||
|
|
const route = useRoute()
|
||
|
|
const loading = ref(false)
|
||
|
|
const rows = ref<ScanApi.ScanTaskRow[]>([])
|
||
|
|
const total = ref(0)
|
||
|
|
const query = reactive({
|
||
|
|
pageNo: 1,
|
||
|
|
pageSize: 10,
|
||
|
|
taskNo: String(route.query.taskNo || ''),
|
||
|
|
status: (route.query.status === 'RUNNING'
|
||
|
|
? 'EXECUTING'
|
||
|
|
: route.query.status
|
||
|
|
? String(route.query.status)
|
||
|
|
: undefined) as string | undefined
|
||
|
|
})
|
||
|
|
const statuses = [
|
||
|
|
'PENDING_CONFIRM',
|
||
|
|
'CONFIRMED',
|
||
|
|
'CLAIMED',
|
||
|
|
'PREPARING',
|
||
|
|
'READY',
|
||
|
|
'EXECUTING',
|
||
|
|
'BLOCKED',
|
||
|
|
'STOP_PENDING',
|
||
|
|
'COMPLETED',
|
||
|
|
'CANCELLED'
|
||
|
|
]
|
||
|
|
let requestVersion = 0
|
||
|
|
const load = async () => {
|
||
|
|
const request = ++requestVersion
|
||
|
|
loading.value = true
|
||
|
|
try {
|
||
|
|
const result = await ScanApi.getPage(query)
|
||
|
|
if (request !== requestVersion) return
|
||
|
|
rows.value = result.list || []
|
||
|
|
total.value = result.total
|
||
|
|
} finally {
|
||
|
|
if (request === requestVersion) loading.value = false
|
||
|
|
}
|
||
|
|
}
|
||
|
|
const search = () => {
|
||
|
|
query.pageNo = 1
|
||
|
|
load()
|
||
|
|
}
|
||
|
|
let timer: ReturnType<typeof setInterval> | undefined
|
||
|
|
const startPolling = () => {
|
||
|
|
if (timer) return
|
||
|
|
load().catch(() => {})
|
||
|
|
timer = setInterval(() => {
|
||
|
|
if (!loading.value && !document.hidden) load().catch(() => {})
|
||
|
|
}, 10000)
|
||
|
|
}
|
||
|
|
const stopPolling = () => {
|
||
|
|
requestVersion++
|
||
|
|
clearInterval(timer)
|
||
|
|
timer = undefined
|
||
|
|
loading.value = false
|
||
|
|
}
|
||
|
|
onMounted(startPolling)
|
||
|
|
watch(() => [route.query.taskNo, route.query.status], () => {
|
||
|
|
query.taskNo = String(route.query.taskNo || '')
|
||
|
|
query.status = route.query.status === 'RUNNING' ? 'EXECUTING' : route.query.status ? String(route.query.status) : undefined
|
||
|
|
search()
|
||
|
|
})
|
||
|
|
onActivated(startPolling)
|
||
|
|
onDeactivated(stopPolling)
|
||
|
|
onUnmounted(stopPolling)
|
||
|
|
</script>
|