浏览代码

11月14日 库存扣减更新

XMLWAN 3 年前
父节点
当前提交
3a64970364
共有 1 个文件被更改,包括 125 次插入6 次删除
  1. 125 6
      src/xt_pages/supply/components/addGoodOrder.vue

+ 125 - 6
src/xt_pages/supply/components/addGoodOrder.vue 查看文件

18
             v-model="supplier_name"
18
             v-model="supplier_name"
19
             style="width: 140px; margin-right: 10px"
19
             style="width: 140px; margin-right: 10px"
20
             placeholder="请选择"
20
             placeholder="请选择"
21
+            :disabled="disabled"
21
           >
22
           >
22
             <el-option
23
             <el-option
23
               v-for="item in supplyList"
24
               v-for="item in supplyList"
29
           </el-select>
30
           </el-select>
30
           <span>单据日期:</span>
31
           <span>单据日期:</span>
31
           <el-date-picker
32
           <el-date-picker
33
+            :disabled="disabled"
32
             size="small"
34
             size="small"
33
             v-model="start_time"
35
             v-model="start_time"
34
             prefix-icon="el-icon-date"
36
             prefix-icon="el-icon-date"
73
           >
75
           >
74
           <el-button size="small" type="primary" @click="checkGoodOrder" v-if="is_check == 2" >审核</el-button>
76
           <el-button size="small" type="primary" @click="checkGoodOrder" v-if="is_check == 2" >审核</el-button>
75
           <el-button size="small" type="primary" @click="MofyGoodOrder" v-if="is_check == 1">反审核</el-button>
77
           <el-button size="small" type="primary" @click="MofyGoodOrder" v-if="is_check == 1">反审核</el-button>
76
-          <el-button size="small" type="primary" @click="" v-if="is_check == 1" >生成采购退货单</el-button>
78
+          <el-button size="small" type="primary" @click="toClick" v-if="is_check == 1" >生成采购退货单</el-button>
77
         </div>
79
         </div>
78
       </div>
80
       </div>
79
 
81
 
402
               v-model="rate_of_concession"
404
               v-model="rate_of_concession"
403
               @input="addressChange"
405
               @input="addressChange"
404
               placeholder="请输入优惠率"
406
               placeholder="请输入优惠率"
407
+              :disabled="disabled"
405
             ></el-input
408
             ></el-input
406
             >%</span
409
             >%</span
407
           >
410
           >
412
               v-model="discount_amount"
415
               v-model="discount_amount"
413
               @input="count_discount"
416
               @input="count_discount"
414
               placeholder="请输入优惠金额"
417
               placeholder="请输入优惠金额"
418
+              :disabled="disabled"
415
             ></el-input
419
             ></el-input
416
           ></span>
420
           ></span>
417
 
421
 
421
               v-model="payment"
425
               v-model="payment"
422
               @input="count_payment"
426
               @input="count_payment"
423
               placeholder="请输入本次付款"
427
               placeholder="请输入本次付款"
428
+              :disabled="disabled"
424
             ></el-input
429
             ></el-input
425
           ></span>
430
           ></span>
426
 
431
 
464
   checkGoodOrderById,
469
   checkGoodOrderById,
465
   getGoodOrderCountList,
470
   getGoodOrderCountList,
466
   ModefySupplyWarehousing,
471
   ModefySupplyWarehousing,
467
-  MofyGoodOrder
472
+  MofyGoodOrder,
473
+  getSupplyWarehouseOutById
468
 } from "@/api/supply";
474
 } from "@/api/supply";
