Преглед изворни кода

ppt发布添加图表来源说明文字

Karsa пре 1 година
родитељ
комит
ed1f82a886

+ 25 - 9
src/views/ppt_manage/mixins/pptMixins.js

@@ -930,18 +930,34 @@ export default {
 		},
 
     /* 生成ppt时图表追加底部文字 来源/说明 */
-    transChartBottomInfo({slide,x,y,width,height},data) {
-      // console.log(slide,x,y,width,height)
-      if(data.SourcesFrom&&JSON.parse(data.SourcesFrom).isShow) {
-        let sourceObj = JSON.parse(data.SourcesFrom);
+    transChartBottomInfo(slide,{x,y,width,height},data) {
+      let chartData = data;
+      let yPercent = Number(Math.ceil(height.replace(/%/,''))+Math.ceil(y.replace(/%/,'')))+'%';
+      // console.log(yPercent)
 
+      if(chartData.SourcesFrom&&JSON.parse(chartData.SourcesFrom).isShow) {
+        let sourceObj = JSON.parse(chartData.SourcesFrom);
         slide.addText(`来源:${sourceObj.text}`,{
           x:x,
-          y:height,
-          w:width,
-          h:20,
-          fontSize: sourceObj.fontSize,
-          color: sourceObj.color.includes('rgb') ? rgbaToHex(sourceObj.color).color.substring(1) : '666',
+          y: yPercent,
+          w: width,
+          margin:10,
+          fontSize: sourceObj.fontSize*0.75,
+          color: sourceObj.color.includes('rgb') ? rgbaToHex(sourceObj.color).color.substring(1) : sourceObj.color.indexOf('#')===0 ? sourceObj.color.substring(1): '666',
+        })
+      }
+
+      if(chartData.Instructions&&JSON.parse(chartData.Instructions).isShow) {
+        let instructObj = JSON.parse(chartData.Instructions);
+
+        slide.addText(instructObj.text,{
+          x:x,
+          y: yPercent,
+          w: width,
+          align:'right',
+          margin:10,
+          fontSize: instructObj.fontSize*0.75,
+          color: instructObj.color.includes('rgb') ? rgbaToHex(instructObj.color).color.substring(1) : instructObj.color.indexOf('#')===0 ? instructObj.color.substring(1): '666',
         })
       }
     }

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

@@ -306,6 +306,9 @@ export default {
                 size: { type: "contain" },
               });
             }
+
+            //追加生成图表底部文字
+            this.transChartBottomInfo(slide,{x,y,width,height},this.optionMap[this.pageList[i].elements[j].chartId])
             
           }else if (textData){
             slide.addText(textData,{

+ 1 - 16
src/views/ppt_manage/newVersion/pptPublish.vue

@@ -320,22 +320,7 @@ export default {
             }
 
             //追加生成图表底部文字
-            this.transChartBottomInfo({slide,x,y,width,height},this.optionMap[this.pageList[i].elements[j].chartId])
-            let chartData = this.optionMap[this.pageList[i].elements[j].chartId]
-            if(chartData.SourcesFrom&&JSON.parse(chartData.SourcesFrom).isShow) {
-              let sourceObj = JSON.parse(chartData.SourcesFrom);
-
-              slide.addText(`来源:${sourceObj.text}`,{
-                x:x,
-                y:height,
-                w:width,
-                h:20,
-                fontSize: sourceObj.fontSize,
-                color: sourceObj.color.includes('rgb') ? rgbaToHex(sourceObj.color).color.substring(1) : '666',
-              })
-              console.log(x,y,width,height)
-            }
-            
+            this.transChartBottomInfo(slide,{x,y,width,height},this.optionMap[this.pageList[i].elements[j].chartId])
           }else if (textData){
             slide.addText(textData,{
               x:x,