潘志宝
2024-09-26 e1ff2dfdc5b7cfa04a73a508187651d342fac04b
提交 | 用户 | 时间
7462da 1 <template>
L 2   <Dialog v-model="dialogVisible" :title="dialogTitle" width="50%">
3     <el-form
4       ref="formRef"
5       v-loading="formLoading"
cd9f11 6       :model="dataForm"
7462da 7       :rules="formRules"
L 8       label-width="120px"
9     >
cd9f11 10       <el-divider content-position="left">基本信息</el-divider>
7462da 11       <el-row>
L 12         <el-col :span="12">
d3ee81 13           <el-form-item label="预测项名" prop="mmPredictItem.itemname">
14             <el-input v-model="dataForm.mmPredictItem.itemname" placeholder="预测项名"
15                       maxlength="50"/>
7462da 16           </el-form-item>
L 17         </el-col>
e1ff2d 18         <el-col :span="12">
d3ee81 19           <el-form-item label="编号" prop="mmPredictItem.itemno">
e1ff2d 20             <el-input v-model="dataForm.mmPredictItem.itemno" placeholder="编号" maxlength="50" readonly/>
7462da 21           </el-form-item>
L 22         </el-col>
23       </el-row>
24       <el-row>
25         <el-col :span="12">
d3ee81 26           <el-form-item label="类型" prop="mmPredictItem.itemtypeid">
2caade 27             <el-select
L 28               v-model="dataForm.mmPredictItem.itemtypeid" @change="changeItemtype"
29               placeholder="请选择">
cd9f11 30               <el-option
L 31                 v-for="item in itemTypeList"
32                 :key="item.id"
33                 :label="item.itemtypename"
34                 :value="item.id"/>
35             </el-select>
7462da 36           </el-form-item>
L 37         </el-col>
38         <el-col :span="12">
e1ff2d 39           <el-form-item label="粒度" prop="mmPredictItem.granularity">
d3ee81 40             <el-select v-model="dataForm.mmPredictItem.granularity" placeholder="请选择">
41               <el-option
e1ff2d 42                 v-for="dict in getIntDictOptions(DICT_TYPE.TIME_GRANULARITY)"
d3ee81 43                 :key="dict.value"
44                 :label="dict.label"
45                 :value="dict.value"
46               />
47             </el-select>
7462da 48           </el-form-item>
L 49         </el-col>
50       </el-row>
51       <el-row>
52         <el-col :span="12">
e1ff2d 53           <el-form-item label="是否检查" prop="mmPredictItem.workchecked">
cd9f11 54             <el-select v-model="dataForm.mmPredictItem.workchecked" placeholder="请选择">
L 55               <el-option
d3ee81 56                 v-for="dict in getIntDictOptions(DICT_TYPE.COM_IS_INT)"
57                 :key="dict.value"
58                 :label="dict.label"
59                 :value="dict.value"
60               />
cd9f11 61             </el-select>
7462da 62           </el-form-item>
L 63         </el-col>
64         <el-col :span="12">
e1ff2d 65           <el-form-item label="是否启用" prop="mmPredictItem.status">
d3ee81 66             <el-select v-model="dataForm.mmPredictItem.status" placeholder="请选择">
cd9f11 67               <el-option
d3ee81 68                 v-for="dict in getIntDictOptions(DICT_TYPE.COM_IS_INT)"
69                 :key="dict.value"
70                 :label="dict.label"
71                 :value="dict.value"
72               />
cd9f11 73             </el-select>
7462da 74           </el-form-item>
L 75         </el-col>
76       </el-row>
77       <el-row>
78         <el-col :span="12">
e1ff2d 79           <el-form-item label="管网" prop="dmModuleItem.moduleid">
cd9f11 80             <el-select v-model="dataForm.dmModuleItem.moduleid" placeholder="请选择">
L 81               <el-option
82                 v-for="item in moduleList"
83                 :key="item.id"
84                 :label="item.modulename"
85                 :value="item.id"/>
86             </el-select>
7462da 87           </el-form-item>
L 88         </el-col>
89         <el-col :span="12">
2caade 90           <el-form-item label="类别">
83f63a 91             <el-input v-model="dataForm.dmModuleItem.categoryid" placeholder="类别" maxlength="64"/>
7462da 92           </el-form-item>
L 93         </el-col>
94       </el-row>
95       <el-row>
96         <el-col :span="12">
e1ff2d 97           <el-form-item label="排序" prop="dmModuleItem.itemorder">
d3ee81 98             <el-input-number v-model="dataForm.dmModuleItem.itemorder" :min="1" clearable
99                              controls-position="right"/>
7462da 100           </el-form-item>
L 101         </el-col>
102         <el-col :span="12">
e1ff2d 103           <el-form-item label="数据点" prop="mmItemOutput.pointid">
cd9f11 104             <el-select
L 105               v-model="dataForm.mmItemOutput.pointid"
106               filterable
107               @change="changeOutputPoint"
108               placeholder="请选择">
109               <el-option
110                 v-for="item in pointList"
111                 :key="item.id"
d3ee81 112                 :label="item.pointName"
cd9f11 113                 :value="item.id"/>
L 114             </el-select>
7462da 115           </el-form-item>
L 116         </el-col>
117       </el-row>
cd9f11 118       <el-row v-if="dataForm.itemtypename === 'MergeItem'">
7462da 119         <el-col :span="12">
2caade 120           <el-form-item label="预测长度">
L 121             <el-input
122               v-model="dataForm.mmPredictItem.predictlength" placeholder="预测长度"
123               maxlength="5"/>
7462da 124           </el-form-item>
L 125         </el-col>
126       </el-row>
cd9f11 127       <el-divider content-position="left" v-if="dataForm.itemtypename === 'NormalItem'">模型信息
L 128       </el-divider>
d3ee81 129       <el-row :gutter="8" v-if="dataForm.itemtypename === 'NormalItem'">
130         <el-col :span="12">
2caade 131           <el-form-item label="模型名称">
L 132             <el-input
133               v-model="dataForm.mmPredictModel.modelname" placeholder="模型名称"
134               maxlength="50"/>
cd9f11 135           </el-form-item>
L 136         </el-col>
7462da 137         <el-col :span="12">
d3ee81 138           <el-upload
139             class="upload-demo"
140             :limit="1"
141             :file-list="fileList"
142             :before-upload="beforeUpload"
143             :on-success="uploadModelSuccess"
144             :on-error="uploadModelError"
145             :action="uploadUrl"
146             :http-request="httpRequest">
147             <el-button type="primary" @click="setReplaceModelOnly(false)">
148               <Icon icon="ep:upload"/>
149               上传模型
150             </el-button>
151             <el-button
152               size="small" type="primary" @click="setReplaceModelOnly(true)"
e1ff2d 153               v-if="formType.value === 'update'">
d3ee81 154               <Icon icon="ep:upload"/>
155               更新模型
156             </el-button>
157           </el-upload>
7462da 158         </el-col>
L 159       </el-row>
d3ee81 160       <el-row :gutter="8" v-if="dataForm.itemtypename === 'NormalItem'">
cd9f11 161         <el-col :span="12">
2caade 162           <el-form-item label="结果">
cd9f11 163             <el-select v-model="dataForm.mmPredictModel.resultstrid" placeholder="请选择">
L 164               <el-option
165                 v-for="item in resultstridList"
166                 :key="item.id"
167                 :label="item.resultstr"
168                 :value="item.id"/>
169             </el-select>
170           </el-form-item>
171         </el-col>
d3ee81 172         <el-col :span="12">
e1ff2d 173           <el-form-item label="编号">
d3ee81 174             <el-input
e1ff2d 175               v-model="dataForm.mmPredictModel.modelno" placeholder="编号" maxlength="30" readonly
d3ee81 176               disabled/>
177           </el-form-item>
178         </el-col>
cd9f11 179       </el-row>
d3ee81 180       <el-row :gutter="8" v-if="dataForm.itemtypename === 'NormalItem'">
cd9f11 181         <el-col :span="24">
2caade 182           <el-form-item label="路径">
L 183             <el-input
184               v-model="dataForm.mmPredictModel.modelpath" placeholder="路径" maxlength="32"
185               disabled/>
cd9f11 186           </el-form-item>
L 187         </el-col>
188       </el-row>
d3ee81 189       <el-row :gutter="8" v-if="dataForm.itemtypename === 'NormalItem'">
cd9f11 190         <el-col :span="24">
2caade 191           <el-form-item label="类名">
L 192             <el-input
193               v-model="dataForm.mmPredictModel.classname" placeholder="类名" maxlength="32"
194               disabled/>
cd9f11 195           </el-form-item>
L 196         </el-col>
197       </el-row>
d3ee81 198       <el-row :gutter="8" v-if="dataForm.itemtypename === 'NormalItem'">
cd9f11 199         <el-col :span="12">
2caade 200           <el-form-item label="方法名">
L 201             <el-input
202               v-model="dataForm.mmPredictModel.methodname" placeholder="方法名"
203               maxlength="32" disabled/>
cd9f11 204           </el-form-item>
L 205         </el-col>
206         <el-col :span="12">
2caade 207           <el-form-item label="参数">
L 208             <el-input
209               v-model="dataForm.mmPredictModel.modelparamstructure" placeholder="参数"
210               maxlength="32" disabled/>
cd9f11 211           </el-form-item>
L 212         </el-col>
213       </el-row>
214       <el-table
215         v-if="dataForm.itemtypename === 'NormalItem'"
216         :data="dataForm.mmModelArithSettingsList"
217         border
218         style="width: 100%; margin-top: 5px;">
219         <el-table-column prop="key" label="键" align="center"/>
220         <el-table-column prop="name" label="名称" align="center"/>
221         <el-table-column prop="valuetype" label="类型" align="center"/>
d3ee81 222         <el-table-column prop="" label="值" align="center" min-width="150">
cd9f11 223           <template #default="scope">
d3ee81 224             <el-input size="mini" v-model="scope.row.value" maxlength="256"
225                       style="width:100%;height:100%"/>
cd9f11 226           </template>
L 227         </el-table-column>
228       </el-table>
229       <el-divider content-position="left" v-if="dataForm.itemtypename === 'NormalItem'">输入参数
230       </el-divider>
231       <el-table
2caade 232         v-if="dataForm.itemtypename === 'NormalItem'"
cd9f11 233         :data="dataForm.mmModelParamList"
L 234         border
235         style="width: 100%; margin-top: 5px;">
236         <el-table-column prop="modelparamportorder" label="端口" width="60" align="center"/>
237         <el-table-column prop="modelparamorder" label="序号" width="60" align="center"/>
238         <el-table-column prop="" label="类型" width="200" align="center">
239           <template #default="scope">
d3ee81 240             <el-select v-model="scope.row.modelparamtype" placeholder="请选择">
cd9f11 241               <el-option
d3ee81 242                 v-for="dict in getStrDictOptions(DICT_TYPE.MODEL_PARAM_TYPE)"
243                 :key="dict.value"
244                 :label="dict.label"
245                 :value="dict.value"
246               />
cd9f11 247             </el-select>
L 248           </template>
249         </el-table-column>
250         <el-table-column prop="" label="参数名称" align="center">
251           <template #default="scope">
252             <el-select
253               v-model="scope.row.modelparamid"
254               filterable
255               @change="changeModelparam(scope.row)"
256               placeholder="请选择">
257               <el-option
258                 v-for="(item, index) in modelparamListMap[scope.row.modelparamtype]"
259                 :key="index"
260                 :label="item.name"
261                 :value="item.id"/>
262             </el-select>
263           </template>
264         </el-table-column>
265         <el-table-column prop="" label="参数长度" width="120" align="center">
266           <template #default="scope">
e1ff2d 267             <el-input-number v-model="scope.row.datalength" :min="0" clearable
268                              controls-position="right"
269                              style="width:100%;hight:100%"/>
cd9f11 270           </template>
L 271         </el-table-column>
2caade 272         <el-table-column prop="" label="操作" width="140" align="center">
cd9f11 273           <template #default="scope">
L 274             <el-button
275               @click="addRow(scope.$index, dataForm.mmModelParamList)"
276               type="text"
277               size="small">
278               添加
279             </el-button>
280             <el-button
281               @click="deleteRow(scope.$index, dataForm.mmModelParamList)"
282               type="text"
283               size="small">
284               删除
285             </el-button>
286           </template>
287         </el-table-column>
288       </el-table>
289       <el-divider content-position="left" v-if="dataForm.itemtypename === 'MergeItem'">表达式
290       </el-divider>
291       <el-table
2caade 292         v-if="dataForm.itemtypename === 'MergeItem'"
cd9f11 293         :data="expressionList"
L 294         border
295         style="width: 100%; margin-top: 5px;">
296         <el-table-column
297           prop=""
298           label="预测项"
299           align="center">
300           <template #default="scope">
301             <el-select
302               v-model="scope.row.point"
303               filterable
304               placeholder="请选择">
305               <el-option
306                 v-for="(item, index) in predictItemList"
307                 :key="index"
308                 :label="item.name"
309                 :value="item.code"/>
310             </el-select>
311           </template>
312         </el-table-column>
313         <el-table-column
314           prop="point"
315           label="编号"
316           align="center"/>
317         <el-table-column
318           prop=""
319           label="运算符"
320           align="center">
321           <template #default="scope">
322             <el-select v-model="scope.row.operator" placeholder="请选择">
323               <el-option
324                 v-for="item in operatorList"
325                 :key="item"
326                 :label="item"
327                 :value="item"/>
328             </el-select>
329           </template>
330         </el-table-column>
331         <el-table-column
332           prop=""
333           label="操作"
2caade 334           width="140"
cd9f11 335           align="center">
L 336           <template #default="scope">
337             <el-button
338               @click="addExpressionRow(scope.$index, expressionList)"
339               type="text"
340               size="small">
341               添加
342             </el-button>
343             <el-button
344               @click="deleteExpressionRow(scope.$index, expressionList)"
345               type="text"
346               size="small">
347               删除
348             </el-button>
349           </template>
350         </el-table-column>
351       </el-table>
7462da 352     </el-form>
L 353     <template #footer>
354       <el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
355       <el-button @click="dialogVisible = false">取 消</el-button>
356     </template>
357   </Dialog>
358 </template>
359 <script lang="ts" setup>
d3ee81 360 import {DICT_TYPE, getIntDictOptions, getStrDictOptions} from '@/utils/dict'
7462da 361 import * as MmPredictItem from '@/api/model/pre/predict'
cd9f11 362 import * as MmItemType from '@/api/model/pre/item'
L 363 import * as DmModule from '@/api/model/pre/dm'
364 import * as MmResultTable from '@/api/model/pre/result'
365 import * as DaPoint from '@/api/data/da/point'
d3ee81 366 import {useUpload} from '@/api/model/pre/predict'
e1ff2d 367 import * as ScheduleModelApi from '@/api/model/sche/model'
d3ee81 368
369 const {uploadUrl, httpRequest} = useUpload()
7462da 370
L 371 defineOptions({name: 'DataMmPredictItemForm'})
372
373 const {t} = useI18n() // 国际化
374 const message = useMessage() // 消息弹窗
375 const dialogVisible = ref(false) // 弹窗的是否展示
376 const dialogTitle = ref('') // 弹窗的标题
377 const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
378 const formType = ref('') // 表单的类型:create - 新增;update - 修改
cd9f11 379 const itemTypeList = ref([])
L 380 const itemTypeMap = ref({})
381 const moduleList = ref([])
382 const resultstridList = ref([])
2caade 383 const pointNoList = ref([])
cd9f11 384 const pointList = ref([])
L 385 const pointMap = ref({})
386 const predictItemList = ref([])
d3ee81 387 const modelparamListMap = ref({})
cd9f11 388 const modelparamMap = ref({})
L 389 const expressionList = ref([])
390 const fileList = ref([])
391 const operatorList = ['+', '-']
d3ee81 392 const replaceModelOnly = ref(false)
cd9f11 393 const queryParams = reactive({
L 394   pageNo: 1,
395   pageSize: 10,
396   pointNo: undefined,
397   pointName: undefined,
398 })
399 const dataForm = ref({
2caade 400   id: undefined,
e1ff2d 401   itemtypename: 'NormalItem',
cd9f11 402   mmPredictItem: {
2caade 403     id: undefined,
L 404     itemno: undefined,
405     itemname: undefined,
406     caltypeid: undefined,
407     itemtypeid: undefined,
408     predictlength: undefined,
d3ee81 409     granularity: 60,
2caade 410     status: undefined,
L 411     isfuse: undefined,
412     predictphase: undefined,
d3ee81 413     workchecked: 0,
2caade 414     unittransfactor: undefined,
L 415     saveindex: undefined
cd9f11 416   },
L 417   dmModuleItem: {
2caade 418     id: undefined,
L 419     moduleid: undefined,
420     itemid: undefined,
d3ee81 421     itemorder: 1,
2caade 422     status: undefined,
L 423     categoryid: undefined
cd9f11 424   },
L 425   mmItemOutput: {
2caade 426     id: undefined,
L 427     itemid: undefined,
428     pointid: undefined,
429     resulttableid: undefined,
430     tagname: undefined,
431     outputorder: undefined
cd9f11 432   },
L 433   mmPredictModel: {
2caade 434     id: undefined,
L 435     modelno: undefined,
436     modelname: undefined,
437     itemid: undefined,
438     arithid: undefined,
439     trainsamplength: undefined,
440     predictsamplength: undefined,
441     isonlinetrain: undefined,
442     modelpath: undefined,
443     isnormal: undefined,
444     normalmax: undefined,
445     normalmin: undefined,
446     status: undefined,
447     classname: undefined,
448     methodname: undefined,
449     modelparamstructure: undefined,
450     resultstrid: undefined,
451     settingmap: undefined
cd9f11 452   },
L 453   mmPredictMergeItem: {
2caade 454     id: undefined,
L 455     itemid: undefined,
456     expression: undefined,
457     num: undefined
cd9f11 458   },
L 459   mmModelArithSettingsList: [],
460   mmModelParamList: []
7462da 461 })
L 462 const formRules = reactive({
d3ee81 463   'mmPredictItem.itemname': [{required: true, message: '预测项名不能为空', trigger: 'blur'}],
464   'mmPredictItem.itemtypeid': [{required: true, message: '类型不能为空', trigger: 'blur'}],
e1ff2d 465   'mmPredictItem.granularity': [{
d3ee81 466     required: true,
467     message: '粒度不能为空',
468     trigger: 'blur'
469   }],
e1ff2d 470   'mmPredictItem.workchecked': [{
d3ee81 471     required: true,
472     message: '是否检查不能为空',
473     trigger: 'blur'
474   }],
e1ff2d 475   'mmPredictItem.status': [{required: true, message: '是否启用不能为空', trigger: 'blur'}],
476   'dmModuleItem.moduleid': [{required: true, message: '管网不能为空', trigger: 'blur'}],
477   'dmModuleItem.itemorder': [{required: true, message: '排序不能为空', trigger: 'blur'}],
478   'mmItemOutput.pointid': [{required: true, message: '数据点不能为空', trigger: 'blur'}],
d3ee81 479
7462da 480 })
L 481 const formRef = ref() // 表单 Ref
482
483 /** 打开弹窗 */
2caade 484 const open = async (type: string, id?: number, itemtypename?: string) => {
e1ff2d 485   formType.value = type
7462da 486   dialogVisible.value = true
L 487   dialogTitle.value = t('action.' + type)
2caade 488   dataForm.value.itemtypename = itemtypename || 'NormalItem'
e1ff2d 489   resetForm()
2caade 490   resetFields(dataForm.value)
83f63a 491   setDefaultFields()
7462da 492   // 修改时,设置数据
L 493   if (id) {
494     formLoading.value = true
495     try {
83f63a 496       getInfo(id)
7462da 497     } finally {
e1ff2d 498       /*formLoading.value = false*/
7462da 499     }
L 500   }
e1ff2d 501
502   // 加载参数列表
503   modelparamListMap.value = await ScheduleModelApi.getModelParamList()
504
505   // 获取预测项类型列表
506   itemTypeList.value = await MmItemType.getItemTypeList()
507   itemTypeList.value.forEach(function (value) {
508     itemTypeMap[value.id] = value.itemtypename
509   })
510   if (!dataForm.value.id) {
511     dataForm.value.mmPredictItem.itemtypeid = itemTypeList.value[0].id
512   }
513   dataForm.value.itemtypename = itemTypeMap[dataForm.value.mmPredictItem.itemtypeid]
514
515   // 获取管网列表
516   moduleList.value = await DmModule.getModuleList()
517
518   // 获取结果字符串列表
519   resultstridList.value = await MmResultTable.getResultstridList()
520
521   // 获取数据点列表
522   pointNoList.value = await DaPoint.getPointList(queryParams)
523   if (pointNoList.value.length > 0) {
524     pointNoList.value.forEach(function (value) {
525       pointList.value.push(value)
526       pointMap[value.id] = value.pointname
527     })
528   }
529
530   formLoading.value = false
7462da 531 }
L 532 defineExpose({open}) // 提供 open 方法,用于打开弹窗
533
534 /** 提交表单 */
535 const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
536 const submitForm = async () => {
537   // 校验表单
538   if (!formRef) return
539   const valid = await formRef.value.validate()
540   if (!valid) return
541   // 提交请求
542   formLoading.value = true
543   try {
cd9f11 544     const data = dataForm.value as unknown as MmPredictItem.MmPredictItemVO
b39d0b 545     if (expressionList.value && expressionList.value.length > 0) {
L 546       let expression = ''
547       for (let i = 0; i < expressionList.value.length; i++) {
548         let value = expressionList.value[i]
549         expression = expression + value.point + (i === (expressionList.value.length - 1) ? '' : value.operator)
550       }
551       dataForm.value.mmPredictMergeItem.expression = expression
552     } else {
553       dataForm.value.mmPredictMergeItem.expression = ''
554     }
555     if (dataForm.value.mmModelArithSettingsList) {
556       for (let item of dataForm.value.mmModelArithSettingsList) {
557         if (item.key === 'lenpredict') {
558           dataForm.value.mmPredictItem.predictlength = item.value
559         }
560       }
561     }
7462da 562     if (formType.value === 'create') {
L 563       await MmPredictItem.createMmPredictItem(data)
564       message.success(t('common.createSuccess'))
565     } else {
566       await MmPredictItem.updateMmPredictItem(data)
567       message.success(t('common.updateSuccess'))
568     }
569     dialogVisible.value = false
570     // 发送操作成功的事件
571     emit('success')
572   } finally {
573     formLoading.value = false
574   }
575 }
83f63a 576
2caade 577 const resetFields = (obj) => {
L 578   for (let key in obj) {
579     if (key === 'itemtypename') {
580       continue
581     }
582     if (obj[key] instanceof Array) {
583       obj[key] = []
584     } else if (obj[key] instanceof Object) {
585       resetFields(obj[key])
586     } else {
587       obj[key] = ''
588     }
589   }
590 }
591
592 const getInfo = async (id) => {
593   dataForm.value = await MmPredictItem.getMmPredictItem(id)
83f63a 594   expressionList.value = []
2caade 595   if (dataForm.value.mmPredictMergeItem && dataForm.value.mmPredictMergeItem.expression) {
L 596     let expression = dataForm.value.mmPredictMergeItem.expression
83f63a 597     do {
L 598       let indexPlus = expression.indexOf('+')
599       let indexSub = expression.indexOf('-')
600       if (indexPlus !== -1 || indexSub !== -1) {
601         let endIndex = (indexSub == -1 || (indexPlus < indexSub && indexPlus !== -1)) ? indexPlus : indexSub
602         expressionList.value.push({
603           point: expression.substring(0, endIndex),
2caade 604           operator: expression.substring(endIndex, 1)
83f63a 605         })
L 606         expression = expression.substring(endIndex + 1)
607       } else {
608         expressionList.value.push({
609           point: expression,
610           operator: ''
611         })
612         expression = ''
613       }
614     } while (expression && expression.length > 0)
615   }
616 }
617
618 function setReplaceModelOnly(value) {
cd9f11 619   replaceModelOnly.value = value
L 620 }
83f63a 621
L 622 function beforeUpload(file) {
cd9f11 623   let fileName = file.name
L 624   let first = fileName.lastIndexOf('.')
625   let nameLength = fileName.length
626   let fileSuffix = fileName.substring(first + 1, nameLength)
627   if (fileSuffix !== 'miail') {
628     message.error('只能上传miail类型文件')
629     return
630   }
631 }
83f63a 632
L 633 function uploadModelSuccess(response, file, fileList) {
cd9f11 634   if (response.code === 0) {
L 635     message.success(t('上传成功'))
636     dataForm.value.mmModelArithSettingsList = []
d3ee81 637     if (!replaceModelOnly.value) {
cd9f11 638       dataForm.value.mmModelParamList = []
L 639     }
640     dataForm.value.mmPredictModel.modelpath = ''
641     dataForm.value.mmPredictModel.modelparamstructure = ''
642     if (response.data.loadFieldSetList && response.data.loadFieldSetList[0].propertyList) {
83f63a 643       response.data.loadFieldSetList[0].propertyList.forEach(function (value) {
cd9f11 644         if (value.key !== 'data1') {
L 645           dataForm.value.mmModelArithSettingsList.push({
646             key: value.key,
647             name: value.name,
648             valuetype: value.valueType,
649             value: value.value
650           })
651         }
2caade 652       })
cd9f11 653     }
d3ee81 654     dataForm.value.mmPredictModel.modelname = response.data.originalFilename
cd9f11 655     dataForm.value.mmPredictModel.classname = response.data.className
L 656     dataForm.value.mmPredictModel.methodname = response.data.methodName
657     if (response.data.paramPathList) {
658       dataForm.value.mmPredictModel.modelpath = response.data.paramPathList[0]
659     }
660     if (response.data.paramsArray) {
661       dataForm.value.mmPredictModel.modelparamstructure = response.data.paramsArray.join(',')
662     }
d3ee81 663     if (response.data.paramsCount && !replaceModelOnly.value) {
cd9f11 664       for (let i = 0; i < response.data.paramsCount; i++) {
L 665         dataForm.value.mmModelParamList.push({
666           modelparamportorder: (i + 1),
667           modelparamorder: (i + 1),
668           modelparamtype: '',
669           modelparamid: '',
670           modelparamname: '',
671           datalength: 0
672         })
673       }
674     }
675     if (response.data.settingConfigMap && response.data.settingConfigMap.settingMap) {
676       dataForm.value.mmPredictModel.settingmap = JSON.stringify(response.data.settingConfigMap.settingMap)
677     }
678   } else {
679     message.error('上传失败!' + response.msg)
680     return
681   }
682   fileList = []
683 }
83f63a 684
L 685 function uploadModelError(file, err, fileList) {
cd9f11 686 }
83f63a 687
L 688 function changeModelparam(row) {
cd9f11 689   row.modelparamname = modelparamMap[row.modelparamid]
L 690 }
83f63a 691
L 692 function changeItemtype(value) {
cd9f11 693   dataForm.value.itemtypename = itemTypeMap[value]
L 694 }
83f63a 695
L 696 function changeModelparamtype(value, row) {
cd9f11 697   row.modelparamid = ''
L 698 }
83f63a 699
L 700 function changeOutputPoint(value) {
cd9f11 701   dataForm.value.mmItemOutput.tagname = pointMap[value]
L 702 }
83f63a 703
L 704 function deleteExpressionRow(index, rows) {
cd9f11 705   rows.splice(index, 1)
L 706 }
83f63a 707
L 708 function addExpressionRow(index, rows) {
cd9f11 709   let row = JSON.parse(JSON.stringify(rows[index]))
L 710   rows.splice(index, 0, row)
711 }
83f63a 712
L 713 function deleteRow(index: string, rows) {
cd9f11 714   if (!rows || rows.length === 1) {
L 715     message.error('不能全部删除!')
716     return
717   }
718   rows.splice(index, 1)
719   orderRow(rows)
720 }
83f63a 721
L 722 function addRow(index: string, rows) {
cd9f11 723   let row = JSON.parse(JSON.stringify(rows[index]))
L 724   rows.splice(index, 0, row)
725   orderRow(rows)
726 }
7462da 727
83f63a 728 function orderRow(rows) {
cd9f11 729   let modelparamorder = 0
L 730   let modelparamportorder = 0
731   rows.forEach(function (value) {
732     if (value.modelparamportorder !== modelparamportorder) {
733       modelparamportorder = value.modelparamportorder
734       modelparamorder = 1
735     }
736     value.modelparamorder = modelparamorder
737     modelparamorder++
738   })
739 }
83f63a 740
2caade 741 const setDefaultFields = () => {
83f63a 742   dataForm.value.mmPredictItem.workchecked = 0
L 743   dataForm.value.mmPredictItem.status = 1
744   dataForm.value.mmPredictItem.isfuse = 0
745   dataForm.value.mmPredictItem.predictphase = 0
746   dataForm.value.mmPredictItem.unittransfactor = 1
747   dataForm.value.mmPredictItem.saveindex = '2'
748   dataForm.value.dmModuleItem.status = 1
749   dataForm.value.mmPredictModel.trainsamplength = 60
750   dataForm.value.mmPredictModel.isonlinetrain = 0
751   dataForm.value.mmPredictModel.status = 1
752   dataForm.value.mmItemOutput.outputorder = 1
753   dataForm.value.mmItemOutput.resulttableid = '3cc2b483-3a01-40f7-a419-0c260210d8eb'
754   expressionList.value = [{
755     point: '',
756     operator: ''
757   }]
758   fileList.value = []
759 }
760
7462da 761 /** 重置表单 */
d3ee81 762 const resetForm = () => {
cd9f11 763   dataForm.value = {
L 764     mmModelArithSettingsList: [],
765     mmModelParamList: [],
766     id: '',
e1ff2d 767     itemtypename: 'NormalItem',
cd9f11 768     mmPredictItem: {
L 769       id: '',
770       itemno: '',
771       itemname: '',
772       caltypeid: '',
773       itemtypeid: '',
774       predictlength: '',
d3ee81 775       granularity: 60,
cd9f11 776       status: '',
L 777       isfuse: '',
778       predictphase: '',
d3ee81 779       workchecked: 0,
cd9f11 780       unittransfactor: '',
L 781       saveindex: ''
782     },
783     dmModuleItem: {
784       id: '',
785       moduleid: '',
786       itemid: '',
d3ee81 787       itemorder: 1,
cd9f11 788       status: 1,
L 789       categoryid: ''
790     },
791     mmItemOutput: {
792       id: '',
793       itemid: '',
794       pointid: '',
795       resulttableid: '3cc2b483-3a01-40f7-a419-0c260210d8eb',
796       tagname: '',
797       outputorder: 1
798     },
799     mmPredictModel: {
800       id: '',
801       modelno: '',
802       modelname: '',
803       itemid: '',
804       arithid: '',
805       trainsamplength: '',
806       predictsamplength: '',
807       isonlinetrain: '',
808       modelpath: '',
809       isnormal: '',
810       normalmax: '',
811       normalmin: '',
812       status: 1,
813       classname: '',
814       methodname: '',
815       modelparamstructure: '',
816       resultstrid: '',
817       settingmap: ''
818     },
819     mmPredictMergeItem: {
820       id: '',
821       itemid: '',
822       expression: '',
823       num: ''
824     }
7462da 825   }
L 826   formRef.value?.resetFields()
d3ee81 827 }
cd9f11 828
L 829 onMounted(() => {
830   init()
831 })
832
83f63a 833 function init() {
cd9f11 834 }
7462da 835 </script>