diff --git a/bj_power_mes/frontend/src/pages/PlcSend.vue b/bj_power_mes/frontend/src/pages/PlcSend.vue
index f606571..3b26f38 100644
--- a/bj_power_mes/frontend/src/pages/PlcSend.vue
+++ b/bj_power_mes/frontend/src/pages/PlcSend.vue
@@ -7,12 +7,12 @@
-
+
+ placeholder="请选择/输入工单号" style="width:200px" @change="onOrderChange">
@@ -37,7 +37,7 @@
-
+
@@ -49,7 +49,7 @@
-
+
@@ -148,7 +148,7 @@ async function searchWorkOrders(kw) {
} catch { workOrders.value = []; woOffset.value = 0; woHasMore.value = false }
finally { woSearching.value = false }
}
-// 下拉滚动到底:按 offset 取下一页并追加(按产品工号去重,避免翻页边界重复)
+// 下拉滚动到底:按 offset 取下一页并追加(按工单号去重,避免翻页边界重复)
async function loadMoreWorkOrders() {
if (!woHasMore.value || woSearching.value) return
woSearching.value = true
@@ -212,7 +212,7 @@ async function onOrderChange() {
}
async function doSend() {
- if (!send.orderNo) return ElMessage.warning('请选择产品工号')
+ if (!send.orderNo) return ElMessage.warning('请选择工单号')
if (!send.sn) return ElMessage.warning('请选择/扫码输入该工单下的工件 产品序号(SN)')
if (!currentStation.value) return ElMessage.warning('未识别到工件当前工位,请先选择已上线工件的 产品序号(SN)')
send.stationNo = currentStation.value
diff --git a/bj_power_mes/frontend/src/pages/ProcessCard.vue b/bj_power_mes/frontend/src/pages/ProcessCard.vue
index 0f7daf1..6528190 100644
--- a/bj_power_mes/frontend/src/pages/ProcessCard.vue
+++ b/bj_power_mes/frontend/src/pages/ProcessCard.vue
@@ -3,8 +3,8 @@
-
-
+
+
@@ -27,7 +27,7 @@
(selectedRows = rows)">
-
+
@@ -61,7 +61,7 @@
- {{ card.workOrderNo }}
+ {{ card.workOrderNo }}
{{ card.productCode || '-' }}
{{ card.productName || '-' }}
{{ card.drawingNo || '-' }}
@@ -161,7 +161,7 @@
{{ snCard.sn }}
- {{ snCard.workOrderNo || '-' }}
+ {{ snCard.workOrderNo || '-' }}
{{ snCard.productCode || '-' }}
{{ snCard.status || '-' }}
{{ snCard.doneAt || '-' }}
@@ -589,7 +589,7 @@ function buildWorkOrderCsv(c) {
const lines = []
const push = (arr) => lines.push(arr.map(csvCell).join(','))
push(['生产流程卡(工单维度)', c.workOrderNo || ''])
- push(['产品工号', c.workOrderNo || '', '产品型号', c.productCode || '', '产品名称', c.productName || '', '图号', c.drawingNo || ''])
+ push(['工单号', c.workOrderNo || '', '产品型号', c.productCode || '', '产品名称', c.productName || '', '图号', c.drawingNo || ''])
push(['计划数', c.planQty ?? '', '完成数', c.finishedNum ?? '', '不良数', c.failNum ?? '', '状态', c.status || ''])
push(['计划开始', c.planStart || '', '计划完成', c.planEnd || '', '实际开始', c.actualStart || '', '实际完成', c.completedAt || ''])
push(['实际结束', c.actualFinish || '', '生成时间', c.generatedAt || ''])
@@ -628,7 +628,7 @@ function buildSnCsv(c) {
const lines = []
const push = (arr) => lines.push(arr.map(csvCell).join(','))
push(['成品追溯卡(序列号维度)', c.sn || ''])
- push(['序列号', c.sn || '', '产品工号', c.workOrderNo || '', '产品型号', c.productCode || '', '状态', c.status || ''])
+ push(['序列号', c.sn || '', '工单号', c.workOrderNo || '', '产品型号', c.productCode || '', '状态', c.status || ''])
push(['完工时间', c.doneAt || '', '生成时间', c.generatedAt || ''])
lines.push('')
push(['一、工序实绩'])
@@ -663,7 +663,7 @@ function buildSnCsv(c) {
}
onMounted(() => {
- // 2026-11-16 日排产「计划vs实际」明细跳转:支持 ?orderNo= 预填产品工号并自动查询
+ // 2026-11-16 日排产「计划vs实际」明细跳转:支持 ?orderNo= 预填工单号并自动查询
const qn = route.query.orderNo
if (qn) listQuery.orderNo = String(qn)
loadList()
diff --git a/bj_power_mes/frontend/src/pages/ProducibleSupport.vue b/bj_power_mes/frontend/src/pages/ProducibleSupport.vue
index 94c187a..6470b95 100644
--- a/bj_power_mes/frontend/src/pages/ProducibleSupport.vue
+++ b/bj_power_mes/frontend/src/pages/ProducibleSupport.vue
@@ -28,7 +28,7 @@ function strText(v) {
return v
}
-// 2026-11-11:滚动分页改 el-pagination 标准分页 + 搜索条件(工单号/成品编码关键字,本地过滤)
+// 2026-11-11:滚动分页改 el-pagination 标准分页 + 搜索条件(工单号/产品编码关键字,本地过滤)
const PAGE_SIZE = 20
const orderKeyword = ref('')
const orderPage = ref(1)
@@ -143,7 +143,7 @@ onMounted(load)
-
共 {{ filteredOrders.length }} 条
@@ -151,7 +151,7 @@ onMounted(load)
{{ strText(row.workOrderNo) }}
-
+
{{ strText(row.productCode) }}
diff --git a/bj_power_mes/frontend/src/pages/ProductProcess.vue b/bj_power_mes/frontend/src/pages/ProductProcess.vue
index 7b7f96c..ebf72e0 100644
--- a/bj_power_mes/frontend/src/pages/ProductProcess.vue
+++ b/bj_power_mes/frontend/src/pages/ProductProcess.vue
@@ -2,7 +2,7 @@
+ title="产品工艺 = 某产品的加工工序顺序(第1道、第2道…)。每个产品建档时系统已自动生成一套工艺,这里只维护工序顺序、不用新建。新建工单选产品后,按这里的工序顺序自动推荐工位:后道工位号必须大于前道(工件单向流转、不回头),每道可改。状态栏「启用/停用」区分当前版与历史版,复制可换版。" />
@@ -29,8 +29,7 @@
查询
重置
- 新增产品工艺
-
+
@@ -75,11 +74,12 @@
{{ fmtTime(row.createdAt) }}
-
+
-
-
{{ row.runningByWorkOrders > 0 ? '查看' : '编辑' }}
+
+
工艺
+
分账
ppCommand(row, c)">
更多 ▾
@@ -126,7 +126,7 @@
-
+
@@ -134,7 +134,7 @@
-
+
@@ -167,84 +167,22 @@
-
-
- 维护物料清单(BOM 总账 + 工序分配)
- 共 {{ dlg.bomRows.length }} 种总账物料;物料清单在独立弹窗中单独保存,不随本工艺表单提交。
-
+
+ 分配物料到工序请回列表点本行的「分账」(与「工艺」平级,各自独立保存)。
+
取消
保存
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 删
-
-
- + 添加物料
- 工序分配(分账,按当前产品工艺隔离)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 删
-
-
-
- + 添加拆分行(同一物料分到多工序)
-
- {{ b.materialCode }}:Σ{{ allocSummary(b.materialCode).sum }} / 总账{{ allocSummary(b.materialCode).total }}
-
-
-
- 关闭
- 保存总账(不清空已有分配)
- 保存工序分配
-
-
+
+
@@ -278,6 +216,7 @@ import { can } from '../utils/perm'
import { fmtTime } from '../utils/format'
import { openPrintableHtml } from '../utils/print'
import PageHelp from '../components/PageHelp.vue'
+import ProductBOMDialog from '../components/ProductBOMDialog.vue'
import { helpProductProcess } from '../help'
const route = useRoute()
@@ -330,8 +269,7 @@ async function loadOptions() {
defineExpose({ reload: () => { load(); loadOptions() } })
-// 2026-11-13 拍板「总分制」:dlg 增加 BOM 总账(bomRows) 与分账(allocations)。
-const dlg = reactive({ show: false, id: 0, productCode: '', productName: '', name: '', remark: '', flows: [], pickFlow: null, bomRows: [], allocations: [] })
+const dlg = reactive({ show: false, id: 0, productCode: '', productName: '', name: '', remark: '', flows: [], pickFlow: null })
// 只读详情(2026-11-10):被未完成工单引用的行不可编辑,但可以查看完整定义
const detailDlg = reactive({ show: false, row: null })
function openRow(row) {
@@ -343,114 +281,29 @@ function openRow(row) {
openEdit(row)
}
-/* ---------- 成品 BOM 总账 / 分账 ---------- */
-async function loadBOM(code) {
- if (!code) { dlg.bomRows = []; return }
- try {
- dlg.bomRows = (await request.get('/product-boms', { params: { productCode: code } }))?.list || []
- } catch { dlg.bomRows = [] }
-}
-// 总账有物料但尚未分配时,按总账一键生成「每物料一行」的初始分账(默认第一道工序、数量=总账量)。
-// 用户可改工序、改数量,或点「添加拆分行」把同一物料分到多道工序。
-function initAllocationsFromBOM() {
- if (!dlg.bomRows.length) { dlg.allocations = []; return }
- if (dlg.allocations.length) return
- const firstFlow = dlg.flows[0] || null
- dlg.allocations = dlg.bomRows.map((r) => ({
- materialCode: r.materialCode, materialName: r.materialName || '', unit: r.unit || '',
- flowId: firstFlow, unitQty: r.unitQty
- }))
-}
-function addAllocationRow() {
- dlg.allocations.push({
- materialCode: dlg.bomRows[0]?.materialCode || '', materialName: '', unit: '',
- flowId: dlg.flows[0] || null, unitQty: 0
- })
-}
-function allocSummary(code) {
- const total = Number(dlg.bomRows.find((r) => r.materialCode === code)?.unitQty || 0)
- const sum = dlg.allocations.filter((a) => a.materialCode === code)
- .reduce((s, a) => s + (Number(a.unitQty) || 0), 0)
- return { total, sum, ok: Math.abs(sum - total) < 1e-6 }
-}
-const bomDlg = reactive({ show: false, productCode: '', rows: [] })
-async function openBOM() {
- if (!dlg.productCode) return ElMessage.warning('请先选择产品')
- if (!dlg.id) ElMessage.info('物料清单与产品工艺分开保存;总账可直接维护,工序分配需先保存工艺')
- bomDlg.productCode = dlg.productCode
- bomDlg.rows = dlg.bomRows.map((r) => ({ ...r }))
- // 物料清单独立弹窗打开时回显该工艺的分账(与工艺表单互不覆盖)
- if (dlg.id > 0) {
- try {
- const d = await request.get('/product-process-materials', { params: { productProcessId: dlg.id } })
- dlg.allocations = (d?.list || []).map((a) => ({
- materialCode: a.materialCode, materialName: a.materialName || '', unit: a.unit || '',
- flowId: a.flowId, unitQty: a.unitQty
- }))
- } catch { /* 保留已加载值 */ }
- }
- initAllocationsFromBOM()
+/* ---------- 分账(2026-11-18 重构:列表「分账」按钮一层直达 ProductBOMDialog) ----------
+ 总账维护在「产品档案」页;本页只把总账物料分到各工序。 */
+const bomDlg = reactive({ show: false, productCode: '', productName: '', productProcessId: 0, flows: [], canEdit: true })
+// 列表「分账」按钮:一层直达打开分账弹窗。总账只读,本页只分配物料到工序。
+// 被未完成工单引用的工艺:只读打开(canEdit=false),仍可查看已分配方案。
+function openBOM(row) {
+ bomDlg.productCode = row.productCode
+ bomDlg.productName = row.productName || ''
+ bomDlg.productProcessId = row.id
+ bomDlg.canEdit = !(row.runningByWorkOrders > 0) && can('produce.productprocess:edit')
+ bomDlg.flows = (row.flows || []).map((it) => ({ id: it.flowId, name: it.flowName || flowNameOf(it.flowId) }))
bomDlg.show = true
}
-function addBOMRow() {
- bomDlg.rows.push({ materialCode: '', materialName: '', spec: '', unit: '', unitQty: 1, lossRate: 0, remark: '' })
-}
-async function saveBOM() {
- for (const r of bomDlg.rows) {
- if (!r.materialCode || !(Number(r.unitQty) > 0)) return ElMessage.warning('总账行需填物料编码且单台用量大于 0')
- }
- await request.post('/product-boms/save', { productCode: bomDlg.productCode, rows: bomDlg.rows })
- ElMessage.success('BOM 总账已保存(已有工序分配保持不变;后端会回校分账,不平衡时整批拒绝)')
- await loadBOM(dlg.productCode)
- // 2026-11-13 P10:改总账绝不清空已有分账;重新拉取分账保持弹窗数据最新
- if (dlg.id > 0) {
- try {
- const d = await request.get('/product-process-materials', { params: { productProcessId: dlg.id } })
- const list = d?.list || []
- if (list.length) {
- dlg.allocations = list.map((a) => ({
- materialCode: a.materialCode, materialName: a.materialName || '', unit: a.unit || '',
- flowId: a.flowId, unitQty: a.unitQty
- }))
- }
- } catch { /* 保留已加载值 */ }
- }
- initAllocationsFromBOM()
-}
-
-// P10:工序分配独立保存,不随「保存产品工艺」提交
-async function saveAllocations() {
- if (!dlg.id) return ElMessage.warning('请先保存产品工艺,再维护工序分配')
- if (!dlg.bomRows.length) return ElMessage.warning('请先维护成品 BOM 总账')
- for (const r of dlg.bomRows) {
- const s = allocSummary(r.materialCode)
- if (!s.ok) return ElMessage.warning(`总账物料 ${r.materialCode} 未分配完:Σ分账 ${s.sum} ≠ 总账 ${s.total}`)
- }
- if (dlg.allocations.some((a) => !a.flowId || !dlg.flows.includes(a.flowId))) {
- return ElMessage.warning('存在未指定工序(或工序已被移除)的分账行')
- }
- await request.post('/product-process-materials/save', {
- productProcessId: dlg.id,
- rows: dlg.allocations.map((a) => ({
- flowId: a.flowId, seq: Math.max(1, dlg.flows.indexOf(a.flowId) + 1),
- materialCode: a.materialCode, materialName: a.materialName, unit: a.unit,
- unitQty: Number(a.unitQty) || 0
- }))
- })
- ElMessage.success('工序分配已独立保存(产品工艺未被重复保存)')
+// 组件内保存分账成功后回调:刷新列表
+function onBOMSaved() {
+ load()
}
async function onProductChange(code) {
const p = products.value.find((x) => x.code === code)
dlg.productName = p ? (p.name || '') : ''
- dlg.name = p ? `${p.code || ''} ${p.name || ''} 工艺`.trim() : ''
- dlg.allocations = []
- await loadBOM(code)
- initAllocationsFromBOM()
-}
-
-function openCreate() {
- Object.assign(dlg, { show: true, id: 0, productCode: '', productName: '', name: '', remark: '', flows: [], pickFlow: null, bomRows: [], allocations: [] })
+ // 2026-11-17:名称建档时已生成(默认=产品名+工艺),编辑改产品时不覆盖已有名称,仅在空时兜底。
+ if (!dlg.name) dlg.name = p ? (p.name || p.code || '') : ''
}
async function openEdit(row) {
@@ -460,17 +313,8 @@ async function openEdit(row) {
Object.assign(dlg, {
show: true, id: row.id, productCode: row.productCode, productName: row.productName,
name: row.name, remark: row.remark || '',
- flows: (row.flows || []).map((it) => it.flowId), pickFlow: null, bomRows: [], allocations: []
+ flows: (row.flows || []).map((it) => it.flowId), pickFlow: null
})
- await loadBOM(row.productCode)
- try {
- const d = await request.get('/product-process-materials', { params: { productProcessId: row.id } })
- dlg.allocations = (d?.list || []).map((a) => ({
- materialCode: a.materialCode, materialName: a.materialName || '', unit: a.unit || '',
- flowId: a.flowId, unitQty: a.unitQty
- }))
- } catch { dlg.allocations = [] }
- initAllocationsFromBOM()
}
// 勾选加入(客户裁定:先勾选、再用上下移排顺序,不用多选的勾选顺序)
@@ -479,7 +323,6 @@ function addFlow() {
if (dlg.flows.includes(dlg.pickFlow)) return ElMessage.warning('同一工艺不能重复加入')
dlg.flows.push(dlg.pickFlow)
dlg.pickFlow = null
- initAllocationsFromBOM()
}
function moveFlow(idx, dir) {
const j = idx + dir
@@ -496,19 +339,15 @@ async function save() {
if (!dlg.name) return ElMessage.warning('请填写产品工艺名称')
if (!dlg.productCode) return ElMessage.warning('请选择产品')
if (!dlg.flows.length) return ElMessage.warning('请先勾选加入工艺,再用上下移按钮排好执行顺序')
- const isNew = !dlg.id
- // P10:物料清单(工序分配)独立保存,本接口只提交工艺定义,绝不顺带写分账
- const saved = await request.post('/product-processes', {
+ // 工序顺序独立保存,本接口只提交工艺定义,不碰分账
+ await request.post('/product-processes', {
id: dlg.id, productCode: dlg.productCode, productName: dlg.productName,
name: dlg.name, remark: dlg.remark,
flows: dlg.flows.map((id) => ({ flowId: id }))
})
- if (isNew && saved?.id) dlg.id = saved.id
- ElMessage.success('产品工艺已保存(物料清单未改动)')
+ ElMessage.success('工序顺序已保存(分账请回列表点本行「分账」维护)')
dlg.show = false
load()
- // 新建保存后自动打开物料清单弹窗,操作人不必回列表再找按钮;编辑/已有工艺不受影响
- if (isNew) openBOM()
}
async function toggleStatus(row) {
@@ -576,263 +415,9 @@ function ppCommand(row, c) {
else if (c === 'del') remove(row)
}
-// ---------- 【已下线】生成工位模板(2026-11-13 拍板:入口已移入「工位管理 → 保存当前绑定为模板」) ----------
-// 页面按钮与弹窗已删除,以下函数没有任何调用路径;保留是因为表格多选公共变量
-// (selectedRows / onSelectionChange)仍被列表使用,贸然删除会牵动无关功能。新实现见 Station.vue。
-// 数据来源:GET /product-processes(每行 flows 工序顺序)、GET /process-flows(每个工艺 stations 工位号数组)
-// 2026-11-10:模板内工位可勾选/拖拽调序/换选工艺;生成前按工单组合口径做三层校验;
-// productCode 作为产品范围标签(跨产品模板留空,套用时不做产品一致性校验)。
+// ---------- 工位模板功能已整体删除(2026-11-18 拍板):建单走「选产品 → 推荐工位」,改绑定在工位管理手动改 ----------
const selectedRows = ref([])
function onSelectionChange(rows) { selectedRows.value = rows || [] }
-const tplDlg = reactive({ show: false, name: '', productCode: '', stations: [], processNames: [], selectedStations: [] })
-const tplTableRef = ref(null)
-function onTplStationSelect(rows) {
- tplDlg.selectedStations = rows || []
- refreshTplCheck()
-}
-function moveTplStation(i, delta) {
- const j = i + delta
- if (j < 0 || j >= tplDlg.stations.length) return
- const arr = tplDlg.stations
- ;[arr[i], arr[j]] = [arr[j], arr[i]]
- refreshTplCheck()
-}
-
-// ---------- 实时校验/置灰(2026-11-11) ----------
-// 产线物理顺序固定=工位号升序,所以「勾选集按工位号升序后同一工序是否被打断」决定了
-// 这套勾选到底能不能成立(打断 = 怎么拖拽调序都救不回来);当前显示顺序乱但升序后合法的,
-// 不禁选,只黄条提示调序。
-const tplCheck = reactive({ err: '' })
-const tplPreview = computed(() => {
- const chosen = (tplDlg.selectedStations.length ? tplDlg.selectedStations : tplDlg.stations)
- .slice().sort((a, b) => a.stationNo - b.stationNo)
- const groups = []
- for (const s of chosen) {
- const last = groups[groups.length - 1]
- if (last && last.flowId === s.flowId) last.nos.push(s.stationNo)
- else groups.push({ flowId: s.flowId, nos: [s.stationNo] })
- }
- return groups.map((g) => `${flowNameOf(g.flowId)} 工位${g.nos.join('/')}`).join(' → ')
-})
-// sorted flowId 序列中某工艺出现后又断了 = 打断(与 validateTemplateStations 同判定)
-function tplBroken(ids) {
- const closed = new Set()
- let cur = null
- for (const f of ids) {
- if (f === cur) continue
- if (cur !== null) closed.add(cur)
- if (closed.has(f)) return true
- cur = f
- }
- return false
-}
-function tplSelectable(row) { return !row._dis }
-function refreshTplCheck() {
- const chosen = tplDlg.selectedStations
- const canonical = (rows) => rows.slice().sort((a, b) => a.stationNo - b.stationNo)
- for (const row of tplDlg.stations) {
- if (chosen.includes(row)) { row._dis = false; row._disReason = ''; continue }
- const ids = canonical([...chosen, row]).map((s) => s.flowId)
- row._dis = tplBroken(ids)
- row._disReason = row._dis
- ? `勾上工位${row.stationNo}(${flowNameOf(row.flowId)})后,${flowNameOf(row.flowId)} 的工位会与已选的其他工序工位互相穿插——流水线要来回走,怎么调序都救不回来。请取消其它工位,或把这一行的「绑定工艺」换掉。`
- : ''
- }
- tplDlg.stations = [...tplDlg.stations] // 替换引用触发表格重估 selectable
- tplCheck.err = chosen.length ? validateTemplateStations(chosen) : ''
-}
-watch(() => tplDlg.stations.map((s) => s.flowId).join(','), refreshTplCheck)
-
-// 原生 HTML5 拖拽调序(不引入第三方拖拽库):事件委托挂在 tbody 上,行重渲染不影响。
-let tplDragFrom = -1
-function bindTplDrag() {
- const table = tplTableRef.value
- const tbody = table?.querySelector?.('.el-table__body-wrapper tbody') || table?.$el?.querySelector?.('tbody')
- if (!tbody || tbody.dataset.tplDragBound) return
- tbody.dataset.tplDragBound = '1'
- tbody.querySelectorAll('tr').forEach((tr) => { tr.draggable = true })
- tbody.addEventListener('dragstart', (e) => {
- const tr = e.target.closest('tr')
- tplDragFrom = tr ? Array.from(tbody.querySelectorAll('tr')).indexOf(tr) : -1
- if (tplDragFrom >= 0) e.dataTransfer.effectAllowed = 'move'
- })
- tbody.addEventListener('dragover', (e) => { e.preventDefault(); e.dataTransfer.dropEffect = 'move' })
- tbody.addEventListener('drop', (e) => {
- e.preventDefault()
- const tr = e.target.closest('tr')
- if (!tr || tplDragFrom < 0) return
- const to = Array.from(tbody.querySelectorAll('tr')).indexOf(tr)
- const arr = tplDlg.stations
- if (to >= 0 && to < arr.length && tplDragFrom < arr.length && to !== tplDragFrom) {
- const [moved] = arr.splice(tplDragFrom, 1)
- arr.splice(to, 0, moved)
- }
- tplDragFrom = -1
- })
- tbody.addEventListener('dragend', () => { tplDragFrom = -1 })
-}
-// 行会随数据重渲染,逐次补挂 draggable
-function ensureTplRowsDraggable() {
- const tbody = tplTableRef.value?.$el?.querySelector?.('tbody')
- tbody?.querySelectorAll('tr')?.forEach((tr) => { tr.draggable = true })
-}
-watch(() => tplDlg.stations.length, () => nextTick(ensureTplRowsDraggable))
-
-function openTemplateDialog() {
- if (!selectedRows.value.length) return ElMessage.warning('请先勾选至少一个产品工艺')
- const byStation = new Map()
- const conflicts = []
- const shared = [] // 同工位被多个产品工艺争用(即使绑定同一工艺,也要让用户看见)
- for (const pp of selectedRows.value) {
- const fs = Array.isArray(pp.flows) ? pp.flows : []
- for (const it of fs) {
- const fid = it.flowId
- const f = flows.value.find((x) => x.id === fid)
- const stationNos = Array.isArray(f?.stations) ? f.stations : []
- for (const no of stationNos) {
- const stationNo = Number(no)
- if (!byStation.has(stationNo)) {
- byStation.set(stationNo, { stationNo, flowId: fid, fromNames: [pp.name], fromCodes: [pp.productCode] })
- } else {
- const cur = byStation.get(stationNo)
- if (!cur.fromNames.includes(pp.name)) cur.fromNames.push(pp.name)
- if (!cur.fromCodes.includes(pp.productCode)) cur.fromCodes.push(pp.productCode)
- if (cur.flowId !== fid) {
- conflicts.push(`工位${stationNo}被工艺${flowNameOf(cur.flowId)}和${flowNameOf(fid)}要求不同工序(同一工位只能绑一道工艺)`)
- } else if (cur.fromNames.length === 2) {
- shared.push(`工位${stationNo}同时被多个产品工艺(${cur.fromNames.join('、')})要求,套用后这些产品共用此绑定`)
- }
- }
- }
- }
- }
- if (conflicts.length) {
- // 2026-11-11:同工位异工艺冲突 → 人话 + 自动分段判定
- const x = analyzeCrossProduct(selectedRows.value)
- const msg = x.seg
- ? `${humanizeStationConflicts(conflicts)}\n\n不过两个产品可以前后分段生产:${x.msg}`
- : humanizeStationConflicts(conflicts)
- ElMessageBox.alert(msg, '无法生成工位模板', { type: 'warning', confirmButtonText: '知道了', customStyle: { whiteSpace: 'pre-wrap' } })
- return
- }
- const stations = [...byStation.values()].sort((a, b) => a.stationNo - b.stationNo)
- .map((x) => ({ stationNo: x.stationNo, flowId: x.flowId, fromNames: x.fromNames.join('、') }))
- const codes = [...new Set(selectedRows.value.map((p) => p.productCode).filter(Boolean))]
- tplDlg.productCode = codes.length === 1 ? codes[0] : '' // 跨产品模板不限定产品范围
- tplDlg.name = selectedRows.value.map((p) => p.name).join('、')
- tplDlg.stations = stations
- tplDlg.selectedStations = stations
- tplDlg.processNames = selectedRows.value.map((p) => p.name)
- tplDlg.show = true
- nextTick(() => {
- bindTplDrag()
- ensureTplRowsDraggable()
- tplTableRef.value?.toggleAllSelection?.() // 默认全选,与 selectedStations 初值一致
- refreshTplCheck()
- })
- if (shared.length) ElMessage.warning(shared.join(';'))
-}
-
-// ---------- 跨产品合并分析(2026-11-11) ----------
-// 把每个产品工艺的工序链(工序顺序→工位组)放到工位号轴上:
-// ① 每条链自身方向必须与工位号同向;② 两条链可归并 ⇔ 按工位号升序后各链工序序号不回退;
-// ③ 不可归并时按工位号断点找分段方案(每条链完整落在一段)→ 可分段给建议,否则完全冲突。
-function analyzeCrossProduct(pps) {
- const chains = []
- for (const pp of pps) {
- const fs = Array.isArray(pp.flows) ? pp.flows : []
- const groups = []
- for (const it of fs) {
- const f = flows.value.find((x) => x.id === it.flowId)
- const nos = (Array.isArray(f?.stations) ? f.stations : []).map(Number).filter((n) => n > 0).sort((a, b) => a - b)
- if (nos.length) groups.push(nos)
- }
- if (groups.length) chains.push({ name: pp.name, code: pp.productCode, groups })
- }
- if (chains.length < 2) return { ok: true, seg: false, msg: '' }
- const flat = (c) => c.groups.flat()
- const describeChain = (c) => c.groups.map((g, i) => `工序${i + 1} 工位${g.join('/')}`).join(' → ')
- for (const c of chains) {
- for (let i = 0; i < c.groups.length - 1; i++) {
- if (Math.max(...c.groups[i]) >= Math.min(...c.groups[i + 1])) {
- return { ok: false, seg: false, msg: `产品「${c.name}」的工序顺序与工位号方向相反(${describeChain(c)})——这条产品工艺本身在产线上走不通,请先修正它的工位绑定。` }
- }
- }
- }
- const seq = []
- chains.forEach((c, ci) => c.groups.forEach((g, gi) => g.forEach((no) => seq.push({ no, ci, gi }))))
- seq.sort((a, b) => a.no - b.no)
- const lastGi = new Map()
- let crossed = false
- for (const s of seq) {
- const prev = lastGi.get(s.ci)
- if (prev !== undefined && s.gi < prev) { crossed = true; break }
- lastGi.set(s.ci, s.gi)
- }
- if (!crossed) return { ok: true, seg: false, msg: '' }
- const minNo = seq[0].no
- const maxNo = seq[seq.length - 1].no
- for (let k = minNo; k < maxNo; k++) {
- const front = chains.filter((c) => flat(c).every((n) => n <= k))
- const back = chains.filter((c) => flat(c).every((n) => n > k))
- if (front.length && back.length && front.length + back.length === chains.length) {
- const f = front.map((c) => `「${c.name}」用 ${describeChain(c)}`).join(',')
- const b = back.map((c) => `「${c.name}」用 ${describeChain(c)}`).join(',')
- return { ok: false, seg: true, msg: `前段:${f};后段:${b}。请分开生成两个模板(各勾选对应产品的产品工艺),两个工单分段生产、互不影响。` }
- }
- }
- return { ok: false, seg: false, msg: `${chains.map((c) => `「${c.name}」${describeChain(c)}`).join(';')}——两个产品的工序方向在相同工位段上互相交叉,方向相反,同一组工位没办法同时满足。请只勾选其中一个产品的工艺生成模板,或调整工位绑定错开两个产品。` }
-}
-function humanizeStationConflicts(conflicts) {
- // conflicts 现为程序化短句,统一转人话前缀
- return conflicts.map((c) => c.replace(/工位(\d+)被工艺(.+?)和(.+?)要求不同工序(同一工位只能绑一道工艺)/,
- '工位 $1 被两个产品同时要求做不同的工序(「$2」和「$3」)——一个工位同一时刻只能干一道工序。')).join('\n')
-}
-
-// 三层校验(对齐 internal/logic/route.go:218-263,265-352,363-380 的工单组合口径):
-// ① 每道被选工序至少有一个工位;② 按工位号升序后同工序必须连续、区间整体递增不回头;
-// ③ 同工序内工位号不重复(一个工位只能出现一次)。
-function validateTemplateStations(stations) {
- if (!stations.length) return '请至少勾选一个工位'
- const seen = new Set()
- for (const s of stations) {
- if (!(s.stationNo > 0)) return '存在无效工位号,请检查'
- if (!(s.flowId > 0)) return `工位${s.stationNo} 未选择绑定工艺`
- if (seen.has(s.stationNo)) return `工位${s.stationNo} 重复,一个工位只能出现一次`
- seen.add(s.stationNo)
- }
- const flowIds = stations.map((s) => s.flowId)
- const firstIdx = new Map()
- const lastIdx = new Map()
- flowIds.forEach((f, i) => {
- if (!firstIdx.has(f)) firstIdx.set(f, i)
- lastIdx.set(f, i)
- })
- for (const [f, first] of firstIdx) {
- const last = lastIdx.get(f)
- for (let i = first; i <= last; i++) {
- if (flowIds[i] !== f) {
- return `${flowNameOf(f)} 的工位被 ${flowNameOf(flowIds[i])}(工位${stations[i].stationNo})隔开了——同一道工序的工位必须排在一起,流水线不能往回走。请拖动/点 ↑↓ 把 ${flowNameOf(f)} 的工位调到一起,或取消勾选工位${stations[i].stationNo}。`
- }
- }
- }
- return ''
-}
-
-async function saveTemplate() {
- if (!tplDlg.name.trim()) return ElMessage.warning('请输入模板名称')
- const chosen = tplDlg.selectedStations.length ? tplDlg.selectedStations : tplDlg.stations
- const err = validateTemplateStations(chosen)
- if (err) return ElMessageBox.alert(err, '模板校验未通过', { type: 'warning', confirmButtonText: '返回修改' })
- await request.post('/station-templates', {
- name: tplDlg.name.trim(),
- productCode: tplDlg.productCode,
- stations: chosen.map((s) => ({ stationNo: s.stationNo, flowId: s.flowId })),
- processNames: tplDlg.processNames
- })
- ElMessage.success(`该绑定满足产品工艺${tplDlg.processNames.join('、')}`)
- tplDlg.show = false
-}
onMounted(async () => {
// 改动4:工单页「查看产品工艺」跳转带 ?pp=产品工艺名称 / ?ppCode=图号,先落到筛选框再加载
@@ -847,11 +432,23 @@ onMounted(async () => {
if (cid > 0) {
try {
await request.post('/product-processes/copy', { sourceId: cid })
- ElMessage.success('已复制为新工艺,列表已刷新;新工艺可正常编辑')
+ ElMessage.success('已复制为新工艺(默认停用),确认无误后在列表点「启用」;列表已刷新')
load()
} catch { /* 错误已由拦截器提示 */ }
history.replaceState(null, '', location.pathname)
}
+ // 2026-11-17:产品档案工艺抽屉「编辑」跳 ?edit=id —— 直达该工艺的编辑/查看弹窗。
+ // 用 page=0 全量按 id 定位(不受默认「只看启用」影响,停用历史工艺也能直达)。
+ const eid = Number(route.query.edit)
+ if (eid > 0) {
+ try {
+ const all = await request.get('/product-processes', { params: { page: 0 } })
+ const target = (Array.isArray(all) ? all : (all?.list || [])).find((x) => x.id === eid)
+ if (target) openRow(target)
+ else ElMessage.warning('未找到该工艺,可能已被删除')
+ } catch { /* 错误已由拦截器提示 */ }
+ history.replaceState(null, '', location.pathname)
+ }
})
diff --git a/bj_power_mes/frontend/src/pages/ProductType.vue b/bj_power_mes/frontend/src/pages/ProductType.vue
index 4c8b600..d4d5b69 100644
--- a/bj_power_mes/frontend/src/pages/ProductType.vue
+++ b/bj_power_mes/frontend/src/pages/ProductType.vue
@@ -9,14 +9,14 @@
-
-
+
+
查询
重置
- 新增成品档案
+ 新增产品档案
+
+
+
+ {{ row.bomKinds }} 种 / 共 {{ row.bomQty }} 件
+ 未维护
+
+
+
{{ row.safetyStock || 0 }}
@@ -79,9 +86,11 @@
正常
-
+
编辑
+ 工艺
+ 物料清单
附件
{{ row.isActive ? '停用' : '启用' }}
重推
@@ -92,9 +101,9 @@
:total="total" v-model:current-page="page" v-model:page-size="pageSize"
:page-sizes="[20, 50, 100]" @current-change="load" @size-change="search" />
-
+
-
+
@@ -113,6 +122,60 @@
+
+
+ 正在加载工艺…
+
+
+
+
+ 当前启用
+
+
+
+ 启用 {{ processDrawer.active.name }}
+ 编辑 →
+
+
+
+
+
+ →
+ 第{{ it.seq }}道 {{ it.flowName }}(工位{{ (it.stationNos || []).join(',') || '未绑定' }})
+
+
+ 尚未维护工序顺序,点「编辑」添加
+
+
+ 对应工单:{{ woText(processDrawer.active.id) }}
+
+
+
+
+
+
+
+
+
+
+ 停用 {{ p.name }}
+ 编辑
+
+
+
+ {{ (p.flows || []).map((x) => `第${x.seq}道 ${x.flowName}`).join(' → ') || '无工序明细' }}
+
+ 对应工单:{{ woText(p.id) }}
+
+
+
+
+
+
+
+
@@ -121,19 +184,21 @@