Browse Source

Merge branch 'dev' of mangpiao/mp-ui-pc into test

lsx 2 years ago
parent
commit
53c5294454

+ 2 - 0
src/views/business/ticket/components/AwardsList.vue

@@ -57,6 +57,7 @@
                 <div v-if="scope.row.prizeType == 'coupon'">券</div>
                 <div v-if="scope.row.prizeType == 'coupon_pkg'">券包</div>
                 <div v-if="scope.row.prizeType == 'coin'">盲豆</div>
+                <div v-if="scope.row.prizeType == 'red_pkg'">微信红包</div>
               </template>
             </el-table-column>
             <el-table-column label="商品价格">
@@ -120,6 +121,7 @@
               <el-dropdown-item command="coupon">券</el-dropdown-item>
               <el-dropdown-item command="coupon_pkg">券包</el-dropdown-item>
               <el-dropdown-item command="coin">盲豆</el-dropdown-item>
+              <el-dropdown-item command="red_pkg">微信红包</el-dropdown-item>
             </el-dropdown-menu>
           </el-dropdown>
         </div>

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

@@ -64,7 +64,7 @@ export default {
         quantity: 1,
         title: `盲豆 x${this.coinForm.quantity}`,
         picUrl: publicFileGetUrl + "md.png",
-        coinValue: this.coinForm.quantity,
+        value: this.coinForm.quantity,
         sortWeight: 100
       };
       this.$refs["coinForm"].validate((valid) => {

+ 94 - 0
src/views/business/ticket/components/RedPkgAdd.vue

@@ -0,0 +1,94 @@
+<template>
+  <div>
+    <el-dialog
+      title="添加微信红包奖品"
+      :visible.sync="dialogVisible"
+      :before-close="close"
+      width="500px"
+    >
+      <el-form
+        :model="packetForm"
+        :rules="packetRules"
+        ref="packetForm"
+        label-width="100px"
+      >
+        <el-form-item label="金额" prop="quantity">
+          <el-input
+            v-model="packetForm.quantity"
+            size="small"
+            placeholder="请输入微信红包金额"
+            style="width: 200px"
+          />
+        </el-form-item>
+      </el-form>
+      <div class="dialog-btn">
+        <el-button size="small" @click="close"> 取 消 </el-button>
+        <div class="ge"></div>
+        <el-button type="primary" size="small" @click="confirmRedPkg">
+          确 认
+        </el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+<script>
+import { publicFileGetUrl } from "@/api/common";
+export default{
+  name: "RedPkgAdd",
+  props: {
+    dialogVisible: {
+      type: Boolean,
+      default: false,
+    },
+  },
+  data() {
+    return {
+      packetForm: { quantity: "" },
+      packetRules: {
+        quantity: [
+          { required: true, message: "请输入金额", trigger: "blur" },
+          {
+            pattern: /^([1-9]\d*)$/,
+            message: "请输入合法的金额数字,需要为正整数",
+            trigger: ["blur", "change"],
+          },
+        ],
+      },
+    };
+  },
+  methods: {
+    // 确认输入金额
+    confirmRedPkg() {
+      let redPacket = {
+        prizeType: "red_pkg",
+        quantity: 1,
+        title: `微信红包 ${this.packetForm.quantity}元`,
+        picUrl: publicFileGetUrl + "static/redPkg.png",
+        value: this.packetForm.quantity,
+        sortWeight: 100
+      };
+      this.$refs["packetForm"].validate((valid) => {
+        if (valid) {
+          this.$emit("confirmRedPkg", redPacket);
+        } else {
+          return false;
+        }
+      });
+    },
+    close() {
+      this.$emit("close");
+    },
+  },
+};
+</script>
+<style lang="scss" scoped>
+.dialog-btn {
+  display: flex;
+  align-content: center;
+  justify-content: flex-end;
+  padding: 40px 0 0;
+  .ge {
+    width: 40px;
+  }
+}
+</style>

+ 27 - 4
src/views/business/ticket/create.vue

@@ -215,6 +215,8 @@
     <coupon-pkg-add :dialog-visible="couponPkgTableVisible" :iconic="iconic" @close="close" @confirmCouponPkgForm="confirmCouponPkgForm" @confirmCouponPkg="confirmCouponPkg" v-if="couponPkgTableVisible" />
     <!-- 添加盲豆 -->
     <coin-add :dialog-visible="coinTableVisible" @close="close" @confirmCoin="confirmCoin" v-if="coinTableVisible" />
+    <!-- 添加微信红包 -->
+    <red-pkg-add :dialog-visible="redPkgTableVisible" @close="close" @confirmRedPkg="confirmRedPkg" v-if="redPkgTableVisible" />
    </div>
 </template>
 <script>
@@ -231,6 +233,7 @@ import CouponAdd from "./components/CouponAdd"
 import CouponPkgAdd from "./components/CouponPkgAdd"
 import CoinAdd from "./components/CoinAdd"
 import AwardForm from "./components/AwardForm"
+import RedPkgAdd from './components/RedPkgAdd.vue';
 export default {
   name: "TicketCreate",
   mixins: [CustomFieldsMixin],
@@ -242,6 +245,7 @@ export default {
     CoinAdd,
     Upload,
     AwardForm,
+    RedPkgAdd,
   },
   data() {
     return {
@@ -262,6 +266,7 @@ export default {
         originPrice: 0, //划线价
         disabled: false,
         saleChannelType: 1,//销售范围类型
+        isHaveRedPkg: 0,
       },
       // 门店列表
       siteList: [],
@@ -371,6 +376,7 @@ export default {
       couponTableVisible: false, // 添加卡券弹框
       couponPkgTableVisible: false, // 添加券包弹框
       coinTableVisible: false, // 添加盲豆弹框
+      redPkgTableVisible: false, //添加微信红包
       pageParams: {
         pageNum: 1,
         pageSize: 10,
@@ -511,6 +517,18 @@ export default {
             return;
           }
 
+          this.form.isHaveRedPkg = 0
+
+          for (let i = 0; i < this.awardsList.length; i++) {
+            const item = this.awardsList[i];
+            for (let j = 0; j < item.prizeList.length; j++) {
+              if(item.prizeList[j].prizeType == 'red_pkg') {
+                this.form.isHaveRedPkg = 1
+                break
+              }
+            }
+          }
+
           let prizeIndex = this.awardsList.findIndex((item) => {
             return !item.prizeList.length && item.quantity > 0;
           });
@@ -549,7 +567,7 @@ export default {
                 refId: ele.goodsId || ele.couponId || ele.id,
                 prizeType: ele.prizeType,
                 quantity: ele.quantity,
-                value: Number(ele.coinValue),
+                value: Number(ele.value),
               };
             });
           });
@@ -640,6 +658,7 @@ export default {
       this.couponTableVisible = false;
       this.couponPkgTableVisible = false;
       this.coinTableVisible = false;
+      this.redPkgTableVisible = false;
     },
 
     changeType(e) {
@@ -662,6 +681,9 @@ export default {
       }else if(e == "ticketGoods") {
         this.iconic = 'goods'
         this.goodsTableVisible2 = true;
+      }else if(e == "red_pkg") {
+        this.iconic = 'redPacket'
+        this.redPkgTableVisible = true;
       }
     },
     goodsCommand(e) {
@@ -688,17 +710,18 @@ export default {
     confirmCoupon(arr) {
       this.$refs.awards.add(1, arr)
     },
-
     // 确认选中券包
     confirmCouponPkg(arr) {
       this.$refs.awards.add(1, arr)
     },
-
     // 确认输入盲豆
     confirmCoin(obj) {
       this.$refs.awards.add(2, obj)
     },
-
+    // 确认输入金额
+    confirmRedPkg(obj) {
+      this.$refs.awards.add(2, obj)
+    },
     //选中的关联商品
     confirmGoodsForm(arr) {
       this.$refs.awardFrom.add(1,arr)