<!--自定义table-->
<template>
  <div class="custom-table">
    <div class="check-data-info">
      <div class="table-info">
        <div class="table-header">
          <span class="table-header-item" v-for="(item,index) of tableTitle"
                :style="`width:${item.width};`">
            {{ item.title }}
          </span>
        </div>
        <div class="table-body" v-if="dataSource.length && tableRoll">
          <vue-seamless-scroll
            v-if="dataSource.length && tableRoll"
            ref="vueSeamless"
            :data="dataSource"
            class="seamless-scroll"
            :class-option="defaultOption"
          >
            <div class="table-item-body" v-for="item of dataSource">
            <span class="data-content" v-for="dataIndex of tableTitle" :style="`width:${dataIndex.width};`">
              <div class="_content">
                <div class="point-name">
                  <div class="_value">{{ item[dataIndex.dataIndex] }}</div>
                  <div class="_unit" v-if="dataIndex.dataUnit">{{ item[dataIndex.dataUnit] }}</div>
                </div>
              </div>

            </span>
            </div>
          </vue-seamless-scroll>
        </div>
        <div class="table-body" v-if="dataSource.length && !tableRoll">
          <div class="table-item-body" v-for="item of dataSource">
            <span class="data-content" v-for="dataIndex of tableTitle" :style="`width:${dataIndex.width};`">
              <div class="_content">
                <div class="point-name">
                  <div class="_value">{{ item[dataIndex.dataIndex] }}</div>
                  <div class="_unit" v-if="dataIndex.dataUnit">{{ item[dataIndex.dataUnit] }}</div>
                </div>
              </div>

            </span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import vueSeamlessScroll from 'vue-seamless-scroll'
export default {
  name: "PeakCustomTable",
  components: {vueSeamlessScroll},
  props: {
    tableTitle: {
      type: Array,
      default: () => []
    },
    dataSource: {
      type: Array,
      default: () => []
    },
    tableRoll: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {}
  },
  computed: {
    defaultOption() {
      return {
        step: 0.3, // 数值越大速度滚动越快
        limitMoveNum: 9, // 开始无缝滚动的数据量 this.dataList.length
        hoverStop: true, // 是否开启鼠标悬停stop
        direction: 1, // 0向下 1向上 2向左 3向右
        openWatch: true, // 开启数据实时监控刷新dom
        singleHeight: 0, // 单步运动停止的高度(默认值0是无缝不停止的滚动) direction => 0/1
        singleWidth: 0, // 单步运动停止的宽度(默认值0是无缝不停止的滚动) direction => 2/3
        waitTime: 1000 // 单步运动停止的时间(默认值1000ms)
      }
    },
  },
  methods: {}
}
</script>

<style scoped lang="less">
@import "assets/styles/mixin";

.custom-table {
  height: 100%;
  width: 100%;
  overflow: auto;

  .check-data-info {
    height: 100%;
    width: 100%;

    .table-info {
      width: 100%;
      height: 100%;
      overflow: auto;

      .table-header {
        position: sticky;
        top: 0;
        height: 30px;
        white-space: nowrap;
        background-color: #063367;

        .table-header-item {
          background-color: rgba(35, 140, 255, 0.2);
          display: inline-block;
          font-family: MicrosoftYaHei-Bold;
          font-size: 14px;
          color: #37EAFF;
          letter-spacing: 0;
          text-align: center;
          line-height: 30px;
          font-weight: 700;
        }
      }

      .table-body {
        height: calc(100% - 30px);

        .seamless-scroll {
          height: 100%;
          overflow: hidden;
        }

        .table-item-body {
          height: 30px;
          margin-top: 10px;
          width: 100%;
          white-space: nowrap;

          .data-content {
            display: inline-block;
            height: 30px;
            background: rgba(21, 77, 160, 0.20);

            ._content {
              height: 100%;
              width: 100%;
              .flex-row;
              justify-content: center;
            }

            .point-name {
              .text-ellipsis;
              .flex-row;

              ._value {
                font-family: MicrosoftYaHei-Bold;
                font-size: 14px;
                color: #FFFFFF;
                letter-spacing: 0;
                font-weight: 700;
              }

              ._unit {
                font-family: MicrosoftYaHei-Bold;
                font-size: 12px;
                color: #FFFFFF;
                letter-spacing: 0;
                font-weight: 700;
              }
            }

            ._icon {
            }
          }

          .odds-ratio-up-icon {
            width: 23px;
            height: 25px;
            background: url("assets/peakCoalImages/left/odds-ratio-up-icon.png") no-repeat;
            padding-left: 20px;
          }

          .odds-ratio-reduction-icon {
            width: 22px;
            height: 26px;
            background: url("assets/peakCoalImages/left/odds-ratio-reduction-icon.png") no-repeat;
            padding-left: 20px;
          }


          .data-value {
            .flex-row;
            justify-content: center;

            ._value {
              font-family: MicrosoftYaHei-Bold;
              font-size: 14px;
              color: #FFFFFF;
              letter-spacing: 0;
              text-align: center;
              font-weight: 700;
            }
          }
        }
      }
    }
  }

}

::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-thumb {
  border-radius: 5px;
  -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  background-color: rgba(21, 77, 160, 0.20);;
}

::-webkit-scrollbar-track {
  -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  border-radius: 5px;
  background-color: #d3dce6;
}
</style>
