myAccountRecord.vue 5.88 KB
<!-- 我的分账-提现记录 -->
<template>
  <d2-container class="my-account-record">
    <div class="header"
         slot="header">
      <d2-search ref="showSearch"
                 :search-form="searchForm"
                 :form-data="showFormData" />
      <div class="up-btns">
        <el-button :id="tableParams.btnId"
                   size="small"
                   type="primary">
          查询
        </el-button>
        <el-button size="small"
                   @click="handleReset">
          重置
        </el-button>
      </div>
    </div>
    <div class="d2-container-content">
      <d2-table-header :left-span="24">
        <span slot="left">共提现<span class="count-txt">{{ countObj.recordCount }}</span>次,累计分账金额<span
          class="count-txt">{{ countObj.totalAmount }}</span>元。</span>
      </d2-table-header>
      <d2-table ref="merchantTable"
                :get-list-api="getListApi"
                :search-form="searchFormSearch"
                :table-params="tableParams"
                :before-search-fn="beforeSearchFn" />
    </div>
  </d2-container>
</template>

<script>
import { Util, deepClone } from '@/common/util'
import { getWithdrawList, getWithdrawCountApi } from '@/api/account'
import { withdrawStatusList, withdrawChannelList } from '@/common/constants.js'
import { getCurrentSixMonth } from '@/common/format.js'
export default {
  name: 'MyAccountRecord',
  data() {
    return {
      countObj: {
        recordCount: '',
        totalAmount: ''
      },
      searchForm: {
        status: '',
        withdrawSource: '',
        withDrawDate: []
      },
      searchFormSearch: {},
      showFormData: [{
        label: '提现时间',
        name: 'withDrawDate',
        type: 'datePicker',
        dateType: 'monthrange',
        pickerOptions: 'rangePickerOptions'
      }, {
        label: '提现结果',
        name: 'status',
        type: 'select',
        optionList: [],
        optionId: 'confId',
        optionLabel: 'confLabel',
        optionsName: 'withdrawStatusList'
      }, {
        label: '提现渠道',
        name: 'withdrawSource',
        type: 'select',
        optionList: [],
        optionId: 'confId',
        optionLabel: 'confLabel',
        optionsName: 'withdrawChannelList'
      }],
      // 表格
      getListApi: getWithdrawList,
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableOption: false,
        tableColumns: [{
          label: '提现时间',
          prop: 'createdDate',
          formatter: (cellValue) => {
            return Util.dateFormate(cellValue.createdDate, 'YYYY-MM-DD HH:mm:ss')
          }
        }, {
          label: '登录账号',
          prop: 'createdBy'
        }, {
          label: '提现金额(元)',
          prop: 'totalAmount'
        }, {
          label: '到账账户名',
          prop: 'accountName'
        }, {
          label: '到账银行',
          prop: 'bankName'
        }, {
          label: '到账卡号',
          prop: 'bankAccountNo'
        }, {
          label: '验证手机号',
          prop: 'withdrawPhone'
        }, {
          label: '提现结果',
          prop: 'status',
          formatter: (cellValue) => {
            return this.baseData.withdrawStatusList.find(item => item.confId === cellValue.status).confLabel
          }
        }, {
          label: '到账金额(元)',
          prop: '',
          formatter: (cellValue) => {
            return cellValue.totalAmount - cellValue.fee
          }
        }, {
          label: '提现渠道',
          prop: 'withdrawSource',
          formatter: (cellValue) => {
            return this.baseData.withdrawChannelList.find(item => item.confId === cellValue.withdrawSource).confLabel
          }
        }]
      },
      baseData: {
        withdrawStatusList: withdrawStatusList,
        withdrawChannelList: withdrawChannelList
      }
    }
  },

  mounted() {
    this.searchForm.withDrawDate = getCurrentSixMonth()
    this.getOptionsList()
  },

  methods: {
    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])
        }
      })
    },

    getCount() {
      var params = this.getParams()
      getWithdrawCountApi(params).then(res => {
        this.countObj = res
      })
    },

    getMouthLastDate(date) {
      return new Date(date.setMonth(date.getMonth() + 1)).setDate(0)
    },

    getParams() {
      var params = deepClone(this.searchForm)
      if (params.withDrawDate && params.withDrawDate.length) {
        params.startDate = Util.dateFormate(this.getMouthLastDate(params.withDrawDate[0]), 'YYYY-MM-DD')
        params.endDate = Util.dateFormate(this.getMouthLastDate(params.withDrawDate[1]), 'YYYY-MM-DD')
        delete params.withDrawDate
      }
      return params
    },

    beforeSearchFn() {
      return new Promise(resolve => {
        this.searchFormSearch = this.getParams()
        this.getCount()
        resolve()
      })
    },

    handleReset() {
      this.searchForm = {
        status: '',
        withdrawSource: '',
        withDrawDate: getCurrentSixMonth()
      }
    }
  }
}

</script>
<style scoped>
.count-txt {
  font-weight: 700;
  color: #2a58ad;
  margin: 0 2px;
}
</style>