<template>
  <div class="app-container">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <p style="font-size: 18px; float:left;">提现记录</p>
      </div>
      <el-table v-loading="loading" :data="withdrawlogList" :height="tableHeight">
        <el-table-column label="提现流水单号" align="center" prop="ReflectSn"/>
        <el-table-column label="提现账号" align="center" prop="BankName">
          <template slot-scope="scope">
            <div>
              {{ scope.row.BankAccountNo }}
            </div>
          </template>
        </el-table-column>
        <el-table-column label="提现金额" :formatter="formatFee" align="center" prop="ReflectMoney"/>
        <el-table-column label="提现状态" align="center" :formatter="formatType" prop="Status"/>
        <el-table-column label="提现审核说明" align="center" prop="Des"/>
        <el-table-column label="提现时间" :formatter="formatTime" align="center" prop="AddTime"/>
        <el-table-column label="手续费" :formatter="formatFee" align="center" prop="Fee"/>
        <el-table-column label="实际到账金额" :formatter="formatFee" align="center" prop="AfterReflectMoney"/>
      </el-table>
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.page"
        :limit.sync="queryParams.limit"
        @pagination="getList"
      />
    </el-card>
  </div>
</template>
<script>
  import {
    listWithdrawlog,
    getWithdrawlog,
    delWithdrawlog,
    addWithdrawlog,
    updateWithdrawlog
  } from '@/api/module/withdrawlog'
  import {dateFormat} from '@/utils'

  export default {
    name: "withdrawlog",
    data() {
      return {
        sellerId: 0,
        fullHeight: 0,
        tableHeight: 0,
        // 遮罩层
        loading: false,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 商户提现表格数据
        withdrawlogList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          page: 1,
          limit: 10,
          sellerId: 0,
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {
          status: [
            {required: true, message: "提现状态 0申请提现 1提现成功 2提现失败不能为空", trigger: "blur"}
          ],
        }
      };
    },
    created() {
      this.sellerId = this.$store.state.user.sellerid;
      this.getList();
      this.$nextTick(() => {
        this.fullHeight = document.getElementsByClassName('box-card')[0].clientHeight
      })
    },
    watch: {
      fullHeight(val) {
        let formHeight = document.getElementsByClassName('clearfix')[0].clientHeight
        this.tableHeight = val - formHeight - 120;
      }
    },
    methods: {
      //格式化状态
      formatType(row) {
        var types = row.Status
        var optDes = ''
        if (types == 1) {
          optDes = "提现成功"
        } else if (types == 2) {
          optDes = "提现失败"
        } else if (types == 0) {
          optDes = "提现申请中"
        }
        return optDes
      },
      //格式化价格
      formatFee(row, s, value, i) {
        var nm = 0
        var money = value
        if (money > 0) {
          nm = money / 100
        }
        return nm
      },
      //格式化时间
      formatTime(row) {
        var Time = row.AddTime
        var newtime = ""
        if (Time > 0) {
          newtime = dateFormat(Time * 1000, "Y-m-d H:i:s");
        }
        return newtime
      },
      /** 查询商户提现列表 */
      getList() {
        this.queryParams.sellerId = this.sellerId;
        listWithdrawlog(this.queryParams).then(response => {
          if (response) {
            this.withdrawlogList = response.data.data;
            this.total = response.data.count;
          } else {
            this.$message({message: '数据出错啦！', type: 'error'});
          }
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          id: null,
          reflect_sn: null,
          reflect_money: null,
          status: 0,
          des: null,
          seller_bank_id: null,
          add_time: null,
          fee: null,
          seller_id: null,
          after_reflect_money: null
        };
        this.resetForm("form");
      },

    } //methods结束
  };
</script>
<style scoped lang="scss" type="text/stylus">

</style>
