feat: 新增预警定时扫描器,移除附件归档字段并为角色表补充更新时间
This commit is contained in:
@@ -28,6 +28,12 @@
|
||||
<span v-else style="color:#c0c4cc">从未登录</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建时间" width="160" align="center">
|
||||
<template #default="{ row }">{{ row.createdAt ? fmtTime(row.createdAt) : '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="更新时间" width="160" align="center">
|
||||
<template #default="{ row }">{{ row.updatedAt ? fmtTime(row.updatedAt) : '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" width="150" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-switch :model-value="row.status" active-value="ENABLED" inactive-value="DISABLED"
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<el-option v-for="(label, val) in BIZ_TYPES" :key="val" :label="label" :value="val" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="业务ID">
|
||||
<el-form-item label="业务标识">
|
||||
<el-input v-model="form.bizId" placeholder="如 产品工号 / 图号 / SN" clearable style="width:190px"
|
||||
@keyup.enter="search" />
|
||||
</el-form-item>
|
||||
@@ -69,7 +69,7 @@
|
||||
<el-table-column label="业务类型" width="110" align="center">
|
||||
<template #default="{ row }">{{ bizTypeText(row.bizType) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="bizId" label="业务ID" width="150" show-overflow-tooltip />
|
||||
<el-table-column prop="bizId" label="业务标识" width="150" show-overflow-tooltip />
|
||||
<el-table-column prop="uploader" label="上传人" width="100" align="center">
|
||||
<template #default="{ row }">{{ row.uploader || '-' }}</template>
|
||||
</el-table-column>
|
||||
|
||||
@@ -253,7 +253,7 @@
|
||||
|
||||
<el-form inline style="margin-bottom:8px" @submit.prevent="loadAttList(1)">
|
||||
<el-form-item label="文件名"><el-input v-model="attFilter.fileName" clearable style="width:150px" @keyup.enter="loadAttList(1)" /></el-form-item>
|
||||
<el-form-item label="业务ID"><el-input v-model="attFilter.bizId" clearable style="width:140px" @keyup.enter="loadAttList(1)" /></el-form-item>
|
||||
<el-form-item label="业务标识"><el-input v-model="attFilter.bizId" clearable style="width:140px" @keyup.enter="loadAttList(1)" /></el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="attFilter.state" style="width:110px" @change="loadAttList(1)">
|
||||
<el-option label="全部" value="all" />
|
||||
@@ -268,7 +268,7 @@
|
||||
</el-form>
|
||||
<el-table :data="attList" size="small" border v-loading="attListLoading" max-height="320">
|
||||
<el-table-column prop="fileName" label="文件名" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column prop="bizId" label="业务ID" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="bizId" label="业务标识" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column label="大小" width="90" align="center">
|
||||
<template #default="{ row }">{{ fmtBytes(row.fileSize) }}</template>
|
||||
</el-table-column>
|
||||
@@ -371,7 +371,7 @@
|
||||
<el-table :data="orphans.list" size="small" border max-height="260">
|
||||
<el-table-column prop="fileName" label="文件名" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column prop="bizType" label="业务类型" width="100" align="center" />
|
||||
<el-table-column prop="bizId" label="业务ID" min-width="110" show-overflow-tooltip />
|
||||
<el-table-column prop="bizId" label="业务标识" min-width="110" show-overflow-tooltip />
|
||||
<el-table-column label="大小" width="90" align="center">
|
||||
<template #default="{ row }">{{ fmtBytes(row.fileSize) }}</template>
|
||||
</el-table-column>
|
||||
|
||||
@@ -252,7 +252,7 @@
|
||||
<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="pdf">PDF(下载文件)</el-radio>
|
||||
<el-radio value="excel">Excel(CSV,双击即用 Excel 打开)</el-radio>
|
||||
<el-radio value="print">打印版(新窗口并直接弹出打印)</el-radio>
|
||||
</el-radio-group>
|
||||
@@ -459,8 +459,26 @@ async function fetchAllFilteredNos() {
|
||||
return nos
|
||||
}
|
||||
|
||||
// 批量导出工单卡:Excel=合并 CSV;PDF/打印版=多卡 HTML 合并一个新窗口(每卡一分页)
|
||||
// 批量导出工单卡:PDF=服务端生成真 PDF 下载;Excel=合并 CSV;打印版=新窗口打印
|
||||
async function exportWorkOrders(nos) {
|
||||
if (exportFormat.value === 'pdf') {
|
||||
exporting.value = true
|
||||
try {
|
||||
const params = new URLSearchParams()
|
||||
nos.forEach((n) => params.append('no', n))
|
||||
const resp = await request.get('/process-card/pdf?' + params.toString(), { responseType: 'blob' })
|
||||
const name = nos.length === 1
|
||||
? `生产流程卡_${nos[0]}.pdf`
|
||||
: `生产流程卡_批量${nos.length}张.pdf`
|
||||
downloadBlob(resp, name)
|
||||
} catch {
|
||||
ElMessage.error('PDF 生成失败,请稍后重试')
|
||||
} finally {
|
||||
exporting.value = false
|
||||
exportVisible.value = false
|
||||
}
|
||||
return
|
||||
}
|
||||
if (exportFormat.value === 'excel') {
|
||||
exporting.value = true
|
||||
try {
|
||||
@@ -484,7 +502,7 @@ async function exportWorkOrders(nos) {
|
||||
}
|
||||
return
|
||||
}
|
||||
// PDF / 打印版:逐卡拉服务端渲染 HTML,合并进一个新窗口(避免逐张弹窗被拦截)
|
||||
// 打印版:逐卡拉服务端渲染 HTML,合并进一个新窗口(避免逐张弹窗被拦截)
|
||||
exporting.value = true
|
||||
try {
|
||||
const htmlList = []
|
||||
@@ -496,7 +514,7 @@ async function exportWorkOrders(nos) {
|
||||
ElMessage.error('未能获取可打印内容')
|
||||
return
|
||||
}
|
||||
openMergedPrintWindow(htmlList, exportFormat.value === 'print')
|
||||
openMergedPrintWindow(htmlList, true)
|
||||
} finally {
|
||||
exporting.value = false
|
||||
exportVisible.value = false
|
||||
@@ -505,6 +523,16 @@ async function exportWorkOrders(nos) {
|
||||
|
||||
// 单张 SN 追溯卡导出
|
||||
async function exportSnSingle(c) {
|
||||
if (exportFormat.value === 'pdf') {
|
||||
try {
|
||||
const resp = await request.get('/process-card/pdf?sn=' + encodeURIComponent(c.sn), { responseType: 'blob' })
|
||||
downloadBlob(resp, `成品追溯卡_${c.sn || 'sn'}.pdf`)
|
||||
} catch {
|
||||
ElMessage.error('PDF 生成失败,请稍后重试')
|
||||
}
|
||||
exportVisible.value = false
|
||||
return
|
||||
}
|
||||
if (exportFormat.value === 'excel') {
|
||||
downloadCsv(buildSnCsv(c), `成品追溯卡_${c.sn || 'sn'}.csv`)
|
||||
exportVisible.value = false
|
||||
@@ -542,6 +570,19 @@ function downloadCsv(content, filename) {
|
||||
document.body.removeChild(a)
|
||||
URL.revokeObjectURL(url)
|
||||
}
|
||||
|
||||
// 二进制文件下载(PDF 等):resp 为 axios blob 响应
|
||||
function downloadBlob(resp, filename) {
|
||||
const blob = resp instanceof Blob ? resp : new Blob([resp])
|
||||
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(','))
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
<el-button type="primary" @click="search">查询</el-button>
|
||||
<el-button @click="resetFilters">重置</el-button>
|
||||
<el-button v-if="can('produce.product:add')" type="primary" plain @click="openAdd">新增物料档案</el-button>
|
||||
<el-button v-if="can('produce.product:add')" @click="downloadTemplate">模板下载</el-button>
|
||||
<el-button v-if="can('produce.product:add')" @click="triggerImport">Excel 导入</el-button>
|
||||
<el-button @click="exportXlsx">导出</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@@ -118,6 +120,7 @@
|
||||
<AttachmentPanel biz-type="material" :biz-id="attachDrawer.code" title="附件(图纸 / 资料)" />
|
||||
</el-drawer>
|
||||
</el-card>
|
||||
<input ref="importInput" type="file" accept=".xlsx" style="display:none" @change="onImportFile" />
|
||||
<PageHelp :data="helpProductType" page="ProductType" />
|
||||
</template>
|
||||
|
||||
@@ -243,6 +246,41 @@ async function toggleActive(row) {
|
||||
load()
|
||||
}
|
||||
function openAttach(row) { Object.assign(attachDrawer, { visible: true, code: row.code, name: row.name }) }
|
||||
async function downloadTemplate() {
|
||||
try {
|
||||
const blob = await request.get('/product-types/template', { responseType: 'blob' })
|
||||
const a = document.createElement('a')
|
||||
a.href = URL.createObjectURL(blob)
|
||||
a.download = '物料档案导入模板.xlsx'
|
||||
a.click()
|
||||
URL.revokeObjectURL(a.href)
|
||||
} catch (e) {
|
||||
ElMessage.error('模板下载失败')
|
||||
}
|
||||
}
|
||||
|
||||
// Excel 导入:隐藏 file input 触发 → 上传 → 展示结果(成功/失败行明细)
|
||||
const importInput = ref(null)
|
||||
function triggerImport() { importInput.value && importInput.value.click() }
|
||||
async function onImportFile(e) {
|
||||
const file = e.target.files && e.target.files[0]
|
||||
if (e.target.value) e.target.value = '' // 允许重复选同一文件
|
||||
if (!file) return
|
||||
const fd = new FormData()
|
||||
fd.append('file', file)
|
||||
try {
|
||||
const res = await request.post('/product-types/import', fd, { headers: { 'Content-Type': 'multipart/form-data' } })
|
||||
const r = res || {}
|
||||
const detail = (r.errors || []).slice(0, 8).map((x) => `第${x.row}行:${x.message}`).join('\n')
|
||||
ElMessage.success(`导入完成:成功 ${r.success || 0} 行,失败 ${r.failed || 0} 行${detail ? '\n' + detail : ''}`)
|
||||
if ((r.failed || 0) > 0) {
|
||||
console.warn('物料档案导入失败明细', r.errors)
|
||||
}
|
||||
load()
|
||||
} catch (err) {
|
||||
ElMessage.error(err?.response?.data?.message || err?.message || '导入失败')
|
||||
}
|
||||
}
|
||||
async function exportXlsx() {
|
||||
if (!filters.startDate || !filters.endDate) {
|
||||
const r = defaultRange()
|
||||
|
||||
@@ -50,6 +50,9 @@
|
||||
<el-table-column label="创建时间" width="160" align="center">
|
||||
<template #default="{ row }">{{ fmtTime(row.createdAt) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="更新时间" width="160" align="center">
|
||||
<template #default="{ row }">{{ fmtTime(row.updatedAt) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="130" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<div style="display:flex;align-items:center;justify-content:center;gap:8px">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<el-card>
|
||||
<el-alert type="info" :closable="false" style="margin-bottom:12px"
|
||||
title="工位数以数据库为准。本页可新增工位与编辑;每个工位在下方下拉选择启用的工艺即完成绑定;一个工位只能绑定一个工艺;内置工位不允许删除。" />
|
||||
title="工位数以数据库为准。新增/停用/绑定工艺在此完成;虚拟工位(线下位)可在「工位名称」列直接点选重命名;内置工位名称锁定不可改、不可删除。" />
|
||||
|
||||
<div style="margin-bottom:12px">
|
||||
<el-button v-if="can('produce.station:add')" type="primary" @click="openAdd">新增工位</el-button>
|
||||
@@ -33,7 +33,15 @@
|
||||
|
||||
<el-table :data="rows" border size="small">
|
||||
<el-table-column prop="stationNo" label="工位号" width="90" align="center" />
|
||||
<el-table-column prop="name" label="工位名称" min-width="170" show-overflow-tooltip />
|
||||
<el-table-column label="工位名称" min-width="170">
|
||||
<template #default="{ row }">
|
||||
<el-input v-if="row.stationType === 'OFFLINE' && renamingId === row.id" v-model="renameVal" size="small"
|
||||
@blur="commitRename(row)" @keyup.enter="commitRename(row)" />
|
||||
<span v-else-if="row.stationType === 'OFFLINE'" style="cursor:pointer;color:#409eff"
|
||||
@click="startRename(row)">{{ row.name }} ✎</span>
|
||||
<span v-else>{{ row.name }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="类型" width="90" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag size="small" :type="row.stationType === 'OFFLINE' ? 'info' : 'success'">
|
||||
@@ -89,7 +97,7 @@
|
||||
<el-table-column label="操作" width="120" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<div style="display:flex;align-items:center;justify-content:center;gap:8px">
|
||||
<el-button v-if="can('produce.station:edit')" link type="primary" size="small" @click="openName(row)">编辑</el-button>
|
||||
<el-button v-if="can('produce.station:edit') && !row.isBuiltin && row.stationType !== 'OFFLINE'" link type="primary" size="small" @click="openName(row)">编辑</el-button>
|
||||
<el-dropdown trigger="click" @command="(c) => stationCommand(row, c)">
|
||||
<el-button link type="primary" size="small">更多 ▾</el-button>
|
||||
<template #dropdown>
|
||||
@@ -265,6 +273,33 @@ function openName(row) {
|
||||
Object.assign(dlg, { show: true, isAdd: false, title: `工位${row.stationNo} - 修改`, id: row.id, stationNo: row.stationNo, name: row.name, stationType: row.stationType || 'LINE', isBuiltin: !!row.isBuiltin })
|
||||
}
|
||||
|
||||
// 虚拟工位(线下位)行内重命名:点名称旁 ✎ 进入编辑,失焦或回车提交
|
||||
const renamingId = ref(0)
|
||||
const renameVal = ref('')
|
||||
function startRename(row) {
|
||||
renamingId.value = row.id
|
||||
renameVal.value = row.name
|
||||
}
|
||||
async function commitRename(row) {
|
||||
if (renamingId.value !== row.id) return
|
||||
const v = (renameVal.value || '').trim()
|
||||
renamingId.value = 0
|
||||
if (!v) {
|
||||
ElMessage.warning('名称不能为空')
|
||||
await load()
|
||||
return
|
||||
}
|
||||
if (v === row.name) return
|
||||
try {
|
||||
await request.post('/stations', { id: row.id, stationNo: row.stationNo, name: v, stationType: row.stationType || 'LINE' })
|
||||
ElMessage.success('名称已更新')
|
||||
} catch {
|
||||
// 拦截器已提示
|
||||
} finally {
|
||||
await load()
|
||||
}
|
||||
}
|
||||
|
||||
async function save() {
|
||||
if (!dlg.name) return ElMessage.warning('请输入工位名称')
|
||||
if (dlg.isAdd && dlg.stationNo >= 1 && dlg.stationNo <= 12) {
|
||||
|
||||
@@ -133,7 +133,7 @@
|
||||
<template #default="{row}">{{ fmt(row.createdAt) }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-divider content-position="left">物料组成(递归展开成品零部件到原材料)</el-divider>
|
||||
<el-divider content-position="left">物料组成(按工艺物料清单平铺一层)</el-divider>
|
||||
<el-table :data="flatBom" border size="small" row-key="_key" default-expand-all>
|
||||
<el-table-column label="物料" min-width="180">
|
||||
<template #default="{row}">
|
||||
@@ -277,19 +277,10 @@ async function exportTorque() {
|
||||
exporting.value = false
|
||||
}
|
||||
}
|
||||
// 把递归的物料组成树扁平化为带层级缩进的列表,避免 el-table 树形 row-key 冲突
|
||||
const flatBom = computed(() => {
|
||||
const out = []
|
||||
const walk = (nodes, depth, prefix) => {
|
||||
;(nodes || []).forEach((n, i) => {
|
||||
const key = prefix + '-' + n.materialCode + '-' + i
|
||||
out.push(Object.assign({}, n, { _depth: depth, _key: key }))
|
||||
if (n.children && n.children.length) walk(n.children, depth + 1, key)
|
||||
})
|
||||
}
|
||||
walk(data.value?.bindTrace?.bomTree || [], 0, 'r')
|
||||
return out
|
||||
})
|
||||
// 装机物料明细(后端已按工艺物料清单平铺一层,无多级树;直接映射为表格行,_depth 恒为 0)
|
||||
const flatBom = computed(() =>
|
||||
(data.value?.bindTrace?.bomTree || []).map((n, i) => Object.assign({}, n, { _depth: 0, _key: 'r-' + n.materialCode + '-' + i }))
|
||||
)
|
||||
// 工件六态生命周期映射(2026-10-19:与 WorkOrder.vue pieceStatusMap 统一口径;
|
||||
// 原映射照抄工单状态,NEW/PROCESSING/SEMI_STORED 无中文显示英文,ONLINE 误作"生产中")
|
||||
const WORKPIECE_STATUS_MAP = { NEW: '待上线', ONLINE: '已上线', PROCESSING: '在制', SEMI_STORED: '半成品入库', DONE: '完工', SCRAPPED: '报废' }
|
||||
|
||||
Reference in New Issue
Block a user