zxl
6 小时以前 9797e46619f64bddb78d4b4eaa03d53069ac2ba4
manager/src/views/activity-prize/index.vue
@@ -78,7 +78,7 @@
              @click="publishPrizeActivity(row)"
              :loading="row.statusLoading"
            >
              {{row.enableStatus === 'on' ? '关闭' : '开启'}}
              {{row.enableStatus === 'ON' ? '关闭' : '开启'}}
            </Button>
            <Button
              type="info"
@@ -88,18 +88,27 @@
            <Button
              type="info"
              size="small"
              :disabled="!row.canSet"
              @click="setPrize(row)"
            >奖品设置</Button>
            <Button
              type="info"
              size="small"
              @click="openEdit(row)"
            >编辑</Button>
            <Button
              type="error"
              size="small"
              @click="delById(row)"
            >删除</Button>
              :disabled="row.popup"
              @click="setPopup(row)"
              >
              弹窗活动
            </Button>
<!--            <Button-->
<!--              type="info"-->
<!--              size="small"-->
<!--              @click="openEdit(row)"-->
<!--            >编辑</Button>-->
<!--            <Button-->
<!--              type="error"-->
<!--              size="small"-->
<!--              @click="delById(row)"-->
<!--            >删除</Button>-->
          </div>
        </template>
@@ -282,8 +291,8 @@
          <Col span="24">
            <div class="detail-item">
              <label>活动状态:</label>
              <Tag :color="detailData.enableStatus === 'on' ? 'success' : 'default'">
                {{ detailData.enableStatus === 'on' ? '已启用' : '未启用' }}
              <Tag :color="detailData.enableStatus === 'ON' ? 'success' : 'default'">
                {{ detailData.enableStatus === 'ON' ? '已启用' : '未启用' }}
              </Tag>
            </div>
          </Col>
@@ -334,7 +343,7 @@
                    </span>
                        </Col>
                        <Col span="12">
                          <span>概率: {{ prize.probability}}%</span>
                          <span>概率: {{ prize.prizeProbability}}%</span>
                        </Col>
                      </Row>
                    </div>
@@ -437,7 +446,7 @@
                    v-model="row.prizeNum"
                    :min="1"
                    :max="999999"
                    placeholder="请输入每日最大中奖数"
                    placeholder="数量"
                    style="width: 100%"
                    @on-change="(val) => handlePrizeNumChange(val, index)"
                  ></InputNumber>
