Explorar o código

Merge branch 'demand-175'

cxmo hai 5 meses
pai
achega
72d68a3ef6

+ 7 - 2
src/api/modules/chartApi.js

@@ -679,7 +679,10 @@ const dataBaseInterface = {
 		},
 		/**
 		 * 多图表一键刷新
-		 * @param {ChartInfoCode} params 
+		 * @param {Object} params
+		 * @param {Array} params.ChartInfoCode
+		 * @param {String} params.Source 来源,枚举值:report、english_report、smart_report、ppt、en_ppt
+		 * @param {Number} params.PrimaryId 报告id/pptId
 		 * @returns 
 		 */
 		reportRefresh: params => {
@@ -962,7 +965,9 @@ const dataBaseInterface = {
 
 	/** 
 	 * 获取图表批量刷新结果
-	 *   Source ReportId ReportChapterId
+	 * @param {Object} params
+	 * @param {String} params.Source 来源,枚举值:report、english_report、smart_report、ppt、en_ppt
+	 * @param {Number} params.PrimaryId 报告id/pptId
 	 * 
 	 */
 	getReportrefreshStatus: params => {

+ 4 - 6
src/api/modules/sheetApi.js

@@ -291,9 +291,8 @@ export const getMixedCalculateData = 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
+ * @param {String} params.Source 来源,枚举值:report、english_report、smart_report、ppt、en_ppt
+ * @param {Number} params.PrimaryId 报告id/pptId
  */
 export const refreshSheet = (params)=>{
     return http.post('/datamanage/excel_info/table/batch_refresh',params)
@@ -301,9 +300,8 @@ export const refreshSheet = (params)=>{
 /**
  * 获取表格刷新结果
  * @param {Object} params
- * @param {String} params.Source 来源,枚举值:report、english_report、smart_report
- * @param {Number} params.ReportId 报告id
- * @param {Number} params.ReportChapterId 章节id 非章节传0
+ * @param {String} params.Source 来源,枚举值:report、english_report、smart_report、ppt、en_ppt
+ * @param {Number} params.PrimaryId 报告id/pptId
  */
 export const getRefreshResult = (params)=>{
     return http.post('/datamanage/excel_info/table/batch_refresh/result',params)

+ 2 - 0
src/lang/modules/Slides/commonLang.js

@@ -18,6 +18,7 @@ export const operationsEn = {
   operations_presentation: "Presentation",
   go_to_publish: "Go to publish",
   operations_save: "Save",
+  operations_refresh:"Refresh",
   operations_insert: "Insert PPT",
   operations_switch: "Switch template",
   paste_before_slide: "Paste before this slide",
@@ -49,6 +50,7 @@ export const operationsZh = {
   operations_presentation: "演示",
   go_to_publish: "去发布",
   operations_save: "保存",
+  operations_refresh:"一键刷新",
   operations_insert: "插入PPT",
   operations_switch: "切换模板",
   paste_before_slide: "粘贴到此页前",

+ 4 - 0
src/lang/modules/Slides/pptPresent.js

@@ -35,6 +35,8 @@ export const presentEn = {
   text_element: "Text settings",
   batch_deletion_successful: "Batch deletion successfu",
   retrieving_ppt_data: "Retrieving PPT data",
+  refresh_ppt_el:"Refreshing the charts and tables in the PPT...",
+  refresh_ppt_hint:"Charts and tables have not been added and cannot be refreshed",
   loading_urgently: "Loading urgently",
   convert_to_report_dlg: "PPT convert to report",
   report_type_select: "Report type",
@@ -126,6 +128,8 @@ export const presentZh = {
   text_element: "文本设置",
   batch_deletion_successful: "批量删除成功",
   retrieving_ppt_data: "正在获取ppt数据",
+  refresh_ppt_el:"正在刷新PPT内图表和表格...",
+  refresh_ppt_hint:"还未添加图表和表格,无法刷新",
   loading_urgently: "拼命加载中",
   convert_to_report_dlg: "PPT转报告",
   report_type_select: "报告类型",

+ 175 - 31
src/views/ppt_manage/mixins/pptEditorMixins.js

@@ -4,6 +4,8 @@
  */
 //lodash
 import _ from "lodash";
+import {dataBaseInterface} from "@/api/api.js"
+import * as sheetInterface from '@/api/modules/sheetApi.js';
 import {createRandomCode,checkPPTpageElemant,getChartInfo} from '../newVersion/utils/untils';
 import {modelInfo,defaultPosition} from '../newVersion/utils/config';
 export default{
@@ -20,6 +22,9 @@ export default{
       showLastSaveTime:false,//是否展示自动保存时间
       lastSaveTime:'',//自动保存时间
       isSaved:false,//是否已点击了保存/发布
+
+      refreshLoading:null,//一键刷新的loading
+      refreshBtnLoading:false,//一键刷新的按钮loading
     }
   },
   directives: {
@@ -253,37 +258,73 @@ export default{
     },
     //更新页面图表
     async updatePage(page){
-      page.isUpdating = true
-      const index = this.pageList.findIndex(i=>i.id===page.id)
-      this.pageList.splice(index,1,page)
-      const chartElements = page.elements.filter((item) => {
-        return item.type === "chart";
-      });
-      //刷新图表
-      //暂停自动保存
-      this.loopTimer&&clearInterval(this.loopTimer)
-      this.loopTimer=null
-      for(let i=0;i<chartElements.length;i++){
-        await this.getRefreshChart(chartElements[i].chartId);
-      }
-      //重新获取图表数据
-      for(let i=0;i<chartElements.length;i++){
-        await this.getchartData(chartElements[i].chartId);
-      }
-      //更新vuex里的图表信息
-      let chartInfoMap = _.cloneDeep(this.$store.state.ppt.chartInfoMap)
-      for(let i=0;i<chartElements.length;i++){     
-        let temp = getChartInfo(this.optionMap[chartElements[i].chartId])
-        chartInfoMap[chartElements[i].chartId] = temp
-      }
-      this.$store.commit('SET_CHART_INFO_MAP',chartInfoMap)
-      //渲染图表
-      await this.initCharts(chartElements, page);
-      page.isUpdating = false
-      this.$message.success(this.$t('MsgPrompt.refresh_success_msg'))
-      this.pageList.splice(index,1,page)
-      //开启自动保存
-      this.autoSave()
+        page.isUpdating = true
+        const index = this.pageList.findIndex(i=>i.id===page.id)
+        this.pageList.splice(index,1,page)
+        const chartElements = page.elements.filter((item) => {
+            return item.type === "chart";
+        });
+        const SheetElements = page.elements.filter((item) => {
+            return item.type === "sheet";
+        });
+        //刷新图表
+        //暂停自动保存
+        this.loopTimer&&clearInterval(this.loopTimer)
+        this.loopTimer=null
+        /* for(let i=0;i<chartElements.length;i++){
+            await this.getRefreshChart(chartElements[i].chartId);
+        }
+        //重新获取图表数据
+        for(let i=0;i<chartElements.length;i++){
+            await this.getchartData(chartElements[i].chartId);
+        }
+        //更新vuex里的图表信息
+        let chartInfoMap = _.cloneDeep(this.$store.state.ppt.chartInfoMap)
+        for(let i=0;i<chartElements.length;i++){     
+            let temp = getChartInfo(this.optionMap[chartElements[i].chartId])
+            chartInfoMap[chartElements[i].chartId] = temp
+        }
+        this.$store.commit('SET_CHART_INFO_MAP',chartInfoMap)
+        //渲染图表
+        await this.initCharts(chartElements, page); */
+
+        chartElements.length&&await this.refreshPageChart(chartElements,page)
+        SheetElements.length&&await this.refreshPageSheet(SheetElements,page)
+        page.isUpdating = false
+        //this.$message.success(this.$t('MsgPrompt.refresh_success_msg'))
+        this.pageList.splice(index,1,page)
+        //开启自动保存
+        this.autoSave()
+    },
+    //更新图表
+    async refreshPageChart(chartElements,page){
+        const codeArr = [...new Set (chartElements.map(i=>i.chartId))]
+        //改成批量刷新图表的接口
+        await this.refreshCharts(codeArr,'',Date.now().toString().slice(-6))
+        //重新获取图表数据
+        for(let i=0;i<chartElements.length;i++){
+            await this.getchartData(chartElements[i].chartId);
+        }
+        //更新vuex里的图表信息
+        let chartInfoMap = _.cloneDeep(this.$store.state.ppt.chartInfoMap)
+        for(let i=0;i<chartElements.length;i++){     
+            let temp = getChartInfo(this.optionMap[chartElements[i].chartId])
+            chartInfoMap[chartElements[i].chartId] = temp
+        }
+        this.$store.commit('SET_CHART_INFO_MAP',chartInfoMap)
+        //渲染图表
+        await this.initCharts(chartElements, page);
+    },
+    //更新表格
+    async refreshPageSheet(sheetElements,page){
+        const codeArr = [...new Set (sheetElements.map(i=>i.sheetId))]
+        await this.refreshSheets(codeArr,'',Date.now().toString().slice(-6))
+        //重新获取表格数据
+        for(let i=0;i<sheetElements.length;i++){
+            await this.getsheetData(sheetElements[i].sheetId);
+        }
+        //渲染表格
+        await this.initSheets(sheetElements,page)
     },
     //设置ctrl按键的状态
     handlePasteKey(e){
@@ -394,6 +435,109 @@ export default{
         this.CoverContent = content
         this.isShowChooseCover = false
     },
+    //一键刷新 图表/表格
+    async refleshFormatEl(){
+        //全局遮罩,按钮禁用
+        this.refreshBtnLoading = true
+        this.refreshLoading = this.$loading({
+            lock: true,
+            text: `${this.$t('Slides.refresh_ppt_el')}...`,
+            spinner: 'el-icon-loading',
+            customClass:'loading',
+            target:document.querySelector('.page-wrap'),
+            background: 'rgba(255, 255, 255, 0.8)'
+        });
+        //刷新图表
+        let chartArr = this.getPPTElIds('chart','chartId')
+        chartArr.length&&await this.refreshCharts(chartArr,this.$route.query.id,Date.now().toString().slice(-6))
+        //刷新表格
+        let sheetArr = this.getPPTElIds('sheet','sheetId')
+        sheetArr.length&&await this.refreshSheets(sheetArr,this.$route.query.id,Date.now().toString().slice(-6))
+        this.refreshLoading&&this.refreshLoading.close()
+        if(!chartArr.length&&!sheetArr.length){
+            this.refreshBtnLoading = false
+            return this.$message.warning(this.$t('Slides.refresh_ppt_hint'))
+        }
+        this.refreshLoading = this.$loading({
+            lock: true,
+            text: `${this.$t('Slides.retrieving_ppt_data')}...`,
+            spinner: 'el-icon-loading',
+            customClass:'loading',
+            target:document.querySelector('.page-wrap'),
+            background: 'rgba(255, 255, 255, 0.8)'
+        });
+        /**
+         * 刷新完成后:
+         * 清空chartInfoMap(store)
+         * 清空optionMap(data)
+         * 清空sheetDataMap(data)
+         */
+        this.$store.commit('SET_CHART_INFO_MAP',{})
+        this.optionMap = {}
+        this.sheetDataMap = {}
+
+        //重新加载所有PPT页
+        //获取数据
+        await this.initPPTAllPage(this.pageList)
+        //渲染元素
+        for(let i=0;i<this.pageList.length;i++){
+            await this.initPageElements(this.pageList[i])
+        }
+        //获取已加载图表的信息
+        let chartInfoMap = {}
+        for(let i=0;i<this.pageList.length;i++){
+            this.pageList[i].elements.forEach(item=>{
+                if(item.type==='chart'){
+                    let temp = getChartInfo(this.optionMap[item.chartId])
+                    chartInfoMap[item.chartId] = temp
+                }
+            })
+        }
+        this.$store.commit('SET_CHART_INFO_MAP',chartInfoMap)
+        //移除遮罩,按钮启用
+        this.refreshLoading&&this.refreshLoading.close()
+        this.refreshBtnLoading = false
+    },
+    getPPTElIds(type,typeKey){
+        let code_arr = []
+        for(let i=0;i<this.pageList.length;i++){
+            this.pageList[i].elements.forEach(item=>{
+                if(item.type===type){
+                    code_arr.push(item[typeKey])
+                }
+            })
+        }
+        return [...new Set(code_arr)]
+    },
+    async refreshCharts(code_arr,id,replaceId){
+        //获取所有图表code
+        let res = await dataBaseInterface.getReportrefreshStatus({
+            Source:this.currentLang==='en'?'en_ppt':'ppt',
+            PrimaryId: Number(id||replaceId),
+        })
+        if(!res.Data.RefreshResult) return this.$message.warning(this.$t('ReportManage.ReportList.chart_refreshed_msg'))
+        const { Ret, Msg } = await dataBaseInterface.reportRefresh({
+            ChartInfoCode: code_arr,
+            Source:this.currentLang==='en'?'en_ppt':'ppt',
+            PrimaryId: Number(id||replaceId)
+        })
+        if(Ret!==200) return 
+        this.$message.success(Msg)
+    },
+    async refreshSheets(code_arr,id,replaceId){
+        let res = await sheetInterface.getRefreshResult({
+            Source:this.currentLang==='en'?'en_ppt':'ppt',
+            PrimaryId: Number(id||replaceId)
+        });
+        if(!res.Data.RefreshResult) return this.$message.warning(this.$t('ReportManage.ReportList.chart_refreshed_msg'))
+        const { Ret,Msg } = await sheetInterface.refreshSheet({
+            ExcelCodes: code_arr,
+            Source:this.currentLang==='en'?'en_ppt':'ppt',
+            PrimaryId: Number(id||replaceId)
+        })
+        if(Ret!==200) return 
+        this.$message.success(Msg)
+    }
   },
   mounted(){
     document.addEventListener("keydown",this.handlePasteKey)

+ 4 - 1
src/views/ppt_manage/newVersion/pptEditor.vue

@@ -94,7 +94,7 @@
                         <!-- 页码 -->
                         <span class="page-num"> {{$i18n.locale == 'zh' ?`第${index+1}页`:` Slide${index+1}`}}</span>
                         <!-- 更新图表 -->
-                        <span class="update-btn" v-show="item.modelId!==6&&item.elements.find((i)=>i.type==='chart')" @click.stop="updatePage(item)"><span class="update-ico"></span> {{$t('Slides.update_chart_btn')}}</span>
+                        <span class="update-btn" v-show="item.modelId!==6&&item.elements.find((i)=>i.type==='chart'||i.type==='sheet')" @click.stop="updatePage(item)"><span class="update-ico"></span> {{$t('Slides.update_chart_btn')}}</span>
                     </div>
                     <AddFormat v-if="index===pageList.length-1" @addPage="addPage($event,index+1)" :chooseModalId="chooseModalId"/>
                 </div> 
@@ -113,6 +113,7 @@
                 style="color: #666; margin-bottom: 15px"
             >{{$t('Slides.last_save_time')}}:{{lastSaveTime}}</div>
             <div class="tool-btn">
+                <el-button type="primary" :loading="refreshBtnLoading" @click="refleshFormatEl">{{$t('Slides.operations_refresh')}}</el-button>
                 <el-button v-permission="permissionBtn.pptPermission.ppt_publish"
                  type="primary" @click="handlePublish">{{$t('Slides.go_to_publish')}}</el-button>
                 <el-button @click="handleSave('save')">{{$t('Slides.operations_save')}}</el-button>
@@ -1092,6 +1093,8 @@ export default {
       if(this.loopTimer) return 
       if(!this.$route.query.id&&!this.pptId) return
       this.loopTimer = setInterval(()=>{
+        //如果当前在刷新图表,则不进行自动保存
+        if(this.refreshBtnLoading) return
         const ppt_id = this.$route.query.id||this.pptId
         const {Title,ReportType,PptDate,BackgroundImg,BackIndex} = this.firstPage
         const FirstPage = {

+ 3 - 0
src/views/ppt_manage/newVersion/pptEnEditor.vue

@@ -110,6 +110,7 @@
                 style="color: #666; margin-bottom: 15px"
             >{{$t('Slides.last_save_time')}}:{{lastSaveTime}}</div>
             <div class="tool-btn">
+                <el-button type="primary" :loading="refreshBtnLoading" @click="refleshFormatEl">{{$t('Slides.operations_refresh')}}</el-button>
                 <el-button v-permission="permissionBtn.enPPTPermission.pptEn_publish"
                  type="primary" @click="handlePublish">{{$t('Slides.go_to_publish')}}</el-button>
                 <el-button @click="handleSave('save')">{{$t('Slides.operations_save')}}</el-button>
@@ -1078,6 +1079,8 @@ export default {
       if(this.loopTimer) return 
       if(!this.$route.query.id&&!this.pptId) return
       this.loopTimer = setInterval(()=>{
+        //如果当前在刷新图表,则不进行自动保存
+        if(this.refreshBtnLoading) return
         const ppt_id = this.$route.query.id||this.pptId
         const {Title,ReportType,PptDate,BackgroundImg,BackIndex} = this.firstPage
         const FirstPage = {

+ 8 - 6
src/views/report_manage/mixins/messagePush.js

@@ -106,13 +106,14 @@ export default {
       if(this.$route.query.id&&code_arr.length) {
         let res = await dataBaseInterface.getReportrefreshStatus({
           Source: fromPage,
-          ReportId: Number(this.$route.query.id),
-          ReportChapterId: 0
+          PrimaryId: Number(this.$route.query.id||Date.now().toString().slice(-6)),
         });
         
         if(!res.Data.RefreshResult) return this.$message.warning(this.$t('ReportManage.ReportList.chart_refreshed_msg'))
         const { Ret,Msg } = await dataBaseInterface.reportRefresh({
-            ChartInfoCode: code_arr
+            ChartInfoCode: code_arr,
+            Source: fromPage,
+            PrimaryId: Number(this.$route.query.id||Date.now().toString().slice(-6)),
           })
           
           if(Ret === 200) {
@@ -130,12 +131,13 @@ export default {
         //获取刷新结果
         let res = await sheetInterface.getRefreshResult({
             Source: fromPage,
-            ReportId: Number(this.$route.query.id),
-            ReportChapterId: 0
+            PrimaryId: Number(this.$route.query.id||Date.now().toString().slice(-6)),
           });
         if(!res.Data.RefreshResult) return this.$message.warning(this.$t('ReportManage.ReportList.chart_refreshed_msg'))
         const { Ret,Msg } = await sheetInterface.refreshSheet({
-            ExcelCodes: sheet_code_arr
+            ExcelCodes: sheet_code_arr,
+            Source: fromPage,
+            PrimaryId: Number(this.$route.query.id||Date.now().toString().slice(-6)),
           })
           
           if(Ret === 200) {

+ 8 - 6
src/views/smartReport/editReport.vue

@@ -874,14 +874,15 @@ export default {
             if(this.$route.query.id&&code_arr.length) {
                 let res = await dataBaseInterface.getReportrefreshStatus({
                 Source: 'smart_report',
-                ReportId: Number(this.$route.query.id),
-                ReportChapterId: 0
+                PrimaryId: Number(this.$route.query.id||Date.now().toString().slice(-6)),
                 });
                 
                 if(!res.Data.RefreshResult) return this.$message.warning(this.$t('ReportManage.ReportList.chart_refreshed_msg'))
 
                 const { Ret,Msg } = await dataBaseInterface.reportRefresh({
-                    ChartInfoCode: code_arr
+                    ChartInfoCode: code_arr,
+                    Source: 'smart_report',
+                    PrimaryId: Number(this.$route.query.id||Date.now().toString().slice(-6)),
                 })
                 
                 if(Ret === 200) {
@@ -898,12 +899,13 @@ export default {
                 //获取刷新结果
                 let res = await sheetInterface.getRefreshResult({
                     Source: 'smart_report',
-                    ReportId: Number(this.$route.query.id),
-                    ReportChapterId: 0
+                    PrimaryId: Number(this.$route.query.id||Date.now().toString().slice(-6)),
                 });
                 if(!res.Data.RefreshResult) return this.$message.warning('表格正在刷新中,请勿重复操作')
                 const { Ret,Msg } = await sheetInterface.refreshSheet({
-                    ExcelCodes: sheet_code_arr
+                    ExcelCodes: sheet_code_arr,
+                    PrimaryId:Number(this.$route.query.id||Date.now().toString().slice(-6)),
+                    Source: 'smart_report',
                 })
                 
                 if(Ret === 200) {