diff --git a/src/views/modules/haianWarehouse/noOrderIssue/noOrderNotification54.vue b/src/views/modules/haianWarehouse/noOrderIssue/noOrderNotification54.vue index 81a1016..ab62c26 100644 --- a/src/views/modules/haianWarehouse/noOrderIssue/noOrderNotification54.vue +++ b/src/views/modules/haianWarehouse/noOrderIssue/noOrderNotification54.vue @@ -70,7 +70,7 @@ style="cursor: pointer" @click="updateModal(scope.row)">编辑 --> - 关闭 + 关闭 推送WCS @@ -84,50 +84,10 @@ layout="total, sizes, prev, pager, next, jumper"> - - - - - - - - - - - - - - - - - - - 供应商 - - - - - - - - - - - 保存 - 关闭 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 查询 - - - - - - 可选物料 - - - - - - - - - - - - - - - - - 添加>> - 删除<< - - - - 已选物料 - - - - - - - - - - - scope.row.requiredQty = value.match(/^(\d+\.?\d*|\.\d+)$/) ? value : ''" - style="height: 11px; width: 98%;"> - - - - - - - - - - 可选物料 - - - - - - - - - - - - - - - - - - - - - - - - - 添加>> - 删除<< - - - - 已选物料 - - - - - - - - - - - - - scope.row.requiredQty = value.match(/^(\d+\.?\d*|\.\d+)$/) ? value : ''" - style="height: 11px; width: 98%;"> - - - - - - - - - 保存 - 关闭 - - - - - - - - - - - - - - 机台 - - - - - - - 加工中心 - - - - - - - - - - - - - - - - - - - - 查询 - - - - - - - - - {{ scope.row[item.columnProp] }} - - - - - - 选择 - - - - - 关闭 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 全数领料 - - - - - - 保存 - 关闭 - - - - - - - - - - 关闭 - - @@ -721,7 +478,7 @@ 新增标签指定 新增批次指定 - 保存后将自动按标签优先、批次其次排序 + 保存后按当前列表顺序进行指定匹配 @@ -872,8 +629,6 @@ - - @@ -885,8 +640,6 @@ import { saveNoOrderMaterialDetail, getNoOrderMaterialList, updateProductionArea, // rqrq - 导入更新目的地API - getFirstOrderListDetail, // rqrq - 导入获取明细信息API - getAreaOptionsForChange, // rqrq - 导入获取区域下拉框API checkIssueNotifyInventory, pushInventoryToWcs, searchMaterialListDetail, // rqrq - 导入预留标签清单API @@ -894,27 +647,17 @@ import { getNoOrderMaterialAllocList, saveNoOrderMaterialAllocList, getNoOrderAvailableInStockLabelList, - getNoOrderMaterialAllocListByNotifyNo + getNoOrderMaterialAllocListByNotifyNo, + updateNotifyStatusNew, + checkUserHasUnissueNoOrder, + cancelNoOrderIssueNotify } from '@/api/haianWarehouse/noOrderIssueNotify.js' -import { - getSiteAndBuByUserName, - createNotify, - closeInboundNotification, - checkUserHasUnissueShipment, - cancelIssueShipment, - deleteNotifyUnissue, -} from '@/api/shipment/shipmentIssue.js' -import Chooselist from '@/views/modules/common/Chooselist_eam' -import { getChooselist } from '@/api/chooselist/chooselist.js' import { getTableDefaultListLanguage, getTableUserListLanguage, } from '@/api/table.js' export default { name: 'noOrderNotification54', - components: { - Chooselist, - }, data() { return { columnsProp: ['createBy', 'updateBy'], @@ -1850,6 +1593,9 @@ export default { }, searchLoading: false, saveLoading: false, + closeLoading: false, + cancelLoading: false, + deleteLoading: false, activeTable: 'inboundDetail', detailModal: false, authSearch: false, @@ -1915,7 +1661,15 @@ export default { // rqrq - 推送WCS预览相关数据 previewDialogVisible: false, previewLoading: false, + pushLoading: false, previewData: [], + previewSummary: { + totalOrderCount: 0, + completeOrderCount: 0, + pushableOrderCount: 0, + pushableOrderNos: [], + completeOrderNos: [] + }, currentNotifyRow: null, // 当前要推送WCS的通知单行数据 - rqrq areaOptions: [], // 区域下拉框选项 - rqrq currentProductionArea: '', // 当前选择的目的地 - rqrq @@ -1950,6 +1704,15 @@ export default { this.haiAnEnsureSubSiteColumns() }, + computed: { + /** + * 只有服务端本次匹配判定的完整订单才允许确认推送,前端不自行按标签数量推断 - rqrq + */ + canPushPreview () { + return !this.previewLoading && !this.pushLoading && this.previewSummary.pushableOrderCount > 0 + } + }, + methods: { /** * 海安无单查看页动态补充subSite列,避免改造老页面列配置 - rqrq @@ -1998,18 +1761,6 @@ export default { buildColumn('444002Table6', '海安无单预留标签清单表', 'SubSite', 'subSite', '子站点', 90) ) }, - // 获取用户的bu - getSiteAndBuByUserName() { - let tempData = { - username: this.$store.state.user.name, - } - getSiteAndBuByUserName(tempData).then(({ data }) => { - if (data.code === 0) { - this.userBuList = data.rows - } - }) - }, - // 获取数据列表 getDataList() { this.searchData.site = this.$store.state.user.site // rqrq - 设置site @@ -2062,176 +1813,33 @@ export default { }, // 子明细每页数 - sizeChangeHandle2(val) { - this.pageSize2 = val - this.pageIndex2 = 1 - this.searchTypeChange() - }, - - // 子明细当前页 - currentChangeHandle2(val) { - this.pageIndex2 = val - this.searchTypeChange() - }, - - saveModal() { - this.modalData = { - flag: '1', - site: '', - orderNo: '', - orderType: '', - orderStatus: '', - requiredInboundDate: '', - supplierId: '', - supplierName: '', - remarks: '', - createdBy: this.$store.state.user.name, - } - this.modalDisableFlag = false - this.modalFlag = true - }, - - updateModal(row) { - if (this.currentRow.orderType === '采购入库') { - this.$message.warning('采购入库单据不能编辑!') - return - } - this.modalData = { - flag: '2', - site: row.site, - bu: row.site + '_' + row.buNo, - buNo: row.buNo, - orderNo: row.orderNo, - orderType: row.orderType, - requiredInboundDate: row.requiredInboundDate, - supplierId: row.supplierId, - supplierName: row.supplierName, - remarks: row.remarks, - updatedBy: this.$store.state.user.name, - } - this.modalDisableFlag = true - this.modalFlag = true - }, - - saveData() { - if (this.modalData.orderType === '' || this.modalData.orderType == null) { - this.$message.warning('请选择单据类型!') - return - } - if ( - this.modalData.requiredInboundDate === '' || - this.modalData.requiredInboundDate == null - ) { - this.$message.warning('请选择要求入库日期!') - return - } - this.saveLoading = true - if (this.modalData.flag === '1') { - // 新增 - this.modalData.orderType = '退料入库' - this.modalData.site = localStorage.getItem('site') - createNotify(this.modalData) - .then(({ data }) => { - if (data && data.code === 0) { - this.getDataList() - this.modalFlag = false - this.$message.success('操作成功') - } else { - this.$message.error(data.msg) - } - }) - .finally(() => { - this.saveLoading = false - }) - } else { - // 修改 - updateInboundNotification(this.modalData) - .then(({ data }) => { - if (data && data.code === 0) { - this.getDataList() - this.modalFlag = false - this.$message.success('操作成功') - } else { - this.$message.error(data.msg) - } - }) - .finally(() => { - this.saveLoading = false - }) - } - }, - - // 删除 - deleteModal() { - if (this.currentRow.orderType === '采购入库') { - this.$message.warning('采购入库单据不能编辑!') - return - } - if (this.inboundSelection.length === 0) { - this.$message.warning('请勾选要删除的单据!') - return - } - this.$confirm( - `是否删除该 ` + this.inboundSelection.length + ` 条记录?`, - '提示', - { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: 'warning', - } - ).then(() => { - let tempData = { - submitList: this.inboundSelection, - } - deleteInboundNotification(tempData).then(({ data }) => { - if (data && data.code === 0) { - this.getDataList() - this.inboundSelection = [] - this.$message.success('操作成功') - } else { - this.$message.error(data.msg) - } - }) - }) - }, - - // 归档 - archiveModal() {}, - - // 关闭 closeModal(row) { this.$confirm(`确认关闭 ` + row.notifyNo + ` 记录?`, '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning', }).then(() => { - closeInboundNotification(row).then(({ data }) => { + this.closeLoading = true + // 关闭申请单只更新海安主表状态,避免误修改旧模块申请单 - rqrq + updateNotifyStatusNew({ + site: row.site || this.$store.state.user.site, + notifyNo: row.notifyNo, + status: 'CLOSED', + closeRemark: row.closeRemark || '页面操作关闭申请单', + username: this.$store.state.user.name, + }).then(({ data }) => { if (data && data.code === 0) { this.getDataList() this.$message.success('操作成功') } else { this.$message.error(data.msg) } + }).finally(() => { + this.closeLoading = false }) }) }, - // 下达 - issueModal(row) { - if (this.currentRow.orderType === '采购入库') { - this.$message.warning('采购入库单据不能编辑!') - return - } - issueInboundNotification(row).then(({ data }) => { - if (data && data.code === 0) { - this.getDataList() - this.$message.success('操作成功') - } else { - this.$message.error(data.msg) - } - }) - }, - // 列表表格选择替换 tabClick(tab, event) { // 刷新列表数据 @@ -2344,197 +1952,6 @@ export default { }) }, - // 查询物料缺陷跟踪 - getInboundDetail() { - let templateData = { - site: this.currentRow.site, - buNo: this.currentRow.buNo, - orderNo: this.currentRow.orderNo, - } - /* getInboundDetail(templateData).then(({ data }) => { - this.detailList = data.rows - }) */ - }, - - // 新增明细 - addInboundDetailModal() { - if (this.currentRow.orderType === '采购入库') { - this.$message.warning('采购入库单据不能编辑!') - return - } - this.detailSearchData = { - site: this.currentRow.site, - buNo: this.currentRow.buNo, - orderNo: this.currentRow.orderNo, - orderType: this.currentRow.orderType, - relatedOrderNo: '', - status: '', - partNo: '', - partDesc: '', - partNos: '', - page: 1, - limit: 10, - } - this.partSelections1 = [] - this.partSelections2 = [] - this.partList1 = [] - this.partList2 = [] - this.pageIndex2 = 1 - this.pageSize2 = 20 - this.totalPage2 = 0 - if (this.currentRow.orderType === '生产入库') { - this.detailSearchData.status = '已开工' - } - this.handleGetProjectPartList() - }, - - handleGetProjectPartList() { - this.detailSearchData.limit = this.pageSize2 - this.detailSearchData.page = this.pageIndex2 - getInboundPartList(this.detailSearchData).then(({ data }) => { - if (data && data.code === 0) { - this.partList1 = data.page.list - this.pageIndex2 = data.page.currPage - this.pageSize2 = data.page.pageSize - this.totalPage2 = data.page.totalCount - this.detailModal = true - } - }) - }, - - chooseSOSModal() { - this.seqNoData = { - site: localStorage.getItem('site'), - orderno: '', - seqno: '', - sResourceid: '', - sWorkcenterno: '', - operatorId: '', - sShiftno: '', - startDate: this.dayjs().format('YYYY-MM-DD'), - endDate: this.dayjs().format('YYYY-MM-DD'), - } - this.searchSOSRouting() - this.seqNoModalFlag = true - }, - searchSOSRouting() { - getSOScheduledRoutingListForIssure(this.seqNoData).then(({ data }) => { - if (data.code === 0) { - this.seqNoList = data.rows - } - }) - }, - // 可选物料 - partClickRow1(row) { - this.$refs.partTable1.toggleRowSelection(row) - }, - - // 已有物料 - partClickRow2(row) { - this.$refs.partTable2.toggleRowSelection(row) - }, - - selectionPart1(val) { - this.partSelections1 = val - }, - - selectionPart2(val) { - this.partSelections2 = val - }, - chooseSOS(row) { - if (this.dataList.length > 0) { - let stop = false - for (let i = 0; i < this.dataList.length; i++) { - if (this.dataList[i].seqNo == row.seqno) { - stop = true - } - } - if (stop) { - this.$alert('已经选择过此派工单,请返回点击明细直接操作!!', '提示', { - confirmButtonText: '确定', - }) - return false - } - } - - this.notifyOrderData.partNo = row.partNo - this.notifyOrderData.orderNo = row.orderNo - this.notifyOrderData.itemNo = row.itemNo - this.notifyOrderData.seqNo = row.seqNo - this.notifyOrderData.partDesc = row.partDesc - this.notifyOrderData.qtyRequired = row.qtyRequired - this.notifyOrderData.sResourceID = row.sResourceID - this.notifyOrderData.issureQty = '' - this.notifyOrderData.needDate = this.dayjs().format('YYYY-MM-DD HH:mm') - this.notifyOrderData.locationNo = row.sResourceID - this.saveSeqNoModalFlag = true - }, - - qtyAllForSeqNo() { - this.notifyOrderData.issureQty = this.notifyOrderData.qtyRequired - }, - - saveSOS() { - if ( - this.notifyOrderData.needDate == null || - this.notifyOrderData.needDate == '' - ) { - this.$message.warning('请选择时间!') - return false - } - if ( - this.notifyOrderData.issureQty == null || - this.notifyOrderData.issureQty == '' || - this.notifyOrderData.issureQty <= 0 - ) { - this.$message.warning('请填写领取数量!') - return false - } - let row = this.notifyOrderData - if (this.dataList.length > 0) { - let stop = false - for (let i = 0; i < this.dataList.length; i++) { - if (this.dataList[i].seqNo == row.seqno) { - stop = true - } - } - if (stop) { - this.$alert('已经选择过此工单,请返回点击明细直接操作!!', '提示', { - confirmButtonText: '确定', - }) - return false - } - } - this.$confirm('确定选择工单' + row.seqno + '?', '提示', { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: 'warning', - }).then(() => { - let inData = { - site: localStorage.getItem('site'), - notifyNo: this.notifyNo, - fGPartNo: row.partNo, - sOOrderNo: row.orderno, - opsItemNo: row.itemno, - seqNo: row.seqno, - locationNo: row.locationNo, - needDate: row.needDate, - issureQty: row.issureQty, - } - saveSOIssueNotifyOrderList(inData).then(({ data }) => { - if (data.code === 0) { - this.saveSeqNoModalFlag = false - this.getNotifyNoOrderDetailByType() - this.enterSOS(row) - this.itemNo = data.itemNo - } else { - this.$alert(data.msg, '错误', { - confirmButtonText: '确定', - }) - } - }) - }) - }, getNotifyNoOrderDetailByType() { if (!this.currentRow || !this.currentRow.notifyNo) { this.detailList = [] @@ -2558,197 +1975,6 @@ export default { this.detailList = [] }) }, - enterSOS(row) { - this.seqNoModalFlag = false - this.materialModalFlag = true - this.sobomList = [] - this.sobomData = { - orderno: row.orderno, - seqno: row.seqno, - partNo: row.partNo, - } - this.bomLoadFlag = true - let inData = { - site: localStorage.getItem('site'), - notifyNo: this.notifyNo, - orderno: row.orderno, - seqno: row.seqno, - partNo: row.partNo, - itemno: row.itemno, - } - getSOSBOMForIssure(inData).then(({ data }) => { - this.bomLoadFlag = false - if (data.code === 0) { - this.sobomList = data.rows - } - }) - }, - // 改变事件 - searchTypeChange() { - // 使用 map 提取 partNo 并加上单引号 - let partNos = this.partList2.map((part) => part.partNo) - // 使用 join 将 partNo 连接成一个字符串 - this.detailSearchData.partNos = partNos.join(',') - this.handleGetProjectPartList() - }, - - // 添加物料 - addPart() { - if (this.partSelections1 == null || this.partSelections1.length === 0) { - this.$message.warning('请选择可选物料!') - return - } - this.partSelections1.forEach((item) => { - this.partList2.push(item) - }) - this.searchTypeChange() - }, - - // 删除物料 - deletePart() { - if (this.partSelections2 == null || this.partSelections2.length === 0) { - this.$message.warning('请选择已选物料!') - return - } - this.partSelections2.forEach((item) => { - // 使用 filter 过滤掉 partList2 中与 selection.part_no 相同的项 - this.partList2 = this.partList2.filter( - (part) => part.partNo !== item.partNo - ) - }) - this.searchTypeChange() - }, - - // 新增明细 - saveInboundDetail() { - let tempData = { - orderNo: this.detailSearchData.orderNo, - createdBy: this.$store.state.user.name, - partList: this.partList2, - } - this.saveLoading = true - saveInboundDetail(tempData) - .then(({ data }) => { - if (data && data.code === 0) { - this.getInboundDetail() - this.detailModal = false - this.$message.success('操作成功') - } else { - this.$message.error(data.msg) - } - }) - .finally(() => { - this.saveLoading = false - }) - }, - - // 删除物料缺陷跟踪 - deleteInboundDetail() { - if (this.currentRow.orderType === '采购入库') { - this.$message.warning('采购入库单据不能编辑!') - return - } - if (this.inboundDetailSelection.length === 0) { - this.$message.warning('请勾选要删除的单据!') - return - } - this.$confirm( - `是否删除该 ` + this.inboundDetailSelection.length + ` 条记录?`, - '提示', - { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: 'warning', - } - ).then(() => { - let tempData = { - submitList: this.inboundDetailSelection, - } - deleteInboundDetail(tempData).then(({ data }) => { - if (data && data.code === 0) { - this.getInboundDetail() - this.inboundDetailSelection = [] - this.$message.success('操作成功') - } else { - this.$message.error(data.msg) - } - }) - }) - }, - - // 批量编辑模态框 - editBatchModel() { - if (this.currentRow.orderType === '采购入库') { - this.$message.warning('采购入库单据不能编辑!') - return - } - if (this.editBatchVisible) { - this.editBatchVisible = false - } else { - this.editBatchVisible = true - } - }, - - // 批量保存 - batchModel() { - let params = [] - params = this.detailList - this.saveLoading = true - updateInboundDetail(params) - .then(({ data }) => { - if (data && data.code === 0) { - this.getInboundDetail() - this.$message.success(data.msg) - this.editBatchVisible = false - } else { - this.$message.error(data.msg) - } - }) - .finally(() => { - this.saveLoading = false - }) - }, - - // 入库明细 - inboundDetailModal(row) { - getInboundDetail2(row).then(({ data }) => { - if (data && data.code === 0) { - this.detailList2 = data.rows - } else { - this.detailList2 = [] - } - }) - this.detailModal2 = true - }, - - // 库位输入校验 - supplierBlur(tagNo) { - let tempData = { - tagno: tagNo, - conditionSql: - " and SupplierID = '" + - this.modalData.supplierId + - "'" + - " and site = '" + - this.modalData.site + - "'", - } - getChooselist(tempData).then(({ data }) => { - if (data && data.code === 0) { - if (data.baseListData.length > 0) { - this.modalData.supplierId = data.baseListData[0].SupplierID - this.modalData.supplierName = data.baseListData[0].SupplierName - } else { - this.modalData.supplierName = '' - } - } - }) - }, - - chooseWareHouse(row) { - this.tempWareHouseRow = row - this.getBaseList(20) - }, /** * 打开指定物料策略弹窗:以订单行itemNo+BOM行号隔离当前物料 - rqrq @@ -2884,7 +2110,7 @@ export default { }, /** - * 调整指定策略行顺序:保存时后端会再做标签优先规范化 - rqrq + * 调整指定策略行顺序:保存时后端会按当前顺序重新生成allocSeq - rqrq */ moveNoOrderAllocRow (index, step) { const targetIndex = index + step @@ -2907,7 +2133,7 @@ export default { }, /** - * 保存当前物料行指定策略:全量提交后由后端重排alloc_seq - rqrq + * 保存当前物料行指定策略:全量提交后由后端按页面顺序重排alloc_seq - rqrq */ saveNoOrderMaterialAlloc () { this.refreshNoOrderAllocRowNo() @@ -2967,51 +2193,6 @@ export default { }, // 获取基础数据列表S - getBaseList(val, type) { - this.tagNo = val - this.tagType = type - this.$nextTick(() => { - let strVal = '' - if (val === 506) { - strVal = this.modalData.supplierId - this.$refs.baseList.init(val, strVal) - } - if (val === 20) { - strVal = this.tempWareHouseRow.inWarehouse - this.$refs.baseList.init(val, strVal) - } - }) - }, - - // 列表方法的回调 - getBaseData(val) { - if (this.tagNo === 506) { - this.modalData.supplierId = val.SupplierID - this.modalData.supplierName = val.SupplierName - } - if (this.tagNo === 20) { - this.tempWareHouseRow.inWarehouse = val.WareHouseID - this.tempWareHouseRow.inWarehouseName = val.WareHouseName - console.log(this.tempWareHouseRow) - } - }, - - async exportExcel() { - this.searchData.limit = -1 - this.searchData.page = 1 - excel.exportTable({ - url: '/inbound/searchInboundNotification', - columnMapping: this.columnList, //可以直接用table,不需要的列就剔除 - mergeSetting: [], //需要合并的列 - params: this.searchData, - fileName: this.exportName + '.xlsx', - rowFetcher: (res) => res.data, - columnFormatter: [], - dropColumns: [], - }) - }, - - // 动态列开始 获取 用户保存的 格式列 async getTableUserColumn(tableId, columnId) { let queryTableUser = { userId: this.$store.state.user.name, @@ -3279,7 +2460,9 @@ export default { type: 'warning', }) .then(() => { - deleteNotifyUnissue(row).then(({ data }) => { + this.deleteLoading = true + // 删除海安订单行走海安接口,避免误删旧申请单数据 - rqrq + deleteNotifySOS(row).then(({ data }) => { if (data && data.code === 0) { this.getNotifyNoOrderDetailByType() this.$message({ @@ -3293,6 +2476,8 @@ export default { confirmButtonText: '确定', }) } + }).finally(() => { + this.deleteLoading = false }) }) .catch(() => {}) @@ -3349,7 +2534,8 @@ export default { username: row.username, } - checkUserHasUnissueShipment(checkData) + // 取消下达前只检查当前用户的海安无订单申请,避免串到shipment业务 - rqrq + checkUserHasUnissueNoOrder(checkData) .then(({ data }) => { if (data && data.code === 0) { // 如果有未下达的申请单 - rqrq @@ -3376,7 +2562,9 @@ export default { notifyNo: row.notifyNo, } - cancelIssueShipment(cancelData) + this.cancelLoading = true + // 海安无订单取消下达只回退海安主单状态,库存和旧流程不参与 - rqrq + cancelNoOrderIssueNotify(cancelData) .then(({ data }) => { if (data && data.code === 0) { this.$message.success('取消下达成功') @@ -3390,6 +2578,8 @@ export default { }) .catch(() => { this.$message.error('取消下达失败') + }).finally(() => { + this.cancelLoading = false }) }) .catch(() => { @@ -3407,10 +2597,83 @@ export default { }, /** - * 海安无单WCS预览:按复刻约束保持关闭,避免触发真实推送链路 - rqrq + * 海安无单WCS预览:服务端重新执行匹配,前端只展示过程返回结果 - rqrq + * @param row 当前申请单主表行 - rqrq + */ + previewInventory (row) { + if (!row || !row.notifyNo) { + this.$alert('请选择有效的海安申请单', '提示', {confirmButtonText: '确定'}) + return + } + this.currentNotifyRow = JSON.parse(JSON.stringify(row)) + this.currentProductionArea = row.productionArea || '' + this.originalProductionArea = this.currentProductionArea + this.currentOrderType = row.orderType || 'noorder' + this.isDestinationEditable = false + this.previewData = [] + this.previewSummary = { + totalOrderCount: 0, + completeOrderCount: 0, + pushableOrderCount: 0, + pushableOrderNos: [], + completeOrderNos: [] + } + this.previewDialogVisible = true + this.previewLoading = true + const queryData = { + site: row.site || this.$store.state.user.site, + notifyNo: row.notifyNo + } + checkIssueNotifyInventory(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: '确定'}) + } + }) + .catch((error) => { + this.previewData = [] + this.$message.error((error && error.message) || '库存匹配请求失败') + }) + .finally(() => { + this.previewLoading = false + }) + }, + + /** + * 关闭预览时清理上次匹配结果,避免不同申请单之间误用摘要 - rqrq */ - previewInventory () { - this.$message.warning('海安无单申请WCS推送功能暂不启用') + closePreviewDialog (force) { + if (!force && (this.previewLoading || this.pushLoading)) { + return + } + this.previewDialogVisible = false + this.previewData = [] + this.previewSummary = { + totalOrderCount: 0, + completeOrderCount: 0, + pushableOrderCount: 0, + pushableOrderNos: [], + completeOrderNos: [] + } }, /** @@ -3464,31 +2727,98 @@ export default { }, /** - * @Description 根据订单满足状态设置行样式 - rqrq + * 根据服务端事件阶段和失败编码设置预览行颜色,指定阻塞与目标区域失败必须醒目 - rqrq */ - getRowClassName({row}) { - if (row.orderSatisfactionStatus === 1) { - return 'success-row' // 绿色:完全立库满足 - } else if (row.orderSatisfactionStatus === 2) { - return 'warning-row' // 黄色:立库+分切区满足 - } else if (row.orderSatisfactionStatus === 3) { - return 'danger-row' // 红色:存在不满足 + getRowClassName ({row}) { + const failureCode = row && row.failureCode + if (['SPECIFIED_DETAIL_UNAVAILABLE', 'SPECIFIED_DETAIL_SHORTAGE', 'SPECIFIED_DETAIL_INVALID_QTY', 'SPECIFIED_DETAIL_INVALID_TYPE'].indexOf(failureCode) >= 0) { + return 'danger-row' + } + if (['TARGET_AREA', 'SHARED_PALLET_CONFLICT', 'ALREADY_PUSHED'].indexOf(failureCode) >= 0) { + return 'warning-row' + } + if (row && row.matchStatus === 'MATCHED' && row.orderSatisfactionStatus === 'COMPLETE') { + return 'success-row' + } + if (row && row.matchStatus === 'FAILED') { + return 'danger-row' } return '' }, /** - * 海安无单WCS推送:按复刻要求注掉推送,仅保留提示 - rqrq + * 将机器状态转换成现场可读文案,失败时优先显示指定明细或区域阻塞阶段 - rqrq + */ + getMatchStatusText (row) { + if (!row) return '' + if (row.failureCode && row.failureCode.indexOf('SPECIFIED_DETAIL') === 0) return '指定明细阻塞' + if (row.failureCode === 'TARGET_AREA') return '目标区域配置失败' + if (row.failureCode === 'SHARED_PALLET_CONFLICT') return '共享托盘阻塞' + if (row.failureCode === 'ALREADY_PUSHED') return '已存在推送任务' + if (row.failureCode === 'INVENTORY_SHORTAGE') return '普通库存不足' + if (row.matchStatus === 'MATCHED' && row.orderSatisfactionStatus === 'COMPLETE') return '完整满足' + if (row.matchStatus === 'MATCHED') return '已匹配' + if (row.matchStatus === 'FAILED') return '匹配失败' + return '汇总待确认' + }, + + /** + * 返回预览状态颜色,成功、指定阻塞、库存不足和配置失败保持不同视觉层级 - rqrq + */ + getMatchStatusColor (row) { + if (row && row.failureCode && row.failureCode.indexOf('SPECIFIED_DETAIL') === 0) return '#F56C6C' + if (row && (row.failureCode === 'TARGET_AREA' || row.failureCode === 'SHARED_PALLET_CONFLICT' || row.failureCode === 'ALREADY_PUSHED')) return '#E6A23C' + if (row && row.failureCode === 'INVENTORY_SHORTAGE') return '#F56C6C' + if (row && row.matchStatus === 'MATCHED' && row.orderSatisfactionStatus === 'COMPLETE') return '#67C23A' + return '#909399' + }, + + /** + * 海安无单WCS确认推送:只提交site和notifyNo,实际订单和标签由服务端重新匹配决定 - rqrq */ pushToWCS () { - this.$message.warning('海安无单申请WCS推送功能暂不启用') + 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.pushLoading = true + pushInventoryToWcs({ + site: this.currentNotifyRow.site || this.$store.state.user.site, + notifyNo: this.currentNotifyRow.notifyNo + }).then(({data}) => { + if (data && data.code === 0) { + const result = data.row || {} + this.$message.success(result.message || data.msg || '推送WCS成功') + this.closePreviewDialog(true) + // 推送成功后刷新主单、申请物料、指定清单和预留标签清单 - rqrq + this.getDataList() + this.getNotifyNoOrderDetailByType() + this.searchNoOrderMaterialAllocListByNotifyNo() + this.searchMaterialListDetail() + } else { + this.$alert((data && data.msg) || '推送WCS失败', '错误', {confirmButtonText: '确定'}) + } + }).catch((error) => { + this.$message.error((error && error.message) || '推送WCS请求失败') + }).finally(() => { + this.pushLoading = false + }) + }).catch(() => {}) }, /** - * 兼容旧按钮入口:统一走关闭提示,不触发任何后端推送接口 - rqrq + * 兼容旧按钮入口,与新确认推送方法保持同一幂等防护 - rqrq */ pushToWcs () { - this.$message.warning('海安无单申请WCS推送功能暂不启用') + return this.pushToWCS() }, }, }