266 lines
8.6 KiB
Vue
266 lines
8.6 KiB
Vue
<template>
|
||
<div class="app-container billing-task-page">
|
||
<div v-if="retryFloatVisible" class="retry-status-float">
|
||
<el-tooltip :content="retryFloatTooltip" placement="bottom">
|
||
<el-button class="retry-status-button" type="primary" plain size="small" @click="filterRetryRef.open()">
|
||
<span class="retry-progress-ring" :style="{ '--retry-progress': retryProgressDegree + 'deg' }" aria-hidden="true">
|
||
<span class="retry-progress-value">{{ retryProgressText }}</span>
|
||
</span>
|
||
<span class="retry-status-text">
|
||
<strong>{{ retryFloatTitle }}</strong>
|
||
<small>{{ retryFloatSummary }}</small>
|
||
</span>
|
||
</el-button>
|
||
</el-tooltip>
|
||
</div>
|
||
|
||
<basic-table
|
||
ref="tableRef"
|
||
:columns="columns"
|
||
:search-columns="searchColumns"
|
||
:query="queryList"
|
||
:default-params="defaultParams"
|
||
row-key="taskId"
|
||
selection
|
||
>
|
||
<template #toolbar="{ ids }">
|
||
<el-col :span="1.5">
|
||
<el-button
|
||
type="primary"
|
||
plain
|
||
icon="Refresh"
|
||
v-hasPermi="['monitor:billingTask:retry']"
|
||
@click="filterRetryRef.open()"
|
||
>批量重新同步</el-button>
|
||
</el-col>
|
||
<el-col :span="1.5">
|
||
<el-button
|
||
type="warning"
|
||
plain
|
||
icon="Refresh"
|
||
:disabled="!ids.length"
|
||
:loading="batchLoading"
|
||
v-hasPermi="['monitor:billingTask:retry']"
|
||
@click="handleBatchRetry(ids)"
|
||
>同步选中</el-button>
|
||
</el-col>
|
||
</template>
|
||
<template #col-billType="{ row }">
|
||
<el-tag size="small">{{ billTypeLabel(row.billType) }}</el-tag>
|
||
</template>
|
||
<template #col-successStatus="{ row }">
|
||
<el-tag size="small" :type="statusTag(row.successStatus)">{{ statusLabel(row.successStatus) }}</el-tag>
|
||
</template>
|
||
<template #col-errorMessage="{ row }">
|
||
<span class="err-text" :title="row.errorMessage || ''">{{ row.errorMessage || '-' }}</span>
|
||
</template>
|
||
<template #col-action="{ row }">
|
||
<el-button link type="primary" icon="View" @click="detailRef.open(row)" v-hasPermi="['monitor:billingTask:list']">查看</el-button>
|
||
<el-button
|
||
link
|
||
type="warning"
|
||
icon="Refresh"
|
||
:loading="retryingId === row.taskId"
|
||
v-hasPermi="['monitor:billingTask:retry']"
|
||
@click="handleRetry(row)"
|
||
>重新同步</el-button>
|
||
</template>
|
||
</basic-table>
|
||
|
||
<billing-task-detail-drawer ref="detailRef" />
|
||
<billing-task-filter-retry-dialog
|
||
ref="filterRetryRef"
|
||
@progress="onFilterRetryProgress"
|
||
@success="onFilterRetrySuccess"
|
||
/>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup name="BillingTaskMonitor">
|
||
import { listBillingTask, retryBillingTask, retryBillingTaskBatch } from '@/api/monitor/billingTask'
|
||
import BillingTaskDetailDrawer from './components/BillingTaskDetailDrawer.vue'
|
||
import BillingTaskFilterRetryDialog from './components/BillingTaskFilterRetryDialog.vue'
|
||
import {
|
||
billTypeLabel,
|
||
statusLabel,
|
||
statusTag
|
||
} from './components/billingTaskOptions'
|
||
|
||
const { proxy } = getCurrentInstance()
|
||
const tableRef = ref()
|
||
const detailRef = ref()
|
||
const filterRetryRef = ref()
|
||
const retryingId = ref(null)
|
||
const batchLoading = ref(false)
|
||
const retryFloat = ref(null)
|
||
|
||
const defaultParams = {}
|
||
|
||
const searchColumns = [
|
||
{ label: '转单号', prop: 'transferNo', component: 'input', placeholder: '转单号', width: '180px' },
|
||
{ label: '客户代码', prop: 'customerCode', component: 'input', placeholder: '客户代码', width: '160px' },
|
||
{ label: '计费时间', prop: 'dateRange', component: 'daterange', width: '308px' }
|
||
]
|
||
|
||
const columns = [
|
||
{ label: '任务ID', prop: 'taskId', align: 'center', width: 100 },
|
||
{ label: '客户代码', prop: 'customerCode', minWidth: 120, showOverflowTooltip: true },
|
||
{ label: '订单号', prop: 'orderNo', minWidth: 160, showOverflowTooltip: true },
|
||
{ label: '运单号', prop: 'trackingNo', minWidth: 150, showOverflowTooltip: true },
|
||
{ label: '转单号', prop: 'transferNo', minWidth: 160, showOverflowTooltip: true },
|
||
{ label: '计费类型', prop: 'billType', align: 'center', width: 100, slot: 'billType' },
|
||
{ label: '状态', prop: 'successStatus', align: 'center', width: 100, slot: 'successStatus' },
|
||
{ label: '计费时间', prop: 'billTime', align: 'center', width: 170 },
|
||
{ label: '失败原因', prop: 'errorMessage', minWidth: 220, slot: 'errorMessage', showOverflowTooltip: true },
|
||
{ label: '失败码', prop: 'failCode', align: 'center', width: 180, showOverflowTooltip: true },
|
||
{ label: '创建时间', prop: 'createTime', align: 'center', width: 170 },
|
||
{ label: '操作', prop: 'action', align: 'center', width: 180, fixed: 'right', slot: 'action', showInToolbar: false }
|
||
]
|
||
|
||
const retryFloatVisible = computed(() => {
|
||
const p = retryFloat.value
|
||
return !!(p && (p.loading || p.finished))
|
||
})
|
||
const retryProgressDegree = computed(() => Math.round(((retryFloat.value?.percent || 0) / 100) * 360))
|
||
const retryProgressText = computed(() => (retryFloat.value?.percent || 0) + '%')
|
||
const retryFloatTitle = computed(() => {
|
||
const st = (retryFloat.value?.status || '').toUpperCase()
|
||
if (retryFloat.value?.loading) return '异步重新计费中'
|
||
if (st === 'SUCCESS') return '重新计费完成'
|
||
if (st === 'FAIL') return '重新计费失败'
|
||
return '异步重新计费'
|
||
})
|
||
const retryFloatSummary = computed(() => {
|
||
const p = retryFloat.value || {}
|
||
return '成功 ' + (p.ok || 0) + ' / 失败 ' + (p.fail || 0) + ' / 总数 ' + (p.total || 0)
|
||
})
|
||
const retryFloatTooltip = computed(() => retryFloat.value?.message || '点击查看详情')
|
||
|
||
function queryList(params) {
|
||
const p = proxy.addDateRange({ ...params }, params.dateRange)
|
||
delete p.dateRange
|
||
return listBillingTask(p)
|
||
}
|
||
|
||
function onFilterRetryProgress(payload) {
|
||
retryFloat.value = payload
|
||
if (payload && payload.finished && !payload.loading) {
|
||
window.setTimeout(() => {
|
||
if (retryFloat.value && retryFloat.value.finished && !retryFloat.value.loading) {
|
||
retryFloat.value = null
|
||
}
|
||
}, 8000)
|
||
}
|
||
}
|
||
|
||
function onFilterRetrySuccess() {
|
||
tableRef.value?.refresh()
|
||
}
|
||
|
||
function handleRetry(row) {
|
||
proxy.$modal.confirm('确认重新同步任务 #' + row.taskId + ' ?').then(() => {
|
||
retryingId.value = row.taskId
|
||
return retryBillingTask(row.taskId)
|
||
}).then(res => {
|
||
const task = res.data || {}
|
||
if (task.successStatus === 'SUCCESS') {
|
||
proxy.$modal.msgSuccess('同步成功')
|
||
} else {
|
||
proxy.$modal.msgError(task.errorMessage || '同步失败')
|
||
}
|
||
tableRef.value.refresh()
|
||
}).catch(() => {}).finally(() => {
|
||
retryingId.value = null
|
||
})
|
||
}
|
||
|
||
function handleBatchRetry(ids) {
|
||
if (!ids || !ids.length) return
|
||
proxy.$modal.confirm('确认同步选中的 ' + ids.length + ' 条任务?').then(() => {
|
||
batchLoading.value = true
|
||
return retryBillingTaskBatch(ids)
|
||
}).then(res => {
|
||
const data = res.data || {}
|
||
proxy.$modal.msgSuccess('完成:成功 ' + (data.ok || 0) + ' / 失败 ' + (data.fail || 0))
|
||
tableRef.value.refresh()
|
||
}).catch(() => {}).finally(() => {
|
||
batchLoading.value = false
|
||
})
|
||
}
|
||
</script>
|
||
|
||
<style scoped>
|
||
.err-text {
|
||
color: #f56c6c;
|
||
word-break: break-all;
|
||
}
|
||
|
||
.billing-task-page .retry-status-float {
|
||
position: fixed;
|
||
top: 92px;
|
||
right: 24px;
|
||
z-index: 3001;
|
||
}
|
||
|
||
.billing-task-page .retry-status-button {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
gap: 10px;
|
||
min-width: 200px;
|
||
min-height: 68px;
|
||
padding: 6px 16px 6px 7px;
|
||
border-radius: 36px;
|
||
}
|
||
|
||
.billing-task-page .retry-progress-ring {
|
||
position: relative;
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
flex: 0 0 54px;
|
||
width: 54px;
|
||
height: 54px;
|
||
border-radius: 50%;
|
||
background: conic-gradient(
|
||
var(--el-color-primary) 0deg var(--retry-progress, 45deg),
|
||
var(--el-color-primary-light-8) var(--retry-progress, 45deg) 360deg
|
||
);
|
||
}
|
||
|
||
.billing-task-page .retry-progress-ring::after {
|
||
position: absolute;
|
||
inset: 5px;
|
||
content: '';
|
||
border-radius: 50%;
|
||
background: var(--el-bg-color);
|
||
}
|
||
|
||
.billing-task-page .retry-progress-value {
|
||
position: relative;
|
||
z-index: 1;
|
||
color: var(--el-color-primary);
|
||
font-size: 12px;
|
||
font-weight: 600;
|
||
line-height: 1;
|
||
}
|
||
|
||
.billing-task-page .retry-status-text {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: flex-start;
|
||
gap: 3px;
|
||
line-height: 1.2;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.billing-task-page .retry-status-text strong {
|
||
font-size: 14px;
|
||
font-weight: 600;
|
||
}
|
||
|
||
.billing-task-page .retry-status-text small {
|
||
color: var(--el-text-color-secondary);
|
||
font-size: 11px;
|
||
}
|
||
</style>
|