recordList.vue 10.2 KB
<template>
  <div class="channel-main scrm-box-f">
    <div class="scrm-GLCombiForm">
      <GLCombiForm :rowNumber="1" ref="formSearch" :formObj="tableSearchForm" :formData="searchFormData" @handleOk="handleSearch" @handleRest="handleReset"></GLCombiForm>
      <!-- <el-form :inline="true" :model="tableSearchForm" class="follow-form-item" label-width="130px">
        <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.cardName" placeholder="请输入渠道名称" :disabled="isShowInput"></el-input>
        </el-form-item>
        <el-form-item size="small" label="名片来源:">
          <el-input size="small" v-model="tableSearchForm.staffName" placeholder="请输入名片来源" :disabled="isShowInput"></el-input>
        </el-form-item>
        <el-form-item size="small" style="float: right; margin-left: 12px">
          <el-button type="primary" @click="handleSearch">查询</el-button>
          <el-button @click="handleReset" class="resetBtn">重置</el-button>
        </el-form-item>
      </el-form> -->
    </div>
    <div class="titleAndTime">
      <div class="listTitle">访问列表</div>
      <div>
        <el-radio-group v-model="timeRadio" size="mini" @change="handleTab">
          <el-radio-button label="">全部</el-radio-button>
          <el-radio-button label="1">今天</el-radio-button>
          <el-radio-button label="2">本周</el-radio-button>
          <el-radio-button label="3">本月</el-radio-button>
          <el-radio-button label="4">今年</el-radio-button>
        </el-radio-group>
        <el-button style="margin-left:20px" plain size="small" @click="handleExport">
          导出
        </el-button>
      </div>
    </div>
    <GLTable ref="table" :layout="layout" :tableData="tableData" :tableTotal="tableTotal" :pageConf="pageConf" :tableParams="tableParams" @refreshTable="handleSearch">
      <div class="table-btns" slot="optionBtns" slot-scope="scope">
        <el-button type="text" @click="accessToRecords(scope)">访问记录</el-button>
      </div>
      <div class="table-btns" slot="nickName" slot-scope="scope">
        {{ scope.scope.nickName }}
        <span class="typeInfo">{{ scope.scope.type == '1' ? '@微信' : scope.scope.type == '2' ? '@企微' : '' }}</span>
      </div>
      <div class="table-btns" slot="isJoin" slot-scope="scope">
        {{ scope.scope.isJoin == '0' ? '否' : scope.scope.isJoin == '1' ? '是' : '--' }}
      </div>
    </GLTable>
    <el-dialog class="recordDialog" title="访问记录" :visible.sync="dialogTableVisible" width="38%" :top="0">
      <el-table :data="recordRelationList">
        <el-table-column type="index" :index="1" label="序号" width="120"></el-table-column>
        <el-table-column property="pageName" label="访问页面" width="220"></el-table-column>
        <el-table-column property="createdTime" label="访问时间"></el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template>

