<template>
  <div class="cmain">
    <el-form :model="queryParams" ref="queryForm" :inline="true" @submit.native.prevent v-show="showSearch">
      <el-form-item label="提现编号" prop="nums">
        <el-input v-model="queryParams.nums" placeholder="请输入提现编号" @keyup.enter.native="handleQuery" clearable />
      </el-form-item>
      <el-form-item label="提现状态" prop="state">
        <el-select v-model="queryParams.state" placeholder="提现状态" clearable style="width: 117px">
          <el-option value="0" label="待提现"></el-option>
          <el-option value="1" label="提现成功"></el-option>
          <el-option value="2" label="提现失败"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="时间范围">
        <el-date-picker v-model="dateRange" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :clearable="false"></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
      <el-button type="primary" icon="el-icon-download" @click="handleExport" v-hasPermi="['work:out:export']" style="float: right">导出</el-button>
    </el-form>
    <el-table :data="response.rows" border>
      <el-table-column type="index" label="序号" align="center" width="80" />
      <el-table-column label="提现编号" align="center" prop="nums" />
      <el-table-column label="提现金额（元）" align="center" prop="money" />
      <el-table-column label="提现状态" align="center" width="130">
        <template slot-scope="scope">
          <el-tag type="danger" v-if="scope.row.state == 0">待提现</el-tag>
          <el-tag type="success" v-if="scope.row.state == 1" :title="'提现时间：' + scope.row.updateTime">提现成功</el-tag>
          <el-popover placement="top-start" v-if="scope.row.state == 2" title="原因" width="200" trigger="hover" :content="scope.row.msg">
            <div slot="reference" :title="'操作时间：' + scope.row.updateTime">
              <el-tag type="info">提现失败</el-tag>
              <i class="el-icon-warning"></i>
            </div>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column label="申请人" align="center" prop="opBy" width="130" />
      <el-table-column label="申请日期" align="center" prop="createTime" />
      <template slot="empty">
        <el-empty></el-empty>
      </template>
    </el-table>
    <pagination v-if="response.total > 0" :total="response.total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
  </div>
</template>

<script>
export default {
  name: 'Out',
  data() {
    return {
      ids: [],
      showSearch: true,
      response: {},
      dateRange: [],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        companyName: null,
        state: null,
        nums: null,
        orderByColumn: 'r.id',
        isAsc: 'desc'
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      if (this.dateRange) {
        this.queryParams.dateBegin = this.dateRange[0];
        this.queryParams.dateEnd = this.dateRange[1];
      }
      this.ajax({ url: '/work/out/list', data: this.queryParams }).then((response) => {
        this.response = response;
      });
    },
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    resetQuery() {
      this.resetForm('queryForm');
      this.dateRange = [];
      this.handleQuery();
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('/work/out/export', { ...this.queryParams }, '提现明细.xlsx');
    }
  }
};
</script>
