addMaterial.vue 8.09 KB
<template>
  <div class="live-room">
    <div class="m-b-20 container-nop">
      <div class="border-title">
        基本信息
      </div>
      <div class="container">
        <glsx-combi-form :isInline="false" class="glsx-combi-form" ref="baseInfoRef" labelWidth="154px" defaultWidth="432px" :formObj="formObj" :formData="formData" :formRules="myRule">
          <div slot="welcomeWordMaterial">
            <GLEditor ref="welcome" :form="'customer'" style="line-height: 12px;" :btnList="btnList"></GLEditor>
          </div>
        </glsx-combi-form>
      </div>
    </div>
    <GLFooter>
      <el-button @click="handleCancel">取消</el-button>
      <el-button type="primary" @click="handleSave">确定</el-button>
    </GLFooter>
  </div>
</template>

<script>
import glsxCombiForm from '@/components/glsx-combi-form'
import { addWelcomeGroup } from '@/api/modules/clientGroupManage'

export default {
  name: 'addMaterial',
  components: {
    glsxCombiForm
  },
  data() {
    return {
      haveActivity: true,
      formObj: {
        attachName: '',
        notify: 0
      },
      myRule: {
        attachName: [{ required: true, message: '请输入资料名称', trigger: 'change' }],
        notify: [{ required: true, message: '消息通知', trigger: 'change' }]
        // attachmentList: [{ required: true, message: '请选择视频', trigger: 'change' }],
      },
      formData: [
        {
          label: '资料名称',
          name: 'attachName',
          maxlength: 50,
          showLimit: true,
          type: 'input',
          isDisabled: false
        },
        {
          label: '群聊欢迎语素材',
          name: 'attachmentList',
          addHtml: 'welcomeWordMaterial'
        },
        {
          label: '消息通知',
          name: 'notify',
          type: 'radio',
          optionId: 'optionId',
          optionLabel: 'optionLabel',
          optionList: [
            {
              optionId: 0,
              optionLabel: '不通知'
            },
            {
              optionId: 1,
              optionLabel: '通知'
            }
          ]
        }
      ],
      btnList: [
        // {
        //   name: '表情',
        //   funcName: '',
        //   type: 'expression',
        //   limitSize: 10
        // },
        // {
        //   name: '图片',
        //   funcName: '',
        //   type: 'img',
        //   uploadApi: this.$apis.common.pictureUpload
        // },
        {
          name: '活动',
          type: 'activity',
          funName: 'activity',
          funParams: [
            {
              itemName: '权益卡试用',
              itemValue: 3,
              itemType: 'card',
              getInterfaceApi: this.$apis.welcomeword.getCard,
              params: {
                tryAble: 1,
                merchantId: this.$globalState.session.merchantId
              }
            },
            {
              itemName: '权益套餐',
              itemValue: 4,
              itemType: 'package',
              getInterfaceApi: this.$apis.welcomeword.getPackage,
              params: {
                state: 1
              }
            },
            {
              itemName: '商城券',
              itemValue: 2,
              itemType: 'coupon',
              getInterfaceApi: this.$apis.welcomeword.getMerchant,
              params: {
                discountTypes: [2, 3, 4],
                directionalFlag: 1, // 1所有人可用2定向礼包专用3关联优惠券
                validType: 'valid',
                status: 2
              }
            }
            // {
            //   itemName: '秒杀活动',
            //   itemValue: 5,
            //   itemType: 'activity',
            //   getInterfaceApi: this.$apis.welcomeword.getActivity,
            //   // params: {
            //   //   activityStatus: 2,
            //   //   currentPage: 1
            //   // }
            // },
            // {
            //   itemName: '无忧服务',
            //   itemValue: 6,
            //   itemType: 'merchant',
            //   getInterfaceApi: this.$apis.welcomeword.merchant,
            //   merchantOpen: {
            //     merchantOpenApi: this.$apis.welcomeword.merchantOpen,
            //     params: {
            //       merchantId: this.$globalState.session.merchantId
            //     }
            //   },
            //   params: {
            //     merchantId: this.$globalState.session.merchantId
            //   }
            // },
            // {
            //   itemName: '众筹活动',
            //   itemValue: 7,
            //   itemType: 'crowdfunding',
            //   getInterfaceApi: this.$apis.welcomeword.crowdfundingActivity,
            //   params: {
            //     currentPage: 1,
            //     activityStatus: 2
            //   }
            // }
          ]
        }
        // {
        //   name: '素材',
        //   type: 'material',
        //   funName: 'material',
        //   groupListApi: this.$apis.welcomeword.getGroupListApi,
        //   materialListApi: this.$apis.welcomeword.getMaterialListApi,
        //   params: {
        //     merchant: this.$globalState.session.merchantId
        //   }
        // },
        // {
        //   name: '模板',
        //   type: 'message',
        //   funName: 'message',
        //   getSearchApi: this.$apis.welcomeword.createdNameList,
        //   templateApi: this.$apis.welcomeword.templatePage,
        //   templateUpdateApi: this.$apis.welcomeword.templateUpdate,
        //   templateSaveApi: this.$apis.welcomeword.templateSave,
        //   templateDetailApi: this.$apis.welcomeword.templateDetail,
        //   params: {
        //     merchant: this.$globalState.session.merchantId
        //   }
        // }
      ]
    }
  },
  methods: {
    handleCancel() {
      this.$emit('changeTab', 1)
    },
    handleSave() {
      this.$refs.baseInfoRef.$refs.formRef.validate(valid => {
        if (valid) {
          let params = JSON.parse(JSON.stringify(this.formObj))
          const previewList = this.$common ? this.$common.utils.deepClone(this.$refs.welcome.previewList) : this.$refs.welcome.previewList

          // 校验是否有填活动
          // this.haveActivity = previewList.find(item => item.attType == 7)
          // if (!this.haveActivity) return

          const attachmentList = previewList.map(item => {
            if (item && item.attType == 7) {
              item.attContent = JSON.stringify(item.attContent)
            }
            return item
          })
          params.attachmentList = attachmentList
          addWelcomeGroup(params).then(res => {
            if (res.data) {
              this.$message.success('新增素材成功')
              this.handleCancel()
            } else {
              this.$message.error(res.message || '新增素材失败')
            }
          })
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
@import '@/styles/variables.scss';
@import '@/styles/resetelement.scss';

.scrm-sub-client-container {
  .pageTitle {
    position: relative;
    margin-bottom: 20px;
    height: 20px;
    font-size: 20px;
    font-weight: 700;
    color: #333333;
    line-height: 20px;
    letter-spacing: 1px;
  }

  .pageContent {
    .leadList {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 8px;

      div {
        text-align: center;

        span:nth-child(1) {
          font-weight: 600;
          font-size: 16px;
        }
      }

      /deep/ .el-button {
        color: #5850ff;
        border: 1px solid #5850ff;
      }
    }

    .glsx-table {
      /deep/ .el-table__fixed,
      /deep/ .el-table__fixed-right {
        height: 100% !important; //设置高优先,以覆盖内联样式
      }
    }

    padding: 20px 20px 30px;
    // min-width: 1300px;
    background-color: #fff;

    .el-button + .el-button {
      margin-left: 10px;
    }
  }

  .el-message--info {
    height: 40px;
    background: #e6e9ff;
    border: 1px solid $btnBlue;
    border-radius: 4px;
    font-size: 14px;
    color: rgba(0, 0, 0, 0.65);
  }

  .el-message .el-icon-info {
    color: $btnBlue;
    font-size: 16px;
  }
}
</style>