From 852233d22755f3722ead38692dddccb57f811299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B8=B8=E7=86=9F=E5=90=B4=E5=BD=A6=E7=A5=96?= Date: Fri, 11 Sep 2026 12:19:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E9=80=81wcs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/haianWarehouse/poOrderIssueNotify.js | 6 + src/api/haianWarehouse/searchIssureNotify.js | 8 +- src/api/haianWarehouse/shipmentIssue.js | 6 + .../noOrderIssue/noOrderNotification54.vue | 12 +- .../poOrder/searchPoIssureNotify54.vue | 681 ++++++++++++++---- .../shipment/shipmentNotification54.vue | 681 ++++++++++++++---- .../searchIssureNotify54.vue | 663 ++++++++++++++--- 7 files changed, 1710 insertions(+), 347 deletions(-) diff --git a/src/api/haianWarehouse/poOrderIssueNotify.js b/src/api/haianWarehouse/poOrderIssueNotify.js index cfa74be..4dd62c5 100644 --- a/src/api/haianWarehouse/poOrderIssueNotify.js +++ b/src/api/haianWarehouse/poOrderIssueNotify.js @@ -31,5 +31,11 @@ export const haiAnUpdateMaterialDetail = (data) => createAPI('/autoWareHourceHai export const haiAnCheckIssueNotifyInventory = (data) => createAPI('/autoWareHourceHaian/haiAnSearchIssureNotify/checkIssueNotifyInventory', 'post', data) export const haiAnPushInventoryToWcs = (data) => createAPI('/autoWareHourceHaian/haiAnSearchIssureNotify/pushInventoryToWcs', 'post', data) +// 海安指定物料复用无单分配接口:委外查看页材料明细与无单共用alloc表 - rqrq +export const getNoOrderMaterialAllocList = (data) => createAPI('/autoWareHourceHaian/haiAnIssureNotify/getNoOrderMaterialAllocList', 'post', data) +export const saveNoOrderMaterialAllocList = (data) => createAPI('/autoWareHourceHaian/haiAnIssureNotify/saveNoOrderMaterialAllocList', 'post', data) +export const getNoOrderAvailableInStockLabelList = (data) => createAPI('/autoWareHourceHaian/haiAnIssureNotify/getNoOrderAvailableInStockLabelList', 'post', data) +export const getNoOrderMaterialAllocListByNotifyNo = (data) => createAPI('/autoWareHourceHaian/haiAnIssureNotify/getNoOrderMaterialAllocListByNotifyNo', 'post', data) + // 公共枚举接口 - rqrq export const getAllNotifyStatus = (data) => createAPI('/sys/enum/list', 'get', data) diff --git a/src/api/haianWarehouse/searchIssureNotify.js b/src/api/haianWarehouse/searchIssureNotify.js index a9d736a..fd2db59 100644 --- a/src/api/haianWarehouse/searchIssureNotify.js +++ b/src/api/haianWarehouse/searchIssureNotify.js @@ -18,6 +18,12 @@ export const haiAnUpdateMaterialDetail = (data) => createAPI('/autoWareHourceHai export const haiAnGetSOSBOMForIssureNew = (data) => createAPI('/autoWareHourceHaian/haiAnSearchIssureNotify/getSOSBOMForIssureNew', 'post', data) export const haiAnSaveMaterialDetail = (data) => createAPI('/autoWareHourceHaian/haiAnSearchIssureNotify/saveMaterialDetail', 'post', data) -// 海安查看页WCS预览与推送占位接口,当前仅保留扩展入口 - rqrq +// 海安查看页WCS预览与推送:服务端按site+notifyNo重新匹配,前端不传标签清单 - rqrq export const haiAnCheckIssueNotifyInventory = (data) => createAPI('/autoWareHourceHaian/haiAnSearchIssureNotify/checkIssueNotifyInventory', 'post', data) export const haiAnPushInventoryToWcs = (data) => createAPI('/autoWareHourceHaian/haiAnSearchIssureNotify/pushInventoryToWcs', 'post', data) + +// 海安指定物料复用无单分配接口:工单/委外/销售查看页材料明细共用同一张alloc表 - rqrq +export const getNoOrderMaterialAllocList = (data) => createAPI('/autoWareHourceHaian/haiAnIssureNotify/getNoOrderMaterialAllocList', 'post', data) +export const saveNoOrderMaterialAllocList = (data) => createAPI('/autoWareHourceHaian/haiAnIssureNotify/saveNoOrderMaterialAllocList', 'post', data) +export const getNoOrderAvailableInStockLabelList = (data) => createAPI('/autoWareHourceHaian/haiAnIssureNotify/getNoOrderAvailableInStockLabelList', 'post', data) +export const getNoOrderMaterialAllocListByNotifyNo = (data) => createAPI('/autoWareHourceHaian/haiAnIssureNotify/getNoOrderMaterialAllocListByNotifyNo', 'post', data) diff --git a/src/api/haianWarehouse/shipmentIssue.js b/src/api/haianWarehouse/shipmentIssue.js index 51454f5..964c768 100644 --- a/src/api/haianWarehouse/shipmentIssue.js +++ b/src/api/haianWarehouse/shipmentIssue.js @@ -31,5 +31,11 @@ export const haiAnUpdateMaterialDetail = (data) => createAPI('/autoWareHourceHai export const haiAnCheckIssueNotifyInventory = (data) => createAPI('/autoWareHourceHaian/haiAnSearchIssureNotify/checkIssueNotifyInventory', 'post', data) export const haiAnPushInventoryToWcs = (data) => createAPI('/autoWareHourceHaian/haiAnSearchIssureNotify/pushInventoryToWcs', 'post', data) +// 海安指定物料复用无单分配接口:销售发货查看页材料明细与无单共用alloc表 - rqrq +export const getNoOrderMaterialAllocList = (data) => createAPI('/autoWareHourceHaian/haiAnIssureNotify/getNoOrderMaterialAllocList', 'post', data) +export const saveNoOrderMaterialAllocList = (data) => createAPI('/autoWareHourceHaian/haiAnIssureNotify/saveNoOrderMaterialAllocList', 'post', data) +export const getNoOrderAvailableInStockLabelList = (data) => createAPI('/autoWareHourceHaian/haiAnIssureNotify/getNoOrderAvailableInStockLabelList', 'post', data) +export const getNoOrderMaterialAllocListByNotifyNo = (data) => createAPI('/autoWareHourceHaian/haiAnIssureNotify/getNoOrderMaterialAllocListByNotifyNo', 'post', data) + // 枚举字典继续复用公共接口,避免重复维护 - rqrq export const getAllNotifyStatus = (data) => createAPI('/sys/enum/list', 'get', data) diff --git a/src/views/modules/haianWarehouse/noOrderIssue/noOrderNotification54.vue b/src/views/modules/haianWarehouse/noOrderIssue/noOrderNotification54.vue index bf22414..b1cb019 100644 --- a/src/views/modules/haianWarehouse/noOrderIssue/noOrderNotification54.vue +++ b/src/views/modules/haianWarehouse/noOrderIssue/noOrderNotification54.vue @@ -372,7 +372,7 @@ --> @@ -1914,6 +1914,11 @@ export default { * @param row 申请明细弹窗中的物料行 */ openNoOrderMaterialAllocDialog (row) { + // 未下达申请单不允许指定,避免未正式下达就锁定标签/批次 - rqrq + if (!this.currentRow || this.currentRow.status !== 'ISSUE') { + this.$alert('未下达申请单不允许指定物料', '提示', { confirmButtonText: '确定' }) + return + } const parentItemNo = (this.clickrow && this.clickrow.itemNo) || row.itemNo const bomItemNo = row.bOMItemNo || row.bomItemNo || '*' this.noOrderAllocForm = { @@ -2069,6 +2074,11 @@ export default { * 保存当前物料行指定策略:全量提交后由后端按页面顺序重排alloc_seq - rqrq */ saveNoOrderMaterialAlloc () { + // 保存前再次校验已下达,防止弹窗打开后主单被取消下达仍提交指定 - rqrq + if (!this.currentRow || this.currentRow.status !== 'ISSUE') { + this.$alert('未下达申请单不允许指定物料', '提示', { confirmButtonText: '确定' }) + return + } this.refreshNoOrderAllocRowNo() const payload = JSON.parse(JSON.stringify(this.noOrderAllocForm)) payload.allocList = (payload.allocList || []).map((row) => ({ diff --git a/src/views/modules/haianWarehouse/poOrder/searchPoIssureNotify54.vue b/src/views/modules/haianWarehouse/poOrder/searchPoIssureNotify54.vue index 68861f2..2dc571d 100644 --- a/src/views/modules/haianWarehouse/poOrder/searchPoIssureNotify54.vue +++ b/src/views/modules/haianWarehouse/poOrder/searchPoIssureNotify54.vue @@ -212,6 +212,40 @@ style="width: 100px; height: 80px"/> + + + + + + + + + + + + + + + + + + + + @@ -444,95 +478,179 @@ - + + :close-on-click-modal="false" + v-drag + width="70%"> + + + + + {{ getAreaDisplayText(currentProductionArea) }} + + + - - - + + - + + - + + - + + - + - + - + + + + - - {{ previewLoading ? '推送中...' : '推送至WCS' }} + + {{ pushLoading ? '推送中...' : '推送至WCS' }} - 关闭 + 关闭 + + + + + + + + + + + + + + + + +
+ 新增标签指定 + 新增批次指定 + 保存后按当前列表顺序进行指定匹配 +
+ + + + + + + + + + + + + + + + + + + + 保存 + 关闭 + +
+ + + + + + + + + + + + + 关闭 + + + @@ -553,7 +671,11 @@ import { haiAnUpdateMaterialDetail, haiAnSaveMaterialDetail, haiAnCheckIssueNotifyInventory, - haiAnPushInventoryToWcs + haiAnPushInventoryToWcs, + getNoOrderMaterialAllocList, + saveNoOrderMaterialAllocList, + getNoOrderAvailableInStockLabelList, + getNoOrderMaterialAllocListByNotifyNo } from '@/api/haianWarehouse/poOrderIssueNotify.js' export default { @@ -1408,7 +1530,39 @@ export default { // 预览相关数据 previewDialogVisible: false, previewLoading: false, + pushLoading: false, previewData: [], + previewSummary: { + totalOrderCount: 0, + completeOrderCount: 0, + pushableOrderCount: 0, + pushableOrderNos: [], + completeOrderNos: [] + }, + currentNotifyRow: null, + areaOptions: [], + currentProductionArea: '', + allocDetailList: [], + allocDetailLoading: false, + noOrderAllocDialogVisible: false, + noOrderAllocLoading: false, + noOrderAllocSaving: false, + noOrderAllocForm: { + site: this.$store.state.user.site, + notifyNo: '', + itemNo: '', + bOMItemNo: '', + partNo: '', + partDesc: '', + subSite: '', + qtyToIssue: 0, + allocList: [] + }, + noOrderLabelPickDialogVisible: false, + noOrderLabelPickLoading: false, + noOrderLabelPickList: [], + noOrderLabelPickIndex: -1, + noOrderLabelPickMode: 'LABEL', // 物料明细对话框相关数据 materialModalFlag: false, sobomList: [], @@ -1447,6 +1601,14 @@ export default { // 补充海安标签扩展列,确保预留标签页签能展示海安增强字段 - rqrq this.haiAnEnsureLabelColumns() }, + computed: { + /** + * 只有服务端本次匹配判定的完整订单才允许确认推送,前端不自行按标签数量推断 - rqrq + */ + canPushPreview () { + return !this.previewLoading && !this.pushLoading && this.previewSummary.pushableOrderCount > 0 + } + }, methods: { // 每页数 sizeChangeHandle (val) { @@ -2132,6 +2294,8 @@ export default { haiAnSearchNotifyLogCloseNew(queryData).then(({ data }) => { this.dataList6 = data && data.code === 0 ? (data.rows || []) : [] }) + } else if (this.activeName === 'allocDetail') { + this.searchNoOrderMaterialAllocListByNotifyNo() } else if (this.activeName === 'labelDetail') { haiAnSearchMaterialListDetail(queryData).then(({ data }) => { this.dataList7 = data && data.code === 0 ? (data.rows || []) : [] @@ -2225,72 +2389,352 @@ export default { }) }, /** - * 海安库存预览当前为占位实现,保留入口并给出待开发提示 - rqrq + * 海安查看页WCS预览:服务端重新执行匹配,前端只展示物料汇总和指定明细 - rqrq + * @param row 当前申请单主表行 - rqrq */ previewInventory (row) { + if (!row || !row.notifyNo) { + this.$alert('请选择有效的海安申请单', '提示', {confirmButtonText: '确定'}) + return + } this.currentRow = row + this.currentNotifyRow = JSON.parse(JSON.stringify(row)) + this.currentProductionArea = row.productionArea || '' + this.previewData = [] + this.previewSummary = { + totalOrderCount: 0, + completeOrderCount: 0, + pushableOrderCount: 0, + pushableOrderNos: [], + completeOrderNos: [] + } this.previewDialogVisible = true this.previewLoading = true - this.previewData = [] - const inData = { - site: this.$store.state.user.site, + const queryData = { + site: row.site || this.$store.state.user.site, notifyNo: row.notifyNo } - haiAnCheckIssueNotifyInventory(inData).then(({ data }) => { - this.previewLoading = false - if (data && data.code === 0) { - this.previewData = data.rows || [] - if (data.placeholder) { - this.$message.warning(data.msg || '海安库存预览待开发') + haiAnCheckIssueNotifyInventory(queryData) + .then(({data}) => { + if (data && data.code === 0) { + this.previewData = data.rows || [] + if (!this.currentProductionArea && this.previewData.length) { + const firstAreaRow = this.previewData.find(item => item.productionArea) + this.currentProductionArea = firstAreaRow ? firstAreaRow.productionArea : '' + } + this.previewSummary = { + totalOrderCount: data.totalOrderCount || 0, + completeOrderCount: data.completeOrderCount || 0, + pushableOrderCount: data.pushableOrderCount || 0, + pushableOrderNos: data.pushableOrderNos || [], + completeOrderNos: data.completeOrderNos || [] + } + if (data.placeholder) { + this.$alert(data.msg || '该海安页面暂不执行真实库存匹配', '提示', {confirmButtonText: '确定'}) + } else if (!this.previewData.length || !this.previewSummary.totalOrderCount) { + this.$alert('服务端未返回有效匹配结果,本次不能推送', '提示', {confirmButtonText: '确定'}) + } + } else { + this.previewData = [] + this.$alert((data && data.msg) || '库存匹配失败', '错误', {confirmButtonText: '确定'}) } - return - } - this.$alert(data.msg, '错误', { - confirmButtonText: '确定' }) - }).catch(() => { - this.previewLoading = false - this.$message.error('获取库存预览失败') - }) + .catch((error) => { + this.previewData = [] + this.$message.error((error && error.message) || '库存匹配请求失败') + }) + .finally(() => { + this.previewLoading = false + }) + }, + /** + * 关闭预览时清理上次匹配结果,避免不同申请单之间误用摘要 - rqrq + */ + closePreviewDialog (force) { + if (!force && (this.previewLoading || this.pushLoading)) { + return + } + this.previewDialogVisible = false + this.previewData = [] + this.previewSummary = { + totalOrderCount: 0, + completeOrderCount: 0, + pushableOrderCount: 0, + pushableOrderNos: [], + completeOrderNos: [] + } + }, + /** + * 目的地展示文本:有区域名称时拼编码+名称,没有则回退编码或未设置 - rqrq + */ + getAreaDisplayText(areaId) { + if (!areaId) return '未设置' + const area = (this.areaOptions || []).find(item => item.areaId === areaId) + if (area) { + return area.areaId + ' - ' + area.areaDesc + } + return areaId + }, + /** + * 根据物料或指定明细自身的匹配结果设置颜色,失败统一标红 - rqrq + */ + getRowClassName ({row}) { + const classNames = [] + if (row && row.displayRowType === 'SPECIFIED') classNames.push('specified-preview-row') + if (row && row.matchStatus === 'FAILED') classNames.push('danger-row') + if (row && row.matchStatus === 'MATCHED') classNames.push('success-row') + return classNames.join(' ') + }, + /** + * 数量展示去除无意义尾零,空值统一显示0 - rqrq + */ + formatPreviewQty (value) { + if (value === null || value === undefined || value === '') return '0' + return String(value).replace(/(\.\d*?[1-9])0+$|\.0+$/, '$1') }, /** - * 海安推送WCS当前为占位实现,仅提示待开发并不触发真实推送 - rqrq + * 海安查看页确认推送:只提交site和notifyNo,实际订单和标签由服务端重新匹配决定 - rqrq */ pushToWCS () { - const validData = this.previewData || [] - this.$confirm(`确认推送 ${validData.length} 条数据至WCS?`, '提示', { - confirmButtonText: '确定', + if (!this.canPushPreview || !this.currentNotifyRow) { + this.$message.warning('当前没有可推送的完整订单') + return + } + const orderNos = this.previewSummary.pushableOrderNos || [] + const total = this.previewSummary.totalOrderCount || 0 + const message = `共有${total}个订单,其中${orderNos.length}个订单完全匹配,本次只推送单据${orderNos.join('、')}` + this.$confirm(message, '确认推送', { + confirmButtonText: '确定推送', cancelButtonText: '取消', type: 'warning' }).then(() => { - this.previewLoading = true - const inData = { - site: this.$store.state.user.site, - notifyNo: this.currentRow.notifyNo, - inventoryList: validData - } - haiAnPushInventoryToWcs(inData).then(({ data }) => { - this.previewLoading = false + this.pushLoading = true + haiAnPushInventoryToWcs({ + site: this.currentNotifyRow.site || this.$store.state.user.site, + notifyNo: this.currentNotifyRow.notifyNo + }).then(({data}) => { if (data && data.code === 0) { - this.$message.warning(data.msg || '海安推送WCS待开发') - this.previewDialogVisible = false - return + const result = data.row || {} + this.$message.success(result.message || data.msg || '推送WCS成功') + this.closePreviewDialog(true) + this.searchTable() + this.refreshCurrentTabTable() + } else { + this.$alert((data && data.msg) || '推送WCS失败', '错误', {confirmButtonText: '确定'}) } - this.$alert(data.msg || '推送失败', '错误', { - confirmButtonText: '确定' - }) }).catch((error) => { - this.previewLoading = false - this.$message.error(error.message || '推送WCS失败,请重试') + this.$message.error((error && error.message) || '推送WCS请求失败') + }).finally(() => { + this.pushLoading = false }) + }).catch(() => {}) + }, + /** + * 兼容旧按钮入口,与新确认推送方法保持同一幂等防护 - rqrq + */ + pushToWcs () { + return this.pushToWCS() + }, + /** + * 查询当前申请单指定物料清单:按site+notifyNo拉取全部指定行,不含备注 - rqrq + */ + searchNoOrderMaterialAllocListByNotifyNo() { + if (!this.currentRow || !this.currentRow.notifyNo) { + this.allocDetailList = [] + return + } + this.allocDetailLoading = true + getNoOrderMaterialAllocListByNotifyNo({ + site: this.currentRow.site || this.$store.state.user.site, + notifyNo: this.currentRow.notifyNo, + page: 1, + limit: 20 + }).then(({ data }) => { + if (data && data.code === 0) { + this.allocDetailList = data.rows || [] + } else { + this.allocDetailList = [] + if (data && data.msg) { + this.$alert(data.msg, '提示', { confirmButtonText: '确定' }) + } + } + }).catch((error) => { + this.allocDetailList = [] + this.$message.error(error.message || '查询指定物料清单失败') + }).finally(() => { + this.allocDetailLoading = false }) }, /** - * 兼容旧入口的海安推送占位方法,避免历史按钮调用空指针 - rqrq + * 打开指定物料策略弹窗:以订单行itemNo+BOM行号隔离当前物料;未下达不允许指定 - rqrq + * @param row 材料明细页签中的物料行 */ - pushToWcs (row) { - this.previewInventory(row) + openNoOrderMaterialAllocDialog (row) { + if (!this.currentRow || this.currentRow.status !== 'ISSUE') { + this.$alert('未下达申请单不允许指定物料', '提示', { confirmButtonText: '确定' }) + return + } + const parentItemNo = row.itemNo + const bomItemNo = row.bOMItemNo || row.BOMItemNo || row.bomItemNo || row.bomitemNo + if (parentItemNo == null || parentItemNo === '') { + this.$alert('当前材料行缺少订单序号,无法指定物料', '提示', { confirmButtonText: '确定' }) + return + } + if (!bomItemNo) { + this.$alert('当前材料行缺少BOM行号,无法指定物料', '提示', { confirmButtonText: '确定' }) + return + } + this.noOrderAllocForm = { + site: this.$store.state.user.site, + notifyNo: this.currentRow.notifyNo, + itemNo: parentItemNo, + bOMItemNo: bomItemNo, + partNo: row.partNo || row.componentPartNo || '', + partDesc: row.partDesc || row.componentPartDesc || '', + subSite: row.subSite || (this.currentRow && this.currentRow.subSite) || this.$store.state.user.site, + qtyToIssue: row.qtyToIssue == null || row.qtyToIssue === '' ? 0 : row.qtyToIssue, + allocList: [] + } + this.noOrderAllocDialogVisible = true + this.noOrderAllocLoading = true + getNoOrderMaterialAllocList(this.noOrderAllocForm).then(({ data }) => { + if (data && data.code === 0) { + this.noOrderAllocForm.allocList = (data.rows || []).map((item, index) => ({ + ...item, + rowNo: index + 1 + })) + } else { + this.noOrderAllocForm.allocList = [] + if (data && data.msg) { + this.$alert(data.msg, '提示', { confirmButtonText: '确定' }) + } + } + }).catch((error) => { + this.$message.error(error.message || '查询指定策略失败') + this.noOrderAllocForm.allocList = [] + }).finally(() => { + this.noOrderAllocLoading = false + }) + }, + /** 新增一条指定策略行:LABEL走标签指定,BATCH走批次指定 - rqrq */ + addNoOrderAllocRow (allocType) { + this.noOrderAllocForm.allocList.push({ + allocType, + serialNo: '', + batchNo: '', + allocQty: '', + subSite: this.noOrderAllocForm.subSite, + allocStatus: 'NEW', + remark: '' + }) + this.refreshNoOrderAllocRowNo() + }, + openNoOrderAvailableLabelDialog (index, pickMode) { + if (!this.noOrderAllocForm.subSite) { + this.$alert('缺少子站点,无法查询在库标签', '提示', { confirmButtonText: '确定' }) + return + } + if (!this.noOrderAllocForm.partNo) { + this.$alert('缺少物料号,无法查询在库标签', '提示', { confirmButtonText: '确定' }) + return + } + this.noOrderLabelPickIndex = index + this.noOrderLabelPickMode = pickMode + this.noOrderLabelPickList = [] + this.noOrderLabelPickDialogVisible = true + this.noOrderLabelPickLoading = true + getNoOrderAvailableInStockLabelList({ + site: this.$store.state.user.site, + subSite: this.noOrderAllocForm.subSite, + partNo: this.noOrderAllocForm.partNo, + page: 1, + limit: 20 + }).then(({ data }) => { + if (data && data.code === 0) { + this.noOrderLabelPickList = data.rows || [] + } else { + this.noOrderLabelPickList = [] + this.$alert((data && data.msg) || '查询在库可用标签失败', '提示', { confirmButtonText: '确定' }) + } + }).catch((error) => { + this.noOrderLabelPickList = [] + this.$message.error(error.message || '查询在库可用标签失败') + }).finally(() => { + this.noOrderLabelPickLoading = false + }) + }, + handleNoOrderAvailableLabelDblClick (row) { + const target = this.noOrderAllocForm.allocList[this.noOrderLabelPickIndex] + if (!target) { + this.$message.warning('未找到待回填的指定行') + return + } + const labelQty = row.qty == null || row.qty === '' ? 0 : row.qty + if (this.noOrderLabelPickMode === 'LABEL') { + if (!row.serialNo) { + this.$alert('所选行缺少标签号,无法指定', '提示', { confirmButtonText: '确定' }) + return + } + target.serialNo = row.serialNo + target.batchNo = '' + target.allocQty = labelQty + } else { + if (!row.batchNo) { + this.$alert('所选标签缺少批次号,无法指定批次', '提示', { confirmButtonText: '确定' }) + return + } + target.serialNo = '' + target.batchNo = row.batchNo + target.allocQty = labelQty + } + this.noOrderLabelPickDialogVisible = false }, + removeNoOrderAllocRow (index) { + this.noOrderAllocForm.allocList.splice(index, 1) + this.refreshNoOrderAllocRowNo() + }, + moveNoOrderAllocRow (index, step) { + const targetIndex = index + step + if (targetIndex < 0 || targetIndex >= this.noOrderAllocForm.allocList.length) { + return + } + const rows = this.noOrderAllocForm.allocList + const current = rows.splice(index, 1)[0] + rows.splice(targetIndex, 0, current) + this.refreshNoOrderAllocRowNo() + }, + refreshNoOrderAllocRowNo () { + ;(this.noOrderAllocForm.allocList || []).forEach((row, index) => { + row.rowNo = index + 1 + }) + }, + saveNoOrderMaterialAlloc () { + if (!this.currentRow || this.currentRow.status !== 'ISSUE') { + this.$alert('未下达申请单不允许指定物料', '提示', { confirmButtonText: '确定' }) + return + } + this.refreshNoOrderAllocRowNo() + const payload = JSON.parse(JSON.stringify(this.noOrderAllocForm)) + payload.allocList = (payload.allocList || []).map((row) => ({ + ...row, + allocQty: row.allocQty === '' || row.allocQty == null ? null : Number(row.allocQty) + })) + this.noOrderAllocSaving = true + saveNoOrderMaterialAllocList(payload).then(({ data }) => { + if (data && data.code === 0) { + this.$message.success('指定策略保存成功') + this.noOrderAllocDialogVisible = false + this.searchNoOrderMaterialAllocListByNotifyNo() + } else if (data) { + this.$alert(data.msg || '保存失败', '提示', { confirmButtonText: '确定' }) + } + }).catch((error) => { + this.$message.error(error.message || '保存指定策略失败') + }).finally(() => { + this.noOrderAllocSaving = false + }) + }, + /** * 海安取消下达流程:先检查未下达冲突,再执行取消并刷新列表 - rqrq */ @@ -2627,24 +3071,6 @@ export default { return data.page.list || [] } return [] - }, - /** - * 委外发料WCS预览:按海安复刻约束保持关闭,避免触发真实推送链路 - rqrq - */ - previewInventory () { - this.$message.warning('海安委外发料WCS推送功能暂不启用') - }, - /** - * 委外发料WCS推送:按复刻要求注掉推送,仅保留提示 - rqrq - */ - pushToWCS () { - this.$message.warning('海安委外发料WCS推送功能暂不启用') - }, - /** - * 兼容旧按钮入口:统一提示关闭,不触发后端推送接口 - rqrq - */ - pushToWcs () { - this.$message.warning('海安委外发料WCS推送功能暂不启用') } }, @@ -2730,4 +3156,17 @@ export default { /deep/ .el-table .danger-row:hover > td { background-color: #fde2e2 !important; } + +/* 指定明细使用缩进和浅色文字形成物料行下展开的视觉关系 - rqrq */ +/deep/ .el-table .specified-preview-row .specified-content { + display: inline-block; + padding-left: 18px; + color: #606266; +} + +/deep/ .matched-labels { + white-space: normal; + word-break: break-all; + line-height: 1.5; +} diff --git a/src/views/modules/haianWarehouse/shipment/shipmentNotification54.vue b/src/views/modules/haianWarehouse/shipment/shipmentNotification54.vue index 6620bb6..6408d00 100644 --- a/src/views/modules/haianWarehouse/shipment/shipmentNotification54.vue +++ b/src/views/modules/haianWarehouse/shipment/shipmentNotification54.vue @@ -212,6 +212,40 @@ style="width: 100px; height: 80px"/> + + + + + +
+ + + + + + + + + + + + + + @@ -444,95 +478,179 @@ - + + :close-on-click-modal="false" + v-drag + width="70%"> + + + + + {{ getAreaDisplayText(currentProductionArea) }} + + + - - - + + - + + - + + - + + - + - + - + + + + - - {{ previewLoading ? '推送中...' : '推送至WCS' }} + + {{ pushLoading ? '推送中...' : '推送至WCS' }} - 关闭 + 关闭 + + + + + + + + + + + + + + + + +
+ 新增标签指定 + 新增批次指定 + 保存后按当前列表顺序进行指定匹配 +
+ + + + + + + + + + + + + + + + + + + + 保存 + 关闭 + +
+ + + + + + + + + + + + + 关闭 + + + @@ -553,7 +671,11 @@ import { haiAnUpdateMaterialDetail, haiAnSaveMaterialDetail, haiAnCheckIssueNotifyInventory, - haiAnPushInventoryToWcs + haiAnPushInventoryToWcs, + getNoOrderMaterialAllocList, + saveNoOrderMaterialAllocList, + getNoOrderAvailableInStockLabelList, + getNoOrderMaterialAllocListByNotifyNo } from '@/api/haianWarehouse/shipmentIssue.js' export default { @@ -1408,7 +1530,39 @@ export default { // 预览相关数据 previewDialogVisible: false, previewLoading: false, + pushLoading: false, previewData: [], + previewSummary: { + totalOrderCount: 0, + completeOrderCount: 0, + pushableOrderCount: 0, + pushableOrderNos: [], + completeOrderNos: [] + }, + currentNotifyRow: null, + areaOptions: [], + currentProductionArea: '', + allocDetailList: [], + allocDetailLoading: false, + noOrderAllocDialogVisible: false, + noOrderAllocLoading: false, + noOrderAllocSaving: false, + noOrderAllocForm: { + site: this.$store.state.user.site, + notifyNo: '', + itemNo: '', + bOMItemNo: '', + partNo: '', + partDesc: '', + subSite: '', + qtyToIssue: 0, + allocList: [] + }, + noOrderLabelPickDialogVisible: false, + noOrderLabelPickLoading: false, + noOrderLabelPickList: [], + noOrderLabelPickIndex: -1, + noOrderLabelPickMode: 'LABEL', // 物料明细对话框相关数据 materialModalFlag: false, sobomList: [], @@ -1447,6 +1601,14 @@ export default { // 补充海安标签扩展列,确保预留标签页签能展示海安增强字段 - rqrq this.haiAnEnsureLabelColumns() }, + computed: { + /** + * 只有服务端本次匹配判定的完整订单才允许确认推送,前端不自行按标签数量推断 - rqrq + */ + canPushPreview () { + return !this.previewLoading && !this.pushLoading && this.previewSummary.pushableOrderCount > 0 + } + }, methods: { // 每页数 sizeChangeHandle (val) { @@ -2132,6 +2294,8 @@ export default { haiAnSearchNotifyLogCloseNew(queryData).then(({ data }) => { this.dataList6 = data && data.code === 0 ? (data.rows || []) : [] }) + } else if (this.activeName === 'allocDetail') { + this.searchNoOrderMaterialAllocListByNotifyNo() } else if (this.activeName === 'labelDetail') { haiAnSearchMaterialListDetail(queryData).then(({ data }) => { this.dataList7 = data && data.code === 0 ? (data.rows || []) : [] @@ -2225,72 +2389,352 @@ export default { }) }, /** - * 海安库存预览当前为占位实现,保留入口并给出待开发提示 - rqrq + * 海安查看页WCS预览:服务端重新执行匹配,前端只展示物料汇总和指定明细 - rqrq + * @param row 当前申请单主表行 - rqrq */ previewInventory (row) { + if (!row || !row.notifyNo) { + this.$alert('请选择有效的海安申请单', '提示', {confirmButtonText: '确定'}) + return + } this.currentRow = row + this.currentNotifyRow = JSON.parse(JSON.stringify(row)) + this.currentProductionArea = row.productionArea || '' + this.previewData = [] + this.previewSummary = { + totalOrderCount: 0, + completeOrderCount: 0, + pushableOrderCount: 0, + pushableOrderNos: [], + completeOrderNos: [] + } this.previewDialogVisible = true this.previewLoading = true - this.previewData = [] - const inData = { - site: this.$store.state.user.site, + const queryData = { + site: row.site || this.$store.state.user.site, notifyNo: row.notifyNo } - haiAnCheckIssueNotifyInventory(inData).then(({ data }) => { - this.previewLoading = false - if (data && data.code === 0) { - this.previewData = data.rows || [] - if (data.placeholder) { - this.$message.warning(data.msg || '海安库存预览待开发') + haiAnCheckIssueNotifyInventory(queryData) + .then(({data}) => { + if (data && data.code === 0) { + this.previewData = data.rows || [] + if (!this.currentProductionArea && this.previewData.length) { + const firstAreaRow = this.previewData.find(item => item.productionArea) + this.currentProductionArea = firstAreaRow ? firstAreaRow.productionArea : '' + } + this.previewSummary = { + totalOrderCount: data.totalOrderCount || 0, + completeOrderCount: data.completeOrderCount || 0, + pushableOrderCount: data.pushableOrderCount || 0, + pushableOrderNos: data.pushableOrderNos || [], + completeOrderNos: data.completeOrderNos || [] + } + if (data.placeholder) { + this.$alert(data.msg || '该海安页面暂不执行真实库存匹配', '提示', {confirmButtonText: '确定'}) + } else if (!this.previewData.length || !this.previewSummary.totalOrderCount) { + this.$alert('服务端未返回有效匹配结果,本次不能推送', '提示', {confirmButtonText: '确定'}) + } + } else { + this.previewData = [] + this.$alert((data && data.msg) || '库存匹配失败', '错误', {confirmButtonText: '确定'}) } - return - } - this.$alert(data.msg, '错误', { - confirmButtonText: '确定' }) - }).catch(() => { - this.previewLoading = false - this.$message.error('获取库存预览失败') - }) + .catch((error) => { + this.previewData = [] + this.$message.error((error && error.message) || '库存匹配请求失败') + }) + .finally(() => { + this.previewLoading = false + }) + }, + /** + * 关闭预览时清理上次匹配结果,避免不同申请单之间误用摘要 - rqrq + */ + closePreviewDialog (force) { + if (!force && (this.previewLoading || this.pushLoading)) { + return + } + this.previewDialogVisible = false + this.previewData = [] + this.previewSummary = { + totalOrderCount: 0, + completeOrderCount: 0, + pushableOrderCount: 0, + pushableOrderNos: [], + completeOrderNos: [] + } + }, + /** + * 目的地展示文本:有区域名称时拼编码+名称,没有则回退编码或未设置 - rqrq + */ + getAreaDisplayText(areaId) { + if (!areaId) return '未设置' + const area = (this.areaOptions || []).find(item => item.areaId === areaId) + if (area) { + return area.areaId + ' - ' + area.areaDesc + } + return areaId + }, + /** + * 根据物料或指定明细自身的匹配结果设置颜色,失败统一标红 - rqrq + */ + getRowClassName ({row}) { + const classNames = [] + if (row && row.displayRowType === 'SPECIFIED') classNames.push('specified-preview-row') + if (row && row.matchStatus === 'FAILED') classNames.push('danger-row') + if (row && row.matchStatus === 'MATCHED') classNames.push('success-row') + return classNames.join(' ') + }, + /** + * 数量展示去除无意义尾零,空值统一显示0 - rqrq + */ + formatPreviewQty (value) { + if (value === null || value === undefined || value === '') return '0' + return String(value).replace(/(\.\d*?[1-9])0+$|\.0+$/, '$1') }, /** - * 海安推送WCS当前为占位实现,仅提示待开发并不触发真实推送 - rqrq + * 海安查看页确认推送:只提交site和notifyNo,实际订单和标签由服务端重新匹配决定 - rqrq */ pushToWCS () { - const validData = this.previewData || [] - this.$confirm(`确认推送 ${validData.length} 条数据至WCS?`, '提示', { - confirmButtonText: '确定', + if (!this.canPushPreview || !this.currentNotifyRow) { + this.$message.warning('当前没有可推送的完整订单') + return + } + const orderNos = this.previewSummary.pushableOrderNos || [] + const total = this.previewSummary.totalOrderCount || 0 + const message = `共有${total}个订单,其中${orderNos.length}个订单完全匹配,本次只推送单据${orderNos.join('、')}` + this.$confirm(message, '确认推送', { + confirmButtonText: '确定推送', cancelButtonText: '取消', type: 'warning' }).then(() => { - this.previewLoading = true - const inData = { - site: this.$store.state.user.site, - notifyNo: this.currentRow.notifyNo, - inventoryList: validData - } - haiAnPushInventoryToWcs(inData).then(({ data }) => { - this.previewLoading = false + this.pushLoading = true + haiAnPushInventoryToWcs({ + site: this.currentNotifyRow.site || this.$store.state.user.site, + notifyNo: this.currentNotifyRow.notifyNo + }).then(({data}) => { if (data && data.code === 0) { - this.$message.warning(data.msg || '海安推送WCS待开发') - this.previewDialogVisible = false - return + const result = data.row || {} + this.$message.success(result.message || data.msg || '推送WCS成功') + this.closePreviewDialog(true) + this.searchTable() + this.refreshCurrentTabTable() + } else { + this.$alert((data && data.msg) || '推送WCS失败', '错误', {confirmButtonText: '确定'}) } - this.$alert(data.msg || '推送失败', '错误', { - confirmButtonText: '确定' - }) }).catch((error) => { - this.previewLoading = false - this.$message.error(error.message || '推送WCS失败,请重试') + this.$message.error((error && error.message) || '推送WCS请求失败') + }).finally(() => { + this.pushLoading = false }) + }).catch(() => {}) + }, + /** + * 兼容旧按钮入口,与新确认推送方法保持同一幂等防护 - rqrq + */ + pushToWcs () { + return this.pushToWCS() + }, + /** + * 查询当前申请单指定物料清单:按site+notifyNo拉取全部指定行,不含备注 - rqrq + */ + searchNoOrderMaterialAllocListByNotifyNo() { + if (!this.currentRow || !this.currentRow.notifyNo) { + this.allocDetailList = [] + return + } + this.allocDetailLoading = true + getNoOrderMaterialAllocListByNotifyNo({ + site: this.currentRow.site || this.$store.state.user.site, + notifyNo: this.currentRow.notifyNo, + page: 1, + limit: 20 + }).then(({ data }) => { + if (data && data.code === 0) { + this.allocDetailList = data.rows || [] + } else { + this.allocDetailList = [] + if (data && data.msg) { + this.$alert(data.msg, '提示', { confirmButtonText: '确定' }) + } + } + }).catch((error) => { + this.allocDetailList = [] + this.$message.error(error.message || '查询指定物料清单失败') + }).finally(() => { + this.allocDetailLoading = false }) }, /** - * 兼容旧入口的海安推送占位方法,避免历史按钮调用空指针 - rqrq + * 打开指定物料策略弹窗:以订单行itemNo+BOM行号隔离当前物料;未下达不允许指定 - rqrq + * @param row 材料明细页签中的物料行 */ - pushToWcs (row) { - this.previewInventory(row) + openNoOrderMaterialAllocDialog (row) { + if (!this.currentRow || this.currentRow.status !== 'ISSUE') { + this.$alert('未下达申请单不允许指定物料', '提示', { confirmButtonText: '确定' }) + return + } + const parentItemNo = row.itemNo + const bomItemNo = row.bOMItemNo || row.BOMItemNo || row.bomItemNo || row.bomitemNo + if (parentItemNo == null || parentItemNo === '') { + this.$alert('当前材料行缺少订单序号,无法指定物料', '提示', { confirmButtonText: '确定' }) + return + } + if (!bomItemNo) { + this.$alert('当前材料行缺少BOM行号,无法指定物料', '提示', { confirmButtonText: '确定' }) + return + } + this.noOrderAllocForm = { + site: this.$store.state.user.site, + notifyNo: this.currentRow.notifyNo, + itemNo: parentItemNo, + bOMItemNo: bomItemNo, + partNo: row.partNo || row.componentPartNo || '', + partDesc: row.partDesc || row.componentPartDesc || '', + subSite: row.subSite || (this.currentRow && this.currentRow.subSite) || this.$store.state.user.site, + qtyToIssue: row.qtyToIssue == null || row.qtyToIssue === '' ? 0 : row.qtyToIssue, + allocList: [] + } + this.noOrderAllocDialogVisible = true + this.noOrderAllocLoading = true + getNoOrderMaterialAllocList(this.noOrderAllocForm).then(({ data }) => { + if (data && data.code === 0) { + this.noOrderAllocForm.allocList = (data.rows || []).map((item, index) => ({ + ...item, + rowNo: index + 1 + })) + } else { + this.noOrderAllocForm.allocList = [] + if (data && data.msg) { + this.$alert(data.msg, '提示', { confirmButtonText: '确定' }) + } + } + }).catch((error) => { + this.$message.error(error.message || '查询指定策略失败') + this.noOrderAllocForm.allocList = [] + }).finally(() => { + this.noOrderAllocLoading = false + }) + }, + /** 新增一条指定策略行:LABEL走标签指定,BATCH走批次指定 - rqrq */ + addNoOrderAllocRow (allocType) { + this.noOrderAllocForm.allocList.push({ + allocType, + serialNo: '', + batchNo: '', + allocQty: '', + subSite: this.noOrderAllocForm.subSite, + allocStatus: 'NEW', + remark: '' + }) + this.refreshNoOrderAllocRowNo() + }, + openNoOrderAvailableLabelDialog (index, pickMode) { + if (!this.noOrderAllocForm.subSite) { + this.$alert('缺少子站点,无法查询在库标签', '提示', { confirmButtonText: '确定' }) + return + } + if (!this.noOrderAllocForm.partNo) { + this.$alert('缺少物料号,无法查询在库标签', '提示', { confirmButtonText: '确定' }) + return + } + this.noOrderLabelPickIndex = index + this.noOrderLabelPickMode = pickMode + this.noOrderLabelPickList = [] + this.noOrderLabelPickDialogVisible = true + this.noOrderLabelPickLoading = true + getNoOrderAvailableInStockLabelList({ + site: this.$store.state.user.site, + subSite: this.noOrderAllocForm.subSite, + partNo: this.noOrderAllocForm.partNo, + page: 1, + limit: 20 + }).then(({ data }) => { + if (data && data.code === 0) { + this.noOrderLabelPickList = data.rows || [] + } else { + this.noOrderLabelPickList = [] + this.$alert((data && data.msg) || '查询在库可用标签失败', '提示', { confirmButtonText: '确定' }) + } + }).catch((error) => { + this.noOrderLabelPickList = [] + this.$message.error(error.message || '查询在库可用标签失败') + }).finally(() => { + this.noOrderLabelPickLoading = false + }) + }, + handleNoOrderAvailableLabelDblClick (row) { + const target = this.noOrderAllocForm.allocList[this.noOrderLabelPickIndex] + if (!target) { + this.$message.warning('未找到待回填的指定行') + return + } + const labelQty = row.qty == null || row.qty === '' ? 0 : row.qty + if (this.noOrderLabelPickMode === 'LABEL') { + if (!row.serialNo) { + this.$alert('所选行缺少标签号,无法指定', '提示', { confirmButtonText: '确定' }) + return + } + target.serialNo = row.serialNo + target.batchNo = '' + target.allocQty = labelQty + } else { + if (!row.batchNo) { + this.$alert('所选标签缺少批次号,无法指定批次', '提示', { confirmButtonText: '确定' }) + return + } + target.serialNo = '' + target.batchNo = row.batchNo + target.allocQty = labelQty + } + this.noOrderLabelPickDialogVisible = false }, + removeNoOrderAllocRow (index) { + this.noOrderAllocForm.allocList.splice(index, 1) + this.refreshNoOrderAllocRowNo() + }, + moveNoOrderAllocRow (index, step) { + const targetIndex = index + step + if (targetIndex < 0 || targetIndex >= this.noOrderAllocForm.allocList.length) { + return + } + const rows = this.noOrderAllocForm.allocList + const current = rows.splice(index, 1)[0] + rows.splice(targetIndex, 0, current) + this.refreshNoOrderAllocRowNo() + }, + refreshNoOrderAllocRowNo () { + ;(this.noOrderAllocForm.allocList || []).forEach((row, index) => { + row.rowNo = index + 1 + }) + }, + saveNoOrderMaterialAlloc () { + if (!this.currentRow || this.currentRow.status !== 'ISSUE') { + this.$alert('未下达申请单不允许指定物料', '提示', { confirmButtonText: '确定' }) + return + } + this.refreshNoOrderAllocRowNo() + const payload = JSON.parse(JSON.stringify(this.noOrderAllocForm)) + payload.allocList = (payload.allocList || []).map((row) => ({ + ...row, + allocQty: row.allocQty === '' || row.allocQty == null ? null : Number(row.allocQty) + })) + this.noOrderAllocSaving = true + saveNoOrderMaterialAllocList(payload).then(({ data }) => { + if (data && data.code === 0) { + this.$message.success('指定策略保存成功') + this.noOrderAllocDialogVisible = false + this.searchNoOrderMaterialAllocListByNotifyNo() + } else if (data) { + this.$alert(data.msg || '保存失败', '提示', { confirmButtonText: '确定' }) + } + }).catch((error) => { + this.$message.error(error.message || '保存指定策略失败') + }).finally(() => { + this.noOrderAllocSaving = false + }) + }, + /** * 海安取消下达流程:先检查未下达冲突,再执行取消并刷新列表 - rqrq */ @@ -2626,24 +3070,6 @@ export default { return data.page.list || [] } return [] - }, - /** - * 销售发料WCS预览:按海安复刻约束保持关闭,避免触发真实推送链路 - rqrq - */ - previewInventory () { - this.$message.warning('海安销售发料WCS推送功能暂不启用') - }, - /** - * 销售发料WCS推送:按复刻要求注掉推送,仅保留提示 - rqrq - */ - pushToWCS () { - this.$message.warning('海安销售发料WCS推送功能暂不启用') - }, - /** - * 兼容旧按钮入口:统一走关闭提示,不触发任何后端推送接口 - rqrq - */ - pushToWcs () { - this.$message.warning('海安销售发料WCS推送功能暂不启用') } }, @@ -2729,4 +3155,17 @@ export default { /deep/ .el-table .danger-row:hover > td { background-color: #fde2e2 !important; } + +/* 指定明细使用缩进和浅色文字形成物料行下展开的视觉关系 - rqrq */ +/deep/ .el-table .specified-preview-row .specified-content { + display: inline-block; + padding-left: 18px; + color: #606266; +} + +/deep/ .matched-labels { + white-space: normal; + word-break: break-all; + line-height: 1.5; +} diff --git a/src/views/modules/haianWarehouse/shopOrderIssueNotify/searchIssureNotify54.vue b/src/views/modules/haianWarehouse/shopOrderIssueNotify/searchIssureNotify54.vue index ee168b0..044c3ad 100644 --- a/src/views/modules/haianWarehouse/shopOrderIssueNotify/searchIssureNotify54.vue +++ b/src/views/modules/haianWarehouse/shopOrderIssueNotify/searchIssureNotify54.vue @@ -212,6 +212,40 @@ style="width: 100px; height: 80px"/> + + + + + +
+ + + + + + + + + + + + + + @@ -444,95 +478,179 @@ - + + :close-on-click-modal="false" + v-drag + width="70%"> + + + + + {{ getAreaDisplayText(currentProductionArea) }} + + + - - - + + - + + - + + - + + - + - + + + + - + - - {{ previewLoading ? '推送中...' : '推送至WCS' }} + + {{ pushLoading ? '推送中...' : '推送至WCS' }} - 关闭 + 关闭 + + + + + + + + + + + + + + + + +
+ 新增标签指定 + 新增批次指定 + 保存后按当前列表顺序进行指定匹配 +
+ + + + + + + + + + + + + + + + + + + + 保存 + 关闭 + +
+ + + + + + + + + + + + + 关闭 + + + @@ -553,7 +671,11 @@ import { haiAnGetSOSBOMForIssureNew, haiAnSaveMaterialDetail, haiAnCheckIssueNotifyInventory, - haiAnPushInventoryToWcs + haiAnPushInventoryToWcs, + getNoOrderMaterialAllocList, + saveNoOrderMaterialAllocList, + getNoOrderAvailableInStockLabelList, + getNoOrderMaterialAllocListByNotifyNo } from '@/api/haianWarehouse/searchIssureNotify.js' export default { @@ -1408,7 +1530,39 @@ export default { // 预览相关数据 previewDialogVisible: false, previewLoading: false, + pushLoading: false, previewData: [], + previewSummary: { + totalOrderCount: 0, + completeOrderCount: 0, + pushableOrderCount: 0, + pushableOrderNos: [], + completeOrderNos: [] + }, + currentNotifyRow: null, + areaOptions: [], + currentProductionArea: '', + allocDetailList: [], + allocDetailLoading: false, + noOrderAllocDialogVisible: false, + noOrderAllocLoading: false, + noOrderAllocSaving: false, + noOrderAllocForm: { + site: this.$store.state.user.site, + notifyNo: '', + itemNo: '', + bOMItemNo: '', + partNo: '', + partDesc: '', + subSite: '', + qtyToIssue: 0, + allocList: [] + }, + noOrderLabelPickDialogVisible: false, + noOrderLabelPickLoading: false, + noOrderLabelPickList: [], + noOrderLabelPickIndex: -1, + noOrderLabelPickMode: 'LABEL', // 物料明细对话框相关数据 materialModalFlag: false, sobomList: [], @@ -1447,6 +1601,14 @@ export default { // 补充海安标签扩展列,确保预留标签页签能展示海安增强字段 - rqrq this.haiAnEnsureLabelColumns() }, + computed: { + /** + * 只有服务端本次匹配判定的完整订单才允许确认推送,前端不自行按标签数量推断 - rqrq + */ + canPushPreview () { + return !this.previewLoading && !this.pushLoading && this.previewSummary.pushableOrderCount > 0 + } + }, methods: { // 每页数 sizeChangeHandle (val) { @@ -2132,6 +2294,8 @@ export default { haiAnSearchNotifyLogCloseNew(queryData).then(({ data }) => { this.dataList6 = data && data.code === 0 ? (data.rows || []) : [] }) + } else if (this.activeName === 'allocDetail') { + this.searchNoOrderMaterialAllocListByNotifyNo() } else if (this.activeName === 'labelDetail') { haiAnSearchMaterialListDetail(queryData).then(({ data }) => { this.dataList7 = data && data.code === 0 ? (data.rows || []) : [] @@ -2225,72 +2389,352 @@ export default { }) }, /** - * 海安库存预览当前为占位实现,保留入口并给出待开发提示 - rqrq + * 海安查看页WCS预览:服务端重新执行匹配,前端只展示物料汇总和指定明细 - rqrq + * @param row 当前申请单主表行 - rqrq */ previewInventory (row) { + if (!row || !row.notifyNo) { + this.$alert('请选择有效的海安申请单', '提示', {confirmButtonText: '确定'}) + return + } this.currentRow = row + this.currentNotifyRow = JSON.parse(JSON.stringify(row)) + this.currentProductionArea = row.productionArea || '' + this.previewData = [] + this.previewSummary = { + totalOrderCount: 0, + completeOrderCount: 0, + pushableOrderCount: 0, + pushableOrderNos: [], + completeOrderNos: [] + } this.previewDialogVisible = true this.previewLoading = true - this.previewData = [] - const inData = { - site: this.$store.state.user.site, + const queryData = { + site: row.site || this.$store.state.user.site, notifyNo: row.notifyNo } - haiAnCheckIssueNotifyInventory(inData).then(({ data }) => { - this.previewLoading = false - if (data && data.code === 0) { - this.previewData = data.rows || [] - if (data.placeholder) { - this.$message.warning(data.msg || '海安库存预览待开发') + haiAnCheckIssueNotifyInventory(queryData) + .then(({data}) => { + if (data && data.code === 0) { + this.previewData = data.rows || [] + if (!this.currentProductionArea && this.previewData.length) { + const firstAreaRow = this.previewData.find(item => item.productionArea) + this.currentProductionArea = firstAreaRow ? firstAreaRow.productionArea : '' + } + this.previewSummary = { + totalOrderCount: data.totalOrderCount || 0, + completeOrderCount: data.completeOrderCount || 0, + pushableOrderCount: data.pushableOrderCount || 0, + pushableOrderNos: data.pushableOrderNos || [], + completeOrderNos: data.completeOrderNos || [] + } + if (data.placeholder) { + this.$alert(data.msg || '该海安页面暂不执行真实库存匹配', '提示', {confirmButtonText: '确定'}) + } else if (!this.previewData.length || !this.previewSummary.totalOrderCount) { + this.$alert('服务端未返回有效匹配结果,本次不能推送', '提示', {confirmButtonText: '确定'}) + } + } else { + this.previewData = [] + this.$alert((data && data.msg) || '库存匹配失败', '错误', {confirmButtonText: '确定'}) } - return - } - this.$alert(data.msg, '错误', { - confirmButtonText: '确定' }) - }).catch(() => { - this.previewLoading = false - this.$message.error('获取库存预览失败') - }) + .catch((error) => { + this.previewData = [] + this.$message.error((error && error.message) || '库存匹配请求失败') + }) + .finally(() => { + this.previewLoading = false + }) + }, + /** + * 关闭预览时清理上次匹配结果,避免不同申请单之间误用摘要 - rqrq + */ + closePreviewDialog (force) { + if (!force && (this.previewLoading || this.pushLoading)) { + return + } + this.previewDialogVisible = false + this.previewData = [] + this.previewSummary = { + totalOrderCount: 0, + completeOrderCount: 0, + pushableOrderCount: 0, + pushableOrderNos: [], + completeOrderNos: [] + } + }, + /** + * 目的地展示文本:有区域名称时拼编码+名称,没有则回退编码或未设置 - rqrq + */ + getAreaDisplayText(areaId) { + if (!areaId) return '未设置' + const area = (this.areaOptions || []).find(item => item.areaId === areaId) + if (area) { + return area.areaId + ' - ' + area.areaDesc + } + return areaId }, /** - * 海安推送WCS当前为占位实现,仅提示待开发并不触发真实推送 - rqrq + * 根据物料或指定明细自身的匹配结果设置颜色,失败统一标红 - rqrq + */ + getRowClassName ({row}) { + const classNames = [] + if (row && row.displayRowType === 'SPECIFIED') classNames.push('specified-preview-row') + if (row && row.matchStatus === 'FAILED') classNames.push('danger-row') + if (row && row.matchStatus === 'MATCHED') classNames.push('success-row') + return classNames.join(' ') + }, + /** + * 数量展示去除无意义尾零,空值统一显示0 - rqrq + */ + formatPreviewQty (value) { + if (value === null || value === undefined || value === '') return '0' + return String(value).replace(/(\.\d*?[1-9])0+$|\.0+$/, '$1') + }, + /** + * 海安查看页确认推送:只提交site和notifyNo,实际订单和标签由服务端重新匹配决定 - rqrq */ pushToWCS () { - const validData = this.previewData || [] - this.$confirm(`确认推送 ${validData.length} 条数据至WCS?`, '提示', { - confirmButtonText: '确定', + if (!this.canPushPreview || !this.currentNotifyRow) { + this.$message.warning('当前没有可推送的完整订单') + return + } + const orderNos = this.previewSummary.pushableOrderNos || [] + const total = this.previewSummary.totalOrderCount || 0 + const message = `共有${total}个订单,其中${orderNos.length}个订单完全匹配,本次只推送单据${orderNos.join('、')}` + this.$confirm(message, '确认推送', { + confirmButtonText: '确定推送', cancelButtonText: '取消', type: 'warning' }).then(() => { - this.previewLoading = true - const inData = { - site: this.$store.state.user.site, - notifyNo: this.currentRow.notifyNo, - inventoryList: validData - } - haiAnPushInventoryToWcs(inData).then(({ data }) => { - this.previewLoading = false + this.pushLoading = true + haiAnPushInventoryToWcs({ + site: this.currentNotifyRow.site || this.$store.state.user.site, + notifyNo: this.currentNotifyRow.notifyNo + }).then(({data}) => { if (data && data.code === 0) { - this.$message.warning(data.msg || '海安推送WCS待开发') - this.previewDialogVisible = false - return + const result = data.row || {} + this.$message.success(result.message || data.msg || '推送WCS成功') + this.closePreviewDialog(true) + this.searchTable() + this.refreshCurrentTabTable() + } else { + this.$alert((data && data.msg) || '推送WCS失败', '错误', {confirmButtonText: '确定'}) } - this.$alert(data.msg || '推送失败', '错误', { - confirmButtonText: '确定' - }) }).catch((error) => { - this.previewLoading = false - this.$message.error(error.message || '推送WCS失败,请重试') + this.$message.error((error && error.message) || '推送WCS请求失败') + }).finally(() => { + this.pushLoading = false }) + }).catch(() => {}) + }, + /** + * 兼容旧按钮入口,与新确认推送方法保持同一幂等防护 - rqrq + */ + pushToWcs () { + return this.pushToWCS() + }, + /** + * 查询当前申请单指定物料清单:按site+notifyNo拉取全部指定行,不含备注 - rqrq + */ + searchNoOrderMaterialAllocListByNotifyNo() { + if (!this.currentRow || !this.currentRow.notifyNo) { + this.allocDetailList = [] + return + } + this.allocDetailLoading = true + getNoOrderMaterialAllocListByNotifyNo({ + site: this.currentRow.site || this.$store.state.user.site, + notifyNo: this.currentRow.notifyNo, + page: 1, + limit: 20 + }).then(({ data }) => { + if (data && data.code === 0) { + this.allocDetailList = data.rows || [] + } else { + this.allocDetailList = [] + if (data && data.msg) { + this.$alert(data.msg, '提示', { confirmButtonText: '确定' }) + } + } + }).catch((error) => { + this.allocDetailList = [] + this.$message.error(error.message || '查询指定物料清单失败') + }).finally(() => { + this.allocDetailLoading = false }) }, /** - * 兼容旧入口的海安推送占位方法,避免历史按钮调用空指针 - rqrq + * 打开指定物料策略弹窗:以订单行itemNo+BOM行号隔离当前物料;未下达不允许指定 - rqrq + * @param row 材料明细页签中的物料行 */ - pushToWcs (row) { - this.previewInventory(row) + openNoOrderMaterialAllocDialog (row) { + if (!this.currentRow || this.currentRow.status !== 'ISSUE') { + this.$alert('未下达申请单不允许指定物料', '提示', { confirmButtonText: '确定' }) + return + } + const parentItemNo = row.itemNo + const bomItemNo = row.bOMItemNo || row.BOMItemNo || row.bomItemNo || row.bomitemNo + if (parentItemNo == null || parentItemNo === '') { + this.$alert('当前材料行缺少订单序号,无法指定物料', '提示', { confirmButtonText: '确定' }) + return + } + if (!bomItemNo) { + this.$alert('当前材料行缺少BOM行号,无法指定物料', '提示', { confirmButtonText: '确定' }) + return + } + this.noOrderAllocForm = { + site: this.$store.state.user.site, + notifyNo: this.currentRow.notifyNo, + itemNo: parentItemNo, + bOMItemNo: bomItemNo, + partNo: row.partNo || row.componentPartNo || '', + partDesc: row.partDesc || row.componentPartDesc || '', + subSite: row.subSite || (this.currentRow && this.currentRow.subSite) || this.$store.state.user.site, + qtyToIssue: row.qtyToIssue == null || row.qtyToIssue === '' ? 0 : row.qtyToIssue, + allocList: [] + } + this.noOrderAllocDialogVisible = true + this.noOrderAllocLoading = true + getNoOrderMaterialAllocList(this.noOrderAllocForm).then(({ data }) => { + if (data && data.code === 0) { + this.noOrderAllocForm.allocList = (data.rows || []).map((item, index) => ({ + ...item, + rowNo: index + 1 + })) + } else { + this.noOrderAllocForm.allocList = [] + if (data && data.msg) { + this.$alert(data.msg, '提示', { confirmButtonText: '确定' }) + } + } + }).catch((error) => { + this.$message.error(error.message || '查询指定策略失败') + this.noOrderAllocForm.allocList = [] + }).finally(() => { + this.noOrderAllocLoading = false + }) + }, + /** 新增一条指定策略行:LABEL走标签指定,BATCH走批次指定 - rqrq */ + addNoOrderAllocRow (allocType) { + this.noOrderAllocForm.allocList.push({ + allocType, + serialNo: '', + batchNo: '', + allocQty: '', + subSite: this.noOrderAllocForm.subSite, + allocStatus: 'NEW', + remark: '' + }) + this.refreshNoOrderAllocRowNo() + }, + openNoOrderAvailableLabelDialog (index, pickMode) { + if (!this.noOrderAllocForm.subSite) { + this.$alert('缺少子站点,无法查询在库标签', '提示', { confirmButtonText: '确定' }) + return + } + if (!this.noOrderAllocForm.partNo) { + this.$alert('缺少物料号,无法查询在库标签', '提示', { confirmButtonText: '确定' }) + return + } + this.noOrderLabelPickIndex = index + this.noOrderLabelPickMode = pickMode + this.noOrderLabelPickList = [] + this.noOrderLabelPickDialogVisible = true + this.noOrderLabelPickLoading = true + getNoOrderAvailableInStockLabelList({ + site: this.$store.state.user.site, + subSite: this.noOrderAllocForm.subSite, + partNo: this.noOrderAllocForm.partNo, + page: 1, + limit: 20 + }).then(({ data }) => { + if (data && data.code === 0) { + this.noOrderLabelPickList = data.rows || [] + } else { + this.noOrderLabelPickList = [] + this.$alert((data && data.msg) || '查询在库可用标签失败', '提示', { confirmButtonText: '确定' }) + } + }).catch((error) => { + this.noOrderLabelPickList = [] + this.$message.error(error.message || '查询在库可用标签失败') + }).finally(() => { + this.noOrderLabelPickLoading = false + }) + }, + handleNoOrderAvailableLabelDblClick (row) { + const target = this.noOrderAllocForm.allocList[this.noOrderLabelPickIndex] + if (!target) { + this.$message.warning('未找到待回填的指定行') + return + } + const labelQty = row.qty == null || row.qty === '' ? 0 : row.qty + if (this.noOrderLabelPickMode === 'LABEL') { + if (!row.serialNo) { + this.$alert('所选行缺少标签号,无法指定', '提示', { confirmButtonText: '确定' }) + return + } + target.serialNo = row.serialNo + target.batchNo = '' + target.allocQty = labelQty + } else { + if (!row.batchNo) { + this.$alert('所选标签缺少批次号,无法指定批次', '提示', { confirmButtonText: '确定' }) + return + } + target.serialNo = '' + target.batchNo = row.batchNo + target.allocQty = labelQty + } + this.noOrderLabelPickDialogVisible = false + }, + removeNoOrderAllocRow (index) { + this.noOrderAllocForm.allocList.splice(index, 1) + this.refreshNoOrderAllocRowNo() + }, + moveNoOrderAllocRow (index, step) { + const targetIndex = index + step + if (targetIndex < 0 || targetIndex >= this.noOrderAllocForm.allocList.length) { + return + } + const rows = this.noOrderAllocForm.allocList + const current = rows.splice(index, 1)[0] + rows.splice(targetIndex, 0, current) + this.refreshNoOrderAllocRowNo() + }, + refreshNoOrderAllocRowNo () { + ;(this.noOrderAllocForm.allocList || []).forEach((row, index) => { + row.rowNo = index + 1 + }) + }, + saveNoOrderMaterialAlloc () { + if (!this.currentRow || this.currentRow.status !== 'ISSUE') { + this.$alert('未下达申请单不允许指定物料', '提示', { confirmButtonText: '确定' }) + return + } + this.refreshNoOrderAllocRowNo() + const payload = JSON.parse(JSON.stringify(this.noOrderAllocForm)) + payload.allocList = (payload.allocList || []).map((row) => ({ + ...row, + allocQty: row.allocQty === '' || row.allocQty == null ? null : Number(row.allocQty) + })) + this.noOrderAllocSaving = true + saveNoOrderMaterialAllocList(payload).then(({ data }) => { + if (data && data.code === 0) { + this.$message.success('指定策略保存成功') + this.noOrderAllocDialogVisible = false + this.searchNoOrderMaterialAllocListByNotifyNo() + } else if (data) { + this.$alert(data.msg || '保存失败', '提示', { confirmButtonText: '确定' }) + } + }).catch((error) => { + this.$message.error(error.message || '保存指定策略失败') + }).finally(() => { + this.noOrderAllocSaving = false + }) }, + /** * 海安取消下达流程:先检查未下达冲突,再执行取消并刷新列表 - rqrq */ @@ -2578,4 +3022,17 @@ export default { /deep/ .el-table .danger-row:hover > td { background-color: #fde2e2 !important; } + +/* 指定明细使用缩进和浅色文字形成物料行下展开的视觉关系 - rqrq */ +/deep/ .el-table .specified-preview-row .specified-content { + display: inline-block; + padding-left: 18px; + color: #606266; +} + +/deep/ .matched-labels { + white-space: normal; + word-break: break-all; + line-height: 1.5; +}