1. 统一全系统UI与文档中的"物料编码"为客户口径"图号",覆盖前端页面、后端导出表头与帮助文档
2. 优化入库模块:
- 新增归属类型"其他"并完善注释
- 入库时自动回写入库单批次号
- 优化库位选择为三级联动下拉选择,替换原手动输入
- 新增入库归属编号录入功能
3. 更新需求文档,同步完成图号全链路改造的验收标记
96 lines
3.6 KiB
Vue
96 lines
3.6 KiB
Vue
<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>
|