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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user