fix(phase-5.2): 消项 CR 第二轮 P1/P2/P3(通道/证据链/交付时序/后管证据页)
This commit is contained in:
@@ -1,38 +1,172 @@
|
||||
import { http, unwrap } from '@/api/http'
|
||||
|
||||
/** 大档分片阈值(AC-11):8MB 以上不再一次 PUT 直传,断点续传由服务端 chunk 通道承担。 */
|
||||
export const CHUNK_UPLOAD_THRESHOLD = 8 * 1024 * 1024
|
||||
/**
|
||||
* 大档分片阈值与片大小(AC-11):后管这一侧只有这一个出口,阈值由片大小派生。
|
||||
*
|
||||
* ⚠ 同族的 8MB 数还另有两处:用户端上传出口一处、桌面客户端分片入口一处。两边是各自
|
||||
* 独立的构建根(各自的 `@` 别名与 tsconfig include),客户端是 Python 打包物 ⇒
|
||||
* 没有共享包就合不成同一个字面量(P3-5 的边界,已登记)。
|
||||
*/
|
||||
export const CHUNK_UPLOAD_PART_SIZE = 8 * 1024 * 1024
|
||||
export const CHUNK_UPLOAD_THRESHOLD = CHUNK_UPLOAD_PART_SIZE
|
||||
|
||||
/** 每片重试次数(不含首次):单片 502/超时不该让 512MB 从 0 再来。 */
|
||||
const PART_RETRY_LIMIT = 2
|
||||
|
||||
/**
|
||||
* 逐片超时(P2-8):预算只看**这一片**有多大——60s 保底 + 每 MB 30s(8MB 片=300s)。
|
||||
* 过去按整包体积算(120s + MB×15s),512MB 包里的一个 8MB 片能拿到 128 分钟,
|
||||
* 慢链路真卡死时没人知道,进度条还会一直爬。
|
||||
*/
|
||||
export function partTimeoutOf(partBytes: number): number {
|
||||
return 60_000 + Math.ceil(partBytes / (1024 * 1024)) * 30_000
|
||||
}
|
||||
|
||||
/** 会话登记/查询只发元数据,固定预算即可;失败要快快回来,别陪整包一起放大。 */
|
||||
const REQUEST_TIMEOUT_MS = 60_000
|
||||
/** 只有拼装这一步真随整包体积走:服务端要读全部分片、复算 sha256。 */
|
||||
const COMPLETE_TIMEOUT_MS = 600_000
|
||||
|
||||
function partUrl(uploadId: string, index: number): string {
|
||||
return `/api/files/chunk/${encodeURIComponent(uploadId)}/part/${index}`
|
||||
}
|
||||
|
||||
/** 后管大档上传(版本包/教程包共用):init → GET 已达片号 → 逐片 POST → complete。 */
|
||||
/** 分片会话跨尝试/刷新续用:同一文件身份复用 upload_id,服务端没回收就从已达片号继续(P2-7)。 */
|
||||
interface StoredChunkSession {
|
||||
uploadId: string;
|
||||
size: number;
|
||||
lastModified: number;
|
||||
}
|
||||
|
||||
const CHUNK_SESSION_PREFIX = 'shufu:admin:chunk:'
|
||||
|
||||
function lastModifiedOf(file: Blob): number {
|
||||
const value = (file as File).lastModified
|
||||
return typeof value === 'number' && Number.isFinite(value) ? value : 0
|
||||
}
|
||||
|
||||
/** 会话键:文件名+体积+修改时间,三者同一条上传才算同一个件。 */
|
||||
export function chunkSessionKeyOf(fileName: string, file: Blob): string {
|
||||
return `${CHUNK_SESSION_PREFIX}${fileName}:${file.size}:${lastModifiedOf(file)}`
|
||||
}
|
||||
|
||||
function readStoredSession(key: string, file: Blob): string {
|
||||
if (typeof localStorage === 'undefined') return ''
|
||||
try {
|
||||
const raw = localStorage.getItem(key)
|
||||
if (!raw) return ''
|
||||
const parsed = JSON.parse(raw) as StoredChunkSession
|
||||
return parsed.size === file.size && parsed.lastModified === lastModifiedOf(file) ? parsed.uploadId : ''
|
||||
} catch {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
function writeStoredSession(key: string, file: Blob, uploadId: string): void {
|
||||
if (typeof localStorage === 'undefined') return
|
||||
try {
|
||||
localStorage.setItem(key, JSON.stringify({
|
||||
uploadId, size: file.size, lastModified: lastModifiedOf(file),
|
||||
} satisfies StoredChunkSession))
|
||||
} catch {
|
||||
// 存储不可用(隐私模式/配额满)只影响跨刷新续传,不影响本次上传
|
||||
}
|
||||
}
|
||||
|
||||
function clearStoredSession(key: string): void {
|
||||
if (typeof localStorage === 'undefined') return
|
||||
try {
|
||||
localStorage.removeItem(key)
|
||||
} catch {
|
||||
// 同上:清不掉只会让下次多问一次 status
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务端对「这个会话还在不在」的三种答复:还在(附带已到片号)/确实没了/问不出来。
|
||||
* 第三态是 P2-7 与 P1-11 的共同判据——过去它被当成"没会话",瞬态抖动=整包作废。
|
||||
*/
|
||||
type ProbeOutcome
|
||||
= { state: 'ok'; parts: number[] }
|
||||
| { state: 'gone' }
|
||||
| { state: 'transient' }
|
||||
|
||||
/** 后端回收会话的原文案(ChunkedUploadService.readMeta);BusinessException 不带 code ⇒ HTTP 200 出。 */
|
||||
function messageSaysSessionGone(text: unknown): boolean {
|
||||
const message = typeof text === 'string' ? text : ''
|
||||
return ['不存在', '过期'].some((marker) => message.includes(marker))
|
||||
}
|
||||
|
||||
function classifyProbe(response: unknown): ProbeOutcome {
|
||||
const status = Number((response as { status?: unknown } | null | undefined)?.status)
|
||||
if (status === 404) return { state: 'gone' }
|
||||
if (status >= 500 || status === 408 || status === 429) return { state: 'transient' }
|
||||
const body = (response as { data?: unknown } | null | undefined)?.data
|
||||
if (body && typeof body === 'object' && (body as { success?: unknown }).success === false) {
|
||||
return messageSaysSessionGone((body as { message?: unknown }).message)
|
||||
? { state: 'gone' }
|
||||
: { state: 'transient' }
|
||||
}
|
||||
const core = (unwrap<Record<string, unknown>>(body) ?? {}) as Record<string, unknown>
|
||||
const arrived = core.uploaded_parts
|
||||
return { state: 'ok', parts: Array.isArray(arrived) ? arrived.map((value) => Number(value)) : [] }
|
||||
}
|
||||
|
||||
/**
|
||||
* 探测已达片号(P2-7/与用户端 upload.ts 同一口径)。
|
||||
* validateStatus 恒真:状态码要自己判——真 404/5xx 一旦被拦截器折成 Error 就分不出原因了;
|
||||
* 能走到 catch 的就只剩网络层失败与超时,铁定瞬态。
|
||||
*/
|
||||
async function probeUploadedParts(uploadId: string): Promise<ProbeOutcome> {
|
||||
try {
|
||||
const response = await http.get(
|
||||
`/api/files/chunk/${encodeURIComponent(uploadId)}`,
|
||||
{ validateStatus: () => true },
|
||||
)
|
||||
return classifyProbe(response)
|
||||
} catch (error) {
|
||||
const status = (error as { response?: { status?: unknown } } | null | undefined)?.response?.status
|
||||
if (status === 404) return { state: 'gone' }
|
||||
if (messageSaysSessionGone((error as { message?: unknown } | null | undefined)?.message)) {
|
||||
return { state: 'gone' }
|
||||
}
|
||||
return { state: 'transient' }
|
||||
}
|
||||
}
|
||||
|
||||
/** 后管大档上传(版本包/教程包共用):会话续用 → GET 已达片号 → 逐片 POST → complete。 */
|
||||
export async function uploadFileInChunks(
|
||||
file: Blob,
|
||||
fileName: string,
|
||||
onProgress?: (percent: number) => void,
|
||||
): Promise<Record<string, unknown>> {
|
||||
const totalParts = Math.max(1, Math.ceil(file.size / CHUNK_UPLOAD_PART_SIZE))
|
||||
const initResponse = await http.post('/api/files/chunk/init', null, {
|
||||
params: { fileName, totalParts, totalBytes: file.size },
|
||||
timeout: 120_000 + Math.ceil(file.size / (1024 * 1024)) * 15_000,
|
||||
})
|
||||
const init = (unwrap(initResponse.data) ?? {}) as Record<string, unknown>
|
||||
const uploadId = String(init.upload_id ?? '')
|
||||
if (!uploadId) {
|
||||
throw new Error('后端未返回分片会话,请重试')
|
||||
const sessionKey = chunkSessionKeyOf(fileName, file)
|
||||
let uploadId = readStoredSession(sessionKey, file)
|
||||
const arrived = new Set<number>()
|
||||
if (uploadId) {
|
||||
const probed = await probeUploadedParts(uploadId)
|
||||
if (probed.state === 'gone') {
|
||||
// 服务端确实说会话没了(404/「不存在或已过期」):清掉重开,否则这个件每次都在同一个死会话上失败。
|
||||
clearStoredSession(sessionKey)
|
||||
uploadId = ''
|
||||
} else if (probed.state === 'ok') {
|
||||
probed.parts.forEach((index) => arrived.add(index))
|
||||
}
|
||||
// transient:片号未知但会话还在 ⇒ 照原会话逐片重传(后端同片覆盖,幂等),不重开 init。
|
||||
}
|
||||
if (!uploadId) {
|
||||
const initResponse = await http.post('/api/files/chunk/init', null, {
|
||||
params: { fileName, totalParts, totalBytes: file.size },
|
||||
timeout: REQUEST_TIMEOUT_MS,
|
||||
})
|
||||
const init = (unwrap(initResponse.data) ?? {}) as Record<string, unknown>
|
||||
uploadId = String(init.upload_id ?? '')
|
||||
if (!uploadId) {
|
||||
throw new Error('后端未返回分片会话,请重试')
|
||||
}
|
||||
writeStoredSession(sessionKey, file, uploadId)
|
||||
}
|
||||
|
||||
const statusResponse = await http.get(`/api/files/chunk/${encodeURIComponent(uploadId)}`)
|
||||
const status = (unwrap(statusResponse.data) ?? {}) as Record<string, unknown>
|
||||
const arrived = new Set<number>(
|
||||
Array.isArray(status.uploaded_parts) ? status.uploaded_parts.map((value) => Number(value)) : [],
|
||||
)
|
||||
|
||||
for (let index = 0; index < totalParts; index += 1) {
|
||||
if (arrived.has(index)) {
|
||||
@@ -47,7 +181,7 @@ export async function uploadFileInChunks(
|
||||
try {
|
||||
const partResponse = await http.post(partUrl(uploadId, index), form, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
timeout: 120_000 + Math.ceil(file.size / (1024 * 1024)) * 15_000,
|
||||
timeout: partTimeoutOf(blob.size),
|
||||
onUploadProgress: (event) => {
|
||||
if (!onProgress) return
|
||||
const perPart = Math.round(((index + (event.loaded || 0) / Math.max(blob.size, 1)) / totalParts) * 100)
|
||||
@@ -63,14 +197,15 @@ export async function uploadFileInChunks(
|
||||
}
|
||||
}
|
||||
if (lastError) {
|
||||
// 后管上传是一次性的:放弃时把会话连同临时片一起清掉,不留 24h 残盘。
|
||||
await http.delete(`/api/files/chunk/${encodeURIComponent(uploadId)}`).catch(() => undefined)
|
||||
// 不 DELETE(P2-7):会话连同已达片号留在服务端(后端 24h 过期回收兜底),
|
||||
// 下一次点开同一个文件就从断点接着传——这才是"续传"两个字的本义。
|
||||
throw lastError instanceof Error ? lastError : new Error('分片上传失败')
|
||||
}
|
||||
}
|
||||
|
||||
const completeResponse = await http.post(
|
||||
`/api/files/chunk/${encodeURIComponent(uploadId)}/complete`, null, { timeout: 600_000 })
|
||||
`/api/files/chunk/${encodeURIComponent(uploadId)}/complete`, null, { timeout: COMPLETE_TIMEOUT_MS })
|
||||
clearStoredSession(sessionKey)
|
||||
if (onProgress) onProgress(100)
|
||||
return (unwrap(completeResponse.data) ?? {}) as Record<string, unknown>
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
import { http } from './http'
|
||||
import { unwrap } from './envelope'
|
||||
|
||||
/** 任务证据件列表行(AC-13:后管只读面,仅超级管理员)。 */
|
||||
export interface TaskEvidenceRow {
|
||||
id: number
|
||||
taskId: string
|
||||
uid: number | null
|
||||
evidenceType: string
|
||||
source: string
|
||||
objectKey: string
|
||||
byteSize: number
|
||||
contentType: string
|
||||
sha256: string
|
||||
createdAt: string | null
|
||||
}
|
||||
|
||||
export interface TaskEvidencePage {
|
||||
items: TaskEvidenceRow[]
|
||||
total: number
|
||||
page: number
|
||||
pageSize: number
|
||||
}
|
||||
|
||||
export interface TaskEvidenceQuery {
|
||||
taskId?: string
|
||||
uid?: number
|
||||
page: number
|
||||
pageSize: number
|
||||
}
|
||||
|
||||
export interface TaskEvidenceContent {
|
||||
id: number
|
||||
taskId: string
|
||||
contentType: string
|
||||
binary: boolean
|
||||
content: string
|
||||
}
|
||||
|
||||
export async function fetchTaskEvidenceFiles(params: TaskEvidenceQuery): Promise<TaskEvidencePage> {
|
||||
const query: Record<string, string | number> = { page: params.page, pageSize: params.pageSize }
|
||||
if (params.taskId) query.taskId = params.taskId
|
||||
if (params.uid) query.uid = params.uid
|
||||
const { data } = await http.get('/api/admin/task-evidence/files', { params: query })
|
||||
return unwrap<TaskEvidencePage>(data)
|
||||
}
|
||||
|
||||
export async function fetchTaskEvidenceContent(fileId: number): Promise<TaskEvidenceContent> {
|
||||
const { data } = await http.get('/api/admin/task-evidence/content', { params: { fileId } })
|
||||
return unwrap<TaskEvidenceContent>(data)
|
||||
}
|
||||
|
||||
/** 下载走服务端流,不把对象直链/预签名 URL 交给浏览器(AC-13 的不入日志口径)。 */
|
||||
export function taskEvidenceDownloadUrl(fileId: number): string {
|
||||
return `/api/admin/task-evidence/download?fileId=${fileId}`
|
||||
}
|
||||
|
||||
export async function deleteTaskEvidence(ids: number[]): Promise<number> {
|
||||
const { data } = await http.post('/api/admin/task-evidence/delete', ids)
|
||||
return unwrap<{ deleted: number }>(data).deleted
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
* 而护栏用例要从这里反过来读注册表,放在一起会成环。 */
|
||||
|
||||
/** 角色内在闸门:只有超管可见可读写,与 user_column_permission 无关。 */
|
||||
export const SUPER_ADMIN_ONLY_MENU_KEYS: readonly string[] = ['admin_companies']
|
||||
export const SUPER_ADMIN_ONLY_MENU_KEYS: readonly string[] = ['admin_companies', 'admin_task_evidence']
|
||||
|
||||
export interface CompanyScopedPage {
|
||||
/** 与 routes.ts 的 menuKey 逐字一致。 */
|
||||
|
||||
@@ -109,6 +109,10 @@ export const OPERATION_GUIDES: Record<string, OperationGuideData> = {
|
||||
text: '桌面客户端与麦象采集机上报的日志按来源、日期和关键字筛选;可查看日志尾部、下载完整文件或删除云端记录,云端日志按保留期自动清理。',
|
||||
steps: ['选择来源与日期', '查看或下载日志', '必要时删除'],
|
||||
},
|
||||
admin_task_evidence: {
|
||||
text: '任务异常现场件与窗口图按任务号关联;只有超级管理员能读取与下载,对象直链不出服务端,证据件按保留期自动清理。',
|
||||
steps: ['按任务号或 uid 查询', '查看现场件或窗口图', '下载或清理过期证据'],
|
||||
},
|
||||
admin_user_secret_usage: {
|
||||
text: '按日期范围统计各用户的密钥调用次数(货源查询与外观专利按 LLM 请求次数、代理按提取次数),用于评估用户资源损耗。',
|
||||
steps: ['选择日期范围', '筛选用户或分组', '核对各模块次数'],
|
||||
|
||||
@@ -9,6 +9,7 @@ import { fetchSoftwareVersions, uploadSoftwareVersion, deleteSoftwareVersions }
|
||||
import type { SoftwareVersionItem } from './version-dto.ts'
|
||||
import { isNonEmptyVersion } from './version-dto.ts'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import { loadFailureMessage } from '@/components/load-failure-model'
|
||||
import { openAdminConfirm } from '@/components/admin-confirm'
|
||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
||||
|
||||
@@ -62,7 +63,7 @@ async function removeSelected() {
|
||||
selectedIds.value = new Set()
|
||||
await load()
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
||||
showAdminFeedback(loadFailureMessage(error, '删除失败'), 'error')
|
||||
}
|
||||
}
|
||||
async function removeOne(row: SoftwareVersionItem) {
|
||||
@@ -73,7 +74,7 @@ async function removeOne(row: SoftwareVersionItem) {
|
||||
selectedIds.value = new Set([...selectedIds.value].filter((id) => id !== row.id))
|
||||
await load()
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
||||
showAdminFeedback(loadFailureMessage(error, '删除失败'), 'error')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +93,7 @@ async function load() {
|
||||
try {
|
||||
items.value = (await fetchSoftwareVersions()).items
|
||||
} catch (error) {
|
||||
loadFailure.value = error instanceof Error ? error.message : '版本列表加载失败'
|
||||
loadFailure.value = loadFailureMessage(error, '版本列表加载失败')
|
||||
showAdminFeedback(loadFailure.value, 'error')
|
||||
} finally {
|
||||
loading.value = false
|
||||
@@ -146,7 +147,8 @@ async function submitUpload() {
|
||||
uploadPercent.value = 0
|
||||
load()
|
||||
} catch (error) {
|
||||
uploadMsg.value = error instanceof Error ? error.message : '上传失败'
|
||||
// P2-10:api/http 拦截器不 sanitize,error.message 可能是英文异常原文——界面只吃中文出口,原文进 console。
|
||||
uploadMsg.value = loadFailureMessage(error, '上传失败')
|
||||
} finally {
|
||||
uploading.value = false
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import { fetchTutorialPackages, uploadTutorialPackage, deleteTutorialPackages }
|
||||
import { formatFileSize } from './tutorial-model.ts'
|
||||
import type { TutorialPackageItem } from './tutorial-dto.ts'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import { loadFailureMessage } from '@/components/load-failure-model'
|
||||
import { openAdminConfirm } from '@/components/admin-confirm'
|
||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
||||
|
||||
@@ -119,7 +120,7 @@ async function removeSelected() {
|
||||
selectedIds.value = new Set()
|
||||
await load()
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
||||
showAdminFeedback(loadFailureMessage(error, '删除失败'), 'error')
|
||||
}
|
||||
}
|
||||
async function removeOne(row: TutorialPackageItem) {
|
||||
@@ -130,7 +131,7 @@ async function removeOne(row: TutorialPackageItem) {
|
||||
selectedIds.value = new Set([...selectedIds.value].filter((id) => id !== row.id))
|
||||
await load()
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
||||
showAdminFeedback(loadFailureMessage(error, '删除失败'), 'error')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +150,7 @@ async function load() {
|
||||
try {
|
||||
items.value = (await fetchTutorialPackages()).items
|
||||
} catch (error) {
|
||||
loadFailure.value = error instanceof Error ? error.message : '教程包列表加载失败'
|
||||
loadFailure.value = loadFailureMessage(error, '教程包列表加载失败')
|
||||
showAdminFeedback(loadFailure.value, 'error')
|
||||
} finally {
|
||||
loading.value = false
|
||||
@@ -198,7 +199,8 @@ async function submitUpload() {
|
||||
uploadPercent.value = 0
|
||||
load()
|
||||
} catch (error) {
|
||||
uploadMsg.value = error instanceof Error ? error.message : '上传失败'
|
||||
// P2-10:api/http 拦截器不 sanitize,error.message 可能是英文异常原文——界面只吃中文出口,原文进 console。
|
||||
uploadMsg.value = loadFailureMessage(error, '上传失败')
|
||||
} finally {
|
||||
uploading.value = false
|
||||
}
|
||||
|
||||
@@ -0,0 +1,305 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 任务证据件(R3「后管可视」):按 taskId / uid 关联查看异常现场件与窗口图。
|
||||
* 读取面在服务端逐个方法走 requireSuperAdmin;本页只消费服务端流,不接触对象直链。
|
||||
*/
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
import {
|
||||
deleteTaskEvidence,
|
||||
fetchTaskEvidenceContent,
|
||||
fetchTaskEvidenceFiles,
|
||||
taskEvidenceDownloadUrl,
|
||||
} from '@/api/task-evidence'
|
||||
import type { TaskEvidenceRow } from '@/api/task-evidence'
|
||||
|
||||
const loading = ref(false)
|
||||
const loadFailure = ref('')
|
||||
const items = ref<TaskEvidenceRow[]>([])
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = ref(20)
|
||||
const taskIdFilter = ref('')
|
||||
const uidFilter = ref('')
|
||||
const selectedIds = ref<Set<number>>(new Set())
|
||||
const selectedCount = computed(() => selectedIds.value.size)
|
||||
|
||||
const previewVisible = ref(false)
|
||||
const previewLoading = ref(false)
|
||||
const previewRow = ref<TaskEvidenceRow | null>(null)
|
||||
const previewText = ref('')
|
||||
const previewImage = ref('')
|
||||
|
||||
function imageOf(row: TaskEvidenceRow, content: string): string {
|
||||
return `data:${row.contentType || 'image/png'};base64,${content}`
|
||||
}
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
loadFailure.value = ''
|
||||
try {
|
||||
const uid = uidFilter.value.trim() ? Number(uidFilter.value.trim()) : undefined
|
||||
const data = await fetchTaskEvidenceFiles({
|
||||
taskId: taskIdFilter.value.trim() || undefined,
|
||||
uid: Number.isFinite(uid) && (uid || 0) > 0 ? uid : undefined,
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
})
|
||||
items.value = data.items
|
||||
total.value = data.total
|
||||
} catch (error) {
|
||||
loadFailure.value = error instanceof Error ? error.message : '任务证据件加载失败'
|
||||
showAdminFeedback(loadFailure.value, 'error')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function search() {
|
||||
page.value = 1
|
||||
selectedIds.value = new Set()
|
||||
load()
|
||||
}
|
||||
|
||||
function changePage(next: number) {
|
||||
page.value = next
|
||||
load()
|
||||
}
|
||||
|
||||
function changeSize(size: number) {
|
||||
pageSize.value = size
|
||||
page.value = 1
|
||||
load()
|
||||
}
|
||||
|
||||
function toggleSelect(id: number) {
|
||||
const next = new Set(selectedIds.value)
|
||||
if (next.has(id)) next.delete(id)
|
||||
else next.add(id)
|
||||
selectedIds.value = next
|
||||
}
|
||||
|
||||
function toggleSelectAllPage() {
|
||||
const allOn = items.value.length > 0 && items.value.every((row) => selectedIds.value.has(row.id))
|
||||
const next = new Set(selectedIds.value)
|
||||
if (allOn) items.value.forEach((row) => next.delete(row.id))
|
||||
else items.value.forEach((row) => next.add(row.id))
|
||||
selectedIds.value = next
|
||||
}
|
||||
|
||||
async function removeSelected() {
|
||||
if (!selectedCount.value) return
|
||||
try {
|
||||
const deleted = await deleteTaskEvidence(Array.from(selectedIds.value))
|
||||
showAdminFeedback(`已删除 ${deleted} 份证据件`, 'success')
|
||||
selectedIds.value = new Set()
|
||||
await load()
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '删除证据件失败', 'error')
|
||||
}
|
||||
}
|
||||
|
||||
async function openPreview(row: TaskEvidenceRow) {
|
||||
previewRow.value = row
|
||||
previewVisible.value = true
|
||||
previewLoading.value = true
|
||||
previewText.value = ''
|
||||
previewImage.value = ''
|
||||
try {
|
||||
const content = await fetchTaskEvidenceContent(row.id)
|
||||
if (content.binary) previewImage.value = imageOf(row, content.content)
|
||||
else previewText.value = content.content
|
||||
} catch (error) {
|
||||
previewText.value = error instanceof Error ? error.message : '证据件读取失败'
|
||||
} finally {
|
||||
previewLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function closePreview() {
|
||||
previewVisible.value = false
|
||||
previewRow.value = null
|
||||
previewText.value = ''
|
||||
previewImage.value = ''
|
||||
}
|
||||
|
||||
function kindLabel(row: TaskEvidenceRow): string {
|
||||
if (row.contentType?.startsWith('image/')) return '窗口/页面图'
|
||||
return row.evidenceType || '证据件'
|
||||
}
|
||||
|
||||
watch([taskIdFilter, uidFilter], () => {
|
||||
// 过滤条件改了不自动打请求,避免一次输入打满接口;按「查询」或回车再取。
|
||||
})
|
||||
|
||||
onMounted(load)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="evidence-view">
|
||||
<section class="panel-box">
|
||||
<div class="evidence-head">
|
||||
<h3>任务证据件</h3>
|
||||
<div class="evidence-tools">
|
||||
<input
|
||||
v-model="taskIdFilter"
|
||||
type="text"
|
||||
class="evidence-input"
|
||||
placeholder="按任务号筛选"
|
||||
@keyup.enter="search"
|
||||
/>
|
||||
<input
|
||||
v-model="uidFilter"
|
||||
type="text"
|
||||
class="evidence-input evidence-uid"
|
||||
placeholder="按 uid 筛选"
|
||||
@keyup.enter="search"
|
||||
/>
|
||||
<button class="btn" type="button" @click="search">查询</button>
|
||||
<button class="btn btn-danger" type="button" :disabled="!selectedCount" @click="removeSelected">
|
||||
删除{{ selectedCount ? `(${selectedCount})` : '' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="page-hint">
|
||||
异常现场件与窗口图按任务号关联;读取与下载仅超级管理员可用,对象直链不出服务端。
|
||||
</p>
|
||||
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
||||
<div class="table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 40px">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="items.length > 0 && items.every((row) => selectedIds.has(row.id))"
|
||||
:disabled="!items.length"
|
||||
@change="toggleSelectAllPage"
|
||||
/>
|
||||
</th>
|
||||
<th style="width: 90px">ID</th>
|
||||
<th style="width: 150px">任务号</th>
|
||||
<th style="width: 90px">UID</th>
|
||||
<th style="width: 130px">类型</th>
|
||||
<th style="width: 130px">来源</th>
|
||||
<th style="width: 110px">体积</th>
|
||||
<th style="width: 160px">生成时间</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<template v-if="items.length">
|
||||
<tr v-for="row in items" :key="row.id">
|
||||
<td>
|
||||
<input type="checkbox" :checked="selectedIds.has(row.id)" @change="toggleSelect(row.id)" />
|
||||
</td>
|
||||
<td>{{ row.id }}</td>
|
||||
<td>{{ row.taskId || '-' }}</td>
|
||||
<td>{{ row.uid ?? '-' }}</td>
|
||||
<td>{{ kindLabel(row) }}</td>
|
||||
<td>{{ row.source || '-' }}</td>
|
||||
<td>{{ row.byteSize }} B</td>
|
||||
<td>{{ formatDateTime(row.createdAt) }}</td>
|
||||
<td class="evidence-actions">
|
||||
<button class="link-like" type="button" @click="openPreview(row)">查看</button>
|
||||
<a class="link-cell" :href="taskEvidenceDownloadUrl(row.id)" target="_blank" rel="noopener">下载</a>
|
||||
</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">暂无证据件</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<OldPagination :total="total" :page="page" :page-size="pageSize" @change="changePage" @size-change="changeSize" />
|
||||
</section>
|
||||
|
||||
<div v-if="previewVisible" class="modal-mask" @click.self="closePreview">
|
||||
<div class="modal evidence-modal">
|
||||
<div class="modal-head">
|
||||
<h3 v-if="previewRow">证据件 #{{ previewRow.id }} · {{ previewRow.taskId || '-' }}</h3>
|
||||
<button class="modal-close" type="button" aria-label="关闭" @click="closePreview">×</button>
|
||||
</div>
|
||||
<div v-if="previewLoading" class="modal-empty">读取中...</div>
|
||||
<div v-else-if="previewImage" class="preview-grid">
|
||||
<img :src="previewImage" alt="任务证据图" />
|
||||
</div>
|
||||
<pre v-else class="evidence-text">{{ previewText || '(空)' }}</pre>
|
||||
<div class="modal-foot">
|
||||
<button class="btn btn-secondary" type="button" @click="closePreview">关闭</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.evidence-view {
|
||||
font-family: inherit;
|
||||
color: var(--c-text, #24384d);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
}
|
||||
.evidence-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.evidence-tools {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.evidence-input {
|
||||
width: 180px;
|
||||
height: 32px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid #cdd8e3;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.evidence-uid {
|
||||
width: 120px;
|
||||
}
|
||||
.evidence-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
.link-like {
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: #2563eb;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
}
|
||||
.evidence-modal {
|
||||
width: min(960px, 92vw);
|
||||
max-height: 86vh;
|
||||
}
|
||||
.evidence-text {
|
||||
max-height: 60vh;
|
||||
overflow: auto;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
background: #f6f8fa;
|
||||
padding: 12px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.preview-grid img {
|
||||
max-width: 100%;
|
||||
max-height: 60vh;
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
}
|
||||
</style>
|
||||
@@ -10,8 +10,6 @@ export const TUTORIAL_UPLOAD_ENDPOINT = '/api/admin/tutorial'
|
||||
export const TUTORIAL_PRESIGN_ENDPOINT = `${TUTORIAL_UPLOAD_ENDPOINT}/presign`
|
||||
export const TUTORIAL_CONFIRM_ENDPOINT = `${TUTORIAL_UPLOAD_ENDPOINT}/confirm`
|
||||
export const TUTORIAL_DELETE_ENDPOINT = `${TUTORIAL_UPLOAD_ENDPOINT}/delete`
|
||||
/** 大档分片通道(AC-11):>8MB 的教程包走这里,不再一次性 presign PUT。 */
|
||||
export const TUTORIAL_CHUNK_ENDPOINT = '/api/files/chunk'
|
||||
|
||||
/** MinIO 直传专用实例:不带 cookie、不挂 401 跳登录拦截器(预签名过期/签名失败不能误判会话过期);大 zip 给足超时。 */
|
||||
const directPut = axios.create({ timeout: 600_000, withCredentials: false })
|
||||
|
||||
@@ -10,8 +10,6 @@ export const SOFTWARE_VERSION_UPLOAD_ENDPOINT = '/api/admin/version'
|
||||
export const SOFTWARE_VERSION_PRESIGN_ENDPOINT = `${SOFTWARE_VERSION_UPLOAD_ENDPOINT}/presign`
|
||||
export const SOFTWARE_VERSION_CONFIRM_ENDPOINT = `${SOFTWARE_VERSION_UPLOAD_ENDPOINT}/confirm`
|
||||
export const SOFTWARE_VERSION_DELETE_ENDPOINT = `${SOFTWARE_VERSION_UPLOAD_ENDPOINT}/delete`
|
||||
/** 大档分片通道(AC-11):>8MB 的安装包走这里,不再一次性 presign PUT。 */
|
||||
export const SOFTWARE_VERSION_CHUNK_ENDPOINT = '/api/files/chunk'
|
||||
|
||||
/** MinIO 直传专用实例:不带 cookie、不挂 401 跳登录拦截器(预签名过期/签名失败不能误判会话过期);大 zip 给足超时。 */
|
||||
const directPut = axios.create({ timeout: 600_000, withCredentials: false })
|
||||
|
||||
@@ -34,6 +34,7 @@ export const adminPages: AdminPageDef[] = [
|
||||
{ path: 'records/tutorial', menuKey: 'admin_tutorial', title: '教程管理', companyScoped: false, load: () => import('@/pages/records/RecordsTutorialPage.vue') },
|
||||
{ path: 'records/workbench-client-package', menuKey: 'admin_workbench_client_package', title: '数富AI工作台客户端包管理', companyScoped: false, load: () => import('@/pages/records/WorkbenchClientPackagePage.vue') },
|
||||
{ path: 'records/device-logs', menuKey: 'admin_device_logs', title: '日志管理', companyScoped: true, load: () => import('@/pages/records/DeviceLogsPage.vue') },
|
||||
{ path: 'records/task-evidence', menuKey: 'admin_task_evidence', title: '任务证据', superAdminOnly: true, companyScoped: false, load: () => import('@/pages/records/TaskEvidencePage.vue') },
|
||||
{ path: 'task-center/board', menuKey: 'admin_task_center', title: '客户端任务管理', companyScoped: true, load: () => import('@/pages/task-center/TaskCenterBoardPage.vue') },
|
||||
{ path: 'records/digital-human-version', menuKey: 'digital_human_version', title: '数字人版本管理', load: () => import('@/pages/records/RecordsDigitalHumanVersionPage.vue') },
|
||||
{ path: 'records/image-video-tasks', menuKey: 'admin_image_video_tasks', title: '视频任务记录', companyScoped: true, load: () => import('@/pages/tasks/ImageVideoTasksPage.vue') },
|
||||
|
||||
Reference in New Issue
Block a user