feat: 大屏改为纯流式自适应布局,新增KPI带与产线动态拓扑地图
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<el-card>
|
||||
<!-- 附件中心:集中查阅 + 下载/预览 + 逻辑删除 + 归档清理。
|
||||
<!-- 附件中心:集中查阅 + 下载/预览 + 逻辑删除。
|
||||
物理落盘统一为 <Upload.Dir>/年/月/日/<文件类型>/<uuid>.<ext>,库内只存相对路径。 -->
|
||||
<el-alert v-if="disk.level !== 'ok'" :type="disk.level === 'critical' ? 'error' : 'warning'"
|
||||
:closable="false" show-icon style="margin-bottom:12px"
|
||||
@@ -8,9 +8,7 @@
|
||||
<template #default>
|
||||
<div style="font-size:12px;line-height:1.7">
|
||||
附件根目录:{{ disk.rootDir }}|剩余 {{ freePercent }}%(剩余 {{ fmtSize(disk.freeBytes) }} / 共 {{ fmtSize(disk.totalBytes) }})
|
||||
<el-button v-if="disk.level === 'critical' && can('sys.attachment:manage')" link type="danger"
|
||||
style="margin-left:8px" @click="doArchive">立即归档清理</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-alert>
|
||||
|
||||
@@ -42,8 +40,6 @@
|
||||
<el-form-item>
|
||||
<el-button type="primary" :loading="loading" @click="search">查询</el-button>
|
||||
<el-button @click="resetFilters">重置</el-button>
|
||||
<el-button v-if="can('sys.attachment:manage')" type="warning" plain :loading="archiving"
|
||||
@click="doArchive">归档清理</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
@@ -56,11 +52,6 @@
|
||||
<el-tag size="small" type="info">{{ fileTypeText(row.fileType) }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="访问路径" min-width="260" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-link type="primary" :underline="false" @click="preview(row)">{{ fullUrl(row) }}</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="大小" width="100" align="right">
|
||||
<template #default="{ row }">{{ fmtSize(row.fileSize) }}</template>
|
||||
</el-table-column>
|
||||
@@ -77,7 +68,6 @@
|
||||
<el-table-column label="状态" width="90" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag v-if="row.deleted" size="small" type="danger">已删除</el-tag>
|
||||
<el-tag v-else-if="row.archived" size="small" type="warning">已归档</el-tag>
|
||||
<el-tag v-else size="small" type="success">有效</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -141,7 +131,6 @@ const list = ref([])
|
||||
const total = ref(0)
|
||||
const page = reactive({ current: 1, size: 20 })
|
||||
const loading = ref(false)
|
||||
const archiving = ref(false)
|
||||
const disk = reactive({ level: 'ok', message: '', rootDir: '', usedPercent: 0, freeBytes: 0, totalBytes: 0 })
|
||||
|
||||
const freePercent = computed(() => Math.max(0, 100 - (disk.usedPercent || 0)))
|
||||
@@ -204,12 +193,6 @@ function preview(row) {
|
||||
if (!row.previewUrl) return ElMessage.warning('无预览地址')
|
||||
window.open(row.previewUrl, '_blank')
|
||||
}
|
||||
// 路径改完整 URL(绝对可访问地址,便于复制/对接)
|
||||
function fullUrl(row) {
|
||||
if (!row.url) return row.filePath || '-'
|
||||
try { return location.origin + row.url } catch { return row.url }
|
||||
}
|
||||
|
||||
// 下载:带鉴权走 id 路由,服务端给出中文文件名
|
||||
async function download(row) {
|
||||
const token = getToken()
|
||||
@@ -235,27 +218,6 @@ async function remove(row) {
|
||||
await load()
|
||||
}
|
||||
|
||||
// 归档:先 dryRun 预览数量,确认后执行(早于本地保留年数的附件移动到外部备份目录并标记已归档)
|
||||
async function doArchive() {
|
||||
const pre = await request.post('/attachment/archive', { dryRun: true })
|
||||
if (!pre?.marked) return ElMessage.info('没有需要归档的附件(早于 ' + pre?.cutYear + ' 年的记录)')
|
||||
const tip = pre.archiveDir
|
||||
? `将把 ${pre.marked} 个早于 ${pre.cutYear} 年的附件移动到备份目录:\n${pre.archiveDir}`
|
||||
: `将把 ${pre.marked} 个早于 ${pre.cutYear} 年的附件标记为已归档(未配置备份目录,不移动物理文件)`
|
||||
try {
|
||||
await ElMessageBox.confirm(tip + '\n\n确认执行归档吗?', '归档确认', {
|
||||
confirmButtonText: '确认归档', cancelButtonText: '取消', type: 'warning'
|
||||
})
|
||||
} catch { return }
|
||||
archiving.value = true
|
||||
try {
|
||||
const res = await request.post('/attachment/archive', { dryRun: false })
|
||||
ElMessage.success(`归档完成:移动 ${res?.moved || 0},标记 ${res?.marked || 0},失败 ${res?.failed || 0}`)
|
||||
await load()
|
||||
} finally {
|
||||
archiving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
</script>
|
||||
|
||||
@@ -384,7 +384,7 @@ async function loadStations() {
|
||||
const nm = {}
|
||||
sts.forEach((s) => { nm[s.stationNo] = s.name })
|
||||
stationNameMap.value = nm
|
||||
// 接驳台真源 = dock 表(一个工位可配 R1/R2 多个接驳台),按 station_no 聚合为 stationNo → [dockCode]
|
||||
// 接驳台真源 = dock 表(一个工位可配 左L/右R 多个接驳台),按 station_no 聚合为 stationNo → [dockCode]
|
||||
const docks = (await request.get('/docks')) || []
|
||||
const dm = {}
|
||||
docks.forEach((d) => {
|
||||
@@ -460,7 +460,7 @@ function onPageChange(p) {
|
||||
fetchPage()
|
||||
}
|
||||
|
||||
// 该行送达接驳台:由工单工艺组合的工位号 → dock 表接驳台编码去重派生(支持一工位 R1/R2 多个接驳台)
|
||||
// 该行送达接驳台:由工单工艺组合的工位号 → dock 表接驳台编码去重派生(支持一工位 左L/右R 多个接驳台)
|
||||
function docksOf(row) {
|
||||
const comb = row.flowCombination || []
|
||||
const seen = {}; const ds = []
|
||||
|
||||
@@ -0,0 +1,375 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-alert type="warning" :closable="false" show-icon style="margin-bottom:12px"
|
||||
title="数据归档 = 备份到外部存储 + 按时间窗物理清理"
|
||||
description="① 先把历史数据备份到 U 盘 / 移动硬盘(不可逆操作的前置保护);② 确认备份完整后,再按时间窗物理删除本地数据以释放空间。清理不可恢复,请务必先备份。" />
|
||||
<el-row :gutter="12">
|
||||
<el-col :xs="24" :lg="14">
|
||||
<el-card shadow="never" header="一、备份到外部存储(U 盘 / 移动硬盘)">
|
||||
<el-form label-width="120px" style="max-width:680px">
|
||||
<el-form-item label="目标路径" required>
|
||||
<div style="display:flex;gap:8px;width:100%;align-items:center">
|
||||
<el-input :model-value="targetPath" readonly placeholder="请选择 U 盘/移动硬盘挂载路径" style="flex:1" />
|
||||
<el-button @click="openPicker">选择路径</el-button>
|
||||
</div>
|
||||
<div class="tip">备份包(zip,含 manifest.json + index.html 清单与校验)将直接流式写入该路径,不在本机留临时文件。默认回填上次成功备份路径。</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="时间窗" required>
|
||||
<div style="display:flex;gap:8px;align-items:center;flex-wrap:wrap">
|
||||
<el-date-picker v-model="startDate" type="date" value-format="YYYY-MM-DD" placeholder="开始日期"
|
||||
:disabled-date="d => d > today" style="width:160px" />
|
||||
<span>至</span>
|
||||
<el-date-picker v-model="endDate" type="date" value-format="YYYY-MM-DD" placeholder="结束日期"
|
||||
:disabled-date="d => d >= tomorrow" style="width:160px" />
|
||||
<el-button :loading="checking" @click="checkCoverage">覆盖预检</el-button>
|
||||
</div>
|
||||
<div class="tip">结束日期须 ≤ 昨天(不可备份当天及之后的数据)。建议先选时间窗做覆盖预检,确认历史已有完整备份。</div>
|
||||
<el-alert v-if="coverage" :type="coverage.ok ? 'success' : 'error'" :closable="false" style="margin-top:8px"
|
||||
:title="coverage.ok ? '该时间窗已被完整备份,可以清理' : '该时间窗未被完整备份,禁止清理'" />
|
||||
</el-form-item>
|
||||
<el-form-item label="数据项" required>
|
||||
<el-checkbox-group v-model="selItems">
|
||||
<el-checkbox v-for="it in items" :key="it.key" :value="it.key">{{ it.name }}</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
<div class="tip">质量相关 4 表(过程检/完工检/巡检/在制品流转)不在此列表,不参与归档清理。</div>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" :loading="backing" :disabled="!canStartBackup" @click="startBackup">开始备份</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-progress v-if="backupProg" :percentage="backupProg.percent" :status="backupProg.failed ? 'exception' : (backupProg.done ? 'success' : '')"
|
||||
:text-inside="true" :stroke-width="18" style="margin-top:8px" />
|
||||
<div v-if="backupProg" class="tip">{{ backupProg.message }}</div>
|
||||
<el-alert v-if="backupResult" type="success" :closable="false" style="margin-top:10px"
|
||||
:title="'备份完成:' + backupResult.backupPath">
|
||||
<div>共 {{ backupResult.items.length }} 项,总量 {{ fmtBytes(backupResult.totalSize) }},校验和(sha256) {{ backupResult.checksum }}</div>
|
||||
</el-alert>
|
||||
</el-card>
|
||||
</el-col>
|
||||
|
||||
<el-col :xs="24" :lg="10">
|
||||
<el-card shadow="never" header="二、按时间窗清理(腾空间,物理删除)">
|
||||
<el-alert v-if="!lastSuccessAt" type="info" :closable="false"
|
||||
title="尚无成功备份记录,清理入口未开放" style="margin-bottom:10px" />
|
||||
<template v-else>
|
||||
<el-form label-width="120px" style="max-width:560px">
|
||||
<el-form-item label="时间窗" required>
|
||||
<div style="display:flex;gap:8px;align-items:center;flex-wrap:wrap">
|
||||
<el-date-picker v-model="cleanStart" type="date" value-format="YYYY-MM-DD" placeholder="开始" :disabled-date="d => d > today" style="width:140px" />
|
||||
<span>至</span>
|
||||
<el-date-picker v-model="cleanEnd" type="date" value-format="YYYY-MM-DD" placeholder="结束" :disabled-date="d => d >= tomorrow" style="width:140px" />
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="数据项">
|
||||
<el-checkbox-group v-model="cleanItems">
|
||||
<el-checkbox v-for="it in items" :key="it.key" :value="it.key">{{ it.name }}</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="二次确认" required>
|
||||
<div>
|
||||
<el-checkbox v-model="ack1">① 我确认已将对应时间窗的数据完整备份到 U 盘 / 移动硬盘</el-checkbox><br />
|
||||
<el-checkbox v-model="ack2">② 我知晓此操作将物理删除本地数据,不可恢复</el-checkbox>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button :loading="previewing" @click="previewClean">预览将删除内容</el-button>
|
||||
<el-button type="danger" :loading="cleaning" :disabled="!canStartClean" @click="startCleanup" style="margin-left:8px">开始清理</el-button>
|
||||
</el-form-item>
|
||||
<el-alert v-if="preview" type="warning" :closable="false" style="margin-top:6px"
|
||||
:title="'清理预览:将删除合计 ' + preview.totalRows + ' 行 / ' + fmtBytes(preview.totalBytes)">
|
||||
<div v-for="p in preview.items" :key="p.key" style="line-height:1.8">
|
||||
{{ p.name }}:{{ p.rows }} 行 / {{ fmtBytes(p.bytes) }}
|
||||
</div>
|
||||
</el-alert>
|
||||
</el-form>
|
||||
<el-progress v-if="cleanProg" :percentage="cleanProg.percent" :status="cleanProg.failed ? 'exception' : (cleanProg.done ? 'success' : '')"
|
||||
:text-inside="true" :stroke-width="18" style="margin-top:8px" />
|
||||
<div v-if="cleanProg" class="tip">{{ cleanProg.message }}</div>
|
||||
</template>
|
||||
|
||||
<el-divider>定时清理提醒</el-divider>
|
||||
<div class="tip">清理提醒周期在「基础设置」页配置(默认 7 天)。距上次成功备份超过该天数时,登录后弹出强提醒,每天一次;仅提醒,不自动删除。</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-card shadow="never" style="margin-top:12px" header="三、备份 / 清理历史">
|
||||
<el-table :data="records.list" v-loading="recordsLoading" stripe size="small">
|
||||
<el-table-column label="执行时间" width="170">
|
||||
<template #default="{ row }">{{ fmtTime(row.executedAt) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="时间窗" min-width="220">
|
||||
<template #default="{ row }">{{ fmtTime(row.rangeStart) }} ~ {{ fmtTime(row.rangeEnd) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="backupPath" label="路径" min-width="200" show-overflow-tooltip />
|
||||
<el-table-column label="大小" width="120">
|
||||
<template #default="{ row }">{{ row.backupPath ? fmtBytes(row.totalSize) : '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.status === 'success' ? 'success' : (row.status === 'failed' ? 'danger' : 'warning')" size="small">
|
||||
{{ row.status === 'success' ? '成功' : (row.status === 'failed' ? '失败' : '部分') }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="operator" label="操作人" width="120" />
|
||||
</el-table>
|
||||
<el-pagination style="margin-top:10px;justify-content:flex-end" layout="total, prev, pager, next"
|
||||
:total="records.total" :page-size="records.size" :current-page="records.page"
|
||||
@current-change="loadRecords" />
|
||||
</el-card>
|
||||
|
||||
<!-- 服务端目录选择器 -->
|
||||
<el-dialog title="选择备份目标路径" v-model="pickerOpen" width="560px">
|
||||
<el-form label-width="60px">
|
||||
<el-form-item label="盘符">
|
||||
<el-select v-model="browseDrive" @change="onDriveChange" style="width:200px">
|
||||
<el-option v-for="d in drives" :key="d.path" :label="d.letter + ':\\'" :value="d.path" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="当前路径">
|
||||
<div style="display:flex;gap:8px;width:100%;align-items:center">
|
||||
<el-input :model-value="browsePath" readonly style="flex:1" />
|
||||
<el-button @click="goUp">上一级</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="子目录">
|
||||
<div v-loading="dirLoading" class="dir-list">
|
||||
<div v-if="!dirs.length" class="tip">该目录下无子目录</div>
|
||||
<div v-for="d in dirs" :key="d.path" class="dir-item" @click="enterDir(d)">
|
||||
<el-icon><Folder /></el-icon><span>{{ d.name }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="pickerOpen = false">取消</el-button>
|
||||
<el-button type="primary" @click="confirmPath">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, computed, onMounted, onBeforeUnmount } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Folder } from '@element-plus/icons-vue'
|
||||
import request from '../utils/request'
|
||||
|
||||
const items = ref([])
|
||||
const targetPath = ref('')
|
||||
const startDate = ref('')
|
||||
const endDate = ref('')
|
||||
const selItems = ref([])
|
||||
const checking = ref(false)
|
||||
const coverage = ref(null)
|
||||
|
||||
const backing = ref(false)
|
||||
const backupProg = ref(null)
|
||||
const backupResult = ref(null)
|
||||
let backupTimer = null
|
||||
|
||||
const cleanStart = ref('')
|
||||
const cleanEnd = ref('')
|
||||
const cleanItems = ref([])
|
||||
const ack1 = ref(false)
|
||||
const ack2 = ref(false)
|
||||
const cleaning = ref(false)
|
||||
const cleanProg = ref(null)
|
||||
let cleanTimer = null
|
||||
|
||||
const previewing = ref(false)
|
||||
const preview = ref(null)
|
||||
|
||||
const lastSuccessAt = ref(Number(localStorage.getItem('mes_last_backup_at') || 0))
|
||||
|
||||
const records = reactive({ list: [], total: 0, page: 1, size: 50 })
|
||||
const recordsLoading = ref(false)
|
||||
|
||||
const today = new Date()
|
||||
const tomorrow = new Date(); tomorrow.setDate(today.getDate() + 1)
|
||||
|
||||
// ===== 目录选择器 =====
|
||||
const pickerOpen = ref(false)
|
||||
const drives = ref([])
|
||||
const browseDrive = ref('')
|
||||
const browsePath = ref('')
|
||||
const dirs = ref([])
|
||||
const dirLoading = ref(false)
|
||||
|
||||
function toUnixEnd(dateStr) {
|
||||
const d = new Date(dateStr + 'T23:59:59')
|
||||
return Math.floor(d.getTime() / 1000)
|
||||
}
|
||||
function toUnixStart(dateStr) {
|
||||
const d = new Date(dateStr + 'T00:00:00')
|
||||
return Math.floor(d.getTime() / 1000)
|
||||
}
|
||||
function fmtBytes(n) {
|
||||
if (!n) return '0 B'
|
||||
const u = ['B', 'KB', 'MB', 'GB', 'TB']
|
||||
let i = 0; let x = n
|
||||
while (x >= 1024 && i < u.length - 1) { x /= 1024; i++ }
|
||||
return (i === 0 ? x : x.toFixed(2)) + ' ' + u[i]
|
||||
}
|
||||
function fmtTime(unix) {
|
||||
if (!unix) return '—'
|
||||
const d = new Date(unix * 1000)
|
||||
const p = (n) => String(n).padStart(2, '0')
|
||||
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`
|
||||
}
|
||||
|
||||
const canStartBackup = computed(() =>
|
||||
targetPath.value.trim() !== '' && startDate.value && endDate.value &&
|
||||
toUnixStart(startDate.value) < toUnixEnd(endDate.value) && selItems.value.length > 0 && !backing.value)
|
||||
|
||||
const canStartClean = computed(() =>
|
||||
lastSuccessAt.value && cleanStart.value && cleanEnd.value &&
|
||||
toUnixStart(cleanStart.value) < toUnixEnd(cleanEnd.value) && cleanItems.value.length > 0 &&
|
||||
ack1.value && ack2.value && preview.value && !cleaning.value)
|
||||
|
||||
async function loadItems() {
|
||||
try { items.value = await request.get('/backup/items') } catch { items.value = [] }
|
||||
}
|
||||
|
||||
async function checkCoverage() {
|
||||
if (!startDate.value || !endDate.value) { ElMessage.warning('请选择时间窗'); return }
|
||||
checking.value = true
|
||||
try {
|
||||
const r = await request.post('/cleanup/check', { start: toUnixStart(startDate.value), end: toUnixEnd(endDate.value) })
|
||||
coverage.value = r
|
||||
} finally { checking.value = false }
|
||||
}
|
||||
|
||||
async function startBackup() {
|
||||
backupResult.value = null
|
||||
backupProg.value = { jobId: '', percent: 0, message: '准备中…' }
|
||||
backing.value = true
|
||||
try {
|
||||
const r = await request.post('/backup/start', {
|
||||
targetPath: targetPath.value.trim(),
|
||||
start: toUnixStart(startDate.value),
|
||||
end: toUnixEnd(endDate.value),
|
||||
items: selItems.value
|
||||
})
|
||||
pollBackup(r.jobId)
|
||||
} catch { backing.value = false; backupProg.value = null }
|
||||
}
|
||||
|
||||
function pollBackup(jobId) {
|
||||
backupTimer = setInterval(async () => {
|
||||
try {
|
||||
const p = await request.get('/backup/progress', { params: { jobId } })
|
||||
backupProg.value = p
|
||||
if (p.done) {
|
||||
clearInterval(backupTimer)
|
||||
backing.value = false
|
||||
if (p.failed) { ElMessage.error(p.message || '备份失败') }
|
||||
else {
|
||||
backupResult.value = p.result
|
||||
lastSuccessAt.value = Math.floor(Date.now() / 1000)
|
||||
localStorage.setItem('mes_last_backup_at', String(lastSuccessAt.value))
|
||||
ElMessage.success('备份完成')
|
||||
loadRecords(1)
|
||||
}
|
||||
}
|
||||
} catch { /* 轮询异常忽略 */ }
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
async function previewClean() {
|
||||
if (!cleanStart.value || !cleanEnd.value) { ElMessage.warning('请先选择清理时间窗'); return }
|
||||
if (!cleanItems.value.length) { ElMessage.warning('请至少选择一个数据项'); return }
|
||||
previewing.value = true
|
||||
preview.value = null
|
||||
try {
|
||||
const r = await request.post('/cleanup/preview', {
|
||||
start: toUnixStart(cleanStart.value), end: toUnixEnd(cleanEnd.value), items: cleanItems.value
|
||||
})
|
||||
preview.value = r
|
||||
} finally { previewing.value = false }
|
||||
}
|
||||
|
||||
async function startCleanup() {
|
||||
try {
|
||||
await ElMessageBox.confirm('即将物理删除本地数据(不可恢复),且已确认 U 盘备份完整。是否继续?', '二次确认', { type: 'warning' })
|
||||
} catch { return }
|
||||
cleanProg.value = { percent: 0, message: '准备中…' }
|
||||
cleaning.value = true
|
||||
try {
|
||||
const r = await request.post('/cleanup/start', {
|
||||
start: toUnixStart(cleanStart.value),
|
||||
end: toUnixEnd(cleanEnd.value),
|
||||
items: cleanItems.value
|
||||
})
|
||||
pollClean(r.jobId)
|
||||
} catch { cleaning.value = false; cleanProg.value = null }
|
||||
}
|
||||
|
||||
function pollClean(jobId) {
|
||||
cleanTimer = setInterval(async () => {
|
||||
try {
|
||||
const p = await request.get('/cleanup/progress', { params: { jobId } })
|
||||
cleanProg.value = p
|
||||
if (p.done) {
|
||||
clearInterval(cleanTimer)
|
||||
cleaning.value = false
|
||||
if (p.failed) ElMessage.error(p.message || '清理被拒/失败')
|
||||
else { ElMessage.success('清理完成'); preview.value = null; loadRecords(1) }
|
||||
}
|
||||
} catch { /* 轮询异常忽略 */ }
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
async function loadRecords(page = 1) {
|
||||
recordsLoading.value = true
|
||||
try {
|
||||
const r = await request.get('/backup/records', { params: { page, size: records.size } })
|
||||
records.list = r.list || []
|
||||
records.total = r.total || 0
|
||||
records.page = r.page || page
|
||||
} catch { /* ignore */ } finally { recordsLoading.value = false }
|
||||
}
|
||||
|
||||
// ===== 目录选择器逻辑 =====
|
||||
async function openPicker() {
|
||||
pickerOpen.value = true
|
||||
dirLoading.value = true
|
||||
try {
|
||||
drives.value = await request.get('/backup/drives')
|
||||
const def = targetPath.value || (drives.value[0] && drives.value[0].path) || ''
|
||||
browsePath.value = def
|
||||
browseDrive.value = (drives.value.find(d => def.startsWith(d.path)) || drives.value[0] || {}).path || ''
|
||||
await loadDirs()
|
||||
} finally { dirLoading.value = false }
|
||||
}
|
||||
function onDriveChange(p) { browsePath.value = p; loadDirs() }
|
||||
function goUp() {
|
||||
const i = Math.max(browsePath.value.lastIndexOf('\\'), browsePath.value.lastIndexOf('/'))
|
||||
if (i > 0) { browsePath.value = browsePath.value.slice(0, i); loadDirs() }
|
||||
}
|
||||
function enterDir(d) { browsePath.value = d.path; loadDirs() }
|
||||
async function loadDirs() {
|
||||
dirLoading.value = true
|
||||
try { dirs.value = await request.get('/backup/listdir', { params: { path: browsePath.value } }) } catch { dirs.value = [] }
|
||||
finally { dirLoading.value = false }
|
||||
}
|
||||
function confirmPath() { targetPath.value = browsePath.value; pickerOpen.value = false }
|
||||
|
||||
onMounted(async () => {
|
||||
await loadItems()
|
||||
try {
|
||||
const r = await request.get('/backup/reminder')
|
||||
if (r.lastBackupPath) targetPath.value = r.lastBackupPath
|
||||
} catch { /* ignore */ }
|
||||
await loadRecords(1)
|
||||
})
|
||||
onBeforeUnmount(() => { if (backupTimer) clearInterval(backupTimer); if (cleanTimer) clearInterval(cleanTimer) })
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.tip { color: #909399; font-size: 12px; line-height: 1.6; width: 100%; }
|
||||
.dir-list { border: 1px solid #ebeef5; border-radius: 4px; padding: 6px; max-height: 240px; overflow: auto; }
|
||||
.dir-item { display: flex; align-items: center; gap: 6px; padding: 4px 8px; cursor: pointer; border-radius: 4px; }
|
||||
.dir-item:hover { background: #f2f6fc; color: #1668dc; }
|
||||
</style>
|
||||
@@ -65,7 +65,7 @@
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" :loading="loading" @click="query">查询</el-button>
|
||||
<el-button :disabled="!canPrint" @click="printCurrent">打印 / 导出 PDF</el-button>
|
||||
<el-button type="success" :disabled="!canPrint" @click="openExportDialog">导出</el-button>
|
||||
<el-button @click="reset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@@ -295,6 +295,25 @@
|
||||
</el-card>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
||||
<!-- ============ 导出选择框(格式选择,选完再生成文件) ============ -->
|
||||
<el-dialog v-model="exportVisible" title="导出生产流程卡" width="440px" :close-on-click-modal="false" append-to-body @closed="exporting = false">
|
||||
<el-form label-width="84px">
|
||||
<el-form-item label="导出格式">
|
||||
<el-radio-group v-model="exportFormat">
|
||||
<el-radio value="pdf">PDF(打印版 / 浏览器另存为 PDF)</el-radio>
|
||||
<el-radio value="excel">Excel(CSV,双击即用 Excel 打开)</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="导出范围">
|
||||
<span class="muted">当前查看的这张卡(单条)</span>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="exportVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="exporting" @click="doExport">确认导出</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
<PageHelp :data="helpProcessCard" page="ProcessCard" />
|
||||
</template>
|
||||
@@ -464,6 +483,134 @@ const dateLabel = computed(() => {
|
||||
|
||||
const canPrint = computed(() => (mode.value === 'workorder' && card.value) || (mode.value === 'sn' && snCard.value))
|
||||
|
||||
// ---------- 导出(选择框 → 选完再生成文件) ----------
|
||||
const exportVisible = ref(false)
|
||||
const exportFormat = ref('pdf')
|
||||
const exporting = ref(false)
|
||||
|
||||
function openExportDialog() {
|
||||
exportFormat.value = 'pdf'
|
||||
exportVisible.value = true
|
||||
}
|
||||
|
||||
async function doExport() {
|
||||
if (exportFormat.value === 'pdf') {
|
||||
// PDF(打印版):复用服务端渲染 HTML,新窗口内打印 / 另存为 PDF
|
||||
exportVisible.value = false
|
||||
printCurrent()
|
||||
return
|
||||
}
|
||||
// Excel(CSV,Excel 可直接打开,零依赖)
|
||||
exporting.value = true
|
||||
try {
|
||||
if (mode.value === 'workorder' && card.value) {
|
||||
downloadCsv(buildWorkOrderCsv(card.value), `生产流程卡_${card.value.workOrderNo || 'workorder'}.csv`)
|
||||
} else if (mode.value === 'sn' && snCard.value) {
|
||||
downloadCsv(buildSnCsv(snCard.value), `成品追溯卡_${snCard.value.sn || 'sn'}.csv`)
|
||||
}
|
||||
} finally {
|
||||
exporting.value = false
|
||||
exportVisible.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 客户端生成 CSV(与页面现有字段一致,UTF-8 BOM 保证 Excel 中文不乱码)
|
||||
function csvCell(v) {
|
||||
if (v === null || v === undefined) v = ''
|
||||
const s = String(v)
|
||||
if (s.includes(',') || s.includes('"') || s.includes('\n') || s.includes('\r')) {
|
||||
return '"' + s.replace(/"/g, '""') + '"'
|
||||
}
|
||||
return s
|
||||
}
|
||||
function downloadCsv(content, filename) {
|
||||
const blob = new Blob(['' + content], { type: 'text/csv;charset=utf-8' })
|
||||
const url = URL.createObjectURL(blob)
|
||||
const a = document.createElement('a')
|
||||
a.href = url
|
||||
a.download = filename
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
document.body.removeChild(a)
|
||||
URL.revokeObjectURL(url)
|
||||
}
|
||||
function buildWorkOrderCsv(c) {
|
||||
const lines = []
|
||||
const push = (arr) => lines.push(arr.map(csvCell).join(','))
|
||||
push(['生产流程卡(工单维度)', c.workOrderNo || ''])
|
||||
push(['产品工号', c.workOrderNo || '', '产品型号', c.productCode || '', '产品名称', c.productName || '', '图号', c.drawingNo || ''])
|
||||
push(['计划数', c.planQty ?? '', '完成数', c.finishedNum ?? '', '不良数', c.failNum ?? '', '状态', c.status || ''])
|
||||
push(['计划开始', c.planStart || '', '计划完成', c.planEnd || '', '实际开始', c.actualStart || '', '实际完成', c.completedAt || ''])
|
||||
push(['实际结束', c.actualFinish || '', '生成时间', c.generatedAt || ''])
|
||||
lines.push('')
|
||||
push(['一、工序实绩'])
|
||||
push(['序号', '工序', '采集方式', '工位', '计划工时', '实绩开始', '实绩结束', '操作人', '状态', '审核人', '审核时间'])
|
||||
;(c.processSteps || []).forEach((r) =>
|
||||
push([r.seq, r.processName, r.collectCN, r.stationNo, r.planHours, r.actualStart, r.actualEnd, r.operators, r.status, (r.auditor || '') + (r.auditRole ? '(' + r.auditRole + ')' : ''), r.auditedAt])
|
||||
)
|
||||
lines.push('')
|
||||
push(['二、用料清单·序列号=是'])
|
||||
push(['图号', '名称', '类型', '规格', '单位', '物料SN', '数量', '装配工位', '装配人'])
|
||||
;(c.serialMaterials || []).forEach((r) =>
|
||||
push([r.materialCode, r.materialName, r.materialType, r.spec, r.unit, (r.snList || []).join(' '), r.qty, r.stationNo, r.operator])
|
||||
)
|
||||
lines.push('')
|
||||
push(['三、用料清单·序列号=否'])
|
||||
push(['图号', '名称', '类型', '规格', '单位', '批次号', '数量', '装配工位', '装配人'])
|
||||
;(c.batchMaterials || []).forEach((r) =>
|
||||
push([r.materialCode, r.materialName, r.materialType, r.spec, r.unit, r.batchNo, r.qty, r.stationNo, r.operator])
|
||||
)
|
||||
lines.push('')
|
||||
push(['四、成品明细'])
|
||||
push(['SN', '状态', '完工时间'])
|
||||
;(c.products || []).forEach((r) => push([r.sn, r.status, r.doneAt]))
|
||||
lines.push('')
|
||||
push(['五、签字确认'])
|
||||
const s = c.signs || {}
|
||||
push(['操作工', s.operator ? s.operator.names + '(' + s.operator.count + '次,最近 ' + s.operator.latestTime + ')' : '待签'])
|
||||
push(['检验员', s.inspector ? s.inspector.names + '(' + s.inspector.count + '次,最近 ' + s.inspector.latestTime + ')' : '待签'])
|
||||
push(['审核人', s.auditor ? s.auditor.names + '(' + s.auditor.count + '次,最近 ' + s.auditor.latestTime + ')' : '待签'])
|
||||
push(['批准人', '手签'])
|
||||
return lines.join('\r\n')
|
||||
}
|
||||
function buildSnCsv(c) {
|
||||
const lines = []
|
||||
const push = (arr) => lines.push(arr.map(csvCell).join(','))
|
||||
push(['成品追溯卡(SN 维度)', c.sn || ''])
|
||||
push(['SN', c.sn || '', '产品工号', c.workOrderNo || '', '产品型号', c.productCode || '', '状态', c.status || ''])
|
||||
push(['完工时间', c.doneAt || '', '生成时间', c.generatedAt || ''])
|
||||
lines.push('')
|
||||
push(['一、工序实绩'])
|
||||
push(['工位', '工序', '开始', '结束', '操作人', '状态', '结果'])
|
||||
;(c.processes || []).forEach((r) => push([r.stationNo, r.processName, r.startAt, r.endAt, r.operator, r.status, r.result]))
|
||||
lines.push('')
|
||||
push(['二、用料清单·序列号=是'])
|
||||
push(['图号', '名称', '类型', '规格', '单位', '物料SN', '数量', '装配工位', '装配人'])
|
||||
;(c.serialMaterials || []).forEach((r) =>
|
||||
push([r.materialCode, r.materialName, r.materialType, r.spec, r.unit, (r.snList || []).join(' '), r.qty, r.stationNo, r.operator])
|
||||
)
|
||||
lines.push('')
|
||||
push(['三、用料清单·序列号=否'])
|
||||
push(['图号', '名称', '类型', '规格', '单位', '批次号', '数量', '装配工位', '装配人'])
|
||||
;(c.batchMaterials || []).forEach((r) =>
|
||||
push([r.materialCode, r.materialName, r.materialType, r.spec, r.unit, r.batchNo, r.qty, r.stationNo, r.operator])
|
||||
)
|
||||
if ((c.torqueRows || []).length) {
|
||||
lines.push('')
|
||||
push(['四、拧紧数据'])
|
||||
push(['螺丝编号', '扭矩(N·m)', '角度(°)', '结果', '操作人', '时间'])
|
||||
;(c.torqueRows || []).forEach((r) => push([r.screwNo, r.torque, r.angle, r.result, r.operator, r.time]))
|
||||
}
|
||||
lines.push('')
|
||||
push([(c.torqueRows && c.torqueRows.length) ? '五、签字确认' : '四、签字确认'])
|
||||
const s = c.signs || {}
|
||||
push(['操作工', s.operator ? s.operator.names : '待签'])
|
||||
push(['检验员', s.inspector ? s.inspector.names : '待签'])
|
||||
push(['审核人', s.auditor ? s.auditor.names : '待签'])
|
||||
push(['批准人', '手签'])
|
||||
return lines.join('\r\n')
|
||||
}
|
||||
|
||||
function printCurrent() {
|
||||
if (mode.value === 'workorder' && workOrderNo.value) {
|
||||
openPrintableHtml('/process-card/workorder', { no: workOrderNo.value })
|
||||
|
||||
@@ -43,6 +43,19 @@
|
||||
<el-input-number v-model="form.dashboardRefreshSeconds" :min="1" :max="10" />
|
||||
<div class="tip">看板大屏轮询兜底刷新间隔(1~10 秒,默认 5);SSE 实时通道可用时由事件驱动刷新,本值仅作兜底间隔</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="门口看板标题">
|
||||
<el-input v-model="form.dashboardTitle" clearable maxlength="30"
|
||||
placeholder="留空=默认标题(总装产线实时看板)" />
|
||||
<div class="tip">厂门口看板顶部标题文字(留空=保持默认「总装产线实时看板」);看板端每分钟自动拉取跟随</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="门口看板语音播报">
|
||||
<el-switch v-model="form.dashboardVoice" />
|
||||
<div class="tip">开启(默认)后厂门口看板对新报警进行中文语音播报;关闭则只静默展示</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="数据归档提醒周期(天)">
|
||||
<el-input-number v-model="form.archiveRemindDays" :min="0" :max="365" />
|
||||
<div class="tip">距上次成功备份超过该天数时,登录后弹出强提醒(每天一次,仅提醒不自动删除);0 = 关闭</div>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button v-if="can('sys.settings:edit')" type="primary" :loading="saving" @click="save">保存</el-button>
|
||||
</el-form-item>
|
||||
@@ -82,7 +95,7 @@ const loading = ref(false)
|
||||
const saving = ref(false)
|
||||
const testing = ref(false)
|
||||
const testMsg = ref('')
|
||||
const form = reactive({ wmsBaseURL: '', demandDays: 5, extrapWindow: 3, extrapCap: 365, logRetentionDays: 0, pipelineCache: 0, allowCrossDay: 1, torqueNgAlert: true, dashboardRefreshSeconds: 5 })
|
||||
const form = reactive({ wmsBaseURL: '', demandDays: 5, extrapWindow: 3, extrapCap: 365, logRetentionDays: 0, pipelineCache: 0, allowCrossDay: 1, torqueNgAlert: true, dashboardRefreshSeconds: 5, archiveRemindDays: 7, dashboardTitle: '', dashboardVoice: true })
|
||||
const info = ref({})
|
||||
|
||||
async function load() {
|
||||
@@ -98,7 +111,10 @@ async function load() {
|
||||
pipelineCache: data.pipelineCache ?? 0,
|
||||
allowCrossDay: data.allowCrossDay ?? 1,
|
||||
torqueNgAlert: data.torqueNgAlert ?? true,
|
||||
dashboardRefreshSeconds: data.dashboardRefreshSeconds ?? 5
|
||||
dashboardRefreshSeconds: data.dashboardRefreshSeconds ?? 5,
|
||||
archiveRemindDays: data.archiveRemindDays ?? 7,
|
||||
dashboardTitle: data.dashboardTitle || '',
|
||||
dashboardVoice: data.dashboardVoice ?? true
|
||||
})
|
||||
info.value = data
|
||||
} finally {
|
||||
|
||||
@@ -154,7 +154,7 @@ import { helpStation } from '../help'
|
||||
|
||||
const stations = ref([])
|
||||
const flows = ref([])
|
||||
// 接驳台主数据(真源在 dock 表):一工位可绑多个接驳台(R1/R2),展示按 dock.station_no 聚合
|
||||
// 接驳台主数据(真源在 dock 表):一工位可绑多个接驳台(左L/右R),展示按 dock.station_no 聚合
|
||||
const dockByStation = ref({})
|
||||
|
||||
async function loadDocks() {
|
||||
|
||||
Reference in New Issue
Block a user