feat: 完成客户第12条需求+多系统改造

1. 新增预警表添加工单号字段,支持按工单号检索预警
2. 添加工单过滤在制品/绩效报表/预警中心查询
3. 补全WMS台账字段口径与权限配置
4. 修复备料单与数量不符处理流程
5. 新增配送进度/库位联动/自动出库功能
6. 修复AGV配送状态更新逻辑
7. 优化退料与库存管理细节
This commit is contained in:
SunYF
2026-09-19 17:04:58 +08:00
parent 62e45b7379
commit 05b0b8a909
89 changed files with 7912 additions and 429 deletions
@@ -14,6 +14,9 @@
<el-option v-for="t in types" :key="t.value" :label="t.label" :value="t.value" />
</el-select>
</el-form-item>
<el-form-item label="工单号">
<el-input v-model="orderNo" clearable style="width:170px" placeholder="工单号(模糊)" @keyup.enter="search" />
</el-form-item>
<el-form-item label="开始时间">
<el-date-picker v-model="startDate" type="date" value-format="YYYY-MM-DD" placeholder="开始时间" style="width:150px" />
</el-form-item>
@@ -39,6 +42,9 @@
<template #default="{row}">{{ typeLabel(row.type) }}</template>
</el-table-column>
<el-table-column prop="title" label="标题" min-width="140" />
<el-table-column prop="orderNo" label="工单号" width="130">
<template #default="{row}">{{ row.orderNo || '-' }}</template>
</el-table-column>
<el-table-column prop="content" label="内容" min-width="200" show-overflow-tooltip />
<el-table-column prop="refId" label="关联ID" width="120" />
<el-table-column prop="createdAt" label="时间" min-width="170">
@@ -70,6 +76,7 @@ const loading = ref(false)
const unread = ref(0)
const statusFilter = ref('all')
const typeFilter = ref('')
const orderNo = ref('')
const startDate = ref(todayStr()) // 开始时间默认当天
const endDate = ref('') // 结束时间默认空
@@ -108,6 +115,7 @@ async function loadAlerts() {
const params = {
status: statusFilter.value === 'all' ? '' : statusFilter.value,
type: typeFilter.value,
orderNo: orderNo.value.trim(),
from: startDate.value,
to: endDate.value,
page: page.value,
@@ -129,6 +137,7 @@ function search() {
function reset() {
statusFilter.value = 'all'
typeFilter.value = ''
orderNo.value = ''
startDate.value = todayStr()
endDate.value = ''
page.value = 1
@@ -8,8 +8,8 @@
<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'" link type="danger" style="margin-left:8px"
@click="doArchive">立即归档清理</el-button>
<el-button v-if="disk.level === 'critical' && can('sys.attachment:manage')" link type="danger"
style="margin-left:8px" @click="doArchive">立即归档清理</el-button>
</div>
</template>
</el-alert>
@@ -42,7 +42,8 @@
<el-form-item>
<el-button type="primary" :loading="loading" @click="search">查询</el-button>
<el-button @click="resetFilters">重置</el-button>
<el-button type="warning" plain :loading="archiving" @click="doArchive">归档清理</el-button>
<el-button v-if="can('sys.attachment:manage')" type="warning" plain :loading="archiving"
@click="doArchive">归档清理</el-button>
</el-form-item>
</el-form>
@@ -84,7 +85,8 @@
<template #default="{ row }">
<el-button link type="primary" size="small" @click="preview(row)">预览</el-button>
<el-button link type="success" size="small" @click="download(row)">下载</el-button>
<el-button v-if="!row.deleted" link type="danger" size="small" @click="remove(row)">删除</el-button>
<el-button v-if="!row.deleted && can('sys.attachment:manage')" link type="danger" size="small"
@click="remove(row)">删除</el-button>
</template>
</el-table-column>
</el-table>
@@ -103,6 +105,7 @@ 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'
@@ -12,10 +12,16 @@
<el-form-item label="物料名称"><el-input v-model="query.materialName" clearable style="width:150px" @keyup.enter="load" /></el-form-item>
<el-form-item label="接驳台"><el-input v-model="query.targetDock" clearable style="width:120px" placeholder="如 DOCK05" @keyup.enter="load" /></el-form-item>
<el-form-item label="工位"><el-input v-model="query.stationNo" clearable style="width:90px" placeholder="如 3" @keyup.enter="load" /></el-form-item>
<el-form-item label="来源">
<el-select v-model="query.source" clearable placeholder="全部" style="width:120px">
<el-option label="排产备料" value="PLAN" />
<el-option label="工位补料" value="REFILL" />
</el-select>
</el-form-item>
<el-form-item label="状态">
<el-select v-model="query.status" clearable placeholder="全部" style="width:130px">
<el-option label="待备料" value="PENDING" />
<el-option label="已锁定" value="LOCKED" />
<el-option label="已备料(已出库)" value="LOCKED" />
<el-option label="配送中" value="DELIVERING" />
<el-option label="已接料完结" value="DONE" />
</el-select>
@@ -23,6 +29,8 @@
<el-form-item>
<el-button type="primary" @click="load">查询</el-button>
<el-button v-if="can('produce.material:generate')" type="success" @click="generate">按日排产生成备料</el-button>
<el-button v-if="can('produce.material:outbound')" type="warning" plain :loading="autoing" @click="autoOutbound">一键自动出库</el-button>
<el-button type="info" plain :loading="progressing" @click="showProgress">物料去向对账</el-button>
</el-form-item>
</el-form>
@@ -30,6 +38,12 @@
<el-table-column prop="requestNo" label="备料单号" min-width="180" />
<el-table-column prop="orderNo" label="工单号" min-width="130" />
<el-table-column prop="planDate" label="排产日期" width="110" />
<el-table-column label="来源" width="95" align="center">
<template #default="{row}">
<el-tag v-if="row.source === 'REFILL'" type="danger" size="small">工位补料</el-tag>
<el-tag v-else type="info" size="small">排产备料</el-tag>
</template>
</el-table-column>
<el-table-column prop="materialCode" label="图号" min-width="110" />
<el-table-column prop="materialName" label="物料名称" min-width="110" show-overflow-tooltip />
<el-table-column prop="unit" label="单位" width="70" />
@@ -41,9 +55,12 @@
<el-table-column prop="targetDock" label="接驳台" width="100" align="center" />
<el-table-column prop="batchNo" label="批次" width="120" align="center" show-overflow-tooltip />
<el-table-column prop="reqQty" label="需求数量" width="90" align="center" />
<el-table-column label="已接料" width="90" align="center">
<el-table-column label="已发出" width="90" align="center">
<template #default="{row}">{{ fmtQty(row.sentQty) }}</template>
</el-table-column>
<el-table-column label="已接料" width="90" align="center">
<template #default="{row}">{{ fmtQty(row.receivedQty) }}</template>
</el-table-column>
<el-table-column label="分批进度" min-width="150">
<template #default="{row}">
<el-progress :percentage="progressPct(row)" :status="row.status === 'DONE' ? 'success' : ''" />
@@ -60,6 +77,79 @@
<el-table-column prop="operator" label="操作人" width="90" />
</el-table>
</el-card>
<el-dialog v-model="progressVisible" title="物料去向对账(在库 / 在途 / 线边 / 已消耗)" width="1060px" top="5vh">
<el-table :data="progressRows" border size="small" max-height="560" row-key="rowKey" @expand-change="onExpandRow">
<el-table-column type="expand">
<template #default="{ row }">
<div style="padding:8px 16px">
<div style="font-weight:600;margin-bottom:6px">接料明细(按备料单,{{ row.orderNo }} / {{ row.materialCode }})</div>
<el-table v-if="expandMap[row.rowKey]?.loaded" :data="expandMap[row.rowKey]?.receives || []" border size="small" max-height="220">
<el-table-column prop="requestNo" label="备料单号" min-width="180" />
<el-table-column label="来源" width="95" align="center">
<template #default="{ row: r }">
<el-tag v-if="r.source === 'REFILL'" type="danger" size="small">工位补料</el-tag>
<el-tag v-else type="info" size="small">排产备料</el-tag>
</template>
</el-table-column>
<el-table-column prop="stationNo" label="工位" width="70" align="center" />
<el-table-column prop="processCode" label="工序" width="70" align="center" />
<el-table-column label="已发出" width="85" align="center">
<template #default="{ row: r }">{{ fmtQty(r.sentQty) }}</template>
</el-table-column>
<el-table-column label="已接料" width="85" align="center">
<template #default="{ row: r }">{{ fmtQty(r.receivedQty) }}</template>
</el-table-column>
<el-table-column prop="status" label="状态" width="100">
<template #default="{ row: r }">{{ statusText(r.status) }}</template>
</el-table-column>
<el-table-column prop="operator" label="接料确认人" width="100" />
</el-table>
<div v-else style="color:#909399;font-size:12px;padding:6px 0">加载中…</div>
<div style="color:#909399;font-size:12px;margin-top:8px">
消耗明细:已消耗量由 WMS 报工反冲核销(台账「已消耗」列),按工序合计的留痕在 WMS 操作日志按工单号查询;出库明细与超领原因在 WMS「出库管理」按工单号查询——本页不做跨系统重复建设。
</div>
</div>
</template>
</el-table-column>
<el-table-column prop="orderNo" label="工单号" min-width="130" />
<el-table-column prop="materialCode" label="图号" min-width="110" />
<el-table-column prop="materialName" label="物料名称" min-width="110" show-overflow-tooltip />
<el-table-column prop="targetStation" label="目标工位" width="80" align="center" />
<el-table-column prop="totalQty" label="需求" width="70" align="center" />
<el-table-column prop="outQty" label="已发出" width="75" align="center" />
<el-table-column prop="returnedQty" label="已退回" width="75" align="center" />
<el-table-column prop="receivedQty" label="已接料" width="75" align="center" />
<el-table-column prop="consumedQty" label="已消耗" width="75" align="center" />
<el-table-column label="在途" width="70" align="center">
<template #default="{row}"><span :style="row.inTransit > 0 ? 'color:#E6A23C;font-weight:600' : ''">{{ row.inTransit }}</span></template>
</el-table-column>
<el-table-column label="工位余" width="70" align="center">
<template #default="{row}"><span :style="lineSideOf(row) > 0 ? 'color:#E6A23C;font-weight:600' : ''">{{ lineSideOf(row) }}</span></template>
</el-table-column>
<el-table-column prop="gap" label="待发缺口" width="85" align="center">
<template #default="{row}">
<el-tag v-if="row.gap > 0" type="danger" size="small">{{ row.gap }}</el-tag>
<span v-else>0</span>
</template>
</el-table-column>
<el-table-column label="对账状态" width="100" align="center" fixed="right">
<template #default="{ row }">
<el-tooltip :content="anomalyTip(row)" placement="top">
<el-tag :type="anomalyOf(row).type" size="small">{{ anomalyOf(row).label }}</el-tag>
</el-tooltip>
</template>
</el-table-column>
</el-table>
<div style="color:#909399;font-size:12px;margin-top:8px">
口径:净领用 = 已发出 − 已退回;在途 = 已发出 − 已接料;工位余 = 已接料 − 已消耗 − 已退回;恒等式:入库总量 = 在库 + 在途 + 工位余 + 已消耗 + 退库回仓 + 盘点差异。
异常判定只标三类硬异常:<b>超领</b>(净领用 &gt; 需求)、<b>完结剩料</b>(台账领料完结但工位仍压料)、<b>在途等待</b>(已发出未接料,含已送达未扫码);生产中的待发缺口属正常状态,不标色。
</div>
<div style="margin-top:10px;text-align:right">
<el-button size="small" @click="exportLedgerCsv">导出 CSV</el-button>
</div>
</el-dialog>
<PageHelp :data="helpMaterial" page="MaterialRequest" />
</template>
@@ -71,22 +161,102 @@ import { can } from '../utils/perm'
import PageHelp from '../components/PageHelp.vue'
import { helpMaterial } from '../help'
const query = reactive({ planDate: '', orderNo: '', status: '', materialCode: '', materialName: '', targetDock: '', stationNo: '' })
const query = reactive({ planDate: '', orderNo: '', status: '', materialCode: '', materialName: '', targetDock: '', stationNo: '', source: '' })
const list = ref([])
const receiving = ref(false)
const receivingNo = ref('')
const autoing = ref(false)
const progressing = ref(false)
const progressVisible = ref(false)
const progressRows = ref([])
const statusText = (s) => (s === 'PENDING' ? '待备料' : s === 'LOCKED' ? '已锁定' : s === 'DELIVERING' ? '配送中' : s === 'DONE' ? '已接料完结' : s)
const statusText = (s) => (s === 'PENDING' ? '待备料' : s === 'LOCKED' ? '已备料(已出库)' : s === 'DELIVERING' ? '配送中' : s === 'DONE' ? '已接料完结' : s)
function fmtQty(v) {
const n = Number(v || 0)
return Number.isInteger(n) ? String(n) : n.toFixed(2)
}
// 进度按「已接料」计算:接料才是工位真正拿到料的节点(已发出只代表仓库发了)
function progressPct(row) {
const req = Number(row.reqQty || 0)
const sent = Number(row.sentQty || 0)
const got = Number(row.receivedQty || 0)
if (req <= 0) return 0
return Math.min(100, Math.round((sent / req) * 100))
return Math.min(100, Math.round((got / req) * 100))
}
// ============ 物料去向对账(只读,后端 progress 接口 + 前端现算,不新增账本) ============
// 口径:净领用 netOut = 已发出 − 已退回;在途 = 已发出 − 已接料;工位余 = 已接料 − 已消耗 − 已退回。
// 异常判定只标三类硬异常(生产中的待发缺口属正常状态,不标色):
// 超领:净领用 > 需求(超领原因在 WMS 出库单留痕,可查)
// 完结剩料:台账「领料完结」但工位仍压料(没耗也没退)
// 在途等待:已发出未接料(含已送达未扫码;是否已送达需 WMS 出库单状态,本页不跨系统拉取)
const expandMap = reactive({})
function lineSideOf(row) {
return Number(row.receivedQty || 0) - Number(row.consumedQty || 0) - Number(row.returnedQty || 0)
}
function anomalyOf(row) {
const netOut = Number(row.netOut ?? (Number(row.outQty || 0) - Number(row.returnedQty || 0)))
if (netOut > Number(row.totalQty || 0)) return { key: 'over', label: '超领', type: 'danger' }
if (row.status === '领料完结' && lineSideOf(row) > 0) return { key: 'left', label: '完结剩料', type: 'warning' }
if (Number(row.inTransit || 0) > 0) return { key: 'transit', label: '在途等待', type: 'warning' }
return { key: 'ok', label: '正常', type: 'success' }
}
function anomalyTip(row) {
const a = anomalyOf(row)
if (a.key === 'over') return '净领用超过工单需求:请到 WMS「出库管理」按工单号查超领原因与明细'
if (a.key === 'left') return '台账已领料完结,但工位仍压料未消耗也未退回:请催报工或发起退料'
if (a.key === 'transit') return '已发出尚未接料(含已送达未扫码):请到 WMS「出库管理」看是否已送达,或催工位扫码接料'
return '在库 / 在途 / 线边 / 已消耗均在正常区间'
}
// 展开行:懒加载该工单+图号的接料明细(备料单行即接料台账,含实收与确认人)
async function onExpandRow(row, expandedRows) {
const key = row.rowKey
if (!expandedRows.some((r) => r.rowKey === key) || expandMap[key]?.loaded) return
expandMap[key] = { loaded: false, receives: [] }
try {
const reqs = (await request.get('/material-requests', { params: { orderNo: row.orderNo } })) || []
const receives = reqs.filter((r) => r.materialCode === row.materialCode)
expandMap[key] = { loaded: true, receives }
} catch {
expandMap[key] = { loaded: true, receives: [] }
}
}
// 导出 CSV(带 BOM,Excel 直接打开中文不乱码;MES 前端无 xlsx 库,纯前端导出)
function exportLedgerCsv() {
const header = ['工单号', '图号', '物料名称', '目标工位', '需求', '已发出', '已退回', '已接料', '已消耗', '在途', '工位余', '待发缺口', '对账状态', '台账状态']
const lines = [header.join(',')]
for (const r of progressRows.value) {
const cells = [
r.orderNo, r.materialCode, r.materialName, r.targetStation,
r.totalQty, r.outQty, r.returnedQty, r.receivedQty, r.consumedQty,
r.inTransit, lineSideOf(r), r.gap, anomalyOf(r).label, r.status
]
lines.push(cells.map((c) => '"' + String(c ?? '').replace(/"/g, '""') + '"').join(','))
}
const blob = new Blob(['\ufeff' + lines.join('\r\n')], { type: 'text/csv;charset=utf-8' })
const a = document.createElement('a')
a.href = URL.createObjectURL(blob)
a.download = '物料去向对账.csv'
a.click()
URL.revokeObjectURL(a.href)
}
// 配送进度:WMS 台账(已发出/已退回/已消耗/缺口)+ 本系统已接料 → 在途/线边
async function showProgress() {
progressing.value = true
try {
const data = await request.get('/material-requests/progress', {
params: { orderNo: query.orderNo, materialCode: query.materialCode, page: 1, pageSize: 100 }
})
progressRows.value = (data?.list || []).map((r) => ({ ...r, rowKey: r.orderNo + '|' + r.materialCode }))
progressVisible.value = true
} catch {
// 拦截器已提示
}
progressing.value = false
}
async function load() {
@@ -129,8 +299,38 @@ async function generate() {
ElMessage.success(`已生成 ${data?.count || 0} 条备料`)
load()
}
// 一键自动出库:按排产日(或指定工单)把未出齐的备料单从 WMS 合格库存 FIFO 自动领料。
// 日常「按日排产生成备料」已自动执行本动作,此处用于库存补齐后的补出。
async function autoOutbound() {
if (!query.planDate && !query.orderNo) return ElMessage.warning('请先选择排产日期或填写工单号')
try {
await ElMessageBox.confirm(
`将对 ${query.orderNo ? '工单 ' + query.orderNo : '排产日期 ' + query.planDate} 下未出齐的备料单,按 FIFO 从 WMS 合格库存自动领料出库。确认继续?`,
'一键自动出库', { type: 'warning' })
} catch {
return
}
autoing.value = true
try {
const data = await request.post('/material-requests/auto-outbound', {
planDate: query.planDate, orderNo: query.orderNo
})
const short = data?.short || []
if (short.length) {
await ElMessageBox.alert(
`已出库达标 ${data?.done || 0} 条;以下仍未出齐(库存不足,等补货后可再次执行):\n\n${short.join('\n')}`,
'自动出库结果', { type: 'warning', confirmButtonText: '知道了' })
} else {
ElMessage.success(`自动出库完成:${data?.done || 0} 条已备料`)
}
load()
} catch {
// 拦截器已提示
}
autoing.value = false
}
onMounted(() => {
query.planDate = new Date().toISOString().slice(0, 10)
load()
})
</script>
})</script>
@@ -9,6 +9,9 @@
<el-option v-for="i in stationNos" :key="i" :label="`工位${i}`" :value="String(i)" />
</el-select>
</el-form-item>
<el-form-item label="工单号">
<el-input v-model="query.orderNo" placeholder="工单号(模糊)" clearable style="width:180px" @keyup.enter="load" />
</el-form-item>
<el-form-item label="日期范围">
<el-date-picker
v-model="query.range"
@@ -153,7 +156,7 @@ import request from '../utils/request'
const activeTab = ref('byOperator')
const pageSize = ref(20)
const stationNos = ref([])
const query = reactive({ operator: '', stationNo: '', range: null })
const query = reactive({ operator: '', stationNo: '', orderNo: '', range: null })
const views = reactive({
byOperator: { total: 0, page: 1, list: [] },
byStation: { total: 0, page: 1, list: [] },
@@ -213,6 +216,7 @@ async function load() {
const params = {
operator: query.operator || '',
stationNo: query.stationNo || '',
orderNo: query.orderNo.trim(),
from: from || '',
to: to || '',
opPage: views.byOperator.page, opPageSize: pageSize.value,
@@ -232,6 +236,7 @@ async function exportXlsx() {
const [from, to] = query.range || []
const params = {
operator: query.operator || '', stationNo: query.stationNo || '',
orderNo: query.orderNo.trim(),
startDate: from || '', endDate: to || ''
}
const blob = await request.get('/performance/export', { params, responseType: 'blob' })
@@ -0,0 +1,189 @@
<template>
<el-card>
<el-alert type="info" :closable="false" style="margin-bottom:12px"
title="数量不符处理:工位终端接料时发现「实收 ≠ 应发」后上报,差异单汇总到本页。仓管/班组长按差异方向处理——少发走「补发」(自动生成补料单并叫 AGV)、多发走「退库」(生成退库单,WMS 确认后库存加回)、少量差异可「调整关闭」(不补不退,必须填说明)。" />
<el-row :gutter="12" style="margin-bottom:12px">
<el-col :span="6">
<el-card shadow="never" class="stat"><div class="stat-num warn">{{ stats.pending }}</div><div class="stat-label">待处理</div></el-card>
</el-col>
<el-col :span="6">
<el-card shadow="never" class="stat"><div class="stat-num ok">{{ stats.replenished }}</div><div class="stat-label">已补发</div></el-card>
</el-col>
<el-col :span="6">
<el-card shadow="never" class="stat"><div class="stat-num info">{{ stats.returned }}</div><div class="stat-label">已退库</div></el-card>
</el-col>
<el-col :span="6">
<el-card shadow="never" class="stat"><div class="stat-num">{{ stats.closed }}</div><div class="stat-label">已关闭</div></el-card>
</el-col>
</el-row>
<el-form inline>
<el-form-item label="状态">
<el-select v-model="query.status" clearable placeholder="全部" style="width:130px">
<el-option label="待处理" value="PENDING" />
<el-option label="已补发" value="REPLENISHED" />
<el-option label="已退库" value="RETURNED" />
<el-option label="已关闭" value="CLOSED" />
</el-select>
</el-form-item>
<el-form-item label="工位"><el-input v-model="query.stationNo" clearable style="width:90px" placeholder="如 3" @keyup.enter="search" /></el-form-item>
<el-form-item label="工单号"><el-input v-model="query.orderNo" clearable style="width:150px" @keyup.enter="search" /></el-form-item>
<el-form-item label="图号"><el-input v-model="query.materialCode" clearable style="width:150px" placeholder="不区分大小写" @keyup.enter="search" /></el-form-item>
<el-form-item>
<el-button type="primary" @click="search">查询</el-button>
<el-button @click="reset">重置</el-button>
</el-form-item>
</el-form>
<el-table :data="list" border size="small" v-loading="loading">
<el-table-column prop="reportNo" label="差异单号" width="100" />
<el-table-column prop="stationNo" label="工位" width="70" align="center" />
<el-table-column prop="orderNo" label="工单号" min-width="130" show-overflow-tooltip />
<el-table-column prop="materialCode" label="图号" min-width="110" show-overflow-tooltip />
<el-table-column prop="materialName" label="物料名称" min-width="110" show-overflow-tooltip />
<el-table-column prop="sn" label="序列号" min-width="120" show-overflow-tooltip />
<el-table-column prop="planQty" label="应发" width="70" align="center" />
<el-table-column prop="actualQty" label="实收" width="70" align="center" />
<el-table-column label="差异" width="80" align="center">
<template #default="{row}">
<span :class="row.diffQty > 0 ? 'diff-short' : row.diffQty < 0 ? 'diff-over' : ''">
{{ row.diffQty > 0 ? '少 ' + row.diffQty : row.diffQty < 0 ? '多 ' + (-row.diffQty) : '-' }}
</span>
</template>
</el-table-column>
<el-table-column prop="cause" label="上报原因" min-width="130" show-overflow-tooltip />
<el-table-column label="上报时间" width="150">
<template #default="{row}">{{ fmtTime(row.createdAt) }}</template>
</el-table-column>
<el-table-column prop="operator" label="上报人" width="90" />
<el-table-column label="状态" width="90">
<template #default="{row}">
<el-tag :type="statusTag(row.status)" size="small">{{ statusText(row.status) }}</el-tag>
</template>
</el-table-column>
<el-table-column label="处理方式" width="90">
<template #default="{row}">{{ handleText(row.handleType) }}</template>
</el-table-column>
<el-table-column prop="handleDocNo" label="处理单据" min-width="170" show-overflow-tooltip />
<el-table-column prop="handleNote" label="处理说明" min-width="150" show-overflow-tooltip />
<el-table-column prop="handledBy" label="处理人" width="90" />
<el-table-column label="处理时间" width="150">
<template #default="{row}">{{ row.handledAt ? fmtTime(row.handledAt) : '-' }}</template>
</el-table-column>
<el-table-column label="操作" width="210" fixed="right" align="center">
<template #default="{row}">
<template v-if="isPending(row.status) && can('produce.qty:handle')">
<el-button size="small" type="success" :disabled="row.diffQty <= 0" @click="doHandle(row, 'REPLENISH')">补发</el-button>
<el-button size="small" type="warning" :disabled="row.diffQty >= 0" @click="doHandle(row, 'RETURN')">退库</el-button>
<el-button size="small" @click="doHandle(row, 'ADJUST')">调整</el-button>
</template>
<span v-else class="muted">{{ isPending(row.status) ? '无处理权限' : '已处理' }}</span>
</template>
</el-table-column>
</el-table>
<el-pagination style="margin-top:12px; justify-content:flex-end"
background layout="total, sizes, prev, pager, next"
:total="total" :current-page="query.page" :page-size="query.pageSize"
:page-sizes="[20, 50, 100]" @current-change="onPage" @size-change="onSize" />
</el-card>
<PageHelp :data="helpQtyReport" page="QtyReport" />
</template>
<script setup>
import { reactive, ref, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import request from '../utils/request'
import { can } from '../utils/perm'
import { fmtTime } from '../utils/format'
import PageHelp from '../components/PageHelp.vue'
import { helpQtyReport } from '../help'
const query = reactive({ status: '', stationNo: '', orderNo: '', materialCode: '', page: 1, pageSize: 20 })
const list = ref([])
const total = ref(0)
const loading = ref(false)
const stats = reactive({ pending: 0, replenished: 0, returned: 0, closed: 0 })
const statusText = (s) => ({ PENDING: '待处理', PROCESSING: '处理中', REPLENISHED: '已补发', RETURNED: '已退库', ADJUSTED: '已关闭', CLOSED: '已关闭', RESOLVED: '已关闭' }[s] || s)
const statusTag = (s) => (s === 'PENDING' || s === 'PROCESSING' ? 'warning' : s === 'REPLENISHED' ? 'success' : s === 'RETURNED' ? 'primary' : 'info')
const handleText = (t) => ({ REPLENISH: '补发', RETURN: '退库', ADJUST: '调整关闭' }[t] || '-')
const isPending = (s) => s === 'PENDING' || s === 'PROCESSING'
async function load() {
loading.value = true
try {
const data = await request.get('/qty-reports', { params: query })
list.value = data?.list || []
total.value = data?.total || 0
} catch {
// 拦截器已提示
}
loading.value = false
}
async function loadStats() {
try {
const data = await request.get('/qty-reports/stats')
Object.assign(stats, data || {})
} catch {
// 统计失败不影响列表
}
}
function search() { query.page = 1; load() }
function reset() {
Object.assign(query, { status: '', stationNo: '', orderNo: '', materialCode: '', page: 1 })
load()
}
function onPage(p) { query.page = p; load() }
function onSize(s) { query.pageSize = s; query.page = 1; load() }
// 处理差异:补发(少发)/ 退库(多发)/ 调整关闭(不补不退,必须填说明)
async function doHandle(row, type) {
if (type === 'REPLENISH' && row.diffQty <= 0) return ElMessage.warning('本单为「多发」,不能补发;请选择退库或调整')
if (type === 'RETURN' && row.diffQty >= 0) return ElMessage.warning('本单为「少发」,不能退库;请选择补发或调整')
const title = type === 'REPLENISH' ? '补发' : type === 'RETURN' ? '退库' : '调整关闭'
const tip = type === 'REPLENISH'
? `将为「${row.materialCode}」生成补料单(数量 ${row.diffQty}),随后自动出库并叫 AGV 送到工位 ${row.stationNo}。`
: type === 'RETURN'
? `将为「${row.materialCode}」生成退库单(数量 ${-row.diffQty}),WMS 确认收货后库存加回。`
: '调整关闭:不补发也不退库,仅登记双方确认结果(必填说明)。'
let note = ''
try {
const { value } = await ElMessageBox.prompt(tip, title, {
inputPlaceholder: type === 'ADJUST' ? '必填:说明双方确认结果' : '选填:处理说明',
inputValidator: (v) => (type !== 'ADJUST' || (v && v.trim().length > 0)) || '调整关闭必须填写处理说明',
confirmButtonText: '确定处理',
type: 'warning'
})
note = (value || '').trim()
} catch {
return
}
try {
const data = await request.post('/qty-reports/handle', { id: row.id, handleType: type, note })
ElMessage.success(`处理完成:${statusText(data?.status)}${data?.handleDocNo ? '(' + data.handleDocNo + ')' : ''}`)
load()
loadStats()
} catch {
// 拦截器已提示
}
}
onMounted(() => {
load()
loadStats()
})
</script>
<style scoped>
.stat { text-align: center; }
.stat-num { font-size: 22px; font-weight: 600; }
.stat-num.warn { color: #E6A23C; }
.stat-num.ok { color: #67C23A; }
.stat-num.info { color: #409EFF; }
.stat-label { font-size: 12px; color: #909399; margin-top: 4px; }
.diff-short { color: #E6A23C; font-weight: 600; }
.diff-over { color: #F56C6C; font-weight: 600; }
.muted { color: #909399; font-size: 12px; }
</style>
+42 -1
View File
@@ -4,12 +4,32 @@
<el-form-item label="工件SN">
<el-input v-model="sn" style="width:220px" placeholder="输入SN查询追溯" @keyup.enter="search" />
</el-form-item>
<el-form-item label="工单号">
<el-input v-model="orderNo" style="width:200px" placeholder="按工单号列出工件(模糊)" @keyup.enter="searchByOrder" />
</el-form-item>
<el-form-item><el-button type="primary" @click="search">追溯查询</el-button></el-form-item>
<el-form-item><el-button @click="searchByOrder">按工单查询</el-button></el-form-item>
<el-form-item>
<el-button type="warning" :disabled="!sn" @click="printCard">打印流程卡</el-button>
</el-form-item>
</el-form>
<el-card v-if="orderRows.length" shadow="never" style="margin-bottom:12px">
<template #header>工单「{{ orderNo }}」下的工件共 {{ orderRows.length }} 件(点「追溯」查看单个工件)</template>
<el-table :data="orderRows" border size="small" max-height="240">
<el-table-column prop="sn" label="工件SN" min-width="180" show-overflow-tooltip />
<el-table-column label="状态" width="100" align="center">
<template #default="{ row }">{{ statusText(row.status) }}</template>
</el-table-column>
<el-table-column prop="currentProcess" label="当前工位" width="100" align="center" />
<el-table-column label="操作" width="90" align="center">
<template #default="{ row }">
<el-button link type="primary" size="small" @click="pickSn(row.sn)">追溯</el-button>
</template>
</el-table-column>
</el-table>
</el-card>
<el-alert v-if="error" :title="error" type="error" show-icon closable style="margin-bottom:10px" />
<template v-if="data">
@@ -101,16 +121,37 @@
<script setup>
import { ref, computed } from 'vue'
import { ElMessageBox } from 'element-plus'
import { ElMessage, ElMessageBox } from 'element-plus'
import request from '../utils/request'
import { openPrintableHtml } from '../utils/print'
import PageHelp from '../components/PageHelp.vue'
import { helpTrace } from '../help'
const sn = ref('')
const orderNo = ref('')
const orderRows = ref([])
const data = ref(null)
const error = ref('')
// 按工单号列出该工单下的全部工件,点击行内「追溯」查看单个工件生命周期(客户第12条:记录查看加工单号查询)
async function searchByOrder() {
const no = orderNo.value.trim()
if (!no) {
ElMessage.warning('请输入工单号')
return
}
try {
orderRows.value = (await request.get('/workpieces', { params: { orderNo: no } })) || []
if (!orderRows.value.length) ElMessage.info('该工单下暂无工件')
} catch {
orderRows.value = []
}
}
function pickSn(v) {
sn.value = v
search()
}
async function search() {
if (!sn.value) return
error.value = ''
+5
View File
@@ -8,6 +8,9 @@
<el-option label="下线位(虚拟)" :value="13" />
</el-select>
</el-form-item>
<el-form-item label="工单号">
<el-input v-model="orderNo" clearable placeholder="工单号(模糊)" style="width:200px" @keyup.enter="load" />
</el-form-item>
<el-form-item label="状态">
<el-select v-model="statusFilter" clearable placeholder="全部状态" style="width:140px">
<el-option label="已上线" value="ONLINE" />
@@ -74,6 +77,7 @@ import { helpWip } from '../help'
const stations = ref([])
const stationNo = ref('')
const orderNo = ref('')
const statusFilter = ref('')
const list = ref([])
const loading = ref(false)
@@ -106,6 +110,7 @@ async function load() {
try {
const params = {}
if (stationNo.value !== '' && stationNo.value !== null) params.stationNo = stationNo.value
if (orderNo.value.trim()) params.orderNo = orderNo.value.trim()
list.value = (await request.get('/workpieces/in-process', { params })) || []
} finally {
loading.value = false