basicInfo.vue 13 KB
<template>
  <div class="container">
    <div class="title">基础信息</div>
    <div class="detail-content">
      <div class="content-info">
        <div class="content-text">
          <div class="detail-item">
            <div class="detail-label">创建者:</div>
            <div class="detail-value">
              <el-tag v-if="basicInfo.createdName" type="info">
                <i class="el-icon-user-solid"></i>
                {{ basicInfo.createdName }}
              </el-tag>
              <span v-else>-</span>
              <!-- {{basicInfo.createdName ? basicInfo.createdName : '-'}} -->
            </div>
          </div>
          <div class="detail-item">
            <div class="detail-label">群发内容:</div>
            <div
              class="detail-value"
            >[共{{basicInfo.attachmentList ? basicInfo.attachmentList.length : '0'}}条]</div>
            <div class="detail-tips">详见右侧视图</div>
          </div>
          <div class="detail-item" v-show="form == 'customer'">
            <div class="detail-label">群发类型:</div>
            <div class="detail-value">{{basicInfo.sendType == 1 ? '立即发送': '定时发送'}}</div>
          </div>
          <div class="detail-item" v-show="form == 'customer'">
            <div class="detail-label">发送状态:</div>
            <div class="detail-value">{{STATUS_TYPE[basicInfo.status]}}</div>
          </div>
          <div class="detail-item">
            <div class="detail-label">发送时间:</div>
            <div class="detail-value">{{basicInfo.sendTime ? basicInfo.sendTime : '-'}}</div>
          </div>
          <div class="detail-item" style="margin-bottom: 0;">
            <div class="detail-label">群发对象:</div>
            <div class="detail-value">
              在
              <span v-for="(item, index) in basicInfo.userList" class="el-tag-item" :key="item.id">
                <el-tag type="info" v-if="index < 5">
                  <i class="el-icon-user-solid"></i>
                  {{ item.staffName }}
                </el-tag>
                <el-tag type="info" v-if="basicInfo.userList.length > 5 && index == 5">
                  <el-popover placement="top" width="300" trigger="hover">
                    <span slot="reference">...({{basicInfo.userList.length}})</span>
                    <div class="entmicro-hover">
                      <el-tag
                        type="info"
                        v-for="(i, index) in basicInfo.userList"
                        :key="index"
                        :disable-transitions="false"
                      >{{i.staffName}}</el-tag>
                    </div>
                  </el-popover>
                </el-tag>
              </span>
              里满足以下条件中的{{basicInfo.customerCount ? basicInfo.customerCount : 0}}个{{form == 'customer' ? '客户' : '群聊'}}
              <!--  v-if="selectType == 2" <span v-for="(item, index) in basicInfo.userList" :key="item.id">
                [{{item.staffName}}]
                <span v-show="basicInfo.userList.length -1 != index">、</span>
              </span>-->
            </div>
          </div>
          <div class="detail-condition" v-if="form == 'customer' && basicInfo.selectType == 2">
            <div class="detail-condition-item">
              <span class="name">性别</span>
              <span>{{SEX_TYPE[basicInfo.condition.sex]}}</span>
            </div>
            <div v-if="basicInfo.condition.startTime" class="detail-condition-item">
              <span class="name">添加时间</span>
              <span>{{basicInfo.condition.startTime ? basicInfo.condition.startTime.split(' ')[0] : '-'}} 至 {{basicInfo.condition.endTime ? basicInfo.condition.endTime.split(' ')[0] : '-'}}</span>
            </div>
            <div class="detail-condition-item" v-if="basicInfo.condition.chatName">
              <span class="name">所在群聊</span>
              <span
                v-for="(item, index) in basicInfo.condition.chatName.split(',')"
                class="el-tag-item"
                :key="index"
              >
                <el-tag v-if="index < 3" type="info">{{ item }}</el-tag>
                <el-tag
                  type="info"
                  v-if="basicInfo.condition.chatName.split(',').length > 3 && index == 3"
                >
                  <el-popover placement="top" width="300" trigger="hover">
                    <span slot="reference">...({{basicInfo.condition.chatName.split(',').length}})</span>
                    <div class="entmicro-hover">
                      <el-tag
                        type="info"
                        v-for="(i, index) in basicInfo.condition.chatName.split(',')"
                        :key="index"
                        :disable-transitions="false"
                      >{{i}}</el-tag>
                    </div>
                  </el-popover>
                </el-tag>
              </span>
            </div>
            <div class="detail-condition-item" v-if="basicInfo.condition.tagName">
              <span class="name">标签筛选</span>
              <span
                v-for="(itm, idx) in basicInfo.condition.tagName.split(',')"
                class="el-tag-item"
                :key="idx"
              >
                <el-tag v-if="idx < 3" type="info">{{ itm }}</el-tag>
                <el-tag
                  type="info"
                  v-if="basicInfo.condition.tagName.split(',').length > 3 && idx == 3"
                >
                  <el-popover placement="top" width="300" trigger="hover">
                    <span slot="reference">...({{basicInfo.condition.tagName.split(',').length}})</span>
                    <div class="entmicro-hover">
                      <el-tag
                        type="info"
                        v-for="(i, index) in basicInfo.condition.tagName.split(',')"
                        :key="index"
                        :disable-transitions="false"
                      >{{i}}</el-tag>
                    </div>
                  </el-popover>
                </el-tag>
              </span>
            </div>
          </div>
        </div>
        <div class="title">数据统计</div>
        <div class="statistics-info">
          <div class="statistics-ul">
            <div class="statistics-li statistics-border">
              <div class="statistics-number">
                <span>{{form == 'customer' ? statistic.senderStaffCount: statistic.senderStaffCount}}</span>
                人
              </div>
              <div class="statistics-text">已发送{{form == 'customer' ? '成员': '群主'}}</div>
            </div>
            <div class="statistics-li">
              <div class="statistics-number">
                <span>{{form == 'customer' ? statistic.senderCustomerCount :statistic.senderGroupCount}}</span>
                {{form == 'customer' ? '人' : '个'}}
              </div>
              <div class="statistics-text">送达{{form == 'customer' ? '客户': '群聊'}}</div>
            </div>
          </div>
          <div class="statistics-ul">
            <div class="statistics-li statistics-border">
              <div class="statistics-number">
                <span>{{form == 'customer' ?statistic.unSenderStaffCount:statistic.unSenderStaffCount}}</span>
                人
              </div>
              <div class="statistics-text">未发送{{form == 'customer' ? '成员': '群主'}}</div>
            </div>
            <div class="statistics-li">
              <div class="statistics-number">
                <span>{{form == 'customer' ?statistic.unSenderCustomerCount:statistic.unSenderGroupCount}}</span>
                {{form == 'customer' ? '人' : '个'}}
              </div>
              <div class="statistics-text">未送达{{form == 'customer' ? '客户': '群聊'}}</div>
            </div>
          </div>
          <div v-if="form == 'customer'" class="statistics-ul">
            <div class="statistics-li">
              <div class="statistics-number">
                <span>{{statistic.senderCustomerFailureCount}}</span>
                人
              </div>
              <div>客户送达失败</div>
            </div>
          </div>
        </div>
      </div>
      <Preview :eventBus="eventBus" :list.sync="basicInfo.attachmentList"></Preview>
    </div>
  </div>
