<template>
  <el-table
    class="tableList"
    ref="rw_table"
    height="700"
    solt="append"
    :data="useData"
    :row-class-name="tableRowClassName"
    @cell-mouse-enter="mouseEnter"
    @cell-mouse-leave="mouseLeave"
  >
    <el-table-column
      prop="username"
      label="姓名"
    />
    </el-table-column>
    <el-table-column
      label="备注"
    >
      <template slot-scope="scope">
        <span>{{ getNote(scope.row) }}</span>
      </template>
    </el-table-column>
  </el-table>
</template>
<script>
export default {
  name: 'TableObj',
  props:{
    tableData:{
      type: Array,
      default:()=>{
        return []
      }
    }
  },
  data () {
    return {
      useData:[],
      autoPlay:false,
      timer:undefined
    }
  },
  watch:{
    tableData:{
      deep:true,
      handler(v){
        if(v&&v.length){
          this.startRolling = false
          let data = []
          for(let i in v){
            data.push(v[i])
          }
          this.useData = data
          this.autoPlay = true
          this.startMove()
        }
      }
    }
  },
  methods: {
    // 鼠标进入
    mouseEnter() {
      this.autoPlay = false
    },
    // 鼠标离开
    mouseLeave() {
      this.autoPlay = true
    },
    startMove(){
      // 拿到表格挂载后的真实DOM
      const table = this.$refs.rw_table
      if(table){
        // 拿到表格中承载数据的div元素
        const divData = table.bodyWrapper
        if(divData){
          if(this.timer){
            clearInterval(this.timer)
          }
          // 拿到元素后,对元素进行定时增加距离顶部距离,实现滚动效果(此配置为每100毫秒移动1像素)
          this.timer = setInterval(() => {
            if(this.autoPlay){
              // 元素自增距离顶部1像素
              if(divData.scrollTop>=48){
                const item = this.useData.shift();
                this.useData.push(item)
                divData.scrollTop-=48
              }
              divData.scrollTop += 1
            }
          }, 50)
        }
      }
    },
    getStatus(row){
      let status = ''
      if(row.workType){
        switch(row.workType){
          case 1:
            status = `在岗`;
            if(row.workplace){
              status +=`(${row.workplace})`
            }
            break;
      }
      return status;
    },
    getNote(row){
      let not = ''
      if(row.workType!==1&&row.handoverName){
        not = `工作交接${row.handoverName}`
        if(row.handoverPos){
          not += ` (${row.handoverPos})`
        }
      }
      return not
    },
    tableRowClassName({row}) {
      let className = ''
      if(row.workType){
        switch(row.workType){
          case 1:
            className = 'onJob';
            break;
        }
      }
      return className;
    }
  }
}
</script>

最新文章

  1. Ubuntu虚拟机中断后重启网络断接错误解决方案
  2. SharePoint 2013 定制搜索显示模板
  3. include使用中注意的问题
  4. Oracle XE http端口8080的修改
  5. win10如何将此电脑显示在桌面
  6. Backbone模型
  7. 展讯DTS路径及编译
  8. Python中的闭包
  9. [iOS]如何删除工程里面用cocoapods导入的第三方库
  10. 网络请求 post 的接受请求头的代理方法
  11. 2012Android开发热门资料(110个)
  12. bootstrap 切换页签失效的解决方法
  13. RxVolley使用文档 —— RxVolley = Volley + RxJava + OkHttp
  14. 手机端rem 用法
  15. es基本修改相关的
  16. rabbitmq 二进制安装
  17. Catch---hdu3478(染色法判断是否含有奇环)
  18. javascript数据结构——队列
  19. 【LeetCode算法题库】Day2:Median of Two Sorted Arrays &amp; Longest Palindromic Substring &amp; ZigZag Conversion
  20. Ultra-QuickSort---poj2299 (归并排序.逆序数.树状数组.离散化)

热门文章

  1. shell:判断某个变量是否包含字符串/变量的方法
  2. P6329 【模板】点分树 | 震波
  3. LOJ3075 「2019 集训队互测 Day 3」组合数求和
  4. nodejs 后台运行 forever
  5. Centos7 MyCat2 安装部署
  6. Note Taking App Comparison: Notesnook vs Joplin
  7. Matplotlib 绘图线
  8. Bug的分类及优先级划分
  9. Head_First_Python(中文版)值得花时间读的一本书
  10. fiddler的界面详细讲解