469
 export default {
475
 export default {
470
   name: "addPurchaseOrder",
476
   name: "addPurchaseOrder",
533
       goodList: [],
539
       goodList: [],
534
       id: 0,
540
       id: 0,
535
       disabled: false,
541
       disabled: false,
536
-      is_check: 2,
542
+      is_check: 0,
537
       dialogVisible: false,
543
       dialogVisible: false,
538
       arrearage: "",
544
       arrearage: "",
539
       payment: "",
545
       payment: "",
986
               this.showTwo = true;
992
               this.showTwo = true;
987
               var orderInfo = response.data.data.list;
993
               var orderInfo = response.data.data.list;
988
               var warehouseOut = response.data.data.warehouseOut;
994
               var warehouseOut = response.data.data.warehouseOut;
989
-              console.log("采购单323322323",warehouseOut)
995
+              this.is_check = 2
990
               this.warese_out_id = warehouseOut.id;
996
               this.warese_out_id = warehouseOut.id;
997
+              console.log("采购单id2322332",this.warese_out_id)
991
               this.good_number = warehouseOut.good_number;
998
               this.good_number = warehouseOut.good_number;
992
               this.rate_of_concession = warehouseOut.rate_of_concession;
999
               this.rate_of_concession = warehouseOut.rate_of_concession;
993
               this.discount_amount = warehouseOut.discount_amount;
1000
               this.discount_amount = warehouseOut.discount_amount;
1117
       getGoodOrderCountList(id, warehousing_id).then((response) => {
1124
       getGoodOrderCountList(id, warehousing_id).then((response) => {
1118
         if (response.data.state == 1) {
1125
         if (response.data.state == 1) {
1119
           this.$message.success("审核成功!");
1126
           this.$message.success("审核成功!");
1120
-          
1127
+          this.disabled = true
1121
           this.is_check = 1
1128
           this.is_check = 1
1122
           this.showOne = false;
1129
           this.showOne = false;
1123
           this.showTwo = true;
1130
           this.showTwo = true;
1256
           var ids = "";
1263
           var ids = "";
1257
           // 如果采购单没有数据,则代表改订单第一次生成采购订单数据
1264
           // 如果采购单没有数据,则代表改订单第一次生成采购订单数据
1258
           if (goodOrder.length == 0) {
1265
           if (goodOrder.length == 0) {
1259
-            this.$router.push({path: "/good/order/add?id=" + id + "&ids=" + ids});
1266
+            this.$router.push({path: "/good/order/add?id=" + this.id + "&ids=" + ids});
1260
           }
1267
           }
1261
           for (let i = 0; i < purcaseOrder.length; i++) {
1268
           for (let i = 0; i < purcaseOrder.length; i++) {
1262
             for (let j = 0; j < drugList.length; j++) {
1269
             for (let j = 0; j < drugList.length; j++) {
1345
         }
1352
         }
1346
       });
1353
       });
1347
     },
1354
     },
1355
+    toClick() {
1356
+      //先判断采购单号有没有关联的采购退货单号,如果没有,则为首次生成采购退货单
1357
+      if (this.is_check == 2) {
1358
+        this.$message.error("该采购单未审核,不能生成退货单数据!");
1359
+        return false;
1360
+      }
1361
+      var id = this.warese_out_id;
1362
+      console.log("生成采购单ID22323",id)
1363
+      getSupplyWarehouseOutById(id).then((response) => {
1364
+        if (response.data.state == 1) {
1365
+          var cancelList = response.data.data.cancelList;
1366
+          console.log("退库单", cancelList);
1367
+           var drugList = response.data.data.drugList;
1368
+          console.log("药品列表", drugList);
1369
+          var cancelOrderList = response.data.data.cancelOrderList;
1370
+          console.log("退库单详情", cancelOrderList);
1371
+          var ids =""
1372
+          if(cancelList.length == 0){
1373
+            this.$router.push({ path: "/good/return/add?id=" +id+"&ids="+ids });
1374
+          }
1375
+          if (cancelList.length > 0) {
1376
+            var outList = response.data.data.outList;
1377
+            console.log("购货单2322323",outList)
1378
+            for(let i=0;i<outList.length;i++){
1379
+              if(outList[i].is_source == 1){
1380
+                for(let j=0;j<drugList.length;j++){
1381
+                  if(outList[i].project_id == drugList[j].id){
1382
+                    if(outList[i].supply_unit == drugList[j].max_unit){
1383
+                      outList[i].count = outList[i].count * drugList[j].min_number
1384
+                    }
1385
+
1386
+                  }
1387
+                }
1388
+              }
1389
+            }
1390
+
1391
+            for(let i=0;i<cancelOrderList.length;i++){
1392
+             if(cancelOrderList[i].is_source == 1){
1393
+                for(let j=0;j<drugList.length;j++){
1394
+                  if(cancelOrderList[i].project_id == drugList[j].id){
1395
+                    if(cancelOrderList[i].supply_unit == drugList[j].max_unit){
1396
+                      cancelOrderList[i].count = cancelOrderList[i].count * drugList[j].min_number
1397
+                    }
1398
+                  }
1399
+                 }
1400
+               }
1401
+            }
1402
+
1403
+          
1404
+
1405
+            let objInfo = {};
1406
+            if(cancelOrderList.length >0){
1407
+              cancelOrderList.forEach((item, index) => {
1408
+                let { project_id } = item;
1409
+                if (!objInfo[project_id]) {
1410
+                  objInfo[project_id] = {
1411
+                    project_id,
1412
+                    child: [],
1413
+                    count: 0,
1414
+                  };
1415
+                }
1416
+              });
1417
+              let newArr = Object.values(objInfo)
1418
+            
1419
+              for (let i = 0; i < cancelOrderList.length; i++) {
1420
+                for (let j = 0; j < newArr.length; j++) {
1421
+                  if (cancelOrderList[i].project_id == newArr[j].project_id) {
1422
+                    newArr[j].child.push(cancelOrderList[i])
1423
+                }
1424
+              }
1425
+
1426
+             }
1427
+
1428
+            for (let i = 0; i < newArr.length; i++) {
1429
+              for (let j = 0; j < newArr[i].child.length; j++) {
1430
+                newArr[i].count += newArr[i].child[j].count;
1431
+              }
1432
+            }
1433
+
1434
+            var arr = []
1435
+            var total = 0;
1436
+            var str = "";
1437
+                //如果采购单有数据,则需要比较数量
1438
+            if (newArr.length > 0) {
1439
+              for (let i = 0; i < outList.length; i++) {
1440
+                for (let j = 0; j < newArr.length; j++) {
1441
+                  if (outList[i].project_id == newArr[j].project_id) {
1442
+                    //根据商品ID比较数量大小,把数量不足的商品ID储存,表示退货单的数量未满足采购单的数据,可以继续生成退货单
1443
+                    if (outList[i].count > newArr[j].count) {
1444
+                       arr.push(outList[i].project_id);
1445
+                    }
1446
+                  }
1447
+                }
1448
+              }
1449
+              //如果total的长度等于 采购单的长度,怎表示该采购订单已经全部生成
1450
+
1451
+              if (arr.length == 0) {
1452
+                this.$message.error("该订单已全部生成退库单,请知悉!");
1453
+                return
1454
+              }
1455
+              console.log("arr23323232232323",arr)
1456
+              if (arr.length > 0) {
1457
+                str = arr.join(",");
1458
+                this.$router.push({ path: "/good/return/edit?id=" + id + "&ids=" + str});
1459
+              }
1460
+             }
1461
+
1462
+          }
1463
+         }
1464
+        }
1465
+      });
1466
+    },
1348
   },
1467
   },
1349
   created() {
1468
   created() {
1350
     const tempObj = {};
1469
     const tempObj = {};