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:
@@ -145,6 +145,7 @@ import {
|
||||
readLastNotifiedId,
|
||||
writeLastNotifiedId,
|
||||
} from '@/layout/notification-bell-model'
|
||||
import { todayDateInput } from '@/utils/datetime'
|
||||
|
||||
const PAGE_SIZE = 10
|
||||
|
||||
@@ -162,13 +163,14 @@ const loading = ref(false)
|
||||
const markingAll = ref(false)
|
||||
const loadError = ref('')
|
||||
const keyword = ref('')
|
||||
const startDate = ref('')
|
||||
const endDate = ref('')
|
||||
const startDate = ref(todayDateInput())
|
||||
const endDate = ref(todayDateInput())
|
||||
|
||||
const badgeText = computed(() => formatUnreadBadge(unreadCount.value))
|
||||
const groupedItems = computed(() => groupNotificationsByDay(items.value))
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / PAGE_SIZE)))
|
||||
const hasFilter = computed(() => Boolean(keyword.value.trim() || startDate.value || endDate.value))
|
||||
/** 日期恒为「当天」是默认视图、不算主动筛选:若计入,下方「无筛选才记录已提醒 id」的分支会永久失效。 */
|
||||
const hasFilter = computed(() => Boolean(keyword.value.trim()))
|
||||
|
||||
/**
|
||||
* el-date-picker 的绑定桥:日期区间在内部仍用 startDate/endDate 两个 ref 表示
|
||||
@@ -279,8 +281,8 @@ function onKeywordInput() {
|
||||
|
||||
function resetFilters() {
|
||||
keyword.value = ''
|
||||
startDate.value = ''
|
||||
endDate.value = ''
|
||||
startDate.value = todayDateInput()
|
||||
endDate.value = todayDateInput()
|
||||
void loadPage(1)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
import { todayDateInput } from '@/utils/datetime'
|
||||
import {
|
||||
fetchUserSecretUsage,
|
||||
type AdminUserSecretUsageRow,
|
||||
@@ -19,8 +20,8 @@ const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = ref(15)
|
||||
const keyword = ref('')
|
||||
const startDate = ref('')
|
||||
const endDate = ref('')
|
||||
const startDate = ref(todayDateInput())
|
||||
const endDate = ref(todayDateInput())
|
||||
const groupFilter = ref<number | null>(null)
|
||||
const groupOptions = ref<GroupOption[]>([])
|
||||
|
||||
@@ -68,8 +69,8 @@ function search() {
|
||||
|
||||
function reset() {
|
||||
keyword.value = ''
|
||||
startDate.value = ''
|
||||
endDate.value = ''
|
||||
startDate.value = todayDateInput()
|
||||
endDate.value = todayDateInput()
|
||||
groupFilter.value = null
|
||||
page.value = 1
|
||||
load()
|
||||
@@ -180,7 +181,7 @@ onMounted(load)
|
||||
</tr>
|
||||
<tr v-else>
|
||||
<td :colspan="isSuperAdmin ? 7 : 6" class="empty-tip">
|
||||
{{ keyword || startDate || endDate || groupFilter ? '暂无匹配记录' : '暂无用量记录' }}
|
||||
{{ keyword || groupFilter ? '暂无匹配记录' : '暂无用量记录' }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
import { formatDateTime, todayDateInput } from '@/utils/datetime'
|
||||
/** 数据去重总数据(registry) · 像素复刻旧版 admin.html panel-dedupe-total-data(自绘:分组摘要 + 双行筛选 + 旧式表格/分页 + 编辑/导入弹窗 + 导出等待遮罩)。
|
||||
* script 逻辑沿用现有 Vue 实现(查询/编辑/删除/导入轮询/导出秒表)。 */
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
@@ -35,7 +35,7 @@ const rows = ref<DedupeTotalItem[]>([])
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = ref(10)
|
||||
const filter = reactive(createDedupeTotalFilterState())
|
||||
const filter = reactive({ ...createDedupeTotalFilterState(), startDate: todayDateInput(), endDate: todayDateInput() })
|
||||
const groups = ref<DedupeGroupOption[]>([])
|
||||
/** 非超管仅有一个可访问分组时,编辑/导入弹窗分组选择锁定为该组(保留展示、不可改)。 */
|
||||
const lockedGroupId = computed<number | null>(() => {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
/** 日志管理页:桌面客户端 / 麦象采集机上报的日志浏览(仅超管)。
|
||||
* 支持来源/日期/关键字筛选,尾部内容查看(自动滚到底、可向前加载更早内容)、
|
||||
* 支持来源/用户/日期筛选,尾部内容查看(自动滚到底、可向前加载更早内容)、
|
||||
* 完整下载、删除;「采集配置」可调全量/精选模式(全局默认 + 终端覆盖)。 */
|
||||
import { computed, nextTick, onMounted, ref } from 'vue'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
import { formatDateTime, todayDateInput } from '@/utils/datetime'
|
||||
import { fetchHistoryUserOptions } from './history-api.ts'
|
||||
import type { HistoryUserOption } from './history-user-option.ts'
|
||||
import {
|
||||
deleteDeviceLogFile,
|
||||
deleteDeviceLogOverride,
|
||||
@@ -53,9 +55,11 @@ const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = ref(15)
|
||||
const sourceFilter = ref('')
|
||||
const keyword = ref('')
|
||||
const startDate = ref('')
|
||||
const endDate = ref('')
|
||||
const uidFilter = ref('')
|
||||
const userOptions = ref<HistoryUserOption[]>([])
|
||||
const usersLoading = ref(false)
|
||||
const startDate = ref(todayDateInput())
|
||||
const endDate = ref(todayDateInput())
|
||||
const retentionDays = ref(7)
|
||||
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
||||
@@ -65,7 +69,7 @@ async function load() {
|
||||
try {
|
||||
const result = await fetchDeviceLogFiles({
|
||||
source: sourceFilter.value || undefined,
|
||||
keyword: keyword.value.trim() || undefined,
|
||||
uid: uidFilter.value ? Number(uidFilter.value) : undefined,
|
||||
startDate: startDate.value || undefined,
|
||||
endDate: endDate.value || undefined,
|
||||
page: page.value,
|
||||
@@ -81,6 +85,17 @@ async function load() {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadUserOptions() {
|
||||
usersLoading.value = true
|
||||
try {
|
||||
userOptions.value = await fetchHistoryUserOptions()
|
||||
} catch {
|
||||
userOptions.value = []
|
||||
} finally {
|
||||
usersLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function search() {
|
||||
page.value = 1
|
||||
load()
|
||||
@@ -88,9 +103,9 @@ function search() {
|
||||
|
||||
function reset() {
|
||||
sourceFilter.value = ''
|
||||
keyword.value = ''
|
||||
startDate.value = ''
|
||||
endDate.value = ''
|
||||
uidFilter.value = ''
|
||||
startDate.value = todayDateInput()
|
||||
endDate.value = todayDateInput()
|
||||
page.value = 1
|
||||
load()
|
||||
}
|
||||
@@ -237,7 +252,10 @@ async function removeOverride(row: DeviceLogOverride) {
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
onMounted(() => {
|
||||
load()
|
||||
loadUserOptions()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -259,9 +277,12 @@ onMounted(load)
|
||||
<option v-for="option in SOURCE_OPTIONS" :key="option.value" :value="option.value">{{ option.label }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" style="min-width: 220px">
|
||||
<label>设备 / 文件名</label>
|
||||
<input v-model="keyword" type="text" placeholder="模糊搜索设备名、设备ID、文件名" @keyup.enter="search" />
|
||||
<div class="form-group" style="min-width: 180px">
|
||||
<label>指定用户</label>
|
||||
<select v-model="uidFilter" :disabled="usersLoading">
|
||||
<option value="">全部用户</option>
|
||||
<option v-for="u in userOptions" :key="u.id" :value="String(u.id)">{{ u.username }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" style="min-width: 150px">
|
||||
<label>日志日期(起)</label>
|
||||
@@ -285,8 +306,7 @@ onMounted(load)
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 110px">来源</th>
|
||||
<th style="width: 230px">设备</th>
|
||||
<th style="width: 130px">用户</th>
|
||||
<th style="width: 200px">用户</th>
|
||||
<th style="width: 230px">文件名</th>
|
||||
<th style="width: 110px">日志日期</th>
|
||||
<th style="width: 100px">已收大小</th>
|
||||
@@ -303,10 +323,6 @@ onMounted(load)
|
||||
{{ sourceLabel(row.source) }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="device-name" :title="row.deviceId">{{ row.deviceName || '—' }}</span>
|
||||
<span class="device-id" :title="row.deviceId">{{ row.deviceId }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<span v-if="row.username" class="user-name">{{ row.username }}</span>
|
||||
<span v-else-if="row.uid" class="user-name">UID {{ row.uid }}</span>
|
||||
@@ -327,11 +343,11 @@ onMounted(load)
|
||||
</tr>
|
||||
</template>
|
||||
<tr v-else-if="loading">
|
||||
<td colspan="9" class="empty-tip">加载中...</td>
|
||||
<td colspan="8" class="empty-tip">加载中...</td>
|
||||
</tr>
|
||||
<tr v-else>
|
||||
<td colspan="9" class="empty-tip">
|
||||
{{ keyword || sourceFilter || startDate || endDate ? '暂无匹配日志' : '暂无日志上报(客户端/采集机上报后自动出现在这里)' }}
|
||||
<td colspan="8" class="empty-tip">
|
||||
{{ sourceFilter || uidFilter ? '暂无匹配日志' : '暂无日志上报(客户端/采集机上报后自动出现在这里)' }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
/** 生成记录页 · 像素复刻旧版 admin.html panel-history(自绘:form-box 筛选 + panel-box 表格 + 旧式分页 + thumb 缩略图)。
|
||||
* script 逻辑沿用现有 Vue 实现(查询/翻页/跳页/点击缩略图放大预览)。 */
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
import { formatDateTime, todayDateTimeRange } from '@/utils/datetime'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { fetchHistoryList, fetchHistoryUserOptions } from './history-api.ts'
|
||||
import type { HistoryUserOption } from './history-user-option.ts'
|
||||
@@ -19,7 +19,8 @@ const page = ref(1)
|
||||
const pageSize = ref(10)
|
||||
const userOptions = ref<HistoryUserOption[]>([])
|
||||
const errorText = ref('')
|
||||
const filter = reactive({ userId: '', timeStart: '', timeEnd: '' })
|
||||
const [todayStart, todayEnd] = todayDateTimeRange()
|
||||
const filter = reactive({ userId: '', timeStart: todayStart, timeEnd: todayEnd })
|
||||
|
||||
const previewVisible = ref(false)
|
||||
const previewItem = ref<HistoryRecordItem | null>(null)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -135,17 +135,37 @@ export function shopDisplayName(shopName: string | null | undefined, shopCount:
|
||||
return count > 1 ? `${name} 等${count}个` : name
|
||||
}
|
||||
|
||||
export function progressText(row: { progressSuccess: number; progressTotal: number }): string {
|
||||
const total = Number(row.progressTotal || 0)
|
||||
if (total <= 0) return '—'
|
||||
return `成功 ${Number(row.progressSuccess || 0)} / 总 ${total}`
|
||||
/** 页签徽章用的条数:只有接口真的回了非负数才算一个数,否则回 null 画「—」。
|
||||
* 麦象在结果表未注册时把 total 回成 -1 哨兵,`Number(x || 0)` 会把它读成 0 条。 */
|
||||
export function tabCount(total: unknown): number | null {
|
||||
if (total === null || total === undefined || total === '') return null
|
||||
const value = Number(total)
|
||||
return Number.isFinite(value) && value >= 0 ? value : null
|
||||
}
|
||||
|
||||
export function progressPercent(row: { progressSuccess: number; progressTotal: number }): number {
|
||||
/** 进度行:已完成数 = 成功 + 失败,与客户端一致(跑完一步就计入,不论成败)。
|
||||
* 见 frontend-vue `BrandBrandTab.vue`「完成数 = 已处理品牌行(成功或查询失败都计入)」;
|
||||
* 旧口径只数成功,会把「1 步全失败」的终态任务显示成 0 / 1。 */
|
||||
export interface TaskCenterProgress {
|
||||
progressSuccess: number
|
||||
progressFailed: number
|
||||
progressTotal: number
|
||||
}
|
||||
|
||||
function progressDone(row: TaskCenterProgress): number {
|
||||
return Math.max(0, Number(row.progressSuccess || 0)) + Math.max(0, Number(row.progressFailed || 0))
|
||||
}
|
||||
|
||||
export function progressText(row: TaskCenterProgress): string {
|
||||
const total = Number(row.progressTotal || 0)
|
||||
if (total <= 0) return '—'
|
||||
return `已完成 ${progressDone(row)} / 总 ${total}`
|
||||
}
|
||||
|
||||
export function progressPercent(row: TaskCenterProgress): number {
|
||||
const total = Number(row.progressTotal || 0)
|
||||
if (total <= 0) return 0
|
||||
const percent = Math.round((Number(row.progressSuccess || 0) / total) * 100)
|
||||
return Math.min(100, Math.max(0, percent))
|
||||
return Math.min(100, Math.max(0, Math.round((progressDone(row) / total) * 100)))
|
||||
}
|
||||
|
||||
/** datetime-local 原生值(YYYY-MM-DDTHH:mm) → 后端 LocalDateTime 兼容的秒级格式。 */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
import { formatDateTime, todayDateTimeRange } from '@/utils/datetime'
|
||||
/** 视频任务记录页 · 像素复刻旧版 admin.html panel-image-video-tasks(自绘:form-box 筛选[用户名/提交起止+查询/重置] + panel-box toolbar[全选/批量下载/权限配置/汇总] + 任务卡片网格 + 旧式分页)。
|
||||
* script 逻辑沿用现有 Vue 实现(批量打包/明细抽屉/权限授权)。 */
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
@@ -29,7 +29,10 @@ const pageSize = ref(10)
|
||||
const jumpPage = ref('')
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(totalTasks.value / pageSize.value)))
|
||||
|
||||
const filter = reactive<ImageVideoFilter & { dateRange: string[] }>({ ...createImageVideoFilter(), dateRange: [] })
|
||||
const filter = reactive<ImageVideoFilter & { dateRange: string[] }>({
|
||||
...createImageVideoFilter(),
|
||||
dateRange: todayDateTimeRange(),
|
||||
})
|
||||
const selection = ref<Set<string>>(new Set())
|
||||
|
||||
const detailVisible = ref(false)
|
||||
@@ -128,7 +131,7 @@ function apply() {
|
||||
|
||||
function reset() {
|
||||
Object.assign(filter, createImageVideoFilter())
|
||||
filter.dateRange = []
|
||||
filter.dateRange = todayDateTimeRange()
|
||||
page.value = 1
|
||||
void load()
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
import { formatDateTime, todayDateTimeRange } from '@/utils/datetime'
|
||||
/** 店铺数据记录页 · 像素复刻旧版 admin.html panel-shop-data-crawl-tasks(自绘:form-box 筛选[h4 筛选条件] + panel-box toolbar[全选/批量下载/权限配置/汇总] + 每店卡片网格 + 旧式分页(店铺级+卡片级 9/页))。
|
||||
* script 逻辑沿用现有 Vue 实现(批量打包/删除结果文件[保留]/权限授权)。 */
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
@@ -40,7 +40,10 @@ const cardPageSize = ref(10)
|
||||
const cardJump = ref('')
|
||||
const cardTotalPages = computed(() => Math.max(1, Math.ceil(allResultRows.value.length / cardPageSize.value)))
|
||||
|
||||
const filter = reactive<ShopDataFilter & { dateRange: string[] }>({ ...createShopDataFilter(), dateRange: [] })
|
||||
const filter = reactive<ShopDataFilter & { dateRange: string[] }>({
|
||||
...createShopDataFilter(),
|
||||
dateRange: todayDateTimeRange(),
|
||||
})
|
||||
const selection = ref<Set<string>>(new Set())
|
||||
|
||||
const permissionVisible = ref(false)
|
||||
@@ -134,7 +137,7 @@ function apply() {
|
||||
|
||||
function reset() {
|
||||
Object.assign(filter, createShopDataFilter())
|
||||
filter.dateRange = []
|
||||
filter.dateRange = todayDateTimeRange()
|
||||
page.value = 1
|
||||
void load()
|
||||
}
|
||||
|
||||
@@ -34,6 +34,17 @@ function pad(n: string | number): string {
|
||||
return String(n).padStart(2, '0')
|
||||
}
|
||||
|
||||
/** 后台日期筛选的统一默认值:进入页面即锁定「当天」。 */
|
||||
export function todayDateInput(now: Date = new Date()): string {
|
||||
return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`
|
||||
}
|
||||
|
||||
/** 当天区间(原生 <input type="datetime-local"> 取值形态,止于 23:59 与手工选择口径一致)。 */
|
||||
export function todayDateTimeRange(now: Date = new Date()): [string, string] {
|
||||
const day = todayDateInput(now)
|
||||
return [`${day}T00:00`, `${day}T23:59`]
|
||||
}
|
||||
|
||||
function padDate(d: Date): string {
|
||||
const y = d.getFullYear()
|
||||
const mo = pad(d.getMonth() + 1)
|
||||
|
||||
Reference in New Issue
Block a user