config.vue 20.7 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 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707
<template>
  <div class="square-main">
    <div class="drainage-wrap scrm-box-f">
      <div class="drainage-title">指定客户1</div>
      <div class="drainage-form">
        <div class="drainage-form-item">
          <label>客户信息1</label>
          <div class="upload-box">
            <div class="upload-file-panel">
              <el-upload action="" class="image-uploader" :before-upload="uploadFile">
                <div class="upload-btn">
                  <i class="el-icon-upload2"></i>
                  上传文件
                </div>
              </el-upload>
              <a class="download-url" href="https://img01.glsx.com.cn/weapp/resource/saas/scrm/xlsx/dractest.xlsx">下载导入模版</a>
            </div>
            <div class="upload-tips" v-if="importName">{{ importName }}</div>
            <div class="upload-tips">支持扩展名:xlsx、xls</div>
          </div>
        </div>
      </div>
    </div>
    <div class="drainage-wrap scrm-box-f">
      <div class="drainage-title">营销配置</div>
      <div class="form-main">
        <div class="drainage-form">
          <div class="drainage-form-item" v-if="editStatus">
            <label class="is-require">跟进员工</label>
            <el-popover placement="top" width="400" trigger="hover" content="通过导入的客户,门店可通过智能外呼及智能短信,结合营销活动的需要向离店用户进行智能营销,可实现标准、高效的营销同时实现用户线上化。">
              <img src="@/assets/img/question.png" slot="reference" class="count-item-question" />
            </el-popover>
            <div>
              <el-button size="small" @click="handleAddEmp">
                <i class="el-icon-plus"></i>
                选择跟进专员
              </el-button>
              <span class="drainage-coutom-count">已经选择{{ dracImFollowStaffResponses.length }}人</span>
              <div class="el-input-tag input-tag-wrapper">
                <el-tag v-for="(tag, idx) in dracImFollowStaffResponses" :key="idx" closable :disable-transitions="false" @close="remove(idx)">
                  {{ tag.staffName }}
                </el-tag>
              </div>
            </div>
          </div>
          <div class="drainage-form-item" v-else>
            <label>跟进员工</label>
            <div class="drainage-emp">
              <template v-for="item in dracImFollowStaffResponses">
                {{ item.staffName }}
              </template>
            </div>
          </div>
          <div class="drainage-form-item">
            <label>群发短信</label>
            <div class="message-panel">
              <el-form ref="configForm" label-position="left" label-width="100px" :model="addForm" :rules="addRules" class="code-body-form">
                <el-form-item label="推送规则:"><div class="configForm-desc">系统将在「开始营销时间」之后启动短信营销,并在「截止营销时间」之后停止短信下放。由于相关管控限制,营销类短信无法实时触达用户,若短信时效要求很高,请谨慎使用。</div></el-form-item>
                <el-form-item size="small" label="营销时间" prop="time">
                  <el-time-picker is-range :disabled="!editStatus" value-format="HH:mm:ss" v-model="addForm.time" range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" placeholder="选择时间范围"></el-time-picker>
                </el-form-item>
                <el-form-item label="短信内容" prop="content">
                  <el-input type="textarea" v-model="addForm.content" rows="5" :disabled="!editStatus" maxlength="500" show-word-limit></el-input>
                  <div class="select-panel" v-if="editStatus">
                    <div @click="handleSelectMessage">
                      <i class="el-icon-circle-plus-outline"><span>选择模板</span></i>
                    </div>
                    <div @click="handleSelectModel">
                      <i class="el-icon-circle-plus-outline"><span>活动</span></i>
                    </div>
                  </div>
                  <div class="form-tips">共可输入500字,70字內(含70字)计一条,超过70字,按70字/条计费。</div>
                  <div class="form-tips">提示:当前短信已有{{ addForm.content.length }}字,按{{ content.length }}条短信发送且计费。</div>
                </el-form-item>
                <el-form-item label="审核通知人:">短信内容审核结果会通过企微消息的形式发送给设置的员工,员工可以及时跟进。</el-form-item>
                <el-form-item label="自动打标签">
                  <div class="tag-item-panel" v-if="editStatus">
                    <div>
                      <el-button size="small" @click="handleAddTag">添加</el-button>
                      <div class="el-input-tag input-tag-wrapper">
                        <template v-for="item in tagging">
                          <el-tag v-for="(tag, idx) in item.labelList" :key="idx" closable :disable-transitions="false" @close="removeTag(item.labelList, idx)">
                            {{ tag.name }}
                          </el-tag>
                        </template>
                      </div>
                    </div>
                  </div>
                  <div v-else>
                    <template v-for="item in tagging">
                      <template v-for="tag in item.labelList">
                        {{ tag.name }}
                      </template>
                    </template>
                  </div>
                </el-form-item>
              </el-form>
            </div>
          </div>
        </div>
        <div class="form-image">
          <img src="@/assets/img/marketing/phone.png" />
          <div class="preview-content">
            <div class="preview-info">
              <div class="preview-text text" v-for="(item, index) in content" :key="index">{{ item }}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div
      class="footer-panel"
      :style="{
        left: footerLeft + 'px',
        width: footerWidth + 'px'
      }"
    >
      <el-button type="primary" @click="goback">取消</el-button>
      <el-button type="primary" @click="handleSave">提交</el-button>
    </div>
    <div class="import-panel" v-if="importStatus">
      <div class="import-panel-box">
        <div class="import-title">操作结果</div>
        <div class="import-num-panel">
          <div class="import-num-item">
            <div class="import-num">{{ ExportDracImResponse.totalCount }}</div>
            <div class="import-num-h2">成功记录</div>
          </div>
          <div class="import-num-item">
            <div class="import-num" style="color: #ff4d4f">{{ ExportDracImResponse.failCount }}</div>
            <div class="import-num-h2">失败记录</div>
          </div>
        </div>
        <div class="import-footer">
          <el-button type="primary" @click="importError(ExportDracImResponse.errorUrl)" size="small" v-if="ExportDracImResponse.failCount">导出失败记录</el-button>
          <el-button type="primary" @click="goback" size="small">完成</el-button>
        </div>
      </div>
    </div>
    <select-emp ref="selectEmpForm" @selectTable="selectTable"></select-emp>
    <select-tag ref="selectTagForm" @tagSelected="tagSelected"></select-tag>
    <activity-model ref="selectModelForm" @selectActivity="selectActivity"></activity-model>
    <message-model ref="selectMessageForm" @selectItem="selectItem"></message-model>
  </div>
