- 新增采集成功/失败记录、卡日流量、套餐日流量详单、冲正流水、退款后处理尝试记录 6 个查询页 - 资产详情新增采集记录、冲正记录与人工冲正,同步后展示本次流量入账结果 - 退款列表与详情展示资产后处理状态,支持按状态筛选、人工重试与查看尝试记录 - 新增前端权限码常量(需在 tb_permission 补数据)
This commit is contained in:
@@ -0,0 +1,233 @@
|
||||
<template>
|
||||
<div class="traffic-records">
|
||||
<ArtSearchBar
|
||||
v-if="!isFixed"
|
||||
:filter="filters"
|
||||
:items="searchItems"
|
||||
:show-expand="true"
|
||||
label-width="120px"
|
||||
@update:filter="(value: Record<string, unknown>) => Object.assign(filters, value)"
|
||||
@search="search"
|
||||
@reset="reset"
|
||||
/>
|
||||
<component :is="isFixed ? 'div' : ElCard" shadow="never">
|
||||
<RecordTableShell
|
||||
:error="error"
|
||||
:hint="hint"
|
||||
:page="pagination.page"
|
||||
:page-size="pagination.page_size"
|
||||
:total="total"
|
||||
@page-change="changePage"
|
||||
@size-change="changeSize"
|
||||
>
|
||||
<ElTable
|
||||
v-loading="loading"
|
||||
:data="rows"
|
||||
row-key="id"
|
||||
border
|
||||
:max-height="isFixed ? 460 : undefined"
|
||||
empty-text="暂无冲正记录"
|
||||
>
|
||||
<ElTableColumn label="冲正时间" min-width="170">
|
||||
<template #default="{ row }">{{ formatDateTime(row.created_at) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
v-if="!isFixed"
|
||||
label="套餐使用记录ID"
|
||||
prop="package_usage_id"
|
||||
min-width="130"
|
||||
/>
|
||||
<ElTableColumn v-if="!isFixed" label="卡ID / 设备ID" min-width="120">
|
||||
<template #default="{ row }">
|
||||
{{
|
||||
row.iot_card_id
|
||||
? `卡 ${row.iot_card_id}`
|
||||
: row.device_id
|
||||
? `设备 ${row.device_id}`
|
||||
: '-'
|
||||
}}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="调整量" min-width="110">
|
||||
<template #default="{ row }">
|
||||
<span :class="row.delta_mb > 0 ? 'delta-deduct' : 'delta-refund'">
|
||||
{{ row.delta_mb > 0 ? '补扣' : '退回' }} {{ formatMb(Math.abs(row.delta_mb)) }}
|
||||
</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="已用量变化" min-width="170">
|
||||
<template #default="{ row }">
|
||||
{{ formatMb(row.before_usage_mb) }} → {{ formatMb(row.after_usage_mb) }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="套餐状态变化" min-width="140">
|
||||
<template #default="{ row }">
|
||||
{{ statusName(row.before_status) }} → {{ statusName(row.after_status) }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="原因" prop="reason" min-width="200" show-overflow-tooltip />
|
||||
<ElTableColumn label="操作人ID" prop="operator_id" width="100" />
|
||||
<ElTableColumn
|
||||
label="关联采集 ID"
|
||||
prop="ref_observation_id"
|
||||
min-width="180"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<ElTableColumn
|
||||
label="关联流量事件 ID"
|
||||
prop="ref_event_id"
|
||||
min-width="180"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
</ElTable>
|
||||
</RecordTableShell>
|
||||
</component>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive, watch } from 'vue'
|
||||
import { ElCard } from 'element-plus'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { TrafficRecordsService } from '@/api/modules/trafficRecords'
|
||||
import { useRecordList } from '@/composables/useRecordList'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import type { SearchFormItem } from '@/types'
|
||||
import type { PackageTrafficAdjustment } from '@/types/api/trafficRecords'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
import { ADJUSTMENT_DIRECTION_OPTIONS } from '@/config/constants/trafficRecords'
|
||||
import {
|
||||
compactQuery,
|
||||
formatMb,
|
||||
optionalPositiveInt,
|
||||
recentTimeRange,
|
||||
requireIdentifierForNonPlatform,
|
||||
toTimeQuery
|
||||
} from '@/utils/business/trafficRecords'
|
||||
import RecordTableShell from './RecordTableShell.vue'
|
||||
|
||||
/** 传入 identifier + packageUsageId 时为资产详情里的单笔套餐冲正记录 */
|
||||
const props = defineProps<{ identifier?: string; packageUsageId?: number }>()
|
||||
const isFixed = computed(() => !!props.identifier && !!props.packageUsageId)
|
||||
const hint = computed(() =>
|
||||
isFixed.value
|
||||
? '按时间倒序展示该套餐的全部冲正记录。'
|
||||
: '时间跨度不超过 31 天,结束时间不含。补扣为正数、退回为负数。不填资产标识查全部仅平台账号可用。'
|
||||
)
|
||||
|
||||
const PACKAGE_STATUS_NAMES: Record<number, string> = {
|
||||
0: '待生效',
|
||||
1: '生效中',
|
||||
2: '已用完',
|
||||
3: '已过期',
|
||||
4: '已失效'
|
||||
}
|
||||
const statusName = (status?: number) =>
|
||||
status === undefined || status === null ? '-' : PACKAGE_STATUS_NAMES[status] || String(status)
|
||||
|
||||
const { info: userInfo } = storeToRefs(useUserStore())
|
||||
const emptyFilters = () => ({
|
||||
identifier: '',
|
||||
package_usage_id: '',
|
||||
operator_id: '',
|
||||
direction: '',
|
||||
range: recentTimeRange(7) as [string, string] | null
|
||||
})
|
||||
const filters = reactive(emptyFilters())
|
||||
|
||||
const { rows, total, loading, error, pagination, load, search, changePage, changeSize, clear } =
|
||||
useRecordList<PackageTrafficAdjustment>((page) => {
|
||||
if (isFixed.value) {
|
||||
return TrafficRecordsService.getAssetPackageAdjustments(
|
||||
props.identifier!,
|
||||
props.packageUsageId!,
|
||||
page
|
||||
)
|
||||
}
|
||||
const identifier = filters.identifier.trim()
|
||||
const packageUsageId = optionalPositiveInt(filters.package_usage_id, '套餐使用记录 ID')
|
||||
if (packageUsageId === undefined) {
|
||||
requireIdentifierForNonPlatform(identifier, userInfo.value.user_type)
|
||||
}
|
||||
return TrafficRecordsService.getTrafficAdjustments(
|
||||
compactQuery({
|
||||
...page,
|
||||
...toTimeQuery(filters.range),
|
||||
identifier,
|
||||
package_usage_id: packageUsageId,
|
||||
operator_id: optionalPositiveInt(filters.operator_id, '操作人账号 ID'),
|
||||
direction: filters.direction as 'deduct' | 'refund' | ''
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
const searchItems: SearchFormItem[] = [
|
||||
{
|
||||
label: '资产标识',
|
||||
prop: 'identifier',
|
||||
type: 'input',
|
||||
config: { clearable: true, maxlength: 64, placeholder: 'ICCID / 虚拟号 / MSISDN / IMEI / SN' }
|
||||
},
|
||||
{
|
||||
label: '冲正时间',
|
||||
prop: 'range',
|
||||
type: 'datetimerange',
|
||||
config: {
|
||||
type: 'datetimerange',
|
||||
rangeSeparator: '至',
|
||||
startPlaceholder: '开始时间',
|
||||
endPlaceholder: '结束时间',
|
||||
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||
clearable: false
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '套餐使用记录ID',
|
||||
prop: 'package_usage_id',
|
||||
type: 'input',
|
||||
config: { clearable: true }
|
||||
},
|
||||
{ label: '操作人账号ID', prop: 'operator_id', type: 'input', config: { clearable: true } },
|
||||
{
|
||||
label: '调整方向',
|
||||
prop: 'direction',
|
||||
type: 'select',
|
||||
options: ADJUSTMENT_DIRECTION_OPTIONS,
|
||||
config: { clearable: true }
|
||||
}
|
||||
]
|
||||
|
||||
function reset() {
|
||||
Object.assign(filters, emptyFilters())
|
||||
void search()
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [props.identifier, props.packageUsageId],
|
||||
() => {
|
||||
clear()
|
||||
pagination.page = 1
|
||||
void load()
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
defineExpose({ reload: load })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.traffic-records {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.delta-deduct {
|
||||
color: var(--el-color-danger);
|
||||
}
|
||||
|
||||
.delta-refund {
|
||||
color: var(--el-color-success);
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user