proxyList.vue 9.08 KB
<template>
  <div class="channel-main scrm-box-f">
    <div class="scrm-flex">
      <el-radio-group v-model="timeRadio" size="mini" @change="handleTab">
        <el-radio-button label="1">昨天</el-radio-button>
        <el-radio-button label="2">近1周</el-radio-button>
        <el-radio-button label="3">近2周</el-radio-button>
        <el-radio-button label="4">近1个月</el-radio-button>
      </el-radio-group>
      <el-form :inline="true" :model="tableSearchForm" class="follow-form-item" label-width="80px">
        <el-form-item size="small" label="访问时间">
          <el-date-picker :picker-options="pickerOptions" @change="handleTime" value-format="yyyy-MM-dd" v-model="createTime" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
        </el-form-item>
        <el-form-item size="small" label="渠道名称">
          <el-input size="small" v-model="tableSearchForm.keyWord" placeholder="请输入渠道名称"></el-input>
        </el-form-item>
        <el-form-item size="small" style="float: right; margin-left: 40px">
          <el-button type="primary" @click="handleSearch">查询</el-button>
        </el-form-item>
      </el-form>
    </div>
    <GLTable ref="table" :layout="layout" :tableData="tableData" :tableTotal="tableTotal" :pageConf="pageConf" :tableParams="tableParams" @refreshTable="handleSearch">
      <div slot="newlyCount" slot-scope="scope">
        <div class="link-dialog" @click="handleEmpDetail(scope.scope, 'day', scope.scope.timeFrame)" v-if="scope.scope.newlyCount">{{ scope.scope.newlyCount }}</div>
        <div v-else>0</div>
      </div>
      <div slot="newlyKeepCount" slot-scope="scope">
        <div class="link-dialog" @click="handleEmpDetail(scope.scope, 'status', scope.scope.timeFrame)" v-if="scope.scope.newlyKeepCount">{{ scope.scope.newlyKeepCount }}</div>
        <div v-else>0</div>
      </div>
      <div class="table-btns" slot="optionBtns" slot-scope="scope">
        <el-button type="text" @click="handleEmpDetail(scope.scope)">访问记录</el-button>
      </div>
    </GLTable>
    <page-detail ref="empDetailForm"></page-detail>
  </div>
</template>

