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