Pārlūkot izejas kodu

区间分析图表生成缩略图

jwyu 7 mēneši atpakaļ
vecāks
revīzija
3e057ef069
1 mainītis faili ar 30 papildinājumiem un 10 dzēšanām
  1. 30 10
      src/views/intervalAnalysis/addChart.vue

+ 30 - 10
src/views/intervalAnalysis/addChart.vue

@@ -332,6 +332,7 @@
 </template>
 
 <script>
+import { dataBaseInterface } from '@/api/api.js';
 import Chart from '@/views/dataEntry_manage/components/chart';
 import edbComputedWrap from './components/edbComputedWrap.vue';
 import apiIntervalAnalysis from '@/api/modules/intervalAnalysis'
@@ -601,6 +602,7 @@ export default {
       apiIntervalAnalysis.chartEdit(params).then(res => {
         if (res.Ret === 200) {
           this.$message.success(this.$t('MsgPrompt.saved_msg'))
+          this.setChartImage({...res.Data,isUpdate:true})
         }
       })
     },
@@ -646,21 +648,39 @@ export default {
       }
       apiIntervalAnalysis.chartAdd(params).then(res => {
         if (res.Ret === 200) {
-          this.$message.success(this.$t('MsgPrompt.saved_msg'))
+          this.setChartImage(res.Data)
           this.showSaveChart = false
-          setTimeout(() => {
-            this.$router.replace({
-              path: '/rangeAnalysis',
-              query: {
-                code: res.Data.UniqueCode,
-                id: res.Data.ChartInfoId
-              }
-            })
-          }, 1500);
         }
       })
     },
 
+     /* 设置图表封面图片 */
+    setChartImage(data) {
+      let svg = this.$refs.chartRef.chart.getSVG({
+        chart: {
+          width: 340,
+          height: 230,
+        }
+      });
+      let form = new FormData();
+      form.append('Img', svg);
+      this.setImageHandle(form,data);
+    },
+    async setImageHandle(form,{ UniqueCode,ChartInfoId,isUpdate }) {
+      form.append('ChartInfoId',ChartInfoId)
+      await dataBaseInterface.setChartThumbnail(form)
+      if(isUpdate) return
+			this.$message.success(this.$t('MsgPrompt.saved_msg'))
+			this.$router.replace({
+				path: '/rangeAnalysis',
+				query: {
+					code: UniqueCode,
+					id: ChartInfoId
+				}
+			})
+
+    },
+
     //计算绘图
     async handleComputed() {
       const edbParams = this.$refs.edbComputedWrap.getParams()