
<template>
  <div style="margin-top:10px;padding: 10px;" v-if="list.length > 0" >
    <el-table :data="list" :stripe="true" :show-overflow-tooltip="true">
      <el-table-column label="获得" align="center" prop="amount" >
        <template #default="scope">
          {{ pointsToPoint(scope.row.amount || 0) }}
        </template>
      </el-table-column>
      
      <el-table-column label="可用" align="center" prop="afterAmount">
        <template #default="scope">
          {{ pointsToPoint(scope.row.afterAmount || 0) }}
        </template>
      </el-table-column>

      <el-table-column label="待确权" align="center" prop="freezeAmount">
        <template #default="scope">
          {{ pointsToPoint(scope.row.freezeAmount || 0) }}
        </template>
      </el-table-column>
      <el-table-column label="冻结余额" align="center" prop="afterFreezeAmount">
        <template #default="scope">
          {{ pointsToPoint(scope.row.afterFreezeAmount || 0) }}
        </template>
      </el-table-column>
      <el-table-column label="最大可用佣金额度变化值" align="center" prop="maxAvailablePointsAmount">
        <template #default="scope">
          {{ pointsToPoint(scope.row.maxAvailablePointsAmount || 0) }}
        </template>
      </el-table-column>
      <el-table-column label="最大可用佣金额度" align="center" prop="afterMaxAvailablePointsAmount">
        <template #default="scope">
          {{ pointsToPoint(scope.row.afterMaxAvailablePointsAmount || 0) }}
        </template>
      </el-table-column>
      <el-table-column label="合赢奖超出值" align="center" prop="accumulatedQuotaAmount">
        <template #default="scope">
          {{ pointsToPoint(scope.row.accumulatedQuotaAmount || 0) }}
        </template>
      </el-table-column>
      <el-table-column label="直推奖超出值" align="center" prop="ancestorQuotaAmount">
        <template #default="scope">
          {{ pointsToPoint(scope.row.ancestorQuotaAmount || 0) }}
        </template>
      </el-table-column>
      <el-table-column label="类别" align="center" prop="profitStatusName" width="180">
        <template #default="scope">
         {{ scope.row.profitStatusName  }} {{ scope.row.username ? '(' + scope.row.username + ')' : '' }}
        </template>
      </el-table-column>
      <el-table-column label="时间" align="center" prop="createTime" width="180">
        <template #default="scope">
          {{ formatDate(scope.row.createTime,"YYYY-MM-DD HH:mm") }}
        </template>
      </el-table-column>
      <!-- <el-table-column label="来源" align="center" prop="" /> -->
      
    </el-table>
    <!-- 分页 -->
    <Pagination
:total="total" v-model:page="queryParams.pageNo" v-model:limit="queryParams.pageSize"
      @pagination="getUserInfo" />
  </div>
  <div style="text-align: center;margin-top: 50px;font-size: 14px;" v-else>
    暂无佣金记录
  </div>
</template>

<script setup>
  import { formatDate } from '@/utils/formatTime'
  import { pointsToPoint } from '@/utils'
  import * as UserApi from '@/api/member/user'


  // 列表的总页数
  const total = ref(0)
  const props = defineProps({
    userId: {
      type: Number,
      default: 0
    },
  });
  const list = ref([])
  const queryParams = reactive({
    pageNo: 1,
    pageSize: 10,
    userId:undefined
  })
  const getUserInfo = async () => {
    const res = await UserApi.getUserPoints(queryParams);
    list.value = res.list
    total.value = res.total
  };
  onMounted(() => {
    // props.userId
    queryParams.userId = props.userId;
    getUserInfo();
  });

  

</script>