feat(后台): 日期筛选统一默认当天(7 页 + 告警铃铛),并带上看板列改造的在途改动
- utils/datetime 新增 todayDateInput()/todayDateTimeRange(),8 处日期筛选的初值与「重置」都锁当天; 撞款监控按口径排除(该页日期是 ASIN 上架时间,默认当天会让首屏几乎为空)。 - NotificationBell 的 hasFilter 不再把日期计入:日期恒有值是默认视图,计入会让 「无筛选才记录已提醒 id」那条分支永久失效。 - 新增护栏 tests/date-filter-default-today.test.ts(6 例,变异自证 3/3 转红): 凡带日期控件的页面没接入当天默认就红,不等人工发现首屏是空的。 - 同批带上另一路会话的看板在途改动(task-center-model 的 tabCount/完成数口径、 TaskCenterBoardPage 列改造与对应用例):它与本页的日期默认改动落在同一文件, 拆开会让单次提交编译不过,故按现状一起上。
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
import { computed, onMounted, onUnmounted, reactive, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
import { formatDateTime, todayDateTimeRange } from '@/utils/datetime'
|
||||
import {
|
||||
fetchTaskCenterOverview,
|
||||
fetchTaskCenterShopOptions,
|
||||
@@ -32,6 +32,7 @@ import {
|
||||
progressPercent,
|
||||
progressText,
|
||||
shopDisplayName,
|
||||
tabCount,
|
||||
taskStatusLabel,
|
||||
taskStatusType,
|
||||
variantAccountText,
|
||||
@@ -51,7 +52,12 @@ const activeTab = ref<BoardTab>('tasks')
|
||||
const overview = ref<TaskCenterOverview | null>(null)
|
||||
const shops = ref<TaskCenterShop[]>([])
|
||||
const shopOptions = ref<string[]>([])
|
||||
const filter = reactive<TaskCenterTaskFilter>(createTaskFilter())
|
||||
/** 首屏与「重置」都锁定当天;共享工厂 createTaskFilter 保持全空(它被单测与别处复用)。 */
|
||||
function todayTaskRange(): Pick<TaskCenterTaskFilter, 'startTime' | 'endTime'> {
|
||||
const [startTime, endTime] = todayDateTimeRange()
|
||||
return { startTime, endTime }
|
||||
}
|
||||
const filter = reactive<TaskCenterTaskFilter>({ ...createTaskFilter(), ...todayTaskRange() })
|
||||
const tasks = ref<TaskCenterTaskRow[]>([])
|
||||
const taskTotal = ref(0)
|
||||
const taskPage = ref(1)
|
||||
@@ -62,7 +68,8 @@ const tasksLoading = ref(false)
|
||||
|
||||
const variantFilter = reactive<TaskCenterVariantFilter>(createVariantFilter())
|
||||
const variantRows = ref<TaskCenterVariantTaskRow[]>([])
|
||||
const variantTotal = ref(0)
|
||||
/** 没查过就是 null(徽章画「—」):变体列表是外部依赖,停在页签一时不能替它说 0。 */
|
||||
const variantTotal = ref<number | null>(null)
|
||||
const variantPage = ref(1)
|
||||
const variantPageSize = ref(20)
|
||||
const variantLoading = ref(false)
|
||||
@@ -76,7 +83,11 @@ const detail = ref<TaskCenterTaskDetail | null>(null)
|
||||
const updatedAt = ref('')
|
||||
|
||||
const taskTotalPages = computed(() => Math.max(1, Math.ceil(taskTotal.value / taskPageSize.value)))
|
||||
const variantTotalPages = computed(() => Math.max(1, Math.ceil(variantTotal.value / variantPageSize.value)))
|
||||
const variantTotalPages = computed(() => Math.max(1, Math.ceil((variantTotal.value ?? 0) / variantPageSize.value)))
|
||||
|
||||
/** 页签一徽章 = 当前在跑任务数,与汇总卡「进行中任务」同源,不允许两处各算各的。
|
||||
* 列表 total(历史全量,且每天 00:00 的 7 天保留清理会往下掉)只用于分页,不上徽章。 */
|
||||
const runningBadge = computed(() => tabCount(overview.value?.runningTasks))
|
||||
|
||||
/** 下拉候选 = 店铺库 + 面板上出现的店铺名(后者可能已从店铺库删掉,下钻要筛得动)。 */
|
||||
const shopFilterOptions = computed(() => {
|
||||
@@ -136,8 +147,9 @@ async function loadVariants(silent = false) {
|
||||
buildVariantQuery(variantFilter, variantPage.value, variantPageSize.value),
|
||||
)
|
||||
variantRows.value = result?.items || []
|
||||
variantTotal.value = Number(result?.total || 0)
|
||||
variantTotal.value = tabCount(result?.total)
|
||||
} catch (error) {
|
||||
variantTotal.value = null
|
||||
ElMessage.error(errorText(error, '变体采集加载失败'))
|
||||
} finally {
|
||||
if (!silent) variantLoading.value = false
|
||||
@@ -155,6 +167,13 @@ async function refreshAll(silent = false) {
|
||||
updatedAt.value = formatDateTime(Date.now())
|
||||
}
|
||||
|
||||
/** 首屏把「另一个页签」也查一遍,徽章才有真数可画。
|
||||
* 只补这一次:变体列表代理麦象 console(外部依赖、8s 超时),不进 30s 轮询热路径。 */
|
||||
async function loadInactiveTabTotal() {
|
||||
if (activeTab.value === 'tasks') await loadVariants(true)
|
||||
else await loadTasks(true)
|
||||
}
|
||||
|
||||
function switchTab(tab: BoardTab) {
|
||||
if (activeTab.value === tab) return
|
||||
activeTab.value = tab
|
||||
@@ -171,7 +190,7 @@ function search() {
|
||||
}
|
||||
|
||||
function resetFilter() {
|
||||
Object.assign(filter, createTaskFilter())
|
||||
Object.assign(filter, createTaskFilter(), todayTaskRange())
|
||||
taskPage.value = 1
|
||||
void loadTasks()
|
||||
}
|
||||
@@ -259,6 +278,7 @@ function onVisibilityChange() {
|
||||
|
||||
onMounted(() => {
|
||||
void refreshAll()
|
||||
void loadInactiveTabTotal()
|
||||
document.addEventListener('visibilitychange', onVisibilityChange)
|
||||
pollTimer = setInterval(() => {
|
||||
if (typeof document !== 'undefined' && document.visibilityState !== 'visible') return
|
||||
@@ -281,10 +301,10 @@ onUnmounted(() => {
|
||||
<div class="tc-head">
|
||||
<div class="tabs">
|
||||
<button class="tab" :class="{ active: activeTab === 'tasks' }" type="button" @click="switchTab('tasks')">
|
||||
客户端任务 <span class="t-count">{{ taskTotal }}</span>
|
||||
客户端任务 <span class="t-count" title="当前在跑任务数,与上方「进行中任务」同源">{{ runningBadge ?? '—' }}</span>
|
||||
</button>
|
||||
<button class="tab" :class="{ active: activeTab === 'variant' }" type="button" @click="switchTab('variant')">
|
||||
变体采集 <span class="t-count">{{ variantTotal }}</span>
|
||||
变体采集 <span class="t-count" title="麦象批量任务条数(全部状态),「—」= 还没查到">{{ variantTotal ?? '—' }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="tc-head-tools">
|
||||
@@ -394,6 +414,7 @@ onUnmounted(() => {
|
||||
<label>店铺</label>
|
||||
<el-select
|
||||
v-model="filter.shop"
|
||||
class="admin-filter"
|
||||
filterable
|
||||
clearable
|
||||
placeholder="全部店铺"
|
||||
@@ -429,12 +450,11 @@ onUnmounted(() => {
|
||||
<th style="width: 160px">店铺</th>
|
||||
<th style="width: 120px">业务</th>
|
||||
<th style="width: 120px">状态</th>
|
||||
<th style="width: 170px">当前处理</th>
|
||||
<th style="width: 170px">任务ID</th>
|
||||
<th style="width: 165px">开始时间</th>
|
||||
<th style="width: 165px">最近上报</th>
|
||||
<th style="width: 165px">结束时间</th>
|
||||
<th style="width: 190px">进度</th>
|
||||
<th style="width: 90px">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -442,7 +462,6 @@ onUnmounted(() => {
|
||||
<tr v-for="row in tasks" :key="row.taskNo">
|
||||
<td>
|
||||
<span class="strong">{{ accountOf(row) }}</span>
|
||||
<span class="sub">{{ row.taskNo }}</span>
|
||||
</td>
|
||||
<td>{{ shopDisplayName(row.shopName, row.shopCount) }}</td>
|
||||
<td>{{ row.moduleLabel || row.moduleType }}</td>
|
||||
@@ -451,7 +470,7 @@ onUnmounted(() => {
|
||||
<span v-if="row.stuck" class="badge warn">疑似卡住</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="scope" :title="currentScopeOf(row)">{{ currentScopeOf(row) }}</span>
|
||||
<button class="cell-link mono" type="button" @click="openDetail(row)">{{ row.id }}</button>
|
||||
</td>
|
||||
<td>{{ formatDateTime(row.createdAt) }}</td>
|
||||
<td>
|
||||
@@ -467,16 +486,13 @@ onUnmounted(() => {
|
||||
</div>
|
||||
<div class="p-track"><div class="p-fill" :style="{ width: progressPercent(row) + '%' }"></div></div>
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn btn-ghost btn-sm" type="button" @click="openDetail(row)">查看</button>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
<tr v-else-if="tasksLoading">
|
||||
<td colspan="10" class="empty-tip">加载中...</td>
|
||||
<td colspan="9" class="empty-tip">加载中...</td>
|
||||
</tr>
|
||||
<tr v-else>
|
||||
<td colspan="10" class="empty-tip">暂无符合条件的任务</td>
|
||||
<td colspan="9" class="empty-tip">暂无符合条件的任务</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -559,7 +575,7 @@ onUnmounted(() => {
|
||||
</table>
|
||||
</div>
|
||||
<OldPagination
|
||||
:total="variantTotal"
|
||||
:total="variantTotal ?? 0"
|
||||
:page="variantPage"
|
||||
:page-size="variantPageSize"
|
||||
@change="changeVariantPage"
|
||||
@@ -771,7 +787,12 @@ h3 {
|
||||
.shop-filter {
|
||||
position: relative;
|
||||
}
|
||||
/* 提示行必须退出列流:.form-row 是 align-items: flex-end,组内多一行会把「店铺」label 顶得比别的筛选项高。 */
|
||||
.filter-tip {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: calc(100% + 4px);
|
||||
white-space: nowrap;
|
||||
color: #93a4b5;
|
||||
font-size: 11.5px;
|
||||
}
|
||||
@@ -780,7 +801,7 @@ h3 {
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-end;
|
||||
gap: 14px 18px;
|
||||
margin-bottom: 16px;
|
||||
margin-bottom: 22px;
|
||||
}
|
||||
.form-group {
|
||||
display: flex;
|
||||
@@ -850,12 +871,6 @@ h3 {
|
||||
border-color: #95b1cb;
|
||||
color: #2f5d8b;
|
||||
}
|
||||
.btn-sm {
|
||||
min-height: 32px;
|
||||
padding: 4px 12px;
|
||||
font-size: 12.5px;
|
||||
border-radius: 7px;
|
||||
}
|
||||
.table-scroll {
|
||||
width: 100%;
|
||||
overflow-x: auto;
|
||||
@@ -895,6 +910,17 @@ td {
|
||||
font-size: 12px;
|
||||
word-break: break-all;
|
||||
}
|
||||
/* 任务 ID 单元格:「操作」列删除后,它是详情抽屉唯一的入口。 */
|
||||
.cell-link {
|
||||
padding: 0;
|
||||
border: none;
|
||||
background: none;
|
||||
color: #2f5d8b;
|
||||
cursor: pointer;
|
||||
}
|
||||
.cell-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.scope {
|
||||
display: inline-block;
|
||||
max-width: 160px;
|
||||
|
||||
Reference in New Issue
Block a user