提交 | 用户 | 时间
|
850106
|
1 |
<template> |
H |
2 |
<el-dialog |
|
3 |
:title="!dataForm.id ? '新增' : '修改'" |
|
4 |
:close-on-click-modal="false" |
|
5 |
width="60%" |
|
6 |
:visible.sync="visible"> |
|
7 |
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" |
|
8 |
label-width="100px"> |
|
9 |
<el-divider content-position="left">基本信息</el-divider> |
|
10 |
<el-row :gutter="10"> |
|
11 |
<el-col :span="12"> |
|
12 |
<el-form-item label="测点编码(自动生成)" prop="cdbm" label-width="40%"> |
|
13 |
<el-input v-model="dataForm.cdbm" maxlength="16" readonly></el-input> |
|
14 |
</el-form-item> |
|
15 |
</el-col> |
|
16 |
<el-col :span="12"> |
|
17 |
<el-form-item label="测点名称" prop="cdmc"> |
|
18 |
<el-input v-model="dataForm.cdmc" placeholder="测点名称" maxlength="40" clearable></el-input> |
|
19 |
</el-form-item> |
|
20 |
</el-col> |
|
21 |
</el-row> |
|
22 |
<el-row :gutter="20"> |
|
23 |
<el-col :span="24"> |
|
24 |
<el-form-item label="测点描述" prop="cdxxms"> |
|
25 |
<el-input v-model="dataForm.cdxxms" placeholder="测点信息描述" maxlength="100"></el-input> |
|
26 |
</el-form-item> |
|
27 |
</el-col> |
|
28 |
</el-row> |
|
29 |
<el-row :gutter="20"> |
|
30 |
<el-col :span="6"> |
|
31 |
<el-form-item label="测点类型" prop="cdlx"> |
|
32 |
<dict-select-tag v-model="dataForm.cdlx" placeholder="测点类型" dictCode="data-cdlx"/> |
|
33 |
</el-form-item> |
|
34 |
</el-col> |
|
35 |
<el-col :span="6"> |
|
36 |
<el-form-item label="读写标记" prop="dxbj"> |
|
37 |
<dict-select-tag v-model="dataForm.dxbj" placeholder="读写标记" dictCode="data-dxbj"/> |
|
38 |
</el-form-item> |
|
39 |
</el-col> |
|
40 |
<el-col :span="6"> |
|
41 |
<el-form-item label="量程下限" prop="lcxx"> |
|
42 |
<el-input v-model="dataForm.lcxx" placeholder="量程下限" maxlength="50" clearable></el-input> |
|
43 |
</el-form-item> |
|
44 |
</el-col> |
|
45 |
<el-col :span="6"> |
|
46 |
<el-form-item label="量程上限" prop="lcsx"> |
|
47 |
<el-input v-model="dataForm.lcsx" placeholder="量程上限" maxlength="50" clearable></el-input> |
|
48 |
</el-form-item> |
|
49 |
</el-col> |
|
50 |
</el-row> |
|
51 |
<el-row :gutter="20"> |
|
52 |
<el-col :span="6"> |
|
53 |
<el-form-item label="默认值" prop="mrz"> |
|
54 |
<el-input v-model="dataForm.mrz" placeholder="默认值" maxlength="50" clearable></el-input> |
|
55 |
</el-form-item> |
|
56 |
</el-col> |
|
57 |
<el-col :span="6"> |
|
58 |
<el-form-item label="数据长度" prop="sjcd"> |
|
59 |
<el-input v-model="dataForm.sjcd" placeholder="数据长度" maxlength="50" clearable></el-input> |
|
60 |
</el-form-item> |
|
61 |
</el-col> |
|
62 |
<el-col :span="6"> |
|
63 |
<el-form-item label="寄存器长度" prop="jcqcd"> |
|
64 |
<el-input v-model="dataForm.jcqcd" placeholder="寄存器长度" maxlength="50" clearable></el-input> |
|
65 |
</el-form-item> |
|
66 |
</el-col> |
|
67 |
<el-col :span="6"> |
|
68 |
<el-form-item label="大小端" prop="dxd"> |
|
69 |
<el-input v-model="dataForm.dxd" placeholder="大小端" maxlength="50" clearable></el-input> |
|
70 |
</el-form-item> |
|
71 |
</el-col> |
|
72 |
</el-row> |
|
73 |
<el-row :gutter="20"> |
|
74 |
<el-col :span="6"> |
|
75 |
<el-form-item label="掩码" prop="ym"> |
|
76 |
<el-input v-model="dataForm.ym" placeholder="掩码" maxlength="50" clearable></el-input> |
|
77 |
</el-form-item> |
|
78 |
</el-col> |
|
79 |
<el-col :span="6"> |
|
80 |
<el-form-item label="移动" prop="yd"> |
|
81 |
<dict-select-tag v-model="dataForm.yd" placeholder="移动" dictCode="data-yd"/> |
|
82 |
</el-form-item> |
|
83 |
</el-col> |
|
84 |
<el-col :span="6"> |
|
85 |
<el-form-item label="系数" prop="xs"> |
|
86 |
<el-input v-model="dataForm.xs" placeholder="系数" maxlength="50" clearable></el-input> |
|
87 |
</el-form-item> |
|
88 |
</el-col> |
|
89 |
<el-col :span="6"> |
|
90 |
<el-form-item label="偏移" prop="py"> |
|
91 |
<el-input v-model="dataForm.py" placeholder="偏移" maxlength="50" clearable></el-input> |
|
92 |
</el-form-item> |
|
93 |
</el-col> |
|
94 |
</el-row> |
|
95 |
<el-row :gutter="20"> |
|
96 |
<el-col :span="6"> |
|
97 |
<el-form-item label="基准" prop="jz"> |
|
98 |
<el-input v-model="dataForm.jz" placeholder="基准" maxlength="50" clearable></el-input> |
|
99 |
</el-form-item> |
|
100 |
</el-col> |
|
101 |
<el-col :span="6"> |
|
102 |
<el-form-item label="断言" prop="dy"> |
|
103 |
<el-input v-model="dataForm.dy" placeholder="断言" maxlength="50" clearable></el-input> |
|
104 |
</el-form-item> |
|
105 |
</el-col> |
|
106 |
<el-col :span="6"> |
|
107 |
<el-form-item label="有无符号" prop="ywfh"> |
|
108 |
<dict-select-tag v-model="dataForm.ywfh" placeholder="有无符号" dictCode="data-ywfh"/> |
|
109 |
</el-form-item> |
|
110 |
</el-col> |
|
111 |
<el-col :span="6"> |
|
112 |
<el-form-item label="小数位数" prop="xsws"> |
|
113 |
<el-input v-model="dataForm.xsws" placeholder="小数位数" maxlength="50" clearable></el-input> |
|
114 |
</el-form-item> |
|
115 |
</el-col> |
|
116 |
</el-row> |
|
117 |
<el-row :gutter="20"> |
|
118 |
<el-col :span="6"> |
|
119 |
<el-form-item label="结果类型" prop="cljglx"> |
|
120 |
<el-input v-model="dataForm.cljglx" placeholder="测量结果类型" maxlength="50" clearable></el-input> |
|
121 |
</el-form-item> |
|
122 |
</el-col> |
|
123 |
<el-col :span="6"> |
|
124 |
<el-form-item label="累积量" prop="ljl"> |
|
125 |
<dict-select-tag v-model="dataForm.ljl" placeholder="累积量" dictCode="data-ljl"/> |
|
126 |
</el-form-item> |
|
127 |
</el-col> |
|
128 |
<el-col :span="6"> |
|
129 |
<el-form-item label="计量单位" prop="jldw"> |
|
130 |
<el-input v-model="dataForm.jldw" placeholder="计量单位" maxlength="50" clearable></el-input> |
|
131 |
</el-form-item> |
|
132 |
</el-col> |
|
133 |
<el-col :span="6"> |
|
134 |
<el-form-item label="源变量" prop="ybl"> |
|
135 |
<el-input v-model="dataForm.ybl" placeholder="源变量" maxlength="50" clearable></el-input> |
|
136 |
</el-form-item> |
|
137 |
</el-col> |
|
138 |
</el-row> |
|
139 |
<el-row :gutter="20"> |
|
140 |
<el-col :span="6"> |
|
141 |
<el-form-item label="控制器ID" prop="kzqId"> |
|
142 |
<el-input v-model="dataForm.kzqId" placeholder="控制器ID" maxlength="50" clearable></el-input> |
|
143 |
</el-form-item> |
|
144 |
</el-col> |
|
145 |
<el-col :span="6"> |
|
146 |
<el-form-item label="逻辑测点" prop="ljcd"> |
|
147 |
<dict-select-tag v-model="dataForm.ljcd" placeholder="逻辑测点" dictCode="data-ljcd"/> |
|
148 |
</el-form-item> |
|
149 |
</el-col> |
|
150 |
<el-col :span="6"> |
|
151 |
<el-form-item label="报警下限" prop="bjxx"> |
|
152 |
<el-input v-model="dataForm.bjxx" placeholder="报警下限" maxlength="50" clearable></el-input> |
|
153 |
</el-form-item> |
|
154 |
</el-col> |
|
155 |
<el-col :span="6"> |
|
156 |
<el-form-item label="报警上限" prop="bjsx"> |
|
157 |
<el-input v-model="dataForm.bjsx" placeholder="报警上限" maxlength="50" clearable></el-input> |
|
158 |
</el-form-item> |
|
159 |
</el-col> |
|
160 |
</el-row> |
|
161 |
<!--采集配置--> |
|
162 |
<el-divider content-position="left">采集配置</el-divider> |
|
163 |
<el-row :gutter="20"> |
|
164 |
<el-col :span="6"> |
|
165 |
<el-form-item label="采集类型" prop="pointTypeId"> |
|
166 |
<el-select v-model="dataForm.pointTypeId" placeholder="采集类型" @change="changePointtype" clearable> |
|
167 |
<el-option |
|
168 |
v-for="item in pointtypeList" |
|
169 |
:key="item.id" |
|
170 |
:label="item.descp" |
|
171 |
:value="item.id"> |
|
172 |
</el-option> |
|
173 |
</el-select> |
|
174 |
</el-form-item> |
|
175 |
</el-col> |
|
176 |
<el-col :span="6"> |
|
177 |
<el-form-item label="采集频率" prop="minfreqid"> |
|
178 |
<el-select v-model="dataForm.minfreqid" placeholder="采集频率" maxlength="36" clearable> |
|
179 |
<el-option |
|
180 |
v-for="item in minfreqList" |
|
181 |
:key="item.id" |
|
182 |
:label="item.minfreqname" |
|
183 |
:value="item.id"> |
|
184 |
</el-option> |
|
185 |
</el-select> |
|
186 |
</el-form-item> |
|
187 |
</el-col> |
|
188 |
</el-row> |
|
189 |
|
|
190 |
<!--计量点--> |
|
191 |
<el-row :gutter="20" v-if="dataForm.pointtypename === 'MEASURE'"> |
|
192 |
<el-col :span="12"> |
|
193 |
<el-form-item label="数据源" prop="measurePoint.sourceid"> |
|
194 |
<el-select v-model="dataForm.measurePoint.sourceid" placeholder="数据源" maxlength="36" @change="sourceChanged" clearable> |
|
195 |
<el-option |
|
196 |
v-for="item in httpList" |
|
197 |
:key="item.id" |
|
198 |
:label="item.code" |
|
199 |
:value="item.id"> |
|
200 |
</el-option> |
|
201 |
</el-select> |
|
202 |
</el-form-item> |
|
203 |
</el-col> |
|
204 |
<el-col :span="12"> |
|
205 |
<el-form-item label="TAG编码" prop="measurePoint.tagno"> |
|
206 |
<el-select v-model="dataForm.measurePoint.tagno" placeholder="请选择Tag编码" maxlength="36" clearable> |
|
207 |
<el-option |
|
208 |
v-for="item in tagList" |
|
209 |
:key="item.tagCode" |
|
210 |
:label="item.tagName + '(' + item.tagCode + ')'" |
|
211 |
:value="item.tagCode"> |
|
212 |
</el-option> |
|
213 |
</el-select> |
|
214 |
</el-form-item> |
|
215 |
</el-col> |
|
216 |
</el-row> |
|
217 |
|
|
218 |
<!--计算点--> |
|
219 |
<el-row :gutter="20" v-if="dataForm.pointtypename === 'CALCULATE'"> |
|
220 |
<el-col :span="24"> |
|
221 |
<el-form-item label="表达式"> |
|
222 |
<el-table |
|
223 |
:data="expressionList" |
|
224 |
border |
|
225 |
style="width: 100%"> |
|
226 |
<el-table-column |
|
227 |
type="index" |
|
228 |
align="center" |
|
229 |
width="50" |
|
230 |
label="序号"> |
|
231 |
</el-table-column> |
|
232 |
<el-table-column |
|
233 |
prop="" |
|
234 |
label="左括号" |
|
235 |
width="120" |
|
236 |
align="center"> |
|
237 |
<template slot-scope="scope"> |
|
238 |
<el-input |
|
239 |
size="mini" |
|
240 |
v-model="scope.row.parenthesesLeft" |
|
241 |
placeholder="" |
|
242 |
readonly |
|
243 |
maxlength="16"> |
|
244 |
<el-button slot="prepend" @click="addParenthesesLeft(scope.$index, scope.row)">+</el-button> |
|
245 |
<el-button slot="append" @click="removeParenthesesLeft(scope.$index, scope.row)">-</el-button> |
|
246 |
</el-input> |
|
247 |
</template> |
|
248 |
</el-table-column> |
|
249 |
<el-table-column |
|
250 |
prop="" |
|
251 |
label="采集点" |
|
252 |
align="center"> |
|
253 |
<template slot-scope="scope"> |
|
254 |
<el-select |
|
255 |
size="mini" |
|
256 |
v-model="scope.row.point" |
|
257 |
filterable |
|
258 |
placeholder="请选择"> |
|
259 |
<el-option |
|
260 |
v-for="(item, index) in pointList" |
|
261 |
:key="index" |
|
262 |
:label="item.cdmc" |
|
263 |
:value="item.cdbm"> |
|
264 |
</el-option> |
|
265 |
</el-select> |
|
266 |
</template> |
|
267 |
</el-table-column> |
|
268 |
<el-table-column |
|
269 |
prop="" |
|
270 |
label="运算值" |
|
271 |
align="center"> |
|
272 |
<template slot-scope="scope"> |
|
273 |
<el-input |
|
274 |
size="mini" |
|
275 |
v-model="scope.row.point" |
|
276 |
placeholder="运算值" |
|
277 |
maxlength="16" |
|
278 |
clearable> |
|
279 |
</el-input> |
|
280 |
</template> |
|
281 |
</el-table-column> |
|
282 |
<el-table-column |
|
283 |
prop="" |
|
284 |
label="右括号" |
|
285 |
width="120" |
|
286 |
align="center"> |
|
287 |
<template slot-scope="scope"> |
|
288 |
<el-input |
|
289 |
size="mini" |
|
290 |
v-model="scope.row.parenthesesRight" |
|
291 |
placeholder="" |
|
292 |
readonly |
|
293 |
maxlength="16"> |
|
294 |
<el-button slot="prepend" @click="addParenthesesRight(scope.$index, scope.row, ')')">+</el-button> |
|
295 |
<el-button slot="append" @click="removeParenthesesRight(scope.$index, scope.row)">-</el-button> |
|
296 |
</el-input> |
|
297 |
</template> |
|
298 |
</el-table-column> |
|
299 |
<el-table-column |
|
300 |
prop="" |
|
301 |
label="运算符" |
|
302 |
width="90" |
|
303 |
align="center"> |
|
304 |
<template slot-scope="scope"> |
|
305 |
<el-select size="mini" v-model="scope.row.operator" clearable placeholder="请选择"> |
|
306 |
<el-option |
|
307 |
v-for="item in operatorList" |
|
308 |
:key="item" |
|
309 |
:label="item" |
|
310 |
:value="item"> |
|
311 |
</el-option> |
|
312 |
</el-select> |
|
313 |
</template> |
|
314 |
</el-table-column> |
|
315 |
<el-table-column |
|
316 |
prop="" |
|
317 |
label="操作" |
|
318 |
width="100" |
|
319 |
align="center"> |
|
320 |
<template slot-scope="scope"> |
|
321 |
<el-button |
|
322 |
@click.native.prevent="addExpressionRow(scope.$index, expressionList)" |
|
323 |
type="text" |
|
324 |
size="small"> |
|
325 |
添加 |
|
326 |
</el-button> |
|
327 |
<el-button |
|
328 |
@click.native.prevent="deleteExpressionRow(scope.$index, expressionList)" |
|
329 |
type="text" |
|
330 |
size="small"> |
|
331 |
删除 |
|
332 |
</el-button> |
|
333 |
</template> |
|
334 |
</el-table-column> |
|
335 |
</el-table> |
|
336 |
</el-form-item> |
|
337 |
</el-col> |
|
338 |
</el-row> |
|
339 |
</el-form> |
|
340 |
<span slot="footer" class="dialog-footer"> |
|
341 |
<el-button :loading="loading" @click="visible = false">取消</el-button> |
|
342 |
<el-button :loading="loading" type="primary" @click="dataFormSubmit()">确定</el-button> |
|
343 |
</span> |
|
344 |
</el-dialog> |
|
345 |
</template> |
|
346 |
|
|
347 |
<script> |
|
348 |
import DictSelectTag from '@/components/dict/dict-select-tag' |
|
349 |
import TagSelect from '@/components/tag/tag-select' |
|
350 |
import {isPositiveInteger} from '@/utils/validate' |
|
351 |
|
|
352 |
export default { |
|
353 |
components: { |
|
354 |
DictSelectTag, |
|
355 |
TagSelect |
|
356 |
}, |
|
357 |
data() { |
|
358 |
let validIsPositiveInteger = (rule, value, callback) => { |
|
359 |
if (value && !isPositiveInteger(value)) { |
|
360 |
callback(new Error('应该为正整数')) |
|
361 |
} else { |
|
362 |
callback() |
|
363 |
} |
|
364 |
} |
|
365 |
return { |
|
366 |
loading: true, |
|
367 |
dialogWidth: 0, |
|
368 |
pointtypeList: [], |
|
369 |
pointtypeMap: {}, |
|
370 |
minfreqList: [], |
|
371 |
storetypeList: [], |
|
372 |
datatypeList: [], |
|
373 |
httpList: [], |
|
374 |
tagList: [], |
|
375 |
expressionList: [], |
|
376 |
pointList: [], |
|
377 |
pointMap: {}, |
|
378 |
operatorList: ['+', '-', '*', '/', '&', '|', '!', '>', '<'], |
|
379 |
visible: false, |
|
380 |
roleList: [], |
|
381 |
allDictItems: JSON.parse(window.localStorage.getItem('DICT_ITEM_MAP')), |
|
382 |
dataForm: { |
|
383 |
id: '', |
|
384 |
cdbm: '', |
|
385 |
lsh: '', |
|
386 |
cdmc: '', |
|
387 |
cdmcSx: '', |
|
388 |
cdxxms: '', |
|
389 |
cdlx: 'float', |
|
390 |
dxbj: 1, |
|
391 |
lcxx: 0, |
|
392 |
lcsx: 1000, |
|
393 |
mrz: '', |
|
394 |
sjcd: '', |
|
395 |
jcqcd: '', |
|
396 |
dxd: '', |
|
397 |
ym: '', |
|
398 |
yd: 0, |
|
399 |
xs: '', |
|
400 |
py: '', |
|
401 |
jz: '', |
|
402 |
dy: '', |
|
403 |
ywfh: 0, |
|
404 |
xsws: '2', |
|
405 |
cljglx: '', |
|
406 |
ljl: 0, |
|
407 |
jldw: '', |
|
408 |
ybl: '', |
|
409 |
kzqId: '', |
|
410 |
bjxx: '', |
|
411 |
bjsx: '', |
|
412 |
ljcd: 0, |
|
413 |
scsj: '', |
|
414 |
sjybm: '', |
|
415 |
minfreqid: '', |
|
416 |
dimension: 1, |
|
417 |
pointTypeId: '7d9fe1db-d7a1-407a-a267-ef2edab5cb6b', |
|
418 |
storeTypeId: '', |
|
419 |
enable: 1, |
|
420 |
pointtypename: 'MEASURE', |
|
421 |
mathPoint: { |
|
422 |
id: '', |
|
423 |
pointid: '', |
|
424 |
expression: '' |
|
425 |
}, |
|
426 |
measurePoint: { |
|
427 |
id: '', |
|
428 |
pointid: '', |
|
429 |
tagno: '', |
|
430 |
sourceid: '', |
|
431 |
} |
|
432 |
}, |
|
433 |
dataRule: { |
|
434 |
'cdbm': [ |
|
435 |
{required: true, message: '名称不能为空', trigger: 'blur'} |
|
436 |
], |
|
437 |
'cdmc': [ |
|
438 |
{required: true, message: '点类型不能为空', trigger: 'blur'} |
|
439 |
], |
|
440 |
'cdxxms': [ |
|
441 |
{required: true, message: '测点信息描述不能为空', trigger: 'blur'} |
|
442 |
], |
|
443 |
'cdlx': [ |
|
444 |
{required: true, message: '测点类型不能为空', trigger: 'blur'} |
|
445 |
], |
|
446 |
'dxbj': [ |
|
447 |
{required: true, message: '读写标记不能为空', trigger: 'blur'} |
|
448 |
], |
|
449 |
'lcxx': [ |
|
450 |
{required: true, message: '量程下限不能为空', trigger: 'blur'} |
|
451 |
], |
|
452 |
'lcsx': [ |
|
453 |
{required: true, message: '量程上限不能为空', trigger: 'blur'} |
|
454 |
], |
|
455 |
'ywfh': [ |
|
456 |
{required: true, message: '有无符号不能为空', trigger: 'blur'} |
|
457 |
], |
|
458 |
'xsws': [ |
|
459 |
{required: true, message: '小数位数不能为空', trigger: 'blur'} |
|
460 |
], |
|
461 |
'ljl': [ |
|
462 |
{required: true, message: '累积量不能为空', trigger: 'blur'} |
|
463 |
], |
|
464 |
'ljcd': [ |
|
465 |
{required: true, message: '逻辑测点不能为空', trigger: 'blur'} |
|
466 |
], |
|
467 |
'enable': [ |
|
468 |
{required: true, message: '启用状态不能为空', trigger: 'blur'} |
|
469 |
], |
|
470 |
'pointTypeId': [ |
|
471 |
{required: true, message: '点类型不能为空', trigger: 'blur'} |
|
472 |
], |
|
473 |
'storeTypeId': [ |
|
474 |
{required: true, message: '存储类型不能为空', trigger: 'blur'} |
|
475 |
], |
|
476 |
'mrz': [ |
|
477 |
{required: false, message: '存储类型不能为空', trigger: 'blur'} |
|
478 |
], |
|
479 |
'minfreqid': [ |
|
480 |
{required: true, message: '采集频率不能为空', trigger: 'blur'} |
|
481 |
], |
|
482 |
'dimension': [ |
|
483 |
{required: true, message: '采样范围不能为空', trigger: 'blur'}, |
|
484 |
{validator: validIsPositiveInteger, trigger: 'blur'} |
|
485 |
], |
|
486 |
'measurePoint.tagno||measurePoint.xsttagno||measurePoint.elelowtagno||measurePoint.fxjytagno': [ |
|
487 |
{required: true, message: '名称不能为空', trigger: 'blur'} |
|
488 |
], |
|
489 |
'measurePoint.sourceid': [ |
|
490 |
{required: true, message: '采集频率不能为空', trigger: 'blur'} |
|
491 |
] |
|
492 |
} |
|
493 |
} |
|
494 |
}, |
|
495 |
methods: { |
|
496 |
init(id) { |
|
497 |
this.dataForm.id = id || 0 |
|
498 |
this.loading = true |
|
499 |
this.visible = true |
|
500 |
this.dataForm.pointtypename = 'MEASURE' |
|
501 |
this.$nextTick(() => { |
|
502 |
this.$refs['dataForm'].resetFields() |
|
503 |
this.expressionList = [{ |
|
504 |
parenthesesLeft: '', |
|
505 |
point: '', |
|
506 |
parenthesesRight: '', |
|
507 |
operator: '' |
|
508 |
}] |
|
509 |
this.dataForm.measurePoint.tagno = '' |
|
510 |
this.dataForm.measurePoint.datatypeid = '' |
|
511 |
this.dataForm.measurePoint.sourceid = '' |
|
512 |
this.dataForm.pointTypeId = '7d9fe1db-d7a1-407a-a267-ef2edab5cb6b' |
|
513 |
}) |
|
514 |
Promise.all([ |
|
515 |
this.getPointtypeList(), |
|
516 |
this.getStoretypeList(), |
|
517 |
this.getMinfreqList(), |
|
518 |
this.getDatatypeList(), |
|
519 |
this.getHttpList(), |
|
520 |
this.getPointList(), |
|
521 |
]).then(() => { |
|
522 |
if (id) { |
|
523 |
this.getInfo() |
|
524 |
} else { |
|
525 |
this.generateCDBM() |
|
526 |
this.loading = false |
|
527 |
} |
|
528 |
}) |
|
529 |
}, |
|
530 |
|
|
531 |
getInfo() { |
|
532 |
this.$http({ |
|
533 |
url: `/data/data/pointRelation/info/${this.dataForm.id}`, |
|
534 |
method: 'get', |
|
535 |
params: this.$http.adornParams() |
|
536 |
}).then(({data}) => { |
|
537 |
this.expressionList = [] |
|
538 |
if (data && data.code === 0) { |
|
539 |
this.dataForm = data.data |
|
540 |
if (this.dataForm.pointtypename && |
|
541 |
this.dataForm.pointtypename === 'CALCULATE' && |
|
542 |
this.dataForm.mathPoint.expression) { |
|
543 |
let expression = this.dataForm.mathPoint.expression |
|
544 |
do { |
|
545 |
let indexArray = [ |
|
546 |
expression.indexOf('+'), |
|
547 |
expression.indexOf('-'), |
|
548 |
expression.indexOf('*'), |
|
549 |
expression.indexOf('/'), |
|
550 |
expression.indexOf('&'), |
|
551 |
expression.indexOf('|'), |
|
552 |
expression.indexOf('!'), |
|
553 |
expression.indexOf('>'), |
|
554 |
expression.indexOf('<') |
|
555 |
].sort(this.numAscSort) |
|
556 |
if (indexArray[indexArray.length - 1] !== -1) { |
|
557 |
let endIndex = 0 |
|
558 |
for (let key in indexArray) { |
|
559 |
if (indexArray[key] > -1) { |
|
560 |
endIndex = indexArray[key] |
|
561 |
break |
|
562 |
} |
|
563 |
} |
|
564 |
|
|
565 |
// 运算值 |
|
566 |
let pointStr = expression.substring(0, endIndex) |
|
567 |
|
|
568 |
// 运算符 |
|
569 |
let operator = expression.substr(endIndex, 1) |
|
570 |
let indexOfParenthesesLeft = pointStr.indexOf('(') |
|
571 |
let lastIndexOfParenthesesLeft = pointStr.lastIndexOf('(') |
|
572 |
|
|
573 |
// 左括号 |
|
574 |
let parenthesesLeft = '' |
|
575 |
if (indexOfParenthesesLeft !== -1 && lastIndexOfParenthesesLeft !== -1) { |
|
576 |
parenthesesLeft = pointStr.substring(indexOfParenthesesLeft, lastIndexOfParenthesesLeft + 1) |
|
577 |
pointStr = pointStr.substring(lastIndexOfParenthesesLeft + 1) |
|
578 |
} |
|
579 |
|
|
580 |
let indexOfParenthesesRight = pointStr.indexOf(')') |
|
581 |
let lastIndexOfParenthesesRight = pointStr.lastIndexOf(')') |
|
582 |
|
|
583 |
// 右括号 |
|
584 |
let parenthesesRight = '' |
|
585 |
if (indexOfParenthesesRight !== -1 && lastIndexOfParenthesesRight !== -1) { |
|
586 |
parenthesesRight = pointStr.substring(indexOfParenthesesRight, lastIndexOfParenthesesRight + 1) |
|
587 |
pointStr = pointStr.substring(0, indexOfParenthesesRight) |
|
588 |
} |
|
589 |
this.expressionList.push({ |
|
590 |
parenthesesLeft: parenthesesLeft, |
|
591 |
point: pointStr, |
|
592 |
parenthesesRight: parenthesesRight, |
|
593 |
operator: operator |
|
594 |
}) |
|
595 |
expression = expression.substring(endIndex + 1) |
|
596 |
} else { |
|
597 |
let pointStr = expression |
|
598 |
let indexOfParenthesesLeft = pointStr.indexOf('(') |
|
599 |
let lastIndexOfParenthesesLeft = pointStr.lastIndexOf('(') |
|
600 |
let parenthesesLeft = '' |
|
601 |
if (indexOfParenthesesLeft !== -1 && lastIndexOfParenthesesLeft !== -1) { |
|
602 |
parenthesesLeft = pointStr.substring(indexOfParenthesesLeft, lastIndexOfParenthesesLeft + 1) |
|
603 |
pointStr = pointStr.substring(lastIndexOfParenthesesLeft + 1) |
|
604 |
} |
|
605 |
let indexOfParenthesesRight = pointStr.indexOf(')') |
|
606 |
let lastIndexOfParenthesesRight = pointStr.lastIndexOf(')') |
|
607 |
let parenthesesRight = '' |
|
608 |
if (indexOfParenthesesRight !== -1 && lastIndexOfParenthesesRight !== -1) { |
|
609 |
parenthesesRight = pointStr.substring(indexOfParenthesesRight, lastIndexOfParenthesesRight + 1) |
|
610 |
pointStr = pointStr.substring(0, indexOfParenthesesRight) |
|
611 |
} |
|
612 |
this.expressionList.push({ |
|
613 |
parenthesesLeft: parenthesesLeft, |
|
614 |
point: pointStr, |
|
615 |
parenthesesRight: parenthesesRight, |
|
616 |
operator: '' |
|
617 |
}) |
|
618 |
expression = '' |
|
619 |
} |
|
620 |
} while (expression && expression.length > 0) |
|
621 |
this.dataForm.expressionList = this.expressionList |
|
622 |
} |
|
623 |
this.loading = false |
|
624 |
} |
|
625 |
}) |
|
626 |
}, |
|
627 |
|
|
628 |
generateCDBM() { |
|
629 |
this.$http({ |
|
630 |
url: `/data/data/pointRelation/generateCDBM`, |
|
631 |
method: 'get' |
|
632 |
}).then(({data}) => { |
|
633 |
if (data && data.code === 0) { |
|
634 |
this.dataForm.cdbm = data.data |
|
635 |
} |
|
636 |
}) |
|
637 |
}, |
|
638 |
|
|
639 |
addParenthesesLeft(index, row) { |
|
640 |
if (row.parenthesesLeft) { |
|
641 |
row.parenthesesLeft = row.parenthesesLeft + '(' |
|
642 |
} else { |
|
643 |
row.parenthesesLeft = '(' |
|
644 |
} |
|
645 |
}, |
|
646 |
|
|
647 |
removeParenthesesLeft(index, row) { |
|
648 |
if (row.parenthesesLeft) { |
|
649 |
row.parenthesesLeft = row.parenthesesLeft.substring(0, row.parenthesesLeft.length - 1) |
|
650 |
} else { |
|
651 |
row.parenthesesLeft = '' |
|
652 |
} |
|
653 |
}, |
|
654 |
addParenthesesRight(index, row) { |
|
655 |
if (row.parenthesesRight) { |
|
656 |
row.parenthesesRight = row.parenthesesRight + ')' |
|
657 |
} else { |
|
658 |
row.parenthesesRight = ')' |
|
659 |
} |
|
660 |
}, |
|
661 |
removeParenthesesRight(index, row) { |
|
662 |
if (row.parenthesesRight) { |
|
663 |
row.parenthesesRight = row.parenthesesRight.substring(0, row.parenthesesRight.length - 1) |
|
664 |
} else { |
|
665 |
row.parenthesesRight = '' |
|
666 |
} |
|
667 |
}, |
|
668 |
numAscSort(a, b) { |
|
669 |
return a - b |
|
670 |
}, |
|
671 |
resetFields(obj) { |
|
672 |
for (let key in obj) { |
|
673 |
if (key === 'pointtypename') { |
|
674 |
continue |
|
675 |
} |
|
676 |
if (obj[key] instanceof Array) { |
|
677 |
obj[key] = [] |
|
678 |
} else if (obj[key] instanceof Object) { |
|
679 |
this.resetFields(obj[key]) |
|
680 |
} else { |
|
681 |
obj[key] = '' |
|
682 |
} |
|
683 |
} |
|
684 |
}, |
|
685 |
setDefaultFields(id, pointtypename) { |
|
686 |
this.dataForm.id = id || 0 |
|
687 |
this.dataForm.pointtypename = pointtypename || '' |
|
688 |
this.dataForm.point.dimension = 1 |
|
689 |
this.expressionList = [{ |
|
690 |
parenthesesLeft: '', |
|
691 |
point: '', |
|
692 |
parenthesesRight: '', |
|
693 |
operator: '' |
|
694 |
}] |
|
695 |
}, |
|
696 |
// 采集类型 |
|
697 |
getPointtypeList() { |
|
698 |
this.$http({ |
|
699 |
url: '/data/data/point-type/list', |
|
700 |
method: 'get', |
|
701 |
params: this.$http.adornParams({ |
|
702 |
'page': 1, |
|
703 |
'limit': 100 |
|
704 |
}) |
|
705 |
}).then(({data}) => { |
|
706 |
if (data && data.code === 0) { |
|
707 |
this.pointtypeList = data.page.list |
|
708 |
this.pointtypeList.forEach(function (value) { |
|
709 |
this.pointtypeMap[value.id] = value.pointtypename |
|
710 |
}, this) |
|
711 |
} else { |
|
712 |
this.pointtypeList = [] |
|
713 |
} |
|
714 |
}) |
|
715 |
}, |
|
716 |
getMinfreqList() { |
|
717 |
this.$http({ |
|
718 |
url: '/data/data/min-freq/list', |
|
719 |
method: 'get', |
|
720 |
params: this.$http.adornParams({ |
|
721 |
'page': 1, |
|
722 |
'limit': 100 |
|
723 |
}) |
|
724 |
}).then(({data}) => { |
|
725 |
if (data && data.code === 0) { |
|
726 |
this.minfreqList = data.page.list |
|
727 |
} else { |
|
728 |
this.minfreqList = [] |
|
729 |
} |
|
730 |
}) |
|
731 |
}, |
|
732 |
getStoretypeList() { |
|
733 |
this.$http({ |
|
734 |
url: '/data/data/store-type/list', |
|
735 |
method: 'get', |
|
736 |
params: this.$http.adornParams({ |
|
737 |
'page': 1, |
|
738 |
'limit': 100 |
|
739 |
}) |
|
740 |
}).then(({data}) => { |
|
741 |
if (data && data.code === 0) { |
|
742 |
this.storetypeList = data.page.list |
|
743 |
} else { |
|
744 |
this.storetypeList = [] |
|
745 |
} |
|
746 |
}) |
|
747 |
}, |
|
748 |
getDatatypeList() { |
|
749 |
this.$http({ |
|
750 |
url: '/data/data/data-type/list', |
|
751 |
method: 'get', |
|
752 |
params: this.$http.adornParams({ |
|
753 |
'page': 1, |
|
754 |
'limit': 100 |
|
755 |
}) |
|
756 |
}).then(({data}) => { |
|
757 |
if (data && data.code === 0) { |
|
758 |
this.datatypeList = data.page.list |
|
759 |
} else { |
|
760 |
this.datatypeList = [] |
|
761 |
} |
|
762 |
}) |
|
763 |
}, |
|
764 |
getHttpList() { |
|
765 |
this.$http({ |
|
766 |
url: '/data/http/api/list', |
|
767 |
method: 'get', |
|
768 |
params: this.$http.adornParams({ |
|
769 |
'page': 1, |
|
770 |
'limit': 100 |
|
771 |
}) |
|
772 |
}).then(({data}) => { |
|
773 |
if (data && data.code === 0) { |
|
774 |
this.httpList = data.data |
|
775 |
} else { |
|
776 |
this.httpList = [] |
|
777 |
} |
|
778 |
}) |
|
779 |
}, |
|
780 |
getTagCodes() { |
|
781 |
this.dataForm.measurePoint.tagno = null |
|
782 |
this.tagList = [] |
|
783 |
this.$http({ |
|
784 |
url: '/data/http/tag/list', |
|
785 |
method: 'get', |
|
786 |
params: this.$http.adornParams({ |
|
787 |
'httpId': this.dataForm.measurePoint.sourceid, |
|
788 |
}) |
|
789 |
}).then(({data}) => { |
|
790 |
if (data && data.code === 0) { |
|
791 |
this.tagList = data.data |
|
792 |
} else { |
|
793 |
this.tagList = [] |
|
794 |
} |
|
795 |
}) |
|
796 |
}, |
|
797 |
sourceChanged() { |
|
798 |
this.getTagCodes(); |
|
799 |
}, |
|
800 |
getPointList() { |
|
801 |
this.$http({ |
|
802 |
url: '/data/data/pointRelation/list/all', |
|
803 |
method: 'get', |
|
804 |
params: {} |
|
805 |
}).then(({data}) => { |
|
806 |
if (data && data.code === 0) { |
|
807 |
this.pointList = data.data |
|
808 |
this.pointList.forEach(function (value) { |
|
809 |
this.pointMap[value.id] = value.pointname |
|
810 |
}, this) |
|
811 |
} else { |
|
812 |
this.pointList = [] |
|
813 |
} |
|
814 |
}) |
|
815 |
}, |
|
816 |
changePointtype(value) { |
|
817 |
this.dataForm.pointtypename = this.pointtypeMap[value] |
|
818 |
if (this.dataForm.pointtypename === 'CONSTANT') { |
|
819 |
this.dataRule['mrz'][0].required = true |
|
820 |
} else { |
|
821 |
this.dataRule['mrz'][0].required = false |
|
822 |
} |
|
823 |
}, |
|
824 |
deleteExpressionRow(index, rows) { |
|
825 |
if (!rows || rows.length === 1) { |
|
826 |
this.$message({ |
|
827 |
message: '不能全部删除!', |
|
828 |
type: 'error', |
|
829 |
duration: 1500 |
|
830 |
}) |
|
831 |
return |
|
832 |
} |
|
833 |
rows.splice(index, 1) |
|
834 |
}, |
|
835 |
addExpressionRow(index, rows) { |
|
836 |
let row = JSON.parse(JSON.stringify(rows[index])) |
|
837 |
rows.splice(index, 0, row) |
|
838 |
}, |
|
839 |
// 表单提交 |
|
840 |
dataFormSubmit() { |
|
841 |
this.$refs['dataForm'].validate((valid) => { |
|
842 |
if (valid) { |
|
843 |
if (this.dataForm.pointtypename !== 'CALCULATE' && |
|
844 |
this.dataForm.pointtypename !== 'MEASURE' && |
|
845 |
this.dataForm.pointtypename !== 'CONSTANT') { |
|
846 |
this.$message({ |
|
847 |
message: '不支持的点类型!', |
|
848 |
type: 'error', |
|
849 |
duration: 1500 |
|
850 |
}) |
|
851 |
return |
|
852 |
} |
|
853 |
|
|
854 |
if (this.dataForm.pointtypename === 'CALCULATE' && |
|
855 |
this.expressionList && this.expressionList.length > 0) { |
|
856 |
let parenthesesLeftRex = /^[(]*$/ |
|
857 |
let parenthesesRightRex = /^[)]*$/ |
|
858 |
let expression = '' |
|
859 |
for (let i = 0; i < this.expressionList.length; i++) { |
|
860 |
let value = this.expressionList[i] |
|
861 |
if (!parenthesesLeftRex.test(value.parenthesesLeft)) { |
|
862 |
this.$message({ |
|
863 |
message: `第${i + 1}行左括号输入不正确!`, |
|
864 |
type: 'error', |
|
865 |
duration: 1500 |
|
866 |
}) |
|
867 |
return |
|
868 |
} |
|
869 |
if (!parenthesesRightRex.test(value.parenthesesRight)) { |
|
870 |
this.$message({ |
|
871 |
message: `第${i + 1}行右括号输入不正确!`, |
|
872 |
type: 'error', |
|
873 |
duration: 1500 |
|
874 |
}) |
|
875 |
return |
|
876 |
} |
|
877 |
if (i !== (this.expressionList.length - 1) && !value.operator) { |
|
878 |
this.$message({ |
|
879 |
message: `第${i + 1}行运算符不能为空!`, |
|
880 |
type: 'error', |
|
881 |
duration: 1500 |
|
882 |
}) |
|
883 |
return |
|
884 |
} |
|
885 |
expression = expression + value.parenthesesLeft + value.point + value.parenthesesRight + (i === (this.expressionList.length - 1) ? '' : value.operator) |
|
886 |
} |
|
887 |
this.dataForm.mathPoint.expression = expression |
|
888 |
} else { |
|
889 |
this.dataForm.mathPoint.expression = '' |
|
890 |
} |
|
891 |
|
|
892 |
this.$http['post'](`/data/data/pointRelation/${!this.dataForm.id ? 'add' : 'update'}`, this.dataForm).then(({data: res}) => { |
|
893 |
if (res.code !== 0) { |
|
894 |
return this.$message.error(res.msg) |
|
895 |
} |
|
896 |
this.$message({ |
|
897 |
message: this.$t('prompt.success'), |
|
898 |
type: 'success', |
|
899 |
duration: 500, |
|
900 |
onClose: () => { |
|
901 |
this.visible = false |
|
902 |
this.$emit('refreshDataList') |
|
903 |
} |
|
904 |
}) |
|
905 |
}).catch(() => { |
|
906 |
}) |
|
907 |
} |
|
908 |
}) |
|
909 |
}, |
|
910 |
} |
|
911 |
} |
|
912 |
</script> |
|
913 |
<style> |
|
914 |
.el-select { |
|
915 |
width: 100% |
|
916 |
} |
|
917 |
|
|
918 |
.el-input-group__append { |
|
919 |
padding: 0 5px 0 5px |
|
920 |
} |
|
921 |
|
|
922 |
.el-input-group__prepend { |
|
923 |
padding: 0 5px 0 5px |
|
924 |
} |
|
925 |
|
|
926 |
.el-radio + .el-radio { |
|
927 |
margin-left: 10px !important; |
|
928 |
} |
|
929 |
</style> |
|
930 |
|