<template>
  <div class="c-consensusNodeTable">
    <el-table
      :data="list"
      style="width: 100%;"
      class="data-table"
      v-loading="loading"
      :cell-style="cellStyle"
      element-loading-text="loading..."
      element-loading-spinner="el-icon-loading"
    >
      <template slot="empty">
        <div>
          <!-- <div class="loading-line"></div> -->
          <span v-if="!loading && list.length === 0">
            {{ $t('lang.page.nodata') }}
          </span>
        </div>
      </template>
      <el-table-column width="40"></el-table-column>
      <el-table-column :label="$t('lang.txDetail.height')">
        <template slot-scope="item">
          <div
            class="text-footer-color"
            :class="{
              ' text-orange2': item.row.type === '',
            }"
          >
            <router-link
              :to="{
                path: '/blockDetail',
                query: {
                  height: item.row.height,
                },
              }"
            >
              {{ item.row.height }}
            </router-link>
          </div>
        </template>
      </el-table-column>
      <el-table-column :label="$t('lang.block.consensusAddress')">
        <template slot-scope="item">
          <div
            class="text-footer-color"
            :class="{
              ' text-orange2': item.row.type === '',
            }"
          >
            <router-link
              :to="{
                path: '/address',
                query: {
                  address: item.row.address,
                },
              }"
            >
              {{ item.row.address | filterHash(10) }}
            </router-link>
          </div>
        </template>
      </el-table-column>
      <el-table-column :label="$t('lang.block.blockReward')">
        <template slot-scope="{ row }">
          <div class="text-darkBlue">{{ row.reward | filterAmount }} YCC</div>
        </template>
      </el-table-column>
      <el-table-column :label="$t('lang.txDetail.time')">
        <template slot-scope="{ row }">
          <div class="text-darkBlue">
            {{ row.time | formatTime }}
          </div>
        </template>
      </el-table-column>
      <el-table-column :label="$t('lang.trade.type')" align="right" width="90">
        <template slot-scope="{ row }">
          <div class="text-darkBlue">
            {{ row.type === 'vote' ? '投票节点' : '打包节点' }}
          </div>
        </template>
      </el-table-column>
      <el-table-column width="40"></el-table-column>
    </el-table>
  </div>
</template>
<script lang="ts">
import Vue from 'vue'
import { Table, TableColumn } from 'element-ui'
export default Vue.extend({
  components: {
    'el-table': Table,
    'el-table-column': TableColumn,
  },
  props: {
    loading: Boolean,
    list: Array,
  },
  methods: {
    cellStyle({ row }: any) {
      return {
        backgroundColor: row.type === 'pack' ? 'rgba(255, 164, 87, 0.06)' : '',
      }
    },
  },
})
</script>