</template>

<script>
import selectEmp from '@/components/selectEmp'
import selectTag from '@/components/selectTag'
import activityModel from './components/activityModel'
import messageModel from './components/messageModel'
export default {
  name: 'config',
  components: {
    selectEmp,
    selectTag,
    activityModel,
    messageModel
  },
  data() {
    return {
      importName: null,
      exportUrl: null,
      editStatus: true,
      importStatus: false,
      ExportDracImResponse: {},
      footerLeft: 0,
      footerWidth: 0,
      addForm: {
        desc: '',
        content: '',
        time: ''
      },
      content: [],
      editId: null,
      tagging: [],
      messageItem: {},
      dialogVisible: true,
      value: false,
      value1: false,
      dracImFollowStaffResponses: [],
      dracImMessageConfigAddRequest: {},
      ModelItem: {},
      addRules: {
        time: [{ required: true, message: '请选择营销时间', trigger: 'change' }],
        content: [{ required: true, message: '请选择短信模板', trigger: 'blur' }]
      }
    }
  },
  watch: {
    'addForm.content': {
      handler: function() {
        this.content = []
        let str = this.addForm.content
        let num = 70
        let len = str.length
        for (let i = 0; i < len / num; i++) {
          let str1 = str.substring(str.length - (i + 1) * num, str.length - i * num)
          this.content.push(str1)
        }
      }
    }
  },
  methods: {
    importError(url) {
      window.open(url)
    },
    goback() {
      this.$router.push('/marketing/index')
    },
    selectItem(item) {
      this.messageItem = item
      this.addForm.content = item.content
    },
    tagSelected(item) {
      this.tagging = item
    },
    uploadFile(file) {
      let AllImgExt = '.xls|.xlsx'
      let extName = file.name.substring(file.name.lastIndexOf('.')).toLowerCase()
      console.log(extName)
      if (AllImgExt.indexOf(extName) === -1) {
        this.$message.error('上传格式不正确')
        return false
      }
      const reader = new FileReader()
      reader.readAsDataURL(file)
      reader.onload = event => {
        const imgFile = event.target.result
        const arrBase64 = imgFile.split(',')
        const fileUrl = file.name.split('.')[1] + '@' + arrBase64[1]
        this.$apis.common.pictureUpload({ file: fileUrl }).then(res => {
          this.importName = file.name
          this.exportUrl = res
        })
      }
    },
    selectTable(item) {
      this.dracImFollowStaffResponses = item.map(item => {
        return {
          staffId: item.relationId,
          staffName: item.staffName
        }
      })
    },
    remove(index) {
      this.dracImFollowStaffResponses.splice(index, 1)
    },
    removeTag(item, idx) {
      item.splice(idx, 1)
    },
    selectActivity(item) {
      this.ModelItem = item
      console.log(this.ModelItem)
    },
    handleSave() {
      if (!this.exportUrl) {
        this.$message.error('请上传客户信息')
        return
      }
      this.$refs['configForm'].validate(valid => {
        if (valid) {
          let startTime, endTime
          if (this.addForm.time) {
            startTime = this.addForm.time[0]
            endTime = this.addForm.time[1]
          }
          let templateId = this.messageItem.id
          const content = this.addForm.content
          const { marketingType, marketingUrl, marketingId } = this.ModelItem
          let params
          if (this.editId) {
            params = {
              imType: 2,
              id: this.editId,
              exportUrl: this.exportUrl
            }
          } else {
            params = {
              imType: 2,
              tagging: JSON.stringify(this.tagging),
              exportUrl: this.exportUrl,
              dracImFollowStaffRequestList: this.dracImFollowStaffResponses,
              dracImMessageConfigRequest: {
                startTime,
                endTime,
                templateId,
                content,
                marketingType,
                marketingUrl,
                marketingId
              }
            }
          }

          this.$apis.marketing.exportAdd(params).then(res => {
            if (res) {
              this.ExportDracImResponse = res
              this.importStatus = true
            }
          })
        }
      })
    },
    handleAddEmp() {
      this.$refs.selectEmpForm.init(this.dracImFollowStaffResponses)
    },
    handleAddTag() {
      this.$refs.selectTagForm.init(this.tagging)
    },
    handleSelectMessage() {
      this.$refs.selectMessageForm.init()
    },
    handleSelectModel() {
      this.$refs.selectModelForm.init()
    },
    findById(id) {
      this.$apis.marketing.findById({ id }).then(res => {
        this.$nextTick(() => {
          this.$refs.configForm.validate()
        })
        this.dracImFollowStaffResponses = res.dracImFollowStaffResponses
        this.addForm.time = [res.dracImMessageConResponse.startTime, res.dracImMessageConResponse.endTime]
        this.addForm.content = res.dracImMessageConResponse.content
        this.tagging = eval(res.tagging)
      })
    },
    resize() {
      this.footerLeft = document.querySelector('.base-container-right').offsetLeft
      this.footerWidth = document.documentElement.clientWidth - this.footerLeft
    }
  },
  mounted() {
    this.resize()
    window.addEventListener('resize', () => {
      this.resize()
    })
    let { id } = this.$route.params
    if (id != -1) {
      this.editId = id
      this.findById(id)
      this.editStatus = false
    }
  }
}
</script>

