Model.vue 14.8 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422
<template>
  <GLDialog v-if="visible" :title="title" :visible.sync="visible" mode="big" :before-close="handleClose">
    <el-form :model="tplForm" class="basic-form" :rules="tplRules" ref="tplForm" label-width="154px">
      <template v-if="[7, 8, 9].includes(taskType)">
        <el-form-item label="跟进员工类型:" prop="followerTypeId">
          <el-select v-model="tplForm.followerTypeId" @change="valueChange" @focus="groupFocus" :size="size" value-key="id" placeholder="请选择">
            <el-option v-for="item in followList" :key="item.id" :label="item.followName" :value="item.id"></el-option>
          </el-select>
        </el-form-item>
      </template>

      <el-form-item :label="labelName + ':'">
        <GLEditor ref="welcome" :form="'customer'" :mapList="mapList" style="line-height: 12px; width: 580px" :maxNum="maxNum" boxHeight="200" :btnList="btnList" @previewWord="previewForm"></GLEditor>
      </el-form-item>
    </el-form>
    <div class="explain" v-show="taskType == 8 || taskType == 9">
      说明:
      <div>
        素材和活动属于营销链接,与图片、视频最多仅支持选择一种类型;
        <br />
        营销链接最多可在素材和活动中各选一个;
        <br />
        图片支持格式:.jpg .png,最多可上传9张,大小不超过10M,尺寸不超过1080*1080;
        <br />
        视频支持格式:.mp4,最多可上传1个,大小不超过10M,时长不超过30s。
        <br />
      </div>
    </div>
    <div class="explain" v-show="taskType == 5 || taskType == 7">
      示例

      <div>
        · 设定内容:您有{客户人数}位客户已进入可报价3天,请及时进行报价跟进。
        <br />
        · 实际发送内容:您有10位客户已进入可报价3天,请及时进行报价跟进。
        <br />
      </div>
    </div>
    <div class="explain" v-show="taskType == 10">提示:请及时联系运营人员完成短信签名认证,否则将影响短信发送</div>
    <span slot="footer" class="dialog-footer">
      <el-button size="small" @click="handleClose">取 消</el-button>
      <el-button size="small" type="primary" @click="handleSelect">确 定</el-button>
    </span>
  </GLDialog>
