index.vue 9.44 KB
<!-- 提现管理 - 列表 -->
<template>
  <div>
    <!-- class="order-detail" -->
    <d2-container>
      <!-- <div class="offline-account"> -->
      <div class="header"
           slot="header"
           style="padding: 10px 20px;">
        <d2-search ref="showSearch"
                   class="show-search"
                   :search-form="searchForm"
                   :label-width="labelWidth"
                   :form-data="showFormData" />
        <div class="up-btns">
          <el-button @click="handleSearch"
                     size="small"
                     type="primary">
            查询
          </el-button>
          <el-button size="small"
                     @click="handleReset">
            重置
          </el-button>
        </div>
      </div>
      <!-- </d2-container>
          <d2-container> -->
      <div class="d2-container-content">
        <d2-table-header>
          <auth-button category="Button" />
        </d2-table-header>
        <d2-table ref="recordTable"
                  :get-list-api="getListApi"
                  :search-form="searchFormSearch"
                  :table-params="tableParams"
                  :before-search-fn="beforeSearchFn">
          <div slot="auth-button"
               slot-scope="scope">
            <!-- 重新发起提现 -->
            <span style="margin-right: 10px;"
                  v-if="scope.scope.status == 8">
              <auth-button :data="scope.scope"
                           :show-btn-ids="['9050603']" />
            </span>
          </div>
        </d2-table>
      </div>
    </d2-container>
    <!-- 新增提现 -->
    <add-dialog :add-visible="addVisible"
                v-if="addVisible"
                @dialogClose="addDialogClose" />
  </div>
</template>

