detailCustomer.vue 13.4 KB
<template>
  <div>
    <BasicInof :eventBus="eventBus" :id="$route.params.id" :form="'customer'" @handleSelect="handleSelect" @handleCustomSelect="handleCustomSelect"></BasicInof>
    <div class="detail-container">
      <div class="detail-modular">
        <div class="title">员工详情</div>
        <div class="detail-info">
          <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect">
            <el-menu-item index>全部</el-menu-item>
            <el-menu-item index="1">已发送员工</el-menu-item>
            <el-menu-item index="0">未发送员工</el-menu-item>
            <el-menu-item index="2">员工发送失败</el-menu-item>
          </el-menu>
          <div class="detail-total">共 {{ employeelist.length || 0 }} 人</div>
          <div v-if="employeelist.length != 0" class="info-list">
            <div class="info-item" v-for="(item, index) in employeelist" :key="item.id">
              <img class="info-avatar" :src="item.avatar ? item.avatar : require('@/assets/guestCustom/default-avatar.png')" alt />
              <div class="info-content">
                <div class="info-text">
                  <div class="info-name">
                    {{ item.staffName }}
                    <span :class="[item.status == 0 ? 'unsend' : 'send']">
                      {{ item.status == 0 ? '未发送' : item.status == 1 ? '已发送' : '发送失败' }}
                      <el-popover v-show="item.status != 0 && item.status != 1" placement="top-start" title="失败原因:" width="400" trigger="hover">
                        <p>1.若插入活动发送失败,可能为企微未绑定活动小程序,请绑定后再尝试。</p>
                        <p>2.可能为客户开启消息免打扰,消息发送失败。</p>
                        <p>3.可能为群发次数达到上限,上限次数为每个客户/客户群每天仅可接收1条群发消息。</p>
                        <p>4.一个客户加多个员工时,先发消息的员工可以送达客户,后发消息的员工无法送达客户。</p>
                        <img slot="reference" :src="iconUrl" alt />
                      </el-popover>
                    </span>
                  </div>
                  <div class="info-num">共{{ item.customerCount ? item.customerCount : 0 }}个客户</div>
                </div>
                <div class="info-right">
                  <div v-if="item.status != 0 || item.remindStatus == 1">已提醒</div>
                  <el-button v-if="item.status == 0" :disabled="item.remindStatus == 1 || isDisabled" size="mini" type="primary" @click="remind(item, index)">提醒</el-button>
                </div>
              </div>
            </div>
          </div>
          <div class="model-item-empty" v-else v-loading="loading">
            <img src="@/assets/empty.png" />
            <div class="empty-item">暂无数据</div>
          </div>
        </div>
      </div>
      <div class="detail-modular">
        <div class="title">客户详情</div>
        <div class="detail-info">
          <el-menu :default-active="customIndex" class="el-menu-demo" mode="horizontal" @select="handleCustomSelect" infinite-scroll-distance="10">
            <el-menu-item index>全部</el-menu-item>
            <el-menu-item index="1">已送达客户</el-menu-item>
            <el-menu-item index="0">未送达客户</el-menu-item>
            <el-menu-item index="2">客户送达失败</el-menu-item>
          </el-menu>
          <div class="detail-total">共 {{ customerCount || 0 }} 人</div>
          <div v-if="customerCount != 0" class="info-list" v-infinite-scroll="customerDetailLoad" immediate-check="false">
            <div class="info-item" v-for="item in customerlist" :key="item.id">
              <img class="info-avatar" :src="item.avatar ? item.avatar : require('@/assets/guestCustom/default-avatar.png')" alt />
              <div class="info-content info-custom">
                <div class="info-text">
                  <div class="info-name">
                    {{ item.customerName }}
                    <div class="customer-table" :class="[item.status == 0 ? 'unsend' : 'send']">
                      {{ item.status == 0 ? '未送达' : item.status == 1 ? '已送达' : '送达失败' }}
                      <el-popover v-show="item.status != 0 && item.status != 1" placement="top-start" title="失败原因:" width="400" trigger="hover">
                        <p>1.若插入活动发送失败,可能为企微未绑定活动小程序,请绑定后再尝试。</p>
                        <p>2.可能为客户开启消息免打扰,消息发送失败。</p>
                        <p>3.可能为群发次数达到上限,上限次数为每个客户/客户群每天仅可接收1条群发消息。</p>
                        <img slot="reference" :src="iconUrl" alt />
                      </el-popover>
                    </div>
                  </div>
                </div>
                <div class="info-right">
                  <div>通过 {{ item.staffName }}发送</div>
                </div>
              </div>
            </div>
          </div>
          <div class="model-item-empty" v-else v-loading="loading">
            <img src="@/assets/empty.png" />
            <div class="empty-item">暂无数据</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
