index.vue
2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<template lang="pug">
.top-tesk-detail
.status-text {{statusText}}
el-switch(
:value="copyValue"
@change="change"
)
template(v-if="isOpen")
.task-info
.over-task.mr5 剩余任务
.mr5 已完成
.already.mr5 {{completed}}
.mr5 待质检
.wait.mr5 {{wait}}
.countDown(v-if="copyCountDownTime !== 0") {{countDownText}}
</template>
<script>
export default {
name: 'TopTeskDetails',
props: {
isOpen: {
type: Boolean,
required: true
},
completed: {
type: [Number, String],
default: 0
},
wait: {
type: [Number, String],
default: 0
},
countDownTime: {
type: Number,
default: 0
}
},
data() {
return {
timer: null, // 计时器
second: this.timeout, // 倒计时时间
copyValue: this.isOpen,
copyCountDownTime: this.countDownTime
}
},
computed: {
statusText() {
return this.isOpen ? '进行中' : '开始'
},
countDownText() {
return this.copyCountDownTime === 0 ? '-' : this.copyCountDownTime
}
},
watch: {
isOpen: {
handler(val) {
if (val && this.copyCountDownTime) {
this.startTimeout()
}
},
immediate: true
}
},
methods: {
startTimeout() {
setTimeout(this.nextSecond, 1000)
},
nextSecond() {
this.copyCountDownTime--
if (this.copyCountDownTime === 0) {
this.$emit('update:isOpen', false)
return
}
setTimeout(this.nextSecond, 1000)
},
change(val) {
this.$nextTick(() => {
this.$emit('update:isOpen', val)
})
}
}
}
</script>
<style lang="scss" scoped>
.top-tesk-detail {
height: 35px;
display: flex;
flex-flow: row nowrap;
justify-content: flex-start;
align-items: center;
.status-text {
width: 70px;
text-align: center;
font-size: 16px;
color: #333;
font-weight: 600;
}
.task-info {
margin: 0 5px;
font-size: 14px;
display: flex;
align-items: center;
.over-task {
font-weight: 500;
}
.already {
padding: 0 5px;
border-radius: 3px;
background-color: #52c3f1;
}
.wait {
padding: 0 5px;
border-radius: 3px;
background-color: #f19b12;
}
}
/* 倒计时*/
.countDown {
width: 35px;
height: 35px;
display: flex;
justify-content: center;
align-items: center;
font-size: 12px;
border-radius: 50%;
border: 3px solid #3f51b5;
box-sizing: border-box;
}
}
</style>