index.vue 7.2 KB
<template>
  <div class="container">
    <GLCombiForm
      ref="showSearch"
      :rowNumber="2"
      :formObj="searchForm"
      :formData="searchFormData"
      @handleOk="handleSearch"
      @handleRest="handleReset"
    ></GLCombiForm>
    <div class="sticky-btns">
      <el-button
        type="default"
        plain
        @click="jump"
        size="small"
      >客户积分充值</el-button>
      <el-button
        @click="handleExport"
        size="small"
      >导出
      </el-button>
    </div>
    <div class="tabelList">
      <GLTable
        ref="listRef"
        :getListApi="getListApi"
        :searchForm="tableSearchForm"
        :tableParams="tableParams"
        :pageConf="pageConf"
        :beforeSearchFn="beforeSearchFn"
      >
        <template
          slot="customerNumber"
          slot-scope="scope"
        >
          <div
            class="link"
            @click="openDetail(scope.scope.id)"
          >{{scope.scope.customerNumber}}</div>
        </template>
        <template
          slot="totalIntegral"
          slot-scope="scope"
        >
          <div class="totalIntegral">
            {{scope.scope.totalIntegral}}
            <div class="service">(含{{scope.scope.totalIntegral}}%手续费)</div>
          </div>
        </template>
        <template
          slot="status"
          slot-scope="scope"
        >
          <div class="status-box">
            <span :class="['status',`status-${scope.scope.status}`]"></span>
            {{{0:'待充值',1:'充值成功'}[scope.scope.status]}}
          </div>
        </template>
        <template
          slot="auth-button"
          slot-scope="scope"
        >
          <GLTableButton
            :buttonList="tableButtonList"
            :buttonItem="scope.scope"
            :buttonNum="3"
          ></GLTableButton>
        </template>
      </GLTable>
    </div>
    <detail-dialog :detailObj.sync="detailObj" />
  </div>
</template>

<script type='text/ecmascript-6'>
import detailDialog from './components/detailDialog.vue'
import * as dayjs from 'dayjs'
import { aToExport } from '@/common/constant'
export default {
  name: '',
  components: {
    detailDialog
  },
  data () {
    return {
      pageConf: { pageSize: 'pageSize', pageNum: 'currentPage', totalCount: 'total' },
      searchForm: {
        batchNo: '',
        policyNo: '',
        customerName: '',
        customerPhone: '',
        auditDate: [],
        merchantId: this.$globalState.session.merchantId
      },
      searchFormData: [
        {
          label: '批次',
          name: 'batchNo',
          type: 'input',
          maxlength: 100
        },
        {
          label: '保单号',
          name: 'policyNo',
          type: 'input',
          maxlength: 100
        },
        {
          label: '用户姓名',
          name: 'customerName',
          type: 'input',
          maxlength: 100
        },
        {
          label: '用户手机号',
          name: 'customerPhone',
          type: 'input',
          maxlength: 100
        },
        {
          label: '发放时间',
          name: 'auditDate',
          type: 'datePicker',
          valueFormat: 'yyyy-MM-dd',
          isClear: true,
          customPickerOptions: {
            disabledDate (date) {
              const yesterday = new Date(new Date().setDate(new Date().getDate()))
              if (date > yesterday) {
                return true
              }
              return false
            }
          }
        },
      ],
      getListApi: this.$apis.points.getIntegralList,
      tableParams: {
        listName: 'list',
        tableOption: true,
        tableColumns: [
          {
            label: '批次',
            prop: 'batchNo',
            minWidth: 100
          },
          {
            label: '客户数量',
            addHtml: 'customerNumber',
            minWidth: 100
          },
          {
            label: '充值积分总数',
            minWidth: 120,
            prop: 'totalIntegral',
          },
          {
            label: '状态',
            minWidth: 100,
            addHtml: 'status',
          },
          {
            label: '创建时间',
            minWidth: 150,
            formatter: cell => dayjs(cell.createdDate).format('YYYY/MM/DD hh:mm:ss')
          },
          {
            label: '操作人',
            prop: 'updatedBy',
            minWidth: 150,
          },
        ]
      },
      tableButtonList: [
        {
          type: 'el-button',
          name: '详情',
          attrs: {
            type: 'text',
          },
          condition: row => row.status == 1,
          listeners: {
            click: row => this.editForm(row)
          }
        },
        {
          type: 'el-button',
          name: '编辑',
          attrs: {
            type: 'text',
          },
          condition: row => row.status == 0,
          listeners: {
            click: row => this.editForm(row, 'edit')
          }
        },
      ],
      tableSearchForm: {},
      detailObj: {}
    }
  },
  mounted () {
  },
  methods: {
    beforeSearchFn () {
      return new Promise(resolve => {
        this.tableSearchForm = this.getParams()
        resolve()
      })
    },
    handleSearch () {
      // this.tableSearchForm = this.getParams()
      this.$refs.listRef.refreshTable()
    },
    handleReset () {
      this.searchForm = this.$options.data.call(this).searchForm
      this.handleSearch()
    },
    handleExport () {
      const params = this.getParams()
      this.$apis.points.exportIntegralList({ ...params, ...this.$refs.listRef.page }).then(res => {
        aToExport(res)
      })
    },
    getParams () {
      let params = JSON.parse(JSON.stringify(this.searchForm))
      this.setTimeFormat(params, 'auditDate', 'auditDateBegin', 'auditDateEnd')
      return params
    },
    setTimeFormat (target, name, start, end) {
      if (target[name] && target[name].length) {
        target[start] = `${dayjs(target[name][0]).format('YYYY-MM-DD')} 00:00:00`
        target[end] = `${dayjs(target[name][1]).format('YYYY-MM-DD')} 23:59:59`
        delete target[name]
      }
    },
    jump () {
      this.$router.push({
        path: '/points/add',
        query: {
          $title: '客户积分充值',
        }
      })
    },
    openDetail (recordId) {
      this.detailObj = {
        show: true,
        recordId
      }
    },
    editForm (row, type = '') {
      this.$router.push({
        path: '/points/add',
        query: {
          $title: type ? '编辑客户积分充值' : '查看客户积分充值',
          id: row.id,
          type
        }
      })
    }

  }
}
</script>

<style scoped lang='scss'>
.container {
  height: 100%;
  background-color: #fff;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  padding: 20px;

  .sticky-btns {
    margin-bottom: 10px;
    display: flex;
    justify-content: flex-end;
    .el-button {
      min-width: 60px;
    }
    .el-button + .el-button {
      margin-left: 10px;
    }
  }
  .link {
    color: #5850ff;
    cursor: pointer;
  }
}
.status-box {
  display: flex;
  align-items: center;
  .status {
    width: 6px;
    height: 6px;
    border-radius: 4px;
    background: #fdb757;
    margin-right: 8px;
  }
  .status-1 {
    background: #2cca74;
  }
}
</style>