<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="蜜瓜号" prop="usercode">
        <el-input
          v-model="queryParams.usercode"
          placeholder="请输入蜜瓜号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="账户名称" prop="cardName">
        <el-input
          v-model="queryParams.cardName"
          placeholder="请输入账户名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="账户" prop="cardAccount">
        <el-input
          v-model="queryParams.cardAccount"
          placeholder="请输入账户"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="审核状态" clearable size="small">
          <el-option
              v-for="dict in cashStatusList"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
              @keyup.enter.native="handleQuery"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['cai:accountCash:edit']"
        >批量审核</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['cai:accountCash:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="accountCashList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="订单号" align="center" prop="orderNo" />
      <el-table-column label="蜜瓜号" align="center" prop="usercode" />
      <el-table-column label="提现紫贝" align="center" prop="withdrawCoin" />
      <el-table-column label="提现金额" align="center" prop="cashMoney" />
      <el-table-column label="银行名称" align="center" prop="bank" />
      <el-table-column label="账户名称" align="center" prop="cardName" />
      <el-table-column label="账户" align="center" prop="cardAccount" />
      <el-table-column label="状态" align="center" prop="status" >
        <template v-slot="scope">
          <cai-dict-tag :options="cashStatusList" :value="scope.row.status" />
        </template>
      </el-table-column>
      <el-table-column label="申请时间" align="center" prop="createTime" />
      <el-table-column label="审核人IP" align="center" prop="operateIp" />
      <el-table-column label="审核时间" align="center" prop="verifyTime" />
      <el-table-column label="审核备注" align="center" prop="verifyRemark" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right">
        <template v-slot="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['cai:accountCash:edit']"
          >审核</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listAccountCash } from '@/api/cai/accountCash'
import { cashStatusList } from '@/constant/statusMap'

export default {
  name: "AccountCash",
  data() {
    return {
      cashStatusList,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 用户提现记录表格数据
      accountCashList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        usercode: undefined,
        orderNo: undefined,
        cardName: undefined,
        cardAccount: undefined,
        status: 1,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询用户提现记录列表 */
    getList() {
      this.loading = true;
      listAccountCash(this.queryParams).then(response => {
        this.accountCashList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('cai/accountCash/export', {
        ...this.queryParams
      }, `提现记录_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
