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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
<template>
<div class="app-container">
<div class="box-card">
<div class="top-title">
<span class="line"></span >
<span class="title-text">历史记录</span>
</div>
<el-form
:model="queryParams"
size="small"
:inline="true"
label-width="80px"
class="searchform"
>
<el-form-item label="设备名称:" prop="equipmentName">
<el-select
v-model="queryParams.equipmentName"
clearable
placeholder="请选择设备"
>
<el-option
v-for="item in selectList"
:key="item.value"
:label="item.name"
:value="item.value"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="时间:" prop="time">
<el-date-picker
:default-time="['00:00:00', '23:59:59']"
style="width: 350px !important;"
v-model="queryParams.time"
type="datetimerange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
clearable
value-format="yyyy-MM-dd HH:mm:ss"
/>
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
@click="toSearch"
style="margin-left: 20px;"
>搜索</el-button>
</el-form-item>
<el-form-item>
<el-button
type="info"
icon="el-icon-setting"
@click="resetTable"
style="margin-left: 20px;"
>重置</el-button>
</el-form-item>
</el-form>
<el-table :data="dmList" height="255">
<el-table-column label="序号" align="center" width="60" type="index"/>
<el-table-column label="设备名称" align="center" prop="equipmentName" />
<el-table-column label="监测点位" align="center" prop="monitoringPoint" />
<el-table-column label="挠度监测(mm)" align="center" prop="value" />
<el-table-column label="监测时间" align="center" prop="jctime" />
<el-table-column align="center" prop="ifbj" label="报警状态">
<template slot-scope="scope">
<span v-if="scope.row.ifbj==='正常'" style="color:#02d808;">
<i class="el-icon-message-solid icolor" style="color:#02d808"></i>
{{scope.row.ifbj}}
</span>
<span v-else style="color: #f21616;">
<i class="el-icon-message-solid icolor" style="color:#f21616"></i>
{{scope.row.ifbj}}
</span>
</template>
</el-table-column>
</el-table>
<el-pagination
style="padding:10px 1px 10px 0px;margin-left:20px;"
:page-sizes="[10, 20, 30, 40]"
layout="total, sizes, prev, pager, next, jumper"
:total="total"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
@pagination="allData"
/>
</div>
<div class="box-chart">
<div class="top-title">
<span class="line"></span >
<span class="title-text">挠度监测图表</span>
</div>
<el-form
:model="querychart"
size="small"
:inline="true"
label-width="80px"
class="searchform"
>
<el-form-item label="设备名称:" prop="equipmentName">
<el-select
v-model="querychart.equipmentName"
clearable
placeholder="请选择设备"
>
<el-option
v-for="item in selectList"
:key="item.value"
:label="item.name"
:value="item.value"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="时间:" prop="time">
<el-date-picker
:default-time="['00:00:00', '23:59:59']"
style="width: 350px !important;"
v-model="querychart.time"
type="datetimerange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
clearable
value-format="yyyy-MM-dd HH:mm:ss"
:picker-options="{shortcuts: shortcuts}"
/>
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
@click="searchChart($event)"
style="margin-left: 20px;"
>搜索</el-button>
</el-form-item>
</el-form>
<div class='chart' id='chart'></div>
</div>
</div>
</template>
<script>
import {tableList,searchSb,reqChart} from "@/api/monitor/cache";
import * as echarts from "echarts";
import { parseTime } from "../../utils/index.js";
export default {
data() {
return {
// 总条数
total: 0,
dmList: [],
selectList:[],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询表格参数
queryParams: {
pageNum: 1,
pageSize: 10,
equipmentName: null,
time:null
},
querychart: {
equipmentName: null,
time:null
},
chartData:{}
};
},
mounted(){
const now = new Date();
const oneMonthBefore = new Date(now - 30 * 24 * 60 * 60 * 1000);
this.querychart.time = [oneMonthBefore, now]; // 设置日期范围为最近一个月
this.searchEqu();
this.allData();
this.drawChart();
this.$watermark.set(" ",this.$refs.content)
},
beforeDestroy() {
this.$watermark.set("",this.$refs.content);
},
computed: {
shortcuts() {
const now = new Date();
let yesterday = new Date();
const oneMonthBefore = new Date(now - 30 * 24 * 60 * 60 * 1000);
yesterday.setDate(yesterday.getDate() - 1);
}
},
methods: {
//设备名称下拉
searchEqu() {
var param ={
equipmentType:'挠度监测'
}
searchSb(param).then((res) => {
var body = res.data||[];
this.selectList = body;
this.querychart.equipmentName = this.selectList[0].value;
this.searchChart({target:{value:this.querychart.equipmentName}})
});
},
//表格
allData() {
var param ={
pageNum:this.queryParams.pageNum,
pageSize: this.queryParams.pageSize
}
tableList(param).then((res) => {
var body = res.rows || [];
this.dmList = body;
this.total = res.total;
});
},
handleSizeChange(val) {
this.queryParams.pageSize =val;
this.toSearch()
},
handleCurrentChange(val) {
this.queryParams.pageNum = val;
this.toSearch()
},
toSearch() {
var param = this.queryParams;
if (this.queryParams.time instanceof Array) {
param.startTime = parseTime(new Date(this.queryParams.time[0]));
param.endTime = parseTime(new Date(this.queryParams.time[1]));
}
tableList(param).then((res) => {
var body = res.rows || [];
this.dmList = body;
this.total = res.total;
});
},
//表格重置
resetTable(){
this.queryParams={}
this.allData()
},
//图表
searchChart(event){
var params ={
equipmentName:this.querychart.equipmentName
}
if (this.querychart.time instanceof Array) {
params.startTime = parseTime(new Date(this.querychart.time[0]));
params.endTime = parseTime(new Date(this.querychart.time[1]));
}
reqChart(params).then((res) => {
var body = res.data||[];
this.chartData = body[0]||{}
this.drawChart()
});
},
drawChart () {
// 基于准备好的dom,初始化echarts实例
let chart = this.$echarts.init(document.getElementById('chart'))
// 监听屏幕变化自动缩放图表
window.addEventListener('resize', function () { chart.resize() })
chart.setOption({
// 设置图表的位置
grid: {
x: 60, // 左间距
y: 40, // 上间距
x2: 30, // 右间距
y2: 60, // 下间距
containLabel: true // grid 区域是否包含坐标轴的刻度标签, 常用于『防止标签溢出』的场景
},
// dataZoom 组件 用于区域缩放
dataZoom: [
{
type: 'inside',
xAxisIndex: [0], // 设置 dataZoom-inside 组件控制的 x 轴
// 数据窗口范围的起始和结束百分比 范围: 0 ~ 100
start: 0,
end: 80
}
],
// 提示框组件
tooltip: {
trigger: 'axis', // 触发类型, axis: 坐标轴触发
axisPointer: {
type: 'line' // 指示器类型
},
textStyle: {
color: '#d5dbff' // 文字颜色
},
formatter: '时间: {b}<br/>设备名称: {a0}<br/>监测值: {c0} mm<br />'
},
// 图例组件
legend: {
top: 13, // 定位
right: 10,
textStyle: { // 文本样式
fontSize: 14,
fontWeight:400,
color: '#030303'
}
},
// X轴
xAxis: [
{
type: 'category',
// 坐标轴轴线
axisLine: {
show: true, // 是否显示坐标轴轴线 默认显示
lineStyle: {
type: 'dotted', // 坐标轴线线的类型 'solid', 'dashed', 'dotted'
width: 1, // 坐标轴线线宽, 不设置默认值为 1
color: '#cccccc' // 坐标轴线线的颜色
}
},
// 分隔线
splitLine: {
show: false,// 是否显示分隔线 默认数值轴显示
// lineStyle: {
// type:'dashed',// 分隔线颜色,可以设置成单个颜色。
// color: '#d9d9d9'
// }
},
// 坐标轴刻度
axisTick: {
show: false,
interval: 0, // 坐标轴刻度的显示间隔,在类目轴中有效。不设置时默认同 axisLabel.interval 一样。设置成 0 强制显示所有标签。如果设置为 1,表示『隔一个标签显示一个标签』,如果值为 2,表示隔两个标签显示一个标签,以此类推。
inside: true, // 默认值false。true 表示坐标轴刻度朝内,false 表示坐标轴刻度朝外
},
axisLabel: {
interval: 'auto', // 只显示最大和最小坐标
textStyle: {
show: true,
color: "#000000",
fontSize: "12",
}
},
// 类目名称
data: this.chartData.times||[]
}
],
yAxis: [
// 左侧Y轴
{
type: 'value', // 坐标轴类型, 'value' 数值轴,适用于连续数据
// 坐标轴在图表区域中的分隔线
name:"单位(mm)",
splitLine: {
show: true, // 是否显示分隔线 默认数值轴显示
lineStyle: {
type:'dashed',// 分隔线颜色,可以设置成单个颜色。
color: '#d9d9d9'
}
},
// 坐标轴刻度
axisTick: {
show: false,
interval: 0, // 坐标轴刻度的显示间隔,在类目轴中有效。不设置时默认同 axisLabel.interval 一样。设置成 0 强制显示所有标签。如果设置为 1,表示『隔一个标签显示一个标签』,如果值为 2,表示隔两个标签显示一个标签,以此类推。
inside: true, // 默认值false。true 表示坐标轴刻度朝内,false 表示坐标轴刻度朝外
},
// 坐标轴轴线。
axisLine: {
show: true, // 是否显示坐标轴轴线 默认显示
lineStyle: {
type: 'dotted', // 坐标轴线线的类型 'solid', 'dashed', 'dotted'
width: 1, // 坐标轴线线宽, 不设置默认值为 1
color: '#555555' // 坐标轴线线的颜色
}
},
axisLabel: {
show: true, // 是否显示刻度标签 默认显示
color: '#555555', // 刻度标签文字的颜色
fontSize: 12, // 文字的字体大小
margin: 10, // 刻度标签与轴线之间的距离 默认值 8
formatter: '{value}'
}
}
],
series: [
{
name: this.chartData.equipmentName,
type: "line",
symbol: "circle", // 默认是空心圆(中间是白色的),改成实心圆
showAllSymbol: true,
symbolSize: 0,
smooth: true,
lineStyle: {
normal: {
color: "rgba(72, 118, 255)", // 线条颜色
},
borderColor: "rgba(0,0,0,.4)",
},
itemStyle: {
color: "rgba(72, 118, 255)",
borderColor: "#646ace",
},
tooltip: {
show: true,
},
areaStyle: {
//区域填充样式
normal: {
//线性渐变,前4个参数分别是x0,y0,x2,y2(范围0~1);相当于图形包围盒中的百分比。如果最后一个参数是‘true’,则该四个值是绝对像素位置。
color: new this.$echarts.graphic.LinearGradient(
0,
0,
0,
1,
[
{
offset: 0,
color: "rgba(72, 118, 255)",
},
{
offset: 1,
color: "rgba(24,187,157, 0)",
},
],
false
),
shadowColor: "rgba(10,219,250, 0.5)", //阴影颜色
},
},
data:this.chartData.value||[],
},
],
})
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scope>
.searchform{
width: 100%;
height: 40px;
background-color: #fff;
display: flex;
justify-content: flex-start;
align-items: center;
padding-left: 30px;
margin-bottom: 0.9375rem;
.el-form-item{
margin-bottom: 0px!important;
}
}
.resetting{
margin:20px 20px 20px 0px;
}
.el-table--scrollable-y .el-table__body-wrappe{
overflow-y: scroll!important;
}
.tableline{
width:50%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.box-card {
width: 100%;
height: 25rem;
background-color: #fff;
.top-title {
width: 100%;
height: 50px;
display: flex;
justify-content: flex-start;
align-items:center;
padding-left: 20px;
.line {
width: 6px;
height: 22px;
background: #0d85f4;
}
.title-text{
font-size: 18px;
font-weight:bold;
color: #333333;
line-height: 30px;
padding-left: 10px;
}
}
}
.box-chart{
width: 100%;
height: 25rem;
background-color: #fff;
margin-top: 20px;
.top-title {
width: 100%;
height: 50px;
display: flex;
justify-content: flex-start;
align-items:center;
padding-left: 20px;
.line {
width: 6px;
height: 22px;
background: #0d85f4;
}
.title-text{
font-size: 18px;
font-weight:bold;
color: #333333;
line-height: 30px;
padding-left: 10px;
}
}
.chart{
width: 100%;
height: 85%!important;
}
}
</style>