staffSendDetail.vue 3.58 KB
<template>
  <div>
    <glsx-combi-form ref="staffSendFormRef" :formObj="searchForm" :formData="staffSendFormData" :inline="true">
      <span slot="footer">
        <el-button type="primary" :size="size" @click="getListApi">查询</el-button>
      </span>
    </glsx-combi-form>
    <GLTable ref="staffSendDetailRef" :hasPage="false" :tableData="sendStaffTableData" @sortChange="sortChange" :beforeSearchFn="beforeSearchFn" :noDataImg="url" :searchForm="searchForm" :tableParams="tableParams"></GLTable>
  </div>
</template>

<script>
import url from '@/assets/empty.png'
export default {
  name: 'staffSendDetail',
  props: ['materialId', 'startTime', 'endTime'],
  data() {
    return {
      url,
      searchForm: {
        materialId: this.$route.query.id,
        employeeName: '',
        sortValue: '',
        sort: ''
        // startTime: this.$parent.startTime,
        // endTime: this.$parent.endTime
      },
      staffSendFormData: [
        {
          label: '',
          name: 'employeeName',
          type: 'input',
          placeholder: '请输入姓名',
          prefixIcon: 'el-icon-search',
          isClear: true
        }
      ],
      // getListApi: this.$apis.material.sendDetailPage,
      // pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'count' },
      sendStaffTableData: [],
      tableParams: {
        listName: 'data',
        tableOption: false,
        tableColumns: [
          {
            label: '姓名',
            prop: 'employeeName'
          },
          {
            label: '发送次数',
            prop: 'sendNumber',
            sortable: true
          },
          {
            label: '阅读次数',
            prop: 'readNumber',
            sortable: true
          },
          {
            label: '阅读人数',
            prop: 'readPeopleNumber'
          },
          {
            label: '打开率',
            prop: 'openRate'
          }
        ]
      }
    }
  },
  mounted() {
    this.getListApi()
  },
  methods: {
    // 搜索
    // handleSearch() {
    //   this.$refs.staffSendDetailRef.refreshTable()
    // },
    // 重置
    handleReset() {
      this.searchForm = {
        staffName: '',
        materialId: this.$route.query.id
      }
      this.getListApi()
    },
    // 排序
    sortChange({ column, prop, order }) {
      order === 'ascending' ? (this.searchForm.sort = 2) : (this.searchForm.sort = 1)
      prop === 'sendNumber' ? (this.searchForm.sortValue = 2) : (this.searchForm.sortValue = 1)
      this.getListApi()
    },
    getParams() {
      var params = JSON.parse(JSON.stringify(this.searchForm))
      return params
    },
    getListApi() {
      var params = this.getParams()
      params.startTime = this.$parent.startTime
      params.endTime = this.$parent.endTime
      this.$apis.material.sendDetailPage(params).then(res => {
        this.sendStaffTableData = res
        // 计算表格高度,数据10条以下自适应,10条以上固定高度,表格内滚动,无数据调用方法计算高度
        res.length ? (res.length > 10 ? (this.$refs.staffSendDetailRef.tableHeightValues = '425px') : (this.$refs.staffSendDetailRef.tableHeightValues = '')) : (this.$refs.staffSendDetailRef.tableHeightValues = '325px')
        // res.length > 10 ? (this.$refs.staffSendDetailRef.tableHeightValues = '425px') : (this.$refs.staffSendDetailRef.tableHeightValues = '')
      })
    }
  }
}
</script>

<style lang="scss" scoped>
/deep/ .el-table .ascending .sort-caret.ascending {
  border-bottom-color: #5850ff;
}
/deep/ .el-table .descending .sort-caret.descending {
  border-top-color: #5850ff;
}
</style>