const iconUrl =
  'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAFoTx1HAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAADqADAAQAAAABAAAADgAAAAC98Dn6AAAB7klEQVQoFVVSQUhUURQ9981sVFyYRRHuFFq1CGlZC3etnBlMRhMXQwhtCqIQJBA3gSSi1EpkNqkjCjOjm1YWuGojBVO7Fi0K2qQLF6H453bO+/ODLvz37z333PvOu+8BtImCf0K56J8VYKLoC9HRMlnwRxaRgB0kOHDDz5gl/0hZBaaFwGl3H65j577nygV/ITCM71pinRo1GiF4zm8jqzkr5dEtluiTJZ9zx8fYTEBmbP5D/tSY3wnaRUwB0rbdsAH5SYK3sW2l4r1/jnFIsUMElmsNmxdB7JGsUnGUWvQz+XkHXtXqNsxx/KL/Zg+oS5xxi8A2T8SqNe0az3NANyfVJD4N5ripZDTDrc1da8kn/i1QxGya4eq4Kl8aui7hblRLUd/JXCSxxXarBJ9T8fuYFLsztiqTv4NjXUTh2rZteEhiP8OKiiIez3+CFoWubdXtpUDe1XAbmJEfQLxpRxFPRz7T1ccz6BFkl6okRzHFOJ5ccbnkr8l5LF8mrl5Pnv5gJksJjmlD/wclv9121ClxeqthH4TJQh5fLhIMaa7LOrRuIk2la89lfO29ghuU/69IHBatqIZfOhgWv2OXhUIOi/FCnDpoZuYqaCaYpYJ5gvf+m6pInUE9Y5NRhoPCdGl80fscyFK1aqfCZH8B0rPa9foo7e4AAAAASUVORK5CYII='
