basicInfo.vue 10.7 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">{{ basicInfo.type == 1 ? '个人发表' : '企业发表' }}</div>
          </div>
          <div class="detail-item">
            <div class="detail-label">发布方式:</div>
            <div class="detail-value">{{ basicInfo.sendType == 1 ? '立即发送' : '定时发送' }}</div>
          </div>
          <div class="detail-item">
            <div class="detail-label">创建时间:</div>
            <div class="detail-value">{{ basicInfo.createdTime ? basicInfo.createdTime : '-' }}</div>
          </div>
          <div class="detail-item" style="margin-bottom: 0">
            <div class="detail-label">创建者:</div>
            <div class="detail-value">
              <div class="entmicro-hover" v-if="basicInfo.createdName">
                <el-tag type="info" :disable-transitions="false">
                  <i class="el-icon-user-solid"></i>
                  {{ basicInfo.createdName }}
                </el-tag>
              </div>
              <!--  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>
        <div class="title">
          数据统计
          <span class="info-refresh" @click="handleRefresh">
            <i :class="{ 'el-icon-refresh': true, 'wait-status': refreshStatus }"></i>
            更新数据
          </span>
          <span class="info-time">更新于:{{ this.updatedTime }}</span>
        </div>
        <div class="statistics-info">
          <div class="statistics-ul">
            <div class="statistics-li statistics-border">
              <div class="statistics-number">
                <span>{{ basicInfo.sendStaffCount }}</span>
                人
              </div>
              <div class="statistics-text">已发送成员</div>
            </div>
            <div class="statistics-li">
              <div class="statistics-number">
                <span>{{ basicInfo.unSendStaffCount }}</span>
                {{ form == 'customer' ? '人' : '个' }}
              </div>
              <div class="statistics-text">未发送成员</div>
            </div>
          </div>
          <div v-if="form == 'customer'" class="statistics-ul">
            <div class="statistics-li">
              <div class="statistics-number">
                <span>{{ basicInfo.copyCustomerCount }}</span>
                人
              </div>
              <div>已送达客户</div>
            </div>
          </div>
        </div>
      </div>
      <Preview :previewView="previewView" :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'
import { utils } from 'glsx-common'
export default {
  name: 'BasicInof',
  props: ['form', 'id', 'eventBus'],
  components: {
    Preview
  },
  data() {
    return {
      previewView: '',
      updatedTime: '',
      refreshStatus: false,
      STATUS_TYPE: STATUS,
      SEX_TYPE: SEX,
      basicInfo: {
        condition: {}
      },
      statistic: {},
      limitUserList: []
    }
  },
  watch: {
    basicInfo(val) {
      if (val.userList.length > 4) {
        this.limitUserList = val.userList.slice(0, 4)
      } else {
        this.limitUserList = val.userList
      }
    }
  },
  mounted() {
    this.handleRefresh()
    // this.getStatistic()
    // console.log(this.basicInfo.condition, '----')
  },
  computed: {
    // tagWidth() {
    //   var jmz = {}
    //   jmz.GetLength = function (str) {
    //     return str.replace(/[\u0391-\uFFE5]/g, 'aa').length //先把中文替换成两个字节的英文,在计算长度
    //   }
    // }
  },
  methods: {
    handleRefresh: utils.debounce(function() {
      this.publicStatus()
      this.refreshStatus = true
      setTimeout(() => {
        this.refreshStatus = false
      }, 1000)
    }, 1000),
    publicStatus() {
      const id = this.$route.query.id
      this.$apis.friendGroup.publicStatus({ id }).then(res => {
        this.getCustomerDetail()
        this.$emit('refreshList')
      })
    },
    getCustomerDetail() {
      const id = this.$route.query.id
      this.$apis.friendGroup.momentDetail({ id }).then(res => {
        this.updatedTime = dayjs(new Date().getTime()).format('YYYY-MM-DD HH:mm:ss')
        this.basicInfo = res
        // console.log(this.basicInfo, '123');
        // 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.previewView = previewList
        //图片合并
        // let previewListFilter = previewList.map(item => {
        //   return {
        //     attContent: [item.attContent],
        //     attType: item.attType
        //   }
        // })
        // previewListFilter = previewListFilter.reduce((prev, cur) => {
        //   let index = prev.findIndex(item => item.attType == 2)
        //   if (index != -1 && prev.length) {
        //     const prevArr = prev.map(tag => {
        //       let attContent
        //       if (tag.attType == 2) {
        //         attContent = tag.attContent.concat(cur.attContent)
        //       } else {
        //         attContent = tag.attContent
        //       }
        //       return {
        //         attType: tag.attType,
        //         attContent
        //       }
        //     })
        //     return prevArr
        //   }
        //   return prev.concat(cur)
        // }, [])
        // this.eventBus.$emit('update', previewListFilter)
      })
    },
    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;
    .info-refresh {
      font-size: 14px;
      color: #5850ff;
      cursor: pointer;
      margin-left: 20px;
      .wait-status {
        transition: all ease-in 1s;
        transform: rotate(360deg);
      }
    }
    .info-time {
      font-size: 14px;
      color: #7d7d7d;
      margin-left: 10px;
    }
  }
  .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% - 323px);

      .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: 85px;
          text-align: right;
          margin-right: 12px;
        }
        .detail-tips {
          margin-left: 8px;
          color: #939393;
        }
        .el-tag-item {
          margin-right: 6px;
          &: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;
          min-width: 325px;

          .name {
            display: inline-block;
            width: 68px;
            padding-left: 10px;
            color: #999999;
          }
        }
      }
      .statistics-info {
        margin-top: 24px;
        margin-left: 52px;
        display: flex;
        overflow-x: scroll;
        .statistics-ul {
          display: flex;
          border-radius: 2px;
          background-color: #f6f6ff;
          border: 1px solid rgba(88, 80, 255, 0.8);
          margin-right: 20px;
          height: 142px;
          &:last-child {
            margin-right: 0;
          }
        }
        .statistics-li {
          position: relative;
          color: #424242;
          font-size: 14px;
          text-align: center;
          width: 142px;
          display: flex;
          align-items: center;
          justify-content: center;
          flex-direction: column;
          &.statistics-border {
            margin-right: 0;
            // border-right: 1px solid #5850ff;
            &::after {
              content: '';
              display: inline-block;
              position: absolute;
              right: 0;
              height: 58px;
              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;
}
.el-tag-item {
  display: inline-flex;
  align-items: center;
}
.hidden-tag {
  max-width: 82px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
</style>