<style lang="scss" scoped>
.footer-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  bottom: 0px;
  height: 64px;
  background: #ffffff;
  box-shadow: 0px -1px 1px 0px rgba(88, 80, 255, 0.1);
}
.image-uploader {
  display: inline-block;
  margin-bottom: 6px;
  height: 20px;
  /deep/ {
    .el-upload-list {
      display: none;
    }
  }
}
.import-panel {
  z-index: 2001;
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0px;
  left: 0px;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  &-box {
    width: 712px;
    height: 266px;
    background: #ffffff;
    border-radius: 4px;
    padding: 20px;
    box-sizing: border-box;
    .import-title {
      font-size: 20px;
      font-weight: 500;
      color: #424242;
      line-height: 28px;
    }
    .import-num-panel {
      display: flex;
      margin: 10px;
      .import-num-item {
        width: 50%;
        height: 140px;
        text-align: center;
        display: table-cell;
        vertical-align: middle;
        .import-num {
          margin-top: 40px;
          font-size: 20px;
          font-weight: 500;
          color: rgba(0, 0, 0, 0.85);
          line-height: 28px;
        }
        .import-num-h2 {
          font-size: 14px;
          font-weight: 400;
          color: rgba(0, 0, 0, 0.65);
          line-height: 22px;
        }
      }
    }
    .import-footer {
      display: flex;
      justify-content: space-between;
    }
  }
}
.drainage-wrap {
  margin-bottom: 20px;
  &:nth-child(2) {
    margin-bottom: 60px;
  }
  .drainage-title {
    padding-left: 20px;
    font-size: 16px;
    font-weight: 500;
    color: #333333;
    line-height: 57px;
    height: 57px;
    border-bottom: 1px solid #d8d8d8;
  }
  .form-main {
    display: flex;
    .form-image {
      width: 280px;
      height: 546px;
      margin: 20px 10px;
      position: relative;
      .preview-content {
        position: absolute;
        width: 250px;
        height: 350px;
        overflow-y: auto;
        top: 115px;
        left: 45px;
        .preview-text {
          padding: 10px;
          position: relative;
          width: 160px;
          color: #333;
          background-color: #fff;
          border-radius: 4px;
          word-wrap: break-word;
          margin-bottom: 10px;
        }
      }
      img {
        width: 100%;
        height: auto;
      }
    }
    .drainage-form {
      flex: 1;
    }
  }
  .form-tips {
    font-size: 14px;
    font-weight: 400;
    color: #333333;
    line-height: 20px;
    margin-top: 5px;
  }
  .drainage-form {
    padding: 20px;
    .drainage-form-item {
      display: flex;
      margin-top: 20px;
      label {
        width: 120px;
        text-align: right;
        margin-right: 20px;
        height: 36px;
        line-height: 36px;
        &.is-require {
          &::before {
            content: '*';
            color: #f56c6c;
            margin-right: 4px;
          }
        }
      }
    }
    /deep/ {
      .el-textarea__inner {
        border-radius: 0px;
        border: 1px solid #dcdfe6;
      }
    }
    .select-panel {
      padding-left: 20px;
      background: #fff;
      display: flex;
      font-size: 14px;
      font-weight: 400;
      color: #717171;
      line-height: 30px;
      border: 1px solid #dcdfe6;
      border-top: 0px;
      > div {
        cursor: pointer;
        margin-right: 10px;
        span {
          margin-left: 3px;
        }
      }
    }

    .upload-box {
      margin-bottom: 10px;
      .upload-file-panel {
        display: flex;
        align-items: center;
        > a {
          margin-left: 10px;
          text-decoration: underline;
          font-size: 12px;
          font-weight: 400;
          color: #5850ff;
          line-height: 17px;
        }
      }
      .upload-btn {
        text-align: center;
        width: 96px;
        background: #ffffff;
        border-radius: 4px;
        border: 1px solid #dcdfe6;
        font-size: 14px;
        font-weight: 400;
        color: #999999;
        padding: 6px 0px;
      }
      .upload-tips {
        margin-top: 6px;
        font-size: 14px;
        font-weight: 400;
        color: #999999;
        line-height: 20px;
      }
    }
    .message-panel {
      background: #f7f7f7;
      border: 1px solid #dcdfe6;
      padding: 20px;
      flex: 1;
      box-sizing: border-box;
      font-size: 14px;
      color: #3a3a3a;
      .configForm-desc {
        margin-top: 10px;
        line-height: 20px;
      }
    }
    .drainage-emp {
      line-height: 36px;
    }
    .input-tag-wrapper {
      position: relative;
      font-size: 14px;
      background-color: #fff;
      background-image: none;
      border-radius: 4px;
      border: 1px solid #dcdfe6;
      box-sizing: border-box;
      color: #606266;
      display: inline-block;
      outline: none;
      padding: 2px 10px 2px 5px;
      flex-wrap: wrap;
      line-height: 36px;
      min-height: 36px;
      transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
      width: 450px;
      display: flex;
      align-items: center;
      margin-top: 6px;
    }
    .tag-item-panel {
      display: flex;
    }
    .el-tag {
      margin-right: 4px;
      height: 26px;
      line-height: 24px;
    }
    .drainage-coutom-count {
      font-size: 14px;
      font-weight: 400;
      color: #7d7d7d;
      line-height: 36px;
      margin-left: 20px;
    }
  }
  .drainage-panel {
    padding: 20px;
    .drainage-config-wrap {
      display: flex;
      justify-content: space-between;
      align-items: center;
      .drainage-item-label {
        width: 50%;
        font-size: 14px;
        font-weight: 400;
        color: #333333;
        line-height: 20px;
      }
    }
    .config-title {
      font-size: 14px;
      font-weight: 400;
      color: #5850ff;
      line-height: 20px;
      margin: 20px 0px;
      i {
        margin-left: 6px;
      }
    }
    .config-market {
      display: flex;
      &-item {
        position: relative;
        padding: 10px;
        width: 50%;
        height: 150px;
        background: #f6f6ff;
        border-radius: 4px;
        opacity: 0.8;
        box-sizing: border-box;
        &:first-child {
          margin-right: 20px;
        }
        &.checked {
          border: 1px solid #5850ff;
          .config-market-title {
            color: #5850ff;
          }
          .config-market-icon {
            background: linear-gradient(153deg, #8085ef 0%, #6f76ee 100%, #6f76ee 100%) !important;
          }
          .config-market-name {
            color: #333333 !important;
          }
          .config-line {
            border: 1px solid #5850ff !important;
          }
        }
        .config-market-title {
          font-size: 16px;
          font-weight: 400;
          color: #999999;
          line-height: 22px;
          text-align: center;
        }
        .config-switch-icon {
          position: absolute;
          right: 10px;
          top: 10px;
        }
        .config-market-select {
          display: flex;
          .config-market-s1 {
            width: 33.33%;
            margin: 0 auto;
            text-align: center;
            position: relative;
            .config-line {
              position: absolute;
              top: 45px;
              right: -30%;
              width: 60%;
              border: 1px solid #999999;
            }
            .config-market-icon {
              width: 56px;
              height: 56px;
              background: #999999;
              border-radius: 50%;
              margin: 20px auto 10px;
            }
            .config-market-name {
              font-size: 14px;
              font-weight: 400;
              color: #adadad;
              line-height: 20px;
            }
          }
        }
      }
    }
  }
}
</style>