|
@@ -180,7 +180,7 @@
|
|
|
<el-select
|
|
<el-select
|
|
|
v-model="scope.row.warehouseId"
|
|
v-model="scope.row.warehouseId"
|
|
|
placeholder="请选择"
|
|
placeholder="请选择"
|
|
|
- @change="warehouseChange(scope.$index, scope.row)"
|
|
|
|
|
|
|
+ @change="warehouseChange(scope.$index, scope.row, true)"
|
|
|
>
|
|
>
|
|
|
<el-option
|
|
<el-option
|
|
|
v-for="item in scope.row.warehouseList"
|
|
v-for="item in scope.row.warehouseList"
|
|
@@ -1115,7 +1115,7 @@
|
|
|
this.selection = [];
|
|
this.selection = [];
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- async warehouseChange(index, row) {
|
|
|
|
|
|
|
+ async warehouseChange(index, row, isReset = false) {
|
|
|
const data = row.warehouseList.find(
|
|
const data = row.warehouseList.find(
|
|
|
(item) => item.warehouseId == row.warehouseId
|
|
(item) => item.warehouseId == row.warehouseId
|
|
|
);
|
|
);
|
|
@@ -1140,9 +1140,11 @@
|
|
|
warehouseOutStock || 0
|
|
warehouseOutStock || 0
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- this.$set(this.form.datasource[index], 'batchStockId', '');
|
|
|
|
|
-
|
|
|
|
|
- this.$set(this.form.datasource[index], 'batchNo', '');
|
|
|
|
|
|
|
+ if(isReset) {
|
|
|
|
|
+ this.$set(this.form.datasource[index], 'batchStockId', '');
|
|
|
|
|
+ this.$set(this.form.datasource[index], 'batchNo', '');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
//批次号选择
|
|
//批次号选择
|
|
@@ -1489,12 +1491,204 @@
|
|
|
});
|
|
});
|
|
|
this.form.datasource.forEach(async (item, index) => {
|
|
this.form.datasource.forEach(async (item, index) => {
|
|
|
if (indexS.includes(index)) {
|
|
if (indexS.includes(index)) {
|
|
|
|
|
+ if(!item.batchNo) {
|
|
|
|
|
+ console.log('111~~~~');
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.form.datasource[index],
|
|
|
|
|
+ 'warehouseList',
|
|
|
|
|
+ await getIdWarehouseList({
|
|
|
|
|
+ categoryId: item.productId
|
|
|
|
|
+ })
|
|
|
|
|
+ );
|
|
|
|
|
+ if (item.warehouseId) {
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.form.datasource[index],
|
|
|
|
|
+ 'warehouseNum',
|
|
|
|
|
+ await getWarehouseOutStock({
|
|
|
|
|
+ warehouseId: item.warehouseId,
|
|
|
|
|
+ code: item.productCode
|
|
|
|
|
+ })
|
|
|
|
|
+ );
|
|
|
|
|
+ } else if (this.form.datasource[index]?.warehouseList?.length) {
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.form.datasource[index],
|
|
|
|
|
+ 'warehouseId',
|
|
|
|
|
+ this.form.datasource[index]?.warehouseList[0].warehouseId
|
|
|
|
|
+ );
|
|
|
|
|
+ await this.warehouseChange(index, this.form.datasource[index]);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const templist = await getBatchList({
|
|
|
|
|
+ categoryCode: item.productCode,
|
|
|
|
|
+ warehouseId: item.warehouseId,
|
|
|
|
|
+ size: -1
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ console.log('templist~~~~', templist.list);
|
|
|
|
|
+
|
|
|
|
|
+ // 批次号
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.form.datasource[index],
|
|
|
|
|
+ 'batchNoList',
|
|
|
|
|
+ templist?.list || []
|
|
|
|
|
+ );
|
|
|
|
|
+ // console.log(this.form.datasource[index]);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.setBatchAndWarehouse(item, index);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ async setBatchAndWarehouse(item, index) {
|
|
|
|
|
+ // 通过产品编号和批次号获取仓库列表
|
|
|
|
|
+ const warehouse = await getIdWarehouseList({
|
|
|
|
|
+ categoryId: item.productId,
|
|
|
|
|
+ batchNo: item.batchNo
|
|
|
|
|
+ })
|
|
|
|
|
+ // 如果有仓库列表
|
|
|
|
|
+ if (warehouse?.length) {
|
|
|
|
|
+ console.log('222~~~~', item.batchNo);
|
|
|
|
|
+ // 设置仓库列表
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.form.datasource[index],
|
|
|
|
|
+ 'warehouseList',
|
|
|
|
|
+ warehouse
|
|
|
|
|
+ );
|
|
|
|
|
+ // 如果有仓库ID
|
|
|
|
|
+ if (item.warehouseId) {
|
|
|
|
|
+ // console.log('444~~~~');
|
|
|
|
|
+ // const templist = await getBatchList({
|
|
|
|
|
+ // categoryCode: item.productCode,
|
|
|
|
|
+ // warehouseId: item.warehouseId,
|
|
|
|
|
+ // size: -1
|
|
|
|
|
+ // });
|
|
|
|
|
+ // const batchNoList = templist?.list || [];
|
|
|
|
|
+ // // 批次号
|
|
|
|
|
+ // this.$set(
|
|
|
|
|
+ // this.form.datasource[index],
|
|
|
|
|
+ // 'batchNoList',
|
|
|
|
|
+ // batchNoList
|
|
|
|
|
+ // );
|
|
|
|
|
+ // const batchNo = batchNoList.find(i => i.batchNo === item.batchNo);
|
|
|
|
|
+ // if (batchNo) {
|
|
|
|
|
+ // this.$set(
|
|
|
|
|
+ // this.form.datasource[index],
|
|
|
|
|
+ // 'batchStockId',
|
|
|
|
|
+ // batchNo.id
|
|
|
|
|
+ // );
|
|
|
|
|
+ // this.$set(
|
|
|
|
|
+ // this.form.datasource[index],
|
|
|
|
|
+ // 'warehouseNum',
|
|
|
|
|
+ // data.measureQuantity || 0
|
|
|
|
|
+ // );
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ // 没有仓库ID,设置第一个仓库ID
|
|
|
|
|
+ else {
|
|
|
|
|
+ if (this.form.datasource[index]?.warehouseList?.length){
|
|
|
|
|
+ console.log('555~~~~');
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.form.datasource[index],
|
|
|
|
|
+ 'warehouseId',
|
|
|
|
|
+ this.form.datasource[index]?.warehouseList[0].warehouseId
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ // await this.warehouseChange(index, this.form.datasource[index]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // const wdata = warehouse.find(
|
|
|
|
|
+ // (i) => i.warehouseId == row.warehouseId
|
|
|
|
|
+ // );
|
|
|
|
|
+
|
|
|
|
|
+ // this.$set(
|
|
|
|
|
+ // this.form.datasource[index],
|
|
|
|
|
+ // 'warehouseName',
|
|
|
|
|
+ // wdata.warehouseName
|
|
|
|
|
+ // );
|
|
|
|
|
+ // this.$set(
|
|
|
|
|
+ // this.form.datasource[index],
|
|
|
|
|
+ // 'warehouseCode',
|
|
|
|
|
+ // wdata.warehouseCode
|
|
|
|
|
+ // );
|
|
|
|
|
+ // const warehouseOutStock = await getWarehouseOutStock({
|
|
|
|
|
+ // warehouseId: wdata.warehouseId,
|
|
|
|
|
+ // code: row.productCode
|
|
|
|
|
+ // });
|
|
|
|
|
+ // this.$set(
|
|
|
|
|
+ // this.form.datasource[index],
|
|
|
|
|
+ // 'warehouseNum',
|
|
|
|
|
+ // warehouseOutStock || 0
|
|
|
|
|
+ // );
|
|
|
|
|
+
|
|
|
|
|
+ console.log('444~~~~');
|
|
|
|
|
+ // 通过仓库ID获取批次号列表
|
|
|
|
|
+ const templist = await getBatchList({
|
|
|
|
|
+ categoryCode: item.productCode,
|
|
|
|
|
+ warehouseId: item.warehouseId,
|
|
|
|
|
+ size: -1
|
|
|
|
|
+ });
|
|
|
|
|
+ let batchNoList = templist?.list || [];
|
|
|
|
|
+ console.log('batchNoList~~~~', batchNoList);
|
|
|
|
|
+ // 设置批次列表
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.form.datasource[index],
|
|
|
|
|
+ 'batchNoList',
|
|
|
|
|
+ batchNoList
|
|
|
|
|
+ );
|
|
|
|
|
+ // 查找批次号是否存在批次列表
|
|
|
|
|
+ const batchNo = batchNoList.find(i => i.batchNo == item.batchNo);
|
|
|
|
|
+ console.log('batchNo~~~~', batchNo);
|
|
|
|
|
+ // 存在
|
|
|
|
|
+ if (batchNo) {
|
|
|
|
|
+ // 设置批次ID
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.form.datasource[index],
|
|
|
|
|
+ 'batchStockId',
|
|
|
|
|
+ batchNo.id
|
|
|
|
|
+ );
|
|
|
|
|
+ // 设置批次库存
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.form.datasource[index],
|
|
|
|
|
+ 'warehouseNum',
|
|
|
|
|
+ batchNo.measureQuantity || 0
|
|
|
|
|
+ );
|
|
|
|
|
+ } else { //不存在
|
|
|
|
|
+ // 批次列表添加不存在的批次号对象
|
|
|
|
|
+ batchNoList = batchNoList.push({
|
|
|
|
|
+ batchNo: item.batchNo,
|
|
|
|
|
+ id: 999,
|
|
|
|
|
+ measureQuantity: 0
|
|
|
|
|
+ })
|
|
|
|
|
+ // 设置为不存在的批次ID
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.form.datasource[index],
|
|
|
|
|
+ 'batchStockId',
|
|
|
|
|
+ 999
|
|
|
|
|
+ );
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.form.datasource[index],
|
|
|
|
|
+ 'warehouseNum',
|
|
|
|
|
+ ''
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // 如果没有仓库列表
|
|
|
|
|
+ else {
|
|
|
|
|
+ console.log('333~~~~');
|
|
|
|
|
+ // 通过产品编码查仓库
|
|
|
|
|
+ const tempWarehouse = await getIdWarehouseList({
|
|
|
|
|
+ categoryId: item.productId,
|
|
|
|
|
+ })
|
|
|
|
|
+ // 有仓库列表
|
|
|
|
|
+ if (tempWarehouse?.length) {
|
|
|
|
|
+ console.log('666~~~~');
|
|
|
this.$set(
|
|
this.$set(
|
|
|
this.form.datasource[index],
|
|
this.form.datasource[index],
|
|
|
'warehouseList',
|
|
'warehouseList',
|
|
|
- await getIdWarehouseList({
|
|
|
|
|
- categoryId: item.productId
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ tempWarehouse
|
|
|
);
|
|
);
|
|
|
if (item.warehouseId) {
|
|
if (item.warehouseId) {
|
|
|
this.$set(
|
|
this.$set(
|
|
@@ -1505,46 +1699,50 @@
|
|
|
code: item.productCode
|
|
code: item.productCode
|
|
|
})
|
|
})
|
|
|
);
|
|
);
|
|
|
- } else if (this.form.datasource[index]?.warehouseList?.length) {
|
|
|
|
|
- this.$set(
|
|
|
|
|
- this.form.datasource[index],
|
|
|
|
|
- 'warehouseId',
|
|
|
|
|
- this.form.datasource[index]?.warehouseList[0].warehouseId
|
|
|
|
|
- );
|
|
|
|
|
- await this.warehouseChange(index, this.form.datasource[index]);
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (this.form.datasource[index]?.warehouseList?.length) {
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.form.datasource[index],
|
|
|
|
|
+ 'warehouseId',
|
|
|
|
|
+ this.form.datasource[index]?.warehouseList[0].warehouseId
|
|
|
|
|
+ );
|
|
|
|
|
+ await this.warehouseChange(index, this.form.datasource[index]);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const templist = await getBatchList({
|
|
|
|
|
|
|
+ const templist1 = await getBatchList({
|
|
|
categoryCode: item.productCode,
|
|
categoryCode: item.productCode,
|
|
|
warehouseId: item.warehouseId,
|
|
warehouseId: item.warehouseId,
|
|
|
size: -1
|
|
size: -1
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- console.log('templist~~~~', templist.list);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ let tempBatchNoList = templist1?.list || [];
|
|
|
|
|
+ tempBatchNoList = tempBatchNoList.push({
|
|
|
|
|
+ batchNo: item.batchNo,
|
|
|
|
|
+ id: 999,
|
|
|
|
|
+ measureQuantity: 0
|
|
|
|
|
+ })
|
|
|
// 批次号
|
|
// 批次号
|
|
|
this.$set(
|
|
this.$set(
|
|
|
this.form.datasource[index],
|
|
this.form.datasource[index],
|
|
|
'batchNoList',
|
|
'batchNoList',
|
|
|
- templist?.list || []
|
|
|
|
|
|
|
+ tempBatchNoList
|
|
|
|
|
+ );
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.form.datasource[index],
|
|
|
|
|
+ 'batchStockId',
|
|
|
|
|
+ 999
|
|
|
|
|
+ );
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.form.datasource[index],
|
|
|
|
|
+ 'warehouseNum',
|
|
|
|
|
+ ''
|
|
|
);
|
|
);
|
|
|
- console.log(this.form.datasource[index]);
|
|
|
|
|
- if (item.batchStockId) {
|
|
|
|
|
- // this.$set(
|
|
|
|
|
- // this.form.datasource[index],
|
|
|
|
|
- // 'warehouseNum',
|
|
|
|
|
- // await getWarehouseOutStock({
|
|
|
|
|
- // warehouseId: item.warehouseId,
|
|
|
|
|
- // code: item.productCode
|
|
|
|
|
- // })
|
|
|
|
|
- // );
|
|
|
|
|
-
|
|
|
|
|
- await this.batchNoChange(index, this.form.datasource[index]);
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
- });
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
},
|
|
},
|
|
|
-
|
|
|
|
|
remove(i) {
|
|
remove(i) {
|
|
|
this.form.datasource.splice(i, 1);
|
|
this.form.datasource.splice(i, 1);
|
|
|
this.setSort();
|
|
this.setSort();
|