
<template>
<div class="home-time">
<div class="tab">
<el-radio-group v-model="radio" @change="radioChange">
<el-radio-button label="1">天</el-radio-button>
<el-radio-button label="2">时</el-radio-button>
</el-radio-group>
</div>
<div class="time-left">
<img src="@/assets/images/gasSit/syg.png" alt="" @click="daydown" />
</div>
<div class="time-seach">
<div class="time-conter">
<div class="time-conT">
<img
style="margin-right: 14px"
src="@/assets/images/gasSit/sqjt.png"
alt=""
@click="dayup"
/>
<img
style="margin-right: 18px"
src="@/assets/images/gasSit/sqjt.png"
alt=""
@click="hourup"
/>
</div>
<div class="time-conC">{{ time }}</div>
<div class="time-conB">
<img
style="margin-right: 14px"
src="@/assets/images/gasSit/xljt.png"
alt=""
@click="daydown"
/>
<img
style="margin-right: 18px"
src="@/assets/images/gasSit/xljt.png"
alt=""
@click="hourdown"
/>
</div>
</div>
</div>
<div class="time-right">
<img
v-if="playing == false"
style="margin-left: 5px"
src="@/assets/images/gasSit/bf.png"
@click="timego"
alt=""
/>
<img
v-else
style="margin-left: 5px"
src="@/assets/images/gasSit/zt.png"
@click="timestop"
alt=""
/>
<img
style="margin-left: 5px"
src="@/assets/images/gasSit/xyg.png"
alt=""
@click="dayup"
/>
</div>
</div>
</template>
<script>
import moment from "moment";
export default {
data() {
return {
time: moment().subtract(7, "days").format("YYYY-MM-DD HH:mm"),
playing: false,
intervalId: null,
pastDates: [],
timer: null,
radio: "2",
};
},
created() {},
methods: {
previousDay() {
this.time = moment(this.time).subtract(1, "day");
},
nextDay() {
this.time = moment(this.time).add(1, "day");
},
radioChange(val) {
switch (Number(val)) {
case 1:
this.isSelectShow = true;
break;
case 2:
this.isSelectShow = false;
break;
}
},
timego() {
this.playing = true;
this.timer = setInterval(() => {
if (moment().diff(this.time, "days") == 0) {
clearInterval(this.timer);
this.timer = null;
this.playing = false;
} else {
this.seventime = moment(this.time)
.add(1, "day")
.format("YYYY-MM-DD HH:mm");
this.time = this.seventime;
}
}, 1000);
},
timestop() {
this.playing = false;
},
dayup() {
if (moment().diff(this.time, "hour") > 0) {
this.time = moment(this.time).add(1, "day").format("YYYY-MM-DD HH:mm");
this.$parent.timeShow(this.time);
} else {
this.$message("请不要选择超过现在的时间");
}
},
daydown() {
if (moment().diff(this.time, "days") <= 7) {
this.time = moment(this.time)
.subtract(1, "day")
.format("YYYY-MM-DD HH:mm");
this.$parent.timeShow(this.time);
} else {
this.$message("仅支持查询七天内");
}
},
hourup() {
if (moment().diff(this.time, "hour") > 0) {
this.time = moment(this.time).add(1, "hour").format("YYYY-MM-DD HH:mm");
this.$parent.timeShow(this.time);
} else {
this.$message("请不要选择超过现在的时间");
}
},
hourdown() {
if (moment().diff(this.time, "days") <= 7) {
this.time = moment(this.time)
.subtract(1, "hour")
.format("YYYY-MM-DD HH:mm");
this.$parent.timeShow(this.time);
} else {
this.$message("仅支持查询七天内");
}
},
},
beforeDestroy() {
if (this.timer) {
clearInterval(this.timer);
this.timer = null;
}
},
};
</script>
<style lang="scss" scoped>
.home-time {
position: absolute;
height: 70px;
width: 330px;
bottom: 20px;
left: 305px;
z-index: 99;
background-color: white;
padding: 10px;
border-radius: 6px;
display: flex;
.time-left {
height: 100%;
width: 28px;
padding: 12px 0;
}
.time-seach {
height: 50px;
width: 146px;
border: 1px solid #70707084;
border-radius: 4px;
.time-conter {
text-align: right;
.time-conT {
height: 15px;
line-height: 10px;
img {
height: 100%;
width: 20px;
}
}
.time-conC {
text-align: center;
height: calc(100% - 20px);
}
.time-conB {
height: 15px;
line-height: 10px;
img {
height: 100%;
width: 20px;
}
}
}
}
.time-right {
height: 100%;
width: 68px;
padding: 12px 0;
}
}
.tab {
width: 80px;
padding: 8px 0;
}
::v-deep .el-radio-button__inner {
padding: 10px;
}
</style>

- 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
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
- 180
- 181
- 182
- 183
- 184
- 185
- 186
- 187
- 188
- 189
- 190
- 191
- 192
- 193
- 194
- 195
- 196
- 197
- 198
- 199
- 200
- 201
- 202
- 203
- 204
- 205
- 206
- 207
- 208
- 209
- 210
- 211
- 212
- 213
- 214
- 215
- 216
- 217
- 218
- 219
- 220
- 221
- 222
- 223
- 224
- 225
- 226
- 227
import Time from "./components/Time.vue";
<Time />