/**
* 顶部header
*/
Vue.component("process-control-bar", {
template: `
No.{{i + 1}}
{{item.name}}
{{item.total}} {{item.unit}}
(
{{item.yesMonitor}} {{item.unit}} /
{{item.notMonitor}} {{item.unit}}
)
`,
props: {
list:{
type:Array
},
height:{
type:Number
},
number:{
type:Number
}
},
data() {
return {
forData:[],
interval: '',
index:0,
}
},
mounted() {
//this.init()
},
methods: {
init() {
this.getData()
//计划时间
},
getData(){
var data = this.list
var max = 0;
for(let i = 0;i {
x.yesWidth = (Number(x.yesMonitor) / max ) * 100
x.notWidth = (Number(x.notMonitor) / max ) * 100
return x
})
this.forData = data
this.$refs.process.scrollTop = 0
this.index = 0
this.interval = setInterval(this.scroll, 5000);
},
scroll() {
let offsetHeight = this.$refs.process.querySelectorAll('.process-for')[0].offsetHeight;
if(this.index == this.forData.length - this.number){
this.index = 0
}else{
this.index += 1
}
$(this.$refs.process).animate({scrollTop:(offsetHeight * this.index)+'px'})
},
MouseEnter() {//鼠标移入停止滚动
clearInterval(this.interval);
},
MouseLeave() {//鼠标离开继续滚动
this.interval = setInterval(this.scroll, 5000);
},
},
watch:{
list: function (n,o) {
this.init()
},
}
})