import Vue from 'vue'
import BasicInof from './components/basicInfo.vue'
export default {
  components: {
    BasicInof
  },
  data() {
    return {
      iconUrl,
      activeIndex: '',
      customIndex: '',
      employeelist: [],
      customerlist: [],
      basicInfo: {},
      eventBus: new Vue(),
      isDisabled: false,
      footerLeft: 0,
      footerWidth: 0,
      // 客户详情分页
      customerPage: {
        pageSize: 10,
        pageNum: 1
      },
      // 客户详情总数
      customerCount: 0
    }
  },
  mounted() {
    this.getCustomerDetail(() => {
      this.getStaffList()
      this.getCustomerList()
    })
    let clientHeight = document.documentElement.clientHeight
    this.footerLeft = document.querySelector('.base-container-right').offsetLeft
    this.footerWidth = document.documentElement.clientWidth - this.footerLeft
    this.boxHeight = clientHeight - 200
  },
  methods: {
    handleSelect(val) {
      this.activeIndex = val
      this.getStaffList(val)
    },
    // 客户详情选择切换
    handleCustomSelect(val) {
      this.customIndex = val
      this.customerlist = []
      // 获取滑动高度清0,防止tab切换时记录滚动条位置问题
      var scrolltopList = document.querySelectorAll('.info-list')
      if (scrolltopList) {
        scrolltopList[1] ? (scrolltopList[1].scrollTop = 0) : ''
      }
      this.customerPage = {
        pageSize: 10,
        pageNum: 1
      }
      this.getCustomerList(val)
    },
    remind(data, index) {
      if (!data.remindStatus) {
        this.$apis.customerTransform
          .remindUserGroup({
            id: data.id,
            type: 1
          })
          .then(res => {
            this.getStaffList(this.activeIndex)
            this.$message({
              type: 'success',
              message: '已提醒'
            })
            // this.$set(this.employeelist[index], 'remindStatus', true)
          })
      }
    },
    getCustomerDetail(callback) {
      const id = this.$route.params.id
      this.$apis.customerTransform.customerDetail({ id }).then(res => {
        this.basicInfo = res
        const date = new Date(res.sendTime)
        const currentDate = new Date()
        this.isDisabled = date > currentDate
        callback()
      })
    },
    getStaffList(status = null) {
      const id = this.$route.params.id
      this.$apis.customerTransform.staffList({ id, status }).then(res => {
        this.employeelist = res ? res : []
      })
    },
    // 客户详情下拉加载
    customerDetailLoad() {
      // 详情列表有数据时才触发
      if (this.customerlist.length > 0) {
        this.customerPage.pageNum++
        // 详情数组数量小于总数才触发,带上切换的tab值
        if (this.customerlist.length < this.customerCount) this.getCustomerList(this.customIndex)
      }
    },
    // 获取客户详情列表
    getCustomerList(status = null) {
      const id = this.$route.params.id
      var params = JSON.parse(JSON.stringify(this.customerPage))
      params.status = status
      params.id = id
      this.$apis.customerTransform.customerDetailList(params).then(res => {
        this.customerCount = res.count
        if (!res.data.length) {
          this.customerlist = []
          return
        }
        this.customerlist.push(...res.data)
      })
    },
    remindUserGroup() {
      const id = this.$route.params.id
      this.$apis.customerTransform.remindUserGroup({ id, type: 1 }).then(res => {})
    }
  }
}
</script>
<style lang="scss" scope>
.detail-container {
  display: flex;
  width: 100%;
  justify-content: space-between;
  // margin-bottom: 84px;
  .detail-modular {
    width: calc(50% - 10px);
    background-color: #ffffff;
    box-shadow: 0 10px 20px 0 rgba(88, 80, 255, 0.1);
  }
  .title {
    padding: 20px 0 17px 20px;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    border-bottom: 1px solid #d8d8d8;
  }
  .detail-info {
    padding: 0 20px;
    .detail-total {
      padding: 20px 0 14px;
      font-size: 14px;
      color: #333;
      line-height: 16px;
    }
    .info-list {
      max-height: 432px;
      overflow: auto;
      margin-bottom: 20px;
    }
    .info-item {
      display: flex;
      align-items: center;
      background-color: #f6f6ff;
      border-radius: 2px;
      border: 1px solid rgba(88, 80, 255, 0.8);
      padding: 15px;
      margin-bottom: 20px;
      &:last-child {
        margin-bottom: 0;
      }
      .info-avatar {
        width: 58px;
        height: 58px;
        margin-right: 20px;
      }
      .info-content {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;

        .info-text {
          height: 62px;
        }
        .info-right {
          display: flex;
          align-items: center;
          font-size: 16px;
          color: #5850ff;
          line-height: 22px;
        }
        .info-name {
          display: flex;
          align-items: center;
          font-size: 16px;
          color: #333;
          font-weight: 600;
          line-height: 22px;
          margin-bottom: 14px;
          span {
            display: inline-block;
            margin-left: 10px;
            font-size: 14px;
          }
          .send {
            position: relative;
            color: #666;
            font-weight: normal;
            span {
              img {
                position: absolute;
                right: -6px;
                top: 4px;
              }
            }
          }
          .unsend {
            padding: 3px 10px;
            background-color: #eb4e4e;
            color: #fff;
            border-radius: 2px;
            font-weight: normal;
          }
          .customer-table {
            display: flex;
            margin-top: 0;
            margin-left: 10px;
            &.send {
              width: 80px;
            }
            span {
              vertical-align: middle;
            }
          }
          div {
            margin-top: 10px;
            font-size: 14px;
          }
        }
        .info-num {
          font-size: 14px;
          color: #666;
          line-height: 20px;
        }
        button {
          margin-left: 10px;
          padding: 9px 28px;
        }
      }
    }
  }
  .el-menu.el-menu--horizontal {
    border-bottom: none;
  }
  .el-menu-item {
    line-height: 56px;
    font-size: 16px;
    height: 46px;
  }
  .el-menu--horizontal > .el-menu-item.is-active {
    border-bottom-color: #5850ff;
    color: #5850ff;
    font-weight: 600;
  }
}
.footer-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  bottom: 0px;
  height: 64px;
  width: 100%;
  background: #ffffff;
  box-shadow: 0px -1px 1px 0px rgba(88, 80, 255, 0.1);
  z-index: 1;
}
.el-empty {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  text-align: center;
  box-sizing: border-box;
  padding: 40px 0;
}

.model-item-empty {
  height: 200px;
  > img {
    display: block;
    margin: 50px auto 0px;
    width: 60px;
    height: auto;
  }
  .empty-item {
    text-align: center;
    font-size: 14px;
    font-weight: 400;
    color: #000000;
    line-height: 22px;
    margin-bottom: 30px;
  }
}
</style>