提交 | 用户 | 时间
|
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> |
d3ee81
|
18 |
<el-col :span="12" v-if="!!dataForm.id"> |
潘 |
19 |
<el-form-item label="编号" prop="mmPredictItem.itemno"> |
83f63a
|
20 |
<el-input v-model="dataForm.mmPredictItem.itemno" placeholder="编号" maxlength="50"/> |
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"> |
d3ee81
|
39 |
<el-form-item label="粒度" prop="dataForm.mmPredictItem.granularity"> |
潘 |
40 |
<el-select v-model="dataForm.mmPredictItem.granularity" placeholder="请选择"> |
|
41 |
<el-option |
|
42 |
v-for="dict in getStrDictOptions(DICT_TYPE.TIME_GRANULARITY)" |
|
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"> |
d3ee81
|
53 |
<el-form-item label="是否检查" prop="dataForm.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"> |
d3ee81
|
65 |
<el-form-item label="是否启用" prop="dataForm.mmPredictItem.status"> |
潘 |
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"> |
d3ee81
|
79 |
<el-form-item label="管网" prop="dataForm.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"> |
d3ee81
|
97 |
<el-form-item label="排序" prop="dataForm.dmModuleItem.itemorder"> |
潘 |
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"> |
d3ee81
|
103 |
<el-form-item label="数据点" prop="dataForm.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)" |
|
153 |
v-if="!!dataForm.id"> |
|
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"> |
潘 |
173 |
<el-form-item label="编号" v-if="!!dataForm.id"> |
|
174 |
<el-input |
|
175 |
v-model="dataForm.mmPredictModel.modelno" placeholder="编号" maxlength="32" |
|
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"> |
2caade
|
267 |
<el-input |
L |
268 |
v-model="scope.row.datalength" maxlength="50" |
|
269 |
style="width:100%;height: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' |
潘 |
367 |
|
|
368 |
const {uploadUrl, httpRequest} = useUpload() |
7462da
|
369 |
|
L |
370 |
defineOptions({name: 'DataMmPredictItemForm'}) |
|
371 |
|
|
372 |
const {t} = useI18n() // 国际化 |
|
373 |
const message = useMessage() // 消息弹窗 |
|
374 |
const dialogVisible = ref(false) // 弹窗的是否展示 |
|
375 |
const dialogTitle = ref('') // 弹窗的标题 |
|
376 |
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用 |
|
377 |
const formType = ref('') // 表单的类型:create - 新增;update - 修改 |
d3ee81
|
378 |
const pointLoading = ref(false) |
cd9f11
|
379 |
const itemTypeList = ref([]) |
L |
380 |
const itemTypeMap = ref({}) |
|
381 |
const moduleList = ref([]) |
|
382 |
const resulttableList = ref([]) |
|
383 |
const resultstridList = ref([]) |
2caade
|
384 |
const pointNoList = ref([]) |
cd9f11
|
385 |
const pointList = ref([]) |
L |
386 |
const pointMap = ref({}) |
2caade
|
387 |
const predictList = ref([]) |
cd9f11
|
388 |
const predictItemList = ref([]) |
L |
389 |
const modelparamList = ref([]) |
d3ee81
|
390 |
const modelparamListMap = ref({}) |
cd9f11
|
391 |
const modelparamMap = ref({}) |
L |
392 |
const expressionList = ref([]) |
|
393 |
const fileList = ref([]) |
|
394 |
const operatorList = ['+', '-'] |
d3ee81
|
395 |
const replaceModelOnly = ref(false) |
cd9f11
|
396 |
const queryParams = reactive({ |
L |
397 |
pageNo: 1, |
|
398 |
pageSize: 10, |
|
399 |
pointNo: undefined, |
|
400 |
pointName: undefined, |
|
401 |
}) |
|
402 |
const dataForm = ref({ |
2caade
|
403 |
id: undefined, |
L |
404 |
itemtypename: undefined, |
cd9f11
|
405 |
mmPredictItem: { |
2caade
|
406 |
id: undefined, |
L |
407 |
itemno: undefined, |
|
408 |
itemname: undefined, |
|
409 |
caltypeid: undefined, |
|
410 |
itemtypeid: undefined, |
|
411 |
predictlength: undefined, |
d3ee81
|
412 |
granularity: 60, |
2caade
|
413 |
status: undefined, |
L |
414 |
isfuse: undefined, |
|
415 |
predictphase: undefined, |
d3ee81
|
416 |
workchecked: 0, |
2caade
|
417 |
unittransfactor: undefined, |
L |
418 |
saveindex: undefined |
cd9f11
|
419 |
}, |
L |
420 |
dmModuleItem: { |
2caade
|
421 |
id: undefined, |
L |
422 |
moduleid: undefined, |
|
423 |
itemid: undefined, |
d3ee81
|
424 |
itemorder: 1, |
2caade
|
425 |
status: undefined, |
L |
426 |
categoryid: undefined |
cd9f11
|
427 |
}, |
L |
428 |
mmItemOutput: { |
2caade
|
429 |
id: undefined, |
L |
430 |
itemid: undefined, |
|
431 |
pointid: undefined, |
|
432 |
resulttableid: undefined, |
|
433 |
tagname: undefined, |
|
434 |
outputorder: undefined |
cd9f11
|
435 |
}, |
L |
436 |
mmPredictModel: { |
2caade
|
437 |
id: undefined, |
L |
438 |
modelno: undefined, |
|
439 |
modelname: undefined, |
|
440 |
itemid: undefined, |
|
441 |
arithid: undefined, |
|
442 |
trainsamplength: undefined, |
|
443 |
predictsamplength: undefined, |
|
444 |
isonlinetrain: undefined, |
|
445 |
modelpath: undefined, |
|
446 |
isnormal: undefined, |
|
447 |
normalmax: undefined, |
|
448 |
normalmin: undefined, |
|
449 |
status: undefined, |
|
450 |
classname: undefined, |
|
451 |
methodname: undefined, |
|
452 |
modelparamstructure: undefined, |
|
453 |
resultstrid: undefined, |
|
454 |
settingmap: undefined |
cd9f11
|
455 |
}, |
L |
456 |
mmPredictMergeItem: { |
2caade
|
457 |
id: undefined, |
L |
458 |
itemid: undefined, |
|
459 |
expression: undefined, |
|
460 |
num: undefined |
cd9f11
|
461 |
}, |
L |
462 |
mmModelArithSettingsList: [], |
|
463 |
mmModelParamList: [] |
7462da
|
464 |
}) |
L |
465 |
const formRules = reactive({ |
d3ee81
|
466 |
'mmPredictItem.itemname': [{required: true, message: '预测项名不能为空', trigger: 'blur'}], |
潘 |
467 |
'mmPredictItem.itemtypeid': [{required: true, message: '类型不能为空', trigger: 'blur'}], |
|
468 |
'dataForm.mmPredictItem.granularity': [{ |
|
469 |
required: true, |
|
470 |
message: '粒度不能为空', |
|
471 |
trigger: 'blur' |
|
472 |
}], |
|
473 |
'dataForm.mmPredictItem.workchecked': [{ |
|
474 |
required: true, |
|
475 |
message: '是否检查不能为空', |
|
476 |
trigger: 'blur' |
|
477 |
}], |
|
478 |
'dataForm.mmPredictItem.status': [{required: true, message: '是否启用不能为空', trigger: 'blur'}], |
|
479 |
'dataForm.dmModuleItem.moduleid': [{required: true, message: '管网不能为空', trigger: 'blur'}], |
|
480 |
'dataForm.dmModuleItem.itemorder': [{required: true, message: '排序不能为空', trigger: 'blur'}], |
|
481 |
'dataForm.mmItemOutput.pointid': [{required: true, message: '数据点不能为空', trigger: 'blur'}], |
|
482 |
|
7462da
|
483 |
}) |
L |
484 |
const formRef = ref() // 表单 Ref |
|
485 |
|
|
486 |
/** 打开弹窗 */ |
2caade
|
487 |
const open = async (type: string, id?: number, itemtypename?: string) => { |
7462da
|
488 |
dialogVisible.value = true |
L |
489 |
dialogTitle.value = t('action.' + type) |
|
490 |
formType.value = type |
2caade
|
491 |
dataForm.value.itemtypename = itemtypename || 'NormalItem' |
L |
492 |
// resetForm() |
|
493 |
resetFields(dataForm.value) |
83f63a
|
494 |
setDefaultFields() |
2caade
|
495 |
getItemTypeList() |
L |
496 |
getModuleList() |
83f63a
|
497 |
getPointList() |
2caade
|
498 |
getModelparamList() |
L |
499 |
getResulttableList() |
|
500 |
getResultstridList() |
7462da
|
501 |
// 修改时,设置数据 |
L |
502 |
if (id) { |
|
503 |
formLoading.value = true |
|
504 |
try { |
83f63a
|
505 |
getInfo(id) |
7462da
|
506 |
} finally { |
L |
507 |
formLoading.value = false |
|
508 |
} |
|
509 |
} |
|
510 |
} |
|
511 |
defineExpose({open}) // 提供 open 方法,用于打开弹窗 |
|
512 |
|
|
513 |
/** 提交表单 */ |
|
514 |
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调 |
|
515 |
const submitForm = async () => { |
|
516 |
// 校验表单 |
|
517 |
if (!formRef) return |
|
518 |
const valid = await formRef.value.validate() |
|
519 |
if (!valid) return |
|
520 |
// 提交请求 |
|
521 |
formLoading.value = true |
|
522 |
try { |
cd9f11
|
523 |
const data = dataForm.value as unknown as MmPredictItem.MmPredictItemVO |
b39d0b
|
524 |
if (expressionList.value && expressionList.value.length > 0) { |
L |
525 |
let expression = '' |
|
526 |
for (let i = 0; i < expressionList.value.length; i++) { |
|
527 |
let value = expressionList.value[i] |
|
528 |
expression = expression + value.point + (i === (expressionList.value.length - 1) ? '' : value.operator) |
|
529 |
} |
|
530 |
dataForm.value.mmPredictMergeItem.expression = expression |
|
531 |
} else { |
|
532 |
dataForm.value.mmPredictMergeItem.expression = '' |
|
533 |
} |
|
534 |
if (dataForm.value.mmModelArithSettingsList) { |
|
535 |
for (let item of dataForm.value.mmModelArithSettingsList) { |
|
536 |
if (item.key === 'lenpredict') { |
|
537 |
dataForm.value.mmPredictItem.predictlength = item.value |
|
538 |
} |
|
539 |
} |
|
540 |
} |
7462da
|
541 |
if (formType.value === 'create') { |
L |
542 |
await MmPredictItem.createMmPredictItem(data) |
|
543 |
message.success(t('common.createSuccess')) |
|
544 |
} else { |
|
545 |
await MmPredictItem.updateMmPredictItem(data) |
|
546 |
message.success(t('common.updateSuccess')) |
|
547 |
} |
|
548 |
dialogVisible.value = false |
|
549 |
// 发送操作成功的事件 |
|
550 |
emit('success') |
|
551 |
} finally { |
|
552 |
formLoading.value = false |
|
553 |
} |
|
554 |
} |
83f63a
|
555 |
|
2caade
|
556 |
const resetFields = (obj) => { |
L |
557 |
for (let key in obj) { |
|
558 |
if (key === 'itemtypename') { |
|
559 |
continue |
|
560 |
} |
|
561 |
if (obj[key] instanceof Array) { |
|
562 |
obj[key] = [] |
|
563 |
} else if (obj[key] instanceof Object) { |
|
564 |
resetFields(obj[key]) |
|
565 |
} else { |
|
566 |
obj[key] = '' |
|
567 |
} |
|
568 |
} |
|
569 |
} |
|
570 |
|
|
571 |
const getInfo = async (id) => { |
|
572 |
dataForm.value = await MmPredictItem.getMmPredictItem(id) |
83f63a
|
573 |
expressionList.value = [] |
2caade
|
574 |
if (dataForm.value.mmPredictMergeItem && dataForm.value.mmPredictMergeItem.expression) { |
L |
575 |
let expression = dataForm.value.mmPredictMergeItem.expression |
83f63a
|
576 |
do { |
L |
577 |
let indexPlus = expression.indexOf('+') |
|
578 |
let indexSub = expression.indexOf('-') |
|
579 |
if (indexPlus !== -1 || indexSub !== -1) { |
|
580 |
let endIndex = (indexSub == -1 || (indexPlus < indexSub && indexPlus !== -1)) ? indexPlus : indexSub |
|
581 |
expressionList.value.push({ |
|
582 |
point: expression.substring(0, endIndex), |
2caade
|
583 |
operator: expression.substring(endIndex, 1) |
83f63a
|
584 |
}) |
L |
585 |
expression = expression.substring(endIndex + 1) |
|
586 |
} else { |
|
587 |
expressionList.value.push({ |
|
588 |
point: expression, |
|
589 |
operator: '' |
|
590 |
}) |
|
591 |
expression = '' |
|
592 |
} |
|
593 |
} while (expression && expression.length > 0) |
|
594 |
} |
|
595 |
} |
|
596 |
|
|
597 |
function setReplaceModelOnly(value) { |
cd9f11
|
598 |
replaceModelOnly.value = value |
L |
599 |
} |
83f63a
|
600 |
|
L |
601 |
function beforeUpload(file) { |
cd9f11
|
602 |
let fileName = file.name |
L |
603 |
let first = fileName.lastIndexOf('.') |
|
604 |
let nameLength = fileName.length |
|
605 |
let fileSuffix = fileName.substring(first + 1, nameLength) |
|
606 |
if (fileSuffix !== 'miail') { |
|
607 |
message.error('只能上传miail类型文件') |
|
608 |
return |
|
609 |
} |
|
610 |
} |
83f63a
|
611 |
|
L |
612 |
function uploadModelSuccess(response, file, fileList) { |
cd9f11
|
613 |
if (response.code === 0) { |
L |
614 |
message.success(t('上传成功')) |
|
615 |
dataForm.value.mmModelArithSettingsList = [] |
d3ee81
|
616 |
if (!replaceModelOnly.value) { |
cd9f11
|
617 |
dataForm.value.mmModelParamList = [] |
L |
618 |
} |
|
619 |
dataForm.value.mmPredictModel.modelpath = '' |
|
620 |
dataForm.value.mmPredictModel.modelparamstructure = '' |
|
621 |
if (response.data.loadFieldSetList && response.data.loadFieldSetList[0].propertyList) { |
83f63a
|
622 |
response.data.loadFieldSetList[0].propertyList.forEach(function (value) { |
cd9f11
|
623 |
if (value.key !== 'data1') { |
L |
624 |
dataForm.value.mmModelArithSettingsList.push({ |
|
625 |
key: value.key, |
|
626 |
name: value.name, |
|
627 |
valuetype: value.valueType, |
|
628 |
value: value.value |
|
629 |
}) |
|
630 |
} |
2caade
|
631 |
}) |
cd9f11
|
632 |
} |
d3ee81
|
633 |
dataForm.value.mmPredictModel.modelname = response.data.originalFilename |
cd9f11
|
634 |
dataForm.value.mmPredictModel.classname = response.data.className |
L |
635 |
dataForm.value.mmPredictModel.methodname = response.data.methodName |
|
636 |
if (response.data.paramPathList) { |
|
637 |
dataForm.value.mmPredictModel.modelpath = response.data.paramPathList[0] |
|
638 |
} |
|
639 |
if (response.data.paramsArray) { |
|
640 |
dataForm.value.mmPredictModel.modelparamstructure = response.data.paramsArray.join(',') |
|
641 |
} |
d3ee81
|
642 |
if (response.data.paramsCount && !replaceModelOnly.value) { |
cd9f11
|
643 |
for (let i = 0; i < response.data.paramsCount; i++) { |
L |
644 |
dataForm.value.mmModelParamList.push({ |
|
645 |
modelparamportorder: (i + 1), |
|
646 |
modelparamorder: (i + 1), |
|
647 |
modelparamtype: '', |
|
648 |
modelparamid: '', |
|
649 |
modelparamname: '', |
|
650 |
datalength: 0 |
|
651 |
}) |
|
652 |
} |
|
653 |
} |
|
654 |
if (response.data.settingConfigMap && response.data.settingConfigMap.settingMap) { |
|
655 |
dataForm.value.mmPredictModel.settingmap = JSON.stringify(response.data.settingConfigMap.settingMap) |
|
656 |
} |
|
657 |
} else { |
|
658 |
message.error('上传失败!' + response.msg) |
|
659 |
return |
|
660 |
} |
|
661 |
fileList = [] |
|
662 |
} |
83f63a
|
663 |
|
L |
664 |
function uploadModelError(file, err, fileList) { |
cd9f11
|
665 |
} |
83f63a
|
666 |
|
L |
667 |
function changeModelparam(row) { |
cd9f11
|
668 |
row.modelparamname = modelparamMap[row.modelparamid] |
L |
669 |
} |
83f63a
|
670 |
|
L |
671 |
function changeItemtype(value) { |
cd9f11
|
672 |
dataForm.value.itemtypename = itemTypeMap[value] |
L |
673 |
} |
83f63a
|
674 |
|
L |
675 |
function changeModelparamtype(value, row) { |
cd9f11
|
676 |
row.modelparamid = '' |
L |
677 |
} |
83f63a
|
678 |
|
L |
679 |
function changeOutputPoint(value) { |
cd9f11
|
680 |
dataForm.value.mmItemOutput.tagname = pointMap[value] |
L |
681 |
} |
83f63a
|
682 |
|
L |
683 |
function deleteExpressionRow(index, rows) { |
cd9f11
|
684 |
rows.splice(index, 1) |
L |
685 |
} |
83f63a
|
686 |
|
L |
687 |
function addExpressionRow(index, rows) { |
cd9f11
|
688 |
let row = JSON.parse(JSON.stringify(rows[index])) |
L |
689 |
rows.splice(index, 0, row) |
|
690 |
} |
83f63a
|
691 |
|
L |
692 |
function deleteRow(index: string, rows) { |
cd9f11
|
693 |
if (!rows || rows.length === 1) { |
L |
694 |
message.error('不能全部删除!') |
|
695 |
return |
|
696 |
} |
|
697 |
rows.splice(index, 1) |
|
698 |
orderRow(rows) |
|
699 |
} |
83f63a
|
700 |
|
L |
701 |
function addRow(index: string, rows) { |
cd9f11
|
702 |
let row = JSON.parse(JSON.stringify(rows[index])) |
L |
703 |
rows.splice(index, 0, row) |
|
704 |
orderRow(rows) |
|
705 |
} |
7462da
|
706 |
|
83f63a
|
707 |
function orderRow(rows) { |
cd9f11
|
708 |
let modelparamorder = 0 |
L |
709 |
let modelparamportorder = 0 |
|
710 |
rows.forEach(function (value) { |
|
711 |
if (value.modelparamportorder !== modelparamportorder) { |
|
712 |
modelparamportorder = value.modelparamportorder |
|
713 |
modelparamorder = 1 |
|
714 |
} |
|
715 |
value.modelparamorder = modelparamorder |
|
716 |
modelparamorder++ |
|
717 |
}) |
|
718 |
} |
83f63a
|
719 |
|
cd9f11
|
720 |
// 获取预测项类型列表 |
2caade
|
721 |
const getItemTypeList = async () => { |
cd9f11
|
722 |
itemTypeList.value = [] |
2caade
|
723 |
itemTypeList.value = await MmItemType.getItemTypeList() |
83f63a
|
724 |
itemTypeList.value.forEach(function (value) { |
cd9f11
|
725 |
itemTypeMap[value.id] = value.itemtypename |
L |
726 |
}) |
|
727 |
if (!dataForm.value.id) { |
2caade
|
728 |
dataForm.value.mmPredictItem.itemtypeid = itemTypeList.value[0].id |
cd9f11
|
729 |
} |
L |
730 |
} |
83f63a
|
731 |
|
cd9f11
|
732 |
// 获取管网列表 |
2caade
|
733 |
const getModuleList = async () => { |
cd9f11
|
734 |
moduleList.value = [] |
2caade
|
735 |
moduleList.value = await DmModule.getModuleList() |
cd9f11
|
736 |
} |
L |
737 |
|
2caade
|
738 |
const getResulttableList = async () => { |
cd9f11
|
739 |
resulttableList.value = [] |
2caade
|
740 |
resulttableList.value = await MmResultTable.getResulttableList() |
cd9f11
|
741 |
} |
83f63a
|
742 |
|
2caade
|
743 |
const getResultstridList = async () => { |
cd9f11
|
744 |
resultstridList.value = [] |
2caade
|
745 |
resultstridList.value = await MmResultTable.getResultstridList() |
cd9f11
|
746 |
} |
83f63a
|
747 |
|
2caade
|
748 |
const getPointList = async () => { |
cd9f11
|
749 |
pointLoading.value = true |
2caade
|
750 |
pointNoList.value = await DaPoint.getPointList(queryParams) |
L |
751 |
if (pointNoList.value.length > 0) { |
|
752 |
pointNoList.value.forEach(function (value) { |
83f63a
|
753 |
pointList.value.push(value) |
L |
754 |
pointMap[value.id] = value.pointname |
|
755 |
}) |
|
756 |
} |
cd9f11
|
757 |
} |
83f63a
|
758 |
|
2caade
|
759 |
const getModelparamList = async () => { |
cd9f11
|
760 |
modelparamListMap.value = [] |
L |
761 |
modelparamList.value = [] |
|
762 |
predictItemList.value = [] |
2caade
|
763 |
pointNoList.value = await DaPoint.getPointList(queryParams) |
cd9f11
|
764 |
let paramList = [] |
2caade
|
765 |
if (pointNoList.value.length > 0) { |
L |
766 |
pointNoList.value.forEach(function (value) { |
83f63a
|
767 |
paramList.push({ |
L |
768 |
id: value.id, |
|
769 |
code: value.pointno, |
|
770 |
name: value.pointname, |
|
771 |
type: 'DATAPOINT' |
|
772 |
}) |
|
773 |
modelparamMap[value.id] = value.pointname |
cd9f11
|
774 |
}) |
83f63a
|
775 |
modelparamListMap['DATAPOINT'] = paramList; |
L |
776 |
} |
cd9f11
|
777 |
|
2caade
|
778 |
predictList.value = await MmPredictItem.getMmPredictItemList() |
cd9f11
|
779 |
paramList = [] |
2caade
|
780 |
if (predictList.value.length > 0) { |
L |
781 |
predictList.value.forEach(function (value) { |
83f63a
|
782 |
paramList.push({ |
cd9f11
|
783 |
id: value.id, |
L |
784 |
code: value.itemno, |
83f63a
|
785 |
name: value.itemname, |
L |
786 |
type: 'PREDICTITEM' |
cd9f11
|
787 |
}) |
83f63a
|
788 |
if (value.id !== dataForm.value.id) { |
2caade
|
789 |
predictItemList.value.push({ |
83f63a
|
790 |
id: value.id, |
L |
791 |
code: value.itemno, |
|
792 |
name: value.itemname |
|
793 |
}) |
|
794 |
} |
|
795 |
modelparamMap[value.id] = value.itemname |
|
796 |
}) |
|
797 |
modelparamListMap['PREDICTITEM'] = paramList; |
|
798 |
} |
cd9f11
|
799 |
} |
83f63a
|
800 |
|
2caade
|
801 |
const setDefaultFields = () => { |
83f63a
|
802 |
dataForm.value.mmPredictItem.workchecked = 0 |
L |
803 |
dataForm.value.mmPredictItem.status = 1 |
|
804 |
dataForm.value.mmPredictItem.isfuse = 0 |
|
805 |
dataForm.value.mmPredictItem.predictphase = 0 |
|
806 |
dataForm.value.mmPredictItem.unittransfactor = 1 |
|
807 |
dataForm.value.mmPredictItem.saveindex = '2' |
|
808 |
dataForm.value.dmModuleItem.status = 1 |
|
809 |
dataForm.value.mmPredictModel.trainsamplength = 60 |
|
810 |
dataForm.value.mmPredictModel.isonlinetrain = 0 |
|
811 |
dataForm.value.mmPredictModel.status = 1 |
|
812 |
dataForm.value.mmItemOutput.outputorder = 1 |
|
813 |
dataForm.value.mmItemOutput.resulttableid = '3cc2b483-3a01-40f7-a419-0c260210d8eb' |
|
814 |
expressionList.value = [{ |
|
815 |
point: '', |
|
816 |
operator: '' |
|
817 |
}] |
|
818 |
fileList.value = [] |
|
819 |
} |
|
820 |
|
7462da
|
821 |
/** 重置表单 */ |
d3ee81
|
822 |
const resetForm = () => { |
cd9f11
|
823 |
dataForm.value = { |
L |
824 |
mmModelArithSettingsList: [], |
|
825 |
mmModelParamList: [], |
|
826 |
id: '', |
|
827 |
itemtypename: '', |
|
828 |
mmPredictItem: { |
|
829 |
id: '', |
|
830 |
itemno: '', |
|
831 |
itemname: '', |
|
832 |
caltypeid: '', |
|
833 |
itemtypeid: '', |
|
834 |
predictlength: '', |
d3ee81
|
835 |
granularity: 60, |
cd9f11
|
836 |
status: '', |
L |
837 |
isfuse: '', |
|
838 |
predictphase: '', |
d3ee81
|
839 |
workchecked: 0, |
cd9f11
|
840 |
unittransfactor: '', |
L |
841 |
saveindex: '' |
|
842 |
}, |
|
843 |
dmModuleItem: { |
|
844 |
id: '', |
|
845 |
moduleid: '', |
|
846 |
itemid: '', |
d3ee81
|
847 |
itemorder: 1, |
cd9f11
|
848 |
status: 1, |
L |
849 |
categoryid: '' |
|
850 |
}, |
|
851 |
mmItemOutput: { |
|
852 |
id: '', |
|
853 |
itemid: '', |
|
854 |
pointid: '', |
|
855 |
resulttableid: '3cc2b483-3a01-40f7-a419-0c260210d8eb', |
|
856 |
tagname: '', |
|
857 |
outputorder: 1 |
|
858 |
}, |
|
859 |
mmPredictModel: { |
|
860 |
id: '', |
|
861 |
modelno: '', |
|
862 |
modelname: '', |
|
863 |
itemid: '', |
|
864 |
arithid: '', |
|
865 |
trainsamplength: '', |
|
866 |
predictsamplength: '', |
|
867 |
isonlinetrain: '', |
|
868 |
modelpath: '', |
|
869 |
isnormal: '', |
|
870 |
normalmax: '', |
|
871 |
normalmin: '', |
|
872 |
status: 1, |
|
873 |
classname: '', |
|
874 |
methodname: '', |
|
875 |
modelparamstructure: '', |
|
876 |
resultstrid: '', |
|
877 |
settingmap: '' |
|
878 |
}, |
|
879 |
mmPredictMergeItem: { |
|
880 |
id: '', |
|
881 |
itemid: '', |
|
882 |
expression: '', |
|
883 |
num: '' |
|
884 |
} |
7462da
|
885 |
} |
L |
886 |
formRef.value?.resetFields() |
d3ee81
|
887 |
} |
cd9f11
|
888 |
|
L |
889 |
onMounted(() => { |
|
890 |
init() |
|
891 |
}) |
|
892 |
|
83f63a
|
893 |
function init() { |
cd9f11
|
894 |
} |
7462da
|
895 |
</script> |