Some checks failed
构建并部署前端到测试环境 / deploy (push) Failing after 4m30s
- 套餐日流量详单按套餐名称搜索选择,操作人按账号用户名搜索选择 - 去掉套餐使用记录ID、退款单ID 等手填 ID 的筛选与列;从退款详情进入时仍按该退款单过滤
227 lines
7.1 KiB
Vue
227 lines
7.1 KiB
Vue
<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="ICCID / 设备号"
|
|
min-width="200"
|
|
show-overflow-tooltip
|
|
>
|
|
<template #default="{ row }">{{ assetDisplay(row) }}</template>
|
|
</ElTableColumn>
|
|
<ElTableColumn v-if="!isFixed" label="套餐" min-width="180" show-overflow-tooltip>
|
|
<template #default="{ row }">{{ row.package_name || '-' }}</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="操作人" min-width="120">
|
|
<template #default="{ row }">{{
|
|
nameOrId(row.operator_name, row.operator_id, '账号ID')
|
|
}}</template>
|
|
</ElTableColumn>
|
|
<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,
|
|
assetDisplay,
|
|
formatMb,
|
|
nameOrId,
|
|
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: '',
|
|
operator_id: undefined as number | undefined,
|
|
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()
|
|
requireIdentifierForNonPlatform(identifier, userInfo.value.user_type)
|
|
return TrafficRecordsService.getTrafficAdjustments(
|
|
compactQuery({
|
|
...page,
|
|
...toTimeQuery(filters.range),
|
|
identifier,
|
|
operator_id: filters.operator_id || undefined,
|
|
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: '操作人',
|
|
prop: 'operator_id',
|
|
type: 'business-select',
|
|
config: { entity: 'account', placeholder: '输入账号用户名搜索' }
|
|
},
|
|
{
|
|
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>
|