feat(推送管理)配置中心-推送通知-推送记录优化
deploy-hxtesting / build-and-deploy (push) Successful in 1m21s

1.增加按“时间”、“标题”、“企微状态”查询
2.增加数据统计在列表顶部
3.增加分页功能
This commit is contained in:
runny committed 2026-11-28 13:05:13 +08:00
1 parent 0c471efb9f
commit 9d4092bc7f
14 files changed
+447 -108

No files matched your search

@@ -207,12 +207,12 @@
</div>
</div>
<!-- 推送记录(逐人企微/站内投递明细;手动触发周一讲师提醒) -->
<!-- 推送记录(逐人企微/站内投递明细;时间/标题/企微状态查询 + 统计 + 分页) -->
<div class="panel-box">
<div class="panel-box__header">
<span class="panel-box__title">推送记录</span>
<div class="push-toolbar">
<t-select v-model="pushScene" class="push-scene-select" size="small" clearable placeholder="全部场景">
<t-select v-model="pushScene" class="push-scene-select" size="small" clearable placeholder="全部场景" @change="searchPushLogs">
<t-option v-for="opt in PUSH_SCENE_OPTIONS" :key="opt.value" :value="opt.value" :label="opt.label" />
</t-select>
<t-button variant="outline" size="small" :loading="pushLogsLoading" @click="loadPushLogs">刷新</t-button>
@@ -221,6 +221,43 @@
</t-popconfirm>
</div>
</div>
<!-- 查询行:时间/标题/企微状态(2026-11 推送记录优化) -->
<div class="push-filters">
<span class="push-filters__label">时间</span>
<t-date-range-picker
v-model="pushDateRange"
class="push-filters__date"
size="small"
clearable
:placeholder="['开始日期', '结束日期']"
@change="searchPushLogs"
/>
<span class="push-filters__label">标题</span>
<t-input
v-model="pushTitle"
class="push-filters__title"
size="small"
clearable
placeholder="按标题查询"
@enter="searchPushLogs"
@clear="searchPushLogs"
@blur="onPushTitleBlur"
/>
<span class="push-filters__label">企微状态</span>
<t-select v-model="pushStatus" class="push-filters__status" size="small" clearable placeholder="全部状态" @change="searchPushLogs">
<t-option v-for="opt in PUSH_STATUS_OPTIONS" :key="opt.value" :value="opt.value" :label="opt.label" />
</t-select>
<t-button variant="outline" size="small" @click="resetPushFilters">重置</t-button>
</div>
<!-- 统计条:当前查询条件命中的全量口径(不受分页影响) -->
<div class="push-stats">
<span class="push-stats__item">共 <b>{{ pushStats.total }}</b> 条</span>
<span class="push-stats__item push-stats__item--success">已送达 {{ pushStats.sent }}</span>
<span class="push-stats__item push-stats__item--danger">已失败 {{ pushStats.dead }}</span>
<span class="push-stats__item push-stats__item--warn">排队与投递中 {{ pushStats.pending }}</span>
<span class="push-stats__item">已跳过 {{ pushStats.skipped }}</span>
<span class="push-stats__item">仅站内 {{ pushStats.in_site }}</span>
</div>
<t-table :data="pushLogs" :columns="pushLogColumns" row-key="id" size="small" :loading="pushLogsLoading" max-height="360">
<template #created_at="{ row }">{{ fmtTime(row.created_at) }}</template>
<template #scene="{ row }"><code class="role-key">{{ row.scene }}</code></template>
@@ -238,8 +275,16 @@
<span class="push-error" :title="row.push_error">{{ row.push_error || '—' }}</span>
</template>
</t-table>
<TrainingPagination
:current="pushPage"
:page-size="pushPageSize"
:total="pushTotal"
:disabled="pushLogsLoading"
@update:current="onPushPageChange"
@update:page-size="onPushPageSizeChange"
/>
<div class="form-hint">
展示最近 {{ pushLogs.length }} 条;pending/sending=排队与投递中,sent=企微已送达,skipped=收件人未绑定企微等跳过,dead=重试耗尽,空=仅站内通知。
统计与总数为当前查询条件命中结果;pending/sending=排队与投递中,sent=企微已送达,skipped=收件人未绑定企微等跳过,dead=重试耗尽,空=仅站内通知。
</div>
</div>
</t-tab-panel>
@@ -337,7 +382,7 @@
</template>
<script setup lang="ts">
import { computed, onMounted, ref, watch } from 'vue'
import { computed, onMounted, ref } from 'vue'
import { MessagePlugin } from 'tdesign-vue-next'
import {
COURSE_CATEGORY_DICT_RULE_KEY,
@@ -356,6 +401,8 @@ import {
seedRuleConfigs,
uploadTrainingTemplate,
type TrainingPushLog,
type TrainingPushLogPage,
type TrainingPushLogStats,
type TrainingRoleDef,
type TrainingRuleConfig,
type TrainingTemplateKey,
@@ -364,6 +411,8 @@ import {
} from '@/api/training'
import { fmtBeijingTime } from '@/utils/datetime'
import { downloadTrainingTemplate } from '../trainingTemplates'
import TrainingPagination from './TrainingPagination.vue'
import { TRAINING_PAGE_SIZE } from './useTrainingPager'
// [2026-11 需求] 配置中心 tab 切换(角色权限/业务规则/推送管理/导入模板)
const activeTab = ref('roles')
@@ -815,10 +864,29 @@ const PUSH_SCENE_OPTIONS = [
{ value: 'remind_lecturer_maintain', label: '课程维护提醒' },
]
// 企微状态筛选项:pending 合并排队与投递中,in_site = 仅站内(push_status 空)。
const PUSH_STATUS_OPTIONS = [
{ value: 'sent', label: '已送达' },
{ value: 'dead', label: '已失败' },
{ value: 'skipped', label: '已跳过' },
{ value: 'pending', label: '排队与投递中' },
{ value: 'in_site', label: '仅站内' },
]
const EMPTY_PUSH_STATS: TrainingPushLogStats = { total: 0, sent: 0, dead: 0, skipped: 0, pending: 0, in_site: 0 }
const pushScene = ref('')
const pushDateRange = ref<string[]>([])
const pushTitle = ref('')
const queriedPushTitle = ref('') // 最近一次已查询的标题(失焦时对比,避免无变化重复查询)
const pushStatus = ref('')
const pushLogs = ref<TrainingPushLog[]>([])
const pushLogsLoading = ref(false)
const runningWeekly = ref(false)
const pushPage = ref(1)
const pushPageSize = ref(TRAINING_PAGE_SIZE)
const pushTotal = ref(0)
const pushStats = ref<TrainingPushLogStats>({ ...EMPTY_PUSH_STATS })
const pushLogColumns = [
{ colKey: 'created_at', title: '时间', width: 150 },
@@ -844,13 +912,58 @@ const pushStatusLabel = (status: string) => {
const loadPushLogs = async () => {
pushLogsLoading.value = true
try {
const res = await listTrainingPushLogs({ scenes: pushScene.value || undefined, limit: 200 })
pushLogs.value = unwrap<TrainingPushLog[]>(res) || []
const [start, end] = pushDateRange.value || []
const title = pushTitle.value.trim()
const res = await listTrainingPushLogs({
scenes: pushScene.value || undefined,
title: title || undefined,
push_status: pushStatus.value || undefined,
start_time: start || undefined,
end_time: end ? `${end} 23:59:59` : undefined,
page: pushPage.value,
page_size: pushPageSize.value,
})
const pageData = unwrap<TrainingPushLogPage>(res)
pushLogs.value = pageData?.items || []
pushTotal.value = pageData?.total || 0
pushStats.value = pageData?.stats || { ...EMPTY_PUSH_STATS }
queriedPushTitle.value = title
} finally {
pushLogsLoading.value = false
}
}
// searchPushLogs 查询条件变化后回到第 1 页重查。
const searchPushLogs = () => {
pushPage.value = 1
loadPushLogs()
}
// onPushTitleBlur 失焦时仅在标题确有修改后才重查(回车/清空已即时查询)。
const onPushTitleBlur = () => {
if (pushTitle.value.trim() !== queriedPushTitle.value) searchPushLogs()
}
// onPushPageChange / onPushPageSizeChange 服务端分页翻页与调每页条数。
const onPushPageChange = (page: number) => {
pushPage.value = page
loadPushLogs()
}
const onPushPageSizeChange = (size: number) => {
pushPageSize.value = size
searchPushLogs()
}
// resetPushFilters 清空全部查询条件后重查(清空引用不触发组件 change,
// 仅此处触发一次查询)。
const resetPushFilters = () => {
pushScene.value = ''
pushDateRange.value = []
pushTitle.value = ''
pushStatus.value = ''
searchPushLogs()
}
const onRunWeekly = async () => {
runningWeekly.value = true
try {
@@ -1018,8 +1131,6 @@ onMounted(() => {
loadPushLogs()
})
// 场景筛选变化即重拉推送记录
watch(pushScene, () => loadPushLogs())
</script>
<style lang="less" scoped>
@@ -1223,6 +1334,68 @@ watch(pushScene, () => loadPushLogs())
width: 180px;
}
/* 查询行:时间/标题/企微状态(2026-11 推送记录优化) */
.push-filters {
display: flex;
gap: 8px;
align-items: center;
margin-bottom: 8px;
flex-wrap: wrap;
&__label {
font-size: var(--app-text-sm);
color: var(--td-text-color-secondary);
white-space: nowrap;
}
&__date {
width: 240px;
}
&__title {
width: 200px;
}
&__status {
width: 150px;
}
}
/* 统计条:当前查询条件命中的全量口径 */
.push-stats {
display: flex;
gap: 16px;
align-items: center;
flex-wrap: wrap;
margin-bottom: 8px;
padding: 6px 12px;
background: var(--td-bg-color-container);
border: 1px solid var(--td-component-border);
border-radius: var(--td-radius-default);
&__item {
font-size: var(--app-text-sm);
color: var(--td-text-color-secondary);
b {
color: var(--td-text-color-primary);
font-weight: 600;
}
&--success {
color: var(--td-success-color);
}
&--danger {
color: var(--td-error-color);
}
&--warn {
color: var(--td-warning-color);
}
}
}
.push-empno {
margin-left: 4px;
font-size: var(--app-text-xs);
@@ -115,6 +115,11 @@
</div>
<t-table :data="pagedRecords" :columns="recordColumns" row-key="id" size="small" :loading="loading">
<template #member="{ row }">{{ recordMemberLabel(row) }}</template>
<template #roster="{ row }">
<t-tag :theme="row.in_roster ? 'success' : 'warning'" variant="light" size="small">
{{ row.in_roster ? '要求培训人员' : '非要求培训人员' }}
</t-tag>
</template>
<template #signed_at="{ row }">{{ fmtRecordTime(row.signed_at) }}</template>
<template #channel="{ row }">{{ channelText(row.channel) }}</template>
<template #status="{ row }">
@@ -164,7 +169,7 @@
<div class="evidence-bar">
<div>
<div class="evidence-bar__title">一键导出 · 请款佐证包</div>
<div class="muted">导出字段:部门 · 工号 · 姓名 · 签到时间 · 讲师姓名 · 课程名称 · 上课时间 · 学员考试成绩</div>
<div class="muted">导出字段:部门 · 工号 · 姓名 · 签到时间 · 讲师姓名 · 课程名称 · 上课时间 · 学员考试成绩 · 人员类型</div>
</div>
<t-button theme="primary" :loading="exportLoading" @click="onExport">导出佐证包(Excel)</t-button>
</div>
@@ -249,6 +254,9 @@ const {
const recordColumns = [
{ colKey: 'member', title: '学员', width: 220 },
// 人员类型标注(2026-11-28 规则调整:员工档案全员可签到,明细区分是否
// 发布培训计划时所选「参加人员」)
{ colKey: 'roster', title: '人员类型', width: 140 },
{ colKey: 'signed_at', title: '签到时间', width: 170 },
{ colKey: 'channel', title: '方式', width: 110 },
{ colKey: 'distance_m', title: '定位距离(m)', width: 110 },