Ver Fonte

【新增】提货预约-校验仓库预约设置

莫绍宝 há 3 anos atrás
pai
commit
d7b3d65c82

+ 9 - 0
src/api/supply/pickup.js

@@ -81,6 +81,15 @@ export function editPickupBook(params) {
   })
 }
 
+// 校验库存
+export function checkStock(params) {
+  return request({
+    url: '/stock/manager/stockHint',
+    method: 'post',
+    data: params
+  })
+}
+
 // 获取短信验证码
 export function getCode(params) {
   return request({

+ 62 - 35
src/views/supply/pickup/components/pickup_form.vue

@@ -114,7 +114,7 @@
 </template>
 
 <script>
-import { getWarehouseList, getDeliverList, getPickupManList, getPickupCarList, getCompanyList, addPickupBook, editPickupBook, getDetail } from "@/api/supply/pickup";
+import { getWarehouseList, getDeliverList, getPickupManList, getPickupCarList, getCompanyList, addPickupBook, editPickupBook, getDetail, checkStock } from "@/api/supply/pickup";
 import { getDictList } from "@/api/common";
 
 export default {
@@ -293,10 +293,6 @@ export default {
           if(this.tableSelection.length < 1) {
             return this.$errorMsg('请选择发货申请单');
           }
-          this.formLoading = true;
-
-          let takerName = this.pickupManList.find(o => o.id == this.mainForm.pickupMan).takerName;
-          let correspondName = this.warehouseList.find(o => o.id == this.mainForm.warehouse).name;
 
           let orderList = [];
           this.tableSelection.forEach(item => {
@@ -304,43 +300,74 @@ export default {
           });
           let params = {
             correspondId: this.mainForm.warehouse,
-            correspondName,
             pickTime: this.mainForm.date + ' 00:00:00',
-            pickStatus: Number(this.mainForm.timeSlot),
-            pickType: Number(this.mainForm.pickupWay),
-            takerId: this.mainForm.pickupMan,
-            takerName,
-            remark: this.mainForm.remark,
             invoiceOrderIds: orderList,
           }
-          if(this.mainForm.pickupWay == '1') {
-            params.takerCarId = this.mainForm.pickupCar;
-          }
-          if(this.mainForm.pickupWay == '2') {
-            params.pickLogistics = this.mainForm.company;
-          }
-          if(this.listItem) {
-            params.id = this.listItem.id;
-            editPickupBook(params).then(res => {
-              this.$successMsg('提交成功');
-              this.goBack();
-              this.$parent.getList();
-            }).finally(res => {
-              this.formLoading = false;
-            })
-          }else {
-            addPickupBook(params).then(res => {
-              this.$successMsg('提交成功');
-              this.goBack();
-              this.$parent.getList();
-            }).finally(res => {
-              this.formLoading = false;
-            })
-          }
+          checkStock(params).then(res => {
+            if(res.data) {
+              this.$confirm(res.data, '提示', {
+                confirmButtonText: '确定',
+                cancelButtonText: '取消',
+                type: 'warning'
+              }).then(() => {
+                this.submitForm();
+              }).catch(() => {});
+            }else {
+              this.submitForm();
+            }
+          })
+          
         }
       })
     },
 
+    submitForm() {
+      this.formLoading = true;
+
+      let takerName = this.pickupManList.find(o => o.id == this.mainForm.pickupMan).takerName;
+      let correspondName = this.warehouseList.find(o => o.id == this.mainForm.warehouse).name;
+
+      let orderList = [];
+      this.tableSelection.forEach(item => {
+        orderList.push(item.invoiceOrderId);
+      });
+      let params = {
+        correspondId: this.mainForm.warehouse,
+        correspondName,
+        pickTime: this.mainForm.date + ' 00:00:00',
+        pickStatus: Number(this.mainForm.timeSlot),
+        pickType: Number(this.mainForm.pickupWay),
+        takerId: this.mainForm.pickupMan,
+        takerName,
+        remark: this.mainForm.remark,
+        invoiceOrderIds: orderList,
+      }
+      if(this.mainForm.pickupWay == '1') {
+        params.takerCarId = this.mainForm.pickupCar;
+      }
+      if(this.mainForm.pickupWay == '2') {
+        params.pickLogistics = this.mainForm.company;
+      }
+      if(this.listItem) {
+        params.id = this.listItem.id;
+        editPickupBook(params).then(res => {
+          this.$successMsg('提交成功');
+          this.goBack();
+          this.$parent.getList();
+        }).finally(res => {
+          this.formLoading = false;
+        })
+      }else {
+        addPickupBook(params).then(res => {
+          this.$successMsg('提交成功');
+          this.goBack();
+          this.$parent.getList();
+        }).finally(res => {
+          this.formLoading = false;
+        })
+      }
+    },
+
     resetForm() {
       this.$refs.mainForm.resetFields();
       this.deliverList = [];