|
@@ -222,6 +222,7 @@
|
|
|
</el-table-column>
|
|
|
<el-table-column label="商品名称" show-overflow-tooltip align="center" prop="productName" />
|
|
|
<el-table-column label="商品规格" align="center" prop="sku" />
|
|
|
+ <el-table-column label="仓库代码" align="center" prop="prodWareHouseCode" />
|
|
|
<!-- <el-table-column label="库存" align="center" prop="stock" /> -->
|
|
|
<el-table-column label="售价" align="center" prop="price" >
|
|
|
<template slot-scope="scope">
|
|
@@ -496,8 +497,29 @@ export default {
|
|
|
}
|
|
|
row.count=1;
|
|
|
row.money=row.count*row.price;
|
|
|
+ let testProduct = [...this.products,row]
|
|
|
+ if (!this.checkProductsWarehouseCode(testProduct)) {
|
|
|
+ this.$message.error("商品仓库代码不一致,且不能为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
this.products.push(row);
|
|
|
this.compute();
|
|
|
+
|
|
|
+ this.$message.success('添加成功!')
|
|
|
+ },
|
|
|
+ checkProductsWarehouseCode(products) {
|
|
|
+ const warehouseCodeSet = new Set(products.map(row => row.prodWareHouseCode));
|
|
|
+ // 2. 检查 Set 大小是否为 1
|
|
|
+ if (warehouseCodeSet.size !== 1) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ // 3. 获取 Set 中的唯一元素(因为 Set 大小为 1,所以可以直接获取)
|
|
|
+ const [singleWarehouseCode] = warehouseCodeSet;
|
|
|
+ // 4. 检查唯一元素是否为空
|
|
|
+ if (singleWarehouseCode === null || singleWarehouseCode === undefined || singleWarehouseCode === '') {
|
|
|
+ return false; // 元素为空
|
|
|
+ }
|
|
|
+ return true; // 所有条件都满足
|
|
|
},
|
|
|
handleAddProduct(){
|
|
|
this.product.open=true;
|
|
@@ -639,6 +661,12 @@ export default {
|
|
|
// return;
|
|
|
this.$refs["form"].validate(valid => {
|
|
|
if (valid) {
|
|
|
+
|
|
|
+ if (!this.checkProductsWarehouseCode(this.products)) {
|
|
|
+ this.$message.error("商品仓库代码不一致,且不能为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
if (this.form.packageId != null) {
|
|
|
updateStoreProductPackage(this.form).then(response => {
|
|
|
if (response.code === 200) {
|