Эх сурвалжийг харах

添加库存校验及订单折扣正则

sakura 1 жил өмнө
parent
commit
63e37eb797

+ 12 - 7
manager-admin/src/views/stock/goodsExchange/goodsExchangeAdd.vue

@@ -662,12 +662,15 @@ export default {
           params.change_time = Math.floor(params.change_time / 1000);
 
           if (!this.goodsExchangeAddForm.product_list.length) {
-            this.$message.error("请选择商品!");
+
             return;
           }
-          /* params.product_list.map((el) => {
-            return (el.product_id = el.id);
-          }); */
+          params.product_list.map((el) => {
+            if(el.out_num<el.usable_stock){
+              this.$message.error("该商品库存不足!");
+              return
+            }
+          });
           if (this.$route.name === "goodsExchangeEdit") {
             API_GoodsExchange.editWarehouseOut(id, params).then((response) => {
               this.$message.success("修改成功!");
@@ -721,9 +724,11 @@ export default {
             this.$message.error("请选择商品!");
             return;
           }
-          /* params.product_list.map((el) => {
-            return (el.product_id = el.id);
-          }); */
+          params.product_list.map((el) => {
+            if(el.out_num<el.usable_stock){
+              this.$message.error("该商品库存不足!");
+              return
+            }})
           if (this.$route.name === "goodsExchangeEdit") {
             API_GoodsExchange.editWarehouseOut(id, params).then((response) => {
               this.$message.success("修改成功!");

+ 19 - 0
manager-admin/src/views/stock/goodsLend.vue

@@ -129,6 +129,12 @@
         </el-table-column> -->
         <el-table-column label="操作" width="250">
           <template slot-scope="scope">
+            <el-button
+              size="mini"
+              v-if="checkPermission(['goodsLend:edit'])"
+              @click="introGoodsLend(scope.row)"
+              >查看</el-button
+            >
             <el-button
               size="mini"
               v-if="checkPermission(['goodsLend:edit'])"
@@ -355,6 +361,19 @@ export default {
     },
   },
   methods: {
+    //查看已选中商品
+    introGoodsLend(row){
+      /* API_GoodsLend.getInfo({id:row.warehouse_id}).then(res=>{
+        console.log(res);
+      }) */
+      this.$router.push({
+        name: "inventoryItem",
+        params: {
+          warehouse_id:row.warehouse_id,
+          type:'check'
+        },
+      });
+    },
     AddGoodsLend(row) {
       this.$router.push({
         name: "inventoryItem",

+ 9 - 11
manager-admin/src/views/stock/inventoryItem.vue

@@ -17,6 +17,7 @@
           class="button"
           size="mini"
           type="primary"
+          :disabled="type==='check'"
           v-if="type !== 'detail' && type !== 'audit'"
           @click="handleSelectWarehouseEntryBatch"
           >选择</el-button
@@ -112,6 +113,7 @@
       <el-button
         v-if="type !== 'audit' && type !== 'detail'"
         type="primary"
+        :disabled="type==='check'"
         @click="saveGoodsExchangeAddForm"
         >添加
       </el-button>
@@ -214,6 +216,10 @@ export default {
     this.id=this.$route.params.id
     this.warehouse_id=this.$route.params.warehouse_id
     this.code = this.$route.params.code;
+    this.type=this.$route.params.type
+    if(this.type==='check'){
+      this.GET_goodsExchangeAddDetail();
+    }
     this.GET_WarehouseList();
     this.GET_DeptList();
     this.outType();
@@ -240,7 +246,6 @@ export default {
         }
         if (this.$route.params.id) {
           this.id = this.$route.params.id;
-          this.GET_goodsExchangeAddDetail();
         }
         this.GET_AdministratorList();
       },
@@ -417,16 +422,9 @@ export default {
     /** 获取详情页面数据 */
     GET_goodsExchangeAddDetail() {
       this.$nextTick(() => {
-        /*  API_GoodsExchange.getGoodsWarehouseOut(this.id).then((response) => {
-          this.goodsExchangeAddForm = response;
-          this.GET_WarehouseList({ dept_id: response.warehouse_id });
-          this.goodsExchangeAddForm.change_time = Math.floor(
-            this.goodsExchangeAddForm.change_time * 1000
-          );
-          this.goodsExchangeAddForm.distribution_name = response.staff_name;
-          this.goodsExchangeAddForm.product_list =
-            response.product_list;
-        }); */
+        API_GoodsLend.getInfo({id:this.warehouse_id}).then(res=>{
+         console.log(res);
+        })
       });
     },
   },

+ 22 - 3
manager-admin/src/views/stock/orderAdd.vue

@@ -117,7 +117,7 @@
               >折扣:<el-input
                 placeholder="请输入"
                 v-model="discount"
-
+                @blur="handleBlur"
                 style="width: 70px"
               ></el-input>
             </span>
@@ -763,7 +763,7 @@ export default {
         ],
       },
       //折扣
-      discount: 0,
+      discount: '',
     };
   },
   computed: {
@@ -779,6 +779,25 @@ export default {
     this.GET_CustomerList();
   },
   methods: {
+    handleBlur() {
+      const value = this.discount;
+      const regex = /^(10|([1-9](\.\d{0,1})?))$/;
+      if (!regex.test(value)) {
+        this.discount = ''; // 清空不符合条件的输入
+      }
+    },
+   /*  //折扣正则
+    handleInput(event) {
+      // 使用正则表达式来检查输入是否为1到10的整数或最多两位小数
+      const value = event.target.value;
+      const regex = /^(10|([1-9](\.\d{0,1})?))$/;
+      console.log(regex.test(value) || value === '');
+      if (regex.test(value) || value === '') {
+        this.discount = value;
+      } else {
+        event.target.value = this.discount;
+      }
+    }, */
     // 打印功能
     printIng() {},
   /*   validateNumber(){
@@ -1318,7 +1337,7 @@ export default {
     discount: {
       deep: true,
       handler(newVal) {
-        this.OrderForm.pay_price = this.price * newVal;
+        this.OrderForm.pay_price = this.price * newVal/10;
       },
     },
     "OrderForm.product_list": {