feat: 大屏新增虚拟工位滚动栏与多订单轮播,附件表增加删除原因及彻底清除留痕字段
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
<template>
|
||||
<el-card>
|
||||
<!-- 附件中心:集中查阅 + 下载/预览 + 逻辑删除。
|
||||
<!-- 附件中心(2026-10-28 生命周期重构):纯查阅——查、预览、下载、状态追溯。
|
||||
删除/恢复/彻底清除唯一入口 =「数据归档 → 磁盘空间回收」。
|
||||
物理落盘统一为 <Upload.Dir>/年/月/日/<文件类型>/<uuid>.<ext>,库内只存相对路径。 -->
|
||||
<el-alert v-if="disk.level !== 'ok'" :type="disk.level === 'critical' ? 'error' : 'warning'"
|
||||
<el-alert v-if="disk.level === 'ok'" type="info" :closable="false" show-icon style="margin-bottom:12px"
|
||||
:title="`磁盘空间正常(剩余 ${freePercent}%,${disk.rootDir})。附件的删除与磁盘释放请前往「数据归档 → 磁盘空间回收」`" />
|
||||
<el-alert v-else :type="disk.level === 'critical' ? 'error' : 'warning'"
|
||||
:closable="false" show-icon style="margin-bottom:12px"
|
||||
:title="disk.message || '磁盘空间告警'">
|
||||
<template #default>
|
||||
@@ -43,6 +46,14 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-alert v-if="!form.includeDeleted && hiddenDeleted > 0" type="warning" :closable="false" show-icon style="margin-bottom:12px">
|
||||
<template #title>
|
||||
另有 <b>{{ hiddenDeleted }}</b> 条已删除附件匹配当前筛选(默认隐藏)。
|
||||
<el-button link type="primary" size="small" @click="showHidden">点击查看</el-button>
|
||||
附件的删除与磁盘释放请前往「数据归档 → 磁盘空间回收」。
|
||||
</template>
|
||||
</el-alert>
|
||||
|
||||
<el-table :data="list" border size="small" v-loading="loading" empty-text="暂无附件">
|
||||
<el-table-column type="index" label="序号" width="60" align="center"
|
||||
:index="(i) => (page.current - 1) * page.size + i + 1" />
|
||||
@@ -65,18 +76,19 @@
|
||||
<el-table-column label="上传时间" width="155" align="center">
|
||||
<template #default="{ row }">{{ fmtTime(row.createdAt) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" width="90" align="center">
|
||||
<el-table-column label="状态" width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag v-if="row.deleted" size="small" type="danger">已删除</el-tag>
|
||||
<el-tag v-else size="small" type="success">有效</el-tag>
|
||||
<el-tooltip v-if="stateOf(row) !== 'normal'" :content="deletedTip(row)" placement="top" effect="dark">
|
||||
<el-tag v-if="stateOf(row) === 'purged'" size="small" type="info">已清除</el-tag>
|
||||
<el-tag v-else size="small" type="danger">已删除</el-tag>
|
||||
</el-tooltip>
|
||||
<el-tag v-else size="small" type="success">正常</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="170" align="center" fixed="right">
|
||||
<el-table-column label="操作" width="130" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" size="small" @click="preview(row)">预览</el-button>
|
||||
<el-button link type="primary" size="small" @click="download(row)">下载</el-button>
|
||||
<el-button v-if="!row.deleted && can('sys.attachment:manage')" link type="danger" size="small"
|
||||
@click="remove(row)">删除</el-button>
|
||||
<el-button link type="primary" size="small" :disabled="stateOf(row) === 'purged'" @click="download(row)">下载</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -95,14 +107,13 @@ import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import request from '../utils/request'
|
||||
import { getToken } from '../utils/auth'
|
||||
import { can } from '../utils/perm'
|
||||
import { fmtTime } from '../utils/format'
|
||||
import PageHelp from '../components/PageHelp.vue'
|
||||
import { helpAttachment } from '../help'
|
||||
|
||||
// 文件类型(大写枚举)中文名
|
||||
const FILE_TYPES = {
|
||||
PROCESS_PDF: '工艺',
|
||||
PROCESS_PDF: '工艺流程',
|
||||
INSPECTION_PHOTO: '检验照片',
|
||||
INSPECTION_PDF: '检验报告',
|
||||
DRAWING: '图纸',
|
||||
@@ -129,6 +140,7 @@ const form = reactive({ fileType: '', bizType: '', bizId: '', fileName: '', incl
|
||||
const dateRange = ref([])
|
||||
const list = ref([])
|
||||
const total = ref(0)
|
||||
const hiddenDeleted = ref(0)
|
||||
const page = reactive({ current: 1, size: 20 })
|
||||
const loading = ref(false)
|
||||
const disk = reactive({ level: 'ok', message: '', rootDir: '', usedPercent: 0, freeBytes: 0, totalBytes: 0 })
|
||||
@@ -163,12 +175,14 @@ async function load() {
|
||||
})
|
||||
list.value = data?.list || []
|
||||
total.value = data?.total || 0
|
||||
hiddenDeleted.value = data?.hiddenDeleted || 0
|
||||
Object.assign(disk, data?.disk || {})
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function showHidden() { form.includeDeleted = true; search() }
|
||||
function search() { page.current = 1; load() }
|
||||
function resetFilters() {
|
||||
form.fileType = ''
|
||||
@@ -188,11 +202,6 @@ function isInlinePreview(row) {
|
||||
// 文件类型枚举兜底(报告/图纸/流程卡多为 PDF)
|
||||
return row.fileType === 'INSPECTION_PDF' || row.fileType === 'PROCESS_PDF' || row.fileType === 'DRAWING'
|
||||
}
|
||||
function preview(row) {
|
||||
if (!isInlinePreview(row)) return download(row) // 非图片/PDF 直接下载
|
||||
if (!row.previewUrl) return ElMessage.warning('无预览地址')
|
||||
window.open(row.previewUrl, '_blank')
|
||||
}
|
||||
// 下载:带鉴权走 id 路由,服务端给出中文文件名
|
||||
async function download(row) {
|
||||
const token = getToken()
|
||||
@@ -207,15 +216,38 @@ async function download(row) {
|
||||
URL.revokeObjectURL(url)
|
||||
}
|
||||
|
||||
async function remove(row) {
|
||||
try {
|
||||
await ElMessageBox.confirm(`确认删除附件「${row.fileName}」吗?删除后可在「含已删除」中追溯。`, '操作确认', {
|
||||
confirmButtonText: '确认删除', cancelButtonText: '取消', type: 'warning'
|
||||
})
|
||||
} catch { return }
|
||||
await request.post('/attachment/delete', { id: row.id })
|
||||
ElMessage.success('删除成功')
|
||||
await load()
|
||||
// 状态三态:正常 / 已删除(文件还在磁盘,可恢复)/ 已清除(文件已物理删除,仅存索引可追溯)
|
||||
function stateOf(row) {
|
||||
if (row.purgedAt) return 'purged'
|
||||
if (row.deleted) return 'deleted'
|
||||
return 'normal'
|
||||
}
|
||||
function deletedTip(row) {
|
||||
const parts = []
|
||||
if (row.deleted) {
|
||||
parts.push(`删除人:${row.deletedBy || '—'}`)
|
||||
parts.push(`删除时间:${row.deletedAt ? fmtTime(row.deletedAt) : '—'}`)
|
||||
if (row.deletedReason) parts.push(`删除说明:${row.deletedReason}`)
|
||||
}
|
||||
if (row.purgedAt) {
|
||||
parts.push(`彻底清除:${fmtTime(row.purgedAt)}(${row.purgedBy || '—'})`)
|
||||
parts.push('磁盘文件已删除,如需找回请使用对应 U 盘备份包(介质可读性由保管人自行核对)')
|
||||
}
|
||||
return parts.join('\n')
|
||||
}
|
||||
|
||||
// 预览:已删除/已清除的附件先弹前因后果提示(用户透明)
|
||||
async function preview(row) {
|
||||
if (stateOf(row) !== 'normal') {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`该附件已被删除,打开前请知悉:\n${deletedTip(row)}`,
|
||||
'该附件为已删除/已清除状态', { type: 'warning', confirmButtonText: '仍要打开', cancelButtonText: '取消' })
|
||||
} catch { return }
|
||||
}
|
||||
if (!isInlinePreview(row)) return download(row) // 非图片/PDF 直接下载
|
||||
if (!row.previewUrl) return ElMessage.warning('无预览地址')
|
||||
window.open(row.previewUrl, '_blank')
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user