<template>
  <div class="app-container">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <p style="font-size: 18px">结算流水</p>
      </div>
      <el-table v-loading="loading" :height="tableHeight" :data="assetList">
        <el-table-column label="ID" align="center" prop="Id"/>
        <el-table-column label="流水订单号" align="center" prop="BalanceSn"/>
        <el-table-column label="变动金额" align="center" prop="ChangeMoney"/>
        <el-table-column label="变动类型" align="center" :formatter="formatType" prop="ChangeType"/>
        <el-table-column label="时间" align="center" :formatter="formatTime" prop="AddTime"/>
        <el-table-column label="描述" align="center" prop="Des"/>
      </el-table>
      <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
                  @pagination="getList"/>
    </el-card>
  </div>
</template>
<script>
  import {
    listAsset,
    getAsset,
    delAsset,
    addAsset,
    updateAsset
  } from '@/api/module/asset'
  import {
    dateFormat
  } from '@/utils'
  export default {
    name: "asset",
    data() {
      return {
        fullHeight: 0,
        tableHeight: 0,
        loading: false, // 遮罩层
        ids: [], // 选中数组
        total: 0, // 总条数
        assetList: [], // 商户余额变动日志表格数据
        title: "", // 弹出层标题
        open: false, // 是否显示弹出层
        queryParams: { // 查询参数
          pageNum: 1,
          pageSize: 10,
          sellerId: 0
        },
        form: {}, // 表单参数
        rules: {} // 表单校验
      };
    },
    created() {
      this.queryParams.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.ChangeType
        var optDes = ''
        if (types == 1) {
          optDes = "增加"
        } else if (types == 2) {
          optDes = "减少"
        }
        return optDes
      },
      //格式化时间
      formatTime(row) {
        let Time = row.AddTime;
        let newtime = "";
        if (Time > 0) {
          newtime = dateFormat(Time * 1000, "Y-m-d H:i:s");
        }
        return newtime
      },
      //格式化价格
      formatMoney(row) {
        var nm = 0;
        var money = row.ChangeMoney;
        if (money > 0) {
          nm = money / 1000
        }
        return nm
      },
      /** 查询商户余额变动日志列表 */
      getList() {
        listAsset(this.queryParams).then(res => {
          this.assetList = res.data.list;
          this.total = res.data.total;
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
    } //methods结束
  };
</script>
<style scoped>

</style>
