detailList.vue 7.75 KB
<template>
  <div class="points">
    <div class="container">
      <GLCombiForm ref="showSearch" :formObj="searchForm" :formData="showFormData" @handleOk="handleSearch" @handleRest="handleReset"></GLCombiForm>
      <div class="table-header">
        <h2>积分明细列表</h2>
        <el-button size="small" @click="handleExport" type="primary" plain>导出</el-button>
      </div>

      <GLTable ref="pointTable" :search-form="searchFormSearch" :table-params="tableParams" :get-list-api="getListApi" :pageConf="pageConf" :before-search-fn="beforeSearchFn">
        <div class="table-btns" slot="auth-button" slot-scope="scope">
          <GLTableButton :buttonList="tableButtonList" :buttonItem="scope.scope" :buttonNum="3"></GLTableButton>
        </div>
      </GLTable>
    </div>
  </div>
  <!-- </div> -->
</template>
<script>
import * as dayjs from 'dayjs'
export default {
  props: {
    // 积分渠道,1.阳光激励 2.续保用户 3.管理层
    channelSource: {
      type: String,
      default: '1'
    }
  },
  data() {
    return {
      searchForm: {
        staffName: '',
        staffPhone: '',
        merchantId: '',
        rewardTime: [],
        reviewTime: [],
        successTime: []
      },
      searchFormSearch: {},
      tableButtonList: [
        {
          type: 'GLButton',
          name: '详情',
          attrs: {
            type: 'text',
            fn: '详情'
          },
          listeners: {
            click: this.handleDetail
          }
        }
      ],
      getListApi: this.$apis.points.getStaffScoreList,
      showFormData: [
        {
          label: '员工名称',
          name: 'staffName',
          type: 'input',
          isClear: true
        },
        {
          label: '员工手机号',
          name: 'staffPhone',
          type: 'input',
          isClear: true
        },
        {
          label: '门店名称',
          name: 'merchantId',
          type: 'select',
          optionList: [],
          optionId: 'merchantId',
          optionLabel: 'merchantName',
          optionsName: 'merchantServiceList'
        },
        {
          label: '积分收益时间',
          name: 'rewardTime',
          type: 'datePicker',
          isClear: true,
          pickerOptions: 'beforeRangePickerOptions'
        },
        {
          label: '积分付款时间',
          name: 'reviewTime',
          type: 'datePicker',
          isClear: true,
          pickerOptions: 'beforeRangePickerOptions'
        },
        {
          label: '积分到账时间',
          name: 'successTime',
          type: 'datePicker',
          isClear: true,
          pickerOptions: 'beforeRangePickerOptions'
        }
      ],
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableOption: true,
        tableColumns: [
          {
            label: '门店名称',
            prop: 'merchantName'
          },
          {
            label: '员工名称',
            prop: 'staffName'
          },
          {
            label: '员工手机号',
            prop: 'staffPhone'
          },
          {
            label: '当前积分',
            prop: 'currentScore'
          },
          {
            label: '累计收益积分',
            prop: 'totalRewardScore'
          },
          {
            label: '累计兑换积分',
            prop: 'totalWithdrawalScore'
          },
          {
            label: '累计抵扣积分',
            prop: 'totalDeductScore'
          }
        ]
      },
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
      baseData: {
        merchantServiceList: []
      }
    }
  },
  mounted() {
    this.tableParams.tableColumns[1].label = this.channelSource == '1' ? '员工名称' : '客户名称'
    this.tableParams.tableColumns[2].label = this.channelSource == '1' ? '员工手机号' : '客户手机号'
    this.showFormData[0].label = this.channelSource == '1' ? '员工名称' : '客户名称'
    this.showFormData[1].label = this.channelSource == '1' ? '员工手机号' : '客户手机号'
    this.$apis.points.getShopMerchantList({}).then((res) => {
      this.baseData.merchantServiceList = res
      this.getOptionsList()
    })
  },
  methods: {
    // 导出
    handleExport() {
      let params = {
        ...this.searchFormSearch,
        currentPage: 1,
        pageSize: 9999
      }

      this.$apis.points.getStaffScoreExport(params).then((res) => {
        console.log(res)
        this.$utils.aToExport(res)
        // this.$open(res)
      })
    },
    handleDetail(row) {
      let obj = {}
      if (this.channelSource != 1) {
        obj = {
          searchObj: JSON.stringify({
            merchantId: row.merchantId,
            staffPhone: row.staffPhone
          }),
          staffName: row.staffName,
          channelSource: this.channelSource
        }
      } else {
        obj = {
          searchObj: JSON.stringify({
            staffId: row.staffId
          }),
          staffName: row.staffName,
          channelSource: this.channelSource
        }
      }
      this.$router.push({
        path: '/pointsList/userDetail',
        query: obj
      })
    },
    getOptionsList() {
      this.showFormData.forEach((item, index) => {
        if (item.type === 'select') {
          if (this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this.showFormData[index].optionLabel] !== '全部') {
            const temp = {}
            temp[this.showFormData[index].optionId] = ''
            temp[this.showFormData[index].optionLabel] = '全部'
            this.baseData[item.optionsName].unshift(temp)
          }
          this.$set(this.showFormData[index], 'optionList', this.baseData[item.optionsName])
        }
      })
    },
    beforeSearchFn() {
      return new Promise(resolve => {
        this.searchFormSearch = this.$common.utils.deepClone(this.searchForm)
        console.log(this.channelSource, 'channelSource-----')
        this.searchFormSearch.channelSource = this.channelSource
        if (this.searchFormSearch.rewardTime && this.searchFormSearch.rewardTime.length) {
          this.searchFormSearch.rewardBeginTime = dayjs(this.searchFormSearch.rewardTime[0]).format('YYYY-MM-DD') + ' 00:00:00'
          this.searchFormSearch.rewardEndTime = dayjs(this.searchFormSearch.rewardTime[1]).format('YYYY-MM-DD') + ' 23:59:59'
        }
        if (this.searchFormSearch.reviewTime && this.searchFormSearch.reviewTime.length) {
          this.searchFormSearch.reviewBeginTime = dayjs(this.searchFormSearch.reviewTime[0]).format('YYYY-MM-DD') + ' 00:00:00'
          this.searchFormSearch.reviewEndTime = dayjs(this.searchFormSearch.reviewTime[1]).format('YYYY-MM-DD') + ' 23:59:59'
        }
        if (this.searchFormSearch.successTime && this.searchFormSearch.successTime.length) {
          this.searchFormSearch.successBeginTime = dayjs(this.searchFormSearch.successTime[0]).format('YYYY-MM-DD') + ' 00:00:00'
          this.searchFormSearch.successEndTime = dayjs(this.searchFormSearch.successTime[1]).format('YYYY-MM-DD') + ' 23:59:59'
        }
        delete this.searchFormSearch.rewardTime
        delete this.searchFormSearch.successTime
        delete this.searchFormSearch.reviewTime
        resolve()
      })
    },
    handleSearch() {
      this.$refs.pointTable.refreshTable()
    },
    handleReset() {
      this.searchForm = {
        staffName: '',
        staffPhone: '',
        merchantId: '',
        rewardTime: [],
        reviewTime: [],
        successTime: []
      }
      this.searchFormSearch = {}
      this.$refs.pointTable.refreshTable(true, true)
    }
  }
}
</script>
<style scoped lang="scss">
.d2-container-content {
  ::v-deep {
    .tableHeaderTitle {
      font-weight: 500;
      font-size: 16px;
      color: #333333;
    }
  }
}
</style>