Issue#6·B3: 短信下行明细页实装(契约 #p-acct 表格范式)——单卡一体:筛选区常驻5项(批次ID精确/手机号模糊/状态6态/通道下拉/搜索重置)+展开区5项(内容/运营商/详细状态raw_code/起止时间datetime-local);9列原生 table(批次ID可点钻入/账号主副两行/手机掩码+通道名·码号/内容truncate/三时间segmentDurations/条数·耗时右对齐/状态badge原始码优先绿红橙灰/来源/CallData mono)+分页条;批次钻入链:表内点击+/record/detail redirect query.batch_id 双入口预填收敛+徽标可×清除;复用B1逻辑层sms.ts封装(fetchDownlinkDetails/DOWNLINK_STATUS_OPTIONS/segmentDurations);验收=vue-tsc 0+Chrome冒烟6/6(入口/9列/时间范围/真实206万条/钻入/状态筛选)
This commit is contained in:
@@ -48,7 +48,7 @@ export const asyncRoutes: RouteRecordRaw[] = [
|
||||
{ path: 'sms/timer', name: 'sms-timer', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '定时任务', icon: 'i-clock', menu: true, group: '业务中心', roles: ['admin', 'ops', 'service', 'group', 'customer'] } },
|
||||
{ path: 'sms/result', name: 'sms-result', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '发送结果反馈', icon: 'i-check', menu: true, group: '业务中心', roles: ['admin', 'ops', 'service', 'group', 'customer'] } },
|
||||
{ path: 'sms/template', name: 'sms-template', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '模板管理', icon: 'i-sms', menu: true, group: '业务中心', roles: ['admin', 'ops', 'service', 'group', 'customer'] } },
|
||||
{ path: 'sms/downlink-detail', name: 'sms-downlink-detail', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '短信下行明细', icon: 'i-sms', menu: true, group: '记录中心', roles: ['admin', 'ops', 'service', 'group', 'customer'] } },
|
||||
{ path: 'sms/downlink-detail', name: 'sms-downlink-detail', component: () => import('@/views/sms/DownlinkDetailView.vue'), meta: { title: '短信下行明细', icon: 'i-sms', menu: true, group: '记录中心', roles: ['admin', 'ops', 'service', 'group', 'customer'] } },
|
||||
{ path: 'video', name: 'video', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '视频业务', icon: 'i-zap', menu: true, group: '业务中心', roles: ['admin', 'ops'] } },
|
||||
{ path: 'csp', name: 'csp', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: 'CSP业务', icon: 'i-sms', menu: true, group: '业务中心', roles: ['admin', 'ops'] } },
|
||||
{ path: 'nullfilter', name: 'nullfilter', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '空号业务', icon: 'i-warn', menu: true, group: '业务中心', roles: ['admin', 'ops'] } },
|
||||
|
||||
@@ -0,0 +1,198 @@
|
||||
<template>
|
||||
<!-- 契约表格范式(#p-acct 单卡一体):筛选区+原生 table+分页;批次钻入链(record/detail redirect 带 batch_id 进来)onMounted 预填 -->
|
||||
<div>
|
||||
<div class="page-header flex items-end justify-between">
|
||||
<div>
|
||||
<h2 class="page-title">短信下行明细</h2>
|
||||
<p class="page-description">号码级发送明细 · 共 {{ total }} 条</p>
|
||||
</div>
|
||||
<span v-if="drilledBatch" class="badge badge-primary">批次钻入 #{{ drilledBatch }}<button class="ml-1 cursor-pointer hover:text-red-500" @click="clearDrill">×</button></span>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<!-- 筛选区:常驻 5 控件 + 展开 5 控件 -->
|
||||
<div class="flex flex-wrap items-center gap-2 border-b border-gray-100 p-4 dark:border-dark-700">
|
||||
<input v-model="filter.batch_id" class="input !w-36" placeholder="批次ID 精确" @keyup.enter="search" />
|
||||
<input v-model="filter.mobile" class="input !w-40" placeholder="手机号 模糊:135****0000" @keyup.enter="search" />
|
||||
<select v-model="filter.status" class="input !w-36" @change="search">
|
||||
<option value="">状态:全部</option>
|
||||
<option v-for="o in DOWNLINK_STATUS_OPTIONS" :key="o.value" :value="o.value">{{ o.label }}</option>
|
||||
</select>
|
||||
<select v-model="filter.channel_id" class="input !w-44" @change="search">
|
||||
<option value="">通道:全部</option>
|
||||
<option v-for="c in channelOptions" :key="c.id" :value="c.id">{{ c.name }}({{ c.protocol.toUpperCase() }})</option>
|
||||
</select>
|
||||
<button class="btn btn-primary" @click="search">搜索</button>
|
||||
<button class="btn btn-secondary" @click="reset">重置</button>
|
||||
<button class="cursor-pointer text-sm text-primary-600 hover:underline" @click="expanded = !expanded">{{ expanded ? '收起 ▴' : '展开 ▾' }}</button>
|
||||
</div>
|
||||
<div v-show="expanded" class="flex flex-wrap items-center gap-2 border-b border-gray-100 bg-gray-50/50 p-4 dark:border-dark-700 dark:bg-dark-800/30">
|
||||
<input v-model="filter.content" class="input !w-40" placeholder="发送内容 模糊:验证码" @keyup.enter="search" />
|
||||
<select v-model="filter.carrier" class="input !w-28" @change="search">
|
||||
<option value="">运营商:全部</option>
|
||||
<option value="移动">移动</option><option value="联通">联通</option><option value="电信">电信</option>
|
||||
</select>
|
||||
<input v-model="filter.raw_code" class="input !w-32" placeholder="详细状态:DELIVRD" @keyup.enter="search" />
|
||||
<input v-model="filter.startTime" type="datetime-local" class="input !w-52" @change="search" />
|
||||
<span class="text-xs text-gray-400">至</span>
|
||||
<input v-model="filter.endTime" type="datetime-local" class="input !w-52" @change="search" />
|
||||
</div>
|
||||
|
||||
<!-- 表格 9 列 -->
|
||||
<div class="table-container m-4 mt-0 border-0">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>批次</th><th>账号</th><th>手机 / 通道</th><th>发送内容</th>
|
||||
<th>时间</th><th class="text-right">条数 · 耗时</th><th>状态</th><th>来源</th><th>CallData</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="r in rows" :key="`${r.batch_id}-${r.mobile}-${r.created_at}`">
|
||||
<td><span class="cursor-pointer font-mono text-xs text-primary-600 hover:underline" @click="drill(r.batch_id)">{{ r.batch_id }}</span></td>
|
||||
<td>
|
||||
<div class="text-sm text-gray-900 dark:text-white">{{ r.account_name }}</div>
|
||||
<div class="text-xs text-gray-400">{{ r.account_sub || '—' }}</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="font-mono text-xs">{{ maskMobile(r.mobile) }}</div>
|
||||
<div class="text-xs text-gray-400">{{ r.channel_name }} · {{ r.channel_number }}</div>
|
||||
</td>
|
||||
<td><div class="max-w-44 truncate text-sm text-gray-500" :title="r.content">{{ r.content }}</div></td>
|
||||
<td>
|
||||
<div class="text-xs">{{ fmt(r.created_at) }}</div>
|
||||
<div class="text-xs text-gray-400">{{ segmentDurations(r) }}</div>
|
||||
</td>
|
||||
<td class="text-right text-sm">{{ r.fee }} 条 <span class="text-xs text-gray-400">· {{ r.duration_s != null ? r.duration_s + 's' : '—' }}</span></td>
|
||||
<td><span class="badge" :class="statusClass(r)">{{ r.raw_code || downlinkStatusText(r.status) }}</span></td>
|
||||
<td><span class="text-xs text-gray-500">{{ sourceText(r.source) }}</span></td>
|
||||
<td><span class="font-mono text-xs text-gray-400">{{ r.call_data || '—' }}</span></td>
|
||||
</tr>
|
||||
<tr v-if="!loading && rows.length === 0">
|
||||
<td colspan="9" class="py-10 text-center text-sm text-gray-400">时间范围内无明细(默认当天)</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- 分页条 -->
|
||||
<div class="flex items-center justify-between border-t border-gray-100 px-4 py-3 text-sm text-gray-500 dark:border-dark-700">
|
||||
<span>共 {{ total }} 条记录</span>
|
||||
<div class="flex items-center gap-1">
|
||||
<button class="rounded-xl px-3.5 py-2 text-sm text-gray-500 hover:bg-gray-100 dark:hover:bg-dark-800" :disabled="page <= 1" @click="goPage(page - 1)">◀</button>
|
||||
<button v-for="p in pageButtons" :key="p" class="rounded-xl px-3.5 py-2 text-sm" :class="p === page ? 'bg-primary-600 font-medium text-white' : 'text-gray-500 hover:bg-gray-100 dark:hover:bg-dark-800'" @click="goPage(p)">{{ p }}</button>
|
||||
<span v-if="lastPage > 5" class="px-1 text-gray-400">…</span>
|
||||
<button class="rounded-xl px-3.5 py-2 text-sm text-gray-500 hover:bg-gray-100 dark:hover:bg-dark-800" :disabled="page >= lastPage" @click="goPage(page + 1)">▶</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import {
|
||||
DOWNLINK_STATUS_OPTIONS, downlinkStatusText, fetchDownlinkDetails,
|
||||
segmentDurations, sourceText, type DownlinkDetailRow,
|
||||
} from '@/api/sms'
|
||||
import { channelApi, type Channel } from '@/api/channel'
|
||||
|
||||
// Issue#2 keep-alive 锚点:组件名=路由名
|
||||
defineOptions({ name: 'sms-downlink-detail' })
|
||||
|
||||
const route = useRoute()
|
||||
const rows = ref<DownlinkDetailRow[]>([])
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = 10
|
||||
const loading = ref(false)
|
||||
const expanded = ref(false)
|
||||
const drilledBatch = ref('')
|
||||
const channelOptions = ref<Channel[]>([])
|
||||
|
||||
const filter = reactive({
|
||||
batch_id: '', mobile: '', status: '' as string | number, channel_id: '' as string | number,
|
||||
content: '', carrier: '', raw_code: '', startTime: '', endTime: '',
|
||||
})
|
||||
|
||||
const lastPage = computed(() => Math.max(1, Math.ceil(total.value / pageSize)))
|
||||
const pageButtons = computed(() => {
|
||||
const from = Math.max(1, Math.min(page.value - 1, lastPage.value - 4))
|
||||
return Array.from({ length: Math.min(5, lastPage.value) }, (_, i) => from + i).filter((p) => p <= lastPage.value)
|
||||
})
|
||||
|
||||
function buildQuery() {
|
||||
return {
|
||||
page: page.value,
|
||||
page_size: pageSize,
|
||||
...(filter.batch_id.trim() ? { batch_id: filter.batch_id.trim() } : {}),
|
||||
...(filter.mobile.trim() ? { mobile: filter.mobile.trim() } : {}),
|
||||
...(filter.status !== '' ? { status: Number(filter.status) } : {}),
|
||||
...(filter.channel_id !== '' ? { channel_id: Number(filter.channel_id) } : {}),
|
||||
...(filter.content.trim() ? { content: filter.content.trim() } : {}),
|
||||
...(filter.carrier ? { carrier: filter.carrier } : {}),
|
||||
...(filter.raw_code.trim() ? { raw_code: filter.raw_code.trim() } : {}),
|
||||
...(filter.startTime ? { start_time: filter.startTime.replace('T', ' ') + ':00' } : {}),
|
||||
...(filter.endTime ? { end_time: filter.endTime.replace('T', ' ') + ':00' } : {}),
|
||||
}
|
||||
}
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await fetchDownlinkDetails(buildQuery())
|
||||
rows.value = res.list
|
||||
total.value = res.total
|
||||
} catch {
|
||||
rows.value = []
|
||||
total.value = 0
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function search() { page.value = 1; void load() }
|
||||
function reset() {
|
||||
filter.batch_id = ''; filter.mobile = ''; filter.status = ''; filter.channel_id = ''
|
||||
filter.content = ''; filter.carrier = ''; filter.raw_code = ''; filter.startTime = ''; filter.endTime = ''
|
||||
drilledBatch.value = ''
|
||||
search()
|
||||
}
|
||||
function goPage(p: number) {
|
||||
if (p < 1 || p > lastPage.value) return
|
||||
page.value = p
|
||||
void load()
|
||||
}
|
||||
|
||||
/** 批次钻入:表内批次ID 点击 → 收敛筛选(记录中心其他页跳入也走这里)。 */
|
||||
function drill(batchId: number) {
|
||||
drilledBatch.value = String(batchId)
|
||||
filter.batch_id = String(batchId)
|
||||
search()
|
||||
}
|
||||
function clearDrill() { filter.batch_id = ''; drilledBatch.value = ''; search() }
|
||||
|
||||
// ---- 展示工具 ----
|
||||
function maskMobile(m: string): string {
|
||||
return m.length >= 11 ? `${m.slice(0, 3)}****${m.slice(7)}` : m
|
||||
}
|
||||
function fmt(s: string): string {
|
||||
return s?.length >= 16 ? s.slice(5, 16) : s
|
||||
}
|
||||
function statusClass(r: DownlinkDetailRow): string {
|
||||
if (r.status === 2 && !r.error_code) return 'badge-success'
|
||||
if (r.status === 3) return 'badge-danger'
|
||||
if (r.status === 5) return 'badge-warning'
|
||||
return 'badge-gray'
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
// 批次钻入链:/record/detail redirect 会带 batch_id query 进来
|
||||
const q = route.query.batch_id as string | undefined
|
||||
if (q) { filter.batch_id = String(q); drilledBatch.value = String(q) }
|
||||
void load()
|
||||
void channelApi.list({ page: 1, page_size: 100 }).then((d) => { channelOptions.value = d.list }).catch(() => {})
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user