Merge branch 'develop'
This commit is contained in:
@@ -1,17 +1,12 @@
|
||||
<template>
|
||||
<ElCard shadow="never" class="search-card">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span>资产查询</span>
|
||||
<ElButton type="danger" @click="handleGoBack">返回上次搜索</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
<div class="search-area">
|
||||
<div class="iccid-search">
|
||||
<div class="iccid-input-wrapper">
|
||||
<ElInput
|
||||
v-model="searchIccid"
|
||||
placeholder="请输入虚拟号、ICCID、IMEI、SN或MSISDN"
|
||||
clearable
|
||||
:prefix-icon="Search"
|
||||
class="asset-search-input"
|
||||
@focus="iccidInputFocused = true"
|
||||
@blur="iccidInputFocused = false"
|
||||
@@ -40,18 +35,19 @@
|
||||
:icon="Refresh"
|
||||
:disabled="refreshDisabled"
|
||||
>
|
||||
{{ refreshButtonText }}
|
||||
同步
|
||||
</ElButton>
|
||||
<ElButton type="default" plain :icon="Back" @click="handleGoBack"> 返回上次搜索 </ElButton>
|
||||
</div>
|
||||
</div>
|
||||
</ElCard>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue'
|
||||
import { ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { ElCard, ElInput, ElButton } from 'element-plus'
|
||||
import { Search, Refresh } from '@element-plus/icons-vue'
|
||||
import { ElInput, ElButton } from 'element-plus'
|
||||
import { Back, Search, Refresh } from '@element-plus/icons-vue'
|
||||
import { useAssetFormatters } from '../composables/useAssetFormatters'
|
||||
|
||||
// Use formatters
|
||||
@@ -63,19 +59,13 @@
|
||||
interface Props {
|
||||
hasCardInfo?: boolean
|
||||
refreshDisabled?: boolean
|
||||
refreshRemainingText?: string
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
withDefaults(defineProps<Props>(), {
|
||||
hasCardInfo: false,
|
||||
refreshDisabled: false,
|
||||
refreshRemainingText: ''
|
||||
refreshDisabled: false
|
||||
})
|
||||
|
||||
const refreshButtonText = computed(() =>
|
||||
props.refreshRemainingText ? `同步(${props.refreshRemainingText})` : '同步'
|
||||
)
|
||||
|
||||
// Emits
|
||||
const emit = defineEmits<{
|
||||
search: [payload: { identifier: string }]
|
||||
@@ -141,103 +131,87 @@
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.search-card {
|
||||
.search-area {
|
||||
position: relative;
|
||||
z-index: 20;
|
||||
margin-bottom: 20px;
|
||||
overflow: visible;
|
||||
background: var(--el-bg-color, #fff);
|
||||
}
|
||||
|
||||
:deep(.el-card__header) {
|
||||
padding: 16px 20px;
|
||||
background: var(--el-fill-color-light);
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
.iccid-search {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
align-items: flex-start;
|
||||
overflow: visible;
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
}
|
||||
.iccid-input-wrapper {
|
||||
position: relative;
|
||||
flex: 1 1 360px;
|
||||
min-width: 240px;
|
||||
|
||||
:deep(.el-card__body) {
|
||||
padding: 16px 20px;
|
||||
overflow: visible;
|
||||
}
|
||||
.asset-search-input {
|
||||
width: 100%;
|
||||
|
||||
.iccid-search {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
align-items: flex-start;
|
||||
|
||||
.iccid-input-wrapper {
|
||||
position: relative;
|
||||
flex: 1 1 360px;
|
||||
min-width: 240px;
|
||||
|
||||
.asset-search-input {
|
||||
width: 100%;
|
||||
:deep(.el-input__prefix) {
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
.iccid-magnifier {
|
||||
.iccid-magnifier {
|
||||
position: absolute;
|
||||
top: calc(100% + 12px);
|
||||
left: 0;
|
||||
z-index: 2000;
|
||||
white-space: nowrap;
|
||||
|
||||
.magnifier-arrow {
|
||||
position: absolute;
|
||||
top: calc(100% + 12px);
|
||||
left: 0;
|
||||
z-index: 1000;
|
||||
white-space: nowrap;
|
||||
top: -9px;
|
||||
left: 80px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background-color: var(--el-color-primary-light-9);
|
||||
border-top: 2px solid var(--el-color-primary);
|
||||
border-left: 2px solid var(--el-color-primary);
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
// 三角箭头 - 上边框样式
|
||||
.magnifier-arrow {
|
||||
position: absolute;
|
||||
top: -9px;
|
||||
left: 80px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background-color: var(--el-bg-color, #fff);
|
||||
border-top: 2px solid var(--el-color-primary);
|
||||
border-left: 2px solid var(--el-color-primary);
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
// 内容区域
|
||||
.magnifier-content {
|
||||
max-width: min(720px, calc(100vw - 48px));
|
||||
padding: 16px 24px;
|
||||
font-family: 'Courier New', Consolas, monospace;
|
||||
font-size: 28px;
|
||||
font-weight: 600;
|
||||
line-height: 1.4;
|
||||
color: var(--el-text-color-primary);
|
||||
letter-spacing: 3px;
|
||||
overflow-wrap: anywhere;
|
||||
white-space: normal;
|
||||
background-color: var(--el-bg-color, #fff);
|
||||
border: 2px solid var(--el-color-primary);
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 12px rgb(0 0 0 / 15%);
|
||||
}
|
||||
.magnifier-content {
|
||||
display: inline-block;
|
||||
width: fit-content;
|
||||
max-width: min(720px, calc(100vw - 48px));
|
||||
padding: 14px 22px;
|
||||
font-family: 'Courier New', Consolas, monospace;
|
||||
font-size: 24px;
|
||||
font-weight: 600;
|
||||
line-height: 1.4;
|
||||
color: var(--el-color-primary);
|
||||
text-align: center;
|
||||
letter-spacing: 1.5px;
|
||||
overflow-wrap: anywhere;
|
||||
white-space: normal;
|
||||
background-color: var(--el-color-primary-light-9);
|
||||
border: 2px solid var(--el-color-primary);
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 8px 18px rgb(15 23 42 / 12%);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.operation-button-group {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
margin-left: auto;
|
||||
}
|
||||
.operation-button-group {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
margin-left: auto;
|
||||
}
|
||||
}
|
||||
|
||||
// 放大效果的过渡动画
|
||||
.zoom-fade-enter-active,
|
||||
.zoom-fade-leave-active {
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.zoom-fade-enter-from {
|
||||
opacity: 0;
|
||||
transform: scale(0.8) translateY(-10px);
|
||||
}
|
||||
|
||||
.zoom-fade-enter-from,
|
||||
.zoom-fade-leave-to {
|
||||
opacity: 0;
|
||||
transform: scale(0.8) translateY(-10px);
|
||||
@@ -250,66 +224,47 @@
|
||||
}
|
||||
|
||||
@media (width <= 768px) {
|
||||
.search-card {
|
||||
top: 16px;
|
||||
.search-area {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
:deep(.el-card__header) {
|
||||
padding: 12px 16px;
|
||||
}
|
||||
.iccid-search {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
|
||||
:deep(.el-card__body) {
|
||||
padding: 12px 16px;
|
||||
}
|
||||
.iccid-input-wrapper {
|
||||
flex-basis: auto;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
|
||||
:deep(.el-card__header) .card-header {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
.iccid-magnifier {
|
||||
right: 0;
|
||||
left: 0;
|
||||
white-space: normal;
|
||||
|
||||
.el-button {
|
||||
width: 100%;
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
.magnifier-arrow {
|
||||
left: 24px;
|
||||
}
|
||||
|
||||
.iccid-search {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
|
||||
.iccid-input-wrapper {
|
||||
flex-basis: auto;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
|
||||
.iccid-magnifier {
|
||||
right: 0;
|
||||
left: 0;
|
||||
white-space: normal;
|
||||
|
||||
.magnifier-arrow {
|
||||
left: 24px;
|
||||
}
|
||||
|
||||
.magnifier-content {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 12px 14px;
|
||||
font-size: 18px;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
.magnifier-content {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 12px 14px;
|
||||
font-size: 18px;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.search-action-button,
|
||||
.operation-button-group,
|
||||
.operation-button-group .el-button {
|
||||
width: 100%;
|
||||
margin-left: 0;
|
||||
}
|
||||
.search-action-button,
|
||||
.operation-button-group,
|
||||
.operation-button-group .el-button {
|
||||
width: 100%;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.operation-button-group {
|
||||
margin-left: 0;
|
||||
}
|
||||
.operation-button-group {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,13 +1,8 @@
|
||||
<template>
|
||||
<ElCard shadow="never" class="info-card current-package-card">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span class="header-title">当前生效套餐</span>
|
||||
<div class="header-actions">
|
||||
<slot name="header-actions" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div class="current-package-section">
|
||||
<ElDivider class="info-section-divider" content-position="left">
|
||||
<span class="section-divider-title">当前生效套餐</span>
|
||||
</ElDivider>
|
||||
|
||||
<!-- 绑定设备提示(优先于一切内容) -->
|
||||
<template v-if="props.boundDeviceId">
|
||||
@@ -205,35 +200,73 @@
|
||||
</div>
|
||||
|
||||
<!-- 套餐详情表格 -->
|
||||
<ElDescriptions :column="descriptionsColumn" border class="package-info-table">
|
||||
<ElDescriptionsItem label="订单号">
|
||||
<ElDescriptions
|
||||
class="asset-descriptions"
|
||||
:column="descriptionsColumn"
|
||||
direction="vertical"
|
||||
border
|
||||
size="large"
|
||||
>
|
||||
<ElDescriptionsItem
|
||||
label="订单号"
|
||||
label-class-name="asset-label asset-label--package-order"
|
||||
>
|
||||
{{ currentPackage.order_no || '-' }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="套餐名称">
|
||||
<ElDescriptionsItem
|
||||
label="套餐名称"
|
||||
label-class-name="asset-label asset-label--package-name"
|
||||
>
|
||||
{{ currentPackage.package_name || '-' }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="套餐成本价格" v-if="isAdminOrPlatform">
|
||||
<ElDescriptionsItem
|
||||
label="套餐成本价格"
|
||||
label-class-name="asset-label asset-label--package-cost"
|
||||
v-if="isAdminOrPlatform"
|
||||
>
|
||||
{{ formatAmount(currentPackage.paid_amount || 0) }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="套餐零售价">
|
||||
<ElDescriptionsItem
|
||||
label="套餐零售价"
|
||||
label-class-name="asset-label asset-label--package-retail"
|
||||
>
|
||||
{{ formatAmount(currentPackage.retail_amount || 0) }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="套餐类型">
|
||||
<ElDescriptionsItem
|
||||
label="套餐类型"
|
||||
label-class-name="asset-label asset-label--package-type"
|
||||
>
|
||||
{{ getPackageTypeName(currentPackage.package_type) }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="开始时间">
|
||||
<ElDescriptionsItem
|
||||
label="开始时间"
|
||||
label-class-name="asset-label asset-label--package-start"
|
||||
>
|
||||
{{ formatDateTime(currentPackage.start_time) || '-' }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="到期时间">
|
||||
<ElDescriptionsItem
|
||||
label="到期时间"
|
||||
label-class-name="asset-label asset-label--package-expire"
|
||||
>
|
||||
{{ formatDateTime(currentPackage.expire_time) || '-' }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="下单时间">
|
||||
<ElDescriptionsItem
|
||||
label="下单时间"
|
||||
label-class-name="asset-label asset-label--package-created"
|
||||
>
|
||||
{{ formatDateTime(currentPackage.created_at) || '-' }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem v-if="currentPackage.duration_days" label="套餐时长">
|
||||
<ElDescriptionsItem
|
||||
v-if="currentPackage.duration_days"
|
||||
label="套餐时长"
|
||||
label-class-name="asset-label asset-label--package-duration"
|
||||
>
|
||||
{{ currentPackage.duration_days }}天
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="到期计时基准">
|
||||
<ElDescriptionsItem
|
||||
label="到期计时基准"
|
||||
label-class-name="asset-label asset-label--package-base"
|
||||
>
|
||||
{{ getExpiryBaseLabel(currentPackage.expiry_base) }}
|
||||
</ElDescriptionsItem>
|
||||
</ElDescriptions>
|
||||
@@ -241,12 +274,12 @@
|
||||
|
||||
<!-- 空状态 -->
|
||||
<ElEmpty v-else-if="!loading" :description="errorMsg || '暂无当前生效套餐'" :image-size="100" />
|
||||
</ElCard>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
ElCard,
|
||||
ElDivider,
|
||||
ElButton,
|
||||
ElDescriptions,
|
||||
ElDescriptionsItem,
|
||||
@@ -319,7 +352,7 @@
|
||||
const descriptionsColumn = computed(() => {
|
||||
if (width.value <= 640) return 1
|
||||
if (width.value <= 1024) return 2
|
||||
return 4
|
||||
return 5
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -345,16 +378,113 @@
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.current-package-card {
|
||||
.card-header {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
.header-title {
|
||||
font-size: 16px;
|
||||
.current-package-section {
|
||||
.asset-descriptions {
|
||||
:deep(.el-descriptions__label.is-vertical-label) {
|
||||
padding: 8px 15px;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
line-height: 18px;
|
||||
color: var(--el-text-color-secondary);
|
||||
background-color: var(--el-fill-color-extra-light);
|
||||
}
|
||||
|
||||
:deep(.asset-label::before) {
|
||||
display: inline-block;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin-right: 6px;
|
||||
font-family: iconfont-sys, sans-serif !important;
|
||||
font-size: 16px;
|
||||
line-height: 1;
|
||||
vertical-align: -3px;
|
||||
color: var(--el-color-primary);
|
||||
content: '';
|
||||
opacity: 0.82;
|
||||
}
|
||||
|
||||
:deep(.asset-label--package-order::before) {
|
||||
content: '\e70f';
|
||||
}
|
||||
|
||||
:deep(.asset-label--package-name::before) {
|
||||
content: '\e775';
|
||||
}
|
||||
|
||||
:deep(.asset-label--package-cost::before) {
|
||||
color: var(--el-color-warning);
|
||||
content: '\e815';
|
||||
}
|
||||
|
||||
:deep(.asset-label--package-retail::before) {
|
||||
color: var(--el-color-success);
|
||||
content: '\e6f5';
|
||||
}
|
||||
|
||||
:deep(.asset-label--package-type::before) {
|
||||
content: '\e723';
|
||||
}
|
||||
|
||||
:deep(.asset-label--package-start::before) {
|
||||
content: '\e751';
|
||||
}
|
||||
|
||||
:deep(.asset-label--package-expire::before) {
|
||||
content: '\e76a';
|
||||
}
|
||||
|
||||
:deep(.asset-label--package-created::before) {
|
||||
content: '\e6ce';
|
||||
}
|
||||
|
||||
:deep(.asset-label--package-duration::before) {
|
||||
content: '\e7af';
|
||||
}
|
||||
|
||||
:deep(.asset-label--package-base::before) {
|
||||
content: '\e7b1';
|
||||
}
|
||||
|
||||
:deep(.el-descriptions__content.is-vertical-content) {
|
||||
padding: 8px 15px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
line-height: 23px;
|
||||
color: var(--el-text-color-primary);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
}
|
||||
|
||||
.info-section-divider {
|
||||
display: flex;
|
||||
height: 20px;
|
||||
align-items: center;
|
||||
border-top: 0;
|
||||
|
||||
:deep(.el-divider__text) {
|
||||
position: static;
|
||||
display: inline-flex;
|
||||
padding: 0;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
line-height: 20px;
|
||||
color: var(--el-text-color-primary);
|
||||
background-color: transparent;
|
||||
transform: none;
|
||||
}
|
||||
|
||||
.section-divider-title {
|
||||
display: inline-flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
|
||||
&::before {
|
||||
width: 3px;
|
||||
height: 16px;
|
||||
content: '';
|
||||
background-color: var(--el-color-primary);
|
||||
border-radius: 2px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -473,18 +603,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
.package-info-table {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
:deep(.el-descriptions__body) {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
:deep(.el-descriptions__cell) {
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
@media (width <= 992px) {
|
||||
.flow-progress-card {
|
||||
.flow-stats-container {
|
||||
@@ -495,15 +613,6 @@
|
||||
}
|
||||
|
||||
@media (width <= 768px) {
|
||||
.card-header {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
|
||||
.header-actions {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.flow-progress-card {
|
||||
padding: 14px;
|
||||
|
||||
|
||||
@@ -1,737 +0,0 @@
|
||||
<template>
|
||||
<ElCard shadow="never" class="info-card operation-logs-card" v-loading="loading">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span class="header-title">操作审计日志</span>
|
||||
<div class="filter-section">
|
||||
<ElSelect
|
||||
v-model="filterForm.operation_type"
|
||||
placeholder="操作类型"
|
||||
clearable
|
||||
class="operation-type-select"
|
||||
@change="handleFilterChange"
|
||||
>
|
||||
<ElOption
|
||||
v-for="option in operationTypeOptions"
|
||||
:key="option.value"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</ElSelect>
|
||||
<ElSelect
|
||||
v-model="filterForm.result_status"
|
||||
placeholder="执行结果"
|
||||
clearable
|
||||
class="result-status-select"
|
||||
@change="handleFilterChange"
|
||||
>
|
||||
<ElOption label="成功" value="success" />
|
||||
<ElOption label="失败" value="failed" />
|
||||
<ElOption label="拒绝" value="denied" />
|
||||
</ElSelect>
|
||||
<ElButton type="primary" @click="handleQuery">查询</ElButton>
|
||||
<ElButton @click="handleReset">重置</ElButton>
|
||||
<ElTag type="info" size="small">共 {{ total }} 条</ElTag>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="logs-table-wrapper">
|
||||
<ElTable :data="logList" class="logs-table" border max-height="400">
|
||||
<ElTableColumn label="操作时间" width="170" align="center">
|
||||
<template #default="{ row }">
|
||||
{{ formatDateTime(row.created_at) }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="操作类型" width="160" align="center">
|
||||
<template #default="{ row }">
|
||||
<ElTag :type="getOperationTypeTag(row.operation_type)" size="small">
|
||||
{{ row.operation_desc }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="操作人" width="130" align="center">
|
||||
<template #default="{ row }">
|
||||
{{ row.operator_name || '-' }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="操作人类型" width="110" align="center">
|
||||
<template #default="{ row }">
|
||||
{{ getOperatorTypeText(row) }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="执行结果" width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<ElTag :type="getResultStatusTag(row.result_status)" size="small">
|
||||
{{ getResultStatusText(row.result_status) }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="变更内容" min-width="320">
|
||||
<template #default="{ row }">
|
||||
<div v-if="getDisplayContent(row).length" class="change-content">
|
||||
<span
|
||||
v-for="(item, index) in getDisplayContent(row)"
|
||||
:key="`${item.type}-${item.key}-${index}`"
|
||||
class="change-item"
|
||||
>
|
||||
<span class="field-name">{{ item.fieldName }}</span>
|
||||
<span class="field-value">
|
||||
<template v-if="item.type === 'change'">
|
||||
<span class="new-value">{{ formatFieldValue(item.key, item.afterValue) }}</span>
|
||||
<ElButton
|
||||
v-if="canDownloadLogFile && isDownloadableFileKey(item.key, item.afterValue)"
|
||||
link
|
||||
type="primary"
|
||||
@click.stop="handleDownloadLogFile(item.afterValue)"
|
||||
>
|
||||
下载文件
|
||||
</ElButton>
|
||||
</template>
|
||||
<span v-else :class="['message-value', item.level === 'error' ? 'is-error' : '']">
|
||||
{{ item.message }}
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
<ElPagination
|
||||
class="logs-pagination"
|
||||
v-if="total > 0"
|
||||
v-model:current-page="pagination.page"
|
||||
v-model:page-size="pagination.page_size"
|
||||
:total="total"
|
||||
:page-sizes="[10, 20, 50]"
|
||||
layout="total, prev, pager, next"
|
||||
@current-change="handlePageChange"
|
||||
@size-change="handleSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</ElCard>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import {
|
||||
ElButton,
|
||||
ElCard,
|
||||
ElMessage,
|
||||
ElOption,
|
||||
ElPagination,
|
||||
ElSelect,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTag
|
||||
} from 'element-plus'
|
||||
import { AssetService, StorageService } from '@/api/modules'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
import type { AssetOperationLogItem } from '@/types/api'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
|
||||
interface Props {
|
||||
assetIdentifier?: string
|
||||
assetType?: string
|
||||
downloadPermission?: string
|
||||
}
|
||||
|
||||
type TagType = 'primary' | 'success' | 'warning' | 'info' | 'danger'
|
||||
type ResultStatus = '' | 'success' | 'failed' | 'denied'
|
||||
|
||||
type OperationLogRow = AssetOperationLogItem & {
|
||||
operator_type_code?: string
|
||||
error_code?: string
|
||||
error_msg?: string
|
||||
request_id?: string
|
||||
request_path?: string
|
||||
request_method?: string
|
||||
ip_address?: string
|
||||
user_agent?: string
|
||||
}
|
||||
|
||||
interface ChangeItem {
|
||||
type: 'change'
|
||||
key: string
|
||||
fieldName: string
|
||||
beforeValue?: any
|
||||
afterValue?: any
|
||||
}
|
||||
|
||||
interface MessageItem {
|
||||
type: 'message'
|
||||
key: string
|
||||
fieldName: string
|
||||
message: string
|
||||
level: 'info' | 'error'
|
||||
}
|
||||
|
||||
type DisplayItem = ChangeItem | MessageItem
|
||||
|
||||
const operationTypeOptions = [
|
||||
{ label: '设备WiFi设置', value: 'device_set_wifi' },
|
||||
{ label: '设备切卡', value: 'device_switch_card' },
|
||||
{ label: '设备切卡模式', value: 'device_switch_mode' },
|
||||
{ label: '设备停机', value: 'device_stop' },
|
||||
{ label: '设备复机', value: 'device_start' },
|
||||
{ label: '设备重启', value: 'device_reboot' },
|
||||
{ label: '设备重置', value: 'device_reset' },
|
||||
{ label: '设备分配', value: 'device_allocate' },
|
||||
{ label: '设备回收', value: 'device_recall' },
|
||||
{ label: '设备绑卡', value: 'device_bind_card' },
|
||||
{ label: '设备解绑卡', value: 'device_unbind_card' },
|
||||
{ label: '卡分配', value: 'card_allocate' },
|
||||
{ label: '卡回收', value: 'card_recall' },
|
||||
{ label: '卡停机', value: 'card_stop' },
|
||||
{ label: '卡复机', value: 'card_start' },
|
||||
{ label: '手动停卡', value: 'card_manual_stop' },
|
||||
{ label: '手动复机', value: 'card_manual_start' },
|
||||
{ label: '自动停卡', value: 'card_auto_stop' },
|
||||
{ label: '自动复机', value: 'card_auto_start' },
|
||||
{ label: '卡轮询状态', value: 'card_polling_status' },
|
||||
{ label: '资产轮询状态', value: 'asset_polling_status' },
|
||||
{ label: '实名策略', value: 'asset_realname_policy' },
|
||||
{ label: '实名状态', value: 'asset_realname_status' },
|
||||
{ label: '轮询开关', value: 'asset_polling' },
|
||||
{ label: 'IoT卡导入任务', value: 'iot_card_import_task_create' }
|
||||
] as const
|
||||
|
||||
const operationTypeTagMap: Record<string, TagType> = {
|
||||
device_set_wifi: 'primary',
|
||||
device_switch_card: 'success',
|
||||
device_switch_mode: 'success',
|
||||
device_stop: 'danger',
|
||||
device_start: 'success',
|
||||
device_reboot: 'warning',
|
||||
device_reset: 'warning',
|
||||
device_allocate: 'primary',
|
||||
device_recall: 'warning',
|
||||
device_bind_card: 'primary',
|
||||
device_unbind_card: 'warning',
|
||||
card_allocate: 'primary',
|
||||
card_recall: 'warning',
|
||||
card_stop: 'danger',
|
||||
card_start: 'success',
|
||||
card_manual_stop: 'danger',
|
||||
card_manual_start: 'success',
|
||||
card_auto_stop: 'danger',
|
||||
card_auto_start: 'success',
|
||||
card_polling_status: 'info',
|
||||
asset_realname_policy: 'info',
|
||||
asset_realname_status: 'info',
|
||||
asset_polling: 'info',
|
||||
asset_polling_status: 'info',
|
||||
iot_card_import_task_create: 'primary'
|
||||
}
|
||||
|
||||
const operatorTypeMap: Record<string, string> = {
|
||||
system: '系统',
|
||||
admin_user: '平台用户',
|
||||
agent_user: '代理账号',
|
||||
enterprise_user: '企业用户',
|
||||
api_user: 'API用户'
|
||||
}
|
||||
|
||||
const fieldNameMap: Record<string, string> = {
|
||||
asset_type: '资产类型',
|
||||
batch_no: '批次号',
|
||||
card_category: '卡类型',
|
||||
device_imei: '设备IMEI',
|
||||
device_sn: '设备SN',
|
||||
device_virtual_no: '设备虚拟号',
|
||||
device_virtual_nos: '设备虚拟号',
|
||||
enable_polling: '轮询开关',
|
||||
file_key: '文件存储键',
|
||||
first_realname_at: '首次实名时间',
|
||||
iccid: 'ICCID',
|
||||
iccids: 'ICCID',
|
||||
network_status: '网络状态',
|
||||
real_name_status: '实名状态',
|
||||
realname_policy: '实名认证策略',
|
||||
shop_name: '店铺',
|
||||
source_service: '来源服务',
|
||||
source_shop_name: '来源店铺',
|
||||
status: '资产状态',
|
||||
stop_reason: '停机原因',
|
||||
switch_mode: '切卡模式',
|
||||
target_shop_name: '目标店铺',
|
||||
to_shop_name: '目标店铺'
|
||||
}
|
||||
|
||||
const realnamePolicyMap: Record<string, string> = {
|
||||
none: '无需实名',
|
||||
before_order: '先实名后充值/购买',
|
||||
after_order: '先充值/购买后实名'
|
||||
}
|
||||
|
||||
const stopReasonMap: Record<string, string> = {
|
||||
'': '无',
|
||||
no_package: '无可用套餐',
|
||||
carrier_stopped: '运营商停机',
|
||||
not_realname: '未实名'
|
||||
}
|
||||
|
||||
const assetTypeMap: Record<string, string> = {
|
||||
iot_card: 'IoT卡',
|
||||
device: '设备'
|
||||
}
|
||||
|
||||
const cardCategoryMap: Record<string, string> = {
|
||||
normal: '普通卡',
|
||||
industry: '行业卡'
|
||||
}
|
||||
|
||||
const assetStatusMap: Record<string, string> = {
|
||||
'1': '在库',
|
||||
'2': '已分销',
|
||||
'3': '已激活',
|
||||
'4': '已停用'
|
||||
}
|
||||
|
||||
const newStatusMap: Record<string, string> = {
|
||||
allocated: '已分配',
|
||||
recalled: '已回收'
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
const { hasAuth } = useAuth()
|
||||
|
||||
const loading = ref(false)
|
||||
const logList = ref<OperationLogRow[]>([])
|
||||
const total = ref(0)
|
||||
const canDownloadLogFile = computed(() => {
|
||||
return props.downloadPermission ? hasAuth(props.downloadPermission) : false
|
||||
})
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
page_size: 20
|
||||
})
|
||||
|
||||
const filterForm = reactive({
|
||||
operation_type: '',
|
||||
result_status: '' as ResultStatus
|
||||
})
|
||||
|
||||
const loadLogs = async () => {
|
||||
if (!props.assetIdentifier) return
|
||||
|
||||
try {
|
||||
loading.value = true
|
||||
const res = await AssetService.getOperationLogs(props.assetIdentifier, {
|
||||
page: pagination.page,
|
||||
page_size: pagination.page_size,
|
||||
operation_type: filterForm.operation_type || undefined,
|
||||
result_status: filterForm.result_status || undefined
|
||||
})
|
||||
if (res.code === 0 && res.data) {
|
||||
logList.value = res.data.items || []
|
||||
total.value = res.data.total || 0
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载操作日志失败:', error)
|
||||
ElMessage.error('加载操作日志失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleQuery = () => {
|
||||
pagination.page = 1
|
||||
loadLogs()
|
||||
}
|
||||
|
||||
const handleReset = () => {
|
||||
filterForm.operation_type = ''
|
||||
filterForm.result_status = ''
|
||||
pagination.page = 1
|
||||
loadLogs()
|
||||
}
|
||||
|
||||
const handleFilterChange = () => {
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
const handlePageChange = () => {
|
||||
loadLogs()
|
||||
}
|
||||
|
||||
const handleSizeChange = () => {
|
||||
pagination.page = 1
|
||||
loadLogs()
|
||||
}
|
||||
|
||||
const getOperationTypeTag = (type: string): TagType => {
|
||||
return operationTypeTagMap[type] || 'info'
|
||||
}
|
||||
|
||||
const getResultStatusTag = (status: string): TagType => {
|
||||
const tagMap: Record<string, TagType> = {
|
||||
success: 'success',
|
||||
failed: 'danger',
|
||||
denied: 'warning'
|
||||
}
|
||||
return tagMap[status] || 'info'
|
||||
}
|
||||
|
||||
const getResultStatusText = (status: string) => {
|
||||
const textMap: Record<string, string> = {
|
||||
success: '成功',
|
||||
failed: '失败',
|
||||
denied: '拒绝'
|
||||
}
|
||||
return textMap[status] || status
|
||||
}
|
||||
|
||||
const isDownloadableFileKey = (key: string, value: unknown) => {
|
||||
return key === 'file_key' && typeof value === 'string' && value.trim() !== ''
|
||||
}
|
||||
|
||||
const handleDownloadLogFile = async (fileKey: string) => {
|
||||
try {
|
||||
await StorageService.downloadFileByKey(fileKey)
|
||||
ElMessage.success('文件下载已开始')
|
||||
} catch (error) {
|
||||
console.error('下载日志文件失败:', error)
|
||||
ElMessage.error('下载文件失败')
|
||||
}
|
||||
}
|
||||
|
||||
const getOperatorTypeText = (row: OperationLogRow) => {
|
||||
if (row.operator_type_code && operatorTypeMap[row.operator_type_code]) {
|
||||
return operatorTypeMap[row.operator_type_code]
|
||||
}
|
||||
if (row.operator_type && operatorTypeMap[row.operator_type]) {
|
||||
return operatorTypeMap[row.operator_type]
|
||||
}
|
||||
return row.operator_type || row.operator_type_code || '-'
|
||||
}
|
||||
|
||||
const formatValue = (value: any): string => {
|
||||
if (value === null || value === undefined) return '空'
|
||||
if (typeof value === 'boolean') return value ? '是' : '否'
|
||||
if (typeof value === 'number') return String(value)
|
||||
if (typeof value === 'string') return value || '空'
|
||||
if (Array.isArray(value)) {
|
||||
if (value.length === 0) return '空'
|
||||
if (value.every((item) => ['string', 'number', 'boolean'].includes(typeof item))) {
|
||||
return value.map((item) => formatValue(item)).join('、')
|
||||
}
|
||||
return JSON.stringify(value)
|
||||
}
|
||||
if (typeof value === 'object') return JSON.stringify(value)
|
||||
return String(value)
|
||||
}
|
||||
|
||||
const formatFieldValue = (key: string, value: any): string => {
|
||||
if (typeof value === 'string' && (key.endsWith('_at') || key.endsWith('_time'))) {
|
||||
return formatDateTime(value)
|
||||
}
|
||||
if (key === 'enable_polling') return value ? '开启' : '关闭'
|
||||
if (key === 'realname_policy') return realnamePolicyMap[value] || formatValue(value)
|
||||
if (key === 'real_name_status') return value === 1 ? '已实名' : '未实名'
|
||||
if (key === 'switch_mode') {
|
||||
return String(value) === '0' ? '自动' : String(value) === '1' ? '手动' : formatValue(value)
|
||||
}
|
||||
if (key === 'new_status') return newStatusMap[value] || formatValue(value)
|
||||
if (key === 'network_status') {
|
||||
return Number(value) === 1 ? '正常' : Number(value) === 0 ? '停机' : formatValue(value)
|
||||
}
|
||||
if (key === 'stop_reason') return stopReasonMap[String(value ?? '')] ?? formatValue(value)
|
||||
if (key === 'asset_type') return assetTypeMap[String(value)] || formatValue(value)
|
||||
if (key === 'card_category') return cardCategoryMap[String(value)] || formatValue(value)
|
||||
if (key === 'status') return assetStatusMap[String(value)] || formatValue(value)
|
||||
if (key === 'source_service') return value === 'asset_polling' ? '资产轮询' : formatValue(value)
|
||||
return formatValue(value)
|
||||
}
|
||||
|
||||
const sanitizeFieldName = (fieldName: string): string => {
|
||||
return fieldName
|
||||
.trim()
|
||||
.replace(/([^)]*)/g, '')
|
||||
.trim()
|
||||
}
|
||||
|
||||
const shouldHideIdField = (key: string, fieldName: string): boolean => {
|
||||
const normalizedKey = key.trim()
|
||||
const normalizedKeyLower = normalizedKey.toLowerCase()
|
||||
const normalizedFieldName = sanitizeFieldName(fieldName)
|
||||
const normalizedFieldNameUpper = normalizedFieldName.toUpperCase()
|
||||
|
||||
const visibleIdentifierKeys = new Set(['iccid', 'msisdn', 'imei', 'imsi', 'sn'])
|
||||
const visibleIdentifierNames = ['ICCID', 'MSISDN', 'IMEI', 'IMSI', 'SN']
|
||||
|
||||
if (
|
||||
visibleIdentifierKeys.has(normalizedKeyLower) ||
|
||||
visibleIdentifierNames.some((name) => normalizedFieldNameUpper.endsWith(name))
|
||||
) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (
|
||||
normalizedKeyLower === 'id' ||
|
||||
normalizedFieldName === '绑定记录ID' ||
|
||||
normalizedFieldName === 'ID'
|
||||
) {
|
||||
return true
|
||||
}
|
||||
|
||||
return (
|
||||
normalizedKeyLower.endsWith('_id') ||
|
||||
/^[a-z][a-z0-9]*Id$/.test(normalizedKey) ||
|
||||
normalizedFieldName.endsWith('ID')
|
||||
)
|
||||
}
|
||||
|
||||
const extractOperationContent = (
|
||||
row: OperationLogRow,
|
||||
type: 'before' | 'after'
|
||||
): Record<string, any> => {
|
||||
const directContent =
|
||||
type === 'before' ? row.operation_content_before : row.operation_content_after
|
||||
if (directContent && Object.keys(directContent).length > 0) {
|
||||
return directContent
|
||||
}
|
||||
|
||||
const fallbackContainer = type === 'before' ? row.before_data : row.after_data
|
||||
const nestedContent = fallbackContainer?.operation_content
|
||||
if (nestedContent && Object.keys(nestedContent).length > 0) {
|
||||
return nestedContent
|
||||
}
|
||||
|
||||
return fallbackContainer || {}
|
||||
}
|
||||
|
||||
const isSameValue = (beforeValue: any, afterValue: any) => {
|
||||
if (beforeValue === afterValue) return true
|
||||
return JSON.stringify(beforeValue) === JSON.stringify(afterValue)
|
||||
}
|
||||
|
||||
const getChangeContent = (row: OperationLogRow): ChangeItem[] => {
|
||||
const before = extractOperationContent(row, 'before')
|
||||
const after = extractOperationContent(row, 'after')
|
||||
const desc = row.operation_fields_desc || {}
|
||||
const keys = new Set([...Object.keys(before), ...Object.keys(after)])
|
||||
|
||||
const changes: ChangeItem[] = []
|
||||
for (const key of keys) {
|
||||
const fieldName = sanitizeFieldName(desc[key] || fieldNameMap[key] || key)
|
||||
if (shouldHideIdField(key, fieldName)) continue
|
||||
|
||||
const beforeValue = before[key]
|
||||
const afterValue = after[key]
|
||||
if (isSameValue(beforeValue, afterValue)) continue
|
||||
|
||||
changes.push({
|
||||
type: 'change',
|
||||
key,
|
||||
fieldName,
|
||||
beforeValue,
|
||||
afterValue
|
||||
})
|
||||
}
|
||||
|
||||
return changes
|
||||
}
|
||||
|
||||
const getMessageItems = (row: OperationLogRow): MessageItem[] => {
|
||||
const items: MessageItem[] = []
|
||||
const seen = new Set<string>()
|
||||
|
||||
const pushMessage = (
|
||||
key: string,
|
||||
fieldName: string,
|
||||
message?: string,
|
||||
level: 'info' | 'error' = 'info'
|
||||
) => {
|
||||
const normalizedMessage = message?.trim()
|
||||
if (!normalizedMessage) return
|
||||
|
||||
const duplicateKey = `${fieldName}:${normalizedMessage}`
|
||||
if (seen.has(duplicateKey)) return
|
||||
seen.add(duplicateKey)
|
||||
|
||||
items.push({
|
||||
type: 'message',
|
||||
key,
|
||||
fieldName,
|
||||
message: normalizedMessage,
|
||||
level
|
||||
})
|
||||
}
|
||||
|
||||
pushMessage('error_msg', '失败原因', row.error_msg, 'error')
|
||||
pushMessage('reason', '原因说明', row.reason, row.result_status === 'failed' ? 'error' : 'info')
|
||||
|
||||
if (row.fail_count > 0) {
|
||||
pushMessage('fail_count', '批量结果', `失败 ${row.fail_count} 项`, 'error')
|
||||
}
|
||||
|
||||
row.failed_items?.slice(0, 3).forEach((item, index) => {
|
||||
const detail = item?.iccid
|
||||
? `${item.iccid}:${item.reason || '未知原因'}`
|
||||
: item?.reason || ''
|
||||
pushMessage(`failed_items_${index}`, '失败明细', detail, 'error')
|
||||
})
|
||||
|
||||
if (!items.length && row.result_status === 'failed') {
|
||||
pushMessage('result_status', '执行结果', '执行失败', 'error')
|
||||
}
|
||||
|
||||
if (!items.length && row.result_status === 'denied') {
|
||||
pushMessage('result_status', '执行结果', '操作被拒绝', 'info')
|
||||
}
|
||||
|
||||
return items
|
||||
}
|
||||
|
||||
const getDisplayContent = (row: OperationLogRow): DisplayItem[] => {
|
||||
return [...getChangeContent(row), ...getMessageItems(row)]
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.assetIdentifier,
|
||||
(newVal) => {
|
||||
if (newVal) {
|
||||
loadLogs()
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.operation-logs-card {
|
||||
.card-header {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
.header-title {
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.filter-section {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
min-width: 0;
|
||||
|
||||
.operation-type-select {
|
||||
width: 180px;
|
||||
}
|
||||
|
||||
.result-status-select {
|
||||
width: 120px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.logs-table-wrapper {
|
||||
overflow-x: auto;
|
||||
|
||||
.logs-table {
|
||||
min-width: 980px;
|
||||
|
||||
:deep(.el-table__header-wrapper) {
|
||||
th {
|
||||
background-color: var(--el-fill-color-light);
|
||||
}
|
||||
}
|
||||
|
||||
.change-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
|
||||
.change-item {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
align-items: center;
|
||||
font-size: 12px;
|
||||
|
||||
.field-name {
|
||||
min-width: 72px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.field-value {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
align-items: center;
|
||||
word-break: break-all;
|
||||
|
||||
.new-value {
|
||||
color: var(--el-color-success);
|
||||
}
|
||||
|
||||
.message-value {
|
||||
color: var(--el-text-color-regular);
|
||||
|
||||
&.is-error {
|
||||
color: var(--el-color-danger);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.logs-pagination {
|
||||
justify-content: flex-end;
|
||||
margin-top: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (width <= 1200px) {
|
||||
.card-header {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
|
||||
.filter-section {
|
||||
justify-content: flex-start;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (width <= 768px) {
|
||||
.card-header {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
|
||||
.filter-section {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
|
||||
:deep(.el-select),
|
||||
.el-button,
|
||||
.el-tag {
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
.el-button {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.logs-table-wrapper {
|
||||
padding: 0 12px;
|
||||
margin-right: -12px;
|
||||
margin-left: -12px;
|
||||
|
||||
:deep(.el-pagination) {
|
||||
justify-content: flex-start !important;
|
||||
overflow-x: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -13,7 +13,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div v-loading="loading" class="package-table-wrapper">
|
||||
<div v-loading="props.loading" class="package-table-wrapper">
|
||||
<!-- 绑定设备提示 -->
|
||||
<ElEmpty v-if="props.boundDeviceId" :image-size="100">
|
||||
<template #description>
|
||||
@@ -32,15 +32,20 @@
|
||||
<ElTable :data="packageList" class="package-table" border>
|
||||
<ElTableColumn label="订单号" width="240">
|
||||
<template #default="scope">
|
||||
<ElButton
|
||||
type="primary"
|
||||
link
|
||||
@click="handleOrderNoClick(scope.row)"
|
||||
v-if="hasAuth('order:package_list_detail')"
|
||||
>
|
||||
{{ scope.row.order_no }}
|
||||
</ElButton>
|
||||
<span v-else>{{ scope.row.order_no }}</span>
|
||||
<div class="order-no-cell">
|
||||
<ElTooltip :content="scope.row.order_no" placement="top" :show-after="300">
|
||||
<ElButton
|
||||
class="order-no-link"
|
||||
type="primary"
|
||||
link
|
||||
@click="handleOrderNoClick(scope.row)"
|
||||
v-if="hasAuth('order:package_list_detail')"
|
||||
>
|
||||
{{ scope.row.order_no }}
|
||||
</ElButton>
|
||||
<span v-else class="order-no-text">{{ scope.row.order_no }}</span>
|
||||
</ElTooltip>
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="套餐名称" width="200" show-overflow-tooltip>
|
||||
@@ -291,6 +296,7 @@
|
||||
v-model="createRefundDialogVisible"
|
||||
:initial-order-id="currentRefundOrderId"
|
||||
:initial-order-no="currentRefundOrderNo"
|
||||
:initial-package-usage-id="currentRefundPackageUsageId"
|
||||
@success="handleRefundSuccess"
|
||||
/>
|
||||
|
||||
@@ -336,7 +342,7 @@
|
||||
<ElDialog
|
||||
v-model="expiresAtDialogVisible"
|
||||
title="修改过期时间"
|
||||
width="420px"
|
||||
width="40%"
|
||||
@closed="resetExpiresAtForm"
|
||||
>
|
||||
<ElForm
|
||||
@@ -389,7 +395,8 @@
|
||||
ElInputNumber,
|
||||
ElDatePicker,
|
||||
ElSelect,
|
||||
ElOption
|
||||
ElOption,
|
||||
ElTooltip
|
||||
} from 'element-plus'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
@@ -432,6 +439,7 @@
|
||||
const createRefundDialogVisible = ref(false)
|
||||
const currentRefundOrderId = ref<number | undefined>(undefined)
|
||||
const currentRefundOrderNo = ref<string | undefined>(undefined)
|
||||
const currentRefundPackageUsageId = ref<number | undefined>(undefined)
|
||||
const selectedPackage = ref<PackageInfo>()
|
||||
const usedDataDialogVisible = ref(false)
|
||||
const expiresAtDialogVisible = ref(false)
|
||||
@@ -490,10 +498,12 @@
|
||||
}
|
||||
currentRefundOrderId.value = row.order_id
|
||||
currentRefundOrderNo.value = row.order_no
|
||||
currentRefundPackageUsageId.value = row.package_usage_id ?? row.id
|
||||
createRefundDialogVisible.value = true
|
||||
}
|
||||
|
||||
const handleRefundSuccess = () => {
|
||||
currentRefundPackageUsageId.value = undefined
|
||||
emit('refresh')
|
||||
}
|
||||
|
||||
@@ -749,6 +759,35 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.order-no-cell {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
|
||||
:deep(.el-tooltip__trigger) {
|
||||
display: block;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.order-no-link,
|
||||
.order-no-text {
|
||||
display: block;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
text-align: left;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.order-no-link {
|
||||
padding: 0;
|
||||
margin-left: 0;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
}
|
||||
|
||||
.package-actions {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
|
||||
@@ -12,21 +12,21 @@
|
||||
<!-- 钱包余额展示 -->
|
||||
<div class="wallet-balance-cards">
|
||||
<div class="balance-card total">
|
||||
<div class="balance-icon">💰</div>
|
||||
<div class="balance-icon"><Money /></div>
|
||||
<div class="balance-info">
|
||||
<div class="balance-label">总余额</div>
|
||||
<div class="balance-value">{{ formatAmount(walletInfo.balance) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="balance-card available">
|
||||
<div class="balance-icon">✅</div>
|
||||
<div class="balance-icon"><CircleCheck /></div>
|
||||
<div class="balance-info">
|
||||
<div class="balance-label">可用余额</div>
|
||||
<div class="balance-value">{{ formatAmount(walletInfo.available_balance) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="balance-card frozen">
|
||||
<div class="balance-icon">🔒</div>
|
||||
<div class="balance-icon"><Lock /></div>
|
||||
<div class="balance-info">
|
||||
<div class="balance-label">冻结余额</div>
|
||||
<div class="balance-value">{{ formatAmount(walletInfo.frozen_balance) }}</div>
|
||||
@@ -40,6 +40,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ElCard, ElTag, ElEmpty } from 'element-plus'
|
||||
import { CircleCheck, Lock, Money } from '@element-plus/icons-vue'
|
||||
import { useAssetFormatters } from '../composables/useAssetFormatters'
|
||||
|
||||
// Use formatters
|
||||
@@ -91,6 +92,11 @@
|
||||
flex-shrink: 0;
|
||||
font-size: 26px;
|
||||
line-height: 1;
|
||||
|
||||
:deep(svg) {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
}
|
||||
}
|
||||
|
||||
.balance-info {
|
||||
|
||||
@@ -1,26 +1,31 @@
|
||||
<template>
|
||||
<ElCard shadow="never" class="info-card wallet-info" v-loading="walletLoading">
|
||||
<ElCard shadow="never" class="info-card wallet-info" v-loading="props.walletLoading">
|
||||
<template #header>
|
||||
<div class="card-header wallet-header">
|
||||
<div class="header-left">
|
||||
<div class="wallet-header-top">
|
||||
<span class="wallet-title">钱包</span>
|
||||
<ElTag v-if="walletInfo" :type="getWalletStatusType(walletInfo.status)" size="small">
|
||||
<ElTag
|
||||
v-if="walletInfo"
|
||||
class="wallet-status-tag"
|
||||
:type="getWalletStatusType(walletInfo.status)"
|
||||
size="large"
|
||||
>
|
||||
{{ walletInfo.status_text || '-' }}
|
||||
</ElTag>
|
||||
<template v-if="walletInfo">
|
||||
<ElDivider class="wallet-divider" direction="vertical" />
|
||||
<span class="balance-item"
|
||||
>💰 总余额 <strong>{{ formatAmount(walletInfo.balance) }}</strong></span
|
||||
>
|
||||
<ElDivider class="wallet-divider" direction="vertical" />
|
||||
<span class="balance-item"
|
||||
>✅ 可用 <strong>{{ formatAmount(walletInfo.available_balance) }}</strong></span
|
||||
>
|
||||
<ElDivider class="wallet-divider" direction="vertical" />
|
||||
<span class="balance-item"
|
||||
>🔒 冻结 <strong>{{ formatAmount(walletInfo.frozen_balance) }}</strong></span
|
||||
>
|
||||
</template>
|
||||
</div>
|
||||
<div v-if="walletInfo" class="wallet-balance-summary">
|
||||
<div class="balance-item">
|
||||
<span class="balance-label">总余额</span>
|
||||
<strong>{{ formatAmount(walletInfo.balance) }}</strong>
|
||||
</div>
|
||||
<div class="balance-item">
|
||||
<span class="balance-label">可用</span>
|
||||
<strong>{{ formatAmount(walletInfo.available_balance) }}</strong>
|
||||
</div>
|
||||
<div class="balance-item">
|
||||
<span class="balance-label">冻结</span>
|
||||
<strong>{{ formatAmount(walletInfo.frozen_balance) }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!props.boundDeviceId" class="filter-section">
|
||||
<ElSelect
|
||||
@@ -44,6 +49,25 @@
|
||||
/>
|
||||
<ElButton type="primary" @click="handleQuery">查询</ElButton>
|
||||
<ElButton @click="handleReset()">重置</ElButton>
|
||||
<ElButton
|
||||
v-if="
|
||||
isPlatformAuditUser &&
|
||||
walletInfo?.wallet_id &&
|
||||
hasAuth(AUDIT_PERMISSIONS.assetInfoWalletFinance)
|
||||
"
|
||||
@click="openWalletAudit"
|
||||
>资金链路</ElButton
|
||||
>
|
||||
<ElButton
|
||||
v-if="
|
||||
isPlatformAuditUser &&
|
||||
walletInfo?.resource_type &&
|
||||
walletInfo?.resource_id &&
|
||||
hasAuth(AUDIT_PERMISSIONS.assetInfoWalletAsset)
|
||||
"
|
||||
@click="openAssetAudit"
|
||||
>资产审计</ElButton
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -65,7 +89,7 @@
|
||||
|
||||
<div v-else v-loading="loading" class="wallet-table-wrapper">
|
||||
<ElTable v-if="hasTransactions" :data="transactionList" class="wallet-table" border>
|
||||
<ElTableColumn prop="reference_no" label="业务编号">
|
||||
<ElTableColumn prop="reference_no" label="业务编号" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<span v-if="scope.row.reference_no" class="reference-no-link">
|
||||
{{ scope.row.reference_no }}
|
||||
@@ -73,14 +97,14 @@
|
||||
<span v-else>--</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="交易类型" width="100" align="center">
|
||||
<ElTableColumn label="交易类型" width="100">
|
||||
<template #default="scope">
|
||||
<ElTag :type="getTransactionTypeTag(scope.row.transaction_type)" size="small">
|
||||
{{ scope.row.transaction_type_text }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="变动金额" width="120" align="right">
|
||||
<ElTableColumn label="变动金额" width="120">
|
||||
<template #default="scope">
|
||||
<span
|
||||
:style="{
|
||||
@@ -92,17 +116,17 @@
|
||||
</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="变动前余额" width="120" align="right">
|
||||
<ElTableColumn label="变动前余额" width="120">
|
||||
<template #default="scope">
|
||||
{{ formatAmount(scope.row.balance_before) }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="变动后余额" width="120" align="right">
|
||||
<ElTableColumn label="变动后余额" width="120">
|
||||
<template #default="scope">
|
||||
{{ formatAmount(scope.row.balance_after) }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="关联业务" width="100" align="center">
|
||||
<ElTableColumn label="关联业务" width="120">
|
||||
<template #default="scope">
|
||||
<ElTag v-if="scope.row.reference_type" type="info" size="small">
|
||||
{{ scope.row.reference_type === 'recharge' ? '充值' : '订单' }}
|
||||
@@ -110,7 +134,7 @@
|
||||
<span v-else>--</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="remark" label="备注" min-width="150" show-overflow-tooltip>
|
||||
<ElTableColumn prop="remark" label="备注" min-width="180" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
{{ scope.row.remark || '-' }}
|
||||
</template>
|
||||
@@ -154,8 +178,7 @@
|
||||
ElDatePicker,
|
||||
ElPagination,
|
||||
ElEmpty,
|
||||
ElMessage,
|
||||
ElDivider
|
||||
ElMessage
|
||||
} from 'element-plus'
|
||||
import { useAssetFormatters } from '../composables/useAssetFormatters'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
@@ -167,6 +190,15 @@
|
||||
AssetWalletTransactionParams,
|
||||
TransactionType
|
||||
} from '@/types/api'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { AUDIT_PERMISSIONS } from '@/config/constants/audit'
|
||||
import { isPlatformAuditAccount } from '@/utils/business/auditAccess'
|
||||
import {
|
||||
resolveAuditResourceTarget,
|
||||
resolveFinanceAuditTarget
|
||||
} from '@/utils/business/auditNavigation'
|
||||
import { openAuditInvestigation } from '@/components/business/audit/investigationController'
|
||||
|
||||
interface Props {
|
||||
assetIdentifier: string
|
||||
@@ -182,6 +214,23 @@
|
||||
boundDeviceId: undefined,
|
||||
boundDeviceNo: ''
|
||||
})
|
||||
const { hasAuth } = useAuth()
|
||||
const userStore = useUserStore()
|
||||
const isPlatformAuditUser = computed(() =>
|
||||
isPlatformAuditAccount(userStore.info.user_type, userStore.isSuperAdmin)
|
||||
)
|
||||
|
||||
const openWalletAudit = () => {
|
||||
const target = resolveFinanceAuditTarget('wallet_id', props.walletInfo?.wallet_id)
|
||||
if (target) openAuditInvestigation(target)
|
||||
}
|
||||
const openAssetAudit = () => {
|
||||
const target = resolveAuditResourceTarget({
|
||||
resourceType: props.walletInfo?.resource_type || '',
|
||||
internalId: props.walletInfo?.resource_id
|
||||
})
|
||||
if (target) openAuditInvestigation(target)
|
||||
}
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'navigateToDevice', deviceNo: string): void
|
||||
@@ -339,35 +388,61 @@
|
||||
&.wallet-info {
|
||||
.wallet-header {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
align-items: stretch;
|
||||
min-width: 0;
|
||||
|
||||
.header-left {
|
||||
.wallet-header-top {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.wallet-title {
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
}
|
||||
.wallet-title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.wallet-divider {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.wallet-balance-summary {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.balance-item {
|
||||
.balance-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
padding: 8px 12px;
|
||||
white-space: nowrap;
|
||||
background: var(--el-fill-color-lighter);
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 8px;
|
||||
|
||||
.balance-label {
|
||||
font-size: 13px;
|
||||
color: var(--el-text-color-regular);
|
||||
|
||||
strong {
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
strong {
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
line-height: 24px;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.wallet-status-tag {
|
||||
padding: 8px 14px;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.filter-section {
|
||||
@@ -376,6 +451,7 @@
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
|
||||
.transaction-type-select {
|
||||
@@ -399,9 +475,6 @@
|
||||
}
|
||||
|
||||
.wallet-table {
|
||||
width: max-content;
|
||||
min-width: 900px;
|
||||
|
||||
:deep(.el-table__header) {
|
||||
th {
|
||||
font-weight: 600;
|
||||
@@ -420,30 +493,14 @@
|
||||
|
||||
@media (width <= 1200px) {
|
||||
.wallet-header {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
|
||||
.header-left,
|
||||
.filter-section {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.filter-section {
|
||||
justify-content: flex-start;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (width <= 768px) {
|
||||
.wallet-header {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
|
||||
.header-left,
|
||||
.filter-section {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.filter-section {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
@@ -460,18 +517,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
.header-left {
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
align-items: flex-start;
|
||||
|
||||
.wallet-divider {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.balance-item {
|
||||
width: 100%;
|
||||
}
|
||||
.wallet-balance-summary {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
<template>
|
||||
<ElDialog v-model="visible" title="套餐流量详单" width="900px" destroy-on-close>
|
||||
<ElDialog
|
||||
v-model="visible"
|
||||
title="套餐流量详单"
|
||||
width="900px"
|
||||
modal-class="asset-information-dialog"
|
||||
destroy-on-close
|
||||
>
|
||||
<div v-if="data">
|
||||
<!-- 套餐信息摘要 -->
|
||||
<ElDescriptions :column="2" border style="margin-bottom: 20px">
|
||||
@@ -45,13 +51,13 @@
|
||||
|
||||
<!-- 每日流量记录表格 -->
|
||||
<ElTable :data="filteredRecords" border stripe max-height="400" v-loading="loading">
|
||||
<ElTableColumn prop="date" label="日期" width="120" align="center" />
|
||||
<ElTableColumn label="当日使用流量" width="150" align="center">
|
||||
<ElTableColumn prop="date" label="日期" width="120" />
|
||||
<ElTableColumn label="当日使用流量" width="150">
|
||||
<template #default="{ row }">
|
||||
{{ formatDataSize(row.daily_usage_mb) }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="累计流量" width="150" align="center">
|
||||
<ElTableColumn label="累计流量" width="150">
|
||||
<template #default="{ row }">
|
||||
{{ formatDataSize(row.cumulative_usage_mb) }}
|
||||
</template>
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
<template>
|
||||
<ElDialog v-model="visible" title="往期订单" width="60%" destroy-on-close>
|
||||
<ElDialog
|
||||
v-model="visible"
|
||||
title="往期订单"
|
||||
width="60%"
|
||||
modal-class="asset-information-dialog"
|
||||
destroy-on-close
|
||||
>
|
||||
<div v-if="loading" style="padding: 40px 0; text-align: center">
|
||||
<ElIcon class="is-loading" :size="40"><Loading /></ElIcon>
|
||||
</div>
|
||||
@@ -132,8 +138,7 @@
|
||||
ElPagination,
|
||||
ElAlert,
|
||||
ElEmpty,
|
||||
ElIcon,
|
||||
ElMessage
|
||||
ElIcon
|
||||
} from 'element-plus'
|
||||
import { Loading } from '@element-plus/icons-vue'
|
||||
import { AssetService } from '@/api/modules'
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
<template>
|
||||
<ElDialog v-model="visible" title="套餐充值" width="30%" @closed="handleDialogClosed">
|
||||
<ElDialog
|
||||
v-model="visible"
|
||||
title="套餐充值"
|
||||
width="40%"
|
||||
modal-class="asset-information-dialog"
|
||||
@closed="handleDialogClosed"
|
||||
>
|
||||
<ElForm ref="formRef" :model="form" :rules="rules" label-width="80px">
|
||||
<ElFormItem label="资产信息">
|
||||
<span style="font-weight: bold; color: #409eff">
|
||||
@@ -22,7 +28,7 @@
|
||||
<template v-if="!props.seriesId">
|
||||
<ElOption value="__NO_PACKAGE__" disabled>
|
||||
<span style="color: var(--el-text-color-warning)">
|
||||
该设备未关联套餐系列,无法购买套餐
|
||||
{{ noSeriesMessage }}
|
||||
</span>
|
||||
</ElOption>
|
||||
</template>
|
||||
@@ -45,7 +51,7 @@
|
||||
</ElSelect>
|
||||
<template v-if="noSeriesId">
|
||||
<div style="margin-top: 4px; font-size: 12px; color: var(--el-text-color-warning)">
|
||||
该设备未关联套餐系列,无法购买套餐
|
||||
{{ noSeriesMessage }}
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="packagesEmptyWithSeriesId">
|
||||
@@ -126,6 +132,7 @@
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import VoucherUpload from '@/components/business/VoucherUpload.vue'
|
||||
import { hasVoucherKeys, toVoucherKeyList } from '@/utils/business'
|
||||
import { normalizeApiError } from '@/utils/business/apiError'
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
@@ -181,6 +188,9 @@
|
||||
})
|
||||
|
||||
const noSeriesId = computed(() => !props.seriesId)
|
||||
const noSeriesMessage = computed(
|
||||
() => `该${props.assetType === 'card' ? '卡' : '设备'}未关联套餐系列,无法购买套餐`
|
||||
)
|
||||
|
||||
const selectedPackageIsGift = computed(() => {
|
||||
if (!form.package_id) return false
|
||||
@@ -336,7 +346,11 @@
|
||||
data.payment_voucher_key = toVoucherKeyList(form.payment_voucher_key)
|
||||
}
|
||||
|
||||
await OrderService.createOrder(data)
|
||||
const response = await OrderService.createOrder(data)
|
||||
if (response.code !== 0) {
|
||||
ElMessage.error(response.msg || '订单创建失败')
|
||||
return
|
||||
}
|
||||
|
||||
if (form.payment_method === 'wallet') {
|
||||
ElMessage.success('订单创建成功,已自动完成支付')
|
||||
@@ -352,6 +366,7 @@
|
||||
return
|
||||
}
|
||||
console.error('创建订单失败:', error)
|
||||
ElMessage.error(normalizeApiError(error).message)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
@@ -1,62 +1,86 @@
|
||||
<template>
|
||||
<ElDialog v-model="visible" title="设置限速" width="500px">
|
||||
<ElDialog
|
||||
v-model="visible"
|
||||
title="设置限速"
|
||||
width="500px"
|
||||
:lock-scroll="true"
|
||||
:z-index="4000"
|
||||
modal-class="asset-information-dialog speed-limit-modal"
|
||||
>
|
||||
<ElForm ref="formRef" :model="form" :rules="rules" label-width="120px">
|
||||
<ElFormItem label="下行速率" prop="download_speed">
|
||||
<ElInputNumber
|
||||
v-model="form.download_speed"
|
||||
:min="1"
|
||||
:step="128"
|
||||
controls-position="right"
|
||||
<ElFormItem label="固定档位" prop="code">
|
||||
<ElSelect
|
||||
v-model="form.code"
|
||||
placeholder="请选择限速档位"
|
||||
style="width: 100%"
|
||||
/>
|
||||
<div style="margin-top: 4px; font-size: 12px; color: #909399">单位: KB/s</div>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="上行速率" prop="upload_speed">
|
||||
<ElInputNumber
|
||||
v-model="form.upload_speed"
|
||||
:min="1"
|
||||
:step="128"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
/>
|
||||
<div style="margin-top: 4px; font-size: 12px; color: #909399">单位: KB/s</div>
|
||||
:teleported="true"
|
||||
append-to="body"
|
||||
popper-class="speed-limit-select-popper"
|
||||
:popper-style="{ zIndex: 4001 }"
|
||||
>
|
||||
<ElOption
|
||||
v-for="tier in speedTiers"
|
||||
:key="tier.code"
|
||||
:label="tier.label"
|
||||
:value="tier.code"
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
<template #footer>
|
||||
<ElButton @click="handleCancel">取消</ElButton>
|
||||
<ElButton type="primary" @click="handleConfirm" :loading="loading"> 确认设置 </ElButton>
|
||||
<ElButton
|
||||
type="primary"
|
||||
@click="handleConfirm"
|
||||
:loading="confirmLoading"
|
||||
:disabled="confirmLoading"
|
||||
>
|
||||
确认设置
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, watch } from 'vue'
|
||||
import { ElDialog, ElForm, ElFormItem, ElInputNumber, ElButton } from 'element-plus'
|
||||
import { ref, reactive, computed, onUnmounted, watch } from 'vue'
|
||||
import { ElDialog, ElForm, ElFormItem, ElSelect, ElOption, ElButton } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
confirmLoading?: boolean
|
||||
}
|
||||
|
||||
type SpeedTierCode = -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8
|
||||
|
||||
interface Emits {
|
||||
(e: 'update:modelValue', value: boolean): void
|
||||
(e: 'confirm', data: { download_speed: number; upload_speed: number }): void
|
||||
(e: 'confirm', data: { code: SpeedTierCode }): void
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
confirmLoading: false
|
||||
})
|
||||
const emit = defineEmits<Emits>()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
const loading = ref(false)
|
||||
const speedTiers = [
|
||||
{ code: -1, label: '不限速' },
|
||||
{ code: 0, label: '0kbps' },
|
||||
{ code: 1, label: '128Kbps' },
|
||||
{ code: 2, label: '512Kbps' },
|
||||
{ code: 3, label: '1Mbps' },
|
||||
{ code: 4, label: '2Mbps' },
|
||||
{ code: 5, label: '10Mbps' },
|
||||
{ code: 6, label: '20Mbps' },
|
||||
{ code: 7, label: '50Mbps' },
|
||||
{ code: 8, label: '100Mbps' }
|
||||
] as const
|
||||
|
||||
const form = reactive({
|
||||
download_speed: 1024,
|
||||
upload_speed: 512
|
||||
})
|
||||
const form = reactive<{ code: SpeedTierCode | undefined }>({ code: undefined })
|
||||
|
||||
const rules: FormRules = {
|
||||
download_speed: [{ required: true, message: '请输入下行速率', trigger: 'blur' }],
|
||||
upload_speed: [{ required: true, message: '请输入上行速率', trigger: 'blur' }]
|
||||
code: [{ required: true, message: '请选择限速档位', trigger: 'change' }]
|
||||
}
|
||||
|
||||
const visible = computed({
|
||||
@@ -65,11 +89,25 @@
|
||||
})
|
||||
|
||||
// 监听对话框打开,重置表单
|
||||
watch(visible, (newVal) => {
|
||||
if (newVal) {
|
||||
form.download_speed = 1024
|
||||
form.upload_speed = 512
|
||||
}
|
||||
const setLayoutScrollLock = (locked: boolean) => {
|
||||
document
|
||||
.querySelector<HTMLElement>('.layouts')
|
||||
?.classList.toggle('speed-limit-scroll-locked', locked)
|
||||
}
|
||||
|
||||
watch(
|
||||
visible,
|
||||
(newVal) => {
|
||||
setLayoutScrollLock(newVal)
|
||||
if (newVal) {
|
||||
form.code = undefined
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
onUnmounted(() => {
|
||||
setLayoutScrollLock(false)
|
||||
})
|
||||
|
||||
const handleCancel = () => {
|
||||
@@ -77,13 +115,14 @@
|
||||
}
|
||||
|
||||
const handleConfirm = async () => {
|
||||
if (props.confirmLoading) return
|
||||
if (!formRef.value) return
|
||||
|
||||
try {
|
||||
await formRef.value.validate()
|
||||
if (form.code === undefined) return
|
||||
emit('confirm', {
|
||||
download_speed: form.download_speed,
|
||||
upload_speed: form.upload_speed
|
||||
code: form.code
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('表单验证失败:', error)
|
||||
@@ -91,4 +130,28 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
<style lang="scss">
|
||||
.speed-limit-modal .el-dialog__body {
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.speed-limit-select-popper {
|
||||
z-index: 4001 !important;
|
||||
overscroll-behavior: contain;
|
||||
}
|
||||
|
||||
.speed-limit-select-popper .el-select-dropdown__wrap,
|
||||
.speed-limit-select-popper .el-scrollbar__wrap {
|
||||
max-height: none !important;
|
||||
overflow-y: visible !important;
|
||||
}
|
||||
|
||||
.speed-limit-modal {
|
||||
overflow: hidden;
|
||||
overscroll-behavior: contain;
|
||||
}
|
||||
|
||||
.layouts.speed-limit-scroll-locked {
|
||||
overflow: hidden !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
<template>
|
||||
<ElDialog v-model="visible" title="设置切卡模式" width="500px">
|
||||
<ElForm ref="formRef" :model="form" :rules="rules" label-width="96px">
|
||||
<ElDialog
|
||||
v-model="visible"
|
||||
title="设置切卡模式"
|
||||
width="45%"
|
||||
modal-class="asset-information-dialog"
|
||||
>
|
||||
<ElForm ref="formRef" :model="form" :rules="rules" label-width="80px">
|
||||
<ElFormItem label="设备标识">
|
||||
<span class="device-identifier">{{ deviceIdentifier || '-' }}</span>
|
||||
</ElFormItem>
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
<template>
|
||||
<ElDialog v-model="visible" title="设置WiFi" width="30%" :append-to-body="true">
|
||||
<ElDialog
|
||||
v-model="visible"
|
||||
title="设置WiFi"
|
||||
width="40%"
|
||||
modal-class="asset-information-dialog"
|
||||
:append-to-body="true"
|
||||
>
|
||||
<ElForm ref="formRef" :model="form" :rules="rules" label-width="80px" autocomplete="off">
|
||||
<ElFormItem label="WiFi状态" prop="enabled">
|
||||
<ElRadioGroup v-model="form.enabled">
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import { ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { AssetService } from '@/api/modules'
|
||||
import { formatRemainingTime, FrontendRateLimitError } from '@/utils/business/apiRateLimit'
|
||||
import { FrontendRateLimitError } from '@/utils/business/apiRateLimit'
|
||||
import type {
|
||||
AssetBoundCard,
|
||||
AssetWalletResponse,
|
||||
@@ -123,6 +123,8 @@ export function useAssetInfo() {
|
||||
updated_at: data.updated_at,
|
||||
accumulated_recharge: data.accumulated_recharge,
|
||||
first_commission_paid: data.first_commission_paid,
|
||||
polling: data.polling ?? null,
|
||||
exchange_trace: data.exchange_trace ?? null,
|
||||
|
||||
// 卡专属字段 (asset_type === 'card')
|
||||
iccid: data.iccid || '',
|
||||
@@ -138,6 +140,11 @@ export function useAssetInfo() {
|
||||
gateway_extend: data.gateway_extend ?? '',
|
||||
total_virtual_used_mb: data.total_virtual_used_mb ?? null,
|
||||
total_virtual_remaining_mb: data.total_virtual_remaining_mb ?? null,
|
||||
estimated_final_expires_at: data.estimated_final_expires_at ?? null,
|
||||
days_until_final_expiry: data.days_until_final_expiry ?? null,
|
||||
expiry_estimate_status: data.expiry_estimate_status,
|
||||
expiry_estimate_status_name: data.expiry_estimate_status_name ?? null,
|
||||
is_expiring: data.is_expiring ?? false,
|
||||
bound_device_id: data.bound_device_id,
|
||||
bound_device_no: data.bound_device_no || '',
|
||||
bound_device_name: data.bound_device_name || '',
|
||||
@@ -430,11 +437,11 @@ export function useAssetInfo() {
|
||||
return true
|
||||
} catch (error: any) {
|
||||
if (error instanceof FrontendRateLimitError) {
|
||||
ElMessage.warning(`操作过于频繁,请${formatRemainingTime(error.remainingMs)}后再试`)
|
||||
ElMessage.warning('操作过于频繁,请稍后重试')
|
||||
return false
|
||||
}
|
||||
if (error?.response?.status === 429) {
|
||||
ElMessage.warning('操作过于频繁,请5分钟后再试')
|
||||
ElMessage.warning('操作过于频繁,请稍后重试')
|
||||
return false
|
||||
}
|
||||
return false
|
||||
|
||||
@@ -11,11 +11,11 @@ import { formatRemainingTime, FrontendRateLimitError } from '@/utils/business/ap
|
||||
export function useAssetOperations(cardInfo: Ref<any>, refreshAssetFn?: () => Promise<void>) {
|
||||
// Loading states
|
||||
const enableCardLoading = ref(false)
|
||||
const startFailureMessage = ref('')
|
||||
const disableCardLoading = ref(false)
|
||||
const manualDeactivateCardLoading = ref(false)
|
||||
const rebootDeviceLoading = ref(false)
|
||||
const resetDeviceLoading = ref(false)
|
||||
const speedLimitLoading = ref(false)
|
||||
const switchCardLoading = ref(false)
|
||||
const setWiFiLoading = ref(false)
|
||||
const pollingLoading = ref(false)
|
||||
@@ -29,22 +29,33 @@ export function useAssetOperations(cardInfo: Ref<any>, refreshAssetFn?: () => Pr
|
||||
type: 'warning'
|
||||
})
|
||||
|
||||
startFailureMessage.value = ''
|
||||
enableCardLoading.value = true
|
||||
const res = await AssetService.startAsset(cardInfo.value.iccid)
|
||||
const res = await AssetService.startAsset(cardInfo.value.iccid, {
|
||||
requestOptions: { errorMessageMode: 'none' }
|
||||
})
|
||||
if (res.code === 0) {
|
||||
ElMessage.success('启用成功')
|
||||
if (refreshAssetFn) {
|
||||
await refreshAssetFn()
|
||||
}
|
||||
return true
|
||||
}
|
||||
startFailureMessage.value = res.msg || '复机失败,请稍后重试'
|
||||
return false
|
||||
} catch (error: any) {
|
||||
if (error !== 'cancel') {
|
||||
if (error instanceof FrontendRateLimitError) {
|
||||
ElMessage.warning(`操作过于频繁,请${formatRemainingTime(error.remainingMs)}后再试`)
|
||||
return
|
||||
return false
|
||||
}
|
||||
console.error('启用失败:', error)
|
||||
const backendMessage = error?.response?.data?.msg
|
||||
startFailureMessage.value =
|
||||
typeof backendMessage === 'string' && backendMessage.trim()
|
||||
? backendMessage
|
||||
: '复机失败,请稍后重试'
|
||||
}
|
||||
return false
|
||||
} finally {
|
||||
enableCardLoading.value = false
|
||||
}
|
||||
@@ -169,35 +180,6 @@ export function useAssetOperations(cardInfo: Ref<any>, refreshAssetFn?: () => Pr
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set device speed limit
|
||||
*/
|
||||
const setSpeedLimit = async (form: { download_speed: number; upload_speed: number }) => {
|
||||
try {
|
||||
speedLimitLoading.value = true
|
||||
const res = await DeviceService.setSpeedLimit(cardInfo.value.imei, {
|
||||
download_speed: form.download_speed,
|
||||
upload_speed: form.upload_speed
|
||||
})
|
||||
if (res.code === 0) {
|
||||
ElMessage.success('限速设置成功')
|
||||
if (refreshAssetFn) {
|
||||
await refreshAssetFn()
|
||||
}
|
||||
return true
|
||||
} else {
|
||||
ElMessage.error(res.msg || '设置失败')
|
||||
return false
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('设置限速失败:', error)
|
||||
console.log(error?.message || '设置失败')
|
||||
return false
|
||||
} finally {
|
||||
speedLimitLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch to different card
|
||||
*/
|
||||
@@ -303,11 +285,11 @@ export function useAssetOperations(cardInfo: Ref<any>, refreshAssetFn?: () => Pr
|
||||
return {
|
||||
// Loading states
|
||||
enableCardLoading,
|
||||
startFailureMessage,
|
||||
disableCardLoading,
|
||||
manualDeactivateCardLoading,
|
||||
rebootDeviceLoading,
|
||||
resetDeviceLoading,
|
||||
speedLimitLoading,
|
||||
switchCardLoading,
|
||||
setWiFiLoading,
|
||||
pollingLoading,
|
||||
@@ -320,7 +302,6 @@ export function useAssetOperations(cardInfo: Ref<any>, refreshAssetFn?: () => Pr
|
||||
// Device operations
|
||||
rebootDevice,
|
||||
resetDevice,
|
||||
setSpeedLimit,
|
||||
switchCard,
|
||||
setWiFi,
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<template>
|
||||
<div class="single-card-page">
|
||||
<div class="single-card-page asset-information-page">
|
||||
<!-- 资产查询区域 -->
|
||||
<AssetSearchCard
|
||||
ref="assetSearchCardRef"
|
||||
:has-card-info="!!cardInfo"
|
||||
:refresh-disabled="refreshDisabled"
|
||||
:refresh-remaining-text="refreshRemainingText"
|
||||
@search="handleSearch"
|
||||
@refresh="handleRefresh"
|
||||
/>
|
||||
@@ -13,51 +12,55 @@
|
||||
<!-- 卡片内容区域 -->
|
||||
<div v-if="cardInfo" class="card-content-area slide-in">
|
||||
<div class="main-content-layout">
|
||||
<!-- 第一行:基本信息 -->
|
||||
<div class="row full-width">
|
||||
<BasicInfoCard
|
||||
:card-info="cardInfo"
|
||||
:device-realtime="deviceRealtime"
|
||||
v-model:polling-enabled="pollingEnabled"
|
||||
:realtime-loading="realtimeLoading"
|
||||
:start-disabled="startDisabled"
|
||||
:stop-disabled="stopDisabled"
|
||||
:start-remaining-text="startRemainingText"
|
||||
:stop-remaining-text="stopRemainingText"
|
||||
:get-start-remaining-text="getStartRemainingText"
|
||||
:get-stop-remaining-text="getStopRemainingText"
|
||||
:is-start-disabled="isStartActionDisabled"
|
||||
:is-stop-disabled="isStopActionDisabled"
|
||||
@enable-card="handleEnableCard"
|
||||
@disable-card="handleDisableCard"
|
||||
@manual-deactivate="handleManualDeactivate"
|
||||
@reboot-device="handleRebootDevice"
|
||||
@reset-device="handleResetDevice"
|
||||
@show-switch-card="showSwitchCardDialog"
|
||||
@show-switch-mode="showSwitchModeDialog"
|
||||
@show-set-wifi="showSetWiFiDialog"
|
||||
@show-realname-policy="showRealnamePolicyDialog"
|
||||
@show-update-realname-status="showUpdateRealnameStatusDialog"
|
||||
@enable-binding-card="handleEnableBindingCard"
|
||||
@disable-binding-card="handleDisableBindingCard"
|
||||
@update-binding-card-realname-status="handleUpdateBindingCardRealnameStatus"
|
||||
@navigate-to-card="handleNavigateToCard"
|
||||
@navigate-to-device="handleNavigateToDevice"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 第二行:当前生效套餐 -->
|
||||
<div class="row full-width">
|
||||
<CurrentPackageCard
|
||||
:current-package="currentPackage"
|
||||
:loading="currentPackageLoading"
|
||||
:error-msg="currentPackageErrorMsg"
|
||||
:bound-device-id="cardInfo.bound_device_id"
|
||||
:bound-device-no="cardInfo.bound_device_no"
|
||||
:bound-device-name="cardInfo.bound_device_name"
|
||||
@show-recharge="showRechargeDialog"
|
||||
@navigate-to-device="handleNavigateToDevice"
|
||||
/>
|
||||
<div class="overview-grid">
|
||||
<!-- 第一层:资产概览与当前生效套餐,按信息高度纵向展开 -->
|
||||
<div class="row overview-primary">
|
||||
<BasicInfoCard
|
||||
:card-info="cardInfo"
|
||||
:device-realtime="deviceRealtime"
|
||||
v-model:polling-enabled="pollingEnabled"
|
||||
:realtime-loading="realtimeLoading"
|
||||
:start-disabled="startDisabled"
|
||||
:start-error-message="startFailureMessage"
|
||||
:stop-disabled="stopDisabled"
|
||||
:start-remaining-text="startRemainingText"
|
||||
:stop-remaining-text="stopRemainingText"
|
||||
:get-start-remaining-text="getStartRemainingText"
|
||||
:get-stop-remaining-text="getStopRemainingText"
|
||||
:is-start-disabled="isStartActionDisabled"
|
||||
:is-stop-disabled="isStopActionDisabled"
|
||||
@enable-card="handleEnableCard"
|
||||
@disable-card="handleDisableCard"
|
||||
@manual-deactivate="handleManualDeactivate"
|
||||
@reboot-device="handleRebootDevice"
|
||||
@reset-device="handleResetDevice"
|
||||
@show-switch-card="showSwitchCardDialog"
|
||||
@show-switch-mode="showSwitchModeDialog"
|
||||
@show-set-wifi="showSetWiFiDialog"
|
||||
@show-realname-policy="showRealnamePolicyDialog"
|
||||
@show-speed-limit="speedLimitDialogVisible = true"
|
||||
@show-update-realname-status="showUpdateRealnameStatusDialog"
|
||||
@enable-binding-card="handleEnableBindingCard"
|
||||
@disable-binding-card="handleDisableBindingCard"
|
||||
@update-binding-card-realname-status="handleUpdateBindingCardRealnameStatus"
|
||||
@navigate-to-asset="handleNavigateToAsset"
|
||||
@navigate-to-card="handleNavigateToCard"
|
||||
@navigate-to-device="handleNavigateToDevice"
|
||||
>
|
||||
<template #current-package>
|
||||
<CurrentPackageCard
|
||||
:current-package="currentPackage"
|
||||
:loading="currentPackageLoading"
|
||||
:error-msg="currentPackageErrorMsg"
|
||||
:bound-device-id="cardInfo.bound_device_id"
|
||||
:bound-device-no="cardInfo.bound_device_no"
|
||||
:bound-device-name="cardInfo.bound_device_name"
|
||||
@show-recharge="showRechargeDialog"
|
||||
@navigate-to-device="handleNavigateToDevice"
|
||||
/>
|
||||
</template>
|
||||
</BasicInfoCard>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 第三行:套餐列表 -->
|
||||
@@ -94,15 +97,6 @@
|
||||
@navigate-to-device="handleNavigateToDevice"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 第五行:操作审计日志 -->
|
||||
<div class="row full-width">
|
||||
<OperationLogsCard
|
||||
:asset-identifier="cardInfo.identifier"
|
||||
:asset-type="cardInfo.asset_type"
|
||||
download-permission="asset_info:download_log_file"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -172,6 +166,11 @@
|
||||
:current-realname-status="bindingCardRealnameStatusValue"
|
||||
@success="handleBindingCardRealnameStatusSuccess"
|
||||
/>
|
||||
<SpeedLimitDialog
|
||||
v-model="speedLimitDialogVisible"
|
||||
:confirm-loading="speedTierSubmitting"
|
||||
@confirm="handleSpeedTierConfirm"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -180,7 +179,10 @@
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ElMessage, ElCard, ElEmpty } from 'element-plus'
|
||||
import { RoutesAlias } from '@/router/routesAlias'
|
||||
import { DeviceService } from '@/api/modules'
|
||||
import { CardService, DeviceService } from '@/api/modules'
|
||||
import { JULY_PERMISSIONS } from '@/config/constants'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
import { normalizeApiError } from '@/utils/business/apiError'
|
||||
import {
|
||||
formatRemainingTime,
|
||||
FrontendRateLimitError,
|
||||
@@ -194,7 +196,6 @@
|
||||
import CurrentPackageCard from './components/CurrentPackageCard.vue'
|
||||
import PackageListCard from './components/PackageListCard.vue'
|
||||
import WalletTransactionCard from './components/WalletTransactionCard.vue'
|
||||
import OperationLogsCard from './components/OperationLogsCard.vue'
|
||||
|
||||
// 引入对话框组件
|
||||
import {
|
||||
@@ -202,7 +203,8 @@
|
||||
WiFiConfigDialog,
|
||||
PackageRechargeDialog,
|
||||
DailyRecordsDialog,
|
||||
OrderHistoryDialog
|
||||
OrderHistoryDialog,
|
||||
SpeedLimitDialog
|
||||
} from './components/dialogs'
|
||||
import SwitchCardDialog from '@/components/device/SwitchCardDialog.vue'
|
||||
import RealnamePolicyDialog from '@/components/device/RealnamePolicyDialog.vue'
|
||||
@@ -231,6 +233,7 @@
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const { hasAuth } = useAuth()
|
||||
|
||||
// ========== 组件引用 ==========
|
||||
const assetSearchCardRef = ref<InstanceType<typeof AssetSearchCard>>()
|
||||
@@ -258,6 +261,7 @@
|
||||
// ========== 资产操作方法(使用 composable) ==========
|
||||
const {
|
||||
enableCardLoading,
|
||||
startFailureMessage,
|
||||
disableCardLoading,
|
||||
enableCard: enableCardOp,
|
||||
disableCard: disableCardOp,
|
||||
@@ -288,6 +292,8 @@
|
||||
|
||||
// 绑定卡实名状态更新
|
||||
const bindingCardRealnameStatusDialogVisible = ref(false)
|
||||
const speedLimitDialogVisible = ref(false)
|
||||
const speedTierSubmitting = ref(false)
|
||||
const bindingCardRealnameStatusIccid = ref('')
|
||||
const bindingCardRealnameStatusValue = ref<number>(0)
|
||||
|
||||
@@ -332,26 +338,7 @@
|
||||
const refreshSubmitting = ref(false)
|
||||
let rateLimitTimer: ReturnType<typeof setInterval> | undefined
|
||||
|
||||
const refreshRateLimitState = computed(() => {
|
||||
const identifier = cardInfo.value?.identifier
|
||||
if (!identifier) {
|
||||
return {
|
||||
limited: false,
|
||||
remainingMs: 0,
|
||||
retryAt: 0
|
||||
}
|
||||
}
|
||||
return getAssetActionRateLimitState('refresh', identifier, rateLimitNow.value)
|
||||
})
|
||||
|
||||
const refreshDisabled = computed(
|
||||
() => refreshSubmitting.value || refreshRateLimitState.value.limited
|
||||
)
|
||||
const refreshRemainingText = computed(() =>
|
||||
refreshRateLimitState.value.limited
|
||||
? formatRemainingTime(refreshRateLimitState.value.remainingMs)
|
||||
: ''
|
||||
)
|
||||
const refreshDisabled = computed(() => refreshSubmitting.value)
|
||||
|
||||
const startRateLimitState = computed(() => {
|
||||
const identifier = cardInfo.value?.iccid || cardInfo.value?.identifier
|
||||
@@ -418,6 +405,7 @@
|
||||
const handleSearch = async ({ identifier }: { identifier: string }) => {
|
||||
// 更新搜索框的值
|
||||
assetSearchCardRef.value?.updateSearchValue(identifier)
|
||||
startFailureMessage.value = ''
|
||||
|
||||
// fetchAssetDetail 内部已经会并行加载所有相关数据,不需要重复调用
|
||||
await fetchAssetDetail(identifier)
|
||||
@@ -465,7 +453,10 @@
|
||||
const handleEnableCard = async () => {
|
||||
if (startDisabled.value) return
|
||||
try {
|
||||
await enableCardOp()
|
||||
const started = await enableCardOp()
|
||||
if (started && cardInfo.value) {
|
||||
await fetchAssetDetail(cardInfo.value.identifier)
|
||||
}
|
||||
} finally {
|
||||
updateRateLimitNow()
|
||||
}
|
||||
@@ -749,6 +740,13 @@
|
||||
await handleSearch({ identifier: iccid })
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到任意资产信息
|
||||
*/
|
||||
const handleNavigateToAsset = async (identifier: string) => {
|
||||
await handleSearch({ identifier })
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到绑定设备信息
|
||||
*/
|
||||
@@ -807,6 +805,42 @@
|
||||
handleSearch({ identifier })
|
||||
}
|
||||
}
|
||||
const handleSpeedTierConfirm = async (data: { code: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 }) => {
|
||||
if (!hasAuth(JULY_PERMISSIONS.speedTier.update)) {
|
||||
ElMessage.error('暂无设置限速权限')
|
||||
return
|
||||
}
|
||||
|
||||
const iccid = cardInfo.value?.iccid
|
||||
if (!iccid) {
|
||||
ElMessage.error('当前卡缺少 ICCID,无法设置限速')
|
||||
return
|
||||
}
|
||||
if (speedTierSubmitting.value) return
|
||||
|
||||
speedTierSubmitting.value = true
|
||||
try {
|
||||
const response = await CardService.setSpeedTier(iccid, data.code)
|
||||
if (response.code !== 0) {
|
||||
speedLimitDialogVisible.value = false
|
||||
await nextTick()
|
||||
ElMessage.error(response.msg || '限速设置失败')
|
||||
return
|
||||
}
|
||||
|
||||
speedLimitDialogVisible.value = false
|
||||
await nextTick()
|
||||
ElMessage.success(`限速设置成功:${response.data.speed_tier_name}`)
|
||||
await handleRefresh()
|
||||
} catch (error) {
|
||||
console.error('设置限速失败:', error)
|
||||
speedLimitDialogVisible.value = false
|
||||
await nextTick()
|
||||
ElMessage.error(normalizeApiError(error).message)
|
||||
} finally {
|
||||
speedTierSubmitting.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@@ -956,6 +990,12 @@
|
||||
}
|
||||
|
||||
// 主内容布局
|
||||
.overview-grid {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.main-content-layout {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -1024,6 +1064,10 @@
|
||||
}
|
||||
|
||||
@media (width <= 768px) {
|
||||
.overview-grid {
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
gap: 16px;
|
||||
|
||||
.row {
|
||||
@@ -1603,3 +1647,118 @@
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.asset-information-page {
|
||||
background: #ffffff;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss">
|
||||
/* Dialogs are teleported to body, so their surface needs a page-level hook. */
|
||||
.asset-information-dialog.el-dialog {
|
||||
max-width: calc(100vw - 32px);
|
||||
overflow: hidden;
|
||||
border: 1px solid #e5eaf1;
|
||||
border-radius: 14px;
|
||||
box-shadow: 0 18px 50px rgb(15 23 42 / 18%);
|
||||
|
||||
.el-dialog__header {
|
||||
padding: 20px 24px 16px;
|
||||
margin: 0;
|
||||
border-bottom: 1px solid #e5eaf1;
|
||||
}
|
||||
|
||||
.el-dialog__title {
|
||||
font-size: 16px;
|
||||
font-weight: 650;
|
||||
color: #172033;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
.el-dialog__body {
|
||||
padding: 22px 24px 20px;
|
||||
}
|
||||
|
||||
.el-dialog__footer {
|
||||
padding: 14px 24px 20px;
|
||||
border-top: 1px solid #eef2f7;
|
||||
}
|
||||
|
||||
.el-form-item {
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.el-form-item__label {
|
||||
color: #526078;
|
||||
}
|
||||
|
||||
.el-button {
|
||||
min-height: 34px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.el-table {
|
||||
--el-table-header-bg-color: #f8fafc;
|
||||
--el-table-row-hover-bg-color: #f5f8ff;
|
||||
--el-table-border-color: #e5eaf1;
|
||||
border-radius: 9px;
|
||||
}
|
||||
|
||||
.el-descriptions__label.el-descriptions__cell.is-bordered-label {
|
||||
color: #526078;
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
|
||||
@media (width <= 768px) {
|
||||
.asset-information-dialog.el-dialog {
|
||||
width: calc(100vw - 20px) !important;
|
||||
|
||||
.el-dialog__header {
|
||||
padding: 16px 18px 13px;
|
||||
}
|
||||
|
||||
.el-dialog__body {
|
||||
max-height: calc(100vh - 150px);
|
||||
padding: 18px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.el-dialog__footer {
|
||||
padding: 12px 18px 16px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
html.dark .asset-information-dialog.el-dialog {
|
||||
border-color: #2b3a52;
|
||||
|
||||
.el-dialog__header,
|
||||
.el-dialog__footer {
|
||||
border-color: #2b3a52;
|
||||
}
|
||||
|
||||
.el-dialog__title,
|
||||
.el-form-item__label {
|
||||
color: #e5edf8;
|
||||
}
|
||||
|
||||
.el-table {
|
||||
--el-table-header-bg-color: #202d42;
|
||||
--el-table-row-hover-bg-color: #223451;
|
||||
--el-table-border-color: #2b3a52;
|
||||
}
|
||||
|
||||
.el-descriptions__label.el-descriptions__cell.is-bordered-label {
|
||||
color: #afbdd0;
|
||||
background: #202d42;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
* 资产信息页面类型定义
|
||||
*/
|
||||
|
||||
import type { AssetExchangeTrace, AssetPollingStatus, ExpiryEstimateStatus } from '@/types/api'
|
||||
|
||||
// 资产类型枚举
|
||||
export type AssetType = 'card' | 'device'
|
||||
|
||||
@@ -33,10 +35,17 @@ export interface AssetInfo {
|
||||
gateway_extend?: string
|
||||
total_virtual_used_mb?: number | null
|
||||
total_virtual_remaining_mb?: number | null
|
||||
estimated_final_expires_at?: string | null
|
||||
days_until_final_expiry?: number | null
|
||||
expiry_estimate_status?: ExpiryEstimateStatus
|
||||
expiry_estimate_status_name?: string | null
|
||||
is_expiring?: boolean
|
||||
last_sync_time?: string | null
|
||||
last_data_check_at?: string | null
|
||||
last_real_name_check_at?: string | null
|
||||
last_card_status_check_at?: string | null
|
||||
polling?: AssetPollingStatus | null
|
||||
exchange_trace?: AssetExchangeTrace | null
|
||||
}
|
||||
|
||||
// 设备绑定卡信息
|
||||
|
||||
@@ -40,6 +40,14 @@
|
||||
>
|
||||
批量设置套餐系列
|
||||
</ElButton>
|
||||
<ElButton
|
||||
type="primary"
|
||||
:disabled="!selectedDevices.length"
|
||||
@click="showBatchRealnamePolicyDialog"
|
||||
v-permission="'device:realname_policy'"
|
||||
>
|
||||
批量修改实名顺序
|
||||
</ElButton>
|
||||
<ElButton
|
||||
type="primary"
|
||||
:disabled="!selectedDevices.length"
|
||||
@@ -85,17 +93,17 @@
|
||||
</ArtTable>
|
||||
|
||||
<!-- 批量分配对话框 -->
|
||||
<ElDialog v-model="allocateDialogVisible" title="批量分配设备" width="600px">
|
||||
<ElDialog v-model="allocateDialogVisible" title="批量分配设备" width="40%">
|
||||
<ElForm
|
||||
ref="allocateFormRef"
|
||||
:model="allocateForm"
|
||||
:rules="allocateRules"
|
||||
label-width="120px"
|
||||
label-width="90px"
|
||||
>
|
||||
<ElFormItem label="已选设备数">
|
||||
<span style="font-weight: bold; color: #409eff">{{ selectedDevices.length }}</span> 台
|
||||
</ElFormItem>
|
||||
<ElFormItem label="店铺" prop="target_shop_id">
|
||||
<ElFormItem label="目标店铺" prop="target_shop_id">
|
||||
<ElCascader
|
||||
v-model="allocateForm.target_shop_id"
|
||||
:options="shopCascadeOptions"
|
||||
@@ -158,8 +166,8 @@
|
||||
</ElDialog>
|
||||
|
||||
<!-- 批量回收对话框 -->
|
||||
<ElDialog v-model="recallDialogVisible" title="批量回收设备" width="600px">
|
||||
<ElForm ref="recallFormRef" :model="recallForm" label-width="120px">
|
||||
<ElDialog v-model="recallDialogVisible" title="批量回收设备" width="40%">
|
||||
<ElForm ref="recallFormRef" :model="recallForm" label-width="90px">
|
||||
<ElFormItem label="已选设备数">
|
||||
<span style="font-weight: bold; color: #e6a23c">{{ selectedDevices.length }}</span> 台
|
||||
</ElFormItem>
|
||||
@@ -217,14 +225,14 @@
|
||||
<ElDialog
|
||||
v-model="seriesBindingDialogVisible"
|
||||
title="批量设置设备套餐系列绑定"
|
||||
width="35%"
|
||||
width="40%"
|
||||
@close="handleCloseSeriesBindingDialog"
|
||||
>
|
||||
<ElForm
|
||||
ref="seriesBindingFormRef"
|
||||
:model="seriesBindingForm"
|
||||
:rules="seriesBindingRules"
|
||||
label-width="120px"
|
||||
label-width="100px"
|
||||
>
|
||||
<ElFormItem label="已选设备数">
|
||||
<span style="font-weight: bold; color: #409eff">{{ selectedDevices.length }}</span> 台
|
||||
@@ -389,19 +397,19 @@
|
||||
>
|
||||
<ElDatePicker
|
||||
v-model="seriesBindingForm.created_at_range"
|
||||
type="daterange"
|
||||
type="datetimerange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始时间"
|
||||
end-placeholder="结束时间"
|
||||
value-format="YYYY-MM-DD"
|
||||
value-format="YYYY-MM-DDTHH:mm:ssZ"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</ElFormItem>
|
||||
|
||||
<ElFormItem label="目标套餐系列" prop="series_id">
|
||||
<ElFormItem label="套餐系列" prop="series_id">
|
||||
<ElSelect
|
||||
v-model="seriesBindingForm.series_id"
|
||||
placeholder="请选择或搜索套餐系列"
|
||||
placeholder="请选择或搜索目标套餐系列"
|
||||
style="width: 100%"
|
||||
filterable
|
||||
remote
|
||||
@@ -685,24 +693,27 @@
|
||||
:current-policy="currentRealnamePolicy"
|
||||
@confirm="handleConfirmRealnamePolicy"
|
||||
/>
|
||||
|
||||
<!-- 操作审计日志弹窗 -->
|
||||
<OperationLogsDialog
|
||||
v-model="operationLogsDialogVisible"
|
||||
:identifier="operationLogsIdentifier"
|
||||
download-permission="device:download_log_file"
|
||||
<BatchRealnamePolicyDialog
|
||||
v-model="batchRealnamePolicyDialogVisible"
|
||||
:selected-count="selectedDevices.length"
|
||||
asset-unit="台设备"
|
||||
:loading="batchRealnamePolicyLoading"
|
||||
:error-message="batchRealnamePolicyError"
|
||||
device-policy-hint
|
||||
@confirm="handleConfirmBatchRealnamePolicy"
|
||||
/>
|
||||
|
||||
<ElDialog
|
||||
v-model="enterpriseDeviceAuthorizeDialogVisible"
|
||||
title="授权设备给企业"
|
||||
width="620px"
|
||||
width="40%"
|
||||
@close="handleEnterpriseDeviceAuthorizeDialogClose"
|
||||
>
|
||||
<ElForm
|
||||
ref="enterpriseDeviceAuthorizeFormRef"
|
||||
:model="enterpriseDeviceAuthorizeForm"
|
||||
:rules="enterpriseDeviceAuthorizeRules"
|
||||
label-width="120px"
|
||||
label-width="100px"
|
||||
>
|
||||
<ElFormItem label="授权企业" prop="enterprise_id">
|
||||
<ElSelect
|
||||
@@ -801,14 +812,14 @@
|
||||
<ElDialog
|
||||
v-model="enterpriseDeviceRecallDialogVisible"
|
||||
title="撤销设备授权"
|
||||
width="620px"
|
||||
width="40%"
|
||||
@close="handleEnterpriseDeviceRecallDialogClose"
|
||||
>
|
||||
<ElForm
|
||||
ref="enterpriseDeviceRecallFormRef"
|
||||
:model="enterpriseDeviceRecallForm"
|
||||
:rules="enterpriseDeviceRecallRules"
|
||||
label-width="120px"
|
||||
label-width="100px"
|
||||
>
|
||||
<ElFormItem label="授权企业" prop="enterprise_id">
|
||||
<ElSelect
|
||||
@@ -952,6 +963,10 @@
|
||||
import { computed, h } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { RoutesAlias } from '@/router/routesAlias'
|
||||
import { AUDIT_PERMISSIONS } from '@/config/constants/audit'
|
||||
import { resolveAuditResourceTarget } from '@/utils/business/auditNavigation'
|
||||
import { openAuditInvestigation } from '@/components/business/audit/investigationController'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import {
|
||||
DeviceService,
|
||||
ShopService,
|
||||
@@ -978,6 +993,11 @@
|
||||
import { useCheckedColumns } from '@/composables/useCheckedColumns'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
import {
|
||||
getExpiryEstimateText,
|
||||
getExpiryEstimateTooltip,
|
||||
getExpiryEstimateClass
|
||||
} from '@/utils/business/expiryEstimate'
|
||||
import type { PackageSeriesResponse } from '@/types/api'
|
||||
import type { EnterpriseItem } from '@/types/api/enterprise'
|
||||
import type {
|
||||
@@ -985,8 +1005,9 @@
|
||||
EnterpriseRecallDevicesResponse
|
||||
} from '@/types/api/enterpriseDevice'
|
||||
import RealnamePolicyDialog from '@/components/device/RealnamePolicyDialog.vue'
|
||||
import OperationLogsDialog from '@/components/business/OperationLogsDialog.vue'
|
||||
import BatchRealnamePolicyDialog from '@/components/business/BatchRealnamePolicyDialog.vue'
|
||||
import ExportTaskCreateDialog from '@/components/business/ExportTaskCreateDialog.vue'
|
||||
import type { AssetRealnamePolicy } from '@/types/api'
|
||||
|
||||
defineOptions({ name: 'DeviceList' })
|
||||
|
||||
@@ -1003,6 +1024,7 @@
|
||||
|
||||
const { hasAuth } = useAuth()
|
||||
const router = useRouter()
|
||||
const userStore = useUserStore()
|
||||
|
||||
const loading = ref(false)
|
||||
const allocateLoading = ref(false)
|
||||
@@ -1013,8 +1035,9 @@
|
||||
const allocateDialogVisible = ref(false)
|
||||
const recallDialogVisible = ref(false)
|
||||
const selectedDevices = ref<Device[]>([])
|
||||
const operationLogsDialogVisible = ref(false)
|
||||
const operationLogsIdentifier = ref('')
|
||||
const batchRealnamePolicyDialogVisible = ref(false)
|
||||
const batchRealnamePolicyLoading = ref(false)
|
||||
const batchRealnamePolicyError = ref('')
|
||||
const exportDialogVisible = ref(false)
|
||||
const shopCascadeOptions = ref<any[]>([])
|
||||
const shopCascadeProps = {
|
||||
@@ -1315,6 +1338,7 @@
|
||||
device_name: '',
|
||||
status: undefined as DeviceStatus | undefined,
|
||||
activation_status: undefined as number | undefined,
|
||||
real_name_status: undefined as 0 | 1 | undefined,
|
||||
batch_no: '',
|
||||
device_type: '',
|
||||
manufacturer: '',
|
||||
@@ -1425,6 +1449,19 @@
|
||||
{ label: '已激活', value: 1 }
|
||||
]
|
||||
},
|
||||
{
|
||||
label: '实名状态',
|
||||
prop: 'real_name_status',
|
||||
type: 'select',
|
||||
config: {
|
||||
clearable: true,
|
||||
placeholder: '全部'
|
||||
},
|
||||
options: () => [
|
||||
{ label: '已实名', value: 1 },
|
||||
{ label: '未实名', value: 0 }
|
||||
]
|
||||
},
|
||||
{
|
||||
label: '批次号',
|
||||
prop: 'batch_no',
|
||||
@@ -1500,13 +1537,13 @@
|
||||
{
|
||||
label: '起止时间',
|
||||
prop: 'dateRange',
|
||||
type: 'date',
|
||||
type: 'datetimerange',
|
||||
config: {
|
||||
type: 'daterange',
|
||||
type: 'datetimerange',
|
||||
rangeSeparator: '至',
|
||||
startPlaceholder: '开始时间',
|
||||
endPlaceholder: '结束时间',
|
||||
valueFormat: 'YYYY-MM-DD'
|
||||
valueFormat: 'YYYY-MM-DDTHH:mm:ssZ'
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -1570,6 +1607,7 @@
|
||||
{ label: '设备名称', prop: 'device_name' },
|
||||
{ label: '店铺名称', prop: 'shop_name' },
|
||||
{ label: '套餐系列', prop: 'series_name' },
|
||||
{ label: '预计套餐到期时间', prop: 'estimated_final_expires_at' },
|
||||
{ label: '设备型号', prop: 'device_model' },
|
||||
{ label: '设备类型', prop: 'device_type' },
|
||||
{ label: '状态', prop: 'status' },
|
||||
@@ -1577,6 +1615,7 @@
|
||||
{ label: '资产世代', prop: 'generation' },
|
||||
{ label: '业务状态', prop: 'asset_status' },
|
||||
{ label: '激活状态', prop: 'activation_status_name' },
|
||||
{ label: '实名状态', prop: 'real_name_status_name' },
|
||||
{ label: '在线状态', prop: 'online_status' },
|
||||
{ label: '实名策略', prop: 'realname_policy' },
|
||||
{ label: '切卡模式', prop: 'switch_mode' },
|
||||
@@ -1853,6 +1892,20 @@
|
||||
minWidth: 180,
|
||||
showOverflowTooltip: true
|
||||
},
|
||||
{
|
||||
prop: 'estimated_final_expires_at',
|
||||
label: '预计套餐到期时间',
|
||||
width: 180,
|
||||
formatter: (row: Device) =>
|
||||
h(
|
||||
'span',
|
||||
{
|
||||
class: getExpiryEstimateClass(row),
|
||||
title: getExpiryEstimateTooltip(row)
|
||||
},
|
||||
getExpiryEstimateText(row)
|
||||
)
|
||||
},
|
||||
{
|
||||
prop: 'device_model',
|
||||
label: '设备型号',
|
||||
@@ -1912,6 +1965,12 @@
|
||||
width: 120,
|
||||
formatter: (row: Device) => row.activation_status_name || '-'
|
||||
},
|
||||
{
|
||||
prop: 'real_name_status_name',
|
||||
label: '实名状态',
|
||||
width: 100,
|
||||
formatter: (row: Device) => row.real_name_status_name || '-'
|
||||
},
|
||||
{
|
||||
prop: 'online_status',
|
||||
label: '在线状态',
|
||||
@@ -2104,6 +2163,7 @@
|
||||
device_name: searchForm.device_name || undefined,
|
||||
status: searchForm.status,
|
||||
activation_status: searchForm.activation_status ?? undefined,
|
||||
real_name_status: searchForm.real_name_status ?? undefined,
|
||||
batch_no: searchForm.batch_no || undefined,
|
||||
device_type: searchForm.device_type || undefined,
|
||||
manufacturer: searchForm.manufacturer || undefined,
|
||||
@@ -2134,6 +2194,7 @@
|
||||
device_name: searchForm.device_name || undefined,
|
||||
status: searchForm.status,
|
||||
activation_status: searchForm.activation_status ?? undefined,
|
||||
real_name_status: searchForm.real_name_status ?? undefined,
|
||||
batch_no: searchForm.batch_no || undefined,
|
||||
device_type: searchForm.device_type || undefined,
|
||||
manufacturer: searchForm.manufacturer || undefined,
|
||||
@@ -2201,6 +2262,51 @@
|
||||
selectedDevices.value = selection
|
||||
}
|
||||
|
||||
const showBatchRealnamePolicyDialog = () => {
|
||||
if (selectedDevices.value.length === 0) {
|
||||
ElMessage.warning('请先选择要修改的设备')
|
||||
return
|
||||
}
|
||||
|
||||
batchRealnamePolicyError.value = ''
|
||||
batchRealnamePolicyDialogVisible.value = true
|
||||
}
|
||||
|
||||
const handleConfirmBatchRealnamePolicy = async (realnamePolicy: AssetRealnamePolicy) => {
|
||||
const assetIds = selectedDevices.value.map((device) => device.id)
|
||||
if (assetIds.length === 0) {
|
||||
batchRealnamePolicyError.value = '请先选择要修改的设备'
|
||||
return
|
||||
}
|
||||
if (assetIds.length > 500) {
|
||||
batchRealnamePolicyError.value = '单次最多可修改500台设备'
|
||||
return
|
||||
}
|
||||
|
||||
batchRealnamePolicyError.value = ''
|
||||
batchRealnamePolicyLoading.value = true
|
||||
try {
|
||||
const res = await DeviceService.batchUpdateRealnamePolicy(
|
||||
{ asset_ids: assetIds, realname_policy: realnamePolicy },
|
||||
{ requestOptions: { errorMessageMode: 'none' } }
|
||||
)
|
||||
if (res.code !== 0) {
|
||||
batchRealnamePolicyError.value = res.msg || '批量修改实名顺序失败'
|
||||
return
|
||||
}
|
||||
|
||||
const successCount = res.data?.success_count ?? assetIds.length
|
||||
ElMessage.success(`批量修改实名顺序成功:${successCount}/${assetIds.length}`)
|
||||
batchRealnamePolicyDialogVisible.value = false
|
||||
selectedDevices.value = []
|
||||
await getTableData()
|
||||
} catch (error: any) {
|
||||
batchRealnamePolicyError.value = error?.response?.data?.msg || '批量修改实名顺序失败'
|
||||
} finally {
|
||||
batchRealnamePolicyLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 删除设备
|
||||
const deleteDevice = (row: Device) => {
|
||||
ElMessageBox.confirm(
|
||||
@@ -2263,7 +2369,7 @@
|
||||
})
|
||||
}
|
||||
|
||||
// 批量分配
|
||||
// 批量分配(设备列表原有操作,和设备批量任务页面并行保留)
|
||||
const handleBatchAllocate = async () => {
|
||||
if (selectedDevices.value.length === 0) {
|
||||
ElMessage.warning('请先选择要分配的设备')
|
||||
@@ -2326,7 +2432,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 批量回收
|
||||
// 批量回收(设备列表原有操作,和设备批量任务页面并行保留)
|
||||
const handleBatchRecall = () => {
|
||||
if (selectedDevices.value.length === 0) {
|
||||
ElMessage.warning('请先选择要回收的设备')
|
||||
@@ -2526,22 +2632,6 @@
|
||||
})
|
||||
}
|
||||
|
||||
// 批量设置套餐系列
|
||||
const handleBatchSetSeries = async () => {
|
||||
seriesBindingResult.value = null
|
||||
Object.assign(seriesBindingForm, createInitialSeriesBindingState(), {
|
||||
selection_type:
|
||||
selectedDevices.value.length > 0 ? DeviceSelectionType.LIST : DeviceSelectionType.FILTER
|
||||
})
|
||||
await Promise.all([
|
||||
loadPackageSeriesList(),
|
||||
loadSearchBatchNoOptions(),
|
||||
loadSeriesBindingShopCascadeOptions()
|
||||
])
|
||||
seriesBindingDialogVisible.value = true
|
||||
seriesBindingFormRef.value?.clearValidate()
|
||||
}
|
||||
|
||||
// 加载套餐系列列表(支持名称搜索,默认20条)
|
||||
const loadPackageSeriesList = async (seriesName?: string) => {
|
||||
seriesLoading.value = true
|
||||
@@ -2570,22 +2660,16 @@
|
||||
await loadPackageSeriesList(query || undefined)
|
||||
}
|
||||
|
||||
const loadSeriesBindingShopCascadeOptions = async () => {
|
||||
try {
|
||||
const res = await ShopService.getShopsCascade({
|
||||
parent_id: undefined,
|
||||
exclude_self: true
|
||||
})
|
||||
if (res.code === 0) {
|
||||
seriesBindingShopCascadeOptions.value = (res.data || []).map((item: any) => ({
|
||||
value: item.id,
|
||||
label: item.shop_name,
|
||||
leaf: !item.has_children
|
||||
}))
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载批量设置套餐系列根级店铺失败:', error)
|
||||
}
|
||||
// 显示批量设置套餐系列对话框
|
||||
const handleBatchSetSeries = async () => {
|
||||
seriesBindingResult.value = null
|
||||
Object.assign(seriesBindingForm, createInitialSeriesBindingState(), {
|
||||
selection_type:
|
||||
selectedDevices.value.length > 0 ? DeviceSelectionType.LIST : DeviceSelectionType.FILTER
|
||||
})
|
||||
await Promise.all([loadPackageSeriesList(), loadSearchBatchNoOptions()])
|
||||
seriesBindingDialogVisible.value = true
|
||||
seriesBindingFormRef.value?.clearValidate()
|
||||
}
|
||||
|
||||
const buildSeriesBindingRequest = (): BatchSetDeviceSeriesBindingRequest | null => {
|
||||
@@ -3074,17 +3158,27 @@
|
||||
})
|
||||
}
|
||||
|
||||
if (hasAuth('device:operation_logs')) {
|
||||
moreActions.push({
|
||||
label: '操作审计日志',
|
||||
handler: () => {
|
||||
operationLogsIdentifier.value = row.virtual_no
|
||||
operationLogsDialogVisible.value = true
|
||||
},
|
||||
type: 'primary'
|
||||
const userType = Number(userStore.getUserInfo.user_type)
|
||||
const auditPermission =
|
||||
userType === 3
|
||||
? AUDIT_PERMISSIONS.agentDeviceActivity
|
||||
: userType === 4
|
||||
? AUDIT_PERMISSIONS.enterpriseDeviceActivity
|
||||
: AUDIT_PERMISSIONS.deviceEntry
|
||||
if (hasAuth(auditPermission)) {
|
||||
const auditTarget = resolveAuditResourceTarget({
|
||||
userType,
|
||||
resourceType: 'device',
|
||||
internalId: row.id,
|
||||
businessIdentifier: row.virtual_no
|
||||
})
|
||||
if (auditTarget)
|
||||
moreActions.push({
|
||||
label: userType >= 3 ? '活动记录' : '审计记录',
|
||||
handler: () => openAuditInvestigation(auditTarget),
|
||||
type: 'primary'
|
||||
})
|
||||
}
|
||||
|
||||
// 如果有更多操作,添加到 actions 中
|
||||
if (moreActions.length > 0) {
|
||||
actions.push(...moreActions)
|
||||
@@ -3112,4 +3206,22 @@
|
||||
:deep(.el-table__row.table-row-with-context-menu) {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.expiry-estimate--critical,
|
||||
.expiry-estimate--warning,
|
||||
.expiry-estimate--notice {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.expiry-estimate--critical {
|
||||
color: var(--el-color-danger);
|
||||
}
|
||||
|
||||
.expiry-estimate--warning {
|
||||
color: #8e44ad;
|
||||
}
|
||||
|
||||
.expiry-estimate--notice {
|
||||
color: #e83e8c;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -45,6 +45,12 @@
|
||||
const exchangeDetail = ref<ExchangeResponse | null>(null)
|
||||
const exchangeId = ref<number>(0)
|
||||
|
||||
const formatExchangeShopName = (shopName?: string | null, shopId?: number | null) => {
|
||||
if (shopName) return shopName
|
||||
if (shopId === null || shopId === 0) return '平台'
|
||||
return '--'
|
||||
}
|
||||
|
||||
const getStatusType = (status: number): TagProps['type'] => {
|
||||
const types: Record<number, TagProps['type']> = {
|
||||
1: 'warning',
|
||||
@@ -77,6 +83,11 @@
|
||||
formatter: (_, data) =>
|
||||
data.flow_type_name || (flowType === 'direct' ? '直接换货' : '物流换货')
|
||||
},
|
||||
{
|
||||
label: '提交人',
|
||||
formatter: (value) => value || '--',
|
||||
prop: 'submitter_name'
|
||||
},
|
||||
{
|
||||
label: '换货原因',
|
||||
prop: 'exchange_reason',
|
||||
@@ -96,6 +107,11 @@
|
||||
label: '新资产标识符',
|
||||
formatter: (value) => value || '--',
|
||||
prop: 'new_asset_identifier'
|
||||
},
|
||||
{
|
||||
label: '继承归属店铺',
|
||||
formatter: (_, data) =>
|
||||
formatExchangeShopName(data.inherited_shop_name, data.inherited_shop_id)
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
411
src/views/asset-management/expiring-assets/index.vue
Normal file
411
src/views/asset-management/expiring-assets/index.vue
Normal file
@@ -0,0 +1,411 @@
|
||||
<template>
|
||||
<ArtTableFullScreen>
|
||||
<div class="expiring-assets-page" id="table-full-screen">
|
||||
<ArtSearchBar
|
||||
v-model:filter="searchForm"
|
||||
:items="searchFormItems"
|
||||
:show-expand="true"
|
||||
label-width="100px"
|
||||
@reset="handleReset"
|
||||
@search="handleSearch"
|
||||
/>
|
||||
|
||||
<ElCard shadow="never" class="art-table-card">
|
||||
<ArtTableHeader
|
||||
:columnList="columnOptions"
|
||||
v-model:columns="columnChecks"
|
||||
@refresh="handleRefresh"
|
||||
>
|
||||
<template #left>
|
||||
<div class="page-intro">
|
||||
临期资产 {{ summary.total_count }} 条(卡 {{ summary.card_count }},设备
|
||||
{{ summary.device_count }}),0-3 天资产优先显示。
|
||||
</div>
|
||||
</template>
|
||||
</ArtTableHeader>
|
||||
|
||||
<ArtTable
|
||||
ref="tableRef"
|
||||
row-key="asset_id"
|
||||
:loading="loading"
|
||||
:data="items"
|
||||
:currentPage="pagination.currentPage"
|
||||
:pageSize="pagination.pageSize"
|
||||
:total="pagination.total"
|
||||
:marginTop="10"
|
||||
@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 { h, onMounted, reactive, ref, computed } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ElButton, ElMessage, ElTag } from 'element-plus'
|
||||
import { AssetService, PackageManageService, ShopService } from '@/api/modules'
|
||||
import type {
|
||||
ExpiringAssetItem,
|
||||
ExpiringAssetSummary,
|
||||
ExpiringAssetType,
|
||||
ExpiringAssetQueryParams,
|
||||
PackageResponse,
|
||||
ShopResponse
|
||||
} from '@/types/api'
|
||||
import type { SearchFormItem } from '@/types'
|
||||
import { RoutesAlias } from '@/router/routesAlias'
|
||||
import { useCheckedColumns } from '@/composables/useCheckedColumns'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
|
||||
defineOptions({ name: 'ExpiringAssets' })
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const tableRef = ref()
|
||||
const loading = ref(false)
|
||||
const shopLoading = ref(false)
|
||||
const packageLoading = ref(false)
|
||||
const shopOptions = ref<ShopResponse[]>([])
|
||||
const packageOptions = ref<PackageResponse[]>([])
|
||||
const items = ref<ExpiringAssetItem[]>([])
|
||||
const summary = reactive<ExpiringAssetSummary>({
|
||||
card_count: 0,
|
||||
device_count: 0,
|
||||
total_count: 0,
|
||||
window_days: 15
|
||||
})
|
||||
const searchForm = reactive<ExpiringAssetQueryParams & { expires_range: string[] }>({
|
||||
asset_type: undefined,
|
||||
keyword: '',
|
||||
shop_id: undefined,
|
||||
package_id: undefined,
|
||||
days_min: undefined,
|
||||
days_max: undefined,
|
||||
expires_from: undefined,
|
||||
expires_to: undefined,
|
||||
expires_range: []
|
||||
})
|
||||
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||
|
||||
const searchFormItems = computed<SearchFormItem[]>(() => [
|
||||
{
|
||||
label: '资产类型',
|
||||
prop: 'asset_type',
|
||||
type: 'select',
|
||||
config: { clearable: true, placeholder: '全部' },
|
||||
options: [
|
||||
{ label: '物联网卡', value: 'iot_card' },
|
||||
{ label: '设备', value: 'device' }
|
||||
]
|
||||
},
|
||||
{
|
||||
label: '关键词',
|
||||
prop: 'keyword',
|
||||
type: 'input',
|
||||
config: { clearable: true, placeholder: '请输入资产标识' }
|
||||
},
|
||||
{
|
||||
label: '店铺',
|
||||
prop: 'shop_id',
|
||||
type: 'select',
|
||||
config: {
|
||||
clearable: true,
|
||||
filterable: true,
|
||||
remote: true,
|
||||
loading: shopLoading.value,
|
||||
remoteMethod: (query: string) => searchShops(query),
|
||||
placeholder: '请选择或搜索店铺'
|
||||
},
|
||||
options: () => shopOptions.value.map((shop) => ({ label: shop.shop_name, value: shop.id }))
|
||||
},
|
||||
{
|
||||
label: '套餐',
|
||||
prop: 'package_id',
|
||||
type: 'select',
|
||||
config: {
|
||||
clearable: true,
|
||||
filterable: true,
|
||||
remote: true,
|
||||
loading: packageLoading.value,
|
||||
remoteMethod: (query: string) => searchPackages(query),
|
||||
placeholder: '请选择或搜索套餐'
|
||||
},
|
||||
options: () =>
|
||||
packageOptions.value.map((pkg) => ({
|
||||
label: `${pkg.package_name} (${pkg.package_code})`,
|
||||
value: pkg.id
|
||||
}))
|
||||
},
|
||||
{
|
||||
label: '最小剩余天数',
|
||||
prop: 'days_min',
|
||||
type: 'input',
|
||||
config: {
|
||||
clearable: true,
|
||||
type: 'number',
|
||||
min: 0,
|
||||
max: 15,
|
||||
placeholder: '最小天数'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '最大剩余天数',
|
||||
prop: 'days_max',
|
||||
type: 'input',
|
||||
config: {
|
||||
clearable: true,
|
||||
type: 'number',
|
||||
min: 0,
|
||||
max: 15,
|
||||
placeholder: '最大天数'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '预计到期起止',
|
||||
prop: 'expires_range',
|
||||
type: 'datetimerange',
|
||||
config: {
|
||||
type: 'datetimerange',
|
||||
rangeSeparator: '至',
|
||||
startPlaceholder: '开始时间',
|
||||
endPlaceholder: '结束时间',
|
||||
valueFormat: 'YYYY-MM-DDTHH:mm:ssZ',
|
||||
clearable: true
|
||||
}
|
||||
}
|
||||
])
|
||||
|
||||
const columnOptions = [
|
||||
{ label: '资产类型', prop: 'asset_type' },
|
||||
{ label: '资产标识', prop: 'identifier' },
|
||||
{ label: '店铺', prop: 'shop_name' },
|
||||
{ label: '当前套餐', prop: 'package_name' },
|
||||
{ label: '预计最终到期', prop: 'estimated_final_expires_at' },
|
||||
{ label: '剩余天数', prop: 'days_until_final_expiry' }
|
||||
]
|
||||
|
||||
const getExpiryClass = (level?: string | null) => {
|
||||
if (level === 'red') return 'expiry-critical'
|
||||
if (level === 'purple') return 'expiry-warning'
|
||||
if (level === 'pink') return 'expiry-notice'
|
||||
return ''
|
||||
}
|
||||
|
||||
const getExpiryTagType = (level?: string | null) => {
|
||||
if (level === 'red') return 'danger'
|
||||
if (level === 'purple') return 'warning'
|
||||
return 'info'
|
||||
}
|
||||
|
||||
const searchShops = async (query = '') => {
|
||||
shopLoading.value = true
|
||||
try {
|
||||
const response = await ShopService.getShops({
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
shop_name: query || undefined
|
||||
})
|
||||
if (response.code === 0) shopOptions.value = response.data.items || []
|
||||
} finally {
|
||||
shopLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const searchPackages = async (query = '') => {
|
||||
packageLoading.value = true
|
||||
try {
|
||||
const response = await PackageManageService.getPackages({
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
package_name: query || undefined
|
||||
})
|
||||
if (response.code === 0) packageOptions.value = response.data.items || []
|
||||
} finally {
|
||||
packageLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const { columnChecks, columns } = useCheckedColumns(() => [
|
||||
{
|
||||
prop: 'asset_type',
|
||||
label: '资产类型',
|
||||
width: 100,
|
||||
formatter: (row: ExpiringAssetItem) => (row.asset_type === 'iot_card' ? '物联网卡' : '设备')
|
||||
},
|
||||
{
|
||||
prop: 'identifier',
|
||||
label: '资产标识',
|
||||
minWidth: 180,
|
||||
showOverflowTooltip: true,
|
||||
formatter: (row: ExpiringAssetItem) =>
|
||||
h(
|
||||
ElButton,
|
||||
{
|
||||
type: 'primary',
|
||||
link: true,
|
||||
onClick: () => goToAsset(row)
|
||||
},
|
||||
() => row.identifier || '-'
|
||||
)
|
||||
},
|
||||
{
|
||||
prop: 'shop_name',
|
||||
label: '店铺',
|
||||
minWidth: 140,
|
||||
showOverflowTooltip: true,
|
||||
formatter: (row: ExpiringAssetItem) => row.shop_name || '-'
|
||||
},
|
||||
{
|
||||
prop: 'package_name',
|
||||
label: '当前套餐',
|
||||
minWidth: 160,
|
||||
showOverflowTooltip: true,
|
||||
formatter: (row: ExpiringAssetItem) => row.package_name || '-'
|
||||
},
|
||||
{
|
||||
prop: 'estimated_final_expires_at',
|
||||
label: '预计最终到期',
|
||||
width: 180,
|
||||
formatter: (row: ExpiringAssetItem) =>
|
||||
h(
|
||||
'span',
|
||||
{ class: getExpiryClass(row.expiry_level) },
|
||||
formatDateTime(row.estimated_final_expires_at) || '-'
|
||||
)
|
||||
},
|
||||
{
|
||||
prop: 'days_until_final_expiry',
|
||||
label: '剩余天数',
|
||||
width: 100,
|
||||
formatter: (row: ExpiringAssetItem) =>
|
||||
h(ElTag, { type: getExpiryTagType(row.expiry_level), size: 'small' }, () =>
|
||||
row.days_until_final_expiry == null ? '-' : `${row.days_until_final_expiry}天`
|
||||
)
|
||||
}
|
||||
])
|
||||
|
||||
const loadAssets = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const toInteger = (value: unknown) => {
|
||||
if (value === undefined || value === null || value === '') return undefined
|
||||
const numberValue = Number(value)
|
||||
return Number.isInteger(numberValue) ? numberValue : undefined
|
||||
}
|
||||
const params: ExpiringAssetQueryParams = {
|
||||
page: pagination.currentPage,
|
||||
page_size: pagination.pageSize
|
||||
}
|
||||
|
||||
if (searchForm.asset_type) params.asset_type = searchForm.asset_type
|
||||
const keyword = searchForm.keyword?.trim()
|
||||
if (keyword) params.keyword = keyword
|
||||
if (searchForm.shop_id !== undefined && searchForm.shop_id !== null) {
|
||||
params.shop_id = searchForm.shop_id
|
||||
}
|
||||
if (searchForm.package_id !== undefined && searchForm.package_id !== null) {
|
||||
params.package_id = searchForm.package_id
|
||||
}
|
||||
const daysMin = toInteger(searchForm.days_min)
|
||||
const daysMax = toInteger(searchForm.days_max)
|
||||
if (daysMin !== undefined) params.days_min = daysMin
|
||||
if (daysMax !== undefined) params.days_max = daysMax
|
||||
const [expiresFrom, expiresTo] = searchForm.expires_range || []
|
||||
if (expiresFrom) params.expires_from = expiresFrom
|
||||
if (expiresTo) params.expires_to = expiresTo
|
||||
|
||||
const response = await AssetService.getExpiringAssets(params)
|
||||
if (response.code === 0 && response.data) {
|
||||
items.value = response.data.items || []
|
||||
pagination.total = response.data.total || 0
|
||||
Object.assign(summary, response.data.summary)
|
||||
} else {
|
||||
ElMessage.error(response.msg || '获取临期资产失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取临期资产失败:', error)
|
||||
ElMessage.error('获取临期资产失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleSearch = () => {
|
||||
pagination.currentPage = 1
|
||||
void loadAssets()
|
||||
}
|
||||
|
||||
const handleReset = () => {
|
||||
Object.assign(searchForm, {
|
||||
asset_type: undefined,
|
||||
keyword: '',
|
||||
shop_id: undefined,
|
||||
package_id: undefined,
|
||||
days_min: undefined,
|
||||
days_max: undefined,
|
||||
expires_from: undefined,
|
||||
expires_to: undefined,
|
||||
expires_range: []
|
||||
})
|
||||
pagination.currentPage = 1
|
||||
void loadAssets()
|
||||
}
|
||||
|
||||
const handleRefresh = () => void loadAssets()
|
||||
const handleSizeChange = (value: number) => {
|
||||
pagination.pageSize = value
|
||||
void loadAssets()
|
||||
}
|
||||
const handleCurrentChange = (value: number) => {
|
||||
pagination.currentPage = value
|
||||
void loadAssets()
|
||||
}
|
||||
|
||||
const goToAsset = (row: ExpiringAssetItem) => {
|
||||
router.push({
|
||||
path: RoutesAlias.AssetInformation,
|
||||
query:
|
||||
row.asset_type === 'iot_card' ? { iccid: row.identifier } : { virtual_no: row.identifier }
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
const assetType = route.query.asset_type
|
||||
if (assetType === 'card' || assetType === 'iot_card' || assetType === 'device') {
|
||||
searchForm.asset_type = assetType === 'card' ? 'iot_card' : (assetType as ExpiringAssetType)
|
||||
}
|
||||
void Promise.all([loadAssets(), searchShops(), searchPackages()])
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.expiring-assets-page {
|
||||
.page-intro {
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.expiry-critical,
|
||||
.expiry-warning,
|
||||
.expiry-notice {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.expiry-critical {
|
||||
color: #f56c6c;
|
||||
}
|
||||
|
||||
.expiry-warning {
|
||||
color: #8e44ad;
|
||||
}
|
||||
|
||||
.expiry-notice {
|
||||
color: #e83e8c;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,9 @@
|
||||
<template>
|
||||
<ExportTaskList />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import ExportTaskList from '../export-task-list/index.vue'
|
||||
|
||||
defineOptions({ name: 'ExportAgentRechargeTaskList' })
|
||||
</script>
|
||||
@@ -0,0 +1,9 @@
|
||||
<template>
|
||||
<ExportTaskList />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import ExportTaskList from '../export-task-list/index.vue'
|
||||
|
||||
defineOptions({ name: 'ExportAgentWalletTransactionTaskList' })
|
||||
</script>
|
||||
@@ -0,0 +1,9 @@
|
||||
<template>
|
||||
<ExportTaskList />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import ExportTaskList from '../export-task-list/index.vue'
|
||||
|
||||
defineOptions({ name: 'ExportExchangeTaskList' })
|
||||
</script>
|
||||
@@ -0,0 +1,9 @@
|
||||
<template>
|
||||
<ExportTaskList />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import ExportTaskList from '../export-task-list/index.vue'
|
||||
|
||||
defineOptions({ name: 'ExportPackageTaskList' })
|
||||
</script>
|
||||
@@ -0,0 +1,9 @@
|
||||
<template>
|
||||
<ExportTaskList />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import ExportTaskList from '../export-task-list/index.vue'
|
||||
|
||||
defineOptions({ name: 'ExportRefundTaskList' })
|
||||
</script>
|
||||
@@ -14,31 +14,33 @@
|
||||
<ElButton v-if="canDownloadTask" type="primary" @click="downloadTask">
|
||||
下载文件
|
||||
</ElButton>
|
||||
<ElButton v-if="canCancelTask" type="danger" @click="cancelTask"> 取消任务 </ElButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="detail-loading">
|
||||
<div v-if="polling.loading && !taskDetail" class="detail-loading">
|
||||
<ElIcon class="is-loading" :size="36">
|
||||
<Loading />
|
||||
</ElIcon>
|
||||
<div>加载中...</div>
|
||||
</div>
|
||||
<DetailPage
|
||||
v-else-if="taskDetail && canViewDetail"
|
||||
v-if="taskDetail && canViewDetail"
|
||||
:sections="detailSections"
|
||||
:data="taskDetail"
|
||||
/>
|
||||
<ElEmpty v-else :description="forbidden ? '暂无权限查看该导出任务详情' : '暂无详情'" />
|
||||
<ElEmpty
|
||||
v-else
|
||||
:description="polling.forbidden ? '暂无权限查看该导出任务详情' : '暂无详情'"
|
||||
/>
|
||||
</ElCard>
|
||||
</div>
|
||||
</ArtTableFullScreen>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, h, onMounted, ref } from 'vue'
|
||||
import { computed, h, onMounted } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ElButton, ElCard, ElEmpty, ElIcon, ElMessage, ElMessageBox, ElTag } from 'element-plus'
|
||||
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'
|
||||
@@ -48,15 +50,29 @@
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
import type { ExportTaskDetail } from '@/types/api'
|
||||
import { ExportTaskStatus } from '@/types/api'
|
||||
import { useAsyncTaskPolling } from '@/composables/useAsyncTaskPolling'
|
||||
|
||||
defineOptions({ name: 'ExportTaskDetail' })
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const { hasAuth } = useAuth()
|
||||
const loading = ref(false)
|
||||
const forbidden = ref(false)
|
||||
const taskDetail = ref<ExportTaskDetail | null>(null)
|
||||
const polling = useAsyncTaskPolling<ExportTaskDetail>({
|
||||
storageKey: `export-task-detail:${String(route.query.id || '')}`,
|
||||
autoRestore: false,
|
||||
fetchTask: async (taskId) => {
|
||||
const res = await ExportTaskService.getExportTaskDetail(taskId)
|
||||
if (res.code === 403) {
|
||||
const error = new Error('您没有查看该导出任务详情的权限') as Error & { status?: number }
|
||||
error.status = 403
|
||||
throw error
|
||||
}
|
||||
if (res.code !== 0 || !res.data) throw new Error(res.msg || '获取导出任务详情失败')
|
||||
return res.data
|
||||
},
|
||||
isForbidden: (error: any) => error?.status === 403 || error?.response?.status === 403
|
||||
})
|
||||
const taskDetail = polling.task
|
||||
|
||||
const taskPermissions = computed(
|
||||
() => getExportTaskSceneConfig(taskDetail.value?.scene)?.permissions
|
||||
@@ -87,16 +103,6 @@
|
||||
return status ? statusTypeMap[status] : 'info'
|
||||
}
|
||||
|
||||
const canCancelTask = computed(
|
||||
() =>
|
||||
canViewDetail.value &&
|
||||
[ExportTaskStatus.PENDING, ExportTaskStatus.PROCESSING].includes(
|
||||
taskDetail.value?.status as ExportTaskStatus
|
||||
) &&
|
||||
!!taskPermissions.value &&
|
||||
hasAuth(taskPermissions.value.cancel)
|
||||
)
|
||||
|
||||
const detailSections = computed((): DetailSection[] => [
|
||||
{
|
||||
title: '任务基本信息',
|
||||
@@ -132,11 +138,17 @@
|
||||
prop: 'completed_at',
|
||||
formatter: (value: string) => formatDateTime(value) || '-'
|
||||
},
|
||||
{
|
||||
label: '更新时间',
|
||||
prop: 'updated_at',
|
||||
formatter: (value: string) => formatDateTime(value) || '-'
|
||||
},
|
||||
{
|
||||
label: '错误信息',
|
||||
prop: 'error_message',
|
||||
prop: 'error_summary',
|
||||
fullWidth: true,
|
||||
formatter: (value: string) => value || '-'
|
||||
formatter: (value: string, data: ExportTaskDetail) =>
|
||||
data.error_summary || data.error_message || value || '-'
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -144,6 +156,22 @@
|
||||
title: '处理进度',
|
||||
fields: [
|
||||
{ label: '进度', prop: 'progress', formatter: (value: number) => `${value ?? 0}%` },
|
||||
{
|
||||
label: '总数',
|
||||
prop: 'total_count',
|
||||
formatter: (value: number, data: ExportTaskDetail) =>
|
||||
String(value ?? data.total_rows ?? 0)
|
||||
},
|
||||
{
|
||||
label: '成功数',
|
||||
prop: 'success_count',
|
||||
formatter: (value: number) => String(value ?? 0)
|
||||
},
|
||||
{
|
||||
label: '失败数',
|
||||
prop: 'failed_count',
|
||||
formatter: (value: number) => String(value ?? 0)
|
||||
},
|
||||
{ label: '总行数', prop: 'total_rows', formatter: (value: number) => String(value ?? 0) },
|
||||
{
|
||||
label: '已处理行数',
|
||||
@@ -203,33 +231,16 @@
|
||||
|
||||
const getTaskId = () => Number(route.query.id)
|
||||
|
||||
const getTaskDetail = async () => {
|
||||
const loadTaskDetail = async () => {
|
||||
const taskId = getTaskId()
|
||||
if (!taskId) {
|
||||
ElMessage.error('缺少任务ID参数')
|
||||
goBack()
|
||||
return
|
||||
}
|
||||
|
||||
loading.value = true
|
||||
forbidden.value = false
|
||||
try {
|
||||
const res = await ExportTaskService.getExportTaskDetail(taskId)
|
||||
if (res.code === 0) {
|
||||
taskDetail.value = res.data
|
||||
if (!canViewDetail.value) {
|
||||
forbidden.value = true
|
||||
ElMessage.warning('您没有查看该导出任务详情的权限')
|
||||
}
|
||||
} else {
|
||||
ElMessage.error(res.msg || '获取导出任务详情失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取导出任务详情失败:', error)
|
||||
ElMessage.error('获取导出任务详情失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
await polling.start(taskId)
|
||||
if (polling.error.value) ElMessage.error(polling.error.value)
|
||||
if (polling.forbidden.value) ElMessage.warning('您没有查看该导出任务详情的权限')
|
||||
}
|
||||
|
||||
const downloadTask = () => {
|
||||
@@ -246,35 +257,8 @@
|
||||
window.open(taskDetail.value.download_url, '_blank')
|
||||
}
|
||||
|
||||
const cancelTask = () => {
|
||||
if (!taskDetail.value) return
|
||||
if (!canCancelTask.value) {
|
||||
ElMessage.warning('您没有取消该导出任务的权限')
|
||||
return
|
||||
}
|
||||
|
||||
ElMessageBox.confirm(`确定取消导出任务 ${taskDetail.value.task_no} 吗?`, '取消确认', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
try {
|
||||
const res = await ExportTaskService.cancelExportTask(taskDetail.value!.id)
|
||||
if (res.code === 0) {
|
||||
ElMessage.success(res.data?.message || '任务取消成功')
|
||||
getTaskDetail()
|
||||
} else {
|
||||
ElMessage.error(res.msg || '取消导出任务失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('取消导出任务失败:', error)
|
||||
ElMessage.error('取消导出任务失败')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getTaskDetail()
|
||||
loadTaskDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
:total="pagination.total"
|
||||
:marginTop="10"
|
||||
:actions="getActions"
|
||||
:actionsWidth="180"
|
||||
:actionsWidth="120"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
>
|
||||
@@ -41,7 +41,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, h, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ElMessage, ElMessageBox, ElProgress, ElTag } from 'element-plus'
|
||||
import { ElMessage, ElProgress, ElTag } from 'element-plus'
|
||||
import { ExportTaskService } from '@/api/modules'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
import { useCheckedColumns } from '@/composables/useCheckedColumns'
|
||||
@@ -49,8 +49,9 @@
|
||||
import { RoutesAlias } from '@/router/routesAlias'
|
||||
import { getExportTaskSceneConfig } from '@/config/constants'
|
||||
import type { SearchFormItem } from '@/types'
|
||||
import type { ExportTaskItem, ExportTaskScene } from '@/types/api'
|
||||
import type { ExportTaskDetail, ExportTaskItem, ExportTaskScene } from '@/types/api'
|
||||
import { ExportTaskStatus } from '@/types/api'
|
||||
import { useAsyncTaskPolling } from '@/composables/useAsyncTaskPolling'
|
||||
|
||||
defineOptions({ name: 'ExportTaskList' })
|
||||
|
||||
@@ -99,15 +100,15 @@
|
||||
options: () => statusOptions
|
||||
},
|
||||
{
|
||||
label: '创建时间',
|
||||
label: '起止时间',
|
||||
prop: 'dateRange',
|
||||
type: 'date',
|
||||
type: 'datetimerange',
|
||||
config: {
|
||||
type: 'daterange',
|
||||
type: 'datetimerange',
|
||||
rangeSeparator: '至',
|
||||
startPlaceholder: '开始时间',
|
||||
endPlaceholder: '结束时间',
|
||||
valueFormat: 'YYYY-MM-DD'
|
||||
valueFormat: 'YYYY-MM-DDTHH:mm:ssZ'
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -116,11 +117,15 @@
|
||||
{ label: '任务编号', prop: 'task_no' },
|
||||
{ label: '状态', prop: 'status_name' },
|
||||
{ label: '进度', prop: 'progress' },
|
||||
{ label: '总数', prop: 'total_count' },
|
||||
{ label: '成功数', prop: 'success_count' },
|
||||
{ label: '失败数', prop: 'failed_count' },
|
||||
{ label: '格式', prop: 'format' },
|
||||
{ label: '总行数', prop: 'total_rows' },
|
||||
{ label: '已处理行数', prop: 'processed_rows' },
|
||||
{ label: '分片', prop: 'total_shards' },
|
||||
{ label: '错误信息', prop: 'error_message' },
|
||||
{ label: '错误信息', prop: 'error_summary' },
|
||||
{ label: '更新时间', prop: 'updated_at' },
|
||||
{ label: '创建时间', prop: 'created_at' }
|
||||
]
|
||||
|
||||
@@ -153,6 +158,24 @@
|
||||
width: 150,
|
||||
formatter: (row: ExportTaskItem) => h(ElProgress, { percentage: row.progress || 0 })
|
||||
},
|
||||
{
|
||||
prop: 'total_count',
|
||||
label: '总数',
|
||||
width: 100,
|
||||
formatter: (row: ExportTaskItem) => row.total_count ?? row.total_rows ?? 0
|
||||
},
|
||||
{
|
||||
prop: 'success_count',
|
||||
label: '成功数',
|
||||
width: 100,
|
||||
formatter: (row: ExportTaskItem) => row.success_count ?? 0
|
||||
},
|
||||
{
|
||||
prop: 'failed_count',
|
||||
label: '失败数',
|
||||
width: 100,
|
||||
formatter: (row: ExportTaskItem) => row.failed_count ?? 0
|
||||
},
|
||||
{ prop: 'format', label: '格式', width: 90 },
|
||||
{ prop: 'total_rows', label: '总行数', width: 110 },
|
||||
{ prop: 'processed_rows', label: '已处理行数', width: 120 },
|
||||
@@ -162,12 +185,24 @@
|
||||
width: 130,
|
||||
formatter: (row: ExportTaskItem) => `${row.success_shards || 0}/${row.total_shards || 0}`
|
||||
},
|
||||
{ prop: 'error_message', label: '错误信息', minWidth: 180, showOverflowTooltip: true },
|
||||
{
|
||||
prop: 'error_summary',
|
||||
label: '错误信息',
|
||||
minWidth: 180,
|
||||
showOverflowTooltip: true,
|
||||
formatter: (row: ExportTaskItem) => row.error_summary || row.error_message || '-'
|
||||
},
|
||||
{
|
||||
prop: 'created_at',
|
||||
label: '创建时间',
|
||||
width: 180,
|
||||
formatter: (row: ExportTaskItem) => formatDateTime(row.created_at) || '-'
|
||||
},
|
||||
{
|
||||
prop: 'updated_at',
|
||||
label: '更新时间',
|
||||
width: 180,
|
||||
formatter: (row: ExportTaskItem) => formatDateTime(row.updated_at) || '-'
|
||||
}
|
||||
])
|
||||
|
||||
@@ -196,6 +231,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
const toRfc3339 = (date: string, endOfDay = false) => {
|
||||
if (!date) return undefined
|
||||
if (date.includes('T')) return date
|
||||
return `${date}T${endOfDay ? '23:59:59' : '00:00:00'}+08:00`
|
||||
}
|
||||
|
||||
const getTableData = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
@@ -205,8 +246,8 @@
|
||||
page_size: pagination.pageSize,
|
||||
scene: currentScene.value,
|
||||
status: searchForm.status,
|
||||
start_time: searchForm.start_time || undefined,
|
||||
end_time: searchForm.end_time || undefined
|
||||
start_time: toRfc3339(searchForm.start_time),
|
||||
end_time: toRfc3339(searchForm.end_time, true)
|
||||
})
|
||||
|
||||
if (res.code === 0 && res.data) {
|
||||
@@ -257,6 +298,25 @@
|
||||
return res.data
|
||||
}
|
||||
|
||||
const activeTaskPolling = useAsyncTaskPolling<ExportTaskDetail>({
|
||||
storageKey: computed(() => `export-task-active:${currentScene.value}`).value,
|
||||
fetchTask: async (taskId) => {
|
||||
const res = await ExportTaskService.getExportTaskDetail(taskId)
|
||||
if (res.code === 403) {
|
||||
const error = new Error('暂无权限查看导出任务') as Error & { status?: number }
|
||||
error.status = 403
|
||||
throw error
|
||||
}
|
||||
if (res.code !== 0 || !res.data) throw new Error(res.msg || '获取导出任务详情失败')
|
||||
return res.data
|
||||
},
|
||||
isForbidden: (error: any) => error?.status === 403 || error?.response?.status === 403
|
||||
})
|
||||
|
||||
watch(activeTaskPolling.task, () => {
|
||||
if (activeTaskPolling.task.value) getTableData()
|
||||
})
|
||||
|
||||
const getRowPermissions = (row: ExportTaskItem) => {
|
||||
return getExportTaskSceneConfig(row.scene)?.permissions || currentPermissions.value
|
||||
}
|
||||
@@ -269,7 +329,7 @@
|
||||
|
||||
router.push({
|
||||
path: RoutesAlias.ExportTaskDetail,
|
||||
query: { id: row.id }
|
||||
query: { id: row.task_id ?? row.id }
|
||||
})
|
||||
}
|
||||
|
||||
@@ -280,7 +340,7 @@
|
||||
}
|
||||
|
||||
try {
|
||||
const detail = await getTaskDetail(row.id)
|
||||
const detail = await getTaskDetail(row.task_id ?? row.id)
|
||||
if (!detail.download_url) {
|
||||
ElMessage.warning('当前任务暂无可用下载地址')
|
||||
return
|
||||
@@ -293,32 +353,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
const cancelTask = (row: ExportTaskItem) => {
|
||||
if (!hasAuth(getRowPermissions(row).cancel)) {
|
||||
ElMessage.warning('您没有取消导出任务的权限')
|
||||
return
|
||||
}
|
||||
|
||||
ElMessageBox.confirm(`确定取消导出任务 ${row.task_no} 吗?`, '取消确认', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
try {
|
||||
const res = await ExportTaskService.cancelExportTask(row.id)
|
||||
if (res.code === 0) {
|
||||
ElMessage.success(res.data?.message || '任务取消成功')
|
||||
getTableData()
|
||||
} else {
|
||||
ElMessage.error(res.msg || '取消导出任务失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('取消导出任务失败:', error)
|
||||
ElMessage.error('取消导出任务失败')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const getActions = (row: ExportTaskItem) => {
|
||||
const actions: any[] = []
|
||||
const permissions = getRowPermissions(row)
|
||||
@@ -327,13 +361,6 @@
|
||||
actions.push({ label: '下载', handler: () => downloadTask(row), type: 'primary' })
|
||||
}
|
||||
|
||||
if (
|
||||
[ExportTaskStatus.PENDING, ExportTaskStatus.PROCESSING].includes(row.status) &&
|
||||
hasAuth(permissions.cancel)
|
||||
) {
|
||||
actions.push({ label: '取消', handler: () => cancelTask(row), type: 'danger' })
|
||||
}
|
||||
|
||||
return actions
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,14 @@
|
||||
>
|
||||
批量设置套餐系列
|
||||
</ElButton>
|
||||
<ElButton
|
||||
type="primary"
|
||||
:disabled="selectedCards.length === 0"
|
||||
@click="showBatchRealnamePolicyDialog"
|
||||
v-permission="'iot_card:realname_policy'"
|
||||
>
|
||||
批量修改实名顺序
|
||||
</ElButton>
|
||||
<ElButton
|
||||
type="primary"
|
||||
:disabled="selectedCards.length === 0"
|
||||
@@ -90,16 +98,16 @@
|
||||
<ElDialog
|
||||
v-model="allocateDialogVisible"
|
||||
title="批量分配"
|
||||
width="600px"
|
||||
width="40%"
|
||||
@close="handleAllocateDialogClose"
|
||||
>
|
||||
<ElForm
|
||||
ref="allocateFormRef"
|
||||
:model="allocateForm"
|
||||
:rules="allocateRules"
|
||||
label-width="120px"
|
||||
label-width="100px"
|
||||
>
|
||||
<ElFormItem label="店铺" prop="to_shop_id">
|
||||
<ElFormItem label="目标店铺" prop="to_shop_id">
|
||||
<ElCascader
|
||||
v-model="allocateForm.to_shop_id"
|
||||
:options="shopCascadeOptions"
|
||||
@@ -233,10 +241,10 @@
|
||||
<ElDialog
|
||||
v-model="recallDialogVisible"
|
||||
title="批量回收"
|
||||
width="600px"
|
||||
width="40%"
|
||||
@close="handleRecallDialogClose"
|
||||
>
|
||||
<ElForm ref="recallFormRef" :model="recallForm" :rules="recallRules" label-width="120px">
|
||||
<ElForm ref="recallFormRef" :model="recallForm" :rules="recallRules" label-width="100px">
|
||||
<ElFormItem label="选卡方式" prop="selection_type">
|
||||
<ElRadioGroup v-model="recallForm.selection_type">
|
||||
<ElRadio label="list">ICCID列表</ElRadio>
|
||||
@@ -377,14 +385,14 @@
|
||||
<ElDialog
|
||||
v-model="enterpriseCardAuthorizeDialogVisible"
|
||||
title="授权卡给企业"
|
||||
width="640px"
|
||||
width="40%"
|
||||
@close="handleEnterpriseCardAuthorizeDialogClose"
|
||||
>
|
||||
<ElForm
|
||||
ref="enterpriseCardAuthorizeFormRef"
|
||||
:model="enterpriseCardAuthorizeForm"
|
||||
:rules="enterpriseCardAuthorizeRules"
|
||||
label-width="120px"
|
||||
label-width="100px"
|
||||
>
|
||||
<ElFormItem label="授权企业" prop="enterprise_id">
|
||||
<ElSelect
|
||||
@@ -530,14 +538,14 @@
|
||||
<ElDialog
|
||||
v-model="enterpriseCardRecallDialogVisible"
|
||||
title="回收卡授权"
|
||||
width="640px"
|
||||
width="40%"
|
||||
@close="handleEnterpriseCardRecallDialogClose"
|
||||
>
|
||||
<ElForm
|
||||
ref="enterpriseCardRecallFormRef"
|
||||
:model="enterpriseCardRecallForm"
|
||||
:rules="enterpriseCardRecallRules"
|
||||
label-width="120px"
|
||||
label-width="100px"
|
||||
>
|
||||
<ElFormItem label="授权企业" prop="enterprise_id">
|
||||
<ElSelect
|
||||
@@ -976,6 +984,14 @@
|
||||
:current-policy="currentRealnamePolicy"
|
||||
@confirm="handleConfirmRealnamePolicy"
|
||||
/>
|
||||
<BatchRealnamePolicyDialog
|
||||
v-model="batchRealnamePolicyDialogVisible"
|
||||
:selected-count="selectedCards.length"
|
||||
asset-unit="张卡"
|
||||
:loading="batchRealnamePolicyLoading"
|
||||
:error-message="batchRealnamePolicyError"
|
||||
@confirm="handleConfirmBatchRealnamePolicy"
|
||||
/>
|
||||
|
||||
<!-- 更新实名状态对话框 -->
|
||||
<UpdateRealnameStatusDialog
|
||||
@@ -985,13 +1001,6 @@
|
||||
@success="handleUpdateRealnameStatusSuccess"
|
||||
/>
|
||||
|
||||
<!-- 操作审计日志弹窗 -->
|
||||
<OperationLogsDialog
|
||||
v-model="operationLogsDialogVisible"
|
||||
:identifier="operationLogsIdentifier"
|
||||
download-permission="iot_card:download_log_file"
|
||||
/>
|
||||
|
||||
<ExportTaskCreateDialog
|
||||
v-model="exportDialogVisible"
|
||||
scene="iot_card"
|
||||
@@ -1008,6 +1017,9 @@
|
||||
import { computed, h } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { RoutesAlias } from '@/router/routesAlias'
|
||||
import { AUDIT_PERMISSIONS } from '@/config/constants/audit'
|
||||
import { resolveAuditResourceTarget } from '@/utils/business/auditNavigation'
|
||||
import { openAuditInvestigation } from '@/components/business/audit/investigationController'
|
||||
import {
|
||||
CardService,
|
||||
ShopService,
|
||||
@@ -1019,6 +1031,7 @@
|
||||
import { ElMessage, ElTag, ElIcon, ElMessageBox } from 'element-plus'
|
||||
import { Loading } from '@element-plus/icons-vue'
|
||||
import RealnamePolicyDialog from '@/components/device/RealnamePolicyDialog.vue'
|
||||
import BatchRealnamePolicyDialog from '@/components/business/BatchRealnamePolicyDialog.vue'
|
||||
import UpdateRealnameStatusDialog from '@/components/business/UpdateRealnameStatusDialog.vue'
|
||||
import ExportTaskCreateDialog from '@/components/business/ExportTaskCreateDialog.vue'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
@@ -1028,6 +1041,11 @@
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
import {
|
||||
getExpiryEstimateText,
|
||||
getExpiryEstimateTooltip,
|
||||
getExpiryEstimateClass
|
||||
} from '@/utils/business/expiryEstimate'
|
||||
import { formatRemainingTime, FrontendRateLimitError } from '@/utils/business/apiRateLimit'
|
||||
import type {
|
||||
StandaloneIotCard,
|
||||
@@ -1039,10 +1057,9 @@
|
||||
BatchSetCardSeriesBindingResponse
|
||||
} from '@/types/api/card'
|
||||
import { CardSelectionType } from '@/types/api/card'
|
||||
import type { PackageSeriesResponse } from '@/types/api'
|
||||
import type { AssetRealnamePolicy, PackageSeriesResponse } from '@/types/api'
|
||||
import type { EnterpriseItem } from '@/types/api/enterprise'
|
||||
import type { AllocateCardsResponse, RecallCardsResponse } from '@/types/api/enterpriseCard'
|
||||
import OperationLogsDialog from '@/components/business/OperationLogsDialog.vue'
|
||||
|
||||
defineOptions({ name: 'StandaloneCardList' })
|
||||
|
||||
@@ -1062,6 +1079,9 @@
|
||||
const allocateFormRef = ref<FormInstance>()
|
||||
const recallFormRef = ref<FormInstance>()
|
||||
const selectedCards = ref<StandaloneIotCard[]>([])
|
||||
const batchRealnamePolicyDialogVisible = ref(false)
|
||||
const batchRealnamePolicyLoading = ref(false)
|
||||
const batchRealnamePolicyError = ref('')
|
||||
const allocationResult = ref<AllocateStandaloneCardsResponse>({
|
||||
allocation_no: '',
|
||||
total_count: 0,
|
||||
@@ -1091,9 +1111,6 @@
|
||||
recalled_devices: null
|
||||
})
|
||||
|
||||
// 操作审计日志弹窗
|
||||
const operationLogsDialogVisible = ref(false)
|
||||
const operationLogsIdentifier = ref('')
|
||||
const exportDialogVisible = ref(false)
|
||||
|
||||
// 套餐系列绑定相关
|
||||
@@ -1536,6 +1553,7 @@
|
||||
const initialSearchState: {
|
||||
status: undefined | number
|
||||
network_status: undefined | number
|
||||
real_name_status: undefined | 0 | 1
|
||||
iccid: string
|
||||
carrier_name: string
|
||||
msisdn: string
|
||||
@@ -1552,6 +1570,7 @@
|
||||
} = {
|
||||
status: undefined,
|
||||
network_status: undefined,
|
||||
real_name_status: undefined,
|
||||
iccid: '',
|
||||
carrier_name: '',
|
||||
msisdn: '',
|
||||
@@ -1723,6 +1742,19 @@
|
||||
{ label: '正常', value: 1 }
|
||||
]
|
||||
},
|
||||
{
|
||||
label: '实名状态',
|
||||
prop: 'real_name_status',
|
||||
type: 'select',
|
||||
config: {
|
||||
clearable: true,
|
||||
placeholder: '全部'
|
||||
},
|
||||
options: () => [
|
||||
{ label: '已实名', value: 1 },
|
||||
{ label: '未实名', value: 0 }
|
||||
]
|
||||
},
|
||||
{
|
||||
label: '卡虚拟号',
|
||||
prop: 'virtual_no',
|
||||
@@ -1911,6 +1943,7 @@
|
||||
{ label: '绑定设备虚拟号', prop: 'device_virtual_no' },
|
||||
{ label: '店铺名称', prop: 'shop_name' },
|
||||
{ label: '套餐系列', prop: 'series_name' },
|
||||
{ label: '预计套餐到期时间', prop: 'estimated_final_expires_at' },
|
||||
{ label: '自然月累计流量(MB)', prop: 'current_month_usage_mb' },
|
||||
{ label: '本月开始日期', prop: 'current_month_start_date' },
|
||||
{ label: '上月流量总量(MB)', prop: 'last_month_total_mb' },
|
||||
@@ -2082,6 +2115,20 @@
|
||||
showOverflowTooltip: true,
|
||||
formatter: (row: StandaloneIotCard) => row.series_name || '-'
|
||||
},
|
||||
{
|
||||
prop: 'estimated_final_expires_at',
|
||||
label: '预计套餐到期时间',
|
||||
width: 180,
|
||||
formatter: (row: StandaloneIotCard) =>
|
||||
h(
|
||||
'span',
|
||||
{
|
||||
class: getExpiryEstimateClass(row),
|
||||
title: getExpiryEstimateTooltip(row)
|
||||
},
|
||||
getExpiryEstimateText(row)
|
||||
)
|
||||
},
|
||||
{
|
||||
prop: 'status',
|
||||
label: '状态',
|
||||
@@ -2136,11 +2183,7 @@
|
||||
prop: 'real_name_status',
|
||||
label: '实名状态',
|
||||
width: 100,
|
||||
formatter: (row: StandaloneIotCard) => {
|
||||
const type = row.real_name_status === 1 ? 'success' : 'warning'
|
||||
const text = row.real_name_status === 1 ? '已实名' : '未实名'
|
||||
return h(ElTag, { type }, () => text)
|
||||
}
|
||||
formatter: (row: StandaloneIotCard) => row.real_name_status_name || '-'
|
||||
},
|
||||
{
|
||||
prop: 'realname_policy',
|
||||
@@ -2269,17 +2312,27 @@
|
||||
})
|
||||
}
|
||||
|
||||
if (hasAuth('iot_card:operation_logs')) {
|
||||
actions.push({
|
||||
label: '操作审计日志',
|
||||
handler: () => {
|
||||
operationLogsIdentifier.value = row.iccid
|
||||
operationLogsDialogVisible.value = true
|
||||
},
|
||||
type: 'primary'
|
||||
const userType = Number(userStore.getUserInfo.user_type)
|
||||
const auditPermission =
|
||||
userType === 3
|
||||
? AUDIT_PERMISSIONS.agentCardActivity
|
||||
: userType === 4
|
||||
? AUDIT_PERMISSIONS.enterpriseCardActivity
|
||||
: AUDIT_PERMISSIONS.cardEntry
|
||||
if (hasAuth(auditPermission)) {
|
||||
const auditTarget = resolveAuditResourceTarget({
|
||||
userType,
|
||||
resourceType: 'iot_card',
|
||||
internalId: row.id,
|
||||
businessIdentifier: row.iccid
|
||||
})
|
||||
if (auditTarget)
|
||||
actions.push({
|
||||
label: userType >= 3 ? '活动记录' : '审计记录',
|
||||
handler: () => openAuditInvestigation(auditTarget),
|
||||
type: 'primary'
|
||||
})
|
||||
}
|
||||
|
||||
return actions
|
||||
}
|
||||
|
||||
@@ -2364,6 +2417,51 @@
|
||||
selectedCards.value = selection
|
||||
}
|
||||
|
||||
const showBatchRealnamePolicyDialog = () => {
|
||||
if (selectedCards.value.length === 0) {
|
||||
ElMessage.warning('请先选择要修改的卡')
|
||||
return
|
||||
}
|
||||
|
||||
batchRealnamePolicyError.value = ''
|
||||
batchRealnamePolicyDialogVisible.value = true
|
||||
}
|
||||
|
||||
const handleConfirmBatchRealnamePolicy = async (realnamePolicy: AssetRealnamePolicy) => {
|
||||
const assetIds = selectedCards.value.map((card) => card.id)
|
||||
if (assetIds.length === 0) {
|
||||
batchRealnamePolicyError.value = '请先选择要修改的卡'
|
||||
return
|
||||
}
|
||||
if (assetIds.length > 500) {
|
||||
batchRealnamePolicyError.value = '单次最多可修改500张卡'
|
||||
return
|
||||
}
|
||||
|
||||
batchRealnamePolicyError.value = ''
|
||||
batchRealnamePolicyLoading.value = true
|
||||
try {
|
||||
const res = await CardService.batchUpdateRealnamePolicy(
|
||||
{ asset_ids: assetIds, realname_policy: realnamePolicy },
|
||||
{ requestOptions: { errorMessageMode: 'none' } }
|
||||
)
|
||||
if (res.code !== 0) {
|
||||
batchRealnamePolicyError.value = res.msg || '批量修改实名顺序失败'
|
||||
return
|
||||
}
|
||||
|
||||
const successCount = res.data?.success_count ?? assetIds.length
|
||||
ElMessage.success(`批量修改实名顺序成功:${successCount}/${assetIds.length}`)
|
||||
batchRealnamePolicyDialogVisible.value = false
|
||||
selectedCards.value = []
|
||||
await getTableData()
|
||||
} catch (error: any) {
|
||||
batchRealnamePolicyError.value = error?.response?.data?.msg || '批量修改实名顺序失败'
|
||||
} finally {
|
||||
batchRealnamePolicyLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 显示批量分配对话框
|
||||
const showAllocateDialog = () => {
|
||||
if (selectedCards.value.length === 0) {
|
||||
@@ -2952,4 +3050,22 @@
|
||||
:deep(.el-table__row.table-row-with-context-menu) {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.expiry-estimate--critical,
|
||||
.expiry-estimate--warning,
|
||||
.expiry-estimate--notice {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.expiry-estimate--critical {
|
||||
color: var(--el-color-danger);
|
||||
}
|
||||
|
||||
.expiry-estimate--warning {
|
||||
color: #8e44ad;
|
||||
}
|
||||
|
||||
.expiry-estimate--notice {
|
||||
color: #e83e8c;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
:pageSize="pagination.pageSize"
|
||||
:total="pagination.total"
|
||||
:marginTop="10"
|
||||
:actions="getActions"
|
||||
:actionsWidth="180"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
>
|
||||
@@ -51,10 +53,15 @@
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
import type { AssetAllocationRecord, AllocationTypeEnum, AssetTypeEnum } from '@/types/api/card'
|
||||
import { RoutesAlias } from '@/router/routesAlias'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { AUDIT_PERMISSIONS } from '@/config/constants/audit'
|
||||
import { resolveAuditResourceTarget } from '@/utils/business/auditNavigation'
|
||||
import { openAuditInvestigation } from '@/components/business/audit/investigationController'
|
||||
|
||||
defineOptions({ name: 'AssetAllocationRecords' })
|
||||
|
||||
const { hasAuth } = useAuth()
|
||||
const userStore = useUserStore()
|
||||
const router = useRouter()
|
||||
|
||||
const loading = ref(false)
|
||||
@@ -165,16 +172,16 @@
|
||||
}))
|
||||
},
|
||||
{
|
||||
label: '创建时间',
|
||||
label: '起止时间',
|
||||
prop: 'dateRange',
|
||||
type: 'date',
|
||||
type: 'datetimerange',
|
||||
config: {
|
||||
type: 'daterange',
|
||||
type: 'datetimerange',
|
||||
clearable: true,
|
||||
rangeSeparator: '至',
|
||||
startPlaceholder: '开始日期',
|
||||
endPlaceholder: '结束日期',
|
||||
valueFormat: 'YYYY-MM-DD'
|
||||
valueFormat: 'YYYY-MM-DDTHH:mm:ssZ'
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -221,6 +228,42 @@
|
||||
|
||||
const recordList = ref<AssetAllocationRecord[]>([])
|
||||
|
||||
const getActions = (row: AssetAllocationRecord) => {
|
||||
const actions: Array<{ label: string; handler: () => void; type: 'primary' }> = []
|
||||
const userType = Number(userStore.info.user_type)
|
||||
const entryPermission =
|
||||
userType === 3
|
||||
? AUDIT_PERMISSIONS.agentAssetAllocationActivity
|
||||
: AUDIT_PERMISSIONS.assetAllocationEntry
|
||||
if (!hasAuth(entryPermission) || ![1, 2, 3].includes(userType)) return actions
|
||||
const recordTarget = resolveAuditResourceTarget({
|
||||
userType,
|
||||
resourceType: 'asset_allocation_record',
|
||||
internalId: row.id,
|
||||
businessIdentifier: row.allocation_no
|
||||
})
|
||||
if (recordTarget)
|
||||
actions.push({
|
||||
label: userType === 3 ? '活动记录' : '分配审计',
|
||||
handler: () => openAuditInvestigation(recordTarget),
|
||||
type: 'primary'
|
||||
})
|
||||
if ([1, 2].includes(userType)) {
|
||||
const assetTarget = resolveAuditResourceTarget({
|
||||
userType,
|
||||
resourceType: row.asset_type,
|
||||
internalId: row.asset_id
|
||||
})
|
||||
if (assetTarget && hasAuth(AUDIT_PERMISSIONS.assetAllocationAssetEntry))
|
||||
actions.push({
|
||||
label: '资产审计',
|
||||
handler: () => openAuditInvestigation(assetTarget),
|
||||
type: 'primary'
|
||||
})
|
||||
}
|
||||
return actions
|
||||
}
|
||||
|
||||
// 获取分配类型标签类型
|
||||
const getAllocationTypeType = (type: AllocationTypeEnum) => {
|
||||
return type === 'allocate' ? 'success' : 'warning'
|
||||
|
||||
@@ -1,140 +0,0 @@
|
||||
<template>
|
||||
<div class="authorization-record-detail">
|
||||
<ElCard shadow="never">
|
||||
<!-- 页面头部 -->
|
||||
<div class="detail-header">
|
||||
<ElButton @click="handleBack">
|
||||
<template #icon>
|
||||
<ElIcon><ArrowLeft /></ElIcon>
|
||||
</template>
|
||||
返回
|
||||
</ElButton>
|
||||
<h2 class="detail-title">授权记录详情</h2>
|
||||
</div>
|
||||
|
||||
<!-- 详情内容 -->
|
||||
<DetailPage v-if="detailData" :sections="detailSections" :data="detailData" />
|
||||
|
||||
<!-- 加载中 -->
|
||||
<div v-if="loading" class="loading-container">
|
||||
<ElIcon class="is-loading"><Loading /></ElIcon>
|
||||
<span>加载中...</span>
|
||||
</div>
|
||||
</ElCard>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ElCard, ElButton, ElIcon, ElMessage } 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 { AuthorizationService } from '@/api/modules'
|
||||
import type { AuthorizationItem } from '@/types/api/authorization'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
|
||||
defineOptions({ name: 'AuthorizationRecordDetail' })
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
const loading = ref(false)
|
||||
const detailData = ref<AuthorizationItem | null>(null)
|
||||
|
||||
// 详情页配置
|
||||
const detailSections: DetailSection[] = [
|
||||
{
|
||||
title: '基本信息',
|
||||
fields: [
|
||||
{ label: '企业ID', prop: 'enterprise_id' },
|
||||
{ label: '企业名称', prop: 'enterprise_name' },
|
||||
{ label: '卡ID', prop: 'card_id' },
|
||||
{ label: 'ICCID', prop: 'iccid' },
|
||||
{ label: '手机号', prop: 'msisdn', formatter: (value) => value || '-' },
|
||||
{ label: '授权人ID', prop: 'authorized_by' },
|
||||
{ label: '授权人', prop: 'authorizer_name' },
|
||||
{
|
||||
label: '授权人类型',
|
||||
formatter: (_, data) => {
|
||||
return data.authorizer_type === 2 ? '平台' : '代理'
|
||||
}
|
||||
},
|
||||
{ label: '授权时间', prop: 'authorized_at', formatter: (value) => formatDateTime(value) },
|
||||
{
|
||||
label: '状态',
|
||||
formatter: (_, data) => {
|
||||
return data.status === 1 ? '有效' : '已回收'
|
||||
}
|
||||
},
|
||||
{ label: '备注', prop: 'remark', formatter: (value) => value || '-' }
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
// 返回上一页
|
||||
const handleBack = () => {
|
||||
router.back()
|
||||
}
|
||||
|
||||
// 获取详情数据
|
||||
const fetchDetail = async () => {
|
||||
const id = Number(route.params.id)
|
||||
if (!id) {
|
||||
ElMessage.error('缺少ID参数')
|
||||
return
|
||||
}
|
||||
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await AuthorizationService.getAuthorizationDetail(id)
|
||||
if (res.code === 0) {
|
||||
detailData.value = res.data
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
console.log('获取授权记录详情失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.authorization-record-detail {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.detail-header {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
align-items: center;
|
||||
padding-bottom: 16px;
|
||||
|
||||
.detail-title {
|
||||
margin: 0;
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.loading-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 60px 20px;
|
||||
color: var(--el-text-color-secondary);
|
||||
|
||||
.el-icon {
|
||||
font-size: 32px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -28,32 +28,19 @@
|
||||
:pageSize="pagination.pageSize"
|
||||
:total="pagination.total"
|
||||
:marginTop="10"
|
||||
:row-class-name="getRowClassName"
|
||||
:actions="getActions"
|
||||
:actionsWidth="100"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
@row-contextmenu="handleRowContextMenu"
|
||||
@cell-mouse-enter="handleCellMouseEnter"
|
||||
@cell-mouse-leave="handleCellMouseLeave"
|
||||
>
|
||||
<template #default>
|
||||
<ElTableColumn v-for="col in columns" :key="col.prop || col.type" v-bind="col" />
|
||||
</template>
|
||||
</ArtTable>
|
||||
|
||||
<!-- 鼠标悬浮提示 -->
|
||||
<TableContextMenuHint :visible="showContextMenuHint" :position="hintPosition" />
|
||||
|
||||
<!-- 右键菜单 -->
|
||||
<ArtMenuRight
|
||||
ref="contextMenuRef"
|
||||
:menu-items="contextMenuItems"
|
||||
:menu-width="120"
|
||||
@select="handleContextMenuSelect"
|
||||
/>
|
||||
|
||||
<!-- 修改备注对话框 -->
|
||||
<ElDialog v-model="remarkDialogVisible" title="修改备注" width="500px">
|
||||
<ElForm ref="remarkFormRef" :model="remarkForm" :rules="remarkRules" label-width="80px">
|
||||
<ElDialog v-model="remarkDialogVisible" title="修改备注" width="40%">
|
||||
<ElForm ref="remarkFormRef" :model="remarkForm" :rules="remarkRules">
|
||||
<ElFormItem label="备注" prop="remark">
|
||||
<ElInput
|
||||
v-model="remarkForm.remark"
|
||||
@@ -81,40 +68,22 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { h } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { AuthorizationService, EnterpriseService } from '@/api/modules'
|
||||
import { ElMessage, ElTag } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import type { SearchFormItem } from '@/types'
|
||||
import { useCheckedColumns } from '@/composables/useCheckedColumns'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
import { useTableContextMenu } from '@/composables/useTableContextMenu'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
import ArtButtonTable from '@/components/core/forms/ArtButtonTable.vue'
|
||||
import ArtMenuRight from '@/components/core/others/ArtMenuRight.vue'
|
||||
import TableContextMenuHint from '@/components/core/others/TableContextMenuHint.vue'
|
||||
import type { MenuItemType } from '@/components/core/others/ArtMenuRight.vue'
|
||||
import type {
|
||||
AuthorizationItem,
|
||||
AuthorizationStatus,
|
||||
AuthorizerType
|
||||
} from '@/types/api/authorization'
|
||||
import { CommonStatus } from '@/config/constants'
|
||||
import { RoutesAlias } from '@/router/routesAlias'
|
||||
|
||||
defineOptions({ name: 'AuthorizationRecords' })
|
||||
|
||||
const { hasAuth } = useAuth()
|
||||
const router = useRouter()
|
||||
|
||||
// 使用表格右键菜单功能
|
||||
const {
|
||||
showContextMenuHint,
|
||||
hintPosition,
|
||||
getRowClassName,
|
||||
handleCellMouseEnter,
|
||||
handleCellMouseLeave
|
||||
} = useTableContextMenu()
|
||||
|
||||
const loading = ref(false)
|
||||
const remarkDialogVisible = ref(false)
|
||||
@@ -122,8 +91,6 @@
|
||||
const tableRef = ref()
|
||||
const remarkFormRef = ref<FormInstance>()
|
||||
const currentRecordId = ref<number>(0)
|
||||
const contextMenuRef = ref<InstanceType<typeof ArtMenuRight>>()
|
||||
const currentRow = ref<AuthorizationItem | null>(null)
|
||||
|
||||
// 企业搜索选项
|
||||
const enterpriseOptions = ref<any[]>([])
|
||||
@@ -233,12 +200,12 @@
|
||||
{
|
||||
label: '授权时间',
|
||||
prop: 'dateRange',
|
||||
type: 'daterange',
|
||||
type: 'datetimerange',
|
||||
config: {
|
||||
type: 'daterange',
|
||||
type: 'datetimerange',
|
||||
startPlaceholder: '开始日期',
|
||||
endPlaceholder: '结束日期',
|
||||
valueFormat: 'YYYY-MM-DD'
|
||||
valueFormat: 'YYYY-MM-DDTHH:mm:ssZ'
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -252,7 +219,8 @@
|
||||
{ label: '授权人类型', prop: 'authorizer_type' },
|
||||
{ label: '授权时间', prop: 'authorized_at' },
|
||||
{ label: '状态', prop: 'status' },
|
||||
{ label: '备注', prop: 'remark' }
|
||||
{ label: '备注', prop: 'remark' },
|
||||
{ label: '操作', prop: 'operation' }
|
||||
]
|
||||
|
||||
const authorizationList = ref<AuthorizationItem[]>([])
|
||||
@@ -284,17 +252,7 @@
|
||||
label: 'ICCID',
|
||||
width: 200,
|
||||
formatter: (row: AuthorizationItem) => {
|
||||
return h(
|
||||
'span',
|
||||
{
|
||||
style: 'color: var(--el-color-primary); cursor: pointer; text-decoration: underline;',
|
||||
onClick: (e: MouseEvent) => {
|
||||
e.stopPropagation()
|
||||
handleNameClick(row)
|
||||
}
|
||||
},
|
||||
row.iccid
|
||||
)
|
||||
return row.iccid || '-'
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -306,7 +264,8 @@
|
||||
{
|
||||
prop: 'enterprise_name',
|
||||
label: '企业名称',
|
||||
minWidth: 150
|
||||
minWidth: 200,
|
||||
showOverflowTooltip: true
|
||||
},
|
||||
{
|
||||
prop: 'authorizer_name',
|
||||
@@ -346,6 +305,21 @@
|
||||
}
|
||||
])
|
||||
|
||||
// 操作列配置,样式与店铺列表保持一致
|
||||
const getActions = (row: AuthorizationItem) => {
|
||||
const actions: any[] = []
|
||||
|
||||
if (hasAuth('authorization_records:update_remark')) {
|
||||
actions.push({
|
||||
label: '修改备注',
|
||||
handler: () => showRemarkDialog(row),
|
||||
type: 'primary'
|
||||
})
|
||||
}
|
||||
|
||||
return actions
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getTableData()
|
||||
searchEnterprises('')
|
||||
@@ -417,22 +391,6 @@
|
||||
getTableData()
|
||||
}
|
||||
|
||||
// 查看详情
|
||||
const viewDetail = (row: AuthorizationItem) => {
|
||||
router.push({
|
||||
path: `${RoutesAlias.AuthorizationRecords}/detail/${row.id}`
|
||||
})
|
||||
}
|
||||
|
||||
// 处理名称点击
|
||||
const handleNameClick = (row: AuthorizationItem) => {
|
||||
if (hasAuth('authorization_records:view_detail')) {
|
||||
viewDetail(row)
|
||||
} else {
|
||||
ElMessage.warning('您没有查看详情的权限')
|
||||
}
|
||||
}
|
||||
|
||||
// 显示修改备注对话框
|
||||
const showRemarkDialog = (row: AuthorizationItem) => {
|
||||
currentRecordId.value = row.id
|
||||
@@ -462,44 +420,10 @@
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 右键菜单项配置
|
||||
const contextMenuItems = computed((): MenuItemType[] => {
|
||||
const items: MenuItemType[] = []
|
||||
|
||||
if (hasAuth('authorization_records:update_remark')) {
|
||||
items.push({ key: 'edit', label: '编辑' })
|
||||
}
|
||||
|
||||
return items
|
||||
})
|
||||
|
||||
// 处理表格行右键菜单
|
||||
const handleRowContextMenu = (row: AuthorizationItem, column: any, event: MouseEvent) => {
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
currentRow.value = row
|
||||
contextMenuRef.value?.show(event)
|
||||
}
|
||||
|
||||
// 处理右键菜单选择
|
||||
const handleContextMenuSelect = (item: MenuItemType) => {
|
||||
if (!currentRow.value) return
|
||||
|
||||
switch (item.key) {
|
||||
case 'edit':
|
||||
showRemarkDialog(currentRow.value)
|
||||
break
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.authorization-records-page {
|
||||
// Authorization records page styles
|
||||
}
|
||||
|
||||
:deep(.el-table__row.table-row-with-context-menu) {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,334 @@
|
||||
<template>
|
||||
<ArtTableFullScreen>
|
||||
<div class="bulk-purchase-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>
|
||||
<ElTag v-if="taskDetail" :type="getStatusType(taskDetail.status)">
|
||||
{{ taskDetail.status_name || getStatusName(taskDetail.status) }}
|
||||
</ElTag>
|
||||
</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">
|
||||
<ElDescriptions :column="4" border>
|
||||
<ElDescriptionsItem label="任务号">{{ taskDetail.task_no || '-' }}</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="订单文件" :span="2">
|
||||
<span class="ellipsis-value" :title="taskDetail.file_name || '-'">
|
||||
{{ taskDetail.file_name || '-' }}
|
||||
</span>
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="套餐名称">
|
||||
<span class="ellipsis-value" :title="taskDetail.package_name || '-'">
|
||||
{{ taskDetail.package_name || '-' }}
|
||||
</span>
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="套餐编码">
|
||||
<span class="ellipsis-value" :title="taskDetail.package_code || '-'">
|
||||
{{ taskDetail.package_code || '-' }}
|
||||
</span>
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="支付方式">
|
||||
{{ getPaymentMethodName(taskDetail.payment_method) }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="总数">{{ taskDetail.total_count ?? 0 }}</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="成功数">{{
|
||||
taskDetail.success_count ?? 0
|
||||
}}</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="失败数">{{ taskDetail.fail_count ?? 0 }}</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="创建人">{{
|
||||
taskDetail.creator_name || '-'
|
||||
}}</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="支付凭证">
|
||||
{{
|
||||
taskDetail.voucher_keys?.length
|
||||
? `已上传 ${taskDetail.voucher_keys.length} 个`
|
||||
: '未上传'
|
||||
}}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="创建时间">{{
|
||||
formatDateTime(taskDetail.created_at)
|
||||
}}</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="开始时间">{{
|
||||
formatDateTime(taskDetail.started_at)
|
||||
}}</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="完成时间">{{
|
||||
formatDateTime(taskDetail.completed_at)
|
||||
}}</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="更新时间">{{
|
||||
formatDateTime(taskDetail.updated_at)
|
||||
}}</ElDescriptionsItem>
|
||||
<ElDescriptionsItem v-if="taskDetail.error_message" label="错误信息" :span="4">
|
||||
{{ taskDetail.error_message }}
|
||||
</ElDescriptionsItem>
|
||||
</ElDescriptions>
|
||||
|
||||
<ElAlert
|
||||
v-if="taskDetail.error_summary"
|
||||
class="task-error"
|
||||
type="error"
|
||||
:closable="false"
|
||||
:title="taskDetail.error_summary"
|
||||
/>
|
||||
|
||||
<template v-if="hasAuth(BULK_PURCHASE_PERMISSIONS.items)">
|
||||
<div class="items-toolbar">
|
||||
<ElSelect
|
||||
v-model="itemStatus"
|
||||
clearable
|
||||
placeholder="筛选行状态"
|
||||
style="width: 140px"
|
||||
>
|
||||
<ElOption label="成功" :value="BulkPurchaseTaskStatus.COMPLETED" />
|
||||
<ElOption label="失败" :value="BulkPurchaseTaskStatus.FAILED" />
|
||||
</ElSelect>
|
||||
<ElButton :loading="loading" @click="refreshTask">刷新结果</ElButton>
|
||||
</div>
|
||||
|
||||
<ElTable v-loading="loading" :data="paginatedItems" border>
|
||||
<ElTableColumn label="行号" width="90">
|
||||
<template #default="scope">{{ scope.row.line ?? '-' }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="资产" min-width="180">
|
||||
<template #default="scope">{{ getAssetIdentifier(scope.row) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="状态" width="110">
|
||||
<template #default="scope">
|
||||
<ElTag :type="getItemStatusType(scope.row.status)">
|
||||
{{ scope.row.status_name || getItemStatusName(scope.row.status) }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="order_no" label="订单号" min-width="180" show-overflow-tooltip />
|
||||
<ElTableColumn label="金额" width="120">
|
||||
<template #default="scope">{{ formatMoney(scope.row.amount) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="处理结果" min-width="240" show-overflow-tooltip>
|
||||
<template #default="scope">{{ getItemReason(scope.row) }}</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
|
||||
<div class="pagination-wrapper">
|
||||
<ElPagination
|
||||
v-model:current-page="itemsPage"
|
||||
v-model:page-size="itemsSize"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:total="filteredItems.length"
|
||||
@size-change="handleItemSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<ElEmpty v-else :description="forbidden ? '暂无查看权限' : '暂无任务详情'" />
|
||||
</ElCard>
|
||||
</div>
|
||||
</ArtTableFullScreen>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import {
|
||||
ElAlert,
|
||||
ElButton,
|
||||
ElCard,
|
||||
ElDescriptions,
|
||||
ElDescriptionsItem,
|
||||
ElEmpty,
|
||||
ElIcon,
|
||||
ElMessage,
|
||||
ElOption,
|
||||
ElPagination,
|
||||
ElSelect,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTag
|
||||
} from 'element-plus'
|
||||
import { ArrowLeft, Loading } from '@element-plus/icons-vue'
|
||||
import { BulkPurchaseService } from '@/api/modules'
|
||||
import type { BulkPurchaseItem, BulkPurchasePaymentMethod, BulkPurchaseTask } from '@/types/api'
|
||||
import { BulkPurchaseTaskStatus } from '@/types/api'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
import { useAsyncTaskPolling } from '@/composables/useAsyncTaskPolling'
|
||||
import { formatDateTime, formatMoney } from '@/utils/business/format'
|
||||
import { BULK_PURCHASE_PERMISSIONS } from '@/config/constants/bulkPurchase'
|
||||
|
||||
defineOptions({ name: 'BulkPurchaseDetail' })
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const { hasAuth } = useAuth()
|
||||
const itemStatus = ref<BulkPurchaseTaskStatus | undefined>()
|
||||
const itemsPage = ref(1)
|
||||
const itemsSize = ref(20)
|
||||
const taskId = Number(route.params.id)
|
||||
|
||||
const polling = useAsyncTaskPolling<BulkPurchaseTask>({
|
||||
storageKey: `bulk-purchase-detail:${taskId}`,
|
||||
autoRestore: false,
|
||||
fetchTask: async (id) => {
|
||||
const res = await BulkPurchaseService.getTask(id)
|
||||
if (res.code === 403) {
|
||||
const error = new Error('暂无查看该批量订购任务详情的权限') as Error & { status?: number }
|
||||
error.status = 403
|
||||
throw error
|
||||
}
|
||||
if (res.code !== 0 || !res.data) {
|
||||
throw new Error(res.msg || '获取批量订购任务详情失败')
|
||||
}
|
||||
return res.data
|
||||
},
|
||||
isForbidden: (error: any) => error?.status === 403 || error?.response?.status === 403
|
||||
})
|
||||
const taskDetail = polling.task
|
||||
const loading = polling.loading
|
||||
const forbidden = polling.forbidden
|
||||
|
||||
const loadTaskDetail = async () => {
|
||||
if (!taskId) {
|
||||
ElMessage.error('缺少任务 ID 参数')
|
||||
goBack()
|
||||
return
|
||||
}
|
||||
|
||||
await polling.start(taskId)
|
||||
if (polling.error.value) ElMessage.error(polling.error.value)
|
||||
if (polling.forbidden.value) ElMessage.warning('暂无查看该批量订购任务详情的权限')
|
||||
}
|
||||
|
||||
const goBack = () => {
|
||||
router.back()
|
||||
}
|
||||
|
||||
const refreshTask = () => {
|
||||
void polling.retry()
|
||||
}
|
||||
|
||||
const getStatusName = (status?: BulkPurchaseTaskStatus) => {
|
||||
const names: Record<BulkPurchaseTaskStatus, string> = {
|
||||
[BulkPurchaseTaskStatus.PENDING]: '待处理',
|
||||
[BulkPurchaseTaskStatus.PROCESSING]: '处理中',
|
||||
[BulkPurchaseTaskStatus.COMPLETED]: '已完成',
|
||||
[BulkPurchaseTaskStatus.FAILED]: '已失败',
|
||||
[BulkPurchaseTaskStatus.CANCELED]: '已取消'
|
||||
}
|
||||
return status ? names[status] || '-' : '-'
|
||||
}
|
||||
|
||||
const getStatusType = (status?: BulkPurchaseTaskStatus) => {
|
||||
if (status === BulkPurchaseTaskStatus.COMPLETED) return 'success'
|
||||
if (status === BulkPurchaseTaskStatus.FAILED) return 'danger'
|
||||
if (status === BulkPurchaseTaskStatus.PROCESSING) return 'warning'
|
||||
return 'info'
|
||||
}
|
||||
|
||||
const getPaymentMethodName = (method?: BulkPurchasePaymentMethod) => {
|
||||
return method === 'offline' ? '线下支付' : method === 'wallet' ? '代理钱包' : '-'
|
||||
}
|
||||
|
||||
const getAssetIdentifier = (item: BulkPurchaseItem) =>
|
||||
item.asset_identifier || item.iccid || item.virtual_no || '-'
|
||||
|
||||
const getItemStatusName = (status?: BulkPurchaseTaskStatus) => {
|
||||
if (status === BulkPurchaseTaskStatus.COMPLETED) return '成功'
|
||||
if (status === BulkPurchaseTaskStatus.FAILED) return '失败'
|
||||
return '-'
|
||||
}
|
||||
|
||||
const getItemStatusType = (status?: BulkPurchaseTaskStatus) => {
|
||||
if (status === BulkPurchaseTaskStatus.COMPLETED) return 'success'
|
||||
if (status === BulkPurchaseTaskStatus.FAILED) return 'danger'
|
||||
return 'info'
|
||||
}
|
||||
|
||||
const getItemReason = (item: BulkPurchaseItem) =>
|
||||
item.reason || item.error_summary || item.error_reason || '-'
|
||||
|
||||
const filteredItems = computed(() => {
|
||||
const items = taskDetail.value?.items || []
|
||||
if (itemStatus.value === undefined) return items
|
||||
return items.filter((item) => item.status === itemStatus.value)
|
||||
})
|
||||
|
||||
const paginatedItems = computed(() => {
|
||||
const start = (itemsPage.value - 1) * itemsSize.value
|
||||
return filteredItems.value.slice(start, start + itemsSize.value)
|
||||
})
|
||||
|
||||
const handleItemSizeChange = () => {
|
||||
itemsPage.value = 1
|
||||
}
|
||||
|
||||
watch(itemStatus, () => {
|
||||
itemsPage.value = 1
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
void loadTaskDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.bulk-purchase-detail-page {
|
||||
.detail-header {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
align-items: center;
|
||||
padding-bottom: 16px;
|
||||
|
||||
.detail-title {
|
||||
margin: 0;
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.detail-loading {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 220px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.ellipsis-value {
|
||||
display: inline-block;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
.task-error {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.items-toolbar {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
margin: 20px 0 12px;
|
||||
}
|
||||
|
||||
.pagination-wrapper {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 16px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,688 @@
|
||||
<template>
|
||||
<ArtTableFullScreen>
|
||||
<div class="bulk-purchase-page" id="table-full-screen">
|
||||
<ElDrawer
|
||||
v-model="createDrawerVisible"
|
||||
title="批量订购套餐"
|
||||
direction="rtl"
|
||||
size="40%"
|
||||
:close-on-click-modal="!createDrawerBusy"
|
||||
:close-on-press-escape="!createDrawerBusy"
|
||||
@closed="handleCreateDrawerClosed"
|
||||
>
|
||||
<ElForm ref="formRef" :model="form" :rules="rules" class="create-form">
|
||||
<ElFormItem label="套餐系列" prop="series_id">
|
||||
<ElSelect
|
||||
v-model="form.series_id"
|
||||
filterable
|
||||
remote
|
||||
clearable
|
||||
:remote-method="handleSeriesSearch"
|
||||
:loading="seriesLoading"
|
||||
placeholder="请输入系列名称搜索"
|
||||
style="width: 100%"
|
||||
@change="handleSeriesChange"
|
||||
@visible-change="handleSeriesVisibleChange"
|
||||
>
|
||||
<ElOption
|
||||
v-for="series in seriesOptions"
|
||||
:key="series.id"
|
||||
:label="series.series_name"
|
||||
:value="series.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
|
||||
<ElFormItem label="相关套餐" prop="package_id">
|
||||
<ElSelect
|
||||
v-model="form.package_id"
|
||||
filterable
|
||||
remote
|
||||
clearable
|
||||
:remote-method="handlePackageSearch"
|
||||
:loading="packageLoading"
|
||||
:disabled="!form.series_id"
|
||||
placeholder="请先选择套餐系列"
|
||||
style="width: 100%"
|
||||
@visible-change="handlePackageVisibleChange"
|
||||
>
|
||||
<ElOption
|
||||
v-for="pkg in packageOptions"
|
||||
:key="pkg.id"
|
||||
:label="pkg.package_name"
|
||||
:value="pkg.id"
|
||||
>
|
||||
<span class="package-option">{{ pkg.package_name }}</span>
|
||||
</ElOption>
|
||||
<template #empty>
|
||||
<div class="package-empty">
|
||||
{{
|
||||
packageLoading
|
||||
? '正在加载套餐...'
|
||||
: form.series_id
|
||||
? '该套餐系列下暂无可用套餐'
|
||||
: '请先选择套餐系列'
|
||||
}}
|
||||
</div>
|
||||
</template>
|
||||
</ElSelect>
|
||||
<div
|
||||
v-if="form.series_id && !packageLoading && packageOptions.length === 0"
|
||||
class="package-empty-tip"
|
||||
>
|
||||
该套餐系列下暂无可用套餐
|
||||
</div>
|
||||
</ElFormItem>
|
||||
|
||||
<ElFormItem label="支付方式" prop="payment_method">
|
||||
<ElRadioGroup v-model="form.payment_method" @change="handlePaymentMethodChange">
|
||||
<ElRadio value="wallet">代理钱包</ElRadio>
|
||||
<ElRadio value="offline">线下支付</ElRadio>
|
||||
</ElRadioGroup>
|
||||
</ElFormItem>
|
||||
|
||||
<ElFormItem label="订单文件" prop="orderFile">
|
||||
<VoucherUpload
|
||||
ref="orderUploadRef"
|
||||
v-model="orderFileKeys"
|
||||
voucher-name="订单文件"
|
||||
:max-count="1"
|
||||
purpose="batch_purchase"
|
||||
:max-size-mb="10"
|
||||
single-column-csv
|
||||
:max-csv-rows="1000"
|
||||
accept=".csv"
|
||||
tip="仅支持 UTF-8 单列 CSV,最多 1000 行,最大 10MB"
|
||||
@uploading-change="orderFileUploading = $event"
|
||||
@change="formRef?.validateField('orderFile')"
|
||||
/>
|
||||
</ElFormItem>
|
||||
|
||||
<ElFormItem
|
||||
v-if="form.payment_method === 'offline'"
|
||||
label="整批支付凭证"
|
||||
prop="voucherFile"
|
||||
>
|
||||
<VoucherUpload
|
||||
ref="voucherUploadRef"
|
||||
v-model="voucherFileKeys"
|
||||
voucher-name="整批支付凭证"
|
||||
@uploading-change="voucherUploading = $event"
|
||||
@change="formRef?.validateField('voucherFile')"
|
||||
/>
|
||||
</ElFormItem>
|
||||
|
||||
<ElAlert
|
||||
v-if="createDrawerBusy"
|
||||
type="info"
|
||||
:closable="false"
|
||||
show-icon
|
||||
:title="
|
||||
voucherUploading
|
||||
? '支付凭证上传中,请稍候'
|
||||
: orderFileUploading
|
||||
? '订单文件上传中,请稍候'
|
||||
: '批量订购文件上传及任务创建中,请勿重复提交'
|
||||
"
|
||||
/>
|
||||
</ElForm>
|
||||
|
||||
<template #footer>
|
||||
<div class="drawer-footer">
|
||||
<ElButton :disabled="createDrawerBusy" @click="createDrawerVisible = false">
|
||||
取消
|
||||
</ElButton>
|
||||
<ElButton
|
||||
type="primary"
|
||||
:loading="createDrawerBusy"
|
||||
:disabled="!hasAuth(BULK_PURCHASE_PERMISSIONS.create)"
|
||||
@click="submitTask"
|
||||
>
|
||||
创建批量订购任务
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</ElDrawer>
|
||||
|
||||
<ElCard
|
||||
v-if="hasAuth(BULK_PURCHASE_PERMISSIONS.detail)"
|
||||
shadow="never"
|
||||
class="art-table-card task-list-card"
|
||||
>
|
||||
<template #header>
|
||||
<div class="task-list-header">
|
||||
<span>批量订购任务</span>
|
||||
<div class="task-list-toolbar">
|
||||
<ElButton
|
||||
v-if="hasAuth(BULK_PURCHASE_PERMISSIONS.template)"
|
||||
@click="downloadTemplate"
|
||||
>
|
||||
下载模板
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="hasAuth(BULK_PURCHASE_PERMISSIONS.create)"
|
||||
type="primary"
|
||||
@click="openCreateDrawer"
|
||||
>
|
||||
批量订购套餐
|
||||
</ElButton>
|
||||
<ElSelect
|
||||
v-model="taskListStatus"
|
||||
clearable
|
||||
placeholder="筛选任务状态"
|
||||
style="width: 150px"
|
||||
@change="handleTaskListStatusChange"
|
||||
>
|
||||
<ElOption label="待处理" :value="BulkPurchaseTaskStatus.PENDING" />
|
||||
<ElOption label="处理中" :value="BulkPurchaseTaskStatus.PROCESSING" />
|
||||
<ElOption label="已完成" :value="BulkPurchaseTaskStatus.COMPLETED" />
|
||||
<ElOption label="已失败" :value="BulkPurchaseTaskStatus.FAILED" />
|
||||
<ElOption label="已取消" :value="BulkPurchaseTaskStatus.CANCELED" />
|
||||
</ElSelect>
|
||||
<ElButton :loading="taskListLoading" @click="loadTaskList">刷新</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<ElTable v-loading="taskListLoading" :data="taskList" border>
|
||||
<ElTableColumn label="任务号" min-width="200" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<ElButton type="primary" link @click="showTask(scope.row)">
|
||||
{{ scope.row.task_no || '-' }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="file_name" label="订单文件" min-width="180" show-overflow-tooltip />
|
||||
<ElTableColumn
|
||||
prop="package_name"
|
||||
label="套餐名称"
|
||||
min-width="180"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<ElTableColumn
|
||||
prop="package_code"
|
||||
label="套餐编码"
|
||||
min-width="180"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<ElTableColumn label="支付方式" width="110">
|
||||
<template #default="scope">{{
|
||||
getPaymentMethodName(scope.row.payment_method)
|
||||
}}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="状态" width="110">
|
||||
<template #default="scope">
|
||||
<ElTag :type="getStatusType(scope.row.status)">
|
||||
{{ scope.row.status_name || getStatusName(scope.row.status) }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="total_count" label="总数" width="90" />
|
||||
<ElTableColumn prop="success_count" label="成功数" width="90" />
|
||||
<ElTableColumn prop="fail_count" label="失败数" width="90" />
|
||||
<ElTableColumn label="创建时间" width="180">
|
||||
<template #default="scope">{{ formatDateTime(scope.row.created_at) }}</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
|
||||
<div class="pagination-wrapper">
|
||||
<ElPagination
|
||||
v-model:current-page="taskListPage"
|
||||
v-model:page-size="taskListSize"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:total="taskListTotal"
|
||||
@current-change="loadTaskList"
|
||||
@size-change="handleTaskListSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</ElCard>
|
||||
</div>
|
||||
</ArtTableFullScreen>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, onMounted, reactive, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import {
|
||||
ElAlert,
|
||||
ElButton,
|
||||
ElCard,
|
||||
ElDrawer,
|
||||
ElForm,
|
||||
ElMessage,
|
||||
ElOption,
|
||||
ElPagination,
|
||||
ElRadio,
|
||||
ElRadioGroup,
|
||||
ElSelect,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTag
|
||||
} from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import VoucherUpload from '@/components/business/VoucherUpload.vue'
|
||||
import { BulkPurchaseService, PackageManageService, PackageSeriesService } from '@/api/modules'
|
||||
import type {
|
||||
BulkPurchasePaymentMethod,
|
||||
BulkPurchaseTask,
|
||||
PackageResponse,
|
||||
PackageSeriesResponse
|
||||
} from '@/types/api'
|
||||
import { BulkPurchaseTaskStatus } from '@/types/api'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
import { BULK_PURCHASE_PERMISSIONS } from '@/config/constants/bulkPurchase'
|
||||
import { RoutesAlias } from '@/router/routesAlias'
|
||||
|
||||
defineOptions({ name: 'BulkPurchase' })
|
||||
|
||||
const router = useRouter()
|
||||
const { hasAuth } = useAuth()
|
||||
const formRef = ref<FormInstance>()
|
||||
const orderUploadRef = ref<InstanceType<typeof VoucherUpload>>()
|
||||
const voucherUploadRef = ref<InstanceType<typeof VoucherUpload>>()
|
||||
const createDrawerVisible = ref(false)
|
||||
const submitting = ref(false)
|
||||
const orderFileKeys = ref<string[]>([])
|
||||
const orderFileUploading = ref(false)
|
||||
const voucherFileKeys = ref<string[]>([])
|
||||
const voucherUploading = ref(false)
|
||||
const seriesOptions = ref<PackageSeriesResponse[]>([])
|
||||
const seriesLoading = ref(false)
|
||||
const packageOptions = ref<PackageResponse[]>([])
|
||||
const packageLoading = ref(false)
|
||||
const taskList = ref<BulkPurchaseTask[]>([])
|
||||
const taskListLoading = ref(false)
|
||||
const taskListPage = ref(1)
|
||||
const taskListSize = ref(20)
|
||||
const taskListTotal = ref(0)
|
||||
const taskListStatus = ref<BulkPurchaseTaskStatus | undefined>()
|
||||
const taskStatusPollInterval = 2000
|
||||
let taskStatusPollTimer: number | undefined
|
||||
let taskStatusPollSession = 0
|
||||
const createDrawerBusy = computed(
|
||||
() => submitting.value || voucherUploading.value || orderFileUploading.value
|
||||
)
|
||||
|
||||
const downloadTemplate = () => {
|
||||
try {
|
||||
const link = document.createElement('a')
|
||||
link.href = new URL('@/template/批量订购套餐模板.csv', import.meta.url).href
|
||||
link.download = '批量订购套餐模板.csv'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
ElMessage.success('模板下载成功')
|
||||
} catch (error) {
|
||||
console.error('下载模板失败:', error)
|
||||
ElMessage.error('模板下载失败')
|
||||
}
|
||||
}
|
||||
|
||||
const form = reactive<{
|
||||
series_id?: number
|
||||
package_id?: number
|
||||
payment_method: BulkPurchasePaymentMethod
|
||||
}>({
|
||||
series_id: undefined,
|
||||
package_id: undefined,
|
||||
payment_method: 'wallet'
|
||||
})
|
||||
|
||||
const rules = computed<FormRules>(() => ({
|
||||
series_id: [{ required: true, message: '请选择套餐系列', trigger: 'change' }],
|
||||
package_id: [{ required: true, message: '请选择套餐', trigger: 'change' }],
|
||||
payment_method: [{ required: true, message: '请选择支付方式', trigger: 'change' }],
|
||||
orderFile: [
|
||||
{
|
||||
validator: (_rule: unknown, _value: unknown, callback: (error?: Error) => void) => {
|
||||
if (orderFileKeys.value.length === 0) callback(new Error('请上传订单文件'))
|
||||
else callback()
|
||||
},
|
||||
trigger: 'change'
|
||||
}
|
||||
],
|
||||
voucherFile: [
|
||||
{
|
||||
validator: (_rule: unknown, _value: unknown, callback: (error?: Error) => void) => {
|
||||
if (form.payment_method === 'offline' && voucherFileKeys.value.length === 0) {
|
||||
callback(new Error('线下支付必须上传整批支付凭证'))
|
||||
} else callback()
|
||||
},
|
||||
trigger: 'change'
|
||||
}
|
||||
]
|
||||
}))
|
||||
|
||||
const loadPackages = async (query = '') => {
|
||||
if (!form.series_id) {
|
||||
packageOptions.value = []
|
||||
return
|
||||
}
|
||||
|
||||
packageLoading.value = true
|
||||
try {
|
||||
const res = await PackageManageService.getPackages({
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
package_name: query.trim() || undefined,
|
||||
series_id: form.series_id,
|
||||
status: 1,
|
||||
shelf_status: 1
|
||||
})
|
||||
if (res.code !== 0) {
|
||||
ElMessage.error(res.msg || '获取套餐列表失败')
|
||||
return
|
||||
}
|
||||
|
||||
packageOptions.value = (res.data?.items || []).filter(
|
||||
(item) => item.status === 1 && item.shelf_status === 1
|
||||
)
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error?.message || '获取套餐列表失败')
|
||||
} finally {
|
||||
packageLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handlePackageSearch = (query: string) => {
|
||||
if (form.series_id) void loadPackages(query)
|
||||
}
|
||||
|
||||
const handlePackageVisibleChange = (visible: boolean) => {
|
||||
if (visible && form.series_id && packageOptions.value.length === 0) void loadPackages()
|
||||
}
|
||||
|
||||
const openCreateDrawer = () => {
|
||||
createDrawerVisible.value = true
|
||||
if (seriesOptions.value.length === 0) void loadSeries()
|
||||
}
|
||||
|
||||
const handleCreateDrawerClosed = () => {
|
||||
formRef.value?.resetFields()
|
||||
form.series_id = undefined
|
||||
form.package_id = undefined
|
||||
form.payment_method = 'wallet'
|
||||
orderFileKeys.value = []
|
||||
voucherFileKeys.value = []
|
||||
orderUploadRef.value?.clearFiles(false)
|
||||
voucherUploadRef.value?.clearFiles(false)
|
||||
orderFileUploading.value = false
|
||||
voucherUploading.value = false
|
||||
}
|
||||
|
||||
const loadSeries = async (query = '') => {
|
||||
seriesLoading.value = true
|
||||
try {
|
||||
const res = await PackageSeriesService.getPackageSeries({
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
series_name: query.trim() || undefined,
|
||||
status: 1
|
||||
})
|
||||
if (res.code !== 0) {
|
||||
ElMessage.error(res.msg || '获取套餐系列失败')
|
||||
return
|
||||
}
|
||||
seriesOptions.value = res.data?.items || []
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error?.message || '获取套餐系列失败')
|
||||
} finally {
|
||||
seriesLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleSeriesSearch = (query: string) => {
|
||||
void loadSeries(query)
|
||||
}
|
||||
|
||||
const handleSeriesVisibleChange = (visible: boolean) => {
|
||||
if (visible && seriesOptions.value.length === 0) void loadSeries()
|
||||
}
|
||||
|
||||
const handleSeriesChange = () => {
|
||||
form.package_id = undefined
|
||||
packageOptions.value = []
|
||||
if (form.series_id) void loadPackages()
|
||||
}
|
||||
|
||||
const handlePaymentMethodChange = (value: string | number | boolean | undefined) => {
|
||||
if (value === 'wallet') {
|
||||
voucherFileKeys.value = []
|
||||
voucherUploadRef.value?.clearFiles()
|
||||
formRef.value?.clearValidate('voucherFile')
|
||||
}
|
||||
}
|
||||
|
||||
const submitTask = async () => {
|
||||
if (
|
||||
!hasAuth(BULK_PURCHASE_PERMISSIONS.create) ||
|
||||
submitting.value ||
|
||||
voucherUploading.value ||
|
||||
orderFileUploading.value
|
||||
)
|
||||
return
|
||||
const valid = await formRef.value?.validate().catch(() => false)
|
||||
if (!valid || !form.package_id || orderFileKeys.value.length === 0) return
|
||||
|
||||
submitting.value = true
|
||||
try {
|
||||
const data = {
|
||||
file_key: orderFileKeys.value[0],
|
||||
package_id: form.package_id,
|
||||
payment_method: form.payment_method,
|
||||
...(form.payment_method === 'offline' ? { voucher_keys: voucherFileKeys.value } : {})
|
||||
}
|
||||
|
||||
const res = await BulkPurchaseService.createTask(data)
|
||||
const taskId = res.data?.task_id ?? res.data?.id
|
||||
if (res.code !== 0 || !taskId) {
|
||||
ElMessage.error(res.msg || '创建批量订购任务失败')
|
||||
return
|
||||
}
|
||||
|
||||
createDrawerVisible.value = false
|
||||
await loadTaskList()
|
||||
startTaskStatusPolling(taskId, res.data?.status ?? BulkPurchaseTaskStatus.PENDING)
|
||||
ElMessage.success(res.data.message || '批量订购任务已创建')
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error?.message || '创建批量订购任务失败')
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const loadTaskList = async () => {
|
||||
if (!hasAuth(BULK_PURCHASE_PERMISSIONS.detail)) return
|
||||
taskListLoading.value = true
|
||||
try {
|
||||
const res = await BulkPurchaseService.getTasks({
|
||||
page: taskListPage.value,
|
||||
page_size: taskListSize.value,
|
||||
status: taskListStatus.value
|
||||
})
|
||||
if (res.code !== 0) {
|
||||
ElMessage.error(res.msg || '获取批量订购任务列表失败')
|
||||
return
|
||||
}
|
||||
|
||||
taskList.value = res.data?.items || []
|
||||
taskListTotal.value = res.data?.total || 0
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error?.message || '获取批量订购任务列表失败')
|
||||
} finally {
|
||||
taskListLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleTaskListStatusChange = () => {
|
||||
taskListPage.value = 1
|
||||
void loadTaskList()
|
||||
}
|
||||
|
||||
const handleTaskListSizeChange = () => {
|
||||
taskListPage.value = 1
|
||||
void loadTaskList()
|
||||
}
|
||||
|
||||
const stopTaskStatusPolling = () => {
|
||||
taskStatusPollSession += 1
|
||||
if (taskStatusPollTimer !== undefined) {
|
||||
window.clearTimeout(taskStatusPollTimer)
|
||||
taskStatusPollTimer = undefined
|
||||
}
|
||||
}
|
||||
|
||||
const startTaskStatusPolling = (
|
||||
taskId: number,
|
||||
initialStatus = BulkPurchaseTaskStatus.PENDING
|
||||
) => {
|
||||
stopTaskStatusPolling()
|
||||
const session = taskStatusPollSession
|
||||
let lastStatus = initialStatus
|
||||
|
||||
const poll = async () => {
|
||||
if (session !== taskStatusPollSession) return
|
||||
|
||||
try {
|
||||
const response = await BulkPurchaseService.getTasks({
|
||||
page: 1,
|
||||
page_size: 100
|
||||
})
|
||||
if (response.code === 0) {
|
||||
const task = response.data.items.find((item) => (item.task_id ?? item.id) === taskId)
|
||||
if (task) {
|
||||
if (task.status !== lastStatus) {
|
||||
lastStatus = task.status
|
||||
await loadTaskList()
|
||||
}
|
||||
if (
|
||||
session === taskStatusPollSession &&
|
||||
[
|
||||
BulkPurchaseTaskStatus.COMPLETED,
|
||||
BulkPurchaseTaskStatus.FAILED,
|
||||
BulkPurchaseTaskStatus.CANCELED
|
||||
].includes(task.status)
|
||||
) {
|
||||
stopTaskStatusPolling()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('轮询批量订购任务状态失败:', error)
|
||||
}
|
||||
|
||||
if (session === taskStatusPollSession) {
|
||||
taskStatusPollTimer = window.setTimeout(() => void poll(), taskStatusPollInterval)
|
||||
}
|
||||
}
|
||||
|
||||
void poll()
|
||||
}
|
||||
|
||||
const showTask = (task: BulkPurchaseTask) => {
|
||||
const taskId = task.task_id ?? task.id
|
||||
if (!taskId) return
|
||||
|
||||
void router.push(`${RoutesAlias.BulkPurchaseDetail}/${taskId}`)
|
||||
}
|
||||
|
||||
const getStatusName = (status: BulkPurchaseTaskStatus) => {
|
||||
const names: Record<BulkPurchaseTaskStatus, string> = {
|
||||
[BulkPurchaseTaskStatus.PENDING]: '待处理',
|
||||
[BulkPurchaseTaskStatus.PROCESSING]: '处理中',
|
||||
[BulkPurchaseTaskStatus.COMPLETED]: '已完成',
|
||||
[BulkPurchaseTaskStatus.FAILED]: '已失败',
|
||||
[BulkPurchaseTaskStatus.CANCELED]: '已取消'
|
||||
}
|
||||
return names[status] || '-'
|
||||
}
|
||||
|
||||
const getStatusType = (status: BulkPurchaseTaskStatus) => {
|
||||
if (status === BulkPurchaseTaskStatus.COMPLETED) return 'success'
|
||||
if (status === BulkPurchaseTaskStatus.FAILED) return 'danger'
|
||||
if (status === BulkPurchaseTaskStatus.PROCESSING) return 'warning'
|
||||
return 'info'
|
||||
}
|
||||
|
||||
const getPaymentMethodName = (method?: BulkPurchasePaymentMethod) => {
|
||||
return method === 'offline' ? '线下支付' : method === 'wallet' ? '代理钱包' : '-'
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void loadTaskList()
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
stopTaskStatusPolling()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.bulk-purchase-page {
|
||||
.task-list-header {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.task-list-toolbar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.package-option {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.package-empty {
|
||||
padding: 8px 0;
|
||||
color: var(--el-color-danger);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.package-empty-tip {
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
color: var(--el-color-danger);
|
||||
}
|
||||
|
||||
.create-form {
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
.drawer-footer {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.pagination-wrapper {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
@media (width <= 768px) {
|
||||
.task-list-header {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.task-list-toolbar {
|
||||
width: 100%;
|
||||
|
||||
.el-select {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,584 @@
|
||||
<template>
|
||||
<ArtTableFullScreen>
|
||||
<div class="device-batch-allocation-page" id="table-full-screen">
|
||||
<ElDrawer
|
||||
v-model="createDrawerVisible"
|
||||
title="设备批量任务"
|
||||
direction="rtl"
|
||||
size="40%"
|
||||
:close-on-click-modal="!createDrawerBusy"
|
||||
:close-on-press-escape="!createDrawerBusy"
|
||||
@closed="handleCreateDrawerClosed"
|
||||
>
|
||||
<ElForm ref="formRef" :model="form" class="create-form">
|
||||
<ElFormItem label="操作类型" prop="operation_type">
|
||||
<ElSelect
|
||||
v-model="form.operation_type"
|
||||
style="width: 100%"
|
||||
@change="handleOperationTypeChange"
|
||||
>
|
||||
<ElOption label="分配目标代理" value="assign_shop" />
|
||||
<ElOption label="设置套餐系列" value="assign_series" />
|
||||
<ElOption label="批量回收设备" value="recall" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
|
||||
<ElFormItem v-if="requiresTargetId" :label="targetLabel" prop="target_id">
|
||||
<ElSelect
|
||||
v-model="form.target_id"
|
||||
filterable
|
||||
remote
|
||||
clearable
|
||||
:remote-method="handleTargetSearch"
|
||||
:loading="targetLoading"
|
||||
:placeholder="targetPlaceholder"
|
||||
style="width: 100%"
|
||||
@visible-change="handleTargetVisibleChange"
|
||||
>
|
||||
<template v-if="form.operation_type === 'assign_shop'">
|
||||
<ElOption
|
||||
v-for="shop in shopOptions"
|
||||
:key="shop.id"
|
||||
:label="shop.shop_name"
|
||||
:value="shop.id"
|
||||
/>
|
||||
</template>
|
||||
<template v-else>
|
||||
<ElOption
|
||||
v-for="series in seriesOptions"
|
||||
:key="series.id"
|
||||
:label="series.series_name"
|
||||
:value="series.id"
|
||||
/>
|
||||
</template>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem v-else label="回收目标">
|
||||
<ElTag type="warning">回收到平台库存</ElTag>
|
||||
</ElFormItem>
|
||||
|
||||
<ElFormItem label="设备文件" prop="file_key">
|
||||
<VoucherUpload
|
||||
ref="uploadRef"
|
||||
v-model="fileKeys"
|
||||
voucher-name="设备标识文件"
|
||||
:max-count="1"
|
||||
purpose="device_batch_allocation"
|
||||
:max-size-mb="10"
|
||||
single-column-csv
|
||||
:max-csv-rows="1000"
|
||||
accept=".csv"
|
||||
tip="格式:一行一个唯一标识;仅支持 UTF-8 单列 CSV,最多 1000 行,最大 10MB"
|
||||
@uploading-change="fileUploading = $event"
|
||||
/>
|
||||
</ElFormItem>
|
||||
|
||||
<ElAlert
|
||||
v-if="createDrawerBusy"
|
||||
type="info"
|
||||
:closable="false"
|
||||
show-icon
|
||||
:title="fileUploading ? '设备文件上传中,请稍候' : '任务创建中,请勿重复提交'"
|
||||
/>
|
||||
</ElForm>
|
||||
|
||||
<template #footer>
|
||||
<div class="drawer-footer">
|
||||
<ElButton :disabled="createDrawerBusy" @click="createDrawerVisible = false">
|
||||
取消
|
||||
</ElButton>
|
||||
<ElButton
|
||||
type="primary"
|
||||
:loading="submitting"
|
||||
:disabled="!hasAuth(JULY_PERMISSIONS.deviceAllocation.create)"
|
||||
@click="submitTask"
|
||||
>
|
||||
创建分配任务
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</ElDrawer>
|
||||
|
||||
<ElCard shadow="never" class="art-table-card task-list-card">
|
||||
<template #header>
|
||||
<div class="task-list-header">
|
||||
<span>设备批量任务</span>
|
||||
<div class="task-list-toolbar">
|
||||
<ElButton
|
||||
v-if="hasAuth(JULY_PERMISSIONS.deviceAllocation.create)"
|
||||
@click="downloadTemplate"
|
||||
>
|
||||
下载模板
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="hasAuth(JULY_PERMISSIONS.deviceAllocation.create)"
|
||||
type="primary"
|
||||
@click="openCreateDrawer"
|
||||
>
|
||||
设备批量任务
|
||||
</ElButton>
|
||||
<ElSelect
|
||||
v-model="taskListOperationType"
|
||||
clearable
|
||||
placeholder="筛选操作类型"
|
||||
style="width: 170px"
|
||||
@change="handleTaskListFilterChange"
|
||||
>
|
||||
<ElOption label="分配目标代理" value="assign_shop" />
|
||||
<ElOption label="设置套餐系列" value="assign_series" />
|
||||
<ElOption label="批量回收设备" value="recall" />
|
||||
</ElSelect>
|
||||
<ElSelect
|
||||
v-model="taskListStatus"
|
||||
clearable
|
||||
placeholder="筛选任务状态"
|
||||
style="width: 150px"
|
||||
@change="handleTaskListFilterChange"
|
||||
>
|
||||
<ElOption label="待处理" :value="DeviceImportTaskStatus.PENDING" />
|
||||
<ElOption label="处理中" :value="DeviceImportTaskStatus.PROCESSING" />
|
||||
<ElOption label="已完成" :value="DeviceImportTaskStatus.COMPLETED" />
|
||||
<ElOption label="失败" :value="DeviceImportTaskStatus.FAILED" />
|
||||
</ElSelect>
|
||||
<ElButton :loading="taskListLoading" @click="loadTaskList">刷新</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<ElTable v-loading="taskListLoading" :data="taskList" border>
|
||||
<ElTableColumn label="任务号" min-width="225" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<ElButton
|
||||
v-if="hasAuth(JULY_PERMISSIONS.deviceAllocation.detail)"
|
||||
type="primary"
|
||||
link
|
||||
@click="showTask(scope.row)"
|
||||
>
|
||||
{{ scope.row.task_no || '-' }}
|
||||
</ElButton>
|
||||
<span v-else>{{ scope.row.task_no || '-' }}</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="操作类型" width="150">
|
||||
<template #default="scope">
|
||||
<ElTag :type="getOperationTagType(scope.row.operation_type)">
|
||||
{{ getOperationLabel(scope.row.operation_type) }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
prop="operation_name"
|
||||
label="操作名称"
|
||||
min-width="170"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #default="scope">
|
||||
{{ scope.row.operation_name || getOperationLabel(scope.row.operation_type) }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="目标名称" min-width="160" show-overflow-tooltip>
|
||||
<template #default="scope">{{ scope.row.target_name || '-' }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="状态" width="110">
|
||||
<template #default="scope">
|
||||
<ElTag :type="getStatusTagType(scope.row.status)">
|
||||
{{ scope.row.status_name || scope.row.status_text || '-' }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="total_count" label="总数" width="90" />
|
||||
<ElTableColumn prop="success_count" label="成功数" width="90" />
|
||||
<ElTableColumn prop="fail_count" label="失败数" width="90" />
|
||||
<ElTableColumn prop="skip_count" label="跳过数" width="90" />
|
||||
<ElTableColumn label="创建时间" width="180">
|
||||
<template #default="scope">{{ formatDateTime(scope.row.created_at) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="完成时间" width="180">
|
||||
<template #default="scope">
|
||||
{{ scope.row.completed_at ? formatDateTime(scope.row.completed_at) : '-' }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
|
||||
<div class="pagination-wrapper">
|
||||
<ElPagination
|
||||
v-model:current-page="taskListPage"
|
||||
v-model:page-size="taskListSize"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:total="taskListTotal"
|
||||
@current-change="loadTaskList"
|
||||
@size-change="handleTaskListSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</ElCard>
|
||||
</div>
|
||||
</ArtTableFullScreen>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, onMounted, reactive, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import {
|
||||
ElAlert,
|
||||
ElButton,
|
||||
ElCard,
|
||||
ElDrawer,
|
||||
ElForm,
|
||||
ElMessage,
|
||||
ElOption,
|
||||
ElPagination,
|
||||
ElSelect,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTag
|
||||
} from 'element-plus'
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import VoucherUpload from '@/components/business/VoucherUpload.vue'
|
||||
import { DeviceService, PackageSeriesService, ShopService } from '@/api/modules'
|
||||
import { DeviceImportTaskStatus } from '@/types/api/device'
|
||||
import type {
|
||||
DeviceBatchAllocationRequest,
|
||||
DeviceImportTask,
|
||||
DeviceImportTaskOperationType
|
||||
} from '@/types/api/device'
|
||||
import type { PackageSeriesResponse, ShopResponse } from '@/types/api'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
import { JULY_PERMISSIONS } from '@/config/constants'
|
||||
import { RoutesAlias } from '@/router/routesAlias'
|
||||
import { normalizeApiError } from '@/utils/business/apiError'
|
||||
|
||||
defineOptions({ name: 'DeviceBatchAllocation' })
|
||||
|
||||
const router = useRouter()
|
||||
const { hasAuth } = useAuth()
|
||||
const formRef = ref<FormInstance>()
|
||||
const uploadRef = ref<InstanceType<typeof VoucherUpload>>()
|
||||
const createDrawerVisible = ref(false)
|
||||
const submitting = ref(false)
|
||||
const fileUploading = ref(false)
|
||||
const fileKeys = ref<string[]>([])
|
||||
const taskList = ref<DeviceImportTask[]>([])
|
||||
const taskListLoading = ref(false)
|
||||
const taskListPage = ref(1)
|
||||
const taskListSize = ref(20)
|
||||
const taskListTotal = ref(0)
|
||||
const taskListStatus = ref<DeviceImportTaskStatus | undefined>()
|
||||
const taskListOperationType = ref<Exclude<DeviceImportTaskOperationType, 'import'> | undefined>()
|
||||
const taskStatusPollInterval = 2000
|
||||
let taskStatusPollTimer: number | undefined
|
||||
let taskStatusPollSession = 0
|
||||
const shopOptions = ref<ShopResponse[]>([])
|
||||
const seriesOptions = ref<PackageSeriesResponse[]>([])
|
||||
const targetLoading = ref(false)
|
||||
const form = reactive<{
|
||||
operation_type: Exclude<DeviceImportTaskOperationType, 'import'>
|
||||
target_id?: number
|
||||
}>({
|
||||
operation_type: 'assign_shop',
|
||||
target_id: undefined
|
||||
})
|
||||
|
||||
const requiresTargetId = computed(() =>
|
||||
['assign_shop', 'assign_series'].includes(form.operation_type)
|
||||
)
|
||||
const targetPlaceholder = computed(() =>
|
||||
form.operation_type === 'assign_shop' ? '请选择启用的目标店铺' : '请选择启用的套餐系列'
|
||||
)
|
||||
const targetLabel = computed(() =>
|
||||
form.operation_type === 'assign_shop' ? '选择店铺' : '套餐系列'
|
||||
)
|
||||
const createDrawerBusy = computed(() => submitting.value || fileUploading.value)
|
||||
|
||||
const getOperationLabel = (operationType: DeviceImportTaskOperationType) => {
|
||||
switch (operationType) {
|
||||
case 'assign_shop':
|
||||
return '分配目标代理'
|
||||
case 'assign_series':
|
||||
return '设置套餐系列'
|
||||
case 'recall':
|
||||
return '批量回收设备'
|
||||
default:
|
||||
return '设备导入'
|
||||
}
|
||||
}
|
||||
|
||||
const getOperationTagType = (operationType: DeviceImportTaskOperationType) =>
|
||||
operationType === 'recall' ? 'warning' : 'primary'
|
||||
|
||||
const getStatusTagType = (status: DeviceImportTaskStatus) => {
|
||||
switch (status) {
|
||||
case DeviceImportTaskStatus.PENDING:
|
||||
return 'info'
|
||||
case DeviceImportTaskStatus.PROCESSING:
|
||||
return 'warning'
|
||||
case DeviceImportTaskStatus.COMPLETED:
|
||||
return 'success'
|
||||
case DeviceImportTaskStatus.FAILED:
|
||||
return 'danger'
|
||||
default:
|
||||
return 'info'
|
||||
}
|
||||
}
|
||||
|
||||
const openCreateDrawer = () => {
|
||||
if (!hasAuth(JULY_PERMISSIONS.deviceAllocation.create)) return
|
||||
createDrawerVisible.value = true
|
||||
}
|
||||
|
||||
const loadTargetOptions = async (query = '') => {
|
||||
if (form.operation_type === 'recall') return
|
||||
targetLoading.value = true
|
||||
try {
|
||||
if (form.operation_type === 'assign_shop') {
|
||||
const res = await ShopService.getShops({
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
status: 1,
|
||||
shop_name: query || undefined
|
||||
})
|
||||
if (res.code === 0) shopOptions.value = res.data.items || []
|
||||
} else {
|
||||
const res = await PackageSeriesService.getPackageSeries({
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
status: 1,
|
||||
series_name: query || undefined
|
||||
})
|
||||
if (res.code === 0) seriesOptions.value = res.data.items || []
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取设备批量任务目标失败:', error)
|
||||
ElMessage.error(normalizeApiError(error).message)
|
||||
} finally {
|
||||
targetLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleTargetSearch = (query: string) => {
|
||||
void loadTargetOptions(query)
|
||||
}
|
||||
|
||||
const handleTargetVisibleChange = (visible: boolean) => {
|
||||
if (
|
||||
visible &&
|
||||
(form.operation_type === 'assign_shop'
|
||||
? !shopOptions.value.length
|
||||
: !seriesOptions.value.length)
|
||||
) {
|
||||
void loadTargetOptions()
|
||||
}
|
||||
}
|
||||
|
||||
const handleOperationTypeChange = () => {
|
||||
form.target_id = undefined
|
||||
shopOptions.value = []
|
||||
seriesOptions.value = []
|
||||
if (form.operation_type !== 'recall') void loadTargetOptions()
|
||||
}
|
||||
|
||||
const handleCreateDrawerClosed = () => {
|
||||
formRef.value?.resetFields()
|
||||
form.operation_type = 'assign_shop'
|
||||
form.target_id = undefined
|
||||
shopOptions.value = []
|
||||
seriesOptions.value = []
|
||||
fileKeys.value = []
|
||||
fileUploading.value = false
|
||||
uploadRef.value?.clearFiles()
|
||||
}
|
||||
|
||||
const downloadTemplate = () => {
|
||||
try {
|
||||
const link = document.createElement('a')
|
||||
link.href = new URL('@/template/设备批量任务.csv', import.meta.url).href
|
||||
link.download = '设备批量任务.csv'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
ElMessage.success('模板下载成功')
|
||||
} catch (error) {
|
||||
console.error('下载模板失败:', error)
|
||||
ElMessage.error('模板下载失败')
|
||||
}
|
||||
}
|
||||
|
||||
const handleTaskListFilterChange = () => {
|
||||
taskListPage.value = 1
|
||||
void loadTaskList()
|
||||
}
|
||||
|
||||
const loadTaskList = async () => {
|
||||
taskListLoading.value = true
|
||||
try {
|
||||
const res = await DeviceService.getImportTasks({
|
||||
page: taskListPage.value,
|
||||
page_size: taskListSize.value,
|
||||
status: taskListStatus.value,
|
||||
operation_type: taskListOperationType.value
|
||||
})
|
||||
if (res.code !== 0) {
|
||||
ElMessage.error(res.msg || '获取设备批量任务失败')
|
||||
return
|
||||
}
|
||||
taskList.value = (res.data.items || []).filter((item) => item.operation_type !== 'import')
|
||||
taskListTotal.value = res.data.total || 0
|
||||
} catch (error) {
|
||||
console.error('获取设备批量任务失败:', error)
|
||||
ElMessage.error(normalizeApiError(error).message)
|
||||
} finally {
|
||||
taskListLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleTaskListSizeChange = () => {
|
||||
taskListPage.value = 1
|
||||
void loadTaskList()
|
||||
}
|
||||
|
||||
const stopTaskStatusPolling = () => {
|
||||
taskStatusPollSession += 1
|
||||
if (taskStatusPollTimer !== undefined) {
|
||||
window.clearTimeout(taskStatusPollTimer)
|
||||
taskStatusPollTimer = undefined
|
||||
}
|
||||
}
|
||||
|
||||
const startTaskStatusPolling = (
|
||||
taskId: number,
|
||||
initialStatus = DeviceImportTaskStatus.PENDING
|
||||
) => {
|
||||
stopTaskStatusPolling()
|
||||
const session = taskStatusPollSession
|
||||
let lastStatus = initialStatus
|
||||
|
||||
const poll = async () => {
|
||||
if (session !== taskStatusPollSession) return
|
||||
|
||||
try {
|
||||
const response = await DeviceService.getImportTasks({
|
||||
page: 1,
|
||||
page_size: 100
|
||||
})
|
||||
if (response.code === 0) {
|
||||
const task = response.data.items.find((item) => item.id === taskId)
|
||||
if (task) {
|
||||
if (task.status !== lastStatus) {
|
||||
lastStatus = task.status
|
||||
await loadTaskList()
|
||||
}
|
||||
if (
|
||||
session === taskStatusPollSession &&
|
||||
[DeviceImportTaskStatus.COMPLETED, DeviceImportTaskStatus.FAILED].includes(
|
||||
task.status
|
||||
)
|
||||
) {
|
||||
stopTaskStatusPolling()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('轮询设备批量任务状态失败:', error)
|
||||
}
|
||||
|
||||
if (session === taskStatusPollSession) {
|
||||
taskStatusPollTimer = window.setTimeout(() => void poll(), taskStatusPollInterval)
|
||||
}
|
||||
}
|
||||
|
||||
void poll()
|
||||
}
|
||||
|
||||
const showTask = (row: DeviceImportTask) => {
|
||||
router.push({
|
||||
path: RoutesAlias.TaskDetail,
|
||||
query: { id: row.id, task_type: 'device' }
|
||||
})
|
||||
}
|
||||
|
||||
const submitTask = async () => {
|
||||
if (createDrawerBusy.value) return
|
||||
if (!fileKeys.value[0]) {
|
||||
ElMessage.warning('请先上传设备标识文件')
|
||||
return
|
||||
}
|
||||
if (requiresTargetId.value && !form.target_id) {
|
||||
ElMessage.warning('请选择目标店铺或套餐系列')
|
||||
return
|
||||
}
|
||||
|
||||
const request: DeviceBatchAllocationRequest = {
|
||||
file_key: fileKeys.value[0],
|
||||
operation_type: form.operation_type
|
||||
}
|
||||
if (requiresTargetId.value) request.target_id = form.target_id
|
||||
|
||||
submitting.value = true
|
||||
try {
|
||||
const res = await DeviceService.createAllocationTask(request)
|
||||
if (res.code !== 0) {
|
||||
ElMessage.error(res.msg || '创建设备批量任务失败')
|
||||
return
|
||||
}
|
||||
createDrawerVisible.value = false
|
||||
await loadTaskList()
|
||||
startTaskStatusPolling(res.data.task_id)
|
||||
ElMessage.success(`任务已创建:${res.data.task_no}`)
|
||||
} catch (error) {
|
||||
console.error('创建设备批量任务失败:', error)
|
||||
ElMessage.error(normalizeApiError(error).message)
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void loadTaskList()
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
stopTaskStatusPolling()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.device-batch-allocation-page {
|
||||
.task-list-header {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.task-list-toolbar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.pagination-wrapper {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
padding-top: 16px;
|
||||
}
|
||||
|
||||
.drawer-footer {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
@media (width <= 900px) {
|
||||
.task-list-header {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.task-list-toolbar {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,35 +1,37 @@
|
||||
<template>
|
||||
<ArtTableFullScreen>
|
||||
<div class="device-task-page" id="table-full-screen">
|
||||
<!-- 搜索栏 -->
|
||||
<div v-if="isPlatformAccount" class="device-task-page" id="table-full-screen">
|
||||
<ArtSearchBar
|
||||
v-model:filter="searchForm"
|
||||
:items="searchFormItems"
|
||||
:show-expand="false"
|
||||
@reset="handleReset"
|
||||
@search="handleSearch"
|
||||
></ArtSearchBar>
|
||||
/>
|
||||
|
||||
<div v-if="pollingError || pollingForbidden" class="task-polling-error">
|
||||
<ElAlert
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
:title="pollingForbidden ? '当前账号无权查看该任务' : pollingError || '任务状态获取失败'"
|
||||
/>
|
||||
<ElButton size="small" @click="polling.retry">重试</ElButton>
|
||||
</div>
|
||||
|
||||
<ElCard shadow="never" class="art-table-card">
|
||||
<!-- 表格头部 -->
|
||||
<ArtTableHeader
|
||||
:columnList="columnOptions"
|
||||
v-model:columns="columnChecks"
|
||||
@refresh="handleRefresh"
|
||||
>
|
||||
<template #left>
|
||||
<ElButton
|
||||
type="primary"
|
||||
:icon="Upload"
|
||||
@click="importDialogVisible = true"
|
||||
v-permission="'device_task:bulk_import'"
|
||||
>
|
||||
<ElButton type="primary" :icon="Upload" @click="importDialogVisible = true">
|
||||
批量导入设备
|
||||
</ElButton>
|
||||
</template>
|
||||
</ArtTableHeader>
|
||||
|
||||
<!-- 表格 -->
|
||||
<ArtTable
|
||||
ref="tableRef"
|
||||
row-key="id"
|
||||
@@ -51,21 +53,20 @@
|
||||
</ElCard>
|
||||
</div>
|
||||
|
||||
<!-- 导入对话框 -->
|
||||
<ElDialog v-model="importDialogVisible" title="批量导入设备" width="40%" align-center>
|
||||
<ElDrawer v-model="importDialogVisible" title="批量导入设备" direction="rtl" size="50%">
|
||||
<ElAlert type="info" :closable="false" style="margin-bottom: 20px">
|
||||
<template #title>
|
||||
<div style="line-height: 1.8">
|
||||
<p><strong>导入说明:</strong></p>
|
||||
<p>1. 请先下载 Excel 模板文件,按照模板格式填写设备信息</p>
|
||||
<p>2. 仅支持 Excel 格式(.xlsx),单次最多导入 1000 条</p>
|
||||
<p>3. 列格式请设置为文本格式,避免长数字被转为科学计数法</p>
|
||||
<p>4. <strong>重要:列顺序固定,不可调整。</strong>系统按位置读取,不识别列名</p>
|
||||
<p style="color: var(--el-color-primary)">5. 必填列:虚拟号(第1列)</p>
|
||||
<p>1. 设备导入使用 Excel 模板,文件大小不能超过 300MB。</p>
|
||||
<p>2. 列格式请设置为文本格式,避免长数字被转为科学计数法。</p>
|
||||
<p>3. <strong>列顺序固定,不可调整。</strong>系统按位置读取,不识别列名。</p>
|
||||
<p style="color: var(--el-color-primary)">
|
||||
4. 必填列:设备标识(第 1 列,支持 VirtualNo、IMEI 或 SN)。
|
||||
</p>
|
||||
<p>
|
||||
6.
|
||||
可选列:SN、设备名称、设备型号、设备类型、IMEI、制造商、最大SIM槽数(默认4,有效范围1-4)、卡1~卡4
|
||||
ICCID
|
||||
5. 可选列:SN、设备名称、设备型号、设备类型、IMEI、制造商、最大 SIM 槽数、卡 1~卡 4
|
||||
ICCID。
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
@@ -117,9 +118,9 @@
|
||||
accept=".xlsx"
|
||||
>
|
||||
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
|
||||
<div class="el-upload__text">将 Excel 文件拖到此处,或<em>点击选择</em></div>
|
||||
<div class="el-upload__text">将文件拖到此处,或<em>点击选择</em></div>
|
||||
<template #tip>
|
||||
<div class="el-upload__tip">只能上传 .xlsx 格式的 Excel 文件,且不超过 300MB</div>
|
||||
<div class="el-upload__tip">设备导入仅支持 .xlsx 文件</div>
|
||||
</template>
|
||||
</ElUpload>
|
||||
|
||||
@@ -134,31 +135,42 @@
|
||||
开始导入
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</ElDrawer>
|
||||
</ArtTableFullScreen>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { h } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { h, onMounted, reactive, ref, watch, computed } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { DeviceService } from '@/api/modules'
|
||||
import { ElMessage, ElTag } from 'element-plus'
|
||||
import { Download, UploadFilled, Upload } from '@element-plus/icons-vue'
|
||||
import { Download, Upload, UploadFilled } from '@element-plus/icons-vue'
|
||||
import type { UploadInstance } from 'element-plus'
|
||||
import type { SearchFormItem } from '@/types'
|
||||
import { useCheckedColumns } from '@/composables/useCheckedColumns'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
import { useAsyncTaskPolling } from '@/composables/useAsyncTaskPolling'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
import { StorageService } from '@/api/modules/storage'
|
||||
import type { DeviceImportTask, DeviceImportTaskStatus, RealnamePolicy } from '@/types/api/device'
|
||||
import type {
|
||||
DeviceImportTask,
|
||||
DeviceImportTaskDetail,
|
||||
DeviceImportTaskQueryParams,
|
||||
DeviceImportTaskStatus,
|
||||
RealnamePolicy
|
||||
} from '@/types/api/device'
|
||||
import { RoutesAlias } from '@/router/routesAlias'
|
||||
import { generatePackageCode } from '@/utils/codeGenerator'
|
||||
import { normalizeApiError } from '@/utils/business/apiError'
|
||||
|
||||
defineOptions({ name: 'DeviceTask' })
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const { hasAuth } = useAuth()
|
||||
const userStore = useUserStore()
|
||||
const isPlatformAccount = computed(() => [1, 2].includes(Number(userStore.info.user_type)))
|
||||
|
||||
const loading = ref(false)
|
||||
const tableRef = ref()
|
||||
@@ -168,38 +180,23 @@
|
||||
const importDialogVisible = ref(false)
|
||||
const importForm = reactive({
|
||||
batch_no: '',
|
||||
realname_policy: '' as '' | 'none' | 'before_order' | 'after_order'
|
||||
realname_policy: '' as '' | RealnamePolicy
|
||||
})
|
||||
|
||||
// 搜索表单初始值
|
||||
const initialSearchState = {
|
||||
status: undefined,
|
||||
status: undefined as DeviceImportTaskStatus | undefined,
|
||||
batch_no: '',
|
||||
dateRange: undefined as any,
|
||||
start_time: '',
|
||||
end_time: ''
|
||||
dateRange: undefined as string[] | undefined
|
||||
}
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = reactive({ ...initialSearchState })
|
||||
const pagination = reactive({ page: 1, pageSize: 20, total: 0 })
|
||||
|
||||
// 分页
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
pageSize: 20,
|
||||
total: 0
|
||||
})
|
||||
|
||||
// 搜索表单配置
|
||||
const searchFormItems: SearchFormItem[] = [
|
||||
{
|
||||
label: '任务状态',
|
||||
prop: 'status',
|
||||
type: 'select',
|
||||
config: {
|
||||
clearable: true,
|
||||
placeholder: '全部'
|
||||
},
|
||||
config: { clearable: true, placeholder: '全部' },
|
||||
options: () => [
|
||||
{ label: '待处理', value: 1 },
|
||||
{ label: '处理中', value: 2 },
|
||||
@@ -211,17 +208,14 @@
|
||||
label: '批次号',
|
||||
prop: 'batch_no',
|
||||
type: 'input',
|
||||
config: {
|
||||
clearable: true,
|
||||
placeholder: '请输入批次号'
|
||||
}
|
||||
config: { clearable: true, placeholder: '请输入批次号' }
|
||||
},
|
||||
{
|
||||
label: '创建时间',
|
||||
prop: 'dateRange',
|
||||
type: 'daterange',
|
||||
type: 'datetimerange',
|
||||
config: {
|
||||
type: 'daterange',
|
||||
type: 'datetimerange',
|
||||
startPlaceholder: '开始时间',
|
||||
endPlaceholder: '结束时间',
|
||||
valueFormat: 'YYYY-MM-DDTHH:mm:ssZ'
|
||||
@@ -229,7 +223,6 @@
|
||||
}
|
||||
]
|
||||
|
||||
// 列配置
|
||||
const columnOptions = [
|
||||
{ label: '任务编号', prop: 'task_no' },
|
||||
{ label: '任务状态', prop: 'status' },
|
||||
@@ -246,8 +239,23 @@
|
||||
]
|
||||
|
||||
const taskList = ref<DeviceImportTask[]>([])
|
||||
const polling = useAsyncTaskPolling<DeviceImportTaskDetail>({
|
||||
storageKey: 'device-import-active-task',
|
||||
autoRestore: false,
|
||||
fetchTask: async (taskId) => {
|
||||
const res = await DeviceService.getImportTaskDetail(taskId)
|
||||
if (res.code !== 0 || !res.data) throw new Error(res.msg || '获取设备任务失败')
|
||||
return res.data
|
||||
},
|
||||
isForbidden: (error) => {
|
||||
const response = (error as { response?: { status?: number; data?: { code?: number } } })
|
||||
?.response
|
||||
return response?.status === 403 || response?.data?.code === 403
|
||||
}
|
||||
})
|
||||
const pollingError = polling.error
|
||||
const pollingForbidden = polling.forbidden
|
||||
|
||||
// 获取状态标签类型
|
||||
const getStatusType = (status: DeviceImportTaskStatus) => {
|
||||
switch (status) {
|
||||
case 1:
|
||||
@@ -263,35 +271,30 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 查看详情
|
||||
const viewDetail = (row: DeviceImportTask) => {
|
||||
if (!isPlatformAccount.value) return
|
||||
router.push({
|
||||
path: RoutesAlias.TaskDetail,
|
||||
query: {
|
||||
id: row.id,
|
||||
task_type: 'device'
|
||||
}
|
||||
query: { id: row.id, task_type: 'device' }
|
||||
})
|
||||
}
|
||||
|
||||
// 处理名称点击
|
||||
const handleNameClick = (row: DeviceImportTask) => {
|
||||
if (hasAuth('device_task:view_detail')) {
|
||||
if (isPlatformAccount.value && hasAuth('device_task:view_detail')) {
|
||||
viewDetail(row)
|
||||
} else {
|
||||
ElMessage.warning('您没有查看详情的权限')
|
||||
}
|
||||
}
|
||||
|
||||
// 动态列配置
|
||||
const { columnChecks, columns } = useCheckedColumns(() => [
|
||||
{
|
||||
prop: 'task_no',
|
||||
label: '任务编号',
|
||||
width: 220,
|
||||
showOverflowTooltip: true,
|
||||
formatter: (row: DeviceImportTask) => {
|
||||
return h(
|
||||
formatter: (row: DeviceImportTask) =>
|
||||
h(
|
||||
'span',
|
||||
{
|
||||
style: 'color: var(--el-color-primary); cursor: pointer; text-decoration: underline;',
|
||||
@@ -302,48 +305,31 @@
|
||||
},
|
||||
row.task_no
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'status',
|
||||
label: '任务状态',
|
||||
width: 100,
|
||||
formatter: (row: DeviceImportTask) => {
|
||||
return h(ElTag, { type: getStatusType(row.status) }, () => row.status_text)
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'total_count',
|
||||
label: '总数',
|
||||
width: 80
|
||||
formatter: (row: DeviceImportTask) =>
|
||||
h(ElTag, { type: getStatusType(row.status) }, () => row.status_name || row.status_text)
|
||||
},
|
||||
{ prop: 'total_count', label: '总数', width: 80 },
|
||||
{
|
||||
prop: 'success_count',
|
||||
label: '成功数',
|
||||
width: 80,
|
||||
formatter: (row: DeviceImportTask) => {
|
||||
return h('span', { style: { color: 'var(--el-color-success)' } }, row.success_count)
|
||||
}
|
||||
formatter: (row: DeviceImportTask) =>
|
||||
h('span', { style: { color: 'var(--el-color-success)' } }, row.success_count)
|
||||
},
|
||||
{
|
||||
prop: 'fail_count',
|
||||
label: '失败数',
|
||||
width: 80,
|
||||
formatter: (row: DeviceImportTask) => {
|
||||
return h('span', { style: { color: 'var(--el-color-danger)' } }, row.fail_count)
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'skip_count',
|
||||
label: '跳过数',
|
||||
width: 80
|
||||
},
|
||||
{
|
||||
prop: 'batch_no',
|
||||
label: '批次号',
|
||||
width: 180,
|
||||
showOverflowTooltip: true
|
||||
formatter: (row: DeviceImportTask) =>
|
||||
h('span', { style: { color: 'var(--el-color-danger)' } }, row.fail_count)
|
||||
},
|
||||
{ prop: 'skip_count', label: '跳过数', width: 80 },
|
||||
{ prop: 'batch_no', label: '批次号', width: 180, showOverflowTooltip: true },
|
||||
{
|
||||
prop: 'started_at',
|
||||
label: '开始时间',
|
||||
@@ -364,12 +350,7 @@
|
||||
showOverflowTooltip: true,
|
||||
formatter: (row: DeviceImportTask) => row.error_message || '-'
|
||||
},
|
||||
{
|
||||
prop: 'file_name',
|
||||
label: '文件名',
|
||||
minWidth: 180,
|
||||
showOverflowTooltip: true
|
||||
},
|
||||
{ prop: 'file_name', label: '文件名', minWidth: 180, showOverflowTooltip: true },
|
||||
{
|
||||
prop: 'creator_name',
|
||||
label: '操作人',
|
||||
@@ -385,79 +366,78 @@
|
||||
}
|
||||
])
|
||||
|
||||
onMounted(() => {
|
||||
getTableData()
|
||||
watch(polling.task, () => {
|
||||
if (isPlatformAccount.value) void getTableData()
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
if (!isPlatformAccount.value) return
|
||||
void getTableData()
|
||||
const routeTaskId = Number(route.query.task_id)
|
||||
if (routeTaskId) {
|
||||
void polling.start(routeTaskId)
|
||||
} else if (polling.taskId.value) {
|
||||
void polling.retry()
|
||||
}
|
||||
})
|
||||
|
||||
// 获取设备任务列表
|
||||
const getTableData = async () => {
|
||||
if (!isPlatformAccount.value) {
|
||||
taskList.value = []
|
||||
pagination.total = 0
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
const params: any = {
|
||||
const params: DeviceImportTaskQueryParams = {
|
||||
page: pagination.page,
|
||||
page_size: pagination.pageSize,
|
||||
status: searchForm.status,
|
||||
operation_type: 'import',
|
||||
batch_no: searchForm.batch_no || undefined
|
||||
}
|
||||
|
||||
// 处理时间范围
|
||||
if (searchForm.dateRange && Array.isArray(searchForm.dateRange)) {
|
||||
params.start_time = searchForm.dateRange[0]
|
||||
params.end_time = searchForm.dateRange[1]
|
||||
}
|
||||
|
||||
// 清理空值
|
||||
Object.keys(params).forEach((key) => {
|
||||
if (params[key] === '' || params[key] === undefined) {
|
||||
delete params[key]
|
||||
}
|
||||
})
|
||||
|
||||
const res = await DeviceService.getImportTasks(params)
|
||||
if (res.code === 0) {
|
||||
const taskItems = (res.data as typeof res.data & { items?: DeviceImportTask[] | null })
|
||||
.items
|
||||
taskList.value = taskItems || []
|
||||
taskList.value = res.data.items || []
|
||||
pagination.total = res.data.total || 0
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
ElMessage.error(normalizeApiError(error).message)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 重置搜索
|
||||
const handleReset = () => {
|
||||
Object.assign(searchForm, { ...initialSearchState })
|
||||
pagination.page = 1
|
||||
getTableData()
|
||||
void getTableData()
|
||||
}
|
||||
|
||||
// 搜索
|
||||
const handleSearch = () => {
|
||||
pagination.page = 1
|
||||
getTableData()
|
||||
void getTableData()
|
||||
}
|
||||
|
||||
// 刷新表格
|
||||
const handleRefresh = () => {
|
||||
getTableData()
|
||||
}
|
||||
const handleRefresh = () => void getTableData()
|
||||
|
||||
// 处理表格分页变化
|
||||
const handleSizeChange = (newPageSize: number) => {
|
||||
pagination.pageSize = newPageSize
|
||||
getTableData()
|
||||
void getTableData()
|
||||
}
|
||||
|
||||
const handleCurrentChange = (newCurrentPage: number) => {
|
||||
pagination.page = newCurrentPage
|
||||
getTableData()
|
||||
void getTableData()
|
||||
}
|
||||
|
||||
// 下载模板
|
||||
const downloadTemplate = async () => {
|
||||
const downloadTemplate = () => {
|
||||
try {
|
||||
const link = document.createElement('a')
|
||||
link.href = new URL('@/template/设备导入模板.xlsx', import.meta.url).href
|
||||
@@ -472,56 +452,49 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 文件选择变化
|
||||
const handleFileChange = (uploadFile: any) => {
|
||||
const maxSize = 300 * 1024 * 1024
|
||||
if (uploadFile.raw && uploadFile.raw.size > maxSize) {
|
||||
const file = uploadFile.raw as File | undefined
|
||||
if (!file) return
|
||||
if (file.size > 300 * 1024 * 1024) {
|
||||
ElMessage.error('文件大小不能超过 300MB')
|
||||
uploadRef.value?.clearFiles()
|
||||
fileList.value = []
|
||||
return
|
||||
}
|
||||
|
||||
if (uploadFile.raw && !uploadFile.raw.name.endsWith('.xlsx')) {
|
||||
ElMessage.error('只能上传 .xlsx 格式的 Excel 文件')
|
||||
if (!file.name.toLowerCase().endsWith('.xlsx')) {
|
||||
ElMessage.error('设备导入只能上传 .xlsx 文件')
|
||||
uploadRef.value?.clearFiles()
|
||||
fileList.value = []
|
||||
return
|
||||
}
|
||||
|
||||
fileList.value = uploadFile.raw ? [uploadFile.raw] : []
|
||||
fileList.value = [file]
|
||||
}
|
||||
|
||||
// 清空文件
|
||||
const clearFiles = () => {
|
||||
uploadRef.value?.clearFiles()
|
||||
fileList.value = []
|
||||
}
|
||||
|
||||
// 生成批次号
|
||||
const handleGenerateBatchNo = () => {
|
||||
const code = generatePackageCode().replace('PKG', 'DEV')
|
||||
importForm.batch_no = code
|
||||
importForm.batch_no = generatePackageCode().replace('PKG', 'DEV')
|
||||
ElMessage.success('批次号生成成功')
|
||||
}
|
||||
|
||||
// 取消导入
|
||||
const handleCancelImport = () => {
|
||||
clearFiles()
|
||||
importForm.batch_no = ''
|
||||
importForm.realname_policy = ''
|
||||
importDialogVisible.value = false
|
||||
}
|
||||
// 提交上传
|
||||
|
||||
const submitUpload = async () => {
|
||||
if (!fileList.value.length) {
|
||||
ElMessage.warning('请先选择 Excel 文件')
|
||||
if (!isPlatformAccount.value || !fileList.value.length) {
|
||||
ElMessage.warning('请先选择文件')
|
||||
return
|
||||
}
|
||||
|
||||
const file = fileList.value[0]
|
||||
uploading.value = true
|
||||
|
||||
try {
|
||||
ElMessage.info('正在准备上传...')
|
||||
const uploadUrlRes = await StorageService.getUploadUrl({
|
||||
@@ -529,14 +502,12 @@
|
||||
content_type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
purpose: 'iot_import'
|
||||
})
|
||||
|
||||
if (uploadUrlRes.code !== 0) {
|
||||
ElMessage.error(uploadUrlRes.msg || '获取上传地址失败')
|
||||
return
|
||||
}
|
||||
|
||||
const { upload_url, file_key } = uploadUrlRes.data
|
||||
|
||||
ElMessage.info('正在上传文件...')
|
||||
await StorageService.uploadFile(
|
||||
upload_url,
|
||||
@@ -544,23 +515,23 @@
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
)
|
||||
|
||||
ElMessage.info('正在创建导入任务...')
|
||||
ElMessage.info('正在创建设备导入任务...')
|
||||
const importRes = await DeviceService.importDevices({
|
||||
file_key,
|
||||
batch_no: importForm.batch_no || undefined,
|
||||
realname_policy: (importForm.realname_policy || undefined) as RealnamePolicy | undefined
|
||||
})
|
||||
|
||||
if (importRes.code !== 0) {
|
||||
ElMessage.error(importRes.msg || '创建导入任务失败')
|
||||
return
|
||||
}
|
||||
|
||||
const taskNo = importRes.data.task_no
|
||||
|
||||
const taskId = importRes.data.task_id
|
||||
handleCancelImport()
|
||||
await router.replace({ path: route.path, query: { task_id: String(taskId) } })
|
||||
await polling.start(taskId)
|
||||
await getTableData()
|
||||
|
||||
ElMessage.success({
|
||||
message: `导入任务已创建!任务编号:${taskNo}`,
|
||||
duration: 3000,
|
||||
@@ -568,66 +539,57 @@
|
||||
})
|
||||
} catch (error: any) {
|
||||
console.error('设备导入失败:', error)
|
||||
console.log(error.message || '设备导入失败')
|
||||
ElMessage.error(normalizeApiError(error).message || error.message || '设备导入失败')
|
||||
} finally {
|
||||
uploading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 从行数据下载失败数据
|
||||
const downloadFailDataByRow = async (row: DeviceImportTask) => {
|
||||
if (!isPlatformAccount.value) return
|
||||
try {
|
||||
const res = await DeviceService.getImportTaskDetail(row.id)
|
||||
if (res.code === 0 && res.data) {
|
||||
const detail = res.data
|
||||
const failReasons =
|
||||
detail.failed_items?.map((item: any) => ({
|
||||
line: item.line || '-',
|
||||
deviceNo: item.virtual_no || '-',
|
||||
message: item.reason || '未知错误'
|
||||
})) || []
|
||||
|
||||
if (failReasons.length === 0) {
|
||||
ElMessage.warning('没有失败数据可下载')
|
||||
return
|
||||
}
|
||||
|
||||
const headers = ['行号', '设备编号', '失败原因']
|
||||
const csvRows = [
|
||||
headers.join(','),
|
||||
...failReasons.map((item: any) =>
|
||||
[item.line, `\t${item.deviceNo}`, `"${item.message}"`].join(',')
|
||||
)
|
||||
]
|
||||
const csvContent = csvRows.join('\n')
|
||||
|
||||
const BOM = '\uFEFF'
|
||||
const blob = new Blob([BOM + csvContent], { type: 'text/csv;charset=utf-8;' })
|
||||
|
||||
const link = document.createElement('a')
|
||||
const url = URL.createObjectURL(blob)
|
||||
link.setAttribute('href', url)
|
||||
link.setAttribute('download', `导入失败数据_${row.batch_no}.csv`)
|
||||
link.style.visibility = 'hidden'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
URL.revokeObjectURL(url)
|
||||
|
||||
ElMessage.success('失败数据下载成功')
|
||||
if (res.code !== 0 || !res.data) return
|
||||
const failReasons =
|
||||
res.data.failed_items?.map((item) => ({
|
||||
line: item.line || '-',
|
||||
deviceNo: item.device_identifier || item.virtual_no || '-',
|
||||
message: item.reason || '未知错误'
|
||||
})) || []
|
||||
if (failReasons.length === 0) {
|
||||
ElMessage.warning('没有失败数据可下载')
|
||||
return
|
||||
}
|
||||
|
||||
const csvRows = [
|
||||
['行号', '设备编号', '失败原因'].join(','),
|
||||
...failReasons.map((item) =>
|
||||
[item.line, `\t${item.deviceNo}`, `"${item.message.replaceAll('"', '""')}"`].join(',')
|
||||
)
|
||||
]
|
||||
const blob = new Blob(['\uFEFF' + csvRows.join('\n')], {
|
||||
type: 'text/csv;charset=utf-8;'
|
||||
})
|
||||
const url = URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.download = `导入失败数据_${row.batch_no}.csv`
|
||||
link.click()
|
||||
URL.revokeObjectURL(url)
|
||||
ElMessage.success('失败数据下载成功')
|
||||
} catch (error) {
|
||||
console.error('下载失败数据失败:', error)
|
||||
ElMessage.error('下载失败数据失败')
|
||||
}
|
||||
}
|
||||
|
||||
const downloadTaskFile = async (row: DeviceImportTask) => {
|
||||
const fileKey = row.file_name?.trim()
|
||||
if (!isPlatformAccount.value) return
|
||||
const fileKey = row.file_key || row.file_name?.trim()
|
||||
if (!fileKey) {
|
||||
ElMessage.warning('当前任务没有可下载的原始文件')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await StorageService.downloadFileByKey(fileKey)
|
||||
ElMessage.success('原始文件下载已开始')
|
||||
@@ -637,19 +599,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 获取操作按钮
|
||||
const getActions = (row: DeviceImportTask) => {
|
||||
if (!isPlatformAccount.value) return []
|
||||
const actions: any[] = []
|
||||
const showDownloadFileAction = false
|
||||
|
||||
if (showDownloadFileAction && row.file_name?.trim() && hasAuth('device_task:download_file')) {
|
||||
actions.push({
|
||||
label: '下载文件',
|
||||
handler: () => downloadTaskFile(row),
|
||||
type: 'primary'
|
||||
})
|
||||
if (row.file_key && hasAuth('device_task:download_file')) {
|
||||
actions.push({ label: '下载文件', handler: () => downloadTaskFile(row), type: 'primary' })
|
||||
}
|
||||
|
||||
if (row.fail_count > 0 && hasAuth('device_task:download_fail_data')) {
|
||||
actions.push({
|
||||
label: '失败数据',
|
||||
@@ -657,13 +612,19 @@
|
||||
type: 'danger'
|
||||
})
|
||||
}
|
||||
|
||||
return actions
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.device-task-page {
|
||||
.task-polling-error {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
:deep(.el-icon--upload) {
|
||||
margin-bottom: 16px;
|
||||
font-size: 67px;
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
</ElDialog>
|
||||
|
||||
<!-- 导入对话框 -->
|
||||
<ElDialog v-model="importDialogVisible" title="批量导入IoT卡" width="700px" align-center>
|
||||
<ElDrawer v-model="importDialogVisible" title="批量导入IoT卡" direction="rtl" size="50%">
|
||||
<ElAlert type="info" :closable="false" style="margin-bottom: 20px">
|
||||
<template #title>
|
||||
<div style="line-height: 1.8">
|
||||
@@ -210,7 +210,7 @@
|
||||
开始导入
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</ElDrawer>
|
||||
</ArtTableFullScreen>
|
||||
</template>
|
||||
|
||||
@@ -329,9 +329,9 @@
|
||||
{
|
||||
label: '创建时间',
|
||||
prop: 'dateRange',
|
||||
type: 'daterange',
|
||||
type: 'datetimerange',
|
||||
config: {
|
||||
type: 'daterange',
|
||||
type: 'datetimerange',
|
||||
startPlaceholder: '开始时间',
|
||||
endPlaceholder: '结束时间',
|
||||
valueFormat: 'YYYY-MM-DDTHH:mm:ssZ'
|
||||
|
||||
@@ -36,8 +36,6 @@
|
||||
:pageSize="pagination.page_size"
|
||||
:total="pagination.total"
|
||||
:marginTop="10"
|
||||
:actions="getActions"
|
||||
:actionsWidth="180"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
>
|
||||
@@ -47,29 +45,31 @@
|
||||
</ArtTable>
|
||||
</ElCard>
|
||||
|
||||
<ElDialog
|
||||
<ElDrawer
|
||||
v-model="createDialogVisible"
|
||||
title="新建订单套餐作废任务"
|
||||
width="560px"
|
||||
direction="rtl"
|
||||
size="40%"
|
||||
:close-on-click-modal="!createDrawerBusy"
|
||||
:close-on-press-escape="!createDrawerBusy"
|
||||
@closed="handleCreateDialogClosed"
|
||||
>
|
||||
<ElForm ref="createFormRef" :model="createForm" :rules="createRules" label-width="100px">
|
||||
<ElForm ref="createFormRef" :model="createForm" :rules="createRules">
|
||||
<ElFormItem label="CSV文件" prop="file">
|
||||
<ElUpload
|
||||
ref="uploadRef"
|
||||
drag
|
||||
:auto-upload="false"
|
||||
:limit="1"
|
||||
accept=".csv,text/csv"
|
||||
:on-change="handleFileChange"
|
||||
:on-remove="handleFileRemove"
|
||||
>
|
||||
<ElIcon class="el-icon--upload"><UploadFilled /></ElIcon>
|
||||
<div class="el-upload__text">将 CSV 文件拖到此处,或<em>点击选择</em></div>
|
||||
<template #tip>
|
||||
<div class="el-upload__tip">仅支持 .csv 文件,必填列:order_no</div>
|
||||
</template>
|
||||
</ElUpload>
|
||||
<VoucherUpload
|
||||
ref="csvUploadRef"
|
||||
v-model="csvFileKeys"
|
||||
voucher-name="CSV文件"
|
||||
:max-count="1"
|
||||
purpose="attachment"
|
||||
:max-size-mb="10"
|
||||
single-column-csv
|
||||
:max-csv-rows="1000"
|
||||
accept=".csv"
|
||||
tip="仅支持 UTF-8 单列 CSV,每行一个订单号,最多 1000 行,最大 10MB"
|
||||
@uploading-change="csvUploading = $event"
|
||||
@files-change="handleCsvFilesChange"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="凭证附件">
|
||||
<VoucherUpload
|
||||
@@ -91,17 +91,19 @@
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
<template #footer>
|
||||
<ElButton @click="createDialogVisible = false">取消</ElButton>
|
||||
<ElButton
|
||||
type="primary"
|
||||
:loading="creating || voucherUploading"
|
||||
:disabled="voucherUploading"
|
||||
@click="handleCreateTask"
|
||||
>
|
||||
{{ voucherUploading ? '凭证上传中...' : '确认创建' }}
|
||||
</ElButton>
|
||||
<div class="drawer-footer">
|
||||
<ElButton @click="createDialogVisible = false">取消</ElButton>
|
||||
<ElButton
|
||||
type="primary"
|
||||
:loading="createDrawerBusy"
|
||||
:disabled="createDrawerBusy"
|
||||
@click="handleCreateTask"
|
||||
>
|
||||
{{ voucherUploading ? '凭证上传中...' : '确认创建' }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</ElDrawer>
|
||||
|
||||
<PaymentVoucherDialog :file-keys="voucherPreviewKeys" @close="voucherPreviewKeys = []" />
|
||||
</div>
|
||||
@@ -109,22 +111,21 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { h, onMounted, reactive, ref } from 'vue'
|
||||
import { computed, h, onMounted, reactive, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import {
|
||||
ElButton,
|
||||
ElCard,
|
||||
ElDrawer,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElIcon,
|
||||
ElInput,
|
||||
ElMessage,
|
||||
ElTag,
|
||||
ElUpload
|
||||
ElTag
|
||||
} from 'element-plus'
|
||||
import { Upload, UploadFilled } from '@element-plus/icons-vue'
|
||||
import type { FormInstance, FormRules, UploadFile, UploadInstance } from 'element-plus'
|
||||
import { OrderPackageInvalidateTaskService, StorageService } from '@/api/modules'
|
||||
import { Upload } from '@element-plus/icons-vue'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { OrderPackageInvalidateTaskService } from '@/api/modules'
|
||||
import type {
|
||||
CreateOrderPackageInvalidateTaskRequest,
|
||||
OrderPackageInvalidateTask,
|
||||
@@ -147,15 +148,20 @@
|
||||
|
||||
const loading = ref(false)
|
||||
const creating = ref(false)
|
||||
const csvUploading = ref(false)
|
||||
const voucherUploading = ref(false)
|
||||
const tableRef = ref()
|
||||
const uploadRef = ref<UploadInstance>()
|
||||
const csvUploadRef = ref<InstanceType<typeof VoucherUpload>>()
|
||||
const voucherUploadRef = ref<InstanceType<typeof VoucherUpload>>()
|
||||
const createFormRef = ref<FormInstance>()
|
||||
const createDialogVisible = ref(false)
|
||||
const selectedFile = ref<File | null>(null)
|
||||
const csvFileKeys = ref<string[]>([])
|
||||
const csvFileName = ref('')
|
||||
const taskList = ref<OrderPackageInvalidateTask[]>([])
|
||||
const voucherPreviewKeys = ref<string[]>([])
|
||||
const createDrawerBusy = computed(
|
||||
() => creating.value || csvUploading.value || voucherUploading.value
|
||||
)
|
||||
|
||||
const searchForm = reactive<OrderPackageInvalidateTaskQueryParams>({
|
||||
page: 1,
|
||||
@@ -384,58 +390,31 @@
|
||||
getTableData()
|
||||
}
|
||||
|
||||
const handleFileChange = (uploadFile: UploadFile) => {
|
||||
const file = uploadFile.raw
|
||||
if (!file) return
|
||||
if (!/\.csv$/i.test(file.name)) {
|
||||
ElMessage.error('仅支持 CSV 文件')
|
||||
uploadRef.value?.clearFiles()
|
||||
selectedFile.value = null
|
||||
createForm.file = ''
|
||||
return
|
||||
}
|
||||
selectedFile.value = file
|
||||
createForm.file = file.name
|
||||
createFormRef.value?.validateField('file')
|
||||
}
|
||||
|
||||
const handleFileRemove = () => {
|
||||
selectedFile.value = null
|
||||
createForm.file = ''
|
||||
createFormRef.value?.validateField('file')
|
||||
}
|
||||
|
||||
const uploadCsvFile = async (file: File) => {
|
||||
const contentType = file.type || 'text/csv'
|
||||
const uploadUrlRes = await StorageService.getUploadUrl({
|
||||
file_name: file.name,
|
||||
content_type: contentType,
|
||||
purpose: 'attachment'
|
||||
})
|
||||
if (uploadUrlRes.code !== 0) {
|
||||
throw new Error(uploadUrlRes.msg || '获取上传地址失败')
|
||||
}
|
||||
|
||||
await StorageService.uploadFile(uploadUrlRes.data.upload_url, file, contentType)
|
||||
return uploadUrlRes.data.file_key
|
||||
const handleCsvFilesChange = (files: Array<{ file_name?: string }>) => {
|
||||
csvFileName.value = files[0]?.file_name || ''
|
||||
createForm.file = csvFileName.value
|
||||
void createFormRef.value?.validateField('file')
|
||||
}
|
||||
|
||||
const handleCreateTask = async () => {
|
||||
if (!createFormRef.value) return
|
||||
if (csvUploading.value) {
|
||||
ElMessage.warning('CSV 文件上传中,请稍候')
|
||||
return
|
||||
}
|
||||
if (voucherUploading.value) {
|
||||
ElMessage.warning('凭证上传中,请稍候')
|
||||
return
|
||||
}
|
||||
|
||||
const valid = await createFormRef.value.validate().catch(() => false)
|
||||
if (!valid || !selectedFile.value) return
|
||||
if (!valid || !csvFileKeys.value[0] || !csvFileName.value) return
|
||||
|
||||
creating.value = true
|
||||
try {
|
||||
const fileKey = await uploadCsvFile(selectedFile.value)
|
||||
const data: CreateOrderPackageInvalidateTaskRequest = {
|
||||
file_key: fileKey,
|
||||
file_name: selectedFile.value.name,
|
||||
file_key: csvFileKeys.value[0],
|
||||
file_name: csvFileName.value,
|
||||
voucher_keys: toVoucherKeyList(createForm.voucher_keys),
|
||||
remark: createForm.remark || undefined
|
||||
}
|
||||
@@ -453,24 +432,26 @@
|
||||
|
||||
const handleCreateDialogClosed = () => {
|
||||
createFormRef.value?.resetFields()
|
||||
uploadRef.value?.clearFiles()
|
||||
csvUploadRef.value?.clearFiles(false)
|
||||
voucherUploadRef.value?.clearFiles(false)
|
||||
selectedFile.value = null
|
||||
csvFileKeys.value = []
|
||||
csvFileName.value = ''
|
||||
createForm.file = ''
|
||||
createForm.voucher_keys = []
|
||||
createForm.remark = ''
|
||||
csvUploading.value = false
|
||||
voucherUploading.value = false
|
||||
}
|
||||
|
||||
const getActions = (row: OrderPackageInvalidateTask) => {
|
||||
const actions: any[] = []
|
||||
if (hasAuth('order_package_invalidate_task:detail')) {
|
||||
actions.push({ label: '详情', handler: () => handleNameClick(row), type: 'primary' })
|
||||
}
|
||||
return actions
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getTableData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.drawer-footer {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
<ArtTableFullScreen>
|
||||
<div class="task-detail-page" id="table-full-screen">
|
||||
<ElCard shadow="never" class="art-table-card">
|
||||
<!-- 页面头部 -->
|
||||
<div class="detail-header">
|
||||
<ElButton @click="goBack">
|
||||
<template #icon>
|
||||
@@ -10,35 +9,59 @@
|
||||
</template>
|
||||
返回
|
||||
</ElButton>
|
||||
<h2 class="detail-title">任务详情</h2>
|
||||
<h2 class="detail-title">{{ taskTitle }}</h2>
|
||||
</div>
|
||||
|
||||
<!-- 使用 DetailPage 组件显示任务信息 -->
|
||||
<DetailPage v-if="taskDetail" :sections="detailSections" :data="taskDetail" />
|
||||
|
||||
<!-- 失败记录 -->
|
||||
<div class="failure-section" v-if="taskDetail?.fail_count && taskDetail.fail_count > 0">
|
||||
<div v-if="taskDetail?.fail_count && taskDetail.fail_count > 0" class="result-section">
|
||||
<ElDivider content-position="left">
|
||||
<span class="section-title">失败记录 ({{ taskDetail.fail_count }})</span>
|
||||
<span class="section-title"
|
||||
>{{ resultAction }}失败记录 ({{ taskDetail.fail_count }})</span
|
||||
>
|
||||
</ElDivider>
|
||||
<ElTable :data="taskDetail.failed_items || []" border style="width: 100%">
|
||||
<ElTableColumn prop="line" label="行号" width="100" />
|
||||
<ElTableColumn v-if="taskType === 'card'" prop="iccid" label="ICCID" min-width="180" />
|
||||
<ElTableColumn v-else prop="virtual_no" label="设备号" min-width="180" />
|
||||
<ElTableColumn prop="reason" label="失败原因" min-width="300" />
|
||||
<ElTableColumn v-else label="设备标识" min-width="180" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
{{ scope.row.device_identifier || scope.row.virtual_no || '-' }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="reason" :label="`${resultAction}失败原因`" min-width="300" />
|
||||
</ElTable>
|
||||
</div>
|
||||
|
||||
<!-- 跳过记录 -->
|
||||
<div class="skipped-section" v-if="taskDetail?.skip_count && taskDetail.skip_count > 0">
|
||||
<div v-if="taskDetail?.skip_count && taskDetail.skip_count > 0" class="result-section">
|
||||
<ElDivider content-position="left">
|
||||
<span class="section-title">跳过记录 ({{ taskDetail.skip_count }})</span>
|
||||
<span class="section-title"
|
||||
>{{ resultAction }}跳过记录 ({{ taskDetail.skip_count }})</span
|
||||
>
|
||||
</ElDivider>
|
||||
<ElTable :data="taskDetail.skipped_items || []" border style="width: 100%">
|
||||
<ElTableColumn prop="line" label="行号" width="100" />
|
||||
<ElTableColumn v-if="taskType === 'card'" prop="iccid" label="ICCID" min-width="180" />
|
||||
<ElTableColumn v-else prop="virtual_no" label="设备号" min-width="180" />
|
||||
<ElTableColumn prop="reason" label="跳过原因" min-width="300" />
|
||||
<ElTableColumn v-else label="设备标识" min-width="180" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
{{ scope.row.device_identifier || scope.row.virtual_no || '-' }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="reason" :label="`${resultAction}跳过原因`" min-width="300" />
|
||||
</ElTable>
|
||||
</div>
|
||||
|
||||
<div v-if="warningCount > 0" class="result-section">
|
||||
<ElDivider content-position="left">
|
||||
<span class="section-title">{{ resultAction }}警告记录 ({{ warningCount }})</span>
|
||||
</ElDivider>
|
||||
<ElTable :data="warningItems" border style="width: 100%">
|
||||
<ElTableColumn prop="line" label="行号" width="100" />
|
||||
<ElTableColumn label="设备标识" min-width="180" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
{{ scope.row.device_identifier || scope.row.virtual_no || '-' }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="reason" label="警告原因" min-width="300" />
|
||||
</ElTable>
|
||||
</div>
|
||||
</ElCard>
|
||||
@@ -47,34 +70,77 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, h } from 'vue'
|
||||
import { computed, h, onMounted, ref } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { CardService, DeviceService } from '@/api/modules'
|
||||
import { ElDivider, ElIcon, ElMessage, ElTable, ElTableColumn, ElTag } from 'element-plus'
|
||||
import type { TagProps } from 'element-plus'
|
||||
import { ArrowLeft } from '@element-plus/icons-vue'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
import type { IotCardImportTaskDetail } from '@/types/api/card'
|
||||
import type { DeviceImportTaskDetail } from '@/types/api/device'
|
||||
import type { DeviceImportTaskDetail, DeviceImportTaskOperationType } from '@/types/api/device'
|
||||
import type { DetailSection } from '@/components/common/DetailPage.vue'
|
||||
import DetailPage from '@/components/common/DetailPage.vue'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
|
||||
defineOptions({ name: 'TaskDetail' })
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const userStore = useUserStore()
|
||||
const isPlatformAccount = computed(() => [1, 2].includes(Number(userStore.info.user_type)))
|
||||
|
||||
type TaskType = 'card' | 'device'
|
||||
type TaskDetail = IotCardImportTaskDetail | DeviceImportTaskDetail
|
||||
|
||||
const taskDetail = ref<TaskDetail | null>(null)
|
||||
const loading = ref(false)
|
||||
const taskType = ref<TaskType>('card')
|
||||
const loading = ref(false)
|
||||
|
||||
const getOperationLabel = (operationType?: DeviceImportTaskOperationType) => {
|
||||
switch (operationType) {
|
||||
case 'assign_shop':
|
||||
return '分配目标代理'
|
||||
case 'assign_series':
|
||||
return '设置套餐系列'
|
||||
case 'recall':
|
||||
return '批量回收设备'
|
||||
case 'import':
|
||||
return '导入设备'
|
||||
default:
|
||||
return '设备任务'
|
||||
}
|
||||
}
|
||||
|
||||
const deviceTask = computed(() =>
|
||||
taskType.value === 'device' ? (taskDetail.value as DeviceImportTaskDetail | null) : null
|
||||
)
|
||||
const taskTitle = computed(() =>
|
||||
taskType.value === 'device'
|
||||
? `${getOperationLabel(deviceTask.value?.operation_type)}任务详情`
|
||||
: 'ICCID导入任务详情'
|
||||
)
|
||||
const resultAction = computed(() => {
|
||||
if (taskType.value !== 'device') return '导入'
|
||||
switch (deviceTask.value?.operation_type) {
|
||||
case 'assign_shop':
|
||||
return '分配'
|
||||
case 'assign_series':
|
||||
return '设置套餐系列'
|
||||
case 'recall':
|
||||
return '回收'
|
||||
default:
|
||||
return '导入'
|
||||
}
|
||||
})
|
||||
const warningCount = computed(() =>
|
||||
taskType.value === 'device' ? deviceTask.value?.warning_count || 0 : 0
|
||||
)
|
||||
const warningItems = computed(() =>
|
||||
taskType.value === 'device' ? deviceTask.value?.warning_items || [] : []
|
||||
)
|
||||
|
||||
// 获取状态标签类型
|
||||
const getStatusType = (status?: number): TagProps['type'] => {
|
||||
if (!status) return 'info'
|
||||
switch (status) {
|
||||
case 1:
|
||||
return 'info'
|
||||
@@ -89,8 +155,54 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 详情页配置
|
||||
const detailSections = computed((): DetailSection[] => {
|
||||
const deviceFields: DetailSection['fields'] =
|
||||
taskType.value === 'device'
|
||||
? [
|
||||
{
|
||||
label: '操作名称',
|
||||
prop: 'operation_name',
|
||||
formatter: (value: string) =>
|
||||
value || getOperationLabel(deviceTask.value?.operation_type)
|
||||
},
|
||||
{
|
||||
label: '目标名称',
|
||||
prop: 'target_name',
|
||||
formatter: (value: string | null | undefined) => value || '-'
|
||||
}
|
||||
]
|
||||
: []
|
||||
|
||||
const cardFields: DetailSection['fields'] =
|
||||
taskType.value === 'card'
|
||||
? [
|
||||
{
|
||||
label: '运营商',
|
||||
prop: 'carrier_name',
|
||||
formatter: (value: string) => value || '-'
|
||||
},
|
||||
{
|
||||
label: '卡业务类型',
|
||||
render: (data: any) => {
|
||||
if (!data.card_category) return h('span', '-')
|
||||
return h(
|
||||
ElTag,
|
||||
{
|
||||
type: data.card_category === 'industry' ? 'warning' : 'success',
|
||||
size: 'small'
|
||||
},
|
||||
() =>
|
||||
data.card_category === 'normal'
|
||||
? '普通卡'
|
||||
: data.card_category === 'industry'
|
||||
? '行业卡'
|
||||
: data.card_category
|
||||
)
|
||||
}
|
||||
}
|
||||
]
|
||||
: []
|
||||
|
||||
return [
|
||||
{
|
||||
title: '任务基本信息',
|
||||
@@ -98,69 +210,44 @@
|
||||
{ label: '任务编号', prop: 'task_no', formatter: (value: string) => value || '-' },
|
||||
{
|
||||
label: '任务类型',
|
||||
render: () => {
|
||||
return h(
|
||||
render: () =>
|
||||
h(
|
||||
ElTag,
|
||||
{ type: taskType.value === 'device' ? 'warning' : 'primary', size: 'small' },
|
||||
() => (taskType.value === 'device' ? '设备导入' : 'ICCID导入')
|
||||
() =>
|
||||
taskType.value === 'device'
|
||||
? getOperationLabel(deviceTask.value?.operation_type)
|
||||
: 'ICCID导入'
|
||||
)
|
||||
}
|
||||
},
|
||||
...deviceFields,
|
||||
{ label: '批次号', prop: 'batch_no', formatter: (value: string) => value || '-' },
|
||||
{ label: '文件名', prop: 'file_name', formatter: (value: string) => value || '-' },
|
||||
{
|
||||
label: '操作人',
|
||||
prop: 'creator_name',
|
||||
formatter: (value: string) => value || '-'
|
||||
},
|
||||
{ label: '操作人', prop: 'creator_name', formatter: (value: string) => value || '-' },
|
||||
{
|
||||
label: '任务状态',
|
||||
render: (data: TaskDetail) => {
|
||||
return h(ElTag, { type: getStatusType(data.status) }, () => data.status_text)
|
||||
}
|
||||
render: (data: TaskDetail) =>
|
||||
h(
|
||||
ElTag,
|
||||
{ type: getStatusType(data.status) },
|
||||
() => (data as DeviceImportTaskDetail).status_name || data.status_text || '-'
|
||||
)
|
||||
},
|
||||
...(taskType.value === 'card'
|
||||
? [
|
||||
{
|
||||
label: '运营商',
|
||||
prop: 'carrier_name',
|
||||
formatter: (value: any) => value || '-'
|
||||
},
|
||||
{
|
||||
label: '卡业务类型',
|
||||
render: (data: any) => {
|
||||
if (!data.card_category) return h('span', '-')
|
||||
return h(
|
||||
ElTag,
|
||||
{
|
||||
type: data.card_category === 'industry' ? 'warning' : 'success',
|
||||
size: 'small'
|
||||
},
|
||||
() =>
|
||||
data.card_category === 'normal'
|
||||
? '普通卡'
|
||||
: data.card_category === 'industry'
|
||||
? '行业卡'
|
||||
: data.card_category
|
||||
)
|
||||
}
|
||||
}
|
||||
]
|
||||
: []),
|
||||
...cardFields,
|
||||
{
|
||||
label: '创建时间',
|
||||
prop: 'created_at',
|
||||
formatter: (value: Date) => (value ? formatDateTime(value) : '-')
|
||||
formatter: (value: string) => (value ? formatDateTime(value) : '-')
|
||||
},
|
||||
{
|
||||
label: '开始处理时间',
|
||||
prop: 'started_at',
|
||||
formatter: (value: Date) => (value ? formatDateTime(value) : '-')
|
||||
formatter: (value: string | null) => (value ? formatDateTime(value) : '-')
|
||||
},
|
||||
{
|
||||
label: '完成时间',
|
||||
prop: 'completed_at',
|
||||
formatter: (value: Date) => (value ? formatDateTime(value) : '-')
|
||||
formatter: (value: string | null) => (value ? formatDateTime(value) : '-')
|
||||
},
|
||||
...(taskDetail.value?.error_message
|
||||
? [
|
||||
@@ -168,13 +255,12 @@
|
||||
label: '错误信息',
|
||||
prop: 'error_message',
|
||||
fullWidth: true,
|
||||
render: (data: TaskDetail) => {
|
||||
return h(
|
||||
render: (data: TaskDetail) =>
|
||||
h(
|
||||
'span',
|
||||
{ style: { color: 'var(--el-color-danger)' } },
|
||||
data.error_message || ''
|
||||
)
|
||||
}
|
||||
}
|
||||
]
|
||||
: [])
|
||||
@@ -186,89 +272,82 @@
|
||||
fields: [
|
||||
{
|
||||
label: '总数',
|
||||
render: (data: TaskDetail) => {
|
||||
return h(
|
||||
render: (data: TaskDetail) =>
|
||||
h(
|
||||
'span',
|
||||
{
|
||||
style: {
|
||||
fontSize: '16px',
|
||||
fontWeight: 'bold',
|
||||
color: 'var(--el-color-primary)'
|
||||
}
|
||||
style: { fontSize: '16px', fontWeight: 'bold', color: 'var(--el-color-primary)' }
|
||||
},
|
||||
String(data.total_count || 0)
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '成功数',
|
||||
render: (data: TaskDetail) => {
|
||||
return h(ElTag, { type: 'success' }, () => String(data.success_count || 0))
|
||||
}
|
||||
render: (data: TaskDetail) =>
|
||||
h(ElTag, { type: 'success' }, () => String(data.success_count || 0))
|
||||
},
|
||||
{
|
||||
label: '失败数',
|
||||
render: (data: TaskDetail) => {
|
||||
return h(ElTag, { type: 'danger' }, () => String(data.fail_count || 0))
|
||||
}
|
||||
render: (data: TaskDetail) =>
|
||||
h(ElTag, { type: 'danger' }, () => String(data.fail_count || 0))
|
||||
},
|
||||
{
|
||||
label: '跳过数',
|
||||
render: (data: TaskDetail) => {
|
||||
return h(ElTag, { type: 'warning' }, () => String(data.skip_count || 0))
|
||||
}
|
||||
}
|
||||
render: (data: TaskDetail) =>
|
||||
h(ElTag, { type: 'warning' }, () => String(data.skip_count || 0))
|
||||
},
|
||||
...(taskType.value === 'device'
|
||||
? [
|
||||
{
|
||||
label: '警告数',
|
||||
render: (data: TaskDetail) =>
|
||||
h(ElTag, { type: 'info' }, () =>
|
||||
String((data as DeviceImportTaskDetail).warning_count || 0)
|
||||
)
|
||||
}
|
||||
]
|
||||
: [])
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
// 返回列表
|
||||
const goBack = () => {
|
||||
router.back()
|
||||
}
|
||||
const goBack = () => router.back()
|
||||
|
||||
// 获取任务详情
|
||||
const getTaskDetail = async () => {
|
||||
const taskId = route.query.id
|
||||
const queryTaskType = route.query.task_type as TaskType | undefined
|
||||
|
||||
if (!taskId) {
|
||||
ElMessage.error('缺少任务ID参数')
|
||||
ElMessage.error('缺少任务 ID 参数')
|
||||
goBack()
|
||||
return
|
||||
}
|
||||
|
||||
// 设置任务类型
|
||||
if (queryTaskType) {
|
||||
taskType.value = queryTaskType
|
||||
if (queryTaskType) taskType.value = queryTaskType
|
||||
if (taskType.value === 'device' && !isPlatformAccount.value) {
|
||||
ElMessage.error('当前账号无权查看设备任务详情')
|
||||
goBack()
|
||||
return
|
||||
}
|
||||
|
||||
loading.value = true
|
||||
try {
|
||||
if (taskType.value === 'device') {
|
||||
// 获取设备导入任务详情
|
||||
const res = await DeviceService.getImportTaskDetail(Number(taskId))
|
||||
if (res.code === 0) {
|
||||
taskDetail.value = res.data
|
||||
}
|
||||
if (res.code === 0) taskDetail.value = res.data
|
||||
} else {
|
||||
// 获取ICCID导入任务详情
|
||||
const res = await CardService.getIotCardImportTaskDetail(Number(taskId))
|
||||
if (res.code === 0) {
|
||||
taskDetail.value = res.data
|
||||
}
|
||||
if (res.code === 0) taskDetail.value = res.data
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
console.log('获取任务详情失败')
|
||||
console.error('获取任务详情失败:', error)
|
||||
ElMessage.error('获取任务详情失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getTaskDetail()
|
||||
void getTaskDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -288,8 +367,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
.failure-section,
|
||||
.skipped-section {
|
||||
.result-section {
|
||||
margin-top: 20px;
|
||||
|
||||
.section-title {
|
||||
|
||||
Reference in New Issue
Block a user