<script>
import util from '@/utils/util'
export default {
  name: 'recordList',
  data() {
    return {
      isShowInput: false,
      recordRelationList: [],
      dialogTableVisible: false,
      timeRadio: '',
      dateInterval: '',
      pickerOptions: {
        disabledDate: time => {
          return time.getTime() > Date.now()
        }
      },
      channel: [],
      tableSearchForm: {
        createTime: '',
        cardName: '',
        staffName: ''
      },
      searchFormData: [
        {
          label: '访问时间',
          name: 'createTime',
          type: 'datePicker',
          placeholder: '',
          isClear: true,
          pickerOptions: {
            disabledDate: time => {
              return time.getTime() > Date.now()
            }
          }
        },
        {
          label: '渠道名称',
          name: 'cardName',
          type: 'input'
        },
        {
          label: '名片来源',
          name: 'staffName',
          type: 'input'
        }
      ],
      tableParams: {
        listName: 'data',
        tableOption: false,
        tableColumns: [
          {
            label: '访客',
            prop: 'nickName',
            addHtml: 'nickName'
          },
          {
            label: '手机号码',
            prop: 'phone'
          },
          {
            label: '已加企微',
            prop: 'isJoin',
            addHtml: 'isJoin'
          },
          {
            label: '渠道名称',
            prop: 'cardName'
          },
          {
            label: '名片来源',
            prop: 'staffName'
          },
          {
            label: '最后访问日期',
            prop: 'lastTime'
          },
          {
            label: '访问时间',
            prop: 'optionBtns',
            width: '100px',
            addHtml: 'optionBtns',
            fixed: 'right'
          }
        ]
      },
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'count' },

      layout: 'sizes, prev, pager, next, jumper, ->, total',
      tableData: [],
      tableTotal: 0,
      startDate: '',
      endDate: '',
      colorList: ['#5850FF', '#2CCA74', '#EB4E4E', '#FF6D00', '#F8C900', '#2CCAC4', '#E74EEB', '#6F2828']
    }
  },
  methods: {
    handleExport() {
      const params = this.getParams(1)
      this.$apis.businessCard.cardRecordExport(params).then(res => {
        util.downloadUrl(res)
      })
    },
    // 查看访问记录弹框
    accessToRecords(scope) {
      this.dialogTableVisible = true
      this.$nextTick(() => {
        this.recordRelationList = scope.scope.recordRelationList
      })
    },
    handleTime() {
      const value = this.createTime
      if (value && value.length > 0) {
        this.startDate = value[0]
        this.endDate = value[1]
        this.timeRadio = null
        this.dateInterval = null
      } else {
        this.startDate = ''
        this.endDate = ''
        this.timeRadio = ''
        this.dateInterval = ''
      }
      this.codeSearch()
    },
    handleTab() {
      this.createTime = []
      this.dateInterval = this.timeRadio
      this.startDate = ''
      this.endDate = ''
      this.codeSearch()
    },
    handleReset() {
      this.isShowInput = false
      Object.keys(this.tableSearchForm).forEach(key => {
        this.tableSearchForm[key] = ''
      })
      this.createTime = []
      this.timeRadio = ''
      let params = {
        ...this.tableSearchForm,
        pageSize: 10,
        pageNum: 1,
        dateInterval: ''
      }
      this.sendPageListApi(params)
    },
    handleSearch() {
      this.codeSearch()
    },
    getParams(status) {
      if (this.tableSearchForm.createTime) {
        this.tableSearchForm.startDate = new Date(this.tableSearchForm.createTime[0]).toLocaleDateString().replace(/\//g, '-')
        this.tableSearchForm.endDate = new Date(this.tableSearchForm.createTime[1]).toLocaleDateString().replace(/\//g, '-')
      }
      let params = {
        ...JSON.parse(JSON.stringify(this.tableSearchForm)),
        pageSize: status ? 100000 : this.$refs.table.page.pageSize,
        pageNum: this.$refs.table.page.pageNum,
        dateInterval: this.dateInterval
      }
      delete params.createTime
      return params
    },
    codeSearch() {
      const params = this.getParams()
      this.sendPageListApi(params)
    },
    sendPageListApi(params) {
      this.$apis.businessCard.getaccessToRecordsPage(params).then(res => {
        this.tableData = res.data
        this.tableTotal = res.count
      })
    }
  },
  mounted() {
    if (this.$parent.query && this.$parent.query.cardName) {
      let { cardName, cardId, staffName } = this.$parent.query
      this.timeRadio = this.dateInterval = 4
      this.$set(this.tableSearchForm, 'cardName', cardName)
      this.$set(this.tableSearchForm, 'staffName', staffName)
      this.$set(this.tableSearchForm, 'cardId', cardId)
      this.isShowInput = true
    }
    this.codeSearch()
  },
  beforeDestroy() {
    this.$parent.query = {}
  }
}
</script>

<style lang="scss" scoped>
.resetBtn {
  margin-left: 8px;
}
.titleAndTime {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  .listTitle {
    font-size: 16px;
    font-weight: 600;
    color: #333;
  }
}
.typeInfo {
  font-size: 12px;
  color: #2cca74;
}
/deep/.recordDialog {
  .el-dialog {
    height: 100vh;
    overflow: auto;
    margin-right: 0;
    margin-bottom: 0;
  }
}
.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>