提交 | 用户 | 时间
|
850106
|
1 |
<template> |
H |
2 |
<el-dialog |
|
3 |
title="采集值" |
|
4 |
:close-on-click-modal="false" |
|
5 |
:visible.sync="visible"> |
|
6 |
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()"> |
|
7 |
<el-form-item> |
|
8 |
<el-date-picker |
|
9 |
v-model="dataForm.startTime" |
|
10 |
type="datetime" |
|
11 |
value-format="yyyy-MM-dd HH:mm:ss" |
|
12 |
placeholder="选择日期时间"> |
|
13 |
</el-date-picker> |
|
14 |
</el-form-item> |
|
15 |
<el-form-item> |
|
16 |
<el-date-picker |
|
17 |
v-model="dataForm.endTime" |
|
18 |
type="datetime" |
|
19 |
value-format="yyyy-MM-dd HH:mm:ss" |
|
20 |
placeholder="选择日期时间"> |
|
21 |
</el-date-picker> |
|
22 |
</el-form-item> |
|
23 |
<el-form-item> |
|
24 |
<el-button @click="getDataList()">查询</el-button> |
|
25 |
</el-form-item> |
|
26 |
<el-form-item> |
|
27 |
<el-button type="primary" @click="exportHandle()">导出</el-button> |
|
28 |
</el-form-item> |
|
29 |
</el-form> |
|
30 |
<div id="chartDom" class="result-chart"></div> |
|
31 |
</el-dialog> |
|
32 |
</template> |
|
33 |
|
|
34 |
<script> |
|
35 |
|
|
36 |
import mixinViewModule from "@/mixins/view-module"; |
|
37 |
|
|
38 |
export default { |
|
39 |
mixins: [mixinViewModule], |
|
40 |
data() { |
|
41 |
return { |
|
42 |
mixinViewModuleOptions: { |
|
43 |
exportURL: '/api/data/export' |
|
44 |
}, |
|
45 |
dialogWidth: 0, |
|
46 |
pointtypeList: [], |
|
47 |
pointtypeMap: {}, |
|
48 |
minfreqList: [], |
|
49 |
minfreqMap: {}, |
|
50 |
storetypeList: [], |
|
51 |
storetypeMap: {}, |
|
52 |
datatypeList: [], |
|
53 |
datatypeMap: {}, |
|
54 |
sourceList: [], |
|
55 |
sourceMap: {}, |
|
56 |
expressionList: [], |
|
57 |
pointList: [], |
|
58 |
pointMap: {}, |
|
59 |
pointCodeMap: {}, |
|
60 |
operatorList: ['+', '-'], |
|
61 |
visible: false, |
|
62 |
roleList: [], |
|
63 |
dataForm: { |
|
64 |
id: '', |
|
65 |
pointNo: '', |
|
66 |
pointName: '', |
|
67 |
startTime: this.getYMDHMS(), |
|
68 |
endTime: '' |
|
69 |
}, |
|
70 |
pointsValue: [] |
|
71 |
} |
|
72 |
}, |
|
73 |
methods: { |
|
74 |
|
|
75 |
/** |
|
76 |
* 根据时间戳获取时间 |
|
77 |
* |
|
78 |
* @param {*} timestamp |
|
79 |
* @returns |
|
80 |
*/ |
|
81 |
getYMDHMS() { |
|
82 |
let timestamp = new Date().getTime() |
|
83 |
let time = new Date(timestamp - 1000 * 60 * 60 * 12) |
|
84 |
let year = time.getFullYear() |
|
85 |
let month = time.getMonth() + 1 |
|
86 |
let date = time.getDate() |
|
87 |
let hours = time.getHours() |
|
88 |
let minute = time.getMinutes() |
|
89 |
let second = time.getSeconds() |
|
90 |
|
|
91 |
if (month < 10) { |
|
92 |
month = '0' + month |
|
93 |
} |
|
94 |
if (date < 10) { |
|
95 |
date = '0' + date |
|
96 |
} |
|
97 |
if (hours < 10) { |
|
98 |
hours = '0' + hours |
|
99 |
} |
|
100 |
if (minute < 10) { |
|
101 |
minute = '0' + minute |
|
102 |
} |
|
103 |
if (second < 10) { |
|
104 |
second = '0' + second |
|
105 |
} |
|
106 |
return year + '-' + month + '-' + date + ' ' + hours + ':' + minute + ':' + '00' |
|
107 |
}, |
|
108 |
|
|
109 |
init(row) { |
|
110 |
this.dataForm.id = row.id |
|
111 |
this.dataForm.pointNo = row.pointNo |
|
112 |
this.dataForm.pointName = row.pointName |
|
113 |
this.dataForm.startTime = this.getYMDHMS() |
|
114 |
this.dataForm.endTime = '' |
|
115 |
this.getDataList() |
|
116 |
}, |
|
117 |
getDataList() { |
|
118 |
this.visible = true |
|
119 |
if (this.dataForm.id) { |
|
120 |
let params = { |
|
121 |
'pointNos': [this.dataForm.pointNo], |
|
122 |
'start': this.dataForm.startTime, |
|
123 |
'end': this.dataForm.endTime |
|
124 |
} |
|
125 |
this.$http['post'](`/data/api/data/point/history`, params).then(({data: res}) => { |
|
126 |
if (res.code !== 0) { |
|
127 |
return this.$message.error(res.msg) |
|
128 |
} |
|
129 |
let dataList = [] |
|
130 |
let xAxisData = [] |
|
131 |
res.data[this.dataForm.pointNo].forEach(function (value) { |
|
132 |
dataList.push([value['time'], value['value']]) |
|
133 |
xAxisData.push(value['time']) |
|
134 |
}) |
|
135 |
let myChart = this.$echarts.init(document.getElementById('chartDom')) |
|
136 |
let seriesData = [] |
|
137 |
seriesData.push({ |
|
138 |
name: '采集值', |
|
139 |
type: 'line', |
|
140 |
data: dataList, |
|
141 |
showSymbol: true, |
|
142 |
smooth: false, |
|
143 |
lineStyle: { |
|
144 |
normal: { |
|
145 |
color: '#5B8FF9', |
|
146 |
width: 1 |
|
147 |
} |
|
148 |
} |
|
149 |
}) |
|
150 |
if (this.dataForm.bjsx) { |
|
151 |
seriesData.push({ |
|
152 |
name: '', |
|
153 |
data: [null], |
|
154 |
type: 'line', |
|
155 |
smooth: false, |
|
156 |
markLine: { |
|
157 |
silent: true, |
|
158 |
lineStyle: { |
|
159 |
normal: { |
|
160 |
color: '#d87a80', // 这儿设置安全基线颜色 |
|
161 |
width: 1 |
|
162 |
} |
|
163 |
}, |
|
164 |
data: [{ |
|
165 |
yAxis: this.dataForm.bjsx |
|
166 |
}], |
|
167 |
label: { |
|
168 |
show: true, |
|
169 |
position: 'insideEndTop', |
|
170 |
color: '#d87a80', |
|
171 |
distance: [-25, 1], |
|
172 |
formatter: '{c}' |
|
173 |
}, |
|
174 |
symbol: ['none', 'none'] |
|
175 |
} |
|
176 |
}) |
|
177 |
} |
|
178 |
if (this.dataForm.bjxx) { |
|
179 |
seriesData.push({ |
|
180 |
name: '', |
|
181 |
data: [null], |
|
182 |
type: 'line', |
|
183 |
smooth: false, |
|
184 |
markLine: { |
|
185 |
silent: true, |
|
186 |
lineStyle: { |
|
187 |
normal: { |
|
188 |
color: '#d87a80', // 这儿设置安全基线颜色 |
|
189 |
width: 1 |
|
190 |
} |
|
191 |
}, |
|
192 |
data: [{ |
|
193 |
yAxis: this.dataForm.bjxx |
|
194 |
}], |
|
195 |
label: { |
|
196 |
show: true, |
|
197 |
position: 'insideEndBottom', |
|
198 |
color: '#d87a80', |
|
199 |
distance: [-25, 1], |
|
200 |
formatter: '{c}' |
|
201 |
}, |
|
202 |
symbol: ['none', 'none'] |
|
203 |
} |
|
204 |
}) |
|
205 |
} |
|
206 |
|
|
207 |
let option = { |
|
208 |
title: { |
|
209 |
text: this.dataForm.pointName, |
|
210 |
top: 0, |
|
211 |
left: '1%', |
|
212 |
textStyle: { |
|
213 |
fontSize: 14 |
|
214 |
} |
|
215 |
}, |
|
216 |
tooltip: { |
|
217 |
trigger: 'axis', |
|
218 |
axisPointer: { |
|
219 |
type: 'line', |
|
220 |
lineStyle: { |
|
221 |
color: '#cccccc', |
|
222 |
width: '1', |
|
223 |
type: 'dashed' |
|
224 |
} |
|
225 |
} |
|
226 |
}, |
|
227 |
legend: { |
|
228 |
show: false, |
|
229 |
top: 10 |
|
230 |
}, |
|
231 |
grid: { |
|
232 |
top: 30, |
|
233 |
left: '3%', |
|
234 |
right: '5%', |
|
235 |
bottom: 10, |
|
236 |
containLabel: true |
|
237 |
}, |
|
238 |
xAxis: { |
|
239 |
type: 'category', |
|
240 |
boundaryGap: false, |
|
241 |
data: xAxisData |
|
242 |
}, |
|
243 |
yAxis: { |
|
244 |
type: 'value', |
|
245 |
// max: rangeH, |
|
246 |
// min: rangeL |
|
247 |
}, |
|
248 |
dataZoom: [{ |
|
249 |
type: 'inside' |
|
250 |
}], |
|
251 |
series: seriesData |
|
252 |
} |
|
253 |
myChart.clear() |
|
254 |
myChart.setOption(option) |
|
255 |
}).catch(() => { |
|
256 |
}) |
|
257 |
} |
|
258 |
}, |
|
259 |
resetFields(obj) { |
|
260 |
for (let key in obj) { |
|
261 |
if (key === 'pointTypeName') { |
|
262 |
continue |
|
263 |
} |
|
264 |
if (obj[key] instanceof Array) { |
|
265 |
obj[key] = [] |
|
266 |
} else if (obj[key] instanceof Object) { |
|
267 |
this.resetFields(obj[key]) |
|
268 |
} else { |
|
269 |
obj[key] = '' |
|
270 |
} |
|
271 |
} |
|
272 |
}, |
|
273 |
exportExcel() { |
|
274 |
let params = { |
|
275 |
'pointNos': this.dataForm.pointNo, |
|
276 |
'start': this.dataForm.startTime, |
|
277 |
'end': this.dataForm.endTime |
|
278 |
} |
|
279 |
}, |
|
280 |
setDefaultFields(id, pointtypename) { |
|
281 |
this.dataForm.id = id || 0 |
|
282 |
this.dataForm.pointtypename = pointtypename || '' |
|
283 |
this.expressionList = [{ |
|
284 |
point: '', |
|
285 |
operator: '' |
|
286 |
}] |
|
287 |
} |
|
288 |
} |
|
289 |
} |
|
290 |
</script> |
|
291 |
<style> |
|
292 |
.el-select { |
|
293 |
width: 100% |
|
294 |
} |
|
295 |
|
|
296 |
.result-chart { |
|
297 |
height: 500px; |
|
298 |
} |
|
299 |
</style> |
|
300 |
|