@@ -489,7 +498,8 @@
  del,
  addActivityRefPrizeList,
  getActivityRefPrizeByActivityId,
  publishPrizeActivity
  publishPrizeActivity,
  popup
} from '@/api/activity-prize.js'
import {delByKey, uploadFileByLmk} from "../../api/common";
@@ -656,7 +666,7 @@
        prizeNum:0,
        activityImg:'',
        activityCover:'',
        enableStatus:'off'
        enableStatus:''
      },
      loading:false,
      columns:[
@@ -707,9 +717,9 @@
          render: (h, params) => {
            return h('Tag', {
              props: {
                color: params.row.enableStatus  === 'on' ? 'green' : 'default'
                color: params.row.enableStatus  === 'ON' ? 'green' : 'default'
              }
            }, params.row.enableStatus === 'on' ? '开启' : '关闭')
            }, params.row.enableStatus === 'ON' ? '开启' : '关闭')
          }
        },
        {
@@ -746,6 +756,16 @@
    this.init();
  },
  methods: {
    setPopup(row){
      popup(row.id).then(res =>{
        if (res.code === 200){
          this.$Message.success(res.msg)
          this.getPage()
        }else {
          this.$Message.error(res.msg)
        }
      })
    },
    handleProbabilityInput(event, index) {
      const inputValue = event.target.value;
      let numericValue = parseFloat(inputValue);
@@ -787,7 +807,6 @@
    // 格式化奖品类型
    replaceText(type) {
      console.log(type)
      if (type === "coupon") {
        return "优惠券";
      }
@@ -820,7 +839,7 @@
    },
    // 检查奖品是否已被选择
    isPrizeChosen(prizeId) {
      return this.choiceData.some(item => item.id === prizeId);
      return this.choiceData.some(item => item.prizeId === prizeId);
    },
    choicePrize(row){
      //判断数组长度
@@ -828,7 +847,9 @@
        this.$Message.warning("最多添加5个奖品")
        return;
      }
      console.log(row.prizeId)
      if (this.isPrizeChosen(row.id)){
        this.$Message.warning("已添加")
        return;
      }
@@ -895,11 +916,11 @@
    //奖品设置
    setPrize(row){
      //判断是否启动,若启动则,无法编辑
      if("on" === row.enableStatus){
      if("ON" === row.enableStatus){
        this.$Message.error("抽奖已开启,不能编辑!")
        return
      }
      //判断是否已有奖品有的话不让设置
      this.activityPrizeId = row.id;
      this.getPrizeList();
      this.prizeSettingShow = true;
@@ -908,6 +929,9 @@
      getActivityRefPrizeByActivityId(row.id).then(res =>{
        this.choiceLoading = false;
        if (res.code === 200){
          res.data.forEach(item =>{
            item.id =null;
          })
          this.choiceData = res.data
        }
@@ -1068,25 +1092,29 @@
      console.log(this.detailData)
    },
    openEdit(row){
      this.modelShow = true;
      this.modelTitle = "编辑活动";
      this.activityFrom= {
        id:row.id,
        activityName:row.activityName,
        activityDes:row.activityDes,
        beginTime:this.formatDate(row.beginTime, 'YYYY-MM-DD HH:mm:ss'),
        endTime: this.formatDate(row.endTime, 'YYYY-MM-DD HH:mm:ss'),
        maxPrize:row.maxPrize,
        prizeNum:row.prizeNum,
        activityImg:row.activityImg,
        activityCover:row.activityCover,
        enableStatus:row.enableStatus,
      }
      this.coverTempUrl = row.activityCoverUrl;
      this.imgTempUrl = row.activityImgUrl;
    },
    // openEdit(row){
    //   if("ON" === row.enableStatus){
    //     this.$Message.error("抽奖已开启,不能编辑!")
    //     return
    //   }
    //   this.modelShow = true;
    //   this.modelTitle = "编辑活动";
    //   this.activityFrom= {
    //     id:row.id,
    //     activityName:row.activityName,
    //     activityDes:row.activityDes,
    //     beginTime:this.formatDate(row.beginTime, 'YYYY-MM-DD HH:mm:ss'),
    //     endTime: this.formatDate(row.endTime, 'YYYY-MM-DD HH:mm:ss'),
    //     maxPrize:row.maxPrize,
    //     prizeNum:row.prizeNum,
    //     activityImg:row.activityImg,
    //     activityCover:row.activityCover,
    //     enableStatus:row.enableStatus,
    //   }
    //   this.coverTempUrl = row.activityCoverUrl;
    //   this.imgTempUrl = row.activityImgUrl;
    //
    // },
    handleSearch(type,value){
      if (type === 'beginTime') {
@@ -1098,6 +1126,7 @@
    },
    openAdd(){
      this.$refs.form.resetFields()
      this.activityFrom.id = null;
      this.modelShow = true;
      this.modelTitle = "新增活动";
      this.coverTempUrl = null;
@@ -1105,16 +1134,21 @@
      this.prizeImg = null;
      this.imgTempUrl = null;
    },
    delById(row){
      del(row.id).then(res=>{
        if (res.code === 200){
          this.$Message.success(res.msg)
        }else {
          this.$Message.error(res.msg)
        }
        this.getPage()
      })
    },
    // delById(row){
    //   if("ON" === row.enableStatus){
    //     this.$Message.error("抽奖已开启,无法删除!")
    //     return
    //   }
    //   //若关联商品不让删
    //   del(row.id).then(res=>{
    //     if (res.code === 200){
    //       this.$Message.success(res.msg)
    //     }else {
    //       this.$Message.error(res.msg)
    //     }
    //     this.getPage()
    //   })
    // },
    // 获取富文本编辑器的内容
    // 初始化数据
    init() {
@@ -1138,15 +1172,15 @@
      this.prizeSearchForm.pageNumber = page
      this.getPrizeList()
    },
    publishPrizeActivity(row){
      publishPrizeActivity(row.id).then(res =>{
    async publishPrizeActivity(row){
      await publishPrizeActivity(row.id).then(res =>{
        if (res.code === 200){
          this.$Message.success(res.msg)
        }else{
          this.$Message.error(res.msg)
        }
      })
      this.getPage()
      await this.getPage()
    },
  },