|
@@ -173,7 +173,7 @@
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
import { getSaleOrderDetails } from '@/api/saleManage/saleorder';
|
|
import { getSaleOrderDetails } from '@/api/saleManage/saleorder';
|
|
|
- import { getInfoBySourceBizNoAll } from '@/api/wms';
|
|
|
|
|
|
|
+ import { getBatchList } from '@/api/wms';
|
|
|
import { mapGetters } from 'vuex';
|
|
import { mapGetters } from 'vuex';
|
|
|
import { saveAs } from 'file-saver';
|
|
import { saveAs } from 'file-saver';
|
|
|
export default {
|
|
export default {
|
|
@@ -203,43 +203,62 @@
|
|
|
methods: {
|
|
methods: {
|
|
|
async open(id) {
|
|
async open(id) {
|
|
|
const list = await getSaleOrderDetails(id);
|
|
const list = await getSaleOrderDetails(id);
|
|
|
- // 逐单查询出库单信息,补充裁剪米段/盘具字段(销售订单明细缺省时)
|
|
|
|
|
this.formData = await Promise.all(
|
|
this.formData = await Promise.all(
|
|
|
list.map(async (wrapperItem) => {
|
|
list.map(async (wrapperItem) => {
|
|
|
- let outInDetailList = [];
|
|
|
|
|
- try {
|
|
|
|
|
- const outboundList = await getInfoBySourceBizNoAll(
|
|
|
|
|
- wrapperItem.orderNo
|
|
|
|
|
- );
|
|
|
|
|
- outInDetailList = outboundList?.[0]?.outInDetailList || [];
|
|
|
|
|
- } catch (e) {
|
|
|
|
|
- outInDetailList = [];
|
|
|
|
|
- }
|
|
|
|
|
- const productList = (wrapperItem.productList || []).map((item) => {
|
|
|
|
|
- const candidates = outInDetailList.filter(
|
|
|
|
|
- (detail) =>
|
|
|
|
|
- detail.categoryCode === item.productCode ||
|
|
|
|
|
- String(detail.categoryId) === String(item.productId)
|
|
|
|
|
- );
|
|
|
|
|
- const outDetail =
|
|
|
|
|
- candidates.find(
|
|
|
|
|
- (detail) =>
|
|
|
|
|
- (item.batchNo && detail.batchNo === item.batchNo) ||
|
|
|
|
|
- (item.systemBatchNo && detail.systemBatchNo === item.systemBatchNo)
|
|
|
|
|
- ) || (candidates.length === 1 ? candidates[0] : {});
|
|
|
|
|
- return {
|
|
|
|
|
- ...item,
|
|
|
|
|
- batchNo: item.batchNo || outDetail.batchNo || '',
|
|
|
|
|
- cuttingLength: item.cuttingLength || outDetail.cuttingLength || '',
|
|
|
|
|
- reelSpecification:
|
|
|
|
|
- item.reelSpecification || outDetail.reelSpecification || ''
|
|
|
|
|
- };
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ const batchRowsCache = new Map();
|
|
|
|
|
+ // 同一批次只查一次 WMS 批次台账,避免明细多时重复请求
|
|
|
|
|
+ const getBatchRowsByItem = (item) => {
|
|
|
|
|
+ const key = item.batchNo || item.systemBatchNo;
|
|
|
|
|
+ if (!key) {
|
|
|
|
|
+ return Promise.resolve([]);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!batchRowsCache.has(key)) {
|
|
|
|
|
+ batchRowsCache.set(key, this.getBatchRows(item));
|
|
|
|
|
+ }
|
|
|
|
|
+ return batchRowsCache.get(key);
|
|
|
|
|
+ };
|
|
|
|
|
+ const productList = await Promise.all(
|
|
|
|
|
+ (wrapperItem.productList || []).map(async (item) => {
|
|
|
|
|
+ const batchRows = await getBatchRowsByItem(item);
|
|
|
|
|
+ const candidates = batchRows.filter(
|
|
|
|
|
+ (row) =>
|
|
|
|
|
+ row.categoryCode === item.productCode ||
|
|
|
|
|
+ String(row.categoryId) === String(item.productId)
|
|
|
|
|
+ );
|
|
|
|
|
+ const batchDetail =
|
|
|
|
|
+ candidates.find((row) => item.batchNo && row.batchNo === item.batchNo) ||
|
|
|
|
|
+ (candidates.length === 1 ? candidates[0] : {});
|
|
|
|
|
+ return {
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ batchNo: item.batchNo || batchDetail.batchNo || '',
|
|
|
|
|
+ cuttingLength: item.cuttingLength || '',
|
|
|
|
|
+ reelSpecification: item.reelSpecification || batchDetail.reelSpecification || ''
|
|
|
|
|
+ };
|
|
|
|
|
+ })
|
|
|
|
|
+ );
|
|
|
return { ...wrapperItem, productList };
|
|
return { ...wrapperItem, productList };
|
|
|
})
|
|
})
|
|
|
);
|
|
);
|
|
|
this.QRvisible = true;
|
|
this.QRvisible = true;
|
|
|
},
|
|
},
|
|
|
|
|
+
|
|
|
|
|
+ // 按物品批次查询 WMS 批次库存台账,返回可匹配的候选行
|
|
|
|
|
+ async getBatchRows(item) {
|
|
|
|
|
+ if (!item.batchNo && !item.systemBatchNo) {
|
|
|
|
|
+ return [];
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ const page = await getBatchList({
|
|
|
|
|
+ batchNo: item.batchNo || undefined,
|
|
|
|
|
+ systemBatchNo: item.systemBatchNo || undefined,
|
|
|
|
|
+ pageNum: 1,
|
|
|
|
|
+ size: 100
|
|
|
|
|
+ });
|
|
|
|
|
+ return page?.list || [];
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ return [];
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
close() {
|
|
close() {
|
|
|
this.QRvisible = false;
|
|
this.QRvisible = false;
|
|
|
},
|
|
},
|