|
@@ -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)
|