<script>
import { Util, deepClone } from '@/common/util'
import { mapActions, mapState } from 'vuex'
import { withdrawalManageStatusList } from '@/common/constants.js'
import { withdrawOrderRecordPage, rewithdraw } from '@api/withdrawalManage'
import addDialog from './components/addDialog'
export default {
  name: 'TransferAccountsList',
  components: {
    addDialog
  },
  data() {
    return {
      userInfo: this.$store.state.d2admin.user.info,
      labelWidth: '100px',
      searchForm: {
        withdrawTradeNo: '',
        merchantName: '',
        merchantIdFuzzy: '',
        // merchantIds: [],
        status: '',
        statuses: [],
        withdrawalDate: ''
      },
      searchFormSearch: {},
      showFormData: [{
        label: '提现流水号',
        name: 'withdrawTradeNo',
        type: 'input',
        maxlength: '20',
        isClear: true
      }, {
        label: '提现商户',
        name: 'merchantName',
        type: 'input',
        maxlength: '50',
        isClear: true
      }, {
        label: '商户号',
        name: 'merchantIdFuzzy',
        type: 'input',
        inputType: 'number',
        maxlength: '20',
        isClear: true
      }, {
        label: '状态',
        name: 'status',
        type: 'select',
        optionList: [],
        optionId: 'confId',
        optionLabel: 'confValue',
        optionsName: 'statusList'
      }, {
        label: '提现时间',
        name: 'withdrawalDate',
        type: 'datePicker',
        isClear: true,
        pickerOptions: 'rangePickerOptions'
      }],
      getListApi: withdrawOrderRecordPage,
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        // tableOption: { width: '200px' },
        tableOption: true,
        tableColumns: [{
          label: '提现流水号',
          prop: 'withdrawTradeNo',
          width: '200px'
        }, {
          label: '提现商户',
          prop: 'merchantName',
          width: '160px'
        }, {
          label: '商户号',
          prop: 'merchantId',
          width: '160px'
        }, {
          label: '提现金额/元',
          prop: 'totalAmount',
          formatter: (cellValue) => {
            return cellValue.totalAmount ? cellValue.totalAmount : '--'
          }
        }, {
          label: '提现时间',
          prop: 'withdrawTime',
          width: '150px',
          formatter: (cellValue) => {
            return cellValue.withdrawTime ? Util.dateFormate(cellValue.withdrawTime, 'YYYY-MM-DD HH:mm:ss') : '--'
          }
        },
        {
          label: '状态',
          prop: 'status',
          width: '100px',
          formatter: (cellValue) => {
            return this.baseData.statusList.find(item => item.confId === cellValue.status)?.confValue
          },
          className: (cellValue) => {
            return {
              5: 'blueSpot',
              6: 'greenSpot',
              8: 'redSpot'
            }[cellValue.status]
          }
        },
        {
          label: '创建人',
          prop: 'createdBy'
        },
        {
          label: '备注',
          prop: 'remark',
          width: '160px',
          showOverFlow: true,
          formatter: (cellValue) => {
            return cellValue.remark ? cellValue.remark : '--'
          }
        }
        ]
      },
      baseData: {
        statusList: deepClone(withdrawalManageStatusList)
      },

      infos: [],
      recordInfo: null,
      addVisible: false
    }
  },
  computed: {
    ...mapState({
      dowloadList: (state) => state.d2admin.user.dowloadList
    })
  },
  mounted() {
    this.getBaseData()
  },

  methods: {
    ...mapActions({
      get: 'd2admin/base/get',
      close: 'd2admin/page/close'
    }),
    ...mapActions('d2admin/user', ['actionSetDownloadList']),

    async getBaseData() {
      this.getOptionsList()
    },

    beforeSearchFn() {
      return new Promise(resolve => {
        this.searchFormSearch = deepClone(this.searchForm)
        if (this.searchFormSearch.withdrawalDate) {
          this.searchFormSearch.withdrawStartTimeStr = Util.dateFormate(this.searchFormSearch.withdrawalDate[0], 'YYYY-MM-DD HH:mm:ss')
          this.searchFormSearch.withdrawEndTimeStr = Util.dateFormate(this.searchFormSearch.withdrawalDate[1], 'YYYY-MM-DD') + ' 23:59:59'
          delete this.searchFormSearch.withdrawalDate
        }
        // if (this.searchFormSearch.merchantId) {
        //   this.searchFormSearch.merchantIds[0] = this.searchFormSearch.merchantId
        //   delete this.searchFormSearch.merchantId
        // }
        if (this.searchFormSearch.status) {
          this.searchFormSearch.statuses[0] = this.searchFormSearch.status
          delete this.searchFormSearch.status
        }
        resolve()
      })
    },

    getOptionsList() {
      this.showFormData.forEach((item, index) => {
        if (item.type === 'select') {
          console.log('this.baseData[item.optionsName]', item.optionsName)
          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])
        }
      })
    },

    handleSearch() {
      this.$refs.recordTable.refreshTable(false, true)
    },
    handleReset() {
      this.searchForm = {
        withdrawTradeNo: '',
        merchantName: '',
        merchantIdFuzzy: '',
        // merchantIds: [],
        status: '',
        statuses: [],
        withdrawalDate: ''
      }
      this.$refs.recordTable.refreshTable(false, true)
    },

    handleAdd() {
      this.addVisible = !this.addVisible
    },

    addDialogClose(obj) {
      this[obj.attrName] = !this[obj.attrName]
      if (obj.flag) {
        this.$refs.recordTable.refreshTable()
      }
    },

    handleExport() {
      var params = this.searchFormSearch
      if (params.statuses.length > 0) {
        const statuses = `statuses[0]`
        params[statuses] = params.statuses[0]
        delete params.statuses
      }
      // if (params.merchantIds.length > 0) {
      //   const merchantIds = `merchantIds[0]`
      //   params[merchantIds] = params.merchantIds[0]
      //   delete params.merchantIds
      // }
      // 去除为null的值
      for (const key in params) {
        if (params[key] === null || params[key] === '' || params[key].length == 0) {
          delete params[key]
        }
      }
      params.method = 'dj.api.smartcarlife.withdrawOrderRecord.exportAsync'
      const list = [
        ...this.dowloadList,
        {
          name: '提现记录',
          exportParam: JSON.stringify(params),
          status: 'waiting',
          timeid: new Date().getTime()
        }
      ]
      this.actionSetDownloadList({ list, type: 'dowloadList' })
    },

    // 重新发起提现
    handleReWithdrawal(row) {
      this.$confirm('重新发起提现,系统自动向银盛平台重新发起提现请求,是否确定发起?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        closeOnClickModal: false
      }).then(() => {
        rewithdraw({ orderCode: row.orderCode }).then(res => {
          this.notice.okTips()
          this.$refs.recordTable.refreshTable()
        })
      }).catch(err => {
        console.log(err)
      })
    }

  }
}

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

.leftSpan {
  display: inline-block;
  box-sizing: border-box;
  margin-right: 10px;
}
</style>