pdfZyb.vue 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111
  1. <template>
  2. <view class="page-wrappe">
  3. <cus-header title=' ' bgColor="transparent"></cus-header>
  4. <view id="pdfContainer" class="pdf-container" :style="{'transform':'scale('+scale+')', 'height': containerScaledHeight + 'px'}" v-if="reportData">
  5. <!-- 封面 -->
  6. <view class="cd_box fm2 adffc" style="border: none;margin-top: 20px;height: 868px;">
  7. <img class="fm2-logo" src="https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/fm_logo.png">
  8. <img class="fm2-logo2" src="https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/fm_logo2.png">
  9. <img class="fm2-perill" src="https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/fm_perill.png">
  10. <view class="fm2-line"></view>
  11. <view class="fm2-p" style="margin-top: 4px;font-size: 38px;">团队发展动态评估报告(团队版)</view>
  12. <view class="fm2-texts adf">
  13. <view class="fm2-texts-pre adf" style="margin-top: 6px;">
  14. <view class="fm2-texts-pre-span">客户名称:</view>
  15. <view class="fm2-texts-pre-val">{{ reportData.teamInfo.enterpriseName||'' }}</view>
  16. </view>
  17. <view class="fm2-texts-pre adf" style="margin-top: 6px;">
  18. <view class="fm2-texts-pre-span">团队名称:</view>
  19. <view class="fm2-texts-pre-val">{{ reportData.teamInfo.teamName||'' }}</view>
  20. </view>
  21. <view class="fm2-texts-pre adf" style="margin-top: 6px;">
  22. <view class="fm2-texts-pre-span">团队职能类型:</view>
  23. <view class="fm2-texts-pre-val">{{ reportData.teamInfo.functionName||'' }}</view>
  24. </view>
  25. <view class="fm2-texts-pre adf" style="margin-top: 6px;">
  26. <view class="fm2-texts-pre-span">团队模式类型:</view>
  27. <view class="fm2-texts-pre-val">{{ reportData.teamInfo.organizationName||'' }}</view>
  28. </view>
  29. <view class="fm2-texts-pre adf" style="margin-top: 6px;">
  30. <view class="fm2-texts-pre-span">评估发起人:</view>
  31. <view class="fm2-texts-pre-val">{{ reportData.teamInfo.initiator||'' }}</view>
  32. </view>
  33. <view class="fm2-texts-pre adf" style="margin-top: 6px;">
  34. <view class="fm2-texts-pre-span">报告生成时间:</view>
  35. <view class="fm2-texts-pre-val">{{ reportData.teamInfo.reportDate||'' }}</view>
  36. </view>
  37. </view>
  38. <view class="fm2-tip" style="margin-top: 12px;">免责声明:本团队测评报告基于您方团队填写的测评数据及相关信息生成,深圳创衡管理顾问有限公司不对报告内容的真实性、准确性和完整性负责。本报告仅供您了解团队情况、优化管理决策提供参考。报告结论不构成任何法律、商业或投资建议,亦不替代专业咨询意见。我方不对因使用本报告内容而产生的任何直接或间接损失承担责任。</view>
  39. </view>
  40. <!-- 介绍 -->
  41. <view class="cd_box" style="border: none">
  42. <view class="v2-top adfacjb" :style="{'background-image':'url(https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/'+'intro'+'_title_bg.png)','padding':'0 8px 0 24px'}">
  43. <view class="vt-left" style="color: #FFFFFF;">PERILL模型介绍</view>
  44. <view class="vt-right">团队发展动态评估报告(团队版) </view>
  45. </view>
  46. <view class="v2-box">
  47. <img class="vb-img1" :src="'https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/intro_box_img1.png'">
  48. <view class="v2-p">PERILL团队发展动态评估源于团队教练辅导领域的先驱、管理思维与团队绩效领域的权威、全球顶尖团队教练David Clutterbuck教授及其团队通过深入研究,提炼出影响团队绩效的140多个基于实证的因素,整合而成的团队评估和提升工具-PERILL模型。</view>
  49. <view class="v2-p" style="margin-top: 8px;">创衡国际基于10多年来在全球与200多家具有前瞻性的国际公司以及国内具有行业代表性公司的合作经验,结合CCMI的PERILL评估工具,在中国推出的团队发展动态评估系统,旨在帮助团队更全面、更有效地从六个维度评估团队的发展现状,为支持团队成为高价值创造团队提供全景式的客观评估。</view>
  50. <view class="v2-p" style="margin-top: 8px;">PERILL团队发展动态评估(团队版)的主体内容由<span>{{ reportData.teamInfo.questionCount }}</span>个关于团队的描述组成。</view>
  51. </view>
  52. <view class="v2-six">
  53. <view class="vsix-title">PERILL六大纬度</view>
  54. <view class="vsix-p">PERILL评估提供了一个复杂的团队系统概览,它并非针对孤立的问题,也不是简单的优缺点,而是着眼于团队系统的复杂性。它通过6个影响因素(如下所述)提出问题,以揭示团队系统各要素之间的联系,以及这些联系如何影响团队的高效运作能力。</view>
  55. <view class="vsix-boxs">
  56. <view class="vsb adfac" v-for="(item,index) in sixWd" :key="index">
  57. <img class="vsb-img" :src="item.img"/>
  58. <view class="vsb-right">
  59. <view class="vsbr-top adfac">
  60. <view class="vsbrt-type" :style="{'background':item.color}">{{ item.type }}</view>
  61. <view class="vsbrt-title" :style="{'color':item.color}">{{ item.title }}</view>
  62. </view>
  63. <view class="vsbr-desc">{{ item.desc }}</view>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. <!-- 总体评估分析 -->
  70. <view class="cd_box adffc" style="border: none;">
  71. <view class="v2-top adfacjb" :style="{'background-image':'url(https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/'+'intro'+'_top_title_bg2.png)'}">
  72. <view class="vt-left">总体评估分析</view>
  73. <view class="vt-right">团队发展动态评估报告(团队版) </view>
  74. </view>
  75. <view class="v2-box" style="border: 1px solid #33A7A7;">
  76. <img class="vb-img1" :src="'https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/intro_box_img1.png'">
  77. <view class="v2-p2">报告的核心是PERILL评估分析下的整体团队表现。这包括团队在PERILL模型每个关键要素上的综合得分,通过结合得分和置信指数,我们能够展示出高功能和低功能领域。</view>
  78. <view class="v2-p2" style="margin-top: 2px;font-weight: 400;color: #002846;font-size: 10px;">下面图中的位置标记显示了团队按影响力划分的总分。</view>
  79. <view class="vb-category">
  80. <view class="vbc-pre adfac">
  81. <view class="vbcp-yuan y1"></view>
  82. <view class="vbcp-text">团队领导者 Team Leader</view>
  83. </view>
  84. <view class="vbc-pre adfac">
  85. <view class="vbcp-yuan y2"></view>
  86. <view class="vbcp-text">团队成员 Team Member</view>
  87. </view>
  88. <view class="vbc-pre adfac">
  89. <view class="vbcp-yuan y3"></view>
  90. <view class="vbcp-text">利益相关方 Stakeholder</view>
  91. </view>
  92. <view class="vbc-pre adfac">
  93. <view class="vbcp-yuan y4"></view>
  94. <view class="vbcp-text">赞助人/出资人 Sponsor</view>
  95. </view>
  96. </view>
  97. <view style="width:360px;height:360px;margin: 0 auto;" class="pdfEchart">
  98. <l-echart ref="ztzdfxRef" :canvas2d="true" @finished="initZtzdfxChart" style="width: 100%;height: 100%;"></l-echart>
  99. </view>
  100. <view class="v2b-tip-title" style="color: #002846;">注: 关于认同度、重要性分、影响力分的定义</view>
  101. <view class="v2b-tip-memo">
  102. a.“认同度分”,指标逻辑为团队全体对当前主题所对应各问卷题目认同度评分的均值,用来表征团队对这一主题问卷所陈述内容与团队情况的相符合程度的平均认知,最高分:5分,最低分:1分;<br>
  103. b.“重要分”,指标逻辑为根据团队全体对当前主题所对应各问卷题目重要性评分的均值,用来表征团队对这一主题问卷所陈述内容对于团队重要性的平均认知,最高分:5分,最低分:1分;<br>
  104. c.“影响力分”,指标逻辑为综合团队全体对当前主题所对应各问卷题目的认同度与重要性的评分数据测算而来,用来表征团队对这一主题问卷所陈述内容对于团队的影响力水平,最高分:5分,最低分:1分;</view>
  105. <view class="v2b-title">评估结果</view>
  106. <view class="v2b-p" v-html="renderMarkdown(reportData.totalDiagnosticOutput||'')"></view>
  107. </view>
  108. </view>
  109. <!-- 总体评估分析 评估建议-->
  110. <view class="cd_box adffc" style="border: none;">
  111. <view class="v2-top adfacjb" :style="{'background-image':'url(https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/intro_top_title_bg2.png)'}">
  112. <view class="vt-left">总体评估分析</view>
  113. <view class="vt-right">团队发展动态评估报告(团队版) </view>
  114. </view>
  115. <view class="v2-box" style="border: 1px solid #33A7A7;">
  116. <img class="vb-img1" :src="'https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/intro_box_img1.png'">
  117. <view class="v2b-title" style="margin-top: 0;">评估建议</view>
  118. <view class="v2b-p" v-html="renderMarkdown(reportData.totalDiagnosisSuggest||'')"></view>
  119. <view class="v2b-alert">注:团队发展本身就不是单一答案的过程,PERILL AI教练根据创衡独创团队教练方法论,可以从不同角度解读团队,发现那些隐藏的机会点。多元建议代表多元可能。您可以尝试再次生成评估报告,探索更多可能性。</view>
  120. </view>
  121. </view>
  122. <!-- 多维度 -->
  123. <canvas type="2d" canvas-id="score-canvas" id="score-canvas" class="offscreen-canvas"></canvas>
  124. <template v-if="reportData&&reportData.dimensionAnalysis&&reportData.dimensionAnalysis.length">
  125. <block v-for="(item,index) in reportData.dimensionAnalysis" :key="index">
  126. <view class="cd_box adffc" style="border: none;">
  127. <view class="v2-top adfacjb" :style="{'background-image':'url(https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/'+(typeDict[item.title]||'zzdj')+'_title_bg.png)','padding':'0 8px 0 24px'}">
  128. <view class="vt-left" :class="{'black':(item.title=='人际关系'||item.title=='学习')}">{{ item.title }}</view>
  129. <view class="vt-right">团队发展动态评估报告(团队版) </view>
  130. </view>
  131. <view class="v2-box" :style="{'border':'none','padding':0}">
  132. <view class="v2-p2">{{ item.desc }}</view>
  133. <view class="vb-table adf" :style="{'border':'1px solid '+item.bordercolor,'margin-top':'12px'}">
  134. <view class="vbt2-left">
  135. <view class="vbt2l-th adf" :style="{'background':item.thbgcolor,'color':item.thtextcolor}">
  136. <view class="vbt2l-th-title adfac">主题</view>
  137. <view class="vbt2l-th-score adfacjc">影响力分</view>
  138. </view>
  139. <view class="vbt2l-pre" v-for="(ss,si) in item.scoreSpreads" :key="si" :style="{'border-bottom':'1px solid '+item.bordercolor}">
  140. <view class="vbt2l-pre-l adffc">
  141. <view class="vbt2l-pre-l-title" :style="{'color':item.titlecolor}">{{ ss.theme||'' }}</view>
  142. <view class="vbt2l-pre-l-tip">{{ ss.question||'' }}</view>
  143. </view>
  144. <view class="vbt2l-pre-r adfacjc">{{ ss.regular.avgScore||0 }}</view>
  145. </view>
  146. </view>
  147. <view class="vbt2-right adffc">
  148. <view class="vbt2r-th adf" :style="{'background':item.thbgcolor,'color':item.thtextcolor}">
  149. <view class="vbt2r-pre adfacjc">认同度分</view>
  150. <view class="vbt2r-pre adfacjc">重要性分</view>
  151. </view>
  152. <view class="vbt2r-tb adf">
  153. <view class="vbt2r-tb-l adffc">
  154. <view class="vbt2r-tb-l-pre red adfac" v-for="(ss,si) in item.scoreSpreads" :key="si" :style="{'border-bottom':'1px solid '+item.bordercolor}">
  155. <view class="vbt2r-tb-l-pre-bg"></view>
  156. <view class="vbt2r-tb-l-pre-zzt red" :style="{'width':(ss.regular.avgAgreement/6*100)+'%'}">
  157. <view class="vbt2r-tb-l-pre-zzt-numl">{{ ss.regular.avgAgreement||0 }}</view>
  158. </view>
  159. </view>
  160. </view>
  161. <view class="vbt2r-tb-l">
  162. <view class="vbt2r-tb-l-pre green adfac" v-for="(ss,si) in item.scoreSpreads" :key="si" :style="{'border-bottom':'1px solid '+item.bordercolor}">
  163. <view class="vbt2r-tb-l-pre-bg r"></view>
  164. <view class="vbt2r-tb-l-pre-zzt green" :style="{'width':(ss.regular.avgVital/6*100)+'%'}">
  165. <view class="vbt2r-tb-l-pre-zzt-numr">{{ ss.regular.avgVital||0 }}</view>
  166. </view>
  167. </view>
  168. </view>
  169. </view>
  170. </view>
  171. </view>
  172. <view class="v2-subp">评估结果</view>
  173. <view class="v2-p" style="margin-top: 6px;" v-html="renderMarkdown2(item.diagnosisOutput||'')"></view>
  174. </view>
  175. </view>
  176. <view class="cd_box adffc" style="border: none;">
  177. <view class="v2-top adfacjb" :style="{'background-image':'url(https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/'+(typeDict[item.title]||'zzdj')+'_title_bg.png)','padding':'0 8px 0 24px'}">
  178. <view class="vt-left" :class="{'black':(item.title=='人际关系'||item.title=='学习')}">{{ item.title }}</view>
  179. <view class="vt-right">团队发展动态评估报告(团队版) </view>
  180. </view>
  181. <view class="v2-box" :style="{'border':'none','padding':0}">
  182. <view class="v2-p" style="margin-top: 6px;" v-html="renderMarkdown2(item.diagnosisSuggest||'')"></view>
  183. </view>
  184. </view>
  185. </block>
  186. </template>
  187. <!-- 封底页 -->
  188. <view class="cd_box fdy" style="border: none;">
  189. <view class="v2-top adfacjb" :style="{'background-image':'url(https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/fdy_title_bg.png)'}">
  190. <view class="vt-left" style="color: #FFFFFF;">结言</view>
  191. <view class="vt-right">团队发展动态评估报告(团队版)</view>
  192. </view>
  193. <view class="fdy-title">致团队:从评估到行动,开启团队进化跃迁之旅</view>
  194. <view class="fdy-p">当您阅读至此,首先恭喜您和团队伙伴共同完成了一次完整、专业的团队评估!这标志着团队发展旅程中一个充满可能性的新起点。</view>
  195. <view class="fdy-p">作为团队教练,我们希望与您分享PERILL评估的科学价值,并为您描绘从系统诊断到协同进化的路径。 </view>
  196. <view class="fdy-subtitle">一、这份报告为团队带来了什么? </view>
  197. <view class="fdy-p" style="margin-top: 6px;">这份报告整合了团队内部(如:团队领导者与成员)与外部(如:客户、合作伙伴、赞助人)的多方视角,为您呈现团队作为一个“系统”的真实状态。它帮助团队:</view>
  198. <view class="fdy-p" style="margin-top: 0px;text-indent: 24px;">· 看见惯性模式与盲点——那些日常被忽略的协作断点、沟通落差与共识偏差。</view>
  199. <view class="fdy-p" style="margin-top: 0px;text-indent: 24px;">· 获得立体画像而非主观印象——基于数据而非直觉,客观定位团队在六大维度的表现。</view>
  200. <view class="fdy-p" style="margin-top: 0px;text-indent: 24px;">· 识别高杠杆改进区——不只列出问题,更揭示“从哪里改变,能带动全局提升”。</view>
  201. <view class="fdy-subtitle">二、PERILL 评估的科学洞察:不只是分数,更是系统思维</view>
  202. <view class="fdy-p" style="margin-top: 6px;">PERILL源自David Clutterbuck教授数十年的实证研究,其价值远超过一份评分报告。它帮助团队实现:</view>
  203. <view class="fdy-subtitle2">从“凭感觉管理”到“系统诊断”</view>
  204. <view class="fdy-p" style="margin-top: 6px;text-indent: 24px;">传统团队讨论容易陷入“我觉得”“你认为”的主观争论。PERILL提供共同语言与结构框架,让对话基于事实,聚焦系统障碍而非个人指责。</view>
  205. <view class="fdy-subtitle2">揭示“维度关联”,避免单一解药</view>
  206. <view class="fdy-p" style="margin-top: 6px;text-indent: 24px;">PERILL 揭示六大维度间的动态关联,例如:</view>
  207. <view class="fdy-p" style="margin-top: 0px;text-indent: 24px;">· 人际关系(R)紧张 → 抑制信息共享 → 影响学习(L)与创新 → 动摇宗旨认同(P)。</view>
  208. <view class="fdy-p" style="margin-top: 0px;text-indent: 24px;">· 改进关键点:可能只需提升心理安全(R),即可激活学习(L)与协同(I)。</view>
  209. <view class="fdy-subtitle2">赋能团队成为“自我进化系统”</view>
  210. <view class="fdy-p" style="margin-top: 6px;text-indent: 24px;">评估过程本身就是一次深度对话与反思。通过共同诊断、共同制定行动,团队主人翁意识被激发,变革可持续性远高于外部强加的“方案”。</view>
  211. <view class="fdy-subtitle">三、接下来,团队可以如何行动?</view>
  212. <view class="fdy-p" style="margin-top: 8px;">报告只是开始,真正的进化发生在对话与实践中。可以依照团队的需求去安排以下内容</view>
  213. <view class="fdy-subtitle2">1. 召开一次“报告解读与共识工作坊”</view>
  214. <view class="fdy-p" style="margin-top: 6px;text-indent: 24px;">邀请专业团队教练与团队一起开放地探讨评估结果,理解数据背后的含义,并就<span style="font-weight: bold;">“我们接下来共同聚焦哪1-2个维度?”</span>达成共识。这个过程本身,就是一次强有力的团队对话与承诺建立。</view>
  215. <view class="fdy-subtitle2">2. 针对关键挑战,设计专题行动实验</view>
  216. <view class="fdy-subtitle2">3. 如需深度支持,可考虑引入团队教练辅导助力团队发展</view>
  217. <view class="fdy-p">每一支高价值团队,都始于对现状清醒的认知与共同进化的勇气。PERILL为团队提供了导航仪与路线图——下一步,行动在您们手中。</view>
  218. <view class="fdy-p">PERILL不止于评估,更在于赋能。期待与您和团队同行,见证未来的更多可能。</view>
  219. <view class="fdy-p" style="margin-top: 41px;">具体需求可联系您的团队教练 或 扫码联系“⼤衡同学”。</view>
  220. <view class="fdy-code adfacjc"><img class="fdy-code-team" :src="'https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/fdy_code.png'"></view>
  221. </view>
  222. </view>
  223. <view class="pdf_btn" @click="createPdf">生成PDF</view>
  224. <view class="loading adffcacjc" v-if="isLoading">
  225. <u-loading-icon text="数据加载中,请耐心等待" :vertical="true" size="72" color="#FFFFFF" textSize="32" textColor="#FFFFFF"></u-loading-icon>
  226. </view>
  227. </view>
  228. </template>
  229. <script name="">
  230. import { BaseApi } from '@/http/baseApi.js';
  231. import * as echarts from '@/pagesHome/components/lime-echart/static/echarts.min.js'
  232. import lEchart from '@/pagesHome/components/lime-echart/components/l-echart/l-echart.vue'
  233. export default {
  234. name: 'ZtzdfxChart',
  235. components:{ lEchart },
  236. data() {
  237. return {
  238. isLoading: true,
  239. reportId:'',
  240. reportData: null,
  241. isChartReady: false,
  242. scale:1,
  243. originalContainerHeight: 0,
  244. containerScaledHeight: 'auto',
  245. typeDict: {
  246. '宗旨与动机':'zzdj',
  247. '外部流程、系统与结构':'wbjg',
  248. '人际关系':'rjgx',
  249. '内部流程、系统与结构':'nbjg',
  250. '学习':'xx',
  251. '领导力':'ldl'
  252. },
  253. sixWd: [
  254. {
  255. img:'https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/intro_img_p.png',
  256. type:'P',
  257. title:'宗旨与动机',
  258. desc:'指团队共享的目的和存在的意义, 包含对共同的愿景,目标和优先级的清晰度。',
  259. color:'#761E6A'
  260. },
  261. {
  262. img:'https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/intro_img_e.png',
  263. type:'E',
  264. title:'外部流程、系统与结构',
  265. desc:'指团队与其外部利益相关者 - 客户,供应商,股东,组织内的上级及其他团队的互动关系和协作机制。',
  266. color:'#009191'
  267. },
  268. {
  269. img:'https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/intro_img_r.png',
  270. type:'R',
  271. title:'人际关系',
  272. desc:'指团队成员共同工作时的关系状态–他们是否相互尊重和信任对方的能力,是否足够心理安全以能够坦诚沟通,是否真正关心彼此的幸福感等。',
  273. color:'#FFD750'
  274. },
  275. {
  276. img:'https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/intro_img_i.png',
  277. type:'I',
  278. title:'内部流程、系统与结构',
  279. desc:'指团队如何管理工作任务和流程(包括但不限于会议、任务分配和团队情绪等),互相支持以及高质量的沟通和决策。',
  280. color:'#4EB2B2'
  281. },
  282. {
  283. img:'https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/intro_img_l.png',
  284. type:'L',
  285. title:'学习',
  286. desc:'指团队如何应对多变的环境和保持持续的进步和成⻓,能够从经验中反思、提炼并应用知识的能力。',
  287. color:'#AFCDF5'
  288. },
  289. {
  290. img:'https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/intro_img_l2.png',
  291. type:'L',
  292. title:'领导力',
  293. desc:'指团队认为需要怎样的领导行为能够让他们,作为个人或者团队做到最好。团队可以和他们的领导者讨论他们的责任及承担方式,以帮助领导者成为他们需要的领导者。',
  294. color:'#002846'
  295. }
  296. ],
  297. pdfImages:[],
  298. };
  299. },
  300. onLoad(options) {
  301. this.reportId = options.reportId;
  302. this.getReportData();
  303. },
  304. onReady() {
  305. // #ifdef MP-WEIXIN
  306. wx.hideShareMenu();
  307. // #endif
  308. },
  309. mounted() {
  310. this.calculateScaleAndPosition();
  311. uni.onWindowResize(() => {
  312. this.calculateScaleAndPosition();
  313. });
  314. },
  315. methods: {
  316. renderMarkdown(val) {
  317. if(!val) return '';
  318. val = '<span style="padding-left:4ch;"></span>'+val;
  319. val = this.formattedText2(val);
  320. val = val.replaceAll('\n','<br><span style="padding-left:4ch;"></span>')
  321. val = this.formattedText(val);
  322. return val
  323. },
  324. renderMarkdown2(val) {
  325. if(!val) return '';
  326. val = '<span style="padding-left:4ch;"></span>'+val;
  327. val = val.replaceAll('\n','<br><span style="padding-left:4ch;"></span>')
  328. return val
  329. },
  330. formattedText(val) {
  331. // 正则表达式:匹配**包裹的内容
  332. // /\*\*(.*?)\*\*/g 解析:
  333. // \*\* 匹配两个星号(*需要转义)
  334. // (.*?) 非贪婪匹配任意字符(括号捕获匹配的内容)
  335. // g 全局匹配(替换所有符合条件的内容)
  336. const regex = /\*\*(.*?)\*\*/g
  337. // 替换为<b>标签,$1表示正则中括号捕获的内容
  338. return val.replace(regex, '<b>$1</b>')
  339. },
  340. formattedText2(val) {
  341. // 正则解析:
  342. // #{1,6} 匹配1到6个#
  343. // (.*?) 非贪婪捕获#后、空格前的任意文字(核心要保留的内容)
  344. // \s 匹配后面的空格(注意是单个空格,若要兼容多个空格可改为\s+)
  345. // g 全局匹配,替换所有符合条件的内容
  346. const regex = /#{1,6}\s*(.+?)\s*\n/g;
  347. // 替换规则:将匹配到的 "#文字 " / "##文字 " / "###文字 " 转为 "<b>文字</b>"
  348. return val.replace(regex, '<b>$1</b><br>')
  349. },
  350. getReportData(){
  351. this.$api.get(`/core/report/previewReport/${this.reportId}`).then(async ({data:res})=>{
  352. if(res.code!==0) return this.$showToast(res.msg)
  353. this.reportData = res.data;
  354. const tempDimensionAnalysis = [
  355. {
  356. title:'宗旨与动机',thbgcolor:'#761E6A',thtextcolor:'#FFFFFF',titlecolor:'#761E6A',dimensionCode:"purpose",bordercolor:'#E4D2E1',
  357. desc:`「宗旨与动机」维度,我们旨在探究团队是否有清晰的存在理由和明确的方向,能够激发团队成员的动力并吸引他们的想象力,以及个人与集体的身份认同是否围绕共同的目标,并在实现目标的优先次序上达成一致。`
  358. },
  359. {
  360. title:'外部流程、系统与结构',thbgcolor:'#009191',thtextcolor:'#FFFFFF',titlecolor:'#009191',dimensionCode:"external",bordercolor:'#B3DEDE',
  361. desc:`「外部流程、系统与结构」维度,我们旨在探究团队如何与各种利益相关者互动,他们与团队的利益相关方各自如何寻求了解对方,以及现有系统和流程的有效性,以帮助管理不同利益相关者的期望和需求。`
  362. },
  363. {
  364. title:'人际关系',thbgcolor:'#FFD750',thtextcolor:'#002846',titlecolor:'#002846',dimensionCode:"relationship",bordercolor:'#FFEBA8',
  365. desc:`「人际关系」维度,我们旨在探究团队成员相互沟通交流的状态,团队成员的信任程度、尊重和关心的程度、心理安全度,以及团队成员之间的关系如何促进(或破坏)协作。`
  366. },
  367. {
  368. title:'内部流程、系统与结构',thbgcolor:'#4EB2B2',thtextcolor:'#FFFFFF',titlecolor:'#33A7A7',dimensionCode:"internal",bordercolor:'#B3DEDE',
  369. desc:`「内部流程、系统与结构」维度,我们旨在探究团队在管理工作任务和流程中如何平衡责任与自主权进行协作。主要关注团队应对变化时的敏捷程度、日常沟通方式以及内部决策过程的有效性。`
  370. },
  371. {
  372. title:'学习',thbgcolor:'#AFCDF5',thtextcolor:'#002846',titlecolor:'#002846',dimensionCode:"learning",bordercolor:'#C7DCF8',
  373. desc:`「学习」维度,我们旨在探究团队如何提高其绩效(完成当下的任务)、能力(提高技能和资源以处理明天的任务)和容量(⻓期的愿景,用更少的资源做更多的事情)以应对当前和未来的任务。同时还关注团队如何管理这些能力和提高效率。`
  374. },
  375. {
  376. title:'领导力',thbgcolor:'#002846',thtextcolor:'#FFFFFF',titlecolor:'#002846',dimensionCode:"leadership",bordercolor:'#E6EAED',
  377. desc:`「领导力」维度,我们旨在探究团队领导者的素质和行为(包括但不限于正式与非正式的引导、赋能与责任承担方式)如何对团队功能和其他因素产生影响,以及这是积极的还是消极的。`
  378. }
  379. ]
  380. this.reportData.dimensionAnalysis.forEach((d,i)=>{
  381. d.scoreSpreads.forEach(s=>{
  382. s.theme = s.theme.replaceAll(',',' ').replaceAll(',','');
  383. })
  384. let temp = tempDimensionAnalysis.find(t=>t.dimensionCode === d.dimensionCode)||{};
  385. this.reportData.dimensionAnalysis[i] = {...d,...temp}
  386. })
  387. // 【关键逻辑】在数据渲染后,开始预加载图片
  388. await this.$nextTick(); // 确保DOM更新完毕
  389. try {
  390. const imageUrls = this.collectImageUrls();
  391. const results = await this.preloadAllImages(imageUrls);
  392. // (可选) 检查加载结果并上报或提示
  393. const failedImages = results
  394. .filter(result => result.status === 'rejected')
  395. .map(result => result.reason.url); // 获取加载失败的图片URL
  396. if (failedImages.length > 0) {
  397. console.error(`加载失败的图片 (重试3次后):`, failedImages);
  398. this.$showToast('部分图片资源加载失败');
  399. } else {
  400. console.log('所有依赖的图片已加载完成!');
  401. }
  402. } catch (error) {
  403. // Promise.allSettled 本身不应该抛出错误,这里作为保险
  404. console.error('预加载过程中发生意外错误:', error);
  405. } finally {
  406. // 无论成功或失败,最后都隐藏loading
  407. this.isLoading = false;
  408. }
  409. }).catch(err => {
  410. // 网络请求失败等情况
  411. console.error('获取报告数据失败:', err);
  412. this.isLoading = false;
  413. this.$showToast('获取报告数据失败,请检查网络');
  414. });
  415. },
  416. /**
  417. * @description 新增:收集页面上所有需要预加载的图片URL
  418. * @returns {Array<string>} 包含所有图片URL的数组
  419. */
  420. collectImageUrls() {
  421. // 使用 Set 来自动去重
  422. const imageUrls = new Set();
  423. const baseUrl = 'https://oss.familydaf.cn/sxsnfile/';
  424. // 1. 静态图片 (封面、介绍等)
  425. imageUrls.add(baseUrl + '20251230/b70c19716d86452aaa0c9808a2851e8b.png');
  426. console.log(`[Preload] 收集到 ${imageUrls.size} 个待加载的图片URL`);
  427. return Array.from(imageUrls); // 将 Set 转换为数组
  428. },
  429. /**
  430. * @description 【新增】带重试逻辑的单个图片加载器
  431. * @param {string} url 图片URL
  432. * @param {number} maxRetries 最大重试次数
  433. * @returns {Promise} 成功时 resolve, 彻底失败时 reject
  434. */
  435. loadImageWithRetry(url, maxRetries = 5) {
  436. return new Promise((resolve, reject) => {
  437. let attempts = 0;
  438. const tryLoad = () => {
  439. attempts++;
  440. uni.getImageInfo({
  441. src: url,
  442. success: (res) => {
  443. // console.log(`图片加载成功: ${url} (尝试次数: ${attempts})`);
  444. resolve(res);
  445. },
  446. fail: (err) => {
  447. console.warn(`图片加载失败: ${url} (尝试次数: ${attempts}/${maxRetries})`);
  448. if (attempts < maxRetries) {
  449. // 稍作延迟后重试,避免立即请求导致服务器压力
  450. setTimeout(tryLoad, 300);
  451. } else {
  452. // 达到最大重试次数,彻底失败
  453. console.error(`图片彻底加载失败: ${url}`);
  454. reject({ url, error: err }); // reject时返回包含url的对象,方便追踪
  455. }
  456. }
  457. });
  458. };
  459. tryLoad();
  460. });
  461. },
  462. /**
  463. * @description 【优化】预加载所有图片,并处理重试逻辑
  464. * @param {Array<string>} urls 图片URL数组
  465. * @returns {Promise<Array<Object>>} 返回 Promise.allSettled 的结果数组
  466. */
  467. preloadAllImages(urls) {
  468. const promises = urls.map(url => this.loadImageWithRetry(url, 5));
  469. // 使用 Promise.allSettled
  470. // 它会等待所有 Promise 完成(无论是 resolve还是reject)
  471. // 这样即使有图片加载失败,也不会中断整个过程
  472. return Promise.allSettled(promises);
  473. },
  474. async createPdf(){
  475. uni.showLoading({
  476. title:'正在生成PDF所需的图片...'
  477. })
  478. try {
  479. const ztzdfxImgPromise = this.downloadZtzdfxImg();
  480. const dimensionImagePromises = this.reportData.dimensionAnalysis.map(d => {
  481. return this.generateScoreImage(d,d.scoreSpreads);
  482. });
  483. const allImageUrls = await Promise.all([
  484. ztzdfxImgPromise,
  485. ...dimensionImagePromises
  486. ]);
  487. this.pdfImages = allImageUrls;
  488. this.$api.post('/core/report/reportToPdf',{
  489. images:this.pdfImages,
  490. reportId:this.reportId
  491. }).then(({data:res})=>{
  492. if(res.code!==0) return this.$showToast(res.msg)
  493. uni.hideLoading();
  494. this.$showToast('生成成功');
  495. setTimeout(()=>{
  496. uni.redirectTo({
  497. url:'/pagesHome/report'
  498. })
  499. },1500)
  500. })
  501. } catch (error) {
  502. uni.hideLoading();
  503. console.error('生成图片过程中发生错误:', error);
  504. uni.showToast({ title: '生成图片失败,请重试', icon: 'none' });
  505. }
  506. },
  507. // 绘制主函数
  508. async generateScoreImage(dimensionData, scoreData) {
  509. return new Promise(resolve => {
  510. console.log('开始生成图片...');
  511. // --- 1. 定义尺寸和样式 ---
  512. const canvasWidth = 588;
  513. const headerHeight = 26;
  514. const rowHeight = 54;
  515. const totalHeight = headerHeight + rowHeight * scoreData.length;
  516. const leftColWidth = 280;
  517. const rightColWidth = 308;
  518. // --- 2. 获取 Canvas 节点 ---
  519. const query = uni.createSelectorQuery().in(this);
  520. query.select('#score-canvas')
  521. .fields({
  522. node: true,
  523. size: true
  524. })
  525. .exec(async (res) => {
  526. if (!res || !res[0] || !res[0].node) {
  527. console.error('获取 Canvas 节点失败,请检查 canvas-id 和 type="2d" 是否正确设置。');
  528. uni.showToast({
  529. title: '组件初始化失败',
  530. icon: 'none'
  531. });
  532. return;
  533. }
  534. const canvasNode = res[0].node;
  535. const ctx = canvasNode.getContext('2d');
  536. const dpr = uni.getSystemInfoSync().pixelRatio;
  537. // --- 3. 设置画布尺寸和缩放以适应高分屏 ---
  538. canvasNode.width = canvasWidth * dpr;
  539. canvasNode.height = totalHeight * dpr;
  540. ctx.scale(dpr, dpr);
  541. // --- 4. 开始绘制 ---
  542. // 绘制大背景
  543. ctx.fillStyle = '#FFFFFF';
  544. ctx.fillRect(0, 0, canvasWidth, totalHeight);
  545. // --- 5. 绘制表头 ---
  546. // 左侧表头背景
  547. ctx.fillStyle = dimensionData.thbgcolor;
  548. ctx.fillRect(0, 0, leftColWidth, headerHeight);
  549. // 右侧表头背景
  550. ctx.fillRect(leftColWidth, 0, rightColWidth, headerHeight);
  551. // 左侧表头文字
  552. ctx.fillStyle = dimensionData.thtextcolor;
  553. ctx.font = 'bold 9px sans-serif';
  554. ctx.textBaseline = 'middle';
  555. ctx.textAlign = 'left';
  556. ctx.fillText('主题', 15, headerHeight / 2);
  557. // 左侧表头分割线
  558. ctx.strokeStyle = 'rgba(255,255,255,0.24)';
  559. ctx.lineWidth = 1;
  560. ctx.beginPath();
  561. ctx.moveTo(leftColWidth - 54, 0);
  562. ctx.lineTo(leftColWidth - 54, headerHeight);
  563. ctx.stroke();
  564. // 影响力分右侧分割线 (Header)
  565. ctx.beginPath();
  566. ctx.moveTo(leftColWidth, 0);
  567. ctx.lineTo(leftColWidth, headerHeight);
  568. ctx.stroke();
  569. ctx.textAlign = 'center';
  570. ctx.fillText('影响力分', leftColWidth - 27, headerHeight / 2);
  571. // 右侧表头分割线
  572. ctx.beginPath();
  573. ctx.moveTo(leftColWidth + rightColWidth / 2, 0);
  574. ctx.lineTo(leftColWidth + rightColWidth / 2, headerHeight);
  575. ctx.stroke();
  576. // 右侧表头文字
  577. ctx.fillText('认同度分', leftColWidth + rightColWidth / 4, headerHeight / 2);
  578. ctx.fillText('重要性分', leftColWidth + rightColWidth * 0.75, headerHeight / 2);
  579. // --- 6. 循环绘制每一行 ---
  580. for (let i = 0; i < scoreData.length; i++) {
  581. const item = scoreData[i];
  582. const yPos = headerHeight + i * rowHeight;
  583. this.drawTableItem(ctx, item, yPos, leftColWidth, rightColWidth, rowHeight, dimensionData);
  584. }
  585. // --- 7. 绘制最外层边框 ---
  586. ctx.strokeStyle = dimensionData.bordercolor;
  587. ctx.lineWidth = 1;
  588. ctx.strokeRect(0, 0, canvasWidth, totalHeight);
  589. // --- 9. 生成图片 ---
  590. uni.hideLoading();
  591. uni.canvasToTempFilePath({
  592. canvas: canvasNode,
  593. x: 0,
  594. y: 0,
  595. width: canvasWidth,
  596. height: totalHeight,
  597. destWidth: canvasWidth * dpr,
  598. destHeight: totalHeight * dpr,
  599. success: async (result) => {
  600. console.log('图片生成成功!', result.tempFilePath);
  601. const fileurl = await this.uploadFilePromise(result.tempFilePath);
  602. console.log(fileurl, 'fileurl');
  603. resolve(fileurl)
  604. },
  605. fail: (err) => {
  606. console.error('图片生成失败', err);
  607. uni.showToast({
  608. title: '图片生成失败',
  609. icon: 'none'
  610. });
  611. }
  612. }, this);
  613. });
  614. })
  615. },
  616. drawTableItem(ctx, item, y, leftW, rightW, h, dimensionData) {
  617. // 1. 设置通用边框样式
  618. ctx.strokeStyle = dimensionData.bordercolor;
  619. ctx.lineWidth = 1;
  620. // 绘制整行下边框 (贯穿左右)
  621. ctx.beginPath();
  622. ctx.moveTo(0, y + h);
  623. ctx.lineTo(leftW + rightW, y + h);
  624. ctx.stroke();
  625. // --- 计算高度 ---
  626. // 必须先设置字体,否则 measureText 计算不准确
  627. ctx.font = 'bold 9px sans-serif';
  628. let themeHeight = this.calculateWrappedTextHeight(ctx, item.theme, 14, leftW - 54 - 20);
  629. ctx.font = '8px sans-serif';
  630. let questionHeight = this.calculateWrappedTextHeight(ctx, item.question, 10, leftW - 54 - 20);
  631. let totalTextHeight = themeHeight + 4 + questionHeight; // 4 is spacing
  632. let startY = y + (h - totalTextHeight) / 2;
  633. // --- 绘制左侧文字 ---
  634. // Theme Title
  635. ctx.fillStyle = dimensionData.titlecolor;
  636. ctx.font = 'bold 9px sans-serif';
  637. ctx.textAlign = 'left';
  638. ctx.textBaseline = 'top';
  639. this.drawWrappedTextTop(ctx, item.theme, 10, startY, 14, leftW - 54 - 20);
  640. // Question Tip
  641. ctx.fillStyle = '#002846';
  642. ctx.font = '8px sans-serif';
  643. this.drawWrappedTextTop(ctx, item.question, 10, startY + themeHeight + 4, 10, leftW - 54 - 20);
  644. // Score
  645. ctx.fillStyle = '#002846';
  646. ctx.font = 'bold 12px DIN, sans-serif';
  647. ctx.textAlign = 'center';
  648. ctx.textBaseline = 'middle';
  649. ctx.fillText((item.regular && item.regular.avgScore) || 0, leftW - 27, y + h / 2);
  650. // 2. 右侧
  651. const rightX = leftW;
  652. // 绘制中间线
  653. const centerX = rightX + rightW / 2;
  654. // Bar Charts
  655. const barHeight = 10;
  656. const barY = y + (h - barHeight) / 2;
  657. // Agreement (Left, Red/Purple)
  658. // Width = avgAgreement / 6 * 100% of half width?
  659. const maxVal = 6;
  660. const halfW = rightW / 2;
  661. const avgAgreement = (item.regular && item.regular.avgAgreement) || 0;
  662. const avgVital = (item.regular && item.regular.avgVital) || 0;
  663. const agreeW = (avgAgreement / maxVal) * halfW;
  664. const vitalW = (avgVital / maxVal) * halfW;
  665. // --- 绘制背景轨道 (灰色) ---
  666. // 模仿 CSS .vbt2r-tb-l-pre-bg: width: calc(100% - 16px); height: 4px;
  667. // 左右各留 8px 空隙?或者就是简单的横条
  668. const trackHeight = 4;
  669. const trackY = y + (h - trackHeight) / 2;
  670. ctx.fillStyle = '#E6EAED';
  671. // 左侧轨道背景 (从右向左)
  672. this.drawRoundedRect(ctx, rightX + 8, trackY, halfW - 8, trackHeight, 2);
  673. // 右侧轨道背景 (从左向右)
  674. this.drawRoundedRect(ctx, centerX, trackY, halfW - 8, trackHeight, 2);
  675. // Draw Agreement Bar (grows from center to left)
  676. ctx.fillStyle = '#BA8EB4';
  677. // 左侧条,圆角在左边 [2, 0, 0, 2]
  678. this.drawCustomRoundedRect(ctx, centerX - agreeW, barY, agreeW, barHeight, [2, 0, 0, 2]);
  679. // Draw Vital Bar (grows from center to right)
  680. ctx.fillStyle = '#80C8C8';
  681. // 右侧条,圆角在右边 [0, 2, 2, 0]
  682. this.drawCustomRoundedRect(ctx, centerX, barY, vitalW, barHeight, [0, 2, 2, 0]);
  683. // --- 绘制数字标签 ---
  684. const tagW = 16;
  685. const tagH = 20;
  686. // 左标签位置 (中心点)
  687. // CSS: left: -8px (relative to bar start/end).
  688. // 实际上是在条形图的末端(远离中心的那一端)
  689. // 左侧条形图末端 x = centerX - agreeW
  690. // 标签中心 x = centerX - agreeW
  691. this.drawValueTag(ctx, avgAgreement, centerX - agreeW, y + h/2, '#904A87', 'rgba(131,52,120,0.19)', 'rgba(118,30,106,0.1)');
  692. // 右标签位置
  693. // 右侧条形图末端 x = centerX + vitalW
  694. this.drawValueTag(ctx, avgVital, centerX + vitalW, y + h/2, '#199C9C', 'rgba(51,167,167,0.31)', 'rgba(118,30,106,0.1)');
  695. },
  696. // 辅助函数:绘制带样式的数值标签
  697. drawValueTag(ctx, value, cx, cy, textColor, borderColor, shadowColor) {
  698. const width = 16;
  699. const height = 20;
  700. const x = cx - width / 2;
  701. const y = cy - height / 2;
  702. const radius = 4;
  703. ctx.save();
  704. // 阴影
  705. ctx.shadowOffsetX = 0;
  706. ctx.shadowOffsetY = 4;
  707. ctx.shadowBlur = 8;
  708. ctx.shadowColor = shadowColor;
  709. // 背景
  710. ctx.fillStyle = '#FFFFFF';
  711. this.drawRoundedRectPath(ctx, x, y, width, height, radius);
  712. ctx.fill();
  713. // 边框 (取消阴影绘制边框)
  714. ctx.shadowColor = 'transparent';
  715. ctx.strokeStyle = borderColor;
  716. ctx.lineWidth = 1;
  717. ctx.stroke();
  718. // 文字
  719. ctx.fillStyle = textColor;
  720. ctx.font = 'bold 12px DIN, sans-serif';
  721. ctx.textAlign = 'center';
  722. ctx.textBaseline = 'middle';
  723. ctx.fillText(value, cx, cy);
  724. ctx.restore();
  725. },
  726. // 辅助函数:绘制圆角矩形路径
  727. drawRoundedRectPath(ctx, x, y, w, h, r) {
  728. ctx.beginPath();
  729. ctx.moveTo(x + r, y);
  730. ctx.lineTo(x + w - r, y);
  731. ctx.arcTo(x + w, y, x + w, y + h, r);
  732. ctx.lineTo(x + w, y + h - r);
  733. ctx.arcTo(x + w, y + h, x, y + h, r);
  734. ctx.lineTo(x + r, y + h);
  735. ctx.arcTo(x, y + h, x, y, r);
  736. ctx.lineTo(x, y + r);
  737. ctx.arcTo(x, y, x + w, y, r);
  738. ctx.closePath();
  739. },
  740. // 辅助函数:绘制圆角矩形 (简单版)
  741. drawRoundedRect(ctx, x, y, w, h, r) {
  742. this.drawRoundedRectPath(ctx, x, y, w, h, r);
  743. ctx.fill();
  744. },
  745. // 辅助函数:绘制自定义四个角圆角的矩形
  746. drawCustomRoundedRect(ctx, x, y, w, h, radii) {
  747. // radii: [tl, tr, br, bl]
  748. if (!Array.isArray(radii)) radii = [radii, radii, radii, radii];
  749. const [tl, tr, br, bl] = radii;
  750. ctx.beginPath();
  751. ctx.moveTo(x + tl, y);
  752. ctx.lineTo(x + w - tr, y);
  753. ctx.arcTo(x + w, y, x + w, y + h, tr);
  754. ctx.lineTo(x + w, y + h - br);
  755. ctx.arcTo(x + w, y + h, x, y + h, br);
  756. ctx.lineTo(x + bl, y + h);
  757. ctx.arcTo(x, y + h, x, y, bl);
  758. ctx.lineTo(x, y + tl);
  759. ctx.arcTo(x, y, x + w, y, tl);
  760. ctx.closePath();
  761. ctx.fill();
  762. },
  763. // 辅助函数:计算自动换行文字的总高度
  764. calculateWrappedTextHeight(ctx, text, lineHeight, maxWidth) {
  765. if (!text) return 0;
  766. let words = text.split('');
  767. let line = '';
  768. let height = lineHeight; // 至少有一行
  769. for (let n = 0; n < words.length; n++) {
  770. let testLine = line + words[n];
  771. let metrics = ctx.measureText(testLine);
  772. let testWidth = metrics.width;
  773. if (testWidth > maxWidth && n > 0) {
  774. line = words[n];
  775. height += lineHeight;
  776. } else {
  777. line = testLine;
  778. }
  779. }
  780. return height;
  781. },
  782. // 辅助函数:绘制自动换行文字 (从顶部开始)
  783. drawWrappedTextTop(ctx, text, x, y, lineHeight, maxWidth) {
  784. if (!text) return;
  785. let words = text.split('');
  786. let line = '';
  787. let currentY = y;
  788. for (let n = 0; n < words.length; n++) {
  789. let testLine = line + words[n];
  790. let metrics = ctx.measureText(testLine);
  791. let testWidth = metrics.width;
  792. if (testWidth > maxWidth && n > 0) {
  793. ctx.fillText(line, x, currentY); // 使用 currentY 作为顶部基线
  794. line = words[n];
  795. currentY += lineHeight;
  796. } else {
  797. line = testLine;
  798. }
  799. }
  800. ctx.fillText(line, x, currentY);
  801. },
  802. calculateScaleAndPosition() {
  803. uni.getSystemInfo({
  804. success: (res) => {
  805. const screenWidth = res.windowWidth; // 手机屏幕的宽度
  806. const pcContentWidth = 630; // PC端内容的原始宽度
  807. this.scale = screenWidth / pcContentWidth;
  808. this.$nextTick(() => {
  809. if (this.$refs.ztzdfxRef) {
  810. this.initZtzdfxChart();
  811. }
  812. });
  813. }
  814. });
  815. },
  816. calculatePdfContainerHeight() {
  817. uni.createSelectorQuery().in(this).select('#pdfContainer').boundingClientRect(rect => {
  818. if (rect) {
  819. this.originalContainerHeight = rect.height;
  820. this.containerScaledHeight = this.originalContainerHeight * this.scale;
  821. // console.log('原始高度:', this.originalContainerHeight, '缩放比例:', this.scale, '缩放后高度:', this.containerScaledHeight);
  822. }
  823. }).exec();
  824. },
  825. downloadZtzdfxImg(){
  826. return new Promise(resolve=>{
  827. if (!this.isChartReady) return console.log('图表尚未准备好');
  828. const chartRef = this.$refs.ztzdfxRef;
  829. if (!chartRef) return console.log('无法找到图表组件');
  830. chartRef.canvasToTempFilePath({
  831. success: async (res) => {
  832. const imgUrl = await this.uploadFilePromise(res.tempFilePath);
  833. console.log(imgUrl,'imgUrl');
  834. resolve(imgUrl)
  835. },
  836. fail: (err) => {
  837. console.log('生成图片失败:', err);
  838. }
  839. });
  840. })
  841. },
  842. uploadFilePromise(url) {
  843. return new Promise((resolve, reject) => {
  844. let a = uni.uploadFile({
  845. url: BaseApi+'/uploadFile',
  846. filePath: url,
  847. name: 'file',
  848. success: (res) => {
  849. setTimeout(() => {
  850. let data = JSON.parse(res.data)
  851. if(data&&data.code===0){
  852. resolve(data.data);
  853. }else this.$showToast(data?.msg)
  854. }, 1000);
  855. },
  856. fail: err =>{
  857. resolve('');
  858. }
  859. });
  860. });
  861. },
  862. async initZtzdfxChart() {
  863. let dataSum = this.reportData.overall.length*this.reportData.overall[0].themeTotalSpreads.length;
  864. const leaderData = [],memberData = [],stakeholderData=[],sponsorData=[];
  865. const overall = this.reportData.overall||[];
  866. overall.forEach(o=>{
  867. let themeTotalSpreads = o.themeTotalSpreads||[];
  868. if(['内部流程、系统与结构','学习','领导力'].includes(o.dimension)) themeTotalSpreads = o.themeTotalSpreads.reverse()||[];
  869. themeTotalSpreads.forEach(t=>{
  870. leaderData.push(t.scoreLeader||0);
  871. memberData.push(t.scoreMember||0);
  872. stakeholderData.push(t.scoreStakeholder||0);
  873. sponsorData.push(t.scoreSponsor||0);
  874. })
  875. })
  876. const sumArr = leaderData.concat(memberData).concat(stakeholderData).concat(sponsorData);
  877. const maxValue = sumArr.reduce((a,b)=>Math.max(a,b));
  878. const minValue = sumArr.reduce((a,b)=>Math.min(a,b));
  879. const chart = await this.$refs.ztzdfxRef.init(echarts);
  880. let option = {
  881. graphic: [
  882. {
  883. type: 'image',
  884. id: 'radar-bg',
  885. z: -1,
  886. bounding: 'raw',
  887. left: 'center',
  888. top: 'center',
  889. style: {
  890. image:'https://oss.familydaf.cn/sxsnfile/20251230/b70c19716d86452aaa0c9808a2851e8b.png',
  891. width: 360*this.scale-20,
  892. height: 360*this.scale-20,
  893. opacity: 1
  894. }
  895. },
  896. {
  897. type: 'circle',
  898. z: 100, // 设置一个较高的 z 值,确保它在最顶层
  899. left: 'center', // 水平居中
  900. top: 'center', // 垂直居中
  901. shape: {
  902. r: 12*this.scale // 圆形的半径,您可以根据需要调整大小
  903. },
  904. style: {
  905. fill: '#FFFFFF', // 填充色为白色
  906. shadowBlur: 20*this.scale, // 阴影的模糊范围
  907. shadowColor: 'rgba(0, 0, 0, 0.15)', // 阴影颜色
  908. shadowOffsetY: 4*this.scale // 向下的阴影偏移,产生悬浮效果
  909. }
  910. }
  911. ],
  912. radar: {
  913. // shape: 'circle',
  914. indicator: new Array(dataSum).fill({ max:maxValue, min:minValue }),
  915. axisName: {
  916. show: false
  917. },
  918. splitArea:{
  919. show:false
  920. },
  921. splitLine: {
  922. show: false
  923. },
  924. axisLine: {
  925. show: false
  926. },
  927. startAngle: 95
  928. },
  929. series: [
  930. {
  931. type: 'radar',
  932. data: [
  933. {
  934. value: sponsorData,
  935. itemStyle: {
  936. color: '#012846'
  937. },
  938. lineStyle: {
  939. color: '#012846',
  940. width:1
  941. },
  942. areaStyle: {
  943. color: 'rgba(255, 255, 255, 0.4)'
  944. },
  945. symbolSize: 2
  946. },
  947. {
  948. value: stakeholderData,
  949. itemStyle: {
  950. color: '#FFD650'
  951. },
  952. lineStyle: {
  953. color: '#FFD650',
  954. width:1
  955. },
  956. areaStyle: {
  957. color: 'rgba(255, 255, 255, 0.4)'
  958. },
  959. symbolSize: 2
  960. },
  961. {
  962. value: memberData,
  963. itemStyle: {
  964. color: '#AFCDF5'
  965. },
  966. lineStyle: {
  967. color: '#AFCDF5',
  968. width:1
  969. },
  970. areaStyle: {
  971. color: 'rgba(255, 255, 255, 0.4)'
  972. },
  973. symbolSize: 2
  974. },
  975. {
  976. value: leaderData,
  977. itemStyle: {
  978. color: '#9F6196'
  979. },
  980. lineStyle: {
  981. color: '#9F6196',
  982. width:1
  983. },
  984. areaStyle: {
  985. color: 'rgba(255, 255, 255, 0.4)'
  986. },
  987. symbolSize: 2
  988. }
  989. ]
  990. }
  991. ]
  992. };
  993. chart.setOption(option);
  994. this.isChartReady = true;
  995. this.$nextTick(() => {
  996. this.calculatePdfContainerHeight();
  997. });
  998. },
  999. }
  1000. };
  1001. </script>
  1002. <style scoped lang="scss">
  1003. .loading{
  1004. position: fixed;
  1005. left: 0;
  1006. right: 0;
  1007. top: 0;
  1008. bottom: 0;
  1009. background: rgba(0,0,0,.4);
  1010. z-index: 1001;
  1011. }
  1012. .page-wrappe{
  1013. width: 100%;
  1014. background: #FFFFFF;
  1015. overflow-x: hidden;
  1016. overflow-y: auto;
  1017. .pdf-container{
  1018. width: 630px;
  1019. padding: 0 20rpx;
  1020. box-sizing: border-box;
  1021. transform-origin: top left;
  1022. }
  1023. }
  1024. .offscreen-canvas {
  1025. position: fixed;
  1026. top: -9999px;
  1027. left: -9999px;
  1028. }
  1029. .pdf_btn{
  1030. padding: 15rpx 20rpx;
  1031. border-radius: 20rpx;
  1032. font-size: 28rpx;
  1033. color: #FFFFFF;
  1034. background: #189B9B;
  1035. position: fixed;
  1036. right: 30rpx;
  1037. bottom: 100rpx;
  1038. z-index: 1000;
  1039. }
  1040. @import '../static/pdf.scss';
  1041. </style>