Răsfoiți Sursa

添加盲票组优化

hwb0 3 ani în urmă
părinte
comite
6c0b23b67b
1 a modificat fișierele cu 66 adăugiri și 24 ștergeri
  1. 66 24
      src/views/business/ticket/create.vue

+ 66 - 24
src/views/business/ticket/create.vue

@@ -460,35 +460,65 @@ export default {
       // 奖级列表
       awardsList: [
         {
-          name: "至尊级",
+          name: "奖品一",
           sort: 1,
           quantity: 0,
           prizeList: [],
         },
         {
-          name: "尊享款",
+          name: "奖品二",
           sort: 2,
           quantity: 0,
           prizeList: [],
         },
         {
-          name: "稀有款",
+          name: "奖品三",
           sort: 3,
           quantity: 0,
           prizeList: [],
         },
         {
-          name: "隐藏款",
+          name: "奖品四",
           sort: 4,
           quantity: 0,
           prizeList: [],
         },
         {
-          name: "普通款",
+          name: "奖品五",
           sort: 5,
           quantity: 0,
           prizeList: [],
         },
+        {
+          name: "奖品六",
+          sort: 6,
+          quantity: 0,
+          prizeList: [],
+        },
+        {
+          name: "奖品七",
+          sort: 7,
+          quantity: 0,
+          prizeList: [],
+        },
+        {
+          name: "奖品八",
+          sort: 8,
+          quantity: 0,
+          prizeList: [],
+        },
+        {
+          name: "奖品九",
+          sort: 9,
+          quantity: 0,
+          prizeList: [],
+        },
+        {
+          name: "奖品十",
+          sort: 10,
+          quantity: 0,
+          prizeList: [],
+        },
       ],
 
       prizeIndex: null, // 奖级下标
@@ -580,16 +610,16 @@ export default {
       const subForm = this.$refs["form"];
       subForm.validate((valid) => {
         if (valid) {
-          let prizeIndex = this.awardsList.findIndex((item) => {
-            return !item.prizeList.length;
-          });
-          // 判断没有设置奖品的奖级
-          if (prizeIndex != -1) {
-            this.$message.error(
-              `请设置${this.awardsList[prizeIndex].name}的奖品!`
-            );
-            return;
-          }
+          // let prizeIndex = this.awardsList.findIndex((item) => {
+          //   return !item.prizeList.length;
+          // });
+          // // 判断没有设置奖品的奖级
+          // if (prizeIndex != -1) {
+          //   this.$message.error(
+          //     `请设置${this.awardsList[prizeIndex].name}的奖品!`
+          //   );
+          //   return;
+          // }
 
           if (this.form.quantity % this.form.pkgUnit != 0) {
             this.$message.error("每包数量错误!");
@@ -622,13 +652,17 @@ export default {
             });
           });
 
+          let filterArr = this.awardsList.filter(item=>{
+            return item.prizeList.length != 0
+          })
+
           let data = {
             ...this.form,
             picUrl: this.form.picUrl[0].fileName,
             facePrice: accMul(this.form.facePrice, 100),
             salePrice: accMul(this.form.salePrice, 100),
             pkgSalePrice: accMul(this.form.pkgSalePrice, 100),
-            awardsList: this.awardsList,
+            awardsList: filterArr,
           };
 
           const loading = this.$loading({
@@ -710,19 +744,27 @@ export default {
 
     // 选中商品
     handleSelectionGoods(e) {
-      this.selectGoodsList = e;
-      this.selectGoodsList.forEach((item) => {
-        item.prizeType = "goods";
-        item.quantity = 1;
+      this.selectGoodsList = e.map((item) => {
+        return {
+          prizeType: "goods",
+          quantity: 1,
+          goodsId: item.goodsId,
+          picUrl: item.picUrl,
+          title: item.title,
+        };
       });
     },
 
     // 选中卡券
     handleSelectionCoupon(e) {
-      this.selectCouponList = e;
-      this.selectCouponList.forEach((item) => {
-        item.prizeType = "coupon";
-        item.quantity = 1;
+      this.selectCouponList = e.map((item) => {
+        return {
+          prizeType: "coupon",
+          quantity: 1,
+          couponId: item.couponId,
+          picUrl: item.picUrl,
+          title: item.title,
+        };
       });
     },