提交 | 用户 | 时间
|
850106
|
1 |
<template> |
H |
2 |
<el-dialog |
|
3 |
:title="!dataForm.id ? '新增' : '修改'" |
|
4 |
:close-on-click-modal="false" |
|
5 |
:width="dialogWidth" |
|
6 |
:visible.sync="visible"> |
|
7 |
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="100px"> |
|
8 |
<el-row :gutter="20"> |
|
9 |
<el-col :span="12"> |
|
10 |
<el-form-item label="采集点名称" prop="point.pointname"> |
|
11 |
<el-input v-model="dataForm.point.pointname" placeholder="采集点名称" maxlength="50" clearable></el-input> |
|
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 |
<el-input v-model="dataForm.point.pointno" placeholder="采集点名称" maxlength="50" disabled></el-input> |
|
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 |
<el-select v-model="dataForm.point.pointtypeid" placeholder="点类型" maxlength="36" |
|
24 |
:disabled="!!dataForm.id" |
|
25 |
@change="changePointtype"> |
|
26 |
<el-option |
|
27 |
v-for="item in pointtypeList" |
|
28 |
:key="item.id" |
|
29 |
:label="item.descp" |
|
30 |
:value="item.id"> |
|
31 |
</el-option> |
|
32 |
</el-select> |
|
33 |
</el-form-item> |
|
34 |
</el-col> |
|
35 |
<el-col :span="12"> |
|
36 |
<el-form-item label="采集频率" prop="point.minfreqid"> |
|
37 |
<el-select v-model="dataForm.point.minfreqid" placeholder="采集频率" maxlength="36" clearable> |
|
38 |
<el-option |
|
39 |
v-for="item in minfreqList" |
|
40 |
:key="item.id" |
|
41 |
:label="item.minfreqname" |
|
42 |
:value="item.id"> |
|
43 |
</el-option> |
|
44 |
</el-select> |
|
45 |
</el-form-item> |
|
46 |
</el-col> |
|
47 |
</el-row> |
|
48 |
<el-row :gutter="20"> |
|
49 |
<el-col :span="12"> |
|
50 |
<el-form-item label="存储类型" prop="point.storetypeid"> |
|
51 |
<el-select v-model="dataForm.point.storetypeid" placeholder="存储类型" maxlength="36" clearable> |
|
52 |
<el-option |
|
53 |
v-for="item in storetypeList" |
|
54 |
:key="item.id" |
|
55 |
:label="item.storetypename" |
|
56 |
:value="item.id"> |
|
57 |
</el-option> |
|
58 |
</el-select> |
|
59 |
</el-form-item> |
|
60 |
</el-col> |
|
61 |
<el-col :span="12"> |
|
62 |
<el-form-item label="单位" prop="point.unit"> |
|
63 |
<el-input v-model="dataForm.point.unit" placeholder="单位" maxlength="16" clearable></el-input> |
|
64 |
</el-form-item> |
|
65 |
</el-col> |
|
66 |
</el-row> |
|
67 |
<el-row :gutter="20"> |
|
68 |
<el-col :span="12"> |
|
69 |
<el-form-item label="逻辑上限" prop="point.logicmax"> |
|
70 |
<el-input v-model="dataForm.point.logicmax" placeholder="逻辑上限" maxlength="19" clearable></el-input> |
|
71 |
</el-form-item> |
|
72 |
</el-col> |
|
73 |
<el-col :span="12"> |
|
74 |
<el-form-item label="逻辑下限" prop="point.logicmin"> |
|
75 |
<el-input v-model="dataForm.point.logicmin" placeholder="逻辑下限" maxlength="19" clearable></el-input> |
|
76 |
</el-form-item> |
|
77 |
</el-col> |
|
78 |
</el-row> |
|
79 |
<el-row :gutter="20"> |
|
80 |
<el-col :span="12"> |
|
81 |
<el-form-item label="最大值" prop="point.maxvalue"> |
|
82 |
<el-input v-model="dataForm.point.maxvalue" placeholder="最大值" maxlength="19" clearable></el-input> |
|
83 |
</el-form-item> |
|
84 |
</el-col> |
|
85 |
<el-col :span="12"> |
|
86 |
<el-form-item label="最小值" prop="point.minvalue"> |
|
87 |
<el-input v-model="dataForm.point.minvalue" placeholder="最小值" maxlength="19" clearable></el-input> |
|
88 |
</el-form-item> |
|
89 |
</el-col> |
|
90 |
</el-row> |
|
91 |
<el-row :gutter="20"> |
|
92 |
<el-col :span="12"> |
|
93 |
<el-form-item label="缺省值" prop="point.defaultvalue"> |
|
94 |
<el-input v-model="dataForm.point.defaultvalue" placeholder="缺省值" maxlength="19" clearable></el-input> |
|
95 |
</el-form-item> |
|
96 |
</el-col> |
|
97 |
<el-col :span="12"> |
|
98 |
<el-form-item label="单位换算" prop="point.unittransfactor"> |
|
99 |
<el-input v-model="dataForm.point.unittransfactor" placeholder="单位换算" maxlength="5" clearable></el-input> |
|
100 |
</el-form-item> |
|
101 |
</el-col> |
|
102 |
</el-row> |
|
103 |
<el-row :gutter="20" v-if="dataForm.pointtypename === 'MEASURE POINT' || dataForm.pointtypename === 'MATHVARIABLE'"> |
|
104 |
<el-col :span="12"> |
|
105 |
<el-form-item label="采样范围" prop="point.dimension"> |
|
106 |
<el-input v-model="dataForm.point.dimension" placeholder="采样范围" maxlength="50" clearable></el-input> |
|
107 |
</el-form-item> |
|
108 |
</el-col> |
|
109 |
</el-row> |
|
110 |
<el-row :gutter="20" v-if="dataForm.pointtypename === 'MEASURE POINT'"> |
|
111 |
<el-col :span="12"> |
|
112 |
<el-form-item label="TAG编号" prop="measurePoint.tagno"> |
|
113 |
<el-input v-model="dataForm.measurePoint.tagno" placeholder="TAG编号" maxlength="50" clearable></el-input> |
|
114 |
</el-form-item> |
|
115 |
</el-col> |
|
116 |
<el-col :span="12"> |
|
117 |
<el-form-item label="数据类型" prop="measurePoint.datatypeid"> |
|
118 |
<el-select v-model="dataForm.measurePoint.datatypeid" placeholder="数据类型" maxlength="36" clearable> |
|
119 |
<el-option |
|
120 |
v-for="item in datatypeList" |
|
121 |
:key="item.id" |
|
122 |
:label="item.descp" |
|
123 |
:value="item.id"> |
|
124 |
</el-option> |
|
125 |
</el-select> |
|
126 |
</el-form-item> |
|
127 |
</el-col> |
|
128 |
</el-row> |
|
129 |
<el-row :gutter="20" v-if="dataForm.pointtypename === 'MEASURE POINT'"> |
|
130 |
<el-col :span="12"> |
|
131 |
<el-form-item label="数据源" prop="measurePoint.sourceid"> |
|
132 |
<el-select v-model="dataForm.measurePoint.sourceid" placeholder="数据源" maxlength="36" clearable> |
|
133 |
<el-option |
|
134 |
v-for="item in sourceList" |
|
135 |
:key="item.id" |
|
136 |
:label="item.sourcename" |
|
137 |
:value="item.id"> |
|
138 |
</el-option> |
|
139 |
</el-select> |
|
140 |
</el-form-item> |
|
141 |
</el-col> |
|
142 |
</el-row> |
|
143 |
<el-row :gutter="20" v-if="dataForm.pointtypename === 'CALCULATE POINT' || dataForm.pointtypename === 'MATHVARIABLE'"> |
|
144 |
<el-col :span="24"> |
|
145 |
<el-form-item label="表达式"> |
|
146 |
<el-table |
|
147 |
:data="expressionList" |
|
148 |
border |
|
149 |
style="width: 100%"> |
|
150 |
<el-table-column |
|
151 |
type="index" |
|
152 |
align="center" |
|
153 |
width="50" |
|
154 |
label="序号"> |
|
155 |
</el-table-column> |
|
156 |
<el-table-column |
|
157 |
prop="" |
|
158 |
label="左括号" |
|
159 |
width="120" |
|
160 |
align="center"> |
|
161 |
<template slot-scope="scope"> |
|
162 |
<el-input |
|
163 |
size="mini" |
|
164 |
v-model="scope.row.parenthesesLeft" |
|
165 |
placeholder="" |
|
166 |
readonly |
|
167 |
maxlength="16"> |
|
168 |
<el-button slot="prepend" @click="addParenthesesLeft(scope.$index, scope.row)">+</el-button> |
|
169 |
<el-button slot="append" @click="removeParenthesesLeft(scope.$index, scope.row)">-</el-button> |
|
170 |
</el-input> |
|
171 |
</template> |
|
172 |
</el-table-column> |
|
173 |
<el-table-column |
|
174 |
prop="" |
|
175 |
label="采集点" |
|
176 |
align="center"> |
|
177 |
<template slot-scope="scope"> |
|
178 |
<el-select |
|
179 |
size="mini" |
|
180 |
v-model="scope.row.point" |
|
181 |
filterable |
|
182 |
placeholder="请选择"> |
|
183 |
<el-option |
|
184 |
v-for="(item, index) in pointList" |
|
185 |
:key="index" |
|
186 |
:label="item.pointname" |
|
187 |
:value="item.pointno"> |
|
188 |
</el-option> |
|
189 |
</el-select> |
|
190 |
</template> |
|
191 |
</el-table-column> |
|
192 |
<el-table-column |
|
193 |
prop="" |
|
194 |
label="运算值" |
|
195 |
align="center"> |
|
196 |
<template slot-scope="scope"> |
|
197 |
<el-input |
|
198 |
size="mini" |
|
199 |
v-model="scope.row.point" |
|
200 |
placeholder="运算值" |
|
201 |
maxlength="16" |
|
202 |
clearable> |
|
203 |
</el-input> |
|
204 |
</template> |
|
205 |
</el-table-column> |
|
206 |
<el-table-column |
|
207 |
prop="" |
|
208 |
label="右括号" |
|
209 |
width="120" |
|
210 |
align="center"> |
|
211 |
<template slot-scope="scope"> |
|
212 |
<el-input |
|
213 |
size="mini" |
|
214 |
v-model="scope.row.parenthesesRight" |
|
215 |
placeholder="" |
|
216 |
readonly |
|
217 |
maxlength="16"> |
|
218 |
<el-button slot="prepend" @click="addParenthesesRight(scope.$index, scope.row, ')')">+</el-button> |
|
219 |
<el-button slot="append" @click="removeParenthesesRight(scope.$index, scope.row)">-</el-button> |
|
220 |
</el-input> |
|
221 |
</template> |
|
222 |
</el-table-column> |
|
223 |
<el-table-column |
|
224 |
prop="" |
|
225 |
label="运算符" |
|
226 |
width="90" |
|
227 |
align="center"> |
|
228 |
<template slot-scope="scope"> |
|
229 |
<el-select size="mini" v-model="scope.row.operator" clearable placeholder="请选择"> |
|
230 |
<el-option |
|
231 |
v-for="item in operatorList" |
|
232 |
:key="item" |
|
233 |
:label="item" |
|
234 |
:value="item"> |
|
235 |
</el-option> |
|
236 |
</el-select> |
|
237 |
</template> |
|
238 |
</el-table-column> |
|
239 |
<el-table-column |
|
240 |
prop="" |
|
241 |
label="操作" |
|
242 |
width="100" |
|
243 |
align="center"> |
|
244 |
<template slot-scope="scope"> |
|
245 |
<el-button |
|
246 |
@click.native.prevent="addExpressionRow(scope.$index, expressionList)" |
|
247 |
type="text" |
|
248 |
size="small"> |
|
249 |
添加 |
|
250 |
</el-button> |
|
251 |
<el-button |
|
252 |
@click.native.prevent="deleteExpressionRow(scope.$index, expressionList)" |
|
253 |
type="text" |
|
254 |
size="small"> |
|
255 |
删除 |
|
256 |
</el-button> |
|
257 |
</template> |
|
258 |
</el-table-column> |
|
259 |
</el-table> |
|
260 |
</el-form-item> |
|
261 |
</el-col> |
|
262 |
</el-row> |
|
263 |
</el-form> |
|
264 |
<span slot="footer" class="dialog-footer"> |
|
265 |
<el-button :loading="loading" @click="visible = false">取消</el-button> |
|
266 |
<el-button :loading="loading" type="primary" @click="dataFormSubmit()">确定</el-button> |
|
267 |
</span> |
|
268 |
</el-dialog> |
|
269 |
</template> |
|
270 |
|
|
271 |
<script> |
|
272 |
import { isPositiveInteger, isPositiveNum } from '@/utils/validate' |
|
273 |
export default { |
|
274 |
data () { |
|
275 |
let validIsPositiveInteger = (rule, value, callback) => { |
|
276 |
if (value && !isPositiveInteger(value)) { |
|
277 |
callback(new Error('应该为正整数')) |
|
278 |
} else { |
|
279 |
callback() |
|
280 |
} |
|
281 |
} |
|
282 |
let validIsPositiveNum = (rule, value, callback) => { |
|
283 |
if (value && !isPositiveNum(value)) { |
|
284 |
callback(new Error('应该为正数')) |
|
285 |
} else { |
|
286 |
callback() |
|
287 |
} |
|
288 |
} |
|
289 |
return { |
|
290 |
loading: true, |
|
291 |
dialogWidth: 0, |
|
292 |
pointtypeList: [], |
|
293 |
pointtypeMap: {}, |
|
294 |
minfreqList: [], |
|
295 |
storetypeList: [], |
|
296 |
datatypeList: [], |
|
297 |
sourceList: [], |
|
298 |
expressionList: [], |
|
299 |
pointList: [], |
|
300 |
pointMap: {}, |
|
301 |
operatorList: ['+', '-', '*', '/'], |
|
302 |
visible: false, |
|
303 |
roleList: [], |
|
304 |
dataForm: { |
|
305 |
id: 0, |
|
306 |
pointtypename: '', |
|
307 |
point: { |
|
308 |
id: '', |
|
309 |
pointno: '', |
|
310 |
pointname: '', |
|
311 |
pointtypeid: '', |
|
312 |
minfreqid: '', |
|
313 |
unit: '', |
|
314 |
dimension: 1, |
|
315 |
descp: '', |
|
316 |
defaultvalue: '', |
|
317 |
maxvalue: '', |
|
318 |
minvalue: '', |
|
319 |
storetypeid: '', |
|
320 |
logicmax: '', |
|
321 |
logicmin: '', |
|
322 |
unittransfactor: '', |
|
323 |
iscollect: '' |
|
324 |
}, |
|
325 |
mathPoint: { |
|
326 |
id: '', |
|
327 |
pointid: '', |
|
328 |
expression: '' |
|
329 |
}, |
|
330 |
measurePoint: { |
|
331 |
id: '', |
|
332 |
pointid: '', |
|
333 |
tagno: '', |
|
334 |
datatypeid: '', |
|
335 |
sourceid: '', |
|
336 |
defaultvalue: '', |
|
337 |
maxvalue: '', |
|
338 |
minvalue: '' |
|
339 |
} |
|
340 |
}, |
|
341 |
dataRule: { |
|
342 |
'point.pointname': [ |
|
343 |
{ required: true, message: '名称不能为空', trigger: 'blur' } |
|
344 |
], |
|
345 |
'point.pointtypeid': [ |
|
346 |
{ required: true, message: '点类型不能为空', trigger: 'blur' } |
|
347 |
], |
|
348 |
'point.minfreqid': [ |
|
349 |
{ required: true, message: '采集频率不能为空', trigger: 'blur' } |
|
350 |
], |
|
351 |
'point.storetypeid': [ |
|
352 |
{ required: true, message: '存储类型不能为空', trigger: 'blur' } |
|
353 |
], |
|
354 |
'point.defaultvalue': [ |
|
355 |
{ required: true, message: '缺省值不能为空', trigger: 'blur' } |
|
356 |
], |
|
357 |
'measurePoint.tagno': [ |
|
358 |
{ required: true, message: '名称不能为空', trigger: 'blur' } |
|
359 |
], |
|
360 |
'measurePoint.datatypeid': [ |
|
361 |
{ required: true, message: '点类型不能为空', trigger: 'blur' } |
|
362 |
], |
|
363 |
'measurePoint.sourceid': [ |
|
364 |
{ required: true, message: '采集频率不能为空', trigger: 'blur' } |
|
365 |
], |
|
366 |
'point.dimension': [ |
|
367 |
{ required: true, message: '采样范围不能为空', trigger: 'blur' }, |
|
368 |
{ validator: validIsPositiveInteger, trigger: 'blur' } |
|
369 |
], |
|
370 |
'point.unittransfactor': [ |
|
371 |
{ validator: validIsPositiveInteger, trigger: 'blur' } |
|
372 |
], |
|
373 |
'point.maxvalue': [ |
|
374 |
{ validator: validIsPositiveNum, trigger: 'blur' } |
|
375 |
], |
|
376 |
'point.minvalue': [ |
|
377 |
{ validator: validIsPositiveNum, trigger: 'blur' } |
|
378 |
], |
|
379 |
'point.logicmax': [ |
|
380 |
{ validator: validIsPositiveNum, trigger: 'blur' } |
|
381 |
], |
|
382 |
'point.logicmin': [ |
|
383 |
{ validator: validIsPositiveNum, trigger: 'blur' } |
|
384 |
] |
|
385 |
} |
|
386 |
} |
|
387 |
}, |
|
388 |
created () { |
|
389 |
this.setDialogWidth() |
|
390 |
}, |
|
391 |
mounted () { |
|
392 |
window.onresize = () => { |
|
393 |
return (() => { |
|
394 |
this.setDialogWidth() |
|
395 |
})() |
|
396 |
} |
|
397 |
}, |
|
398 |
methods: { |
|
399 |
setDialogWidth () { |
|
400 |
let val = document.body.clientWidth |
|
401 |
const def = 1300 // 默认宽度 |
|
402 |
if (val < def) { |
|
403 |
this.dialogWidth = '80%' |
|
404 |
} else { |
|
405 |
this.dialogWidth = '60%' |
|
406 |
} |
|
407 |
}, |
|
408 |
init (id, pointtypename) { |
|
409 |
this.getPointtypeList(id) |
|
410 |
this.getMinfreqList() |
|
411 |
this.getStoretypeList() |
|
412 |
this.getDatatypeList() |
|
413 |
this.getSourceList() |
|
414 |
this.getPointList() |
|
415 |
this.dataForm.id = id || 0 |
|
416 |
this.loading = true |
|
417 |
this.dataForm.pointtypename = pointtypename || '' |
|
418 |
this.visible = true |
|
419 |
this.$nextTick(() => { |
|
420 |
this.$refs['dataForm'].resetFields() |
|
421 |
this.resetFields(this.dataForm) |
|
422 |
this.setDefaultFields(id, pointtypename) |
|
423 |
}) |
|
424 |
if (id) { |
|
425 |
this.$http({ |
|
426 |
url: `/data/data/point/info/${this.dataForm.id}`, |
|
427 |
method: 'get', |
|
428 |
params: this.$http.adornParams() |
|
429 |
}).then(({data}) => { |
|
430 |
this.expressionList = [] |
|
431 |
if (data && data.code === 0) { |
|
432 |
for (let key in this.dataForm.point) { |
|
433 |
this.dataForm.point[key] = '' |
|
434 |
if (data.point.point[key] || data.point.point[key] === 0) { |
|
435 |
this.dataForm.point[key] = data.point.point[key] |
|
436 |
} |
|
437 |
} |
|
438 |
if (data.point.mathPoint) { |
|
439 |
for (let key in this.dataForm.mathPoint) { |
|
440 |
this.dataForm.mathPoint[key] = '' |
|
441 |
if (data.point.mathPoint[key] || data.point.mathPoint[key] === 0) { |
|
442 |
this.dataForm.mathPoint[key] = data.point.mathPoint[key] |
|
443 |
} |
|
444 |
} |
|
445 |
if (this.dataForm.mathPoint.expression) { |
|
446 |
let expression = this.dataForm.mathPoint.expression |
|
447 |
do { |
|
448 |
let indexArray = [expression.indexOf('+'), expression.indexOf('-'), expression.indexOf('*'), expression.indexOf('/')].sort(this.numAscSort) |
|
449 |
if (indexArray[indexArray.length - 1] !== -1) { |
|
450 |
let endIndex = 0 |
|
451 |
for (let key in indexArray) { |
|
452 |
if (indexArray[key] > -1) { |
|
453 |
endIndex = indexArray[key] |
|
454 |
break |
|
455 |
} |
|
456 |
} |
|
457 |
let pointStr = expression.substring(0, endIndex) |
|
458 |
let operator = expression.substr(endIndex, 1) |
|
459 |
let indexOfParenthesesLeft = pointStr.indexOf('(') |
|
460 |
let lastIndexOfParenthesesLeft = pointStr.lastIndexOf('(') |
|
461 |
let parenthesesLeft = '' |
|
462 |
if (indexOfParenthesesLeft !== -1 && lastIndexOfParenthesesLeft !== -1) { |
|
463 |
parenthesesLeft = pointStr.substring(indexOfParenthesesLeft, lastIndexOfParenthesesLeft + 1) |
|
464 |
pointStr = pointStr.substring(lastIndexOfParenthesesLeft + 1) |
|
465 |
} |
|
466 |
|
|
467 |
let indexOfParenthesesRight = pointStr.indexOf(')') |
|
468 |
let lastIndexOfParenthesesRight = pointStr.lastIndexOf(')') |
|
469 |
let parenthesesRight = '' |
|
470 |
if (indexOfParenthesesRight !== -1 && lastIndexOfParenthesesRight !== -1) { |
|
471 |
parenthesesRight = pointStr.substring(indexOfParenthesesRight, lastIndexOfParenthesesRight + 1) |
|
472 |
pointStr = pointStr.substring(0, indexOfParenthesesRight) |
|
473 |
} |
|
474 |
this.expressionList.push({ |
|
475 |
parenthesesLeft: parenthesesLeft, |
|
476 |
point: pointStr, |
|
477 |
parenthesesRight: parenthesesRight, |
|
478 |
operator: operator |
|
479 |
}) |
|
480 |
expression = expression.substring(endIndex + 1) |
|
481 |
} else { |
|
482 |
let pointStr = expression |
|
483 |
let indexOfParenthesesLeft = pointStr.indexOf('(') |
|
484 |
let lastIndexOfParenthesesLeft = pointStr.lastIndexOf('(') |
|
485 |
let parenthesesLeft = '' |
|
486 |
if (indexOfParenthesesLeft !== -1 && lastIndexOfParenthesesLeft !== -1) { |
|
487 |
parenthesesLeft = pointStr.substring(indexOfParenthesesLeft, lastIndexOfParenthesesLeft + 1) |
|
488 |
pointStr = pointStr.substring(lastIndexOfParenthesesLeft + 1) |
|
489 |
} |
|
490 |
let indexOfParenthesesRight = pointStr.indexOf(')') |
|
491 |
let lastIndexOfParenthesesRight = pointStr.lastIndexOf(')') |
|
492 |
let parenthesesRight = '' |
|
493 |
if (indexOfParenthesesRight !== -1 && lastIndexOfParenthesesRight !== -1) { |
|
494 |
parenthesesRight = pointStr.substring(indexOfParenthesesRight, lastIndexOfParenthesesRight + 1) |
|
495 |
pointStr = pointStr.substring(0, indexOfParenthesesRight) |
|
496 |
} |
|
497 |
this.expressionList.push({ |
|
498 |
parenthesesLeft: parenthesesLeft, |
|
499 |
point: pointStr, |
|
500 |
parenthesesRight: parenthesesRight, |
|
501 |
operator: '' |
|
502 |
}) |
|
503 |
expression = '' |
|
504 |
} |
|
505 |
} while (expression && expression.length > 0) |
|
506 |
} |
|
507 |
} |
|
508 |
this.dataForm.expressionList = this.expressionList |
|
509 |
if (data.point.measurePoint) { |
|
510 |
for (let key in this.dataForm.measurePoint) { |
|
511 |
this.dataForm.measurePoint[key] = data.point.measurePoint[key] || '' |
|
512 |
} |
|
513 |
} |
|
514 |
this.loading = false |
|
515 |
} |
|
516 |
}) |
|
517 |
} else { |
|
518 |
this.loading = false |
|
519 |
} |
|
520 |
}, |
|
521 |
addParenthesesLeft (index, row) { |
|
522 |
if (row.parenthesesLeft) { |
|
523 |
row.parenthesesLeft = row.parenthesesLeft + '(' |
|
524 |
} else { |
|
525 |
row.parenthesesLeft = '(' |
|
526 |
} |
|
527 |
}, |
|
528 |
removeParenthesesLeft (index, row) { |
|
529 |
if (row.parenthesesLeft) { |
|
530 |
row.parenthesesLeft = row.parenthesesLeft.substring(0, row.parenthesesLeft.length - 1) |
|
531 |
} else { |
|
532 |
row.parenthesesLeft = '' |
|
533 |
} |
|
534 |
}, |
|
535 |
addParenthesesRight (index, row) { |
|
536 |
if (row.parenthesesRight) { |
|
537 |
row.parenthesesRight = row.parenthesesRight + ')' |
|
538 |
} else { |
|
539 |
row.parenthesesRight = ')' |
|
540 |
} |
|
541 |
}, |
|
542 |
removeParenthesesRight (index, row) { |
|
543 |
if (row.parenthesesRight) { |
|
544 |
row.parenthesesRight = row.parenthesesRight.substring(0, row.parenthesesRight.length - 1) |
|
545 |
} else { |
|
546 |
row.parenthesesRight = '' |
|
547 |
} |
|
548 |
}, |
|
549 |
numAscSort (a, b) { |
|
550 |
return a - b |
|
551 |
}, |
|
552 |
resetFields (obj) { |
|
553 |
for (let key in obj) { |
|
554 |
if (key === 'pointtypename') { |
|
555 |
continue |
|
556 |
} |
|
557 |
if (obj[key] instanceof Array) { |
|
558 |
obj[key] = [] |
|
559 |
} else if (obj[key] instanceof Object) { |
|
560 |
this.resetFields(obj[key]) |
|
561 |
} else { |
|
562 |
obj[key] = '' |
|
563 |
} |
|
564 |
} |
|
565 |
}, |
|
566 |
setDefaultFields (id, pointtypename) { |
|
567 |
this.dataForm.id = id || 0 |
|
568 |
this.dataForm.pointtypename = pointtypename || '' |
|
569 |
this.dataForm.point.dimension = 1 |
|
570 |
this.expressionList = [{ |
|
571 |
parenthesesLeft: '', |
|
572 |
point: '', |
|
573 |
parenthesesRight: '', |
|
574 |
operator: '' |
|
575 |
}] |
|
576 |
}, |
|
577 |
// 获取预测项类型列表 |
|
578 |
getPointtypeList (id) { |
|
579 |
this.$http({ |
|
580 |
url: '/data/data/point-type/list', |
|
581 |
method: 'get', |
|
582 |
params: this.$http.adornParams({ |
|
583 |
'page': 1, |
|
584 |
'limit': 100 |
|
585 |
}) |
|
586 |
}).then(({data}) => { |
|
587 |
if (data && data.code === 0) { |
|
588 |
this.pointtypeList = data.page.list |
|
589 |
this.pointtypeList.forEach(function (value) { |
|
590 |
this.pointtypeMap[value.id] = value.pointtypename |
|
591 |
}, this) |
|
592 |
if (!id) { |
|
593 |
this.dataForm.point.pointtypeid = this.pointtypeList[0].id |
|
594 |
this.dataForm.pointtypename = this.pointtypeMap[this.dataForm.point.pointtypeid] |
|
595 |
} |
|
596 |
} else { |
|
597 |
this.pointtypeList = [] |
|
598 |
} |
|
599 |
}) |
|
600 |
}, |
|
601 |
getMinfreqList () { |
|
602 |
this.$http({ |
|
603 |
url: '/data/min-freq/list', |
|
604 |
method: 'get', |
|
605 |
params: this.$http.adornParams({ |
|
606 |
'page': 1, |
|
607 |
'limit': 100 |
|
608 |
}) |
|
609 |
}).then(({data}) => { |
|
610 |
if (data && data.code === 0) { |
|
611 |
this.minfreqList = data.page.list |
|
612 |
} else { |
|
613 |
this.minfreqList = [] |
|
614 |
} |
|
615 |
}) |
|
616 |
}, |
|
617 |
getStoretypeList () { |
|
618 |
this.$http({ |
|
619 |
url: '/data/data/store-type/list', |
|
620 |
method: 'get', |
|
621 |
params: this.$http.adornParams({ |
|
622 |
'page': 1, |
|
623 |
'limit': 100 |
|
624 |
}) |
|
625 |
}).then(({data}) => { |
|
626 |
if (data && data.code === 0) { |
|
627 |
this.storetypeList = data.page.list |
|
628 |
} else { |
|
629 |
this.storetypeList = [] |
|
630 |
} |
|
631 |
}) |
|
632 |
}, |
|
633 |
getDatatypeList () { |
|
634 |
this.$http({ |
|
635 |
url: '/data/data/data-type/list', |
|
636 |
method: 'get', |
|
637 |
params: this.$http.adornParams({ |
|
638 |
'page': 1, |
|
639 |
'limit': 100 |
|
640 |
}) |
|
641 |
}).then(({data}) => { |
|
642 |
if (data && data.code === 0) { |
|
643 |
this.datatypeList = data.page.list |
|
644 |
} else { |
|
645 |
this.datatypeList = [] |
|
646 |
} |
|
647 |
}) |
|
648 |
}, |
|
649 |
getSourceList () { |
|
650 |
this.$http({ |
|
651 |
url: '/data/data/data-source/list', |
|
652 |
method: 'get', |
|
653 |
params: this.$http.adornParams({ |
|
654 |
'page': 1, |
|
655 |
'limit': 100 |
|
656 |
}) |
|
657 |
}).then(({data}) => { |
|
658 |
if (data && data.code === 0) { |
|
659 |
this.sourceList = data.page.list |
|
660 |
} else { |
|
661 |
this.sourceList = [] |
|
662 |
} |
|
663 |
}) |
|
664 |
}, |
|
665 |
getPointList () { |
|
666 |
this.$http({ |
|
667 |
url: '/data/data/point/list/all', |
|
668 |
method: 'get', |
|
669 |
params: { |
|
670 |
'pointtypeid': '7d9fe1db-d7a1-407a-a267-ef2edab5cb6b' |
|
671 |
} |
|
672 |
}).then(({data}) => { |
|
673 |
if (data && data.code === 0) { |
|
674 |
this.pointList = data.data |
|
675 |
this.pointList.forEach(function (value) { |
|
676 |
this.pointMap[value.id] = value.pointname |
|
677 |
}, this) |
|
678 |
} else { |
|
679 |
this.pointList = [] |
|
680 |
} |
|
681 |
}) |
|
682 |
}, |
|
683 |
changePointtype (value) { |
|
684 |
this.dataForm.pointtypename = this.pointtypeMap[value] |
|
685 |
if (this.dataForm.pointtypename === 'CONSTANT') { |
|
686 |
this.dataRule['point.defaultvalue'][0].required = true |
|
687 |
} else { |
|
688 |
this.dataRule['point.defaultvalue'][0].required = false |
|
689 |
} |
|
690 |
}, |
|
691 |
deleteExpressionRow (index, rows) { |
|
692 |
if (!rows || rows.length === 1) { |
|
693 |
this.$message({ |
|
694 |
message: '不能全部删除!', |
|
695 |
type: 'error', |
|
696 |
duration: 1500 |
|
697 |
}) |
|
698 |
return |
|
699 |
} |
|
700 |
rows.splice(index, 1) |
|
701 |
}, |
|
702 |
addExpressionRow (index, rows) { |
|
703 |
let row = JSON.parse(JSON.stringify(rows[index])) |
|
704 |
rows.splice(index, 0, row) |
|
705 |
}, |
|
706 |
// 表单提交 |
|
707 |
dataFormSubmit () { |
|
708 |
this.$refs['dataForm'].validate((valid) => { |
|
709 |
if (valid) { |
|
710 |
if (this.dataForm.pointtypename !== 'CALCULATE POINT' && |
|
711 |
this.dataForm.pointtypename !== 'MEASURE POINT' && |
|
712 |
this.dataForm.pointtypename !== 'CONSTANT' && |
|
713 |
this.dataForm.pointtypename !== 'MATHVARIABLE') { |
|
714 |
this.$message({ |
|
715 |
message: '不支持的点类型!', |
|
716 |
type: 'error', |
|
717 |
duration: 1500 |
|
718 |
}) |
|
719 |
return |
|
720 |
} |
|
721 |
if ((this.dataForm.pointtypename === 'CALCULATE POINT' || this.dataForm.pointtypename === 'MATHVARIABLE') && |
|
722 |
this.expressionList && this.expressionList.length > 0) { |
|
723 |
let parenthesesLeftRex = /^[(]*$/ |
|
724 |
let parenthesesRightRex = /^[)]*$/ |
|
725 |
let expression = '' |
|
726 |
for (let i = 0; i < this.expressionList.length; i++) { |
|
727 |
let value = this.expressionList[i] |
|
728 |
if (!parenthesesLeftRex.test(value.parenthesesLeft)) { |
|
729 |
this.$message({ |
|
730 |
message: `第${i + 1}行左括号输入不正确!`, |
|
731 |
type: 'error', |
|
732 |
duration: 1500 |
|
733 |
}) |
|
734 |
return |
|
735 |
} |
|
736 |
if (!parenthesesRightRex.test(value.parenthesesRight)) { |
|
737 |
this.$message({ |
|
738 |
message: `第${i + 1}行右括号输入不正确!`, |
|
739 |
type: 'error', |
|
740 |
duration: 1500 |
|
741 |
}) |
|
742 |
return |
|
743 |
} |
|
744 |
if (i !== (this.expressionList.length - 1) && !value.operator) { |
|
745 |
this.$message({ |
|
746 |
message: `第${i + 1}行运算符不能为空!`, |
|
747 |
type: 'error', |
|
748 |
duration: 1500 |
|
749 |
}) |
|
750 |
return |
|
751 |
} |
|
752 |
expression = expression + value.parenthesesLeft + value.point + value.parenthesesRight + (i === (this.expressionList.length - 1) ? '' : value.operator) |
|
753 |
} |
|
754 |
this.dataForm.mathPoint.expression = expression |
|
755 |
} else { |
|
756 |
this.dataForm.mathPoint.expression = '' |
|
757 |
} |
|
758 |
this.$http({ |
|
759 |
url: `/data/data/point/${!this.dataForm.id ? 'save' : 'update'}`, |
|
760 |
method: 'post', |
|
761 |
data: this.$http.adornData({ |
|
762 |
pointtypename: this.dataForm.pointtypename, |
|
763 |
point: this.dataForm.point, |
|
764 |
mathPoint: this.dataForm.mathPoint, |
|
765 |
measurePoint: this.dataForm.measurePoint |
|
766 |
}) |
|
767 |
}).then(({data}) => { |
|
768 |
if (data && data.code === 0) { |
|
769 |
this.$message({ |
|
770 |
message: '操作成功', |
|
771 |
type: 'success', |
|
772 |
duration: 1500, |
|
773 |
onClose: () => { |
|
774 |
this.visible = false |
|
775 |
this.$emit('refreshDataList') |
|
776 |
} |
|
777 |
}) |
|
778 |
} else { |
|
779 |
this.$message.error(data.msg) |
|
780 |
} |
|
781 |
}) |
|
782 |
} |
|
783 |
}) |
|
784 |
} |
|
785 |
} |
|
786 |
} |
|
787 |
</script> |
|
788 |
<style> |
|
789 |
.el-select { |
|
790 |
width:100% |
|
791 |
} |
|
792 |
.el-input-group__append { |
|
793 |
padding: 0 5px 0 5px |
|
794 |
} |
|
795 |
.el-input-group__prepend { |
|
796 |
padding: 0 5px 0 5px |
|
797 |
} |
|
798 |
</style> |
|
799 |
|