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