feat: 新增预警与附件模块,优化工位派工功能

1. 新增预警规则、预警消息、业务附件数据库表与CRUD逻辑
2. 为拧紧记录添加审核人、审核时间字段及审核留痕功能
3. 优化产线点位类型与编号描述,更新工位组合下发菜单名称为工艺路线派工
4. 新增上传文件获取原文件名与大小的工具方法
5. 在系统管理菜单新增预警中心与附件中心入口
This commit is contained in:
SunYF
2026-09-14 16:31:08 +08:00
parent 0ab21b1234
commit 5c3b747a20
399 changed files with 147674 additions and 2213 deletions
@@ -0,0 +1,95 @@
<template>
<el-card>
<el-form inline style="margin-bottom:12px">
<el-form-item label="业务类型">
<el-select v-model="form.bizType" style="width:160px">
<el-option label="工单" value="work_order" />
<el-option label="物料" value="material" />
<el-option label="工艺流程" value="process_flow" />
<el-option label="检验" value="inspection" />
</el-select>
</el-form-item>
<el-form-item label="业务ID">
<el-input v-model="form.bizId" placeholder="如 工单号 / 物料编码" style="width:220px" />
</el-form-item>
<el-form-item>
<el-upload action="#" :show-file-list="false" :http-request="doUpload">
<el-button type="primary">选择文件上传</el-button>
</el-upload>
</el-form-item>
<el-form-item><el-button @click="load">查询</el-button></el-form-item>
</el-form>
<el-table :data="list" border size="small">
<el-table-column prop="fileName" label="文件名" min-width="180" />
<el-table-column prop="fileSize" label="大小" width="110">
<template #default="{row}">{{ fmtSize(row.fileSize) }}</template>
</el-table-column>
<el-table-column prop="bizType" label="业务类型" width="120" />
<el-table-column prop="bizId" label="业务ID" width="140" />
<el-table-column prop="uploader" label="上传人" width="100" />
<el-table-column prop="createdAt" label="上传时间" min-width="170" />
<el-table-column label="操作" width="160" fixed="right">
<template #default="{row}">
<el-button size="small" type="primary" @click="download(row)">下载</el-button>
<el-button size="small" type="danger" @click="remove(row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-card>
</template>
<script setup>
import { reactive, ref, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import request from '../utils/request'
import { getToken } from '../utils/auth'
const form = reactive({ bizType: 'work_order', bizId: '' })
const list = ref([])
async function load() {
list.value = (await request.get('/attachments', { params: { bizType: form.bizType, bizId: form.bizId } })) || []
}
function fmtSize(n) {
n = n || 0
if (n < 1024) return n + ' B'
if (n < 1024 * 1024) return (n / 1024).toFixed(1) + ' KB'
return (n / 1024 / 1024).toFixed(1) + ' MB'
}
async function doUpload(option) {
if (!form.bizId) {
ElMessage.warning('请先填写业务ID再上传')
return
}
const fd = new FormData()
fd.append('file', option.file)
fd.append('bizType', form.bizType)
fd.append('bizId', form.bizId)
try {
await request.post('/attachment/upload', fd)
ElMessage.success('上传成功')
if (option.onSuccess) option.onSuccess()
load()
} catch (e) {
if (option.onError) option.onError(e)
}
}
async function download(row) {
const token = getToken()
const resp = await fetch('/api/v1/attachment/download?name=' + encodeURIComponent(row.filePath), { headers: { Authorization: 'Bearer ' + token } })
if (!resp.ok) { ElMessage.error('下载失败'); return }
const blob = await resp.blob()
const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = row.fileName || 'file'
a.click()
URL.revokeObjectURL(url)
}
async function remove(row) {
await ElMessageBox.confirm('确认删除该附件?', '提示', { type: 'warning' })
await request.post('/attachment/delete', { id: row.id })
ElMessage.success('已删除')
load()
}
onMounted(load)
</script>