<template>
  <div>
    <el-table v-loading="shujuloading" :data="tableData" :max-height="maxHeight" ref="shujuscroll_Table" stripe
      @mouseenter.native="shujuautoScroll(true)" @mouseleave.native="shujuautoScroll(false)"  class="Tabtab">
      <el-table-column v-for="(column, index) in columns" :key="index" :prop="column.prop"
        :label="column.label"></el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  props: {
    tableData: {
      type: Array,
      default: () => []
    },
    shujuloading: {
      type: Boolean,
      default: false
    },
    tableTitle: {
      type: String,
      default: ''
    },
    columns: {
      type: Array,
      default: () => []
    },
    maxHeight: {
      type: Number,
      default: 150
    }
  },
  mounted() {
    this.shujuautoScroll()
  },
  beforeDestroy() {
    this.shujuautoScroll(true)
  },
  methods: {

    shujuautoScroll(stop) {
      const table = this.$refs.shujuscroll_Table
      const divData = table.$refs.bodyWrapper
      if (stop) {
        window.clearInterval(this.scrolltimer)
      } else {
        this.scrolltimer = window.setInterval(() => {
          divData.scrollTop += 1
          if (divData.clientHeight + divData.scrollTop == divData.scrollHeight) {
            divData.scrollTop = 0
          }
        }, 150)
      }
    },

    tableRowClassName ({ row, rowIndex }) {
      if (rowIndex % 2 === 1) {
        return 'warning-row'
      } else {
        return 'success-row'
      }
    },
  }
};
</script>

<style lang="scss" scoped>
.Tabtab {
  font-size: 12px;
}


::v-deep.el-table .el-table__cell {
  padding: 2px 0 !important;
}



/* 去掉最下面的那一条线 */
.el-table::before {
  height: 0px;
}

/* 滚动条样式 */
::v-deep .el-table__body-wrapper::-webkit-scrollbar-track {
  background-color: #004F5F;
}

::v-deep .el-table__body-wrapper::-webkit-scrollbar {
  width: 15px;
  opacity: 0.5;
}

::v-deep .el-table__body-wrapper::-webkit-scrollbar-thumb {
  border-radius: 15px;
  background-color: rgba(0, 79, 95, 0.75);
}


</style>
