898e8a5ea9
- BatchDeleteActions margin-left:auto 右对齐、不再独占一行,14 页迁入各自筛选/工具行(Users/Groups/Menus/UserSecrets/QueryAsin/AsinInvalid/SkipPrice/DedupeRegistry/ProductCategory/DeviceLogs/DigitalHuman/ShopManage/ShopKeys/BrandGating);主按钮沿用全局 34px 同高,align-batch-toolbar-inline.test.ts 钉形状防回归
- 公司删除:DELETE /api/admin/companies/{id}(仅超管,名下有账号拒并带数量),只收公司行+columns 菜单树(PermissionMenuService.deleteTreeByCompany 与 copyTreeFromTemplate 对称),业务数据不级联;列表 VO 带 user_count 供前端置灰勾选/删除按钮;批量删除按用户管理同形走前端逐条循环
- CompaniesPage 加勾选列+行删除按钮(ops-cell 补 flex-wrap 过 ops-cell-must-wrap),删除后 refreshCompanyDirectory 同步 tab 条
- 测试:CompanyServiceDeleteTest 6+PermissionMenuServiceDeleteTreeTest 2+CompanyVoTest user_count 契约+CompanyControllerEndpointTest 翻转 exposesNoDeleteEndpoint→点名 DELETE 端点+CompanyReadPathMenuGateTest ensureSuperAdmin 3→4(delete 入册)+company-directory/row-buttons 补例;source-pin 基线重生成(265 文件/1859 例)
- 验证:admin-vue vue-tsc rc=0、node --test 1976 全绿、vitest mount 247 全绿;backend test-compile rc=0、Company*/PermissionMenu*/跨切守卫点名全绿(CatchSilenceRatchet 红因=另一路在飞件 JdPublishFillAiService 3 个 catch,归属京东窗不代抬)
797 lines
25 KiB
Vue
797 lines
25 KiB
Vue
<script setup lang="ts">
|
||
import BatchDeleteActions from '@/components/BatchDeleteActions.vue'
|
||
import BatchDeleteCheckbox from '@/components/BatchDeleteCheckbox.vue'
|
||
import { useRowSelection } from '@/utils/use-row-selection'
|
||
/** 日志管理页:桌面客户端 / 麦象采集机上报的日志浏览(仅超管)。
|
||
* 支持来源/用户/日期筛选,尾部内容查看(自动滚到底、可向前加载更早内容)、
|
||
* 完整下载、删除;「采集配置」可调全量/精选模式(全局默认 + 终端覆盖)。 */
|
||
import { computed, nextTick, onMounted, ref, watch } from 'vue'
|
||
import OldPagination from '@/components/OldPagination.vue'
|
||
import { ElMessage } from 'element-plus'
|
||
import { formatDateTime, orderedPair, todayDateInput } from '@/utils/datetime'
|
||
import { createLatestRequestGate } from '@/utils/latest-request'
|
||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||
import { fetchHistoryUserOptions } from './history-api.ts'
|
||
import type { HistoryUserOption } from './history-user-option.ts'
|
||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||
import { openAdminConfirm } from '@/components/admin-confirm'
|
||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
||
import {
|
||
deleteDeviceLogFile,
|
||
deleteDeviceLogOverride,
|
||
deviceLogDownloadUrl,
|
||
fetchDeviceLogConfig,
|
||
fetchDeviceLogContent,
|
||
fetchDeviceLogDevices,
|
||
fetchDeviceLogFiles,
|
||
updateDeviceLogGlobalMode,
|
||
updateDeviceLogOverride,
|
||
type DeviceLogContent,
|
||
type DeviceLogDevice,
|
||
type DeviceLogFileRow,
|
||
type DeviceLogOverride,
|
||
} from '@/api/device-logs'
|
||
|
||
const SOURCE_OPTIONS = [
|
||
{ value: '', label: '全部来源' },
|
||
{ value: 'client', label: '桌面客户端' },
|
||
{ value: 'maixiang', label: '麦象采集机' },
|
||
]
|
||
|
||
function sourceLabel(source: string): string {
|
||
if (source === 'client') return '桌面客户端'
|
||
if (source === 'maixiang') return '麦象采集机'
|
||
return source || '—'
|
||
}
|
||
|
||
function formatBytes(bytes: number | null | undefined): string {
|
||
if (bytes == null || !Number.isFinite(bytes) || bytes <= 0) return '—'
|
||
if (bytes < 1024) return `${bytes} B`
|
||
const units = ['KB', 'MB', 'GB']
|
||
let value = bytes / 1024
|
||
let unitIndex = 0
|
||
while (value >= 1024 && unitIndex < units.length - 1) {
|
||
value /= 1024
|
||
unitIndex += 1
|
||
}
|
||
return `${value >= 100 ? value.toFixed(0) : value.toFixed(1)} ${units[unitIndex]}`
|
||
}
|
||
|
||
const companyTab = useCompanyTabStore()
|
||
|
||
const loading = ref(false)
|
||
const loadFailure = ref('')
|
||
// 设备日志列表竞态门(S1-F4)
|
||
const gate = createLatestRequestGate()
|
||
const rows = ref<DeviceLogFileRow[]>([])
|
||
const total = ref(0)
|
||
const page = ref(1)
|
||
const pageSize = ref(15)
|
||
const sourceFilter = ref('')
|
||
const uidFilter = ref('')
|
||
const userOptions = ref<HistoryUserOption[]>([])
|
||
const usersLoading = ref(false)
|
||
const startDate = ref(todayDateInput())
|
||
const endDate = ref(todayDateInput())
|
||
/** min/max 挡不住手输,落值后把倒挂的起止交换回来。 */
|
||
function clampDatePair(): void {
|
||
const [s, e] = orderedPair(startDate.value, endDate.value)
|
||
startDate.value = s
|
||
endDate.value = e
|
||
}
|
||
|
||
const retentionDays = ref(7)
|
||
|
||
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
||
|
||
async function load() {
|
||
// S1-F4:快速切公司/改筛选时旧响应可能晚到——回写前必须过竞态门
|
||
const token = gate.begin()
|
||
loading.value = true
|
||
loadFailure.value = ''
|
||
try {
|
||
const result = await fetchDeviceLogFiles({
|
||
source: sourceFilter.value || undefined,
|
||
uid: uidFilter.value ? Number(uidFilter.value) : undefined,
|
||
startDate: startDate.value || undefined,
|
||
endDate: endDate.value || undefined,
|
||
page: page.value,
|
||
pageSize: pageSize.value,
|
||
companyId: companyTab.requestCompanyId,
|
||
})
|
||
if (!gate.isCurrent(token)) return
|
||
rows.value = result?.items || []
|
||
total.value = Number(result?.total || 0)
|
||
if (result?.retentionDays) retentionDays.value = result.retentionDays
|
||
} catch (error) {
|
||
if (!gate.isCurrent(token)) return
|
||
loadFailure.value = error instanceof Error ? error.message : '日志列表加载失败'
|
||
showAdminFeedback(loadFailure.value, 'error')
|
||
} finally {
|
||
if (gate.isCurrent(token)) loading.value = false
|
||
}
|
||
}
|
||
|
||
// 切公司 = 重新取数(形状同店铺管理页):只有列表这一个取数口按公司收窄,
|
||
// 内容/下载/删除/终端下拉都不带 company_id,所以这里只需重跑 load()。
|
||
watch(() => companyTab.activeId, () => void 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()
|
||
}
|
||
|
||
function reset() {
|
||
sourceFilter.value = ''
|
||
uidFilter.value = ''
|
||
startDate.value = todayDateInput()
|
||
endDate.value = todayDateInput()
|
||
page.value = 1
|
||
load()
|
||
}
|
||
|
||
function changePage(next: number) {
|
||
if (next < 1 || next > totalPages.value) return
|
||
page.value = next
|
||
load()
|
||
}
|
||
|
||
function changeSize(size: number) {
|
||
pageSize.value = size
|
||
page.value = 1
|
||
load()
|
||
}
|
||
|
||
// ---------------------------------------------------------------- 内容查看
|
||
|
||
const TAIL_STEP = 256 * 1024
|
||
const TAIL_MAX = 8 * 1024 * 1024
|
||
|
||
const viewerVisible = ref(false)
|
||
const viewerLoading = ref(false)
|
||
const viewerFile = ref<DeviceLogFileRow | null>(null)
|
||
const viewerContent = ref<DeviceLogContent | null>(null)
|
||
const viewerMaxBytes = ref(TAIL_STEP)
|
||
const viewerPre = ref<HTMLElement | null>(null)
|
||
|
||
async function openViewer(row: DeviceLogFileRow) {
|
||
viewerFile.value = row
|
||
viewerMaxBytes.value = TAIL_STEP
|
||
viewerContent.value = null
|
||
viewerVisible.value = true
|
||
await loadContent(true)
|
||
}
|
||
|
||
async function loadContent(scrollToBottom: boolean) {
|
||
if (!viewerFile.value) return
|
||
viewerLoading.value = true
|
||
try {
|
||
viewerContent.value = await fetchDeviceLogContent(viewerFile.value.id, viewerMaxBytes.value)
|
||
if (scrollToBottom) {
|
||
await nextTick()
|
||
if (viewerPre.value) viewerPre.value.scrollTop = viewerPre.value.scrollHeight
|
||
}
|
||
} catch (error) {
|
||
showAdminFeedback(error instanceof Error ? error.message : '日志内容加载失败', 'error')
|
||
} finally {
|
||
viewerLoading.value = false
|
||
}
|
||
}
|
||
|
||
function loadMore() {
|
||
viewerMaxBytes.value = Math.min(viewerMaxBytes.value * 2, TAIL_MAX)
|
||
loadContent(false)
|
||
}
|
||
|
||
const batch = useRowSelection({
|
||
pageRows: () => rows.value,
|
||
rowId: (row) => row.id,
|
||
rowLabel: (row) => row.fileName,
|
||
deleteOne: (id) => deleteDeviceLogFile(id),
|
||
refresh: load,
|
||
blocked: () => loading.value || !!loadFailure.value,
|
||
scope: () => companyTab.activeId,
|
||
consequence: '将删除所选云端日志,此操作不可恢复。',
|
||
})
|
||
|
||
async function remove(row: DeviceLogFileRow) {
|
||
if (batch.busy) return
|
||
if (!(await openAdminConfirm({ message: `确认删除「${row.fileName}」(${row.deviceName || row.deviceId})的云端日志?删除后不可恢复。`, danger: true }))) return
|
||
try {
|
||
await deleteDeviceLogFile(row.id)
|
||
batch.removeFromSelection(row.id)
|
||
ElMessage.success('已删除')
|
||
load()
|
||
} catch (error) {
|
||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
||
}
|
||
}
|
||
|
||
// ---------------------------------------------------------------- 采集配置
|
||
|
||
const configVisible = ref(false)
|
||
const configLoading = ref(false)
|
||
const globalMode = ref('full')
|
||
const overrides = ref<DeviceLogOverride[]>([])
|
||
const devices = ref<DeviceLogDevice[]>([])
|
||
const newOverrideKey = ref('')
|
||
const newOverrideMode = ref('selected')
|
||
|
||
const MODE_OPTIONS = [
|
||
{ value: 'full', label: '全量采集' },
|
||
{ value: 'selected', label: '精选采集' },
|
||
]
|
||
|
||
function modeLabel(mode: string): string {
|
||
return mode === 'selected' ? '精选' : '全量'
|
||
}
|
||
|
||
/** 终端覆盖下拉的显示文案(el-option 需要显式 label,文案与旧原生 <option> 逐字一致)。 */
|
||
function deviceOptionLabel(device: DeviceLogDevice): string {
|
||
return `${sourceLabel(device.source)} · ${device.deviceName || device.deviceId}(${device.deviceId})`
|
||
}
|
||
|
||
async function openConfig() {
|
||
configVisible.value = true
|
||
await loadConfig()
|
||
}
|
||
|
||
async function loadConfig() {
|
||
configLoading.value = true
|
||
try {
|
||
const data = await fetchDeviceLogConfig()
|
||
globalMode.value = data.globalMode || 'full'
|
||
overrides.value = data.overrides || []
|
||
devices.value = (await fetchDeviceLogDevices()) || []
|
||
} catch (error) {
|
||
showAdminFeedback(error instanceof Error ? error.message : '采集配置加载失败', 'error')
|
||
} finally {
|
||
configLoading.value = false
|
||
}
|
||
}
|
||
|
||
async function saveGlobalMode(mode: string) {
|
||
if (mode === globalMode.value) return
|
||
try {
|
||
await updateDeviceLogGlobalMode(mode)
|
||
globalMode.value = mode
|
||
ElMessage.success(`全局采集模式已切换为「${modeLabel(mode)}」`)
|
||
} catch (error) {
|
||
showAdminFeedback(error instanceof Error ? error.message : '保存失败', 'error')
|
||
}
|
||
}
|
||
|
||
async function addOverride() {
|
||
if (!newOverrideKey.value) {
|
||
ElMessage.warning('请先选择终端')
|
||
return
|
||
}
|
||
const [source, deviceId] = newOverrideKey.value.split('|')
|
||
const device = devices.value.find((item) => item.source === source && item.deviceId === deviceId)
|
||
try {
|
||
await updateDeviceLogOverride(source, deviceId, device?.deviceName || null, newOverrideMode.value)
|
||
ElMessage.success('终端覆盖已保存')
|
||
newOverrideKey.value = ''
|
||
await loadConfig()
|
||
} catch (error) {
|
||
showAdminFeedback(error instanceof Error ? error.message : '保存失败', 'error')
|
||
}
|
||
}
|
||
|
||
async function removeOverride(row: DeviceLogOverride) {
|
||
const who = row.deviceName || row.deviceId
|
||
if (!(await openAdminConfirm({ message: `确认删除终端「${who}」的采集覆盖(回落到全局默认)?`, danger: true }))) return
|
||
try {
|
||
await deleteDeviceLogOverride(row.id)
|
||
ElMessage.success('已删除')
|
||
await loadConfig()
|
||
} catch (error) {
|
||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
||
}
|
||
}
|
||
|
||
onMounted(() => {
|
||
load()
|
||
loadUserOptions()
|
||
})
|
||
</script>
|
||
|
||
<template>
|
||
<div class="device-logs-view">
|
||
<section class="panel-box">
|
||
<div class="logs-head">
|
||
<h3>日志文件列表</h3>
|
||
<div class="logs-head-tools">
|
||
<span class="retention-tip">云端仅保留 {{ retentionDays }} 天</span>
|
||
<button class="btn btn-ghost" type="button" @click="openConfig">采集配置</button>
|
||
<button class="btn" type="button" @click="load">刷新</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-row logs-filter-row">
|
||
<div class="form-group" style="min-width: 150px">
|
||
<label>来源</label>
|
||
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 弹层是直角原生物,换 el-select。
|
||
「全部来源」保留为空值首行(value 语义不变,查询参数仍是空串)。 -->
|
||
<el-select v-model="sourceFilter" class="admin-filter" aria-label="来源">
|
||
<el-option v-for="option in SOURCE_OPTIONS" :key="option.value" :label="option.label" :value="option.value" />
|
||
</el-select>
|
||
</div>
|
||
<div class="form-group" style="min-width: 180px">
|
||
<label>指定用户</label>
|
||
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 弹层是直角原生物,换 el-select。
|
||
「全部用户」保留为空值首行;用户值仍是 String(id)(下游按字符串判空、落库前再转数字)。 -->
|
||
<el-select v-model="uidFilter" class="admin-filter" filterable aria-label="指定用户" :disabled="usersLoading">
|
||
<el-option label="全部用户" value="" />
|
||
<el-option v-for="u in userOptions" :key="u.id" :label="u.username" :value="String(u.id)" />
|
||
</el-select>
|
||
</div>
|
||
<div class="form-group" style="min-width: 150px">
|
||
<label>日志日期(起)</label>
|
||
<input v-model="startDate" type="date" :max="endDate" @change="clampDatePair" />
|
||
</div>
|
||
<div class="form-group" style="min-width: 150px">
|
||
<label>日志日期(止)</label>
|
||
<input v-model="endDate" type="date" :min="startDate" @change="clampDatePair" />
|
||
</div>
|
||
<div class="form-group">
|
||
<label> </label>
|
||
<div class="filter-actions">
|
||
<button class="btn" type="button" @click="search">查询</button>
|
||
<button class="btn btn-ghost" type="button" @click="reset">重置</button>
|
||
</div>
|
||
</div>
|
||
<BatchDeleteActions :batch="batch" />
|
||
</div>
|
||
|
||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
||
<div class="logs-table-scroll">
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th class="batch-delete-cell" scope="col">
|
||
<BatchDeleteCheckbox label="全选当前页可删除记录" :checked="batch.pageAll" :partial="batch.pageSome"
|
||
:disabled="batch.disabled || batch.pageEmpty" @change="batch.togglePage" />
|
||
</th>
|
||
<th style="width: 110px">来源</th>
|
||
<th style="width: 200px">用户</th>
|
||
<th style="width: 230px">文件名</th>
|
||
<th style="width: 110px">日志日期</th>
|
||
<th style="width: 100px">已收大小</th>
|
||
<th style="width: 80px">片段数</th>
|
||
<th style="width: 170px">最后更新</th>
|
||
<th style="width: 190px">操作</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<template v-if="rows.length">
|
||
<tr v-for="row in rows" :key="row.id" :class="{ 'batch-selected': batch.isSelected(row) }">
|
||
<td class="batch-delete-cell">
|
||
<BatchDeleteCheckbox :label="batch.reason(row) || `选择 ${batch.label(row)}`" :checked="batch.isSelected(row)"
|
||
:disabled="batch.disabled || !!batch.reason(row)" @change="batch.toggle(row)" />
|
||
</td>
|
||
<td>
|
||
<span class="source-pill" :class="row.source === 'maixiang' ? 'is-maixiang' : 'is-client'">
|
||
{{ sourceLabel(row.source) }}
|
||
</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>
|
||
<span v-else class="dim">—</span>
|
||
</td>
|
||
<td>
|
||
<span class="file-name" :title="row.fileName">{{ row.fileName }}</span>
|
||
</td>
|
||
<td>{{ row.logDate }}</td>
|
||
<td>{{ formatBytes(row.uploadedBytes) }}</td>
|
||
<td>{{ row.partCount ?? 0 }}</td>
|
||
<td>{{ row.lastUploadAt ? formatDateTime(row.lastUploadAt) : '—' }}</td>
|
||
<td class="ops-cell">
|
||
<button class="btn btn-sm" type="button" @click="openViewer(row)">查看</button>
|
||
<a class="btn btn-sm btn-ghost dl-link" :href="deviceLogDownloadUrl(row.id)" download>下载</a>
|
||
<button class="btn btn-sm btn-danger" type="button" :disabled="batch.busy" @click="remove(row)">删除</button>
|
||
</td>
|
||
</tr>
|
||
</template>
|
||
<tr v-else-if="loading">
|
||
<td colspan="9" class="empty-tip">加载中...</td>
|
||
</tr>
|
||
<tr v-else>
|
||
<td colspan="9" class="empty-tip">
|
||
{{ sourceFilter || uidFilter ? '暂无匹配日志' : '暂无日志上报(客户端/采集机上报后自动出现在这里)' }}
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<OldPagination :total="total" :page="page" :page-size="pageSize" @change="changePage" @size-change="changeSize" />
|
||
</section>
|
||
|
||
<el-dialog v-model="viewerVisible" :title="viewerFile ? `${viewerFile.fileName}(${viewerFile.deviceName || viewerFile.deviceId})` : '日志内容'" width="900px" top="5vh">
|
||
<div class="viewer-toolbar">
|
||
<span class="viewer-meta">
|
||
云端已收 {{ formatBytes(viewerContent?.totalBytes ?? viewerFile?.uploadedBytes) }}
|
||
<template v-if="viewerContent"> · 当前展示 {{ formatBytes(viewerContent.shownBytes) }}</template>
|
||
<template v-if="viewerContent?.truncated"> · 更早内容未加载</template>
|
||
</span>
|
||
<span class="viewer-actions">
|
||
<button class="btn btn-sm btn-ghost" type="button" :disabled="viewerLoading" @click="loadContent(true)">刷新</button>
|
||
<button
|
||
class="btn btn-sm btn-ghost"
|
||
type="button"
|
||
:disabled="viewerLoading || !viewerContent?.truncated || viewerMaxBytes >= TAIL_MAX"
|
||
@click="loadMore"
|
||
>加载更早</button>
|
||
<a v-if="viewerFile" class="btn btn-sm btn-ghost dl-link" :href="deviceLogDownloadUrl(viewerFile.id)" download>下载完整日志</a>
|
||
</span>
|
||
</div>
|
||
<pre ref="viewerPre" class="log-pre">{{ viewerLoading && !viewerContent ? '加载中...' : (viewerContent?.content || '(暂无内容)') }}</pre>
|
||
</el-dialog>
|
||
|
||
<el-dialog v-model="configVisible" title="采集配置" width="720px">
|
||
<div class="config-block">
|
||
<h4>全局默认模式</h4>
|
||
<p class="config-desc">对未单独配置的终端生效。全量=上传日志目录内全部文件;精选=排除低价值大日志(客户端排除 pywebview;麦象排除 kk-browser / 控制台 / 测试日志)。终端在下一次上报周期(约 1 分钟内)跟随新配置。</p>
|
||
<div class="mode-switch">
|
||
<button
|
||
v-for="option in MODE_OPTIONS"
|
||
:key="option.value"
|
||
class="mode-btn"
|
||
:class="{ 'is-active': globalMode === option.value }"
|
||
type="button"
|
||
@click="saveGlobalMode(option.value)"
|
||
>{{ option.label }}</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="config-block">
|
||
<h4>终端覆盖</h4>
|
||
<div class="override-add">
|
||
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 弹层是直角原生物,换 el-select。
|
||
value 仍是 `${source}|${deviceId}` 与 'full'/'selected' 常量,逐字保留(addOverride
|
||
按 '|' 切分、后端按 mode 常量解析,值形状一动就错单)。 -->
|
||
<el-select v-model="newOverrideKey" class="admin-filter override-select" filterable aria-label="选择终端">
|
||
<el-option label="选择终端(最近上报的设备)" value="" />
|
||
<el-option
|
||
v-for="device in devices"
|
||
:key="`${device.source}|${device.deviceId}`"
|
||
:label="deviceOptionLabel(device)"
|
||
:value="`${device.source}|${device.deviceId}`"
|
||
/>
|
||
</el-select>
|
||
<el-select v-model="newOverrideMode" class="admin-filter override-mode" aria-label="覆盖模式">
|
||
<el-option v-for="option in MODE_OPTIONS" :key="option.value" :label="option.label" :value="option.value" />
|
||
</el-select>
|
||
<button class="btn btn-sm" type="button" @click="addOverride">添加/更新覆盖</button>
|
||
</div>
|
||
<table class="override-table">
|
||
<thead>
|
||
<tr>
|
||
<th style="width: 100px">来源</th>
|
||
<th>设备</th>
|
||
<th style="width: 80px">模式</th>
|
||
<th style="width: 160px">更新时间</th>
|
||
<th style="width: 90px">操作</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr v-for="row in overrides" :key="row.id">
|
||
<td>{{ sourceLabel(row.source) }}</td>
|
||
<td>
|
||
<span class="device-name">{{ row.deviceName || row.deviceId }}</span>
|
||
<span class="device-id">{{ row.deviceId }}</span>
|
||
</td>
|
||
<td>{{ modeLabel(row.mode) }}</td>
|
||
<td>{{ row.updatedAt ? formatDateTime(row.updatedAt) : '—' }}</td>
|
||
<td class="ops-cell">
|
||
<button class="btn btn-sm btn-danger" type="button" @click="removeOverride(row)">删除</button>
|
||
</td>
|
||
</tr>
|
||
<tr v-if="!overrides.length">
|
||
<td colspan="5" class="empty-tip">{{ configLoading ? '加载中...' : '暂无终端覆盖(全部跟随全局默认)' }}</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<template #footer>
|
||
<el-button @click="configVisible = false">关闭</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
</div>
|
||
</template>
|
||
|
||
<style scoped>
|
||
/* 沿用「记录与版本」系列的旧后台面板视觉语言。 */
|
||
.device-logs-view {
|
||
font-family: inherit;
|
||
color: #24384d;
|
||
}
|
||
.panel-box {
|
||
width: 100%;
|
||
min-width: 0;
|
||
padding: 20px 22px 24px;
|
||
border: 1px solid #d8e3ee;
|
||
border-radius: 14px;
|
||
background: linear-gradient(145deg, #ffffff, #f9fbfd);
|
||
box-shadow: 0 1px 2px rgba(39, 67, 94, 0.04), 0 14px 30px -24px rgba(39, 67, 94, 0.28);
|
||
}
|
||
h3 {
|
||
margin: 0;
|
||
font-size: 15px;
|
||
font-weight: 650;
|
||
color: #24384d;
|
||
letter-spacing: 0.2px;
|
||
}
|
||
.logs-head {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 12px;
|
||
margin-bottom: 16px;
|
||
}
|
||
.logs-head-tools {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 10px;
|
||
}
|
||
.retention-tip {
|
||
color: #8598ab;
|
||
font-size: 12.5px;
|
||
}
|
||
.logs-filter-row {
|
||
margin: 0 0 16px;
|
||
}
|
||
.form-row {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
align-items: flex-end;
|
||
gap: 14px 18px;
|
||
}
|
||
.form-group {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 7px;
|
||
}
|
||
.form-group label {
|
||
color: #5b6f83;
|
||
font-size: 12.5px;
|
||
font-weight: 600;
|
||
}
|
||
.form-group input {
|
||
min-width: 0;
|
||
min-height: 42px;
|
||
padding: 8px 12px;
|
||
border: 1px solid #cbd9e6;
|
||
border-radius: 9px;
|
||
background: #f8fbfd;
|
||
color: #24384d;
|
||
font-size: 13.5px;
|
||
font-family: inherit;
|
||
color-scheme: light;
|
||
outline: none;
|
||
}
|
||
.form-group input:focus {
|
||
background: #ffffff;
|
||
border-color: #5f85ad;
|
||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||
}
|
||
.filter-actions {
|
||
display: flex;
|
||
gap: 10px;
|
||
}
|
||
.btn {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
gap: 8px;
|
||
min-height: 42px;
|
||
padding: 9px 18px;
|
||
border: 1px solid #4f78a5;
|
||
border-radius: 9px;
|
||
background: linear-gradient(135deg, #5f85ad, #4f78a5);
|
||
color: #ffffff;
|
||
font-family: inherit;
|
||
font-size: 13.5px;
|
||
cursor: pointer;
|
||
box-shadow: 0 8px 18px -14px rgba(79, 120, 165, 0.72);
|
||
text-decoration: none;
|
||
}
|
||
.btn:hover:not(:disabled) {
|
||
background: linear-gradient(135deg, #7094ba, #5d83ac);
|
||
}
|
||
.btn:disabled {
|
||
cursor: not-allowed;
|
||
opacity: 0.55;
|
||
}
|
||
.btn-ghost {
|
||
background: #ffffff;
|
||
border-color: #c7d7e5;
|
||
color: #4f78a5;
|
||
box-shadow: none;
|
||
}
|
||
.btn-ghost:hover:not(:disabled) {
|
||
background: #edf5fb;
|
||
border-color: #95b1cb;
|
||
color: #2f5d8b;
|
||
}
|
||
.btn-danger {
|
||
background: linear-gradient(135deg, #c06d77, #b35f6a);
|
||
border-color: #b35f6a;
|
||
}
|
||
.btn-danger:hover:not(:disabled) {
|
||
background: linear-gradient(135deg, #cb7c84, #b96570);
|
||
}
|
||
.btn-sm {
|
||
min-height: 32px;
|
||
padding: 4px 12px;
|
||
font-size: 12.5px;
|
||
border-radius: 7px;
|
||
}
|
||
.logs-table-scroll {
|
||
width: 100%;
|
||
overflow-x: auto;
|
||
}
|
||
table {
|
||
width: 100%;
|
||
border-collapse: collapse;
|
||
font-size: 13px;
|
||
}
|
||
th {
|
||
padding: 10px 12px;
|
||
text-align: left;
|
||
color: #5b6f83;
|
||
font-weight: 650;
|
||
font-size: 12.5px;
|
||
border-bottom: 1px solid #dbe6f0;
|
||
white-space: nowrap;
|
||
}
|
||
td {
|
||
padding: 10px 12px;
|
||
border-bottom: 1px solid #eaf1f7;
|
||
vertical-align: top;
|
||
}
|
||
.source-pill {
|
||
display: inline-block;
|
||
padding: 2px 10px;
|
||
border-radius: 999px;
|
||
font-size: 12px;
|
||
font-weight: 600;
|
||
}
|
||
.source-pill.is-client {
|
||
background: #e8f1fb;
|
||
color: #37618f;
|
||
}
|
||
.source-pill.is-maixiang {
|
||
background: #eef7ec;
|
||
color: #3f7a42;
|
||
}
|
||
.device-name {
|
||
display: block;
|
||
font-weight: 600;
|
||
word-break: break-all;
|
||
}
|
||
.device-id {
|
||
display: block;
|
||
color: #8598ab;
|
||
font-size: 11.5px;
|
||
word-break: break-all;
|
||
}
|
||
.user-name {
|
||
font-weight: 600;
|
||
}
|
||
.file-name {
|
||
display: block;
|
||
word-break: break-all;
|
||
}
|
||
.dim {
|
||
color: #9db0c2;
|
||
}
|
||
.ops-cell {
|
||
display: flex;
|
||
gap: 8px;
|
||
flex-wrap: wrap;
|
||
border-bottom: none;
|
||
}
|
||
.empty-tip {
|
||
padding: 26px 0;
|
||
text-align: center;
|
||
color: #8598ab;
|
||
}
|
||
.dl-link {
|
||
text-decoration: none;
|
||
}
|
||
.viewer-toolbar {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 12px;
|
||
margin-bottom: 10px;
|
||
}
|
||
.viewer-meta {
|
||
color: #5b6f83;
|
||
font-size: 12.5px;
|
||
}
|
||
.viewer-actions {
|
||
display: flex;
|
||
gap: 8px;
|
||
}
|
||
.log-pre {
|
||
max-height: 62vh;
|
||
margin: 0;
|
||
padding: 12px 14px;
|
||
overflow: auto;
|
||
border: 1px solid #d8e3ee;
|
||
border-radius: 10px;
|
||
background: #0f1c29;
|
||
color: #d7e4f1;
|
||
font-family: Consolas, 'Courier New', monospace;
|
||
font-size: 12.5px;
|
||
line-height: 1.55;
|
||
white-space: pre;
|
||
}
|
||
.config-block {
|
||
margin-bottom: 18px;
|
||
}
|
||
.config-block h4 {
|
||
margin: 0 0 6px;
|
||
font-size: 13.5px;
|
||
color: #24384d;
|
||
}
|
||
.config-desc {
|
||
margin: 0 0 10px;
|
||
color: #66798d;
|
||
font-size: 12.5px;
|
||
line-height: 1.6;
|
||
}
|
||
.mode-switch {
|
||
display: flex;
|
||
gap: 10px;
|
||
}
|
||
.mode-btn {
|
||
min-height: 38px;
|
||
padding: 8px 20px;
|
||
border: 1px solid #c7d7e5;
|
||
border-radius: 9px;
|
||
background: #ffffff;
|
||
color: #4f78a5;
|
||
font-size: 13.5px;
|
||
font-family: inherit;
|
||
cursor: pointer;
|
||
}
|
||
.mode-btn.is-active {
|
||
border-color: #4f78a5;
|
||
background: linear-gradient(135deg, #5f85ad, #4f78a5);
|
||
color: #ffffff;
|
||
font-weight: 600;
|
||
}
|
||
.override-add {
|
||
display: flex;
|
||
gap: 10px;
|
||
margin-bottom: 12px;
|
||
}
|
||
/* 只管布局:外壳皮肤(42px/9 圆角/#f8fbfd/focus ring)由全局 .admin-filter 提供,
|
||
这里不再重复描边(旧 `.override-add select` 那段原生下拉皮肤已随 el-select 删除)。 */
|
||
.override-select {
|
||
flex: 1;
|
||
min-width: 0;
|
||
}
|
||
.override-mode {
|
||
flex: 0 0 140px;
|
||
}
|
||
.override-table td {
|
||
vertical-align: middle;
|
||
}
|
||
</style>
|