From 932c3ab49ea4e911fb2c2531c29d6609ac5afefd Mon Sep 17 00:00:00 2001
From: dengzedong <dengzedong@email>
Date: 星期四, 02 一月 2025 10:51:37 +0800
Subject: [PATCH] itemchart bug修复。 页面优化

---
 src/views/model/pre/item/MmPredictItemForm.vue  |    8 +++-----
 src/views/model/pre/item/index.vue              |    6 ++----
 src/views/model/pre/item/MmPredictItemChart.vue |   28 ++++++++++++++++++----------
 3 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/src/views/model/pre/item/MmPredictItemChart.vue b/src/views/model/pre/item/MmPredictItemChart.vue
index 14afaed..4d24c06 100644
--- a/src/views/model/pre/item/MmPredictItemChart.vue
+++ b/src/views/model/pre/item/MmPredictItemChart.vue
@@ -3,6 +3,7 @@
     title="预测数据"
     :close-on-click-modal="false"
     width="50%"
+    @close="dialogClose"
     v-model="visible"
   >
     <el-form
@@ -12,7 +13,6 @@
     >
       <el-form-item label="开始时间">
         <el-date-picker
-          size="mini"
           v-model="dataForm.startTime"
           format="YYYY-MM-DD HH:mm:00"
           value-format="YYYY-MM-DD HH:mm:00"
@@ -22,7 +22,6 @@
       </el-form-item>
       <el-form-item label="结束时间">
         <el-date-picker
-          size="mini"
           v-model="dataForm.endTime"
           format="YYYY-MM-DD HH:mm:00"
           value-format="YYYY-MM-DD HH:mm:00"
@@ -79,9 +78,16 @@
   dataForm.value.id = row.id;
   dataForm.value.itemName = row.itemname;
   if (row.id) {
-    myChart = echarts.init(chartDomPre.value);
-    myChart.clear()
+    nextTick(() => {
+      myChart = echarts.init(chartDomPre.value);
+    });
     getDataList();
+  }
+}
+
+const dialogClose = () => {
+  if (myChart) {
+    myChart.dispose(); // 组件卸载时销毁实例
   }
 }
 
@@ -96,12 +102,12 @@
       chartParams.endTime = dataForm.value.endTime;
       const data = await McsApi.getPreDataItemChart(chartParams)
       let legendData = []
-      if (data.legend && data.legend.length > 0) {
-        data.legend.forEach(item => {
-          legendData.push(item + ":" + '真实值')
-          legendData.push(item + ":" + '预测值')
-        })
-      }
+      // if (data.legend && data.legend.length > 0) {
+      //   data.legend.forEach(item => {
+      //     legendData.push(item + ":" + '真实值')
+      //     legendData.push(item + ":" + '预测值')
+      //   })
+      // }
 
       let seriesData = []
       if (data.predictTime) {
@@ -134,6 +140,7 @@
         Object.keys(data.viewMap).forEach(key => {
           let viewData = data.viewMap[key]
           if(viewData.realData) {
+            legendData.push(key + ":" + '真实值')
             seriesData.push({
               name: key + ":" + '真实值',
               type: "line",
@@ -147,6 +154,7 @@
               },
             })
           }
+          legendData.push(key + ":" + '预测值')
           seriesData.push({
             name: key + ":" + '预测值',
             type: "line",
diff --git a/src/views/model/pre/item/MmPredictItemForm.vue b/src/views/model/pre/item/MmPredictItemForm.vue
index 22e5776..fc87750 100644
--- a/src/views/model/pre/item/MmPredictItemForm.vue
+++ b/src/views/model/pre/item/MmPredictItemForm.vue
@@ -298,7 +298,7 @@
         <el-table-column prop="valuetype" label="类型" align="center" min-width="150"/>
         <el-table-column prop="" label="值" align="center" min-width="200">
           <template #default="scope">
-            <el-input size="mini" v-model="scope.row.value" maxlength="1000"
+            <el-input v-model="scope.row.value" maxlength="1000"
                       :disabled="scope.row.key === 'pyFile'"
                       style="width:100%;height:100%"/>
           </template>
@@ -372,14 +372,12 @@
           <template #default="scope">
             <el-button
               @click="addRow(scope.$index, dataForm.mmModelParamList)"
-              type="text"
-              size="mini">
+              type="text">
               添加
             </el-button>
             <el-button
               @click="deleteRow(scope.$index, scope.row, dataForm.mmModelParamList)"
-              type="text"
-              size="mini">
+              type="text">
               删除
             </el-button>
           </template>
diff --git a/src/views/model/pre/item/index.vue b/src/views/model/pre/item/index.vue
index c1b6f60..883fe9d 100644
--- a/src/views/model/pre/item/index.vue
+++ b/src/views/model/pre/item/index.vue
@@ -97,7 +97,7 @@
       <el-table-column label="运行时间" min-width="150" align="center" prop="lastTime"/>
       <el-table-column label="运行状态" align="center" prop="runStatus">
         <template #default="scope">
-          <dict-tag :type="DICT_TYPE.ITEM_RUN_STATUS" :value="scope.row.runStatus" />
+          <dict-tag :type="DICT_TYPE.ITEM_RUN_STATUS" :value="scope.row.runStatus || 200" />
         </template>
       </el-table-column>
       <el-table-column label="运行耗时(ms)" align="center" prop="duration"/>
@@ -106,17 +106,15 @@
           <el-button
             link
             type="primary"
-            size="mini"
             @click="openForm('update', scope.row.id, scope.row.itemtypename)"
             v-hasPermi="['model:pre-item:update']"
           >
             编辑
           </el-button>
-          <el-button link size="mini" type="primary" @click="chartHandle(scope.row)">数据</el-button>
+          <el-button link type="primary" @click="chartHandle(scope.row)">数据</el-button>
           <el-button
             link
             type="danger"
-            size="mini"
             @click="handleDelete(scope.row.id)"
             v-hasPermi="['model:pre-item:delete']"
           >

--
Gitblit v1.9.3