ソースを参照

盲票管理--奖级数量 新增关联奖级 奖品增加数量字段

DELL 3 年 前
コミット
4ce8606652

+ 47 - 16
src/views/business/ticket/components/AwardsList.vue

@@ -5,6 +5,11 @@
           <div>奖级名称:{{ item.name }}</div>
           <div>奖级:{{ item.sort }}</div>
           <div>
+            关联奖级:<el-select v-model="item.awardsLabel" style="width: 120px;">
+            <el-option v-for="(item,index) in awardsLabelList"  :label="item.dictLabel" :value="item.dictLabel" :key="index"/>
+          </el-select>
+          </div>
+          <div v-if="ticketType == 'offline'">
             奖级数量:
             <el-input-number
               v-model="item.quantity"
@@ -15,6 +20,7 @@
               :disabled="item.isEdit"
             ></el-input-number>
           </div>
+          <div v-else>奖级数量:{{ item.quantity }}</div>
         </div>
         <div class="prize-table">
           <el-table :data="item.prizeList" class="el-table">
@@ -42,31 +48,32 @@
                 <div v-if="scope.row.prizeType == 'coin'">盲豆</div>
               </template>
             </el-table-column>
-            <el-table-column label="排序" prop="sortWeight">
+            <el-table-column label="奖品数量" prop="quantity" v-if="ticketType != 'offline'">
               <template slot-scope="scope">
                 <div>
                   <el-input-number
-                    v-model="scope.row.sortWeight"
+                    v-model="scope.row.quantity"
                     controls-position="right"
-                    :min="0"
+                    @change="handleChange($event, index)"
+                    :min="1"
                     size="small"
                   ></el-input-number>
                 </div>
               </template>
             </el-table-column>
-            <!-- <el-table-column label="奖品数量" prop="storeName">
+            <el-table-column label="排序" prop="sortWeight">
               <template slot-scope="scope">
                 <div>
                   <el-input-number
-                    v-model="scope.row.quantity"
+                    v-model="scope.row.sortWeight"
                     controls-position="right"
-                    @change="handleChange($event, index)"
-                    :min="1"
+                    :min="0"
                     size="small"
                   ></el-input-number>
                 </div>
               </template>
-            </el-table-column> -->
+            </el-table-column>
+
             <el-table-column label="操作" align="center">
               <template slot-scope="scope">
                 <el-button
