This commit is contained in:
@@ -0,0 +1,278 @@
|
||||
<template>
|
||||
<ArtTableFullScreen>
|
||||
<div class="unbind-import-task-detail-page" id="table-full-screen">
|
||||
<ElCard shadow="never" class="art-table-card">
|
||||
<div class="detail-header">
|
||||
<ElButton @click="goBack">
|
||||
<template #icon>
|
||||
<ElIcon><ArrowLeft /></ElIcon>
|
||||
</template>
|
||||
返回
|
||||
</ElButton>
|
||||
<h2 class="detail-title">解绑导入任务详情</h2>
|
||||
</div>
|
||||
|
||||
<div v-if="loading && !taskDetail" class="detail-loading">
|
||||
<ElIcon class="is-loading" :size="36">
|
||||
<Loading />
|
||||
</ElIcon>
|
||||
<div>加载中...</div>
|
||||
</div>
|
||||
<template v-else-if="taskDetail">
|
||||
<DetailPage :sections="detailSections" :data="taskDetail" />
|
||||
|
||||
<div class="row-table-title">逐行结果</div>
|
||||
<ElTable :data="taskDetail.items || []" border stripe size="default" max-height="460">
|
||||
<ElTableColumn prop="line" label="行号" width="80" />
|
||||
<ElTableColumn
|
||||
prop="asset_identifier"
|
||||
label="资产标识(原文)"
|
||||
min-width="180"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<ElTableColumn prop="asset_type" label="资产类型" width="110">
|
||||
<template #default="{ row }">
|
||||
{{ row.asset_type ? (row.asset_type === 'iot_card' ? '物联网卡' : '设备') : '-' }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="asset_id" label="资产ID" width="100">
|
||||
<template #default="{ row }">
|
||||
{{ row.asset_id ? row.asset_id : '-' }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="status" label="行状态" width="90">
|
||||
<template #default="{ row }">
|
||||
<ElTag :type="row.status === 3 ? 'success' : 'danger'" size="small">
|
||||
{{ row.status_name || (row.status === 3 ? '成功' : '失败') }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
prop="associated_phones"
|
||||
label="解绑时关联手机号"
|
||||
min-width="200"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{ (row.associated_phones || []).join('、') || '-' }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="unbound_count" label="解除关系数" width="100" />
|
||||
<ElTableColumn prop="reason" label="失败原因" min-width="200" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ row.reason || '-' }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
</template>
|
||||
<ElEmpty v-else description="暂无详情" />
|
||||
</ElCard>
|
||||
</div>
|
||||
</ArtTableFullScreen>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, h, onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ElButton, ElCard, ElEmpty, ElIcon, ElMessage, ElTag } from 'element-plus'
|
||||
import { ArrowLeft, Loading } from '@element-plus/icons-vue'
|
||||
import DetailPage from '@/components/common/DetailPage.vue'
|
||||
import type { DetailSection } from '@/components/common/DetailPage.vue'
|
||||
import { PhoneAssetAssociationService } from '@/api/modules'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
import { normalizeApiError } from '@/utils/business/apiError'
|
||||
import { RoutesAlias } from '@/router/routesAlias'
|
||||
import { AUGUST_PERMISSIONS } from '@/config/constants'
|
||||
import type {
|
||||
PhoneAssetUnbindImportTaskDetail,
|
||||
PhoneAssetUnbindImportTaskStatus
|
||||
} from '@/types/api'
|
||||
|
||||
defineOptions({ name: 'PhoneAssetUnbindImportTaskDetail' })
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const { hasAuth } = useAuth()
|
||||
|
||||
const taskId = computed(() => Number(route.query.id || route.params.id || 0))
|
||||
const loading = ref(false)
|
||||
const taskDetail = ref<PhoneAssetUnbindImportTaskDetail | null>(null)
|
||||
let pollTimer: ReturnType<typeof setInterval> | null = null
|
||||
|
||||
const getStatusTagType = (status?: PhoneAssetUnbindImportTaskStatus) => {
|
||||
const map: Record<number, 'info' | 'warning' | 'success' | 'danger'> = {
|
||||
1: 'info',
|
||||
2: 'warning',
|
||||
3: 'success',
|
||||
4: 'danger'
|
||||
}
|
||||
return status ? map[status] || 'info' : 'info'
|
||||
}
|
||||
|
||||
const fetchDetail = async () => {
|
||||
if (!taskId.value) {
|
||||
ElMessage.error('缺少任务ID')
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await PhoneAssetAssociationService.getUnbindImportTaskDetail(taskId.value)
|
||||
if (res.code === 403) {
|
||||
ElMessage.error(res.msg || '无权限查看该任务详情')
|
||||
return
|
||||
}
|
||||
if (res.code !== 0 || !res.data) {
|
||||
ElMessage.error(res.msg || '获取解绑导入任务详情失败')
|
||||
return
|
||||
}
|
||||
taskDetail.value = res.data
|
||||
startPollingIfNeeded()
|
||||
} catch (error) {
|
||||
console.error('获取解绑导入任务详情失败:', error)
|
||||
ElMessage.error(normalizeApiError(error).message || '获取解绑导入任务详情失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const startPollingIfNeeded = () => {
|
||||
const status = taskDetail.value?.status
|
||||
if (status === 1 || status === 2) {
|
||||
if (!pollTimer) {
|
||||
pollTimer = setInterval(fetchDetail, 5000)
|
||||
}
|
||||
} else {
|
||||
stopPolling()
|
||||
}
|
||||
}
|
||||
|
||||
const stopPolling = () => {
|
||||
if (pollTimer) {
|
||||
clearInterval(pollTimer)
|
||||
pollTimer = null
|
||||
}
|
||||
}
|
||||
|
||||
const detailSections = computed((): DetailSection[] => {
|
||||
const data = taskDetail.value
|
||||
if (!data) return []
|
||||
return [
|
||||
{
|
||||
title: '任务基本信息',
|
||||
fields: [
|
||||
{ label: '任务编号', prop: 'task_no', formatter: (value: string) => value || '-' },
|
||||
{ label: '文件名', prop: 'file_name', formatter: (value: string) => value || '-' },
|
||||
{
|
||||
label: '任务状态',
|
||||
render: (task: PhoneAssetUnbindImportTaskDetail) =>
|
||||
h(ElTag, { type: getStatusTagType(task.status) }, () => task.status_name || '-')
|
||||
},
|
||||
{
|
||||
label: '任务级解绑原因',
|
||||
prop: 'unbind_reason',
|
||||
fullWidth: true,
|
||||
formatter: (value: string) => value || '-'
|
||||
},
|
||||
{
|
||||
label: '创建人',
|
||||
prop: 'creator_name',
|
||||
formatter: (value: string) => value || '-'
|
||||
},
|
||||
{
|
||||
label: '创建时间',
|
||||
prop: 'created_at',
|
||||
formatter: (value: string) => formatDateTime(value) || '-'
|
||||
},
|
||||
{
|
||||
label: '开始时间',
|
||||
prop: 'started_at',
|
||||
formatter: (value: string) => formatDateTime(value) || '-'
|
||||
},
|
||||
{
|
||||
label: '完成时间',
|
||||
prop: 'completed_at',
|
||||
formatter: (value: string) => formatDateTime(value) || '-'
|
||||
},
|
||||
{
|
||||
label: '任务级错误',
|
||||
prop: 'error_message',
|
||||
fullWidth: true,
|
||||
formatter: (value: string) => value || '-'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: '处理统计',
|
||||
fields: [
|
||||
{
|
||||
label: '数据行总数',
|
||||
prop: 'total_count',
|
||||
formatter: (value: number) => String(value ?? 0)
|
||||
},
|
||||
{
|
||||
label: '成功行数',
|
||||
prop: 'success_count',
|
||||
formatter: (value: number) => String(value ?? 0)
|
||||
},
|
||||
{
|
||||
label: '失败行数',
|
||||
prop: 'fail_count',
|
||||
formatter: (value: number) => String(value ?? 0)
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
const goBack = () => {
|
||||
router.push(RoutesAlias.PhoneAssetUnbindImportTasks)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (!hasAuth(AUGUST_PERMISSIONS.phoneAssetAssociation.unbindImportDetail)) {
|
||||
ElMessage.warning('您没有查看解绑导入任务详情的权限')
|
||||
goBack()
|
||||
return
|
||||
}
|
||||
fetchDetail()
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
stopPolling()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.unbind-import-task-detail-page {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.detail-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
|
||||
.detail-title {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.detail-loading {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 60px 0;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.row-table-title {
|
||||
margin: 20px 0 12px;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,294 @@
|
||||
<template>
|
||||
<ArtTableFullScreen>
|
||||
<div class="unbind-import-tasks-page" id="table-full-screen">
|
||||
<ArtSearchBar
|
||||
v-model:filter="searchForm"
|
||||
:items="searchFormItems"
|
||||
:show-expand="false"
|
||||
@reset="handleReset"
|
||||
@search="handleSearch"
|
||||
/>
|
||||
|
||||
<ElCard shadow="never" class="art-table-card">
|
||||
<ArtTableHeader
|
||||
:columnList="columnOptions"
|
||||
v-model:columns="columnChecks"
|
||||
@refresh="handleRefresh"
|
||||
>
|
||||
<template #left>
|
||||
<ElButton @click="goAssociationList">返回关联列表</ElButton>
|
||||
</template>
|
||||
</ArtTableHeader>
|
||||
|
||||
<ArtTable
|
||||
:loading="loading"
|
||||
:data="taskList"
|
||||
:currentPage="pagination.page"
|
||||
:pageSize="pagination.pageSize"
|
||||
:total="pagination.total"
|
||||
:marginTop="10"
|
||||
:actions="getActions"
|
||||
:actionsWidth="90"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
>
|
||||
<template #default>
|
||||
<ElTableColumn v-for="col in columns" :key="col.prop || col.type" v-bind="col" />
|
||||
</template>
|
||||
</ArtTable>
|
||||
</ElCard>
|
||||
</div>
|
||||
</ArtTableFullScreen>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, h, onMounted, reactive, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ElMessage, ElTag } from 'element-plus'
|
||||
import { PhoneAssetAssociationService } from '@/api/modules'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
import { useCheckedColumns } from '@/composables/useCheckedColumns'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
import { normalizeApiError } from '@/utils/business/apiError'
|
||||
import { RoutesAlias } from '@/router/routesAlias'
|
||||
import { AUGUST_PERMISSIONS } from '@/config/constants'
|
||||
import type { SearchFormItem } from '@/types'
|
||||
import type { PhoneAssetUnbindImportTask, PhoneAssetUnbindImportTaskStatus } from '@/types/api'
|
||||
|
||||
defineOptions({ name: 'PhoneAssetUnbindImportTasks' })
|
||||
|
||||
const router = useRouter()
|
||||
const { hasAuth } = useAuth()
|
||||
const perms = AUGUST_PERMISSIONS.phoneAssetAssociation
|
||||
|
||||
const canDetail = computed(() => hasAuth(perms.unbindImportDetail))
|
||||
|
||||
const loading = ref(false)
|
||||
const taskList = ref<PhoneAssetUnbindImportTask[]>([])
|
||||
const pagination = reactive({ page: 1, pageSize: 20, total: 0 })
|
||||
|
||||
const initialSearchState = {
|
||||
status: undefined as PhoneAssetUnbindImportTaskStatus | undefined
|
||||
}
|
||||
|
||||
const searchForm = reactive({ ...initialSearchState })
|
||||
|
||||
const statusOptions = [
|
||||
{ label: '待处理', value: 1 },
|
||||
{ label: '处理中', value: 2 },
|
||||
{ label: '已完成', value: 3 },
|
||||
{ label: '失败', value: 4 }
|
||||
]
|
||||
|
||||
const searchFormItems: SearchFormItem[] = [
|
||||
{
|
||||
label: '任务状态',
|
||||
prop: 'status',
|
||||
type: 'select',
|
||||
config: { clearable: true, placeholder: '全部' },
|
||||
options: () => statusOptions
|
||||
}
|
||||
]
|
||||
|
||||
const columnOptions = [
|
||||
{ label: '任务编号', prop: 'task_no' },
|
||||
{ label: '文件名', prop: 'file_name' },
|
||||
{ label: '状态', prop: 'status' },
|
||||
{ label: '总行数', prop: 'total_count' },
|
||||
{ label: '成功行数', prop: 'success_count' },
|
||||
{ label: '失败行数', prop: 'fail_count' },
|
||||
{ label: '任务级原因', prop: 'unbind_reason' },
|
||||
{ label: '创建人', prop: 'creator_name' },
|
||||
{ label: '创建时间', prop: 'created_at' },
|
||||
{ label: '开始时间', prop: 'started_at' },
|
||||
{ label: '完成时间', prop: 'completed_at' },
|
||||
{ label: '任务级错误', prop: 'error_message' }
|
||||
]
|
||||
|
||||
const getStatusTagType = (status?: PhoneAssetUnbindImportTaskStatus) => {
|
||||
const map: Record<number, 'info' | 'warning' | 'success' | 'danger'> = {
|
||||
1: 'info',
|
||||
2: 'warning',
|
||||
3: 'success',
|
||||
4: 'danger'
|
||||
}
|
||||
return status ? map[status] || 'info' : 'info'
|
||||
}
|
||||
|
||||
const { columnChecks, columns } = useCheckedColumns(() => [
|
||||
{
|
||||
prop: 'task_no',
|
||||
label: '任务编号',
|
||||
minWidth: 170,
|
||||
showOverflowTooltip: true,
|
||||
formatter: (row: PhoneAssetUnbindImportTask) =>
|
||||
h(
|
||||
'span',
|
||||
{
|
||||
class: 'task-no-link',
|
||||
onClick: () => goDetail(row)
|
||||
},
|
||||
row.task_no || '-'
|
||||
)
|
||||
},
|
||||
{
|
||||
prop: 'file_name',
|
||||
label: '文件名',
|
||||
minWidth: 180,
|
||||
showOverflowTooltip: true,
|
||||
formatter: (row: PhoneAssetUnbindImportTask) => row.file_name || '-'
|
||||
},
|
||||
{
|
||||
prop: 'status',
|
||||
label: '状态',
|
||||
width: 100,
|
||||
formatter: (row: PhoneAssetUnbindImportTask) =>
|
||||
h(ElTag, { type: getStatusTagType(row.status) }, () => row.status_name || '-')
|
||||
},
|
||||
{
|
||||
prop: 'total_count',
|
||||
label: '总行数',
|
||||
width: 90,
|
||||
formatter: (row: PhoneAssetUnbindImportTask) => row.total_count ?? 0
|
||||
},
|
||||
{
|
||||
prop: 'success_count',
|
||||
label: '成功行数',
|
||||
width: 90,
|
||||
formatter: (row: PhoneAssetUnbindImportTask) => row.success_count ?? 0
|
||||
},
|
||||
{
|
||||
prop: 'fail_count',
|
||||
label: '失败行数',
|
||||
width: 90,
|
||||
formatter: (row: PhoneAssetUnbindImportTask) => row.fail_count ?? 0
|
||||
},
|
||||
{
|
||||
prop: 'unbind_reason',
|
||||
label: '任务级原因',
|
||||
minWidth: 160,
|
||||
showOverflowTooltip: true,
|
||||
formatter: (row: PhoneAssetUnbindImportTask) => row.unbind_reason || '-'
|
||||
},
|
||||
{
|
||||
prop: 'creator_name',
|
||||
label: '创建人',
|
||||
width: 120,
|
||||
formatter: (row: PhoneAssetUnbindImportTask) => row.creator_name || '-'
|
||||
},
|
||||
{
|
||||
prop: 'created_at',
|
||||
label: '创建时间',
|
||||
minWidth: 170,
|
||||
formatter: (row: PhoneAssetUnbindImportTask) => formatDateTime(row.created_at) || '-'
|
||||
},
|
||||
{
|
||||
prop: 'started_at',
|
||||
label: '开始时间',
|
||||
minWidth: 170,
|
||||
formatter: (row: PhoneAssetUnbindImportTask) => formatDateTime(row.started_at) || '-'
|
||||
},
|
||||
{
|
||||
prop: 'completed_at',
|
||||
label: '完成时间',
|
||||
minWidth: 170,
|
||||
formatter: (row: PhoneAssetUnbindImportTask) => formatDateTime(row.completed_at) || '-'
|
||||
},
|
||||
{
|
||||
prop: 'error_message',
|
||||
label: '任务级错误',
|
||||
minWidth: 160,
|
||||
showOverflowTooltip: true,
|
||||
formatter: (row: PhoneAssetUnbindImportTask) => row.error_message || '-'
|
||||
}
|
||||
])
|
||||
|
||||
const getTableData = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await PhoneAssetAssociationService.getUnbindImportTasks({
|
||||
page: pagination.page,
|
||||
page_size: pagination.pageSize,
|
||||
status: searchForm.status
|
||||
})
|
||||
if (res.code === 0 && res.data) {
|
||||
taskList.value = res.data.items || []
|
||||
pagination.total = res.data.total || 0
|
||||
} else {
|
||||
ElMessage.error(res.msg || '获取解绑导入任务列表失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取解绑导入任务列表失败:', error)
|
||||
ElMessage.error(normalizeApiError(error).message || '获取解绑导入任务列表失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleReset = () => {
|
||||
Object.assign(searchForm, { ...initialSearchState })
|
||||
pagination.page = 1
|
||||
getTableData()
|
||||
}
|
||||
|
||||
const handleSearch = () => {
|
||||
pagination.page = 1
|
||||
getTableData()
|
||||
}
|
||||
|
||||
const handleRefresh = () => {
|
||||
getTableData()
|
||||
}
|
||||
|
||||
const handleSizeChange = (pageSize: number) => {
|
||||
pagination.pageSize = pageSize
|
||||
getTableData()
|
||||
}
|
||||
|
||||
const handleCurrentChange = (page: number) => {
|
||||
pagination.page = page
|
||||
getTableData()
|
||||
}
|
||||
|
||||
const goDetail = (row: PhoneAssetUnbindImportTask) => {
|
||||
if (!canDetail.value) {
|
||||
ElMessage.warning('您没有查看解绑导入任务详情的权限')
|
||||
return
|
||||
}
|
||||
router.push({
|
||||
path: RoutesAlias.PhoneAssetUnbindImportTaskDetail,
|
||||
query: { id: String(row.id) }
|
||||
})
|
||||
}
|
||||
|
||||
const getActions = (row: PhoneAssetUnbindImportTask) => {
|
||||
const actions: any[] = []
|
||||
if (canDetail.value) {
|
||||
actions.push({ label: '详情', handler: () => goDetail(row), type: 'primary' })
|
||||
}
|
||||
return actions
|
||||
}
|
||||
|
||||
const goAssociationList = () => {
|
||||
router.push(RoutesAlias.PhoneAssetAssociation)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getTableData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.unbind-import-tasks-page {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
:deep(.task-no-link) {
|
||||
color: var(--el-color-primary);
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user