</template>
<script>
const ATT_TYPE = {
  TEXT: 1,
  IMAGE: 2,
  VEDIO: 3,
  URL: 4,
  MINIPROGRAM: 5,
  FILE: 6,
  ACTIVITY: 7
}
export default {
  props: {
    tplVisible: Boolean,
    taskType: {
      type: String,
      default: '7'
    },
    taskParam: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      visible: false,
      maxNum:50,
      labelName: '',
      tplForm: {
        followerTypeId: '',
        staffUserIds: '',
        attachments: [],
        attContentList: []
      },
      tplRules: {
        followerTypeId: [{ required: true, message: '请选择员工类型', trigger: 'change' }]
      },
      followList: [],

      btnList: [],
      mapList: {
        客户人数: '${dataSize}'
      }
    }
  },
  watch: {
    tplVisible(newVal) {
      this.visible = newVal
      this.getFollowListType()
      if (this.taskParam) {
        this.tplForm = {
          ...this.taskParam
        }
        if (this.tplForm.attContentList.length) {
          this.$nextTick(() => {
            this.$refs.welcome && this.$refs.welcome.updateList(this.tplForm.attContentList)
          })
        }
      }
    },
    taskType(newVal) {
      this.changeEdit(newVal)
      switch (this.taskType) {
        case 7:
          this.title = '企微提醒模版'
          this.labelName = '提醒内容'
          this.maxNum = 50
          break
        case 5:
          this.title = '门店助手提醒模版'
          this.labelName = '提醒内容'
          this.maxNum = 50
          break
        case 8:
        case 9:
          this.title = '营销模板'
          this.labelName = '营销内容'
          this.maxNum = 200
          break
        case 10:
          this.title = '短信模版'
          this.labelName = '短信内容'
          this.maxNum = 50
          break
      }
    }
  },
  methods: {
    renderParameter(options) {
      let { id, type } = options
      let obj = {
        3: `{"appId":"wxe10067a63c1856ac","title":"送您一张专属权益服务卡","page":"packageShopmall/packageEquity/pages/freecard/freecard?id=${id}&merchantId={1}&nodeId={2}&sopId={3}","pic_url":"http://img01.glsx.com.cn/upload/biz/dracMini-qy-10004.png"}`,
        4: `{"appId":"wxe10067a63c1856ac","title":"专属权益服务套餐","page":"packageShopmall/packageEquity/pages/package/package?id=${id}&merchantId={1}&nodeId={2}&sopId={3}","pic_url":"http://img01.glsx.com.cn/upload/biz/dracMini-qy-10004.png"}`,
        2: `{"appId":"wxe10067a63c1856ac","title":"送您一张商城优惠券","page":"packageShopmall/packageMall/pages/coupon/coupon?couponId=${id}&merchantId=&{1}&issueDate={3}&nodeId={2}&sopId={3}","pic_url":"http://img01.glsx.com.cn/upload/biz/dracMini-yh-10004.png"}`,
        5: `{"appId":"wxe10067a63c1856ac","title":"您有一个秒杀活动可参加","page":"packageShopmall/packageMall/pages/detail/detail?isActivity=true&id=${id}&merchantId={1}&nodeId={2}&sopId={3}","pic_url":"http://img01.glsx.com.cn/upload/biz/dracMini-ms-10004.png"}`,
        8: `{"appId":"wxe10067a63c1856ac","title":"您有一个众筹活动可参加","page":"pages/crowdfunding/index/index?isActivity=true&id=${id}&merchantId={1}&nodeId={2}&sopId={3}","pic_url":"http://img01.glsx.com.cn/upload/biz/dracMini-ms-10004.png"}`,
        7: `{"appId":"wxb818f6bc908c52fc","title":"您有一个新资讯,请及时查看","page":"packageMine/pages/questionnaire/questionnaire?id=${id}&merchantId={1}&nodeId={2}&sopId={3}","pic_url":"http://img01.glsx.com.cn/upload/biz/dracMini-ms-10004.png"}`,
        6: `{"appId":"wxe10067a63c1856ac","title":"您有一个新资讯,请及时查看","page":"pages/psdView/psdView?id=${id}&merchantId={1}&nodeId={2}&sopId={3}","pic_url":"http://img01.glsx.com.cn/upload/biz/dracMini-ms-10004.png"}`
      }
      return obj[type]
    },
    changeEdit(taskType) {
      if (taskType == 7 || taskType == 5) {
        this.btnList = [
          {
            type: '客户人数',
            name: '客户人数'
          }
        ]
      } else if (taskType == 10) {
        this.btnList = [
          {
            name: '活动',
            type: 'activity',
            funName: 'activity',
            togetherItem: [ATT_TYPE.TEXT],
            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,
                  activityStatusList: [1, 2],
                  currentPage: 1
                }
              },
              {
                itemName: '众筹活动',
                itemValue: 8,
                itemType: 'crowdfunding',
                getInterfaceApi: this.$apis.welcomeword.crowdfundingActivity,
                params: {
                  currentPage: 1,
                  activityStatus: 2
                }
              },
              {
                itemName: '问卷调查',
                itemValue: 7,
                itemType: 'questionnaire',
                getInterfaceApi: this.$apis.welcomeword.activityQuestionnaireForm,
                params: {
                  merchantId: this.$globalState.session.merchantId,
                  statuses: [0, 1]
                }
              }
            ]
          },
          {
            name: '素材',
            type: 'material',
            funName: 'material',
            togetherItem: [ATT_TYPE.TEXT],
            fileType: true,
            groupListApi: this.$apis.welcomeword.getGroupListApi,
            materialListApi: this.$apis.welcomeword.getMaterialListApi
            // pdfNo: 1
            // videoNo: 1
          }
        ]
      } else {
        this.btnList = [
          {
            name: '表情',
            funcName: '',
            type: 'expression',
            limitSize: 10
          },
          {
            name: '图片',
            funcName: '',
            togetherItem: [ATT_TYPE.TEXT],
            type: 'img',
            // togetherItem: [ATT_TYPE.TEXT], //只允许文本和图片
            limitSize: 10, //限制图片大小
            limitNum: 9, //限制图片数量
            limitWidth: 10800, //限制单张图片宽度
            limitHeight: 1080, //限制单张图片高度
            // Isdraggable: true, //图片拖拽
            uploadApi: this.$apis.common.pictureUpload
          },
          {
            name: '活动',
            type: 'activity',
            funName: 'activity',
            togetherItem: [ATT_TYPE.TEXT],
            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,
                  activityStatusList: [1, 2],
                  currentPage: 1
                }
              },
              {
                itemName: '众筹活动',
                itemValue: 8,
                itemType: 'crowdfunding',
                getInterfaceApi: this.$apis.welcomeword.crowdfundingActivity,
                params: {
                  currentPage: 1,
                  activityStatus: 2
                }
              },
              {
                itemName: '问卷调查',
                itemValue: 7,
                itemType: 'questionnaire',
                getInterfaceApi: this.$apis.welcomeword.activityQuestionnaireForm,
                params: {
                  merchantId: this.$globalState.session.merchantId,
                  statuses: [0, 1]
                }
              }
            ]
          },
          {
            name: '素材',
            type: 'material',
            funName: 'material',
            togetherItem: [ATT_TYPE.TEXT],
            fileType: true,
            groupListApi: this.$apis.welcomeword.getGroupListApi,
            materialListApi: this.$apis.welcomeword.getMaterialListApi
            // pdfNo: 1
            // videoNo: 1
          },
          {
            name: '视频',
            funcName: '',
            type: 'video',
            togetherItem: [ATT_TYPE.TEXT],
            limitSize: 10, //限制视频大小
            //   togetherItem: [ATT_TYPE.TEXT], //只允许文本和图片
            limitNum: 1, //限制视频数量
            // limitWidth: 1280, //限制视频宽度
            // limitHeight: 720, //限制视频高度
            limitTime: 30, //限制视频时长
            paramsType: 'form-data',
            uploadApi: this.$apis.common.compressVideo
          }
        ]
      }
    },
    //跟进员工类型
    getFollowListType() {
      this.$apis.journeyConfig.getFollowListType({ flag: 0 }).then(res => {
        this.followList = res
      })
    },
    //根据跟进员工类型获取员工
    valueChange(val) {
      let staffUserIds = []
      this.$apis.journeyConfig.getStaffList({ followerTypeId: val, pageNum: 1, pageSize: 9999 }).then(res => {
        res.data.forEach(val => {
          staffUserIds.push(val.userId)
        })
        this.tplForm.staffUserIds = staffUserIds.join(',')
        this.tplForm.followName = this.followList.filter(item => item.id == val)[0].followName
      })
    },
    previewForm(val) {
      const value = this.$common.utils.deepClone(val)
      if (value[0] && !value[0].attContent) value.splice(0, 1)
      this.tplForm.attContentList = this.$common.utils.deepClone(value)
      value.forEach(activity => {
        let opts
        if (activity.attType == 7) {
          opts = {
            type: activity.attContent.marketingType,
            id: activity.attContent.marketingId
          }
          activity.attContent = this.renderParameter(opts)
          activity.attType = 4
        } else if (activity.attType == 6) {
          opts = {
            type: activity.attType,
            id: JSON.parse(activity.attContent).objectId
          }
          activity.attContent = this.renderParameter(opts)
          activity.attType = 4
        }
      })
      this.tplForm.attachments = value
    },
    handleClose() {
      this.$emit('dialogClose', false)
    },
    handleSelect() {
      this.$refs.tplForm.validate(valid => {
        if (valid) {
          if (this.tplForm.attachments.length == 0) {
            this.$message.error(`请输入${this.labelName}`)
            return
          }
          this.$emit('confirm', this.tplForm)
        }
      })
    }
  }
}
</script>
<style scoped lang="scss">
.explain {
  font-size: 14px;
  color: #999999;
  line-height: 22px;
  margin: -12px 0 0 154px;
}
</style>