<script>
import pageDetail from '@/components/pageDetail'
export default {
  name: 'proxyList',
  components: {
    pageDetail
  },
  data() {
    return {
      timeRadio: 1,
      trendType: 1,
      pickerOptions: {
        disabledDate: time => {
          return time.getTime() > Date.now()
        }
      },
      channel: [],
      createTime: [],
      tableSearchForm: {},
      tableParams: {
        listName: 'data',
        tableOption: false,
        tableColumns: [
          {
            label: '微信名称',
            prop: 'codeName'
          },
          {
            label: '手机号码',
            prop: 'codeName'
          },
          {
            label: '已加企微',
            prop: 'newlyCount',
            formatter: value => {
              return '是'
            }
          },
          {
            label: '渠道名称',
            prop: 'codeName'
          },
          {
            label: '名片来源',
            prop: 'newlyKeepCount',
            addHtml: 'newlyKeepCount'
          },
          {
            label: '日期',
            prop: 'timeFrame'
          },
          {
            label: '操作',
            prop: 'optionBtns',
            width: '80px',
            addHtml: 'optionBtns',
            fixed: 'right'
          }
        ]
      },
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'count' },
      layout: 'sizes, prev, pager, next, jumper, ->, total',
      tableData: [],
      tableTotal: 0,
      startTime: '',
      endTime: '',
      selectItem: [],
      codeIds: [],
      colorList: ['#5850FF', '#2CCA74', '#EB4E4E', '#FF6D00', '#F8C900', '#2CCAC4', '#E74EEB', '#6F2828']
    }
  },
  // watch: {
  //   createTime(value) {
  //     if (value) {
  //       this.startTime = value[0]
  //       this.endTime = value[1]
  //       this.timeRadio = null
  //       this.trendType = null
  //     } else {
  //       this.startTime = ''
  //       this.endTime = ''
  //       this.timeRadio = 1
  //       this.trendType = 1
  //     }
  //     this.getFollower()
  //     this.codeSearch()
  //   }
  // },
  methods: {
    handleTime() {
      const value = this.createTime
      if (value && value.length > 0) {
        this.startTime = value[0]
        this.endTime = value[1]
        this.timeRadio = null
        this.trendType = null
      } else {
        this.startTime = ''
        this.endTime = ''
        this.timeRadio = 1
        this.trendType = 1
      }
      this.getFollower()
      this.codeSearch()
    },
    handleTab() {
      this.createTime = []
      this.trendType = this.timeRadio
      this.createTime = ''
      this.endTime = ''
      this.codeSearch()
      this.getFollower()
    },
    handleSearch() {
      this.codeSearch()
    },
    handleEmpDetail(scope, value, day) {
      this.$refs.empDetailForm.init(scope, value, day)
    },
    codeSearch() {
      var params = {
        ...JSON.parse(JSON.stringify(this.tableSearchForm)),
        pageSize: this.$refs.table.page.pageSize,
        pageNum: this.$refs.table.page.pageNum,
        startTime: this.startTime,
        endTime: this.endTime,
        trendType: this.trendType
      }
      this.$apis.overview.codeSearch(params).then(res => {
        this.tableData = res.data
        this.tableTotal = res.count
      })
    },
    codeTrend() {
      let codeIds = this.codeIds.map(item => {
        return item.codeState
      })
      let codeName = this.codeIds.map(item => {
        return item.codeName
      })
      const { trendType, startTime, endTime } = this
      let params = {
        codeIds,
        trendType: trendType ? trendType : null,
        startTime,
        endTime
      }
      this.$apis.overview.codeTrend(params).then(res => {
        this.$refs.channelLine.init(res, codeName)
      })
    },
    selectTable(value) {
      this.codeIds = value.map(item => {
        return {
          codeState: item.codeState,
          codeName: item.codeName,
          totalNum: item.totalNum
        }
      })
      this.getFollower()
    },
    handleChannel() {
      this.$refs.channelForm.init(this.codeIds)
    },
    getFollowerTotal() {
      var params = {
        pageSize: 1000,
        pageNum: 1
      }
      this.$apis.channel.listChannelCodeByPage(params).then(res => {
        console.log(res)
        this.tableData = res.data
        this.tableTotal = res.count
        this.tableData.forEach(item => {
          this.selectCode.forEach((itm, index) => {
            if (itm.codeState == item.codeState) {
              this.$refs.table.$refs.salelistMutiTable.toggleRowSelection(item)
            }
          })
        })
      })
    },
    getFollower() {
      let codeState = this.codeIds.map(item => item.codeState)
      var params = {
        startTime: this.startTime,
        endTime: this.endTime,
        trendType: this.trendType,
        pageSize: 8,
        pageNum: 1,
        codeState
      }
      this.$apis.channel.listChannelCodeByPage(params).then(res => {
        this.channel = res.data
        this.codeIds = this.channel.map(item => {
          return {
            codeState: item.codeState,
            codeName: item.codeName,
            totalNum: item.totalNum
          }
        })
        this.codeTrend()
      })
    }
  },
  mounted() {
    this.codeSearch()
    this.getFollower()
  }
}
</script>

<style lang="scss" scoped>
.channel-main {
  padding: 20px;
  /deep/ {
    .el-radio-group {
      margin-top: 3px;
    }
  }
}
.link-dialog {
  text-decoration: underline;
  cursor: pointer;
}
.channel-chart {
  display: flex;
  .channel-chart-desc {
    width: 300px;
    min-height: 310px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    margin-bottom: 30px;
    .chart-desc-title {
      display: flex;
      justify-content: space-between;
      font-size: 14px;
      font-weight: 600;
      color: #333333;
      line-height: 20px;
      .chart-title-time {
        color: #5850ff;
      }
    }
    .chart-desc-item {
      display: flex;
      justify-content: space-between;
      font-size: 12px;
      font-weight: 400;
      color: #666666;
      line-height: 17px;
      margin-top: 10px;
      .chart-item-title {
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
        span {
          vertical-align: middle;
          display: inline-block;
          width: 12px;
          height: 2px;
          margin-right: 10px;
        }
      }
    }
    .chart-desc-add {
      font-size: 12px;
      font-weight: 400;
      color: #5850ff;
      line-height: 17px;
      text-align: center;
    }
    .chart-desc-addNum {
      font-size: 12px;
      font-weight: 400;
      color: #666666;
      line-height: 17px;
      text-align: center;
    }
  }
  &-box {
    flex: 1;
    .channel-chart-title {
      font-size: 18px;
      font-weight: 600;
      color: #333333;
      line-height: 25px;
    }
    .channel-chart-container {
      margin-top: 20px;
    }
  }
}
</style>