@@ -106,7 +113,8 @@ export default {
   },
   data() {
     return {
-      prizeIndex: null, // 奖级下标
+      awardsLabelList: [],//关联奖级列表
+      prizeIndex: 0, // 奖级下标
       // 奖级列表
       awardsList: [
         {
@@ -182,9 +190,19 @@ export default {
           prizeList: [],
         },
       ],
+      ticketType: '',
     };
   },
+  created() {
+    this.getAwardsLabelList()
+  },
   methods: {
+    //获取关联奖级
+    getAwardsLabelList(){
+      this.getDicts('awards_label').then(res=>{
+        this.awardsLabelList = res.data
+      })
+    },
     // 添加奖品
     add(type, item) {
       if(type == 1) {
@@ -196,6 +214,13 @@ export default {
       }
       this.$emit('input', this.awardsList)
       this.$emit('close')
+      if (this.ticketType != 'offline') {
+        this.getQuantity();
+      }
+    },
+
+    changetype(e) {
+      this.ticketType = e
     },
 
     // 选择奖品种类
@@ -208,14 +233,18 @@ export default {
     handleChangeAll(e, item) {
       this.$set(item, "quantity", e);
       this.$forceUpdate();
-      // this.getQuantity();
+      if (this.ticketType != 'offline') {
+        this.getQuantity();
+      }
     },
 
     // 改变奖品数量
     handleChange(e, index) {
       this.prizeIndex = index;
       this.$forceUpdate();
-      // this.getQuantity();
+      if (this.ticketType != 'offline') {
+        this.getQuantity();
+      }
     },
 
     // 奖级商品删除
@@ -224,16 +253,18 @@ export default {
       let list = item.prizeList;
       list.splice(index, 1);
       this.$set(item, "prizeList", list);
-      // this.getQuantity();
+      if (this.ticketType != 'offline') {
+        this.getQuantity();
+      }
     },
 
     // 计算奖级数量
     getQuantity() {
       let num = 0;
-      this.awardsList[this.prizeIndex].prizeList.forEach((item) => {
-        num += item.quantity;
-      });
-      this.awardsList[this.prizeIndex].quantity = num;
+        this.awardsList[this.prizeIndex].prizeList.forEach((item) => {
+          num += item.quantity;
+        });
+        this.awardsList[this.prizeIndex].quantity = num;
     },
   },
 };

+ 2 - 2
src/views/business/ticket/components/CoinAdd.vue

@@ -61,7 +61,7 @@ export default {
     confirmCoin() {
       let coin = {
         prizeType: "coin",
-        // quantity: 1,
+        quantity: 1,
         title: `盲豆 x${this.coinForm.quantity}`,
         picUrl: publicFileGetUrl + "md.jpeg",
         coinValue: this.coinForm.quantity,
@@ -91,4 +91,4 @@ export default {
     width: 40px;
   }
 }
-</style>
+</style>

+ 1 - 1
src/views/business/ticket/components/CouponAdd.vue

@@ -142,7 +142,7 @@ export default {
       this.selectCouponList = e.map((item) => {
         return {
           prizeType: "coupon",
-          // quantity: 1,
+          quantity: 1,
           couponId: item.couponId,
           picUrl: item.picUrl,
           title: item.title,

+ 1 - 1
src/views/business/ticket/components/CouponPkgAdd.vue

@@ -113,7 +113,7 @@ export default {
       this.selectCouponPkgList = e.map((item) => {
         return {
           prizeType: "coupon_pkg",
-          // quantity: 1,
+          quantity: 1,
           id: item.id,
           picUrl: publicFileGetUrl + item.picUrl,
           title: item.title,

+ 1 - 1
src/views/business/ticket/components/GoodsAdd.vue

@@ -142,7 +142,7 @@ export default {
       this.selectGoodsList = e.map((item) => {
         return {
           prizeType: "goods",
-          // quantity: 1,
+          quantity: 1,
           goodsId: item.goodsId,
           picUrl: item.picUrl,
           title: item.title,

+ 45 - 3
src/views/business/ticket/create.vue

@@ -6,7 +6,7 @@
       <div class="base-info-form">
         <el-form :model="form" :rules="rules" ref="form" label-width="100px">
           <el-form-item label="盲票类型" prop="type">
-            <el-radio-group v-model="form.type" size="small" :disabled="form.disabled" @change="$refs['form'].clearValidate()">
+            <el-radio-group v-model="form.type" size="small" :disabled="form.disabled" @change="$refs['form'].clearValidate();changeType($event)">
               <el-radio label="online">线上盲票</el-radio>
               <el-radio label="offline">线下盲票</el-radio>
             </el-radio-group>
@@ -45,6 +45,20 @@
               <template slot="append">元</template>
             </el-input>
           </el-form-item>
+          <el-form-item
+            label="划线价"
+            prop="originPrice"
+            v-if="form.type != 'offline'"
+          >
+            <el-input
+              v-model="form.originPrice"
+              style="width: 240px"
+              size="small"
+              placeholder="请输入划线价"
+            >
+              <template slot="append">元</template>
+            </el-input>
+          </el-form-item>
           <el-form-item label="盲票总数" prop="quantity">
             <el-input
               v-model="form.quantity"
@@ -184,6 +198,7 @@ export default {
         pkgUnit: 200, // 张数
         pkgSalePrice: 0, // 单价
         saleCommRate: "", // 基数
+        originPrice: 0, //划线价
         disabled: false,
         saleChannelType: 1
       },
@@ -229,6 +244,11 @@ export default {
             trigger: ["blur", "change"],
           },
         ],
+        originPrice: [{
+          pattern: /^([0-9]\d*)$/,
+          message: "请输入合法的数字",
+          trigger: ["blur", "change"],
+        },],
         pkgUnit: [
           { required: true, message: "请输入每包张数", trigger: "blur" },
           {
@@ -297,7 +317,7 @@ export default {
         boxId: this.id
       }
       ticketBoxDetail(data).then(res => {
-        const { awardsList, type, title, picUrl, facePrice, salePrice, quantity, pkgUnit, pkgSalePrice, saleCommRate, saleChannelType, channelList } = res.data
+        const { awardsList, type, title, picUrl, facePrice, salePrice, quantity, originPrice, pkgUnit, pkgSalePrice, saleCommRate, saleChannelType, channelList } = res.data
         this.form = {
           disabled:true,
           title, picUrl, quantity, pkgUnit, saleCommRate, saleChannelType,
@@ -305,7 +325,8 @@ export default {
           type: JSON.parse(type).value,
           facePrice:accDiv(facePrice, 100),
           salePrice:accDiv(salePrice, 100),
-          pkgSalePrice:accDiv(pkgSalePrice, 100)
+          pkgSalePrice:accDiv(pkgSalePrice, 100),
+          originPrice:accDiv(originPrice, 100)
         }
         if(awardsList){
           awardsList.forEach((item) => {
@@ -317,6 +338,7 @@ export default {
           });
           this.$nextTick(() => {
             this.$refs.awards.add(3, awardsList)
+            this.$refs.awards.changetype(JSON.parse(type).value)
           })
           this.awardsList = awardsList
         }
@@ -402,11 +424,27 @@ export default {
             return item.quantity != 0;
           });
 
+          for (let i = 0; i < filterArr2.length; i++) {
+            if(filterArr2[i].awardsLabel == "" || filterArr2[i].awardsLabel == undefined){
+              this.$message.error("关联奖级不能为空");
+              return
+            }
+          }
+          if (this.form.type == "offline") {
+            this.form.originPrice = null
+            for (let i = 0; i < filterArr2.length; i++) {
+              for (let j = 0; j < filterArr2[i].prizeList; j++) {
+                filterArr2[i].prizeList[j].quantity = null
+              }
+            }
+          }
+
           let data = {
             ...this.form,
             facePrice: accMul(this.form.facePrice, 100),
             salePrice: accMul(this.form.salePrice, 100),
             pkgSalePrice: accMul(this.form.pkgSalePrice, 100),
+            originPrice: accMul(this.form.originPrice, 100),
             awardsList: filterArr2,
           };
 
@@ -450,6 +488,10 @@ export default {
       this.coinTableVisible = false;
     },
 
+    changeType(e) {
+      this.$refs.awards.changetype(e)
+    },
+
     // 添加奖品种类
     handleCommand(e) {
       if (e == "goods") {