StepOne.vue 6.88 KB
<template>
  <el-scrollbar class="step-box">
    <div class="step-content">
      <glsx-combi-form
        ref="formRef"
        :isEdit="true"
        :isBlock="true"
        :formObj="form"
        :formData="formData"
        :formRules="rule"
      >
        <template #merchantId>
          <el-select
            v-model="form.merchantId"
            placeholder="请选择"
            filterable
            remote
            :remote-method="remoteMethod"
            v-reachbottom="onReachBottom"
            @focus="selectFocus"
            :loading="loading"
          >
            <el-option
              v-for="item in merchantObj.data"
              :key="item.confId"
              :label="item.confName"
              :value="item.confId"
            ></el-option>
            <template v-if="nothing">
              <div class="nothing">到底了!</div>
            </template>
          </el-select>
        </template>
        <template #activity>
          <div class="tabs flex">
            <template v-for="(i,index) in tabs">
              <template>
                <div
                  @click="changeActivity(index)"
                  :class="['tab',{active:index == tabIndex}]"
                  :key="index"
                >{{i}}</div>
              </template>
            </template>
          </div>
          <div
            class="activity-box"
            :key="activityKey"
          >
            <template v-for="(i,index) in activityList">
              <template>
                <div
                  @click="chooseRed(i.id)"
                  :key="index"
                  :class="['item',{'active': form.activityId == i.id}]"
                >
                  <div class="icon">
                    <img src="@/assets/red-radio.png" />
                  </div>
                  <div class="title">{{ i.activityName }}</div>
                  <div class="type">活动形式:{{ {
                       0: '随机红包', 1: '九宫格', 2: '翻牌', 3: '大转盘' 
                    }[i.activityType] }}</div>
                  <div class="time">活动时间:{{dayjs(i.activityStartTime).format('YYYY/MM/DD')}} - {{dayjs(i.activityEndTime).format('YYYY/MM/DD')}}</div>
                  <div class="status">状态:{{ {
                       0: '活动待进行', 1: '活动进行中', 2: '红包已用完', 3: '活动已结束' 
                    }[i.activityStatus] }}</div>
                </div>
              </template>
            </template>
          </div>
        </template>
      </glsx-combi-form>
    </div>
  </el-scrollbar>
</template>

<script type='text/ecmascript-6'>
import * as dayjs from 'dayjs'
import { getMerchantListMixin } from '@/mixins'
export default {
  name: 'StepOne',
  mixins:[getMerchantListMixin],
  data () {
    return {
      dayjs,
      configForm: {
        merchantId: '',
        activityImg: ''
      },
      rule: {
        activityName: [{ required: true, message: '请输入问卷名称', trigger: 'change' }],
        merchantId: [{ required: true, message: '请选择所属渠道', trigger: 'change' }],
        activityTime: [{ required: true, message: '请输入卡片标题', trigger: 'change' }],
        activityImg: [{ required: true, message: '请上传卡片封面', trigger: 'change' }],
      },
      formData: [
        {
          label: '问卷名称',
          name: 'activityName',
          type: 'input',
          maxlength: 50,
        },
        {
          label: '所属渠道',
          type: 'select',
          name: 'merchantId',
          addHtml: 'merchantId'
        },
        {
          label: '卡片标题',
          name: 'activityTime',
          type: 'input',
          maxlength: 20,
        },
        {
          label: '卡片封面',
          name: 'activityImg',
          type: 'upload',
          width: '320px',
          // limitSize: 10,
          maxPhotoNum: 1,
          suffixSlot: 'activityImg',
          handleUpload: (e, file, targetItem) => {
            const imgFile = e.target.result,
              base64 = file.name.split('.')[file.name.split('.').length - 1] + '@' + imgFile.split(',')[1]
            this.$apis.common.pictureUpload({ file: base64, fileType: 'image' }).then(res => {
              this.configForm[targetItem.name] = res
              this.formRef().validateField(targetItem.name)
            })
          }
        },
        {
          label: '关联活动',
          addHtml: 'activity'
        }
      ],
      tabs: ['权益卡试用', '商城券', '红包活动'],
      tabIndex: 0,
      activityList: new Array(20).fill({}),
      activityKey: Date.now(),
      merchantObj: {
        nothing: false,
        data: [],
        currentPage: 1,
        name: '',
        loading: false,
        total: 0
      }
    }
  },
  mounted () {
  },
  methods: {
    formRef () {
      return this.$refs.formRef.$refs.formRef
    },

    changeActivity (index) {
      this.tabIndex = index
    }
  },

}
</script>

<style scoped lang='scss'>
.step-box {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  /deep/.el-scrollbar__wrap {
    &::-webkit-scrollbar {
      width: 0;
      height: 0;
      color: transparent;
    }
  }
  .step-content {
    padding-top: 32px;
  }
  /deep/.el-form-item__content {
    width: fit-content;
    max-width: calc(100% - 154px);
  }
  /deep/.activity-img,
  /deep/.muti-imgs {
    width: 104px;
    height: 104px;
    background: #0000000a;
    border: 1px dashed #00000026;
    border-radius: 4px;
    input {
      margin-top: 0;
    }
    .img-w-h,
    .img-btns {
      width: 100%;
      height: 100%;
    }
  }
  .tabs {
    height: 36px;
    background: #f8f8f8;
    border-radius: 4px;
    padding: 0 2px;
    width: fit-content;
    .tab {
      height: 32px;
      font-size: 14px;
      color: #666666;
      padding: 0 16px;
      cursor: pointer;
      transition: all 0.25s;
      &:hover {
        opacity: 0.85;
      }
    }
    .active {
      background: #ffffff;
      border-radius: 3px;
      font-weight: 500;
      color: #5850ff;
    }
  }
  .activity-box {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 16px;
    .item {
      width: 282px;
      height: 132px;
      background: #f9f9f9;
      border-radius: 4px;
      border: 2px solid #f9f9f9;
      box-sizing: border-box;
      cursor: pointer;
      padding: 0 16px;
      font-size: 14px;
      color: #666666;
      line-height: 20px;
      position: relative;
      .icon {
        display: none;
      }
      div {
        margin-top: 8px;
      }
      .title {
        font-weight: 500;
        font-size: 14px;
        color: #333333;
        padding-top: 4px;
      }
      &:hover {
        opacity: 0.95;
      }
    }
    .active {
      border-color: #5850ff;
      .icon {
        display: block;
        position: absolute;
        right: 0;
        bottom: 0;
        width: 16px;
        height: 16px;
        background-color: #5850ff;
      }
    }
  }
}
</style>