index.vue 6.38 KB
<template>
  <div class=" marketing pointerWriteOff">
    <div class="container">
      <GLCombiForm ref="pointerWriteOffSearch" :rowNumber="1" :formObj="searchForm" :formData="searchFormData"
                   @handleOk="handleSearch" @handleRest="handleReset"></GLCombiForm>
      <div class="exportBtn">
        <el-button :size="size" @click="handleExport" class="default-blue-btn" type="default">导出</el-button>
      </div>
      <GLTable ref="pointerWriteOffRef" :getListApi="getListApi" :noDataImg="url" :searchForm="searchForm"
               :tableParams="tableParams" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn">
        <div class="table-btns" slot="auth-button" slot-scope="scope">
          <GLTableButton :buttonList="tableButtonList" :buttonItem="scope.scope" :buttonNum="3"></GLTableButton>
        </div>
      </GLTable>
    </div>
  </div>
</template>

<script>

import {exportFn} from "@/common/constant";

export default {
  name: "index",
  data() {
    return {
      size: 'small',
      searchForm: {
        // merchantId: this.$globalState.session.merchantId,
        // merchantName: this.$globalState.session.merchantName
      },
      searchFormData: [
        {
          label: '项目名称',
          name: 'bizRelName',
          type: 'input',
          placeholder: '请输入项目名称'
        },
        {
          label: '核销日期',
          name: 'createDate',
          type: 'datePicker',
          isClear: true,
          pickerOptions: 'beforeRangePickerOptions'
        },
        {
          label: '结算状态',
          name: 'settlementStatus',
          type: 'select',
          optionList: [],
          optionId: 'confId',
          optionLabel: 'confName',
          optionsName: 'waiteOffStatusList'
        }
      ],
      baseData: {
        waiteOffStatusList: [
          {
            confId: '0',
            confName: '未结算'
          },
          {
            confId: '1',
            confName: '已结算'
          }
        ],
      },
      getListApi: this.$apis.pointWriteOff.getListApi,
      tableParams: {
        listName: 'list',
        tableOption: true,
        tableColumns: [
          {
            label: '项目名称',
            prop: 'bizRelName',
            width: 280
          },
          {
            label: '消费积分',
            prop: 'integralValue',
            width: 150
          },
          {
            label: '客户昵称',
            width: 150,
            prop: 'customerWechatName'
          },
          {
            label: '手机号',
            prop: 'customerPhone',
            width: 200,
            line: 1
          },
          {
            label: '核销员工',
            prop: 'verificationStaffName',
            width: 150
          },
          {
            label: '结算状态',
            prop: 'settlementStatus',
            width: 100,
            formatter: cellValue => {
              return this.baseData.waiteOffStatusList.find(item => item.confId == cellValue.settlementStatus).confName
            }
          },
          {
            label: '核销日期',
            width: 200,
            prop: 'verificationTime'
          },
          {
            label: '订单编号',
            prop: 'orderCode',
            width: 220
          }
        ],
      },
      tableButtonList: [
        {
          type: 'el-button',
          name: '查看',
          attrs: {
            type: 'text'
          },
          // condition: row => {
          //   return row.sopStatus != 1
          // },
          listeners: {
            click: row => this.$router.push({
              path: '/pointWriteOff/details',
              query: row ? { id: row.id } : ''
            })
          }
        },
      ],
      pageConf: {pageSize: 'pageSize', pageNum: 'currentPage', totalCount: 'total'},
    }
  },
  mounted() {
    this.getOptionsList('searchFormData')
  },
  methods: {

    getParams() {
      var params = JSON.parse(JSON.stringify(this.searchForm))
      if (this.searchForm.createDate?.length) {
        params.verificationStartTime = new Date(this.searchForm.createDate[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
        params.verificationEndTime = new Date(this.searchForm.createDate[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59'
      }
      delete params.createDate
      return params
    },
    handleReset() {
      this.searchForm = {
        bizRelName: '',
        settlementStatus: '',
        createDate: []
      }
      this.handleSearch()
    },
    getOptionsList(formName, hasAll = true, refreshSigle) {
      if (refreshSigle) {
        var item = this[formName].find(k => k.name == refreshSigle)
        var index = this[formName].findIndex(k => k.name == refreshSigle)
        this.$set(this[formName][index], 'optionList', this.$common.utils.deepClone(this.baseData[item.optionsName]))
        if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== '全部') {
          const temp = {}
          temp[this[formName][index].optionId] = ''
          temp[this[formName][index].optionLabel] = '全部'
          this[formName][index].optionList.unshift(temp)
        }
      } else {
        this[formName].forEach((item, index) => {
          if (item.type === 'select' && this.baseData[item.optionsName].length) {
            this.$set(this[formName][index], 'optionList', this.$common.utils.deepClone(this.baseData[item.optionsName]))
            if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== '全部') {
              const temp = {}
              temp[this[formName][index].optionId] = ''
              temp[this[formName][index].optionLabel] = '全部'
              this[formName][index].optionList.unshift(temp)
            }
          }
        })
      }
    },
    handleSearch() {
      this.$refs.pointerWriteOffRef.refreshTable()
    },
    beforeSearchFn() {
      return new Promise(resolve => {
        this.searchForm = this.getParams()
        // delete this.searchForm.createDate
        resolve()
      })
    },
    handleExport() {
      var params = this.getParams()
      this.$apis.pointWriteOff.pointWriteOffExportApi(params).then(res => {
        exportFn(res)
      })
    },

  }
}
</script>

<style lang="scss" scoped>
.exportBtn {
  float: right;
  margin-bottom: 10px;
}
</style>