index.vue 4.77 KB
<template>
  <div>
    <WithdrawalSearch @sendSearchForm='getSearchForm' />
    <div class='btnOptons'>
      <el-button
        size='small'
        type='primary'
        @click="handleDialog('check')"
      >批量审核
      </el-button
      >
      <!--      <el-button-->
      <!--        size='small'-->
      <!--        type='primary'-->
      <!--        @click="handleDialog('transfer')"-->
      <!--      >-->
      <!--        批量重新发起转账-->
      <!--      </el-button-->
      <!--      >-->
      <el-button
        size='small'
        type='primary'
        @click='handleOutput'
      >导出
      </el-button
      >
    </div>
    <div class='account'>
      <p>累计提现金额:{{ collectionCash.totalAmount }};</p>
      <p>待审核:{{ collectionCash.reviewingAmount }};</p>
      <p>到账中:{{ collectionCash.receivingAmount }};</p>
      <p>已到账:{{ collectionCash.receivedAmount }};</p>
      <p>到账失败:{{ collectionCash.failureAmount }}</p>
    </div>
    <WithdrawalTable ref='table' :searchForm='searchForm' @sendCollection='getCollection' />
    <WithdrawalDialog :textTooltip='textTooltip' :auditId='auditId' ref='dialogRef' />
  </div>
</template>
<script>
import { withdrawalApi } from '@/api/withdrawalManagement'

import WithdrawalSearch from './components/WithdrawalSearch'
import WithdrawalTable from './components/WithdrawalTable'
import WithdrawalDialog from './components/WithdrawalDialog'
import { profitApi } from '@/api/profitManagement'

export default {
  components: {
    WithdrawalSearch,
    WithdrawalTable,
    WithdrawalDialog
  },
  data() {
    return {
      textTooltip: '',
      searchForm: {},
      choiceStatus: [],
      auditId: [],
      collectionCash: {}
    }
  },
  methods: {
    getCollection(val) {
      this.collectionCash = val
    },
    getSearchForm(val) {
      let params = JSON.parse(JSON.stringify(val))
      if (params && params.withdrawalTime) {
        params.withdrawalBeginTime = params.withdrawalTime[0]
        params.withdrawalEndTime = params.withdrawalTime[1]
      }
      if (params.withdrawalTime && params.withdrawalTime.length) delete params.withdrawalTime
      if (params && params.reviewTime) {
        params.reviewBeginTime = params.reviewTime[0]
        params.reviewEndTime = params.reviewTime[1]
      }
      if (params.reviewTime && params.reviewTime.length) delete params.reviewTime
      this.searchForm = params
      setTimeout(() => {
        this.$refs.table.$refs.withdrawalTable.refreshTable(true,true)
      }, 500)
    },
    getSeletedData() {
      this.choiceStatus = this.$refs.table.$children[0].mutiSelectArr.list &&
        this.$refs.table.$children[0].mutiSelectArr.list.map(item => {
          let { status, id, ...params } = item
          return { status, id }
        })
    },
    handleOutput() {
      let params = JSON.parse(JSON.stringify(this.searchForm))
      let pageConfig = {
        pageSize: 9999, pageNum: 1
      }
      withdrawalApi.exportList({ ...params, ...pageConfig }).then(res => {
        if (res.code == 0) {
          this.$Utils.exportFn(res.data)
        } else {
          this.$message({
            type: 'error',
            message: '导出失败!'
          })
        }
      })
    },
    vertify(selectType, status) {
      this.getSeletedData()
      let errMsg = selectType == 'check' ? '请选择待审核的提现记录!' : '请选择到账失败的提现记录'
      if ((selectType && (this.choiceStatus && !this.choiceStatus.length)) || !(selectType && (this.choiceStatus && this.choiceStatus.every(item => item.status == status)))) {
        this.$message({
          type: 'error',
          message: errMsg
        })
        return false
      } else {
        return true
      }
    },

    handleDialog(type) {
      let vertifycheck
      if (type == 'check') {
        vertifycheck = this.vertify('check', '1')
      } else {
        vertifycheck = this.vertify('transfer', '4')
      }
      if (vertifycheck) {
        this.auditId = this.choiceStatus.map(item => item.id)
        const checkText = `<p>审核通过, 系统将自动转账至员工的微信零钱中</p><p>是否确定审核?</p>`
        const transferText = `<p>手动发起转账,系统将重新发起转账至员工的微信零钱中</p><p>是否确定发起?</p>`
        this.textTooltip = type == 'check' ? checkText : transferText
        this.$refs.dialogRef.dialogVisible = true
      }
    }
  }
}
</script>
<style scoped>
.addList {
  width: 112px;
  background: #1994f9;
  border-radius: 2px;
  margin-bottom: 16px;
}

.el-icon-plus {
  padding-right: 5px;
}

.my-row-height >>> .el-table__body-wrapper .el-table__row {
  height: 48px;
}

.btnOptons {
  margin-bottom: 10px;
}

.account {
  display: flex;
}

.account > p {
  margin-right: 10px;
}

</style>