feat(calls): 微信语音列表加今日统计卡片+通话时间范围筛选+客户跳转带通话时间定位(对齐云客)
- GET /api/calls/stats:今日(Asia/Shanghai)好友呼入/外呼量+群量+时长聚合(@chatroom判群) - CallList:5张统计卡片(仅微信语音tab)+datetimerange筛选(服务端start/end)+viewCallCustomer带?start定位 - TDD新增stats聚合测试,全量绿 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import { getJson, requestJson } from './client'
|
||||
import type {
|
||||
Account,
|
||||
CallChannel,
|
||||
CallStats,
|
||||
Channel,
|
||||
Customer,
|
||||
Department,
|
||||
@@ -185,6 +186,10 @@ export interface CallQuery {
|
||||
page_size?: number
|
||||
}
|
||||
|
||||
export function getCallStats(): Promise<CallStats> {
|
||||
return getJson<CallStats>('/calls/stats')
|
||||
}
|
||||
|
||||
export function getCalls(query: CallQuery = {}): Promise<Page<PhoneCall>> {
|
||||
return getJson<Page<PhoneCall>>(
|
||||
'/calls',
|
||||
|
||||
@@ -120,6 +120,16 @@ export interface GroupMember {
|
||||
*/
|
||||
export type CallChannel = 'phone_call' | 'voice_call' | 'wa_voice_call'
|
||||
|
||||
export interface CallStats {
|
||||
/** 今日微信语音统计卡片(GET /api/calls/stats,时长单位秒)。 */
|
||||
friend_incoming: number
|
||||
friend_outgoing: number
|
||||
group_count: number
|
||||
friend_incoming_duration: number
|
||||
friend_outgoing_duration: number
|
||||
group_duration: number
|
||||
}
|
||||
|
||||
export interface PhoneCall {
|
||||
call_id: string
|
||||
channel: CallChannel
|
||||
|
||||
@@ -3,8 +3,8 @@ import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Download } from '@element-plus/icons-vue'
|
||||
import { getCalls } from '@/api'
|
||||
import type { CallChannel, PhoneCall } from '@/api/types'
|
||||
import { getCallStats, getCalls } from '@/api'
|
||||
import type { CallChannel, CallStats, PhoneCall } from '@/api/types'
|
||||
import {
|
||||
callDirectionLabel,
|
||||
callStatusLabel,
|
||||
@@ -30,6 +30,27 @@ const callType = ref<CallChannel>(
|
||||
// 仅在 voice_call tab 生效;client-side 过滤当前页。
|
||||
const voiceScope = ref<'friend' | 'group'>('friend')
|
||||
|
||||
/** 通话时间范围筛选([startMs, endMs] | null,对齐云客高级筛选)。 */
|
||||
const callRange = ref<[string, string] | null>(null)
|
||||
|
||||
/** 今日微信语音统计卡片(对齐云客语音列表顶部)。 */
|
||||
const stats = ref<CallStats | null>(null)
|
||||
|
||||
async function loadStats(): Promise<void> {
|
||||
try {
|
||||
stats.value = await getCallStats()
|
||||
} catch {
|
||||
stats.value = null // 卡片失败不阻塞列表
|
||||
}
|
||||
}
|
||||
|
||||
function fmtDur(sec: number | undefined): string {
|
||||
if (!sec) return '0秒'
|
||||
const m = Math.floor(sec / 60)
|
||||
const s = sec % 60
|
||||
return m > 0 ? `${m}分${s}秒` : `${s}秒`
|
||||
}
|
||||
|
||||
const calls = ref<PhoneCall[]>([])
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
@@ -66,6 +87,8 @@ async function load(): Promise<void> {
|
||||
channel: callType.value,
|
||||
// 微信语音 好友/群 scope 为服务端过滤(@chatroom 后缀判群,与云客 isRoom 等价)
|
||||
scope: callType.value === 'voice_call' ? voiceScope.value : undefined,
|
||||
start: callRange.value?.[0] ? Number(callRange.value[0]) : undefined,
|
||||
end: callRange.value?.[1] ? Number(callRange.value[1]) : undefined,
|
||||
page: page.value,
|
||||
page_size: pageSize.value,
|
||||
})
|
||||
@@ -79,6 +102,12 @@ async function load(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
/** 通话时间范围变更 → 回第 1 页重查(服务端过滤)。 */
|
||||
function handleRangeChange(): void {
|
||||
page.value = 1
|
||||
load()
|
||||
}
|
||||
|
||||
function handlePageChange(p: number): void {
|
||||
page.value = p
|
||||
load()
|
||||
@@ -101,6 +130,7 @@ watch(
|
||||
// 复位 scope,避免把 微信群/好友 筛选带到 WA语音。
|
||||
voiceScope.value = 'friend'
|
||||
load()
|
||||
loadStats()
|
||||
}
|
||||
},
|
||||
)
|
||||
@@ -226,6 +256,8 @@ function viewCallCustomer(row: PhoneCall): void {
|
||||
ownerId: String(owner),
|
||||
talkerId: String(talker),
|
||||
},
|
||||
// 对齐云客:带通话时间定位(?start=),聊天窗滚动到该通通话附近
|
||||
query: row.start_call_time ? { start: String(row.start_call_time) } : undefined,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -243,7 +275,10 @@ const drawerSections = computed(() =>
|
||||
drawerCall.value ? buildCallSections(drawerCall.value) : [],
|
||||
)
|
||||
|
||||
onMounted(load)
|
||||
onMounted(() => {
|
||||
load()
|
||||
loadStats()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -271,15 +306,56 @@ onMounted(load)
|
||||
style="margin-bottom: 12px"
|
||||
/>
|
||||
|
||||
<el-radio-group
|
||||
v-if="callType === 'voice_call'"
|
||||
v-model="voiceScope"
|
||||
size="small"
|
||||
style="margin-bottom: 8px"
|
||||
<!-- 今日统计卡片(对齐云客微信语音列表顶部;仅微信语音 tab) -->
|
||||
<div
|
||||
v-if="callType === 'voice_call' && stats"
|
||||
style="display: flex; gap: 12px; margin-bottom: 12px; flex-wrap: wrap"
|
||||
>
|
||||
<el-radio-button value="friend">微信好友</el-radio-button>
|
||||
<el-radio-button value="group">微信群</el-radio-button>
|
||||
</el-radio-group>
|
||||
<el-card shadow="never" style="flex: 1; min-width: 140px">
|
||||
<div style="font-size: 12px; color: var(--el-text-color-secondary)">今日好友语音呼入量</div>
|
||||
<div style="font-size: 20px; font-weight: 600">{{ stats.friend_incoming }}</div>
|
||||
</el-card>
|
||||
<el-card shadow="never" style="flex: 1; min-width: 140px">
|
||||
<div style="font-size: 12px; color: var(--el-text-color-secondary)">今日好友语音外呼量</div>
|
||||
<div style="font-size: 20px; font-weight: 600">{{ stats.friend_outgoing }}</div>
|
||||
</el-card>
|
||||
<el-card shadow="never" style="flex: 1; min-width: 140px">
|
||||
<div style="font-size: 12px; color: var(--el-text-color-secondary)">今日微信群语音量</div>
|
||||
<div style="font-size: 20px; font-weight: 600">{{ stats.group_count }}</div>
|
||||
</el-card>
|
||||
<el-card shadow="never" style="flex: 1; min-width: 140px">
|
||||
<div style="font-size: 12px; color: var(--el-text-color-secondary)">今日好友呼入/呼出时长</div>
|
||||
<div style="font-size: 20px; font-weight: 600">{{ fmtDur(stats.friend_incoming_duration) }} / {{ fmtDur(stats.friend_outgoing_duration) }}</div>
|
||||
</el-card>
|
||||
<el-card shadow="never" style="flex: 1; min-width: 140px">
|
||||
<div style="font-size: 12px; color: var(--el-text-color-secondary)">今日群通话录音时长</div>
|
||||
<div style="font-size: 20px; font-weight: 600">{{ fmtDur(stats.group_duration) }}</div>
|
||||
</el-card>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; gap: 12px; align-items: center; margin-bottom: 8px; flex-wrap: wrap">
|
||||
<el-radio-group
|
||||
v-if="callType === 'voice_call'"
|
||||
v-model="voiceScope"
|
||||
size="small"
|
||||
>
|
||||
<el-radio-button value="friend">微信好友</el-radio-button>
|
||||
<el-radio-button value="group">微信群</el-radio-button>
|
||||
</el-radio-group>
|
||||
<!-- 高级筛选:通话时间范围(对齐云客,传 /api/calls 已有 start/end) -->
|
||||
<el-date-picker
|
||||
v-model="callRange"
|
||||
type="datetimerange"
|
||||
size="small"
|
||||
range-separator="至"
|
||||
start-placeholder="通话开始时间"
|
||||
end-placeholder="通话结束时间"
|
||||
value-format="x"
|
||||
clearable
|
||||
style="width: 340px"
|
||||
@change="handleRangeChange"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
|
||||
Reference in New Issue
Block a user