<template>
  <div class="winner_list" ref="winnerList">
    <table>
      <tbody>
      <tr v-for="(row, idx) in $props.rows" :key="idx" :style="{height: 100 / rows.length + '%'}">
          <td v-if="showIcon"><div class="col_number">{{ idx + 1 }}</div></td>
          <td class="winner_span" :style="titleIndependentStyle?row.titleStyle:columnsStyle['title']">{{ row.title }}</td>
          <td v-for="(col, idz) in row.column" :key="idz" :style="columnsStyle[col.key]">
            <p class="key_span">{{ col.key }}</p>
            <p class="value_span" :style="col.valStyle">{{colFormatter[''+idz]?colFormatter[''+idz](col.value):col.value }}</p>
          </td>
      </tr>
      </tbody>
    </table>
  </div>
</template>
<script>

export default {
  name: "WinnersList",
  props: {
    showIcon: {
      type: Boolean,
      default: true
    },
    titleIndependentStyle:{
      type: Boolean,
      default: false
    },
    columnsStyle:{
      type: Object,
      default: function () {
        return {};
      }
    },
    rows: {
      type: Array,
      default:function(){
        return [
          {title: '标题列',titleStyle:{},blankColumn:false, column: [{key: '字段', value: '0'}]},
          {title: '标题列',titleStyle:{},blankColumn:false, column: [{key: '字段', value: '0'}]},
          {title: '标题列',titleStyle:{},blankColumn:false, column: [{key: '字段', value: '0'}]}
        ];
      }
    },
    colFormatter:{
      type: Object,
      default: function(){
        return {};
      }
    },
    mouseHand: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {};
  },
  mounted() {
    this.$refs.winnerList.style.cursor = this.$props.mouseHand ? "pointer" : "default"
  },
  methods: {}
};
</script>
<style scoped>

.winner_list {

}

.winner_list::-webkit-scrollbar { width: 0 !important }

table {
  height: 100%;
  font-size: 12px;
  color: white;
}

tr:nth-child(odd) {
  background-color: #0E5FFF20;
}

tr:nth-child(even) {
  background-color: #0E5FFF30;
}

td {
  padding: 0 0 0 1rem;
}

.col_number {
  height: 38px;
  min-width: 38px;
  color: #19EBFF;
  font-weight: bold;
  text-align: center;
  line-height: 38px;
  background: url(../../assets/img/number_bg.png) no-repeat center;
}

.winner_span {
  color: white;
  font-size: 14px;
  display: table-cell;
}

.key_span {
}

.value_span {
  color: lightblue;
  font-weight: bold;
}
</style>
