feat(看板): 删净在跑店铺看板,进度文案对齐客户端,加国家列,默认筛「在跑」
- 店铺看板整条移除(面板/`/shops`/`shops()`/`TaskCenterShopVo`),汇总卡「在跑店铺」保留; - 采集数据行进度改成客户端那句「关键词进度:第 N/总 个」(只改文字,数字口径与夹取不变), 其余无进度条的模块仍显示「—」; - 列表加「国家」列:值来自 request_json 的 7 条路径(线上实测顺序与覆盖 315/451=69.8%), 按页内主键点查、不进列表 UNION,以免把大 JSON 列拉回已知慢查询;品牌行不发查询; 只展示不筛选,无迁移; - 状态默认「在跑」= PENDING∪RUNNING∪SCHEDULED,前端下发 ACTIVE 哨兵、只在服务层 statusFilter 一处展开,成员与 ACTIVE_STATUS_SET/ACTIVE_STATUSES 同源钉死; - 护栏:后端 task-center 77 例(新增状态 IN 渲染、7 路径顺序、归一两形态、品牌不查国家等)、 前端 21 例;4 个变异点(路径顺序/哨兵不展开/归一截断/文案分支)全部被抓到并字节级还原。
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { http } from './http'
|
||||
import { unwrap } from './envelope'
|
||||
|
||||
/** 客户端任务管理(后台看板):按店铺 × 账号 × 业务统一查看客户端在跑任务,全部只读。 */
|
||||
/** 客户端任务管理(后台看板):按账号 × 店铺 × 业务统一查看客户端任务,全部只读。 */
|
||||
|
||||
/** 查询参数(由页面侧 buildTaskQuery / buildVariantQuery 产出,空白项不下传)。 */
|
||||
type QueryParams = Record<string, string | number>
|
||||
@@ -14,16 +14,6 @@ export interface TaskCenterOverview {
|
||||
stuckTasks: number
|
||||
}
|
||||
|
||||
/** 店铺面板行:一个店铺在当前所有进行中任务里的汇总;「不挂店铺」是兜住无店铺模块的合成桶。 */
|
||||
export interface TaskCenterShop {
|
||||
shop: string
|
||||
noShop: boolean
|
||||
runningTasks: number
|
||||
stuckTasks: number
|
||||
moduleSummary: string
|
||||
lastReportAt: string | null
|
||||
}
|
||||
|
||||
export interface TaskCenterTaskRow {
|
||||
id: number
|
||||
taskNo: string
|
||||
@@ -37,6 +27,8 @@ export interface TaskCenterTaskRow {
|
||||
webDevice: boolean
|
||||
shopName: string | null
|
||||
shopCount: number
|
||||
/** 目标站点国家码(后端从 request_json 归一,多国家用 / 连);该模块不写国家时为 null。 */
|
||||
country: string | null
|
||||
createdAt: string | null
|
||||
finishedAt: string | null
|
||||
lastReportAt: string | null
|
||||
@@ -92,12 +84,6 @@ export async function fetchTaskCenterOverview(): Promise<TaskCenterOverview> {
|
||||
return unwrap<TaskCenterOverview>(data)
|
||||
}
|
||||
|
||||
/** 店铺面板:当前全部进行中任务按店铺归组(与汇总卡的「在跑店铺」同源):GET /api/admin/task-center/shops */
|
||||
export async function fetchTaskCenterShops(): Promise<TaskCenterShop[]> {
|
||||
const { data } = await http.get('/api/admin/task-center/shops')
|
||||
return unwrap<TaskCenterShop[]>(data)
|
||||
}
|
||||
|
||||
/** 店铺筛选候选(店铺库内的店铺名,精确匹配):GET /api/admin/task-center/shop-options */
|
||||
export async function fetchTaskCenterShopOptions(): Promise<string[]> {
|
||||
const { data } = await http.get('/api/admin/task-center/shop-options')
|
||||
|
||||
@@ -95,8 +95,8 @@ export const OPERATION_GUIDES: Record<string, OperationGuideData> = {
|
||||
steps: ['选择日期范围', '筛选用户或分组', '核对各模块次数'],
|
||||
},
|
||||
admin_task_center: {
|
||||
text: '在跑店铺看板按店铺汇总当前进行中的客户端任务;点店铺行筛出该店铺任务,点任务查看明细。',
|
||||
steps: ['看在跑店铺看板', '点店铺行筛任务', '打开任务详情'],
|
||||
text: '按账号、业务、状态、店铺和创建时间筛出客户端任务,点任务查看明细与分组结果;顶部汇总卡给当前在跑与疑似卡住的总量。',
|
||||
steps: ['按条件筛任务', '查看任务明细', '核对汇总卡'],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
/** 客户端任务管理看板:全局看板看「哪些店铺有任务在跑」,再下钻到任务明细(只读,仅超管或被授权管理员)。
|
||||
* 页签一「客户端任务」= biz_file_task(12 个客户端模块)∪ brand_crawl_tasks,顶部是按店铺归组的在跑面板;
|
||||
/** 客户端任务管理看板:全局看有哪些客户端任务在跑,再下钻到任务明细(只读,仅超管或被授权管理员)。
|
||||
* 页签一「客户端任务」= biz_file_task(12 个客户端模块)∪ brand_crawl_tasks;
|
||||
* 页签二「变体采集」= 麦象批量任务(variant-collection),数据口径与列不同故独立页签。
|
||||
* 30s 轮询:页面隐藏暂停、回前台立即刷新、卸载清理;另有手动刷新。 */
|
||||
import { computed, onMounted, onUnmounted, reactive, ref } from 'vue'
|
||||
@@ -10,17 +10,16 @@ import { formatDateTime, todayDateTimeRange } from '@/utils/datetime'
|
||||
import {
|
||||
fetchTaskCenterOverview,
|
||||
fetchTaskCenterShopOptions,
|
||||
fetchTaskCenterShops,
|
||||
fetchTaskCenterTaskDetail,
|
||||
fetchTaskCenterTasks,
|
||||
fetchTaskCenterVariantTasks,
|
||||
type TaskCenterOverview,
|
||||
type TaskCenterShop,
|
||||
type TaskCenterTaskDetail,
|
||||
type TaskCenterTaskRow,
|
||||
type TaskCenterVariantTaskRow,
|
||||
} from '@/api/task-center'
|
||||
import {
|
||||
ACTIVE_TASK_STATUS,
|
||||
MODULE_OPTIONS,
|
||||
TASK_STATUS_OPTIONS,
|
||||
VARIANT_STATUS_OPTIONS,
|
||||
@@ -50,14 +49,18 @@ const activeTab = ref<BoardTab>('tasks')
|
||||
// ---------------------------------------------------------------- 客户端任务
|
||||
|
||||
const overview = ref<TaskCenterOverview | null>(null)
|
||||
const shops = ref<TaskCenterShop[]>([])
|
||||
const shopOptions = ref<string[]>([])
|
||||
/** 首屏与「重置」都锁定当天;共享工厂 createTaskFilter 保持全空(它被单测与别处复用)。 */
|
||||
function todayTaskRange(): Pick<TaskCenterTaskFilter, 'startTime' | 'endTime'> {
|
||||
const [startTime, endTime] = todayDateTimeRange()
|
||||
return { startTime, endTime }
|
||||
}
|
||||
const filter = reactive<TaskCenterTaskFilter>({ ...createTaskFilter(), ...todayTaskRange() })
|
||||
/** 默认视图 = 今天 + 只看在跑(合并哨兵,后端展开成三个进行中状态);历史状态仍在下拉里可查。 */
|
||||
function defaultTaskFilter(): TaskCenterTaskFilter {
|
||||
return { ...createTaskFilter(), ...todayTaskRange(), status: ACTIVE_TASK_STATUS }
|
||||
}
|
||||
|
||||
const filter = reactive<TaskCenterTaskFilter>(defaultTaskFilter())
|
||||
const tasks = ref<TaskCenterTaskRow[]>([])
|
||||
const taskTotal = ref(0)
|
||||
const taskPage = ref(1)
|
||||
@@ -89,15 +92,6 @@ const variantTotalPages = computed(() => Math.max(1, Math.ceil((variantTotal.val
|
||||
* 列表 total(历史全量,且每天 00:00 的 7 天保留清理会往下掉)只用于分页,不上徽章。 */
|
||||
const runningBadge = computed(() => tabCount(overview.value?.runningTasks))
|
||||
|
||||
/** 下拉候选 = 店铺库 + 面板上出现的店铺名(后者可能已从店铺库删掉,下钻要筛得动)。 */
|
||||
const shopFilterOptions = computed(() => {
|
||||
const names = new Set(shopOptions.value)
|
||||
for (const row of shops.value) {
|
||||
if (!row.noShop) names.add(row.shop)
|
||||
}
|
||||
return [...names]
|
||||
})
|
||||
|
||||
function errorText(error: unknown, fallback: string): string {
|
||||
return error instanceof Error && error.message ? error.message : fallback
|
||||
}
|
||||
@@ -110,14 +104,6 @@ async function loadOverview() {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadShops() {
|
||||
try {
|
||||
shops.value = (await fetchTaskCenterShops()) || []
|
||||
} catch (error) {
|
||||
ElMessage.error(errorText(error, '在跑店铺加载失败'))
|
||||
}
|
||||
}
|
||||
|
||||
/** 店铺库下拉候选。 */
|
||||
async function loadShopOptions() {
|
||||
try {
|
||||
@@ -156,11 +142,10 @@ async function loadVariants(silent = false) {
|
||||
}
|
||||
}
|
||||
|
||||
/** 汇总卡与在跑店铺面板只描述客户端任务,两个页签都刷新它们(切页签时看到的就是最新)。 */
|
||||
/** 汇总卡与店铺候选只描述客户端任务,两个页签都刷新它们(切页签时看到的就是最新)。 */
|
||||
async function refreshAll(silent = false) {
|
||||
await Promise.all([
|
||||
loadOverview(),
|
||||
loadShops(),
|
||||
loadShopOptions(),
|
||||
activeTab.value === 'tasks' ? loadTasks(silent) : loadVariants(silent),
|
||||
])
|
||||
@@ -190,14 +175,7 @@ function search() {
|
||||
}
|
||||
|
||||
function resetFilter() {
|
||||
Object.assign(filter, createTaskFilter(), todayTaskRange())
|
||||
taskPage.value = 1
|
||||
void loadTasks()
|
||||
}
|
||||
|
||||
/** 点店铺面板行:按该店铺精确筛选任务(再点一次取消);「不挂店铺」合成桶没有可下钻的店铺名。 */
|
||||
function selectShop(shop: string) {
|
||||
filter.shop = filter.shop === shop ? '' : shop
|
||||
Object.assign(filter, defaultTaskFilter())
|
||||
taskPage.value = 1
|
||||
void loadTasks()
|
||||
}
|
||||
@@ -346,52 +324,10 @@ onUnmounted(() => {
|
||||
|
||||
<!-- ============ 页签一:客户端任务 ============ -->
|
||||
<template v-if="activeTab === 'tasks'">
|
||||
<section class="panel-box">
|
||||
<div class="box-head">
|
||||
<h3>在跑店铺看板</h3>
|
||||
<span class="box-note">全局看每家店当前有哪些任务在跑,点店铺行筛出它的任务,不必逐台客户端检查</span>
|
||||
</div>
|
||||
<div v-if="shops.length" class="table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 210px">店铺</th>
|
||||
<th style="width: 90px">在跑任务</th>
|
||||
<th style="width: 90px">疑似卡住</th>
|
||||
<th style="width: 230px">业务分布</th>
|
||||
<th style="width: 165px">最近上报</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="row in shops"
|
||||
:key="row.shop"
|
||||
class="shop-row"
|
||||
:class="{ 'is-bucket': row.noShop, active: !row.noShop && filter.shop === row.shop }"
|
||||
@click="row.noShop ? null : selectShop(row.shop)"
|
||||
>
|
||||
<td>
|
||||
<span class="strong">{{ row.shop }}</span>
|
||||
<span v-if="row.noShop" class="sub">采集/货源/品牌这类任务不落店铺,按业务筛选查看</span>
|
||||
</td>
|
||||
<td>{{ row.runningTasks }}</td>
|
||||
<td>
|
||||
<span :class="{ 'is-warn-text': row.stuckTasks > 0 }">{{ row.stuckTasks }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="scope" :title="row.moduleSummary">{{ row.moduleSummary || '—' }}</span>
|
||||
</td>
|
||||
<td>{{ row.lastReportAt ? formatDateTime(row.lastReportAt) : '—' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div v-else class="empty-tip">暂无在跑店铺</div>
|
||||
</section>
|
||||
|
||||
<section class="panel-box">
|
||||
<div class="box-head">
|
||||
<h3>任务筛选</h3>
|
||||
<span class="box-note">默认只列今天的在跑任务(待执行/执行中/已排期算一个口径),看历史请换状态或放宽创建时间</span>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group" style="min-width: 160px">
|
||||
@@ -421,7 +357,7 @@ onUnmounted(() => {
|
||||
style="width: 220px"
|
||||
@change="search"
|
||||
>
|
||||
<el-option v-for="shop in shopFilterOptions" :key="shop" :label="shop" :value="shop" />
|
||||
<el-option v-for="shop in shopOptions" :key="shop" :label="shop" :value="shop" />
|
||||
</el-select>
|
||||
<span class="filter-tip">精确匹配店铺名</span>
|
||||
</div>
|
||||
@@ -448,6 +384,7 @@ onUnmounted(() => {
|
||||
<tr>
|
||||
<th style="width: 120px">账号</th>
|
||||
<th style="width: 160px">店铺</th>
|
||||
<th style="width: 90px">国家</th>
|
||||
<th style="width: 120px">业务</th>
|
||||
<th style="width: 120px">状态</th>
|
||||
<th style="width: 170px">任务ID</th>
|
||||
@@ -464,6 +401,7 @@ onUnmounted(() => {
|
||||
<span class="strong">{{ accountOf(row) }}</span>
|
||||
</td>
|
||||
<td>{{ shopDisplayName(row.shopName, row.shopCount) }}</td>
|
||||
<td class="mono">{{ row.country || '—' }}</td>
|
||||
<td>{{ row.moduleLabel || row.moduleType }}</td>
|
||||
<td>
|
||||
<span class="st-pill" :class="`is-${taskStatusType(row.status)}`">{{ taskStatusLabel(row.status) }}</span>
|
||||
@@ -491,10 +429,10 @@ onUnmounted(() => {
|
||||
</tr>
|
||||
</template>
|
||||
<tr v-else-if="tasksLoading">
|
||||
<td colspan="9" class="empty-tip">加载中...</td>
|
||||
<td colspan="10" class="empty-tip">加载中...</td>
|
||||
</tr>
|
||||
<tr v-else>
|
||||
<td colspan="9" class="empty-tip">暂无符合条件的任务</td>
|
||||
<td colspan="10" class="empty-tip">暂无符合条件的任务</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -768,20 +706,6 @@ h3 {
|
||||
color: #8598ab;
|
||||
font-size: 12.5px;
|
||||
}
|
||||
.shop-row {
|
||||
cursor: pointer;
|
||||
}
|
||||
.shop-row:hover td {
|
||||
background: #f2f8fd;
|
||||
}
|
||||
.shop-row.active td {
|
||||
background: #eaf2fb;
|
||||
}
|
||||
.shop-row.is-bucket,
|
||||
.shop-row.is-bucket:hover td {
|
||||
cursor: default;
|
||||
background: #fafcfe;
|
||||
}
|
||||
.is-warn-text {
|
||||
color: #b3803a;
|
||||
font-weight: 650;
|
||||
@@ -923,13 +847,6 @@ td {
|
||||
.cell-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.scope {
|
||||
display: inline-block;
|
||||
max-width: 160px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.res-mes {
|
||||
display: block;
|
||||
word-break: break-all;
|
||||
|
||||
@@ -44,8 +44,15 @@ export const MODULE_OPTIONS: Array<{ value: string; label: string }> = [
|
||||
{ value: 'BRAND', label: '品牌检测' },
|
||||
]
|
||||
|
||||
/**
|
||||
* 「在跑」= 待执行 ∪ 执行中 ∪ 已排期 的合并哨兵(后端展开成 IN 列表),不是表里的状态值。
|
||||
* 看板默认就用它:客户端任务的日常问题是「现在有什么在跑」,历史状态保留但不用来看。
|
||||
*/
|
||||
export const ACTIVE_TASK_STATUS = 'ACTIVE'
|
||||
|
||||
export const TASK_STATUS_OPTIONS: Array<{ value: string; label: string }> = [
|
||||
{ value: '', label: '全部状态' },
|
||||
{ value: ACTIVE_TASK_STATUS, label: '在跑' },
|
||||
{ value: 'PENDING', label: '待执行' },
|
||||
{ value: 'RUNNING', label: '执行中' },
|
||||
{ value: 'SCHEDULED', label: '已排期' },
|
||||
@@ -152,16 +159,23 @@ export interface TaskCenterProgress {
|
||||
progressSuccess: number
|
||||
progressFailed: number
|
||||
progressTotal: number
|
||||
moduleType?: string | null
|
||||
}
|
||||
|
||||
function progressDone(row: TaskCenterProgress): number {
|
||||
return Math.max(0, Number(row.progressSuccess || 0)) + Math.max(0, Number(row.progressFailed || 0))
|
||||
}
|
||||
|
||||
/** 采集数据在客户端写的是「关键词进度:第 N/总 个」(N = 已处理 + 1,封顶总个数),
|
||||
* 照抄口径而不是这里另造一套说法:见 frontend-vue BrandCollectDataTab.vue taskKeywordProgress。 */
|
||||
export function progressText(row: TaskCenterProgress): string {
|
||||
const total = Number(row.progressTotal || 0)
|
||||
if (total <= 0) return '—'
|
||||
return `已完成 ${progressDone(row)} / 总 ${total}`
|
||||
const done = progressDone(row)
|
||||
if ((row.moduleType || '').toUpperCase() === 'COLLECT_DATA') {
|
||||
return `关键词进度:第 ${Math.min(total, done + 1)}/${total} 个`
|
||||
}
|
||||
return `已完成 ${done} / 总 ${total}`
|
||||
}
|
||||
|
||||
export function progressPercent(row: TaskCenterProgress): number {
|
||||
|
||||
Reference in New Issue
Block a user