createPPTContent.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. import {formatPPTDate} from '../utils/index'
  2. import {bgList} from '../utils/config'
  3. import {ref} from 'vue'
  4. import Cover from '../template/Cover.vue'
  5. import Footer from '../template/Footer.vue'
  6. import FormatOne from '../template/FormatOne.vue'
  7. import FormatTwo from '../template/FormatTwo.vue'
  8. import FormatThree from '../template/FormatThree.vue'
  9. import FormatFour from '../template/FormatFour.vue'
  10. import FormatFive from '../template/FormatFive.vue'
  11. import FormatSix from '../template/FormatSix.vue'
  12. import FormatSeven from '../template/FormatSeven.vue'
  13. import FormatEight from '../template/FormatEight.vue'
  14. import FormatNine from '../template/FormatNine.vue'
  15. import ChartWrap from '../components/ChartWrap.vue'
  16. import RichText from '../components/RichText.vue'
  17. import ImageWrap from '../components/ImageWrap.vue'
  18. import SheetWrap from '../components/SheetWrap.vue'
  19. import RectShape from '../components/layers/RectShape.vue'
  20. import LineShape from '../components/layers/LineShape.vue'
  21. import TextShape from '../components/layers/TextShape.vue'
  22. import { storeToRefs } from 'pinia'
  23. import { useConfigSettingStore } from '@/store/modules/etaConfig'
  24. export function getPPTConfig() {
  25. const lang=window.location.pathname.startsWith('/ppten')?'en':'zh'
  26. const { etaConfigInfo } = storeToRefs(useConfigSettingStore())
  27. const { CnPptCoverImgs,CnPptBackgroundImg,CnPptBottomImg,PptCompanyName,PptTeamName,PptFontColor,EnPptCoverImgs,EnPptBackgroundImg,EnPptBottomImg,PptCompanyNameEn,PptTeamNameEn,PptFontColorEn } = etaConfigInfo.value
  28. return {
  29. pptCoverList: lang==='en' ? EnPptCoverImgs.split(',') : CnPptCoverImgs.split(','),
  30. pptBgImage: lang==='en' ? EnPptBackgroundImg : CnPptBackgroundImg,
  31. pptBackImage: lang==='en' ? EnPptBottomImg : CnPptBottomImg,
  32. pptCoverCompenyName: lang==='en' ? PptCompanyNameEn : PptCompanyName,
  33. pptCoverDepartName: lang==='en' ? PptTeamNameEn : PptTeamName,
  34. pptCoverTextColor: lang==='en' ? PptFontColorEn : PptFontColor
  35. }
  36. }
  37. /**
  38. * 格式化ppt内容
  39. * @param params ppt详情接口返回的数据
  40. * modelId 模板1-9 0代表封面 -1代表尾页
  41. */
  42. export function createPPTContent(params){
  43. const lang=window.location.pathname.startsWith('/ppten')?'en':'zh'
  44. const {
  45. Content,
  46. Title,
  47. ReportType,
  48. BackgroundImg,
  49. PptDate,
  50. TemplateType,
  51. ReportId,
  52. ModifyTime,
  53. PublishTime
  54. }=params
  55. let arr=[]//ppt内容数组
  56. // 封面页数据
  57. const coverPageData={
  58. Title,
  59. ReportType,
  60. BackgroundImg,
  61. PptDate:formatPPTDate('zh',PptDate),
  62. TemplateType,
  63. BackIndex:TemplateType-1,
  64. imgLocalUrl:bgList[lang][TemplateType-1],
  65. modelId:0,
  66. id:0,
  67. }
  68. arr.push(coverPageData)
  69. // ppt内容页数据
  70. const conArr=JSON.parse(Content)
  71. arr.push(...conArr)
  72. //ppt尾页数据
  73. const lastPageData={
  74. name:'back',
  75. modelId:-1,
  76. id:-1,
  77. //英文地址:https://hzstatic.hzinsights.com/static/ppt_m/ppt_last__img_en.png
  78. bgImg:lang=='zh'?'/pptImg/ppt_last_img.png':'/pptImg/ppt_last_img_en.png',
  79. }
  80. arr.push(lastPageData)
  81. return arr
  82. }
  83. /**
  84. * ppt模板Map
  85. * 根据modelId获取是哪个模板组件
  86. */
  87. export function getTemplate(modelId){
  88. const modelMap=new Map([
  89. [0,Cover],
  90. [1,FormatOne],
  91. [2,FormatTwo],
  92. [3,FormatThree],
  93. [4,FormatFour],
  94. [5,FormatFive],
  95. [6,FormatSix],
  96. [7,FormatSeven],
  97. [8,FormatEight],
  98. [9,FormatNine],
  99. [-1,Footer],
  100. ])
  101. return modelMap.get(modelId)
  102. }
  103. /**
  104. * 获取ppt页面内部是哪种组件
  105. * @param position 该模板中哪个位置
  106. * @param list 该ppt页的element数据
  107. */
  108. export function getPPTContentType(position,list){
  109. const typeMap=new Map([
  110. ['chart',ChartWrap],
  111. ['text',RichText],
  112. ['image',ImageWrap],
  113. ['sheet',SheetWrap]
  114. ])
  115. // 查找出list中的position和position对应的类型
  116. let type=''
  117. list.forEach(item => {
  118. if(item.position===position){
  119. type=item.type
  120. }
  121. });
  122. return typeMap.get(type)
  123. }
  124. /**
  125. * 获取ppt页面中某模块的数据
  126. * @param position 该模板中哪个位置
  127. * @param data 该ppt页的数据
  128. */
  129. export function getPPTContentItemData(position,data){
  130. let obj={}
  131. data.elements.forEach(item => {
  132. if(item.position===position){
  133. obj=item
  134. }
  135. });
  136. return {...obj,pptPageIndex:data.pptPageIndex}
  137. }
  138. /**
  139. * 设置ppt每页中的layer图层类型
  140. */
  141. export function getPPTLayerType(data){
  142. const typeMap=new Map([
  143. ['shape',RectShape],
  144. ['line',LineShape],
  145. ['text',TextShape]
  146. ])
  147. return typeMap.get(data.type)
  148. }