|
@@ -420,7 +420,10 @@
|
|
|
import outboundDetailsDialog from './outboundDetailsDialog.vue';
|
|
import outboundDetailsDialog from './outboundDetailsDialog.vue';
|
|
|
import taskinstanceDialog from '@/BIZComponents/procedure/taskinstanceDialog.vue';
|
|
import taskinstanceDialog from '@/BIZComponents/procedure/taskinstanceDialog.vue';
|
|
|
import { lbjtList, orderSourceType, pricingWayList } from '@/enum/dict.js';
|
|
import { lbjtList, orderSourceType, pricingWayList } from '@/enum/dict.js';
|
|
|
- import { parameterGetByCode } from '@/api/main/index.js';
|
|
|
|
|
|
|
+ import {
|
|
|
|
|
+ getDefaultWarehouseId,
|
|
|
|
|
+ parameterGetByCode
|
|
|
|
|
+ } from '@/api/main/index.js';
|
|
|
import tabMixins from '@/mixins/tableColumnsMixin';
|
|
import tabMixins from '@/mixins/tableColumnsMixin';
|
|
|
import productListMain from '@/BIZComponents/product-list.vue';
|
|
import productListMain from '@/BIZComponents/product-list.vue';
|
|
|
import warehouseAll from '@/BIZComponents/warehouseAll.vue';
|
|
import warehouseAll from '@/BIZComponents/warehouseAll.vue';
|
|
@@ -881,7 +884,9 @@
|
|
|
],
|
|
],
|
|
|
isTotalCount: 0, //采购收货数量是否限制不能大于采购总数 //0否 1是
|
|
isTotalCount: 0, //采购收货数量是否限制不能大于采购总数 //0否 1是
|
|
|
isBatchNo: 0,
|
|
isBatchNo: 0,
|
|
|
- isWarehouseId: 0
|
|
|
|
|
|
|
+ isWarehouseId: 0,
|
|
|
|
|
+ // 物品默认仓库缓存(物品ID -> 默认仓库ID),避免同一物品多行重复请求
|
|
|
|
|
+ defaultWarehouseCache: {}
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
created() {
|
|
created() {
|
|
@@ -918,9 +923,21 @@
|
|
|
if (row.warehouseId) {
|
|
if (row.warehouseId) {
|
|
|
data = this.warehouseList.find((item) => item.id == row.warehouseId);
|
|
data = this.warehouseList.find((item) => item.id == row.warehouseId);
|
|
|
} else {
|
|
} else {
|
|
|
- data = this.warehouseList.find(
|
|
|
|
|
- (item) => item.inventoryType == row.categoryRootLevelId
|
|
|
|
|
|
|
+ // 优先取物品主数据中的默认仓库,未配置时按仓库定义中的物品类型兜底
|
|
|
|
|
+ const defaultWarehouseId = await this.loadDefaultWarehouseId(
|
|
|
|
|
+ row.productId
|
|
|
);
|
|
);
|
|
|
|
|
+ if (defaultWarehouseId) {
|
|
|
|
|
+ data = this.warehouseList.find(
|
|
|
|
|
+ (item) =>
|
|
|
|
|
+ item.id == defaultWarehouseId && this.warehouseUsable(item)
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!data) {
|
|
|
|
|
+ data = this.warehouseList.find((item) =>
|
|
|
|
|
+ this.warehouseMatchInventoryType(item, row.categoryRootLevelId)
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
if (data) {
|
|
if (data) {
|
|
|
this.$set(this.form.datasource[index], 'warehouseName', data.name);
|
|
this.$set(this.form.datasource[index], 'warehouseName', data.name);
|
|
@@ -928,6 +945,49 @@
|
|
|
this.$set(this.form.datasource[index], 'warehouseId', data.id);
|
|
this.$set(this.form.datasource[index], 'warehouseId', data.id);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ // 取物品默认仓库(物品主数据-仓储配置),按物品缓存
|
|
|
|
|
+ async loadDefaultWarehouseId(productId) {
|
|
|
|
|
+ if (!productId) return null;
|
|
|
|
|
+ if (
|
|
|
|
|
+ Object.prototype.hasOwnProperty.call(
|
|
|
|
|
+ this.defaultWarehouseCache,
|
|
|
|
|
+ productId
|
|
|
|
|
+ )
|
|
|
|
|
+ ) {
|
|
|
|
|
+ return this.defaultWarehouseCache[productId];
|
|
|
|
|
+ }
|
|
|
|
|
+ let warehouseId = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ warehouseId = await getDefaultWarehouseId(productId);
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ warehouseId = null;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.defaultWarehouseCache[productId] = warehouseId || null;
|
|
|
|
|
+ return this.defaultWarehouseCache[productId];
|
|
|
|
|
+ },
|
|
|
|
|
+ // 仓库可用:未返回状态视为可用;已停用的默认仓库不采用,回退到物品类型匹配
|
|
|
|
|
+ warehouseUsable(warehouse) {
|
|
|
|
|
+ if (!warehouse) return false;
|
|
|
|
|
+ if (warehouse.status === undefined || warehouse.status === null) {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ return warehouse.status == 1;
|
|
|
|
|
+ },
|
|
|
|
|
+ // 仓库定义的物品类型(逗号分隔)是否包含该行根级分类
|
|
|
|
|
+ warehouseMatchInventoryType(warehouse, categoryRootLevelId) {
|
|
|
|
|
+ if (!warehouse || !warehouse.inventoryType) return false;
|
|
|
|
|
+ if (
|
|
|
|
|
+ categoryRootLevelId === undefined ||
|
|
|
|
|
+ categoryRootLevelId === null ||
|
|
|
|
|
+ categoryRootLevelId === ''
|
|
|
|
|
+ ) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ return String(warehouse.inventoryType)
|
|
|
|
|
+ .split(',')
|
|
|
|
|
+ .map((item) => String(item).trim())
|
|
|
|
|
+ .includes(String(categoryRootLevelId));
|
|
|
|
|
+ },
|
|
|
warehouseAllChange(data) {
|
|
warehouseAllChange(data) {
|
|
|
console.log(this.selection, 'this.selection');
|
|
console.log(this.selection, 'this.selection');
|
|
|
let keyS = this.selection.map((item) => item.key - 1);
|
|
let keyS = this.selection.map((item) => item.key - 1);
|