feat: 多系统新增扫码中间件与 AGV 对接,优化拧紧与退库流程

新增扫码中间件支持网络型扫码枪键盘注入,AGV 对接从 WMS 迁至 MES 统一管理;新增拧紧不合格人工处置与 PLC 对账机制,优化退库单关联与工位终端功能,同时清理旧 AGV 任务表,完善数据库与配置项。
This commit is contained in:
SunYF
2026-10-14 17:24:59 +08:00
parent 8e6048c64b
commit f65a52d9e1
170 changed files with 15415 additions and 10572 deletions
@@ -29,6 +29,7 @@
<el-form-item>
<el-button type="primary" :loading="loading" @click="onSearch">查询</el-button>
<el-button @click="onReset">重置</el-button>
<el-button @click="onMismatchCheck" :loading="checking">PLC 对账核对</el-button>
</el-form-item>
</el-form>
@@ -52,7 +53,10 @@
</el-table-column>
<el-table-column label="操作" width="90" fixed="right" align="center">
<template #default="{row}">
<el-button v-if="row.status === 'UNREAD'" size="small" type="primary" link :loading="row._resolving" @click="resolve(row)">标记已读</el-button>
<template v-if="row.status === 'UNREAD'">
<el-button size="small" type="primary" link :loading="row._resolving" @click="resolve(row)">标记已读</el-button>
<el-button v-if="row.type === 'torque_ng'" size="small" type="warning" link :loading="row._disposing" @click="disposeTorque(row)">确认放行</el-button>
</template>
<span v-else style="color:#999">已读</span>
</template>
</el-table-column>
@@ -101,6 +105,7 @@ function levelTag(l) {
const list = ref([])
const total = ref(0)
const loading = ref(false)
const checking = ref(false)
const page = ref(1)
const pageSize = ref(20)
@@ -150,6 +155,24 @@ function onSizeChange() {
page.value = 1
load()
}
// PLC↔MES 对账(#8 T7):管理员手动核对——全量 11 位,命中落预警中心。
async function onMismatchCheck() {
checking.value = true
try {
const data = await request.post('/plc/mismatch/check', { stationNo: 0, trigger: 'manual' })
const items = (data && data.items) || []
if (items.length === 0) {
ElMessage.success('PLC↔MES 对账一致,无不一致项')
} else {
ElMessage.warning(`发现 ${items.length} 个不一致项,已写入预警中心`)
load()
}
} catch (e) {
ElMessage.error(e?.message || '对账核对失败')
} finally {
checking.value = false
}
}
async function resolve(row) {
try {
await ElMessageBox.confirm('确认将该告警标记为已读?', '标记已读', {
@@ -167,6 +190,23 @@ async function resolve(row) {
row._resolving = false
}
}
// B6 拧紧闭环:拧紧不合格预警「确认放行」——质检/班组长处置,清工件标记 + 写 event_log + 置预警 resolved。
async function disposeTorque(row) {
try {
const { value: reason } = await ElMessageBox.prompt('请填写处置原因(确认放行后该工件可继续流转)', '拧紧不合格-确认放行', {
confirmButtonText: '确认放行', cancelButtonText: '取消', inputType: 'textarea',
inputValidator: (v) => (v && v.trim()) ? true : '处置原因必填'
})
row._disposing = true
await request.post('/torque/dispose', { sn: row.refId, reason: reason.trim() })
ElMessage.success('已确认放行')
load()
} catch (e) {
if (e !== 'cancel' && e !== 'close') ElMessage.error(e?.message || '处置失败')
} finally {
row._disposing = false
}
}
onMounted(() => { load() })
</script>
<style scoped>
@@ -1,347 +1,140 @@
<template>
<el-card>
<el-alert type="info" :closable="false" style="margin-bottom:12px"
title="备料单:根据「日排产」自动算出某天要生产的所有工单所需物料。选好排产日期后点「按日排产生成备料」,系统按各产品物料清单(单台用量×计划数量×(1+损耗率))自动汇总生成备料单,仓库据此备料出库。" />
title="叫料单(只读):工位在终端按叫料池发起、仓库在 WMS「叫料队列」完成备料/驳回、退库由工位申请并经仓库确认收回。本页仅查看全部叫料单;数量账(需求/已发/占用/可用)以叫料池为准,随启用状态日排产自动派生。" />
<el-form inline>
<el-form-item label="日期">
<el-date-picker v-model="query.planDate" type="date" value-format="YYYY-MM-DD" @change="load" />
</el-form-item>
<el-form-item label="工单号"><el-input v-model="query.orderNo" clearable style="width:160px" @keyup.enter="load" /></el-form-item>
<el-form-item label="叫料单号"><el-input v-model="query.requestNo" clearable style="width:180px" placeholder="不区分大小写" @keyup.enter="load" /></el-form-item>
<el-form-item label="图号"><el-input v-model="query.materialCode" clearable style="width:150px" placeholder="不区分大小写" @keyup.enter="load" /></el-form-item>
<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 v-model="query.source" clearable placeholder="全部" style="width:130px">
<el-option label="工位叫料" value="CALL" />
<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="DELIVERING" />
<el-option label="已接料完结" value="DONE" />
<el-option label="已发货" value="SHIPPED" />
<el-option label="已完成" value="DONE" />
<el-option label="已取消" value="CANCELLED" />
<el-option label="已驳回" value="REJECTED" />
<el-option label="退库中" value="RETURNING" />
<el-option label="已退库" value="RETURNED" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="load">查询</el-button>
<el-button @click="resetFilters">重置</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-button type="success" plain @click="exportCsv">导出</el-button>
</el-form-item>
</el-form>
<el-table :data="list" border size="small">
<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">
<el-table-column prop="requestNo" label="叫料单号" min-width="180" />
<el-table-column label="来源" width="120" 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>
<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" />
<el-table-column label="管理方式" width="100">
<el-table-column prop="unit" label="单位" width="70" align="center" />
<el-table-column label="序列号方式" width="100" align="center">
<template #default="{row}">{{ row.snMode === 1 ? '序列号=是' : '序列号=否' }}</template>
</el-table-column>
<el-table-column prop="stationNo" label="工位" width="70" align="center" />
<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">
<template #default="{row}">{{ fmtQty(row.sentQty) }}</template>
<el-table-column prop="reqQty" label="请求量" width="90" align="center" />
<el-table-column label="实发量" width="90" align="center">
<template #default="{row}">{{ Number(row.sentQty || 0) > 0 ? fmtQty(row.sentQty) : '—' }}</template>
</el-table-column>
<el-table-column label="已接料" width="90" align="center">
<template #default="{row}">{{ Number(row.sentQty || 0) > 0 ? fmtQty(row.receivedQty) : '—' }}</template>
<el-table-column label="退库量" width="90" align="center">
<template #default="{row}">{{ Number(row.returnedQty || 0) > 0 ? fmtQty(row.returnedQty) : '—' }}</template>
</el-table-column>
<el-table-column label="分批进度" min-width="150">
<el-table-column label="跨日" width="80" align="center">
<template #default="{row}">
<el-progress :percentage="progressPct(row)" :status="row.status === 'DONE' ? 'success' : ''" />
<el-tag v-if="row.crossDay" type="warning" size="small">非当日</el-tag>
<span v-else>—</span>
</template>
</el-table-column>
<el-table-column prop="status" label="状态" width="100">
<template #default="{row}">{{ statusText(row.status) }}</template>
<el-table-column prop="outboundNo" label="WMS出库单号" min-width="150" show-overflow-tooltip>
<template #default="{row}">{{ row.outboundNo || '—' }}</template>
</el-table-column>
<el-table-column label="操作" width="90" align="center" fixed="right">
<template #default="{row}">
<el-tooltip content="仓库发出后才能确认接料" :disabled="Number(row.sentQty || 0) > 0" placement="top">
<el-button size="small" type="primary" :disabled="row.status === 'DONE' || Number(row.sentQty || 0) <= 0" :loading="receiving && receivingNo === row.requestNo" @click="receive(row)">确认接料</el-button>
</el-tooltip>
</template>
<el-table-column label="状态" width="100" align="center">
<template #default="{row}"><el-tag :type="statusTag(row.status)" size="small">{{ statusText(row.status) }}</el-tag></template>
</el-table-column>
<el-table-column prop="rejectReason" label="驳回理由" min-width="130" show-overflow-tooltip />
<el-table-column prop="refReportNo" label="数量不符单号" min-width="140" show-overflow-tooltip />
<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 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 label="已接料" width="75" align="center">
<template #default="{row}">{{ Number(row.outQty || 0) > 0 ? fmtQty(row.receivedQty) : '—' }}</template>
</el-table-column>
<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>(已发出未接料,含已送达未扫码);生产中的待发缺口属正常状态,不标色。
<br>注:「已接料」为<b>本工单+图号的累计接料量</b>(MES 按工单汇总,不细分到每行),并非本行发出对应的接料;某行「已发出」为 0 时该列显示「—」,详情见上方接料明细。
</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>
<script setup>
import { reactive, ref, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { ElMessage } from 'element-plus'
import request from '../utils/request'
import { confirmExport } from '../utils/confirm'
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: '', source: '' })
const query = reactive({ requestNo: '', status: '', materialCode: '', materialName: '', targetDock: '', stationNo: '', source: '' })
function resetFilters() {
query.planDate = new Date().toISOString().slice(0, 10)
Object.assign(query, { orderNo: '', status: '', materialCode: '', materialName: '', targetDock: '', stationNo: '', source: '' })
Object.assign(query, { requestNo: '', status: '', materialCode: '', materialName: '', targetDock: '', stationNo: '', source: '' })
load()
}
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 STATUS_TEXT = {
PENDING: '待备料', SHIPPED: '已发货', DONE: '已完成', CANCELLED: '已取消',
REJECTED: '已驳回', RETURNING: '退库中', RETURNED: '已退库'
}
const STATUS_TAG = {
PENDING: 'warning', SHIPPED: 'primary', DONE: 'success', CANCELLED: 'info',
REJECTED: 'danger', RETURNING: 'warning', RETURNED: 'info'
}
const statusText = (s) => STATUS_TEXT[s] || s || '—'
const statusTag = (s) => STATUS_TAG[s] || 'info'
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 got = Number(row.receivedQty || 0)
if (req <= 0) return 0
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(带物料清单列,Excel 直接打开中文不乱码;MES 前端无 xlsx 库,纯前端导出)
async function exportLedgerCsv() {
if (!(await confirmExport(progressRows.value.length, '物料去向对账记录'))) return
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() {
list.value = (await request.get('/material-requests', { params: query })) || []
}
// 已接料(班组长补录入口):确认本批全部剩余(sentQty 补到 reqQty),达到即置 DONE
async function receive(row) {
if (!row?.requestNo) return
try {
await ElMessageBox.confirm(`确认「${row.requestNo}」已接料(物料将累计到已发料,达需求即完结)?`, '接料确认', { type: 'warning' })
} catch {
return
// 全量导出 CSV(带 BOM,Excel 直接打开中文不乱码)
async function exportCsv() {
if (!(await confirmExport(list.value.length, '叫料单记录'))) return
const header = ['叫料单号', '来源', '图号', '物料名称', '单位', '序列号方式', '工位', '接驳台',
'请求量', '实发量', '退库量', '跨日', 'WMS出库单号', '状态', '驳回理由', '数量不符单号', '操作人']
const srcOf = (r) => (r.source === 'REFILL' ? '数量不符补发' : '工位叫料')
const lines = [header.join(',')]
for (const r of list.value) {
const cells = [
r.requestNo, srcOf(r), r.materialCode, r.materialName, r.unit,
r.snMode === 1 ? '序列号=是' : '序列号=否', r.stationNo, r.targetDock,
r.reqQty, r.sentQty, r.returnedQty, r.crossDay ? '非当日' : '',
r.outboundNo, statusText(r.status), r.rejectReason, r.refReportNo, r.operator
]
lines.push(cells.map((c) => '"' + String(c ?? '').replace(/"/g, '""') + '"').join(','))
}
receiving.value = true
receivingNo.value = row.requestNo
try {
await request.post('/material-requests/receive', { requestNo: row.requestNo })
ElMessage.success('已接料确认:' + row.requestNo)
load()
} catch {
// 拦截器已提示
}
receiving.value = false
receivingNo.value = ''
}
async function generate() {
if (!query.planDate) return ElMessage.warning('请先选择排产日期')
await ElMessageBox.confirm(
`将按排产日期 ${query.planDate} 的所有工单,根据各产品物料清单自动计算所需物料并生成备料单。确认继续?`,
'生成备料', { type: 'info' })
const data = await request.post('/material-requests/generate', { planDate: query.planDate })
if (data?.blocked) {
const missing = (data.missing || []).join('、')
await ElMessageBox.alert(
`以下物料在 WMS 物料档案中不存在,请先到 WMS 创建物料档案后再生成备料单:\n\n${missing}`,
'无法生成备料单', { type: 'error', confirmButtonText: '知道了' })
return
}
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
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)
}
onMounted(() => {
query.planDate = new Date().toISOString().slice(0, 10)
load()
})</script>
onMounted(load)
</script>
+12 -2
View File
@@ -31,6 +31,14 @@
<el-input-number v-model="form.pipelineCache" :min="0" :max="1" />
<div class="tip">滚筒线缓存模式(1=启用缓存位并行流转,0=串行不缓存);预留配置,PLC 真机接入后生效</div>
</el-form-item>
<el-form-item label="允许叫非今日排产的料">
<el-input-number v-model="form.allowCrossDay" :min="0" :max="1" />
<div class="tip">1=允许(默认,叫料池含非今日排产时工位端预警提示,仓库可正常发也可按「非当日」驳回);0=禁止</div>
</el-form-item>
<el-form-item label="单次叫料上限">
<el-input-number v-model="form.callMaxQty" :min="0" :max="100000" />
<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>
@@ -70,7 +78,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 })
const form = reactive({ wmsBaseURL: '', demandDays: 5, extrapWindow: 3, extrapCap: 365, logRetentionDays: 0, pipelineCache: 0, allowCrossDay: 1, callMaxQty: 0 })
const info = ref({})
async function load() {
@@ -83,7 +91,9 @@ async function load() {
extrapWindow: data.extrapWindow ?? 3,
extrapCap: data.extrapCap ?? 365,
logRetentionDays: data.logRetentionDays ?? 0,
pipelineCache: data.pipelineCache ?? 0
pipelineCache: data.pipelineCache ?? 0,
allowCrossDay: data.allowCrossDay ?? 1,
callMaxQty: data.callMaxQty ?? 0
})
info.value = data
} finally {
+24
View File
@@ -45,6 +45,12 @@
<el-descriptions-item v-if="data.workpiece?.onlineAt" label="进线时间">{{ fmt(data.workpiece?.onlineAt) }}</el-descriptions-item>
<el-descriptions-item v-if="data.workpiece?.doneAt" label="完工时间">{{ fmt(data.workpiece?.doneAt) }}</el-descriptions-item>
</el-descriptions>
<el-alert v-if="data.torqueNgPending" type="warning" :closable="false" show-icon style="margin-bottom:12px">
<template #title>
<span>该工件拧紧扭矩不合格,待人工处置(质检/班组长确认放行后方可继续报工/下线完工)。</span>
<el-button size="small" type="warning" :loading="disposing" style="margin-left:12px" @click="disposeTorque">确认放行</el-button>
</template>
</el-alert>
<el-alert type="info" :closable="false" style="margin-bottom:12px"
title="追溯链路:产品型号(物)→ 工单(批次任务)→ 工件(实例SN)。本页展示单个工件的完整生命周期。" />
@@ -254,6 +260,24 @@ function statusText(st) {
const map = { CREATED: '已创建', ONLINE: '生产中', DONE: '已完工', SCRAPPED: '已报废' }
return map[st] || st || '-'
}
// B6 拧紧闭环:质检/班组长确认放行——清标记 + 写 event_log + 置 torque_ng 预警 resolved。
const disposing = ref(false)
async function disposeTorque() {
try {
const { value: reason } = await ElMessageBox.prompt('请填写处置原因(确认放行后该工件可继续流转)', '拧紧不合格-确认放行', {
confirmButtonText: '确认放行', cancelButtonText: '取消', inputType: 'textarea',
inputValidator: (v) => (v && v.trim()) ? true : '处置原因必填'
})
disposing.value = true
await request.post('/torque/dispose', { sn: sn.value, reason: reason.trim() })
ElMessage.success('已确认放行')
await search()
} catch (e) {
if (e !== 'cancel' && e !== 'close') ElMessage.error(e?.message || '处置失败')
} finally {
disposing.value = false
}
}
function fmt(v) { return v ? String(v).replace('T', ' ').slice(0, 19) : '-' }
// 检验附件(只读):优先公开直链新窗口打开;无直链时走带鉴权 id 路由下载
async function openAttachment(a) {