提交 | 用户 | 时间
|
850106
|
1 |
<template> |
H |
2 |
<el-dialog |
|
3 |
title="详情" |
|
4 |
:close-on-click-modal="false" |
|
5 |
:width="dialogWidth" |
|
6 |
:visible.sync="visible"> |
|
7 |
<el-form :model="dataForm" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="120px"> |
|
8 |
<el-row :gutter="20"> |
|
9 |
<el-col :span="12"> |
|
10 |
<el-form-item label="采集点名称:" prop="point.pointname"> |
|
11 |
{{dataForm.point.pointname}} |
|
12 |
</el-form-item> |
|
13 |
</el-col> |
|
14 |
<el-col :span="12"> |
|
15 |
<el-form-item label="编号:" prop="point.pointno" v-if="!!dataForm.id"> |
|
16 |
{{dataForm.point.pointno}} |
|
17 |
</el-form-item> |
|
18 |
</el-col> |
|
19 |
</el-row> |
|
20 |
<el-row :gutter="20"> |
|
21 |
<el-col :span="12"> |
|
22 |
<el-form-item label="点类型:" prop="point.pointtypeid"> |
|
23 |
{{pointtypeMap[dataForm.point.pointtypeid]}} |
|
24 |
</el-form-item> |
|
25 |
</el-col> |
|
26 |
<el-col :span="12"> |
|
27 |
<el-form-item label="采集频率:" prop="point.minfreqid"> |
|
28 |
{{minfreqMap[dataForm.point.minfreqid]}} |
|
29 |
</el-form-item> |
|
30 |
</el-col> |
|
31 |
</el-row> |
|
32 |
<el-row :gutter="20"> |
|
33 |
<el-col :span="12"> |
|
34 |
<el-form-item label="存储类型:" prop="point.storetypeid"> |
|
35 |
{{storetypeMap[dataForm.point.storetypeid]}} |
|
36 |
</el-form-item> |
|
37 |
</el-col> |
|
38 |
<el-col :span="12"> |
|
39 |
<el-form-item label="单位:" prop="point.unit"> |
|
40 |
{{dataForm.point.unit}} |
|
41 |
</el-form-item> |
|
42 |
</el-col> |
|
43 |
</el-row> |
|
44 |
<el-row :gutter="20"> |
|
45 |
<el-col :span="12"> |
|
46 |
<el-form-item label="逻辑上限:" prop="point.logicmax"> |
|
47 |
{{dataForm.point.logicmax}} |
|
48 |
</el-form-item> |
|
49 |
</el-col> |
|
50 |
<el-col :span="12"> |
|
51 |
<el-form-item label="逻辑下限:" prop="point.logicmin"> |
|
52 |
{{dataForm.point.logicmin}} |
|
53 |
</el-form-item> |
|
54 |
</el-col> |
|
55 |
</el-row> |
|
56 |
<el-row :gutter="20"> |
|
57 |
<el-col :span="12"> |
|
58 |
<el-form-item label="最大值:" prop="point.maxvalue"> |
|
59 |
{{dataForm.point.maxvalue}} |
|
60 |
</el-form-item> |
|
61 |
</el-col> |
|
62 |
<el-col :span="12"> |
|
63 |
<el-form-item label="最小值:" prop="point.minvalue"> |
|
64 |
{{dataForm.point.minvalue}} |
|
65 |
</el-form-item> |
|
66 |
</el-col> |
|
67 |
</el-row> |
|
68 |
<el-row :gutter="20"> |
|
69 |
<el-col :span="12"> |
|
70 |
<el-form-item label="缺省值:" prop="point.defaultvalue"> |
|
71 |
{{dataForm.point.defaultvalue}} |
|
72 |
</el-form-item> |
|
73 |
</el-col> |
|
74 |
<el-col :span="12"> |
|
75 |
<el-form-item label="单位换算:" prop="point.unittransfactor"> |
|
76 |
{{dataForm.point.unittransfactor}} |
|
77 |
</el-form-item> |
|
78 |
</el-col> |
|
79 |
</el-row> |
|
80 |
<el-row :gutter="20" v-if="dataForm.pointtypename ==='MEASURE POINT' || dataForm.pointtypename === 'MATHVARIABLE'"> |
|
81 |
<el-col :span="12"> |
|
82 |
<el-form-item label="采样范围" prop="point.dimension"> |
|
83 |
{{dataForm.point.dimension}} |
|
84 |
</el-form-item> |
|
85 |
</el-col> |
|
86 |
</el-row> |
|
87 |
<el-row :gutter="20" v-if="dataForm.pointtypename ==='MEASURE POINT'"> |
|
88 |
<el-col :span="12"> |
|
89 |
<el-form-item label="TAG编号:" prop="measurePoint.tagno"> |
|
90 |
{{dataForm.measurePoint.tagno}} |
|
91 |
</el-form-item> |
|
92 |
</el-col> |
|
93 |
<el-col :span="12"> |
|
94 |
<el-form-item label="数据类型:" prop="measurePoint.datatypeid"> |
|
95 |
{{datatypeMap[dataForm.measurePoint.datatypeid]}} |
|
96 |
</el-form-item> |
|
97 |
</el-col> |
|
98 |
</el-row> |
|
99 |
<el-row :gutter="20" v-if="dataForm.pointtypename ==='MEASURE POINT'"> |
|
100 |
<el-col :span="12"> |
|
101 |
<el-form-item label="数据源:" prop="measurePoint.sourceid"> |
|
102 |
{{sourceMap[dataForm.measurePoint.sourceid]}} |
|
103 |
</el-form-item> |
|
104 |
</el-col> |
|
105 |
</el-row> |
|
106 |
<el-row :gutter="20" v-if="dataForm.pointtypename === 'CALCULATE POINT' || dataForm.pointtypename === 'MATHVARIABLE'"> |
|
107 |
<el-col :span="24"> |
|
108 |
<el-form-item label="表达式:"> |
|
109 |
<el-table |
|
110 |
:data="expressionList" |
|
111 |
border |
|
112 |
style="width: 100%"> |
|
113 |
<el-table-column |
|
114 |
type="index" |
|
115 |
align="center" |
|
116 |
width="50" |
|
117 |
label="序号"> |
|
118 |
</el-table-column> |
|
119 |
<el-table-column |
|
120 |
prop="parenthesesLeft" |
|
121 |
label="左括号" |
|
122 |
width="90" |
|
123 |
align="center"> |
|
124 |
</el-table-column> |
|
125 |
<el-table-column |
|
126 |
prop="pointName" |
|
127 |
label="采集点" |
|
128 |
align="center"> |
|
129 |
</el-table-column> |
|
130 |
<el-table-column |
|
131 |
prop="point" |
|
132 |
label="运算值" |
|
133 |
align="center"> |
|
134 |
</el-table-column> |
|
135 |
<el-table-column |
|
136 |
prop="parenthesesRight" |
|
137 |
label="右括号" |
|
138 |
width="90" |
|
139 |
align="center"> |
|
140 |
</el-table-column> |
|
141 |
<el-table-column |
|
142 |
prop="operator" |
|
143 |
label="运算符" |
|
144 |
align="center"> |
|
145 |
</el-table-column> |
|
146 |
</el-table> |
|
147 |
</el-form-item> |
|
148 |
</el-col> |
|
149 |
</el-row> |
|
150 |
</el-form> |
|
151 |
</el-dialog> |
|
152 |
</template> |
|
153 |
|
|
154 |
<script> |
|
155 |
export default { |
|
156 |
data () { |
|
157 |
return { |
|
158 |
dialogWidth: 0, |
|
159 |
pointtypeList: [], |
|
160 |
pointtypeMap: {}, |
|
161 |
minfreqList: [], |
|
162 |
minfreqMap: {}, |
|
163 |
storetypeList: [], |
|
164 |
storetypeMap: {}, |
|
165 |
datatypeList: [], |
|
166 |
datatypeMap: {}, |
|
167 |
sourceList: [], |
|
168 |
sourceMap: {}, |
|
169 |
expressionList: [], |
|
170 |
pointList: [], |
|
171 |
pointMap: {}, |
|
172 |
pointCodeMap: {}, |
|
173 |
operatorList: ['+', '-'], |
|
174 |
visible: false, |
|
175 |
roleList: [], |
|
176 |
dataForm: { |
|
177 |
id: 0, |
|
178 |
pointtypename: '', |
|
179 |
point: { |
|
180 |
id: '', |
|
181 |
pointno: '', |
|
182 |
pointname: '', |
|
183 |
pointtypeid: '', |
|
184 |
minfreqid: '', |
|
185 |
unit: '', |
|
186 |
dimension: 1, |
|
187 |
descp: '', |
|
188 |
defaultvalue: '', |
|
189 |
maxvalue: '', |
|
190 |
minvalue: '', |
|
191 |
storetypeid: '', |
|
192 |
logicmax: '', |
|
193 |
logicmin: '', |
|
194 |
unittransfactor: '', |
|
195 |
iscollect: '' |
|
196 |
}, |
|
197 |
mathPoint: { |
|
198 |
id: '', |
|
199 |
pointid: '', |
|
200 |
expression: '' |
|
201 |
}, |
|
202 |
measurePoint: { |
|
203 |
id: '', |
|
204 |
pointid: '', |
|
205 |
tagno: '', |
|
206 |
datatypeid: '', |
|
207 |
sourceid: '', |
|
208 |
defaultvalue: '', |
|
209 |
maxvalue: '', |
|
210 |
minvalue: '' |
|
211 |
} |
|
212 |
} |
|
213 |
} |
|
214 |
}, |
|
215 |
created () { |
|
216 |
this.setDialogWidth() |
|
217 |
}, |
|
218 |
mounted () { |
|
219 |
window.onresize = () => { |
|
220 |
return (() => { |
|
221 |
this.setDialogWidth() |
|
222 |
})() |
|
223 |
} |
|
224 |
}, |
|
225 |
methods: { |
|
226 |
setDialogWidth () { |
|
227 |
let val = document.body.clientWidth |
|
228 |
const def = 1300 // 默认宽度 |
|
229 |
if (val < def) { |
|
230 |
this.dialogWidth = '70%' |
|
231 |
} else { |
|
232 |
this.dialogWidth = '50%' |
|
233 |
} |
|
234 |
}, |
|
235 |
init (id, pointtypename) { |
|
236 |
this.getPointtypeList(id) |
|
237 |
this.getMinfreqList() |
|
238 |
this.getStoretypeList() |
|
239 |
this.getDatatypeList() |
|
240 |
this.getSourceList() |
|
241 |
this.getPointList() |
|
242 |
this.dataForm.id = id || 0 |
|
243 |
this.dataForm.pointtypename = pointtypename || '' |
|
244 |
this.visible = true |
|
245 |
this.$nextTick(() => { |
|
246 |
this.resetFields(this.dataForm) |
|
247 |
this.setDefaultFields(id, pointtypename) |
|
248 |
}) |
|
249 |
if (id) { |
|
250 |
this.$http({ |
|
251 |
url: `/data/mcs/point/info/${this.dataForm.id}`, |
|
252 |
method: 'get', |
|
253 |
params: this.$http.adornParams() |
|
254 |
}).then(({data}) => { |
|
255 |
this.expressionList = [] |
|
256 |
if (data && data.code === 0) { |
|
257 |
for (let key in this.dataForm.point) { |
|
258 |
this.dataForm.point[key] = '' |
|
259 |
if (data.point.point[key] || data.point.point[key] === 0) { |
|
260 |
this.dataForm.point[key] = data.point.point[key] |
|
261 |
} |
|
262 |
} |
|
263 |
if (data.point.mathPoint) { |
|
264 |
for (let key in this.dataForm.mathPoint) { |
|
265 |
this.dataForm.mathPoint[key] = '' |
|
266 |
if (data.point.mathPoint[key] || data.point.mathPoint[key] === 0) { |
|
267 |
this.dataForm.mathPoint[key] = data.point.mathPoint[key] |
|
268 |
} |
|
269 |
} |
|
270 |
if (this.dataForm.mathPoint.expression) { |
|
271 |
let expression = this.dataForm.mathPoint.expression |
|
272 |
do { |
|
273 |
let indexArray = [expression.indexOf('+'), expression.indexOf('-'), expression.indexOf('*'), expression.indexOf('/')].sort(this.numAscSort) |
|
274 |
if (indexArray[indexArray.length - 1] !== -1) { |
|
275 |
let endIndex = 0 |
|
276 |
for (let key in indexArray) { |
|
277 |
if (indexArray[key] > -1) { |
|
278 |
endIndex = indexArray[key] |
|
279 |
break |
|
280 |
} |
|
281 |
} |
|
282 |
let pointStr = expression.substring(0, endIndex) |
|
283 |
let operator = expression.substr(endIndex, 1) |
|
284 |
let indexOfParenthesesLeft = pointStr.indexOf('(') |
|
285 |
let lastIndexOfParenthesesLeft = pointStr.lastIndexOf('(') |
|
286 |
let parenthesesLeft = '' |
|
287 |
if (indexOfParenthesesLeft !== -1 && lastIndexOfParenthesesLeft !== -1) { |
|
288 |
parenthesesLeft = pointStr.substring(indexOfParenthesesLeft, lastIndexOfParenthesesLeft + 1) |
|
289 |
pointStr = pointStr.substring(lastIndexOfParenthesesLeft + 1) |
|
290 |
} |
|
291 |
let indexOfParenthesesRight = pointStr.indexOf(')') |
|
292 |
let lastIndexOfParenthesesRight = pointStr.lastIndexOf(')') |
|
293 |
let parenthesesRight = '' |
|
294 |
if (indexOfParenthesesRight !== -1 && lastIndexOfParenthesesRight !== -1) { |
|
295 |
parenthesesRight = pointStr.substring(indexOfParenthesesRight, lastIndexOfParenthesesRight + 1) |
|
296 |
pointStr = pointStr.substring(0, indexOfParenthesesRight) |
|
297 |
} |
|
298 |
this.expressionList.push({ |
|
299 |
parenthesesLeft: parenthesesLeft, |
|
300 |
pointName: this.pointCodeMap[pointStr] || pointStr, |
|
301 |
point: pointStr, |
|
302 |
parenthesesRight: parenthesesRight, |
|
303 |
operator: operator |
|
304 |
}) |
|
305 |
expression = expression.substring(endIndex + 1) |
|
306 |
} else { |
|
307 |
let pointStr = expression |
|
308 |
let indexOfParenthesesLeft = pointStr.indexOf('(') |
|
309 |
let lastIndexOfParenthesesLeft = pointStr.lastIndexOf('(') |
|
310 |
let parenthesesLeft = '' |
|
311 |
if (indexOfParenthesesLeft !== -1 && lastIndexOfParenthesesLeft !== -1) { |
|
312 |
parenthesesLeft = pointStr.substring(indexOfParenthesesLeft, lastIndexOfParenthesesLeft + 1) |
|
313 |
pointStr = pointStr.substring(lastIndexOfParenthesesLeft + 1) |
|
314 |
} |
|
315 |
let indexOfParenthesesRight = pointStr.indexOf(')') |
|
316 |
let lastIndexOfParenthesesRight = pointStr.lastIndexOf(')') |
|
317 |
let parenthesesRight = '' |
|
318 |
if (indexOfParenthesesRight !== -1 && lastIndexOfParenthesesRight !== -1) { |
|
319 |
parenthesesRight = pointStr.substring(indexOfParenthesesRight, lastIndexOfParenthesesRight + 1) |
|
320 |
pointStr = pointStr.substring(0, indexOfParenthesesRight) |
|
321 |
} |
|
322 |
this.expressionList.push({ |
|
323 |
parenthesesLeft: parenthesesLeft, |
|
324 |
pointName: this.pointCodeMap[pointStr], |
|
325 |
point: pointStr, |
|
326 |
parenthesesRight: parenthesesRight, |
|
327 |
operator: '' |
|
328 |
}) |
|
329 |
expression = '' |
|
330 |
} |
|
331 |
} while (expression && expression.length > 0) |
|
332 |
} |
|
333 |
} |
|
334 |
if (data.point.measurePoint) { |
|
335 |
for (let key in this.dataForm.measurePoint) { |
|
336 |
this.dataForm.measurePoint[key] = data.point.measurePoint[key] || '' |
|
337 |
} |
|
338 |
} |
|
339 |
} |
|
340 |
}) |
|
341 |
} |
|
342 |
}, |
|
343 |
numAscSort (a, b) { |
|
344 |
return a - b |
|
345 |
}, |
|
346 |
resetFields (obj) { |
|
347 |
for (let key in obj) { |
|
348 |
if (key === 'pointtypename') { |
|
349 |
continue |
|
350 |
} |
|
351 |
if (obj[key] instanceof Array) { |
|
352 |
obj[key] = [] |
|
353 |
} else if (obj[key] instanceof Object) { |
|
354 |
this.resetFields(obj[key]) |
|
355 |
} else { |
|
356 |
obj[key] = '' |
|
357 |
} |
|
358 |
} |
|
359 |
}, |
|
360 |
setDefaultFields (id, pointtypename) { |
|
361 |
this.dataForm.id = id || 0 |
|
362 |
this.dataForm.pointtypename = pointtypename || '' |
|
363 |
this.expressionList = [{ |
|
364 |
point: '', |
|
365 |
operator: '' |
|
366 |
}] |
|
367 |
}, |
|
368 |
// 获取预测项类型列表 |
|
369 |
getPointtypeList (id) { |
|
370 |
this.$http({ |
|
371 |
url: '/data/mcs/point-type/list', |
|
372 |
method: 'get', |
|
373 |
params: this.$http.adornParams({ |
|
374 |
'page': 1, |
|
375 |
'limit': 100 |
|
376 |
}) |
|
377 |
}).then(({data}) => { |
|
378 |
if (data && data.code === 0) { |
|
379 |
this.pointtypeList = data.page.list |
|
380 |
this.pointtypeList.forEach(function (value) { |
|
381 |
this.pointtypeMap[value.id] = value.descp |
|
382 |
}, this) |
|
383 |
if (!id) { |
|
384 |
this.dataForm.point.pointtypeid = this.pointtypeList[0].id |
|
385 |
this.dataForm.pointtypename = this.pointtypeMap[this.dataForm.point.pointtypeid] |
|
386 |
} |
|
387 |
} else { |
|
388 |
this.pointtypeList = [] |
|
389 |
} |
|
390 |
}) |
|
391 |
}, |
|
392 |
getMinfreqList () { |
|
393 |
this.$http({ |
|
394 |
url: '/data/mcs/min-freq/list', |
|
395 |
method: 'get', |
|
396 |
params: this.$http.adornParams({ |
|
397 |
'page': 1, |
|
398 |
'limit': 100 |
|
399 |
}) |
|
400 |
}).then(({data}) => { |
|
401 |
if (data && data.code === 0) { |
|
402 |
this.minfreqList = data.page.list |
|
403 |
this.minfreqList.forEach(function (value) { |
|
404 |
this.minfreqMap[value.id] = value.minfreqname |
|
405 |
}, this) |
|
406 |
} else { |
|
407 |
this.minfreqList = [] |
|
408 |
} |
|
409 |
}) |
|
410 |
}, |
|
411 |
getStoretypeList () { |
|
412 |
this.$http({ |
|
413 |
url: '/data/mcs/store-type/list', |
|
414 |
method: 'get', |
|
415 |
params: this.$http.adornParams({ |
|
416 |
'page': 1, |
|
417 |
'limit': 100 |
|
418 |
}) |
|
419 |
}).then(({data}) => { |
|
420 |
if (data && data.code === 0) { |
|
421 |
this.storetypeList = data.page.list |
|
422 |
this.storetypeList.forEach(function (value) { |
|
423 |
this.storetypeMap[value.id] = value.storetypename |
|
424 |
}, this) |
|
425 |
} else { |
|
426 |
this.storetypeList = [] |
|
427 |
} |
|
428 |
}) |
|
429 |
}, |
|
430 |
getDatatypeList () { |
|
431 |
this.$http({ |
|
432 |
url: '/data/mcs/data-type/list', |
|
433 |
method: 'get', |
|
434 |
params: this.$http.adornParams({ |
|
435 |
'page': 1, |
|
436 |
'limit': 100 |
|
437 |
}) |
|
438 |
}).then(({data}) => { |
|
439 |
if (data && data.code === 0) { |
|
440 |
this.datatypeList = data.page.list |
|
441 |
this.datatypeList.forEach(function (value) { |
|
442 |
this.datatypeMap[value.id] = value.descp |
|
443 |
}, this) |
|
444 |
} else { |
|
445 |
this.datatypeList = [] |
|
446 |
} |
|
447 |
}) |
|
448 |
}, |
|
449 |
getSourceList () { |
|
450 |
this.$http({ |
|
451 |
url: '/data/mcs/data-source/list', |
|
452 |
method: 'get', |
|
453 |
params: this.$http.adornParams({ |
|
454 |
'page': 1, |
|
455 |
'limit': 100 |
|
456 |
}) |
|
457 |
}).then(({data}) => { |
|
458 |
if (data && data.code === 0) { |
|
459 |
this.sourceList = data.page.list |
|
460 |
this.sourceList.forEach(function (value) { |
|
461 |
this.sourceMap[value.id] = value.sourcename |
|
462 |
}, this) |
|
463 |
} else { |
|
464 |
this.sourceList = [] |
|
465 |
} |
|
466 |
}) |
|
467 |
}, |
|
468 |
getPointList () { |
|
469 |
this.$http({ |
|
470 |
url: '/data/mcs/point/list/all', |
|
471 |
method: 'get', |
|
472 |
params: { |
|
473 |
'pointtypeid': '7d9fe1db-d7a1-407a-a267-ef2edab5cb6b' |
|
474 |
} |
|
475 |
}).then(({data}) => { |
|
476 |
if (data && data.code === 0) { |
|
477 |
this.pointList = data.data |
|
478 |
this.pointList.forEach(function (value) { |
|
479 |
this.pointMap[value.id] = value.pointname |
|
480 |
this.pointCodeMap[value.pointno] = value.pointname |
|
481 |
}, this) |
|
482 |
} else { |
|
483 |
this.pointList = [] |
|
484 |
} |
|
485 |
}) |
|
486 |
}, |
|
487 |
changePointtype (value) { |
|
488 |
this.dataForm.pointtypename = this.pointtypeMap[value] |
|
489 |
}, |
|
490 |
deleteExpressionRow (index, rows) { |
|
491 |
rows.splice(index, 1) |
|
492 |
}, |
|
493 |
addExpressionRow (index, rows) { |
|
494 |
let row = JSON.parse(JSON.stringify(rows[index])) |
|
495 |
rows.splice(index, 0, row) |
|
496 |
}, |
|
497 |
// 表单提交 |
|
498 |
dataFormSubmit () { |
|
499 |
this.$refs['dataForm'].validate((valid) => { |
|
500 |
if (valid) { |
|
501 |
if (this.expressionList && this.expressionList.length > 0) { |
|
502 |
let expression = '' |
|
503 |
for (let i = 0; i < this.expressionList.length; i++) { |
|
504 |
let value = this.expressionList[i] |
|
505 |
expression = expression + value.point + (i === (this.expressionList.length - 1) ? '' : value.operator) |
|
506 |
} |
|
507 |
this.dataForm.mathPoint.expression = expression |
|
508 |
} else { |
|
509 |
this.dataForm.mathPoint.expression = '' |
|
510 |
} |
|
511 |
this.$http({ |
|
512 |
url: `/data/mcs/point/${!this.dataForm.id ? 'save' : 'update'}`, |
|
513 |
method: 'post', |
|
514 |
data: this.$http.adornData({ |
|
515 |
pointtypename: this.dataForm.pointtypename, |
|
516 |
point: this.dataForm.point, |
|
517 |
mathPoint: this.dataForm.mathPoint, |
|
518 |
measurePoint: this.dataForm.measurePoint |
|
519 |
}) |
|
520 |
}).then(({data}) => { |
|
521 |
if (data && data.code === 0) { |
|
522 |
this.$message({ |
|
523 |
message: '操作成功', |
|
524 |
type: 'success', |
|
525 |
duration: 1500, |
|
526 |
onClose: () => { |
|
527 |
this.visible = false |
|
528 |
this.$emit('refreshDataList') |
|
529 |
} |
|
530 |
}) |
|
531 |
} else { |
|
532 |
this.$message.error(data.msg) |
|
533 |
} |
|
534 |
}) |
|
535 |
} |
|
536 |
}) |
|
537 |
} |
|
538 |
} |
|
539 |
} |
|
540 |
</script> |
|
541 |
<style> |
|
542 |
.el-select { |
|
543 |
width:100% |
|
544 |
} |
|
545 |
</style> |
|
546 |
|