Bladeren bron

Merge branch 'need-12.18'

cxmo 11 maanden geleden
bovenliggende
commit
7928bf43b0
2 gewijzigde bestanden met toevoegingen van 68 en 25 verwijderingen
  1. 21 0
      src/api/modules/sheetApi.js
  2. 47 25
      src/views/report_manage/mixins/messagePush.js

+ 21 - 0
src/api/modules/sheetApi.js

@@ -287,6 +287,27 @@ export const getMixedCalculateData = params => {
 	return http.post('/datamanage/excel_info/mixed/calculate',params)
 }
 
+/**
+ * 表格一键刷新
+ * @param {Object} params
+ * @param {Array} params.ExcelCodes 表格唯一编码
+ * @param {String} params.Source 来源,枚举值:report、english_report、smart_report
+ * @param {Number} params.ReportId 报告id
+ * @param {Number} params.ReportChapterId 章节id 非章节传0
+ */
+export const refreshSheet = (params)=>{
+    return http.post('/datamanage/excel_info/table/batch_refresh',params)
+}
+/**
+ * 获取表格刷新结果
+ * @param {Object} params
+ * @param {String} params.Source 来源,枚举值:report、english_report、smart_report
+ * @param {Number} params.ReportId 报告id
+ * @param {Number} params.ReportChapterId 章节id 非章节传0
+ */
+export const getRefreshResult = (params)=>{
+    return http.post('/datamanage/excel_info/table/batch_refresh/result',params)
+}
 
 /* =====自定义分析==== */
 

+ 47 - 25
src/views/report_manage/mixins/messagePush.js

@@ -1,4 +1,5 @@
 import { reportadd, reportedit, messagePushPost,dataBaseInterface,reportMessageSend } from "@/api/api.js";
+import * as sheetInterface from '@/api/modules/sheetApi.js';
 import { getUrlParams } from '@/utils/common'
 export default {
   data() {
@@ -84,50 +85,71 @@ export default {
       });
     },
 
-    //刷报告中的所有图表  
+    //刷报告中的所有图表和表格
     refreshReport: _.debounce ( async function() {
       let code_arr = [];
+      let sheet_code_arr = []
       $('iframe').each((k,i) => {
         try {
           let href = $(i).attr('src');
-          code_arr.push(getUrlParams(href,'code'));
-    
+          if(href.includes('chartshow')){
+            code_arr.push(getUrlParams(href,'code'));
+          }
+          if(href.includes('sheetshow')){
+            sheet_code_arr.push(getUrlParams(href,'code'))
+          }
         } catch (err) {
         }
       });
 
-      if(!code_arr.length) return this.$message.warning('请插入图表');
+      if(!code_arr.length&&!sheet_code_arr.length) return this.$message.warning('请插入图表或表格')
 
-      if(this.$route.query.id) {
+      const fromPage = this.$route.path === "/reportEnEditor" ? "english_report" : "report";
+      if(this.$route.query.id&&code_arr.length) {
         let res = await dataBaseInterface.getReportrefreshStatus({
-          Source: 'report',
+          Source: fromPage,
           ReportId: Number(this.$route.query.id),
           ReportChapterId: 0
         });
         
         if(!res.Data.RefreshResult) return this.$message.warning('图表正在刷新中,请勿重复操作')
+        const { Ret,Msg } = await dataBaseInterface.reportRefresh({
+            ChartInfoCode: code_arr
+          })
+          
+          if(Ret === 200) {
+            $('iframe').each((k,i) => {
+                let href = $(i).attr('src');
+                if(href.includes('chartshow')){
+                    $(i).attr('src',$(i).attr('src'))
+                }
+            });
+            this.$message.success(Msg);
+          }
       }
 
-      // const loading = this.$loading({
-      //   lock: true,
-      //   text: '刷新中..',
-      //   spinner: 'el-icon-loading',
-      //   background: 'rgba(0, 0, 0, 0.02)'
-      // });
-
-      const { Ret,Msg } = await dataBaseInterface.reportRefresh({
-        ChartInfoCode: code_arr
-      })
-  
-      // loading.close();
-      
-      if(Ret === 200) {
-        $('iframe').each((k,i) => {
-          $(i).attr('src',$(i).attr('src'))
-        });
-        this.$message.success(Msg);
+      if(this.$route.query.id&&sheet_code_arr.length){
+        //获取刷新结果
+        let res = await sheetInterface.getRefreshResult({
+            Source: fromPage,
+            ReportId: Number(this.$route.query.id),
+            ReportChapterId: 0
+          });
+        if(!res.Data.RefreshResult) return this.$message.warning('表格正在刷新中,请勿重复操作')
+        const { Ret,Msg } = await sheetInterface.refreshSheet({
+            ExcelCodes: sheet_code_arr
+          })
+          
+          if(Ret === 200) {
+            $('iframe').each((k,i) => {
+                let href = $(i).attr('src');
+                if(href.includes('sheetshow')){
+                    $(i).attr('src',$(i).attr('src'))
+                }
+            });
+            this.$message.success(Msg);
+          }
       }
-
     },1000),
   },
 };