</template>
<script>
const STATUS = {
  '-1': '创建失败',
  '0': '创建成功',
  '1': '发送成功',
  '2': '发送失败',
  '3': '待发送'
}
const SEX = {
  null: '全部',
  '1': '男',
  '2': '女',
  '0': '未知性别'
}

import * as dayjs from 'dayjs'
import Preview from '../components/preview.vue'
export default {
  name: 'BasicInof',
  props: ['form', 'id', 'eventBus'],
  components: {
    Preview
  },
  data() {
    return {
      STATUS_TYPE: STATUS,
      SEX_TYPE: SEX,
      basicInfo: {
        condition: {}
      },
      statistic: {}
    }
  },
  mounted() {
    this.getCustomerDetail(this.id)
    this.getStatistic()
    // console.log(this.basicInfo)
  },
  methods: {
    getCustomerDetail(id) {
      this.$apis.customerTransform.customerDetail({ id }).then(res => {
        this.basicInfo = res
        // this.basicInfo.sendTime = dayjs(this.basicInfo.sendTime).format('YYYY-MM-DD HH:mm:ss')
        const previewList = res.attachmentList.map(item => {
          if (item.attType == 7 && item.attContent) item.attContent = JSON.parse(item.attContent)
          if (item.attType == 1) {
            item.attContent = item.attContent.replaceAll('[@昵称]', '@昵称')
          }
          return item
        })
        this.eventBus.$emit('update', previewList)
      })
    },
    getStatistic() {
      const { id, form } = this
      if (form == 'customer') {
        this.$apis.customerTransform.detailStatistic({ id }).then(res => {
          this.statistic = res
        })
      } else if (form == 'customerGroup') {
        this.$apis.customerTransform.groupDetailStatistic({ id }).then(res => {
          this.statistic = res
        })
      }
    }
  }
}
</script>
<style lang="scss" scope>
.container {
  margin-bottom: 20px;
  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-content {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    padding: 20px 24px 40px 0;
    .content-info {
      width: calc(100% - 360px);

      .content-text {
        padding-left: 52px;
        height: 400px;
      }
      .detail-item {
        display: flex;
        align-items: center;
        font-size: 14px;
        color: #333;
        line-height: 20px;
        margin-bottom: 24px;
        .detail-label {
          width: 70px;
        }
        .detail-tips {
          margin-left: 8px;
          color: #939393;
        }
        .el-tag-item {
          margin-right: 10px;
          &:last-child {
            margin-right: 0;
          }
        }
        i {
          color: #75acff;
          margin-right: 3px;
          font-size: 14px;
        }
      }
      .detail-condition {
        display: flex;
        width: calc(100% - 66px);
        margin-left: 72px;
        margin-top: 13px;
        border-radius: 2px;
        font-size: 14px;
        color: #333333;
        flex-wrap: wrap;
        // div:nth-child(odd) {
        //   border-right: none;
        // }
        div:nth-child(2),
        div:nth-child(4) {
          border-left: none;
        }
        div:nth-child(3),
        div:nth-child(4) {
          border-top: none;
        }
        &-item {
          width: calc(50% - 2px);
          min-width: 327px;
          height: 40px;
          line-height: 40px;
          background: #f7f7f7;
          border: 1px solid #d8d8d8;

          .name {
            display: inline-block;
            width: 68px;
            padding-left: 10px;
            color: #999999;
          }
        }
      }
      .statistics-info {
        display: flex;
        justify-content: space-around;
        margin-top: 24px;
        margin-left: 52px;
        .statistics-ul {
          border-radius: 2px;
          background-color: #f6f6ff;
          border: 1px solid rgba(88, 80, 255, 0.8);
        }
        .statistics-li {
          display: inline-block;
          // width: 142px;
          color: #424242;
          font-size: 14px;
          text-align: center;
          margin: 42px 35px;
          &.statistics-border {
            padding-right: 35 px;
            margin-right: 0;
            padding-right: 36px;
            border-right: 1px solid #5850ff;
          }
          .statistics-number {
            margin-bottom: 12px;
            font-size: 16px;
            color: #333;
            span {
              font-size: 26px;
            }
          }
          .statistics-text {
            width: 70px;
          }
        }
      }
    }
  }
}
.el-tag {
  margin-right: 6px;
  cursor: pointer;
}
.el-popover .el-tag {
  margin-bottom: 6px;
}
</style>