|
|
@@ -101,6 +101,7 @@
|
|
|
ref="inventoryTableref"
|
|
|
:orderId="form.orderId"
|
|
|
:productType="1"
|
|
|
+ :planWarehouse="planWarehouse"
|
|
|
></inventoryTable>
|
|
|
</el-tab-pane>
|
|
|
|
|
|
@@ -147,6 +148,7 @@
|
|
|
import inventoryTable from './inventoryTable.vue';
|
|
|
import orderListDialog from '../../invoice/components/orderListDialog.vue';
|
|
|
import { getByIdCondition } from '@/api/purchasingManage/purchaseOrder';
|
|
|
+ import { getplanDetail } from '@/api/purchasingManage/purchasePlanManage';
|
|
|
import processSubmitDialog from '@/BIZComponents/processSubmitDialog/processSubmitDialog.vue';
|
|
|
import { getWarehouseListByIds } from '@/api/purchasingManage/returnGoods';
|
|
|
import taskInfoTable from '@/views/saleManage/saleOrder/invoice/components/taskInfoTable.vue';
|
|
|
@@ -213,16 +215,21 @@
|
|
|
// 是否是修改
|
|
|
isUpdate: false,
|
|
|
processSubmitDialogFlag: false,
|
|
|
- businessId: ''
|
|
|
+ businessId: '',
|
|
|
+ // 采购订单关联的采购计划 id / 计划回写的默认仓库映射(按产品匹配)
|
|
|
+ purchasePlanId: '',
|
|
|
+ planWarehouse: null
|
|
|
};
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
- //打开新增编辑弹框
|
|
|
- async open(type, row, orderId) {
|
|
|
+ //打开新增编辑弹框(purchasePlanId:采购订单关联的采购计划,用于带出默认仓库)
|
|
|
+ async open(type, row, orderId, purchasePlanId) {
|
|
|
this.activeName = 'first';
|
|
|
this.title = type === 'add' ? '新增委外发货单' : '修改';
|
|
|
this.row = row;
|
|
|
+ this.purchasePlanId = purchasePlanId || '';
|
|
|
+ this.planWarehouse = null;
|
|
|
if (orderId) {
|
|
|
await this.getPurchaseOrderDetail(orderId);
|
|
|
}
|
|
|
@@ -259,14 +266,53 @@
|
|
|
},
|
|
|
//选择订单回调
|
|
|
changeOrder(obj) {
|
|
|
+ this.purchasePlanId = obj.purchasePlanId || '';
|
|
|
this.getPurchaseOrderDetail(obj.id);
|
|
|
},
|
|
|
+ //采购计划详情取回写的默认仓库,供物品清单预选仓库
|
|
|
+ // 仓库挂在 outputDetailList / detailList 的行上(warehouseId/warehouseName/warehouseCode),
|
|
|
+ // 不是计划顶层字段;按产品建立 产品id/类别id/产品编码 -> 仓库 的映射
|
|
|
+ async getPlanWarehouse(planId) {
|
|
|
+ if (!planId) return null;
|
|
|
+ try {
|
|
|
+ const plan = await getplanDetail(planId);
|
|
|
+ const list =
|
|
|
+ (plan?.outputDetailList?.length
|
|
|
+ ? plan.outputDetailList
|
|
|
+ : plan?.detailList) || [];
|
|
|
+ const warehouseMap = {};
|
|
|
+ list.forEach((item) => {
|
|
|
+ if (!item || !item.warehouseId) return;
|
|
|
+ const warehouse = {
|
|
|
+ warehouseId: item.warehouseId,
|
|
|
+ warehouseName: item.warehouseName || '',
|
|
|
+ warehouseCode: item.warehouseCode || ''
|
|
|
+ };
|
|
|
+ [item.productId, item.categoryId, item.productCode].forEach(
|
|
|
+ (key) => {
|
|
|
+ if (key) warehouseMap[String(key)] = warehouse;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ // 计划行缺少产品标识时,整单共用一个默认仓库
|
|
|
+ if (!warehouseMap.__default) warehouseMap.__default = warehouse;
|
|
|
+ });
|
|
|
+ return Object.keys(warehouseMap).length ? warehouseMap : null;
|
|
|
+ } catch (error) {
|
|
|
+ console.warn('[outsourceSend] 采购计划仓库获取失败', error);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ },
|
|
|
//获取订单详情
|
|
|
async getPurchaseOrderDetail(id) {
|
|
|
this.loading = true;
|
|
|
const data = await getByIdCondition(id, 1);
|
|
|
this.loading = false;
|
|
|
if (data) {
|
|
|
+ // 订单未直接带出仓库时,按关联采购计划回写的默认仓库预选明细行仓库
|
|
|
+ this.planWarehouse =
|
|
|
+ (await this.getPlanWarehouse(
|
|
|
+ this.purchasePlanId || data.purchasePlanId
|
|
|
+ )) || null;
|
|
|
this.$nextTick(() => {
|
|
|
let {
|
|
|
partbId,
|