setTimer.vue
1.29 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
<template>
<div class="timer-sel">
<el-select v-model="settimer" placeholder="请选择" @change="changet">
<el-option
v-for="(item, index) in timeroptions"
:key="index"
:label="item.name"
:value="item.value"
>
</el-option>
</el-select>
</div>
</template>
<script>
export default {
data() {
return {
settimer: 0,
timeroptions: [
{ name: 5, value: 5 },
{ name: 10, value: 10 },
{ name: 15, value: 15 },
{ name: 30, value: 30 },
{ name: "不限时", value: -1 }
]
};
},
methods: {
changet(val) {
this.$emit("timerchange", val);
}
},
props: ["runtime", "runindex"],
updated(v) {
this.$nextTick(function() {
// alert(v)
this.settimer = this.runtime;
});
},
mounted() {
this.settimer = this.runtime;
if (this.runindex == 0 && (this.runtime == 0 || this.runtime == -1)) {
this.settimer = -1;
}
if (this.runindex > 0) {
this.timeroptions = [
{ name: "0", value: 0 },
{ name: 5, value: 5 },
{ name: 10, value: 10 },
{ name: 15, value: 15 },
{ name: 30, value: 30 }
];
}
},
watch: {
runtime(val) {
this.settimer = val;
}
}
};
</script>
<style></style>