From 631da1c7ec58ecea8dc906c019a2ef2867a2081e Mon Sep 17 00:00:00 2001
From: dengzedong <dengzedong@email>
Date: 星期一, 14 十月 2024 09:10:12 +0800
Subject: [PATCH] 模型运行参数回显 模型方法参数设置bug修复

---
 src/views/model/mpk/file/MpkRun.vue |   28 ++++++++++++++++++++++++++--
 1 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/src/views/model/mpk/file/MpkRun.vue b/src/views/model/mpk/file/MpkRun.vue
index f3a0318..6b0111b 100644
--- a/src/views/model/mpk/file/MpkRun.vue
+++ b/src/views/model/mpk/file/MpkRun.vue
@@ -116,6 +116,7 @@
   const dialogTitle = ref('模型运行') // 弹窗的标题
 
   const formData = reactive({
+    pyName: '',
     className: '',
     methodName: '',
     datas: [],
@@ -131,6 +132,7 @@
   const open = async (row) => {
     dialogVisible.value = true
     formData.className = row.pkgName + '.impl.' + row.pyName + 'Impl';
+    formData.pyName = row.pyName;
     const mpk = await MpkApi.getMpk(row.id)
     methodList.value = mpk.modelMethods
     formData.methodName = mpk.modelMethods[0].methodName
@@ -139,6 +141,16 @@
      formData.datas[i] = '[[]]'
     }
     hasModel.value = mpk.modelMethods[0].model === 1
+
+    // 回显参数
+    if (mpk.modelMethods[0].methodSettings && mpk.modelMethods[0].methodSettings.length > 0) {
+      formData.modelSettings = mpk.modelMethods[0].methodSettings.map(e => {
+        return {
+          settingKey: e.settingKey,
+          settingValue: e.value
+        }
+      })
+    }
   }
   defineExpose({ open }) // 提供 open 方法,用于打开弹窗
 
@@ -162,10 +174,22 @@
   }
   const methodChange = function (value) {
     formData.datas = []
-    for (let i = 0 ; i < methodList.value.find(e => e.methodName === value)?.dataLength ; i++) {
+    var method = methodList.value.find(e => e.methodName === value);
+    for (let i = 0 ; i < method?.dataLength ; i++) {
       formData.datas[i] = '[[]]'
     }
-    hasModel.value = methodList.value.find(e => e.methodName === value)?.model === 1
+    hasModel.value = method?.model === 1
+    // 回显参数
+    if (method.methodSettings && method.methodSettings.length > 0) {
+      formData.modelSettings = method.methodSettings.map(e => {
+        return {
+          settingKey: e.settingKey,
+          settingValue: e.value
+        }
+      })
+    }else {
+      formData.modelSettings = []
+    }
   }
 
   const fileList = ref([]) // 文件列表

--
Gitblit v1.9.3