pdfZyb.vue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846
  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="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">团队发展动态评估报告(专业版)</view>
  12. <view class="fm2-texts adf" style="margin-top: 5px;">
  13. <view class="fm2-texts-pre adf" style="margin-top: 10px;">
  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: 10px;">
  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: 10px;">
  22. <view class="fm2-texts-pre-span">评估发起人:</view>
  23. <view class="fm2-texts-pre-val">{{ reportData.teamInfo.initiator||'' }}</view>
  24. </view>
  25. <view class="fm2-texts-pre adf" style="margin-top: 10px;">
  26. <view class="fm2-texts-pre-span">报告生成时间:</view>
  27. <view class="fm2-texts-pre-val">{{ reportData.teamInfo.reportDate||'' }}</view>
  28. </view>
  29. <view class="fm2-texts-pre adf" style="margin-top: 10px;">
  30. <view class="fm2-texts-pre-span">团队类型:</view>
  31. <view class="fm2-texts-pre-val">{{ reportData.teamInfo.functionName||'' }}</view>
  32. </view>
  33. <view class="fm2-texts-pre adf" style="margin-top: 10px;">
  34. <view class="fm2-texts-pre-span">团队层级:</view>
  35. <view class="fm2-texts-pre-val">{{ reportData.teamInfo.hierarchy||'' }}</view>
  36. </view>
  37. </view>
  38. </view>
  39. <!-- 介绍 -->
  40. <view class="cd_box">
  41. <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)'}">
  42. <view class="vt-left" style="color: #FFFFFF;">介绍<span>PERILL团队发展动态评估简介</span></view>
  43. <view class="vt-right">PERILL团队发展动态评估报告(专业版)</view>
  44. </view>
  45. <view class="v2-box">
  46. <img class="vb-img1" :src="'https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/'+'intro'+'_box_img1.png'">
  47. <img class="vb-img2" :src="'https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/'+'intro'+'_box_img2.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||0}}</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.image"/>
  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">
  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">PERILL团队发展动态评估报告(专业版)</view>
  74. </view>
  75. <view class="v2-box" @click="downloadZtzdfxImg">
  76. <img class="vb-img1" :src="'https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/'+'intro'+'_box_img1.png'">
  77. <img class="vb-img2" :src="'https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/'+'intro'+'_box_img2.png'">
  78. <view class="v2-p2">报告的核心是PERILL团队发展动态评估分析下的整体团队表现。这包括团队在PERILL团队发展动态评估每个关键要素上的综合得分,通过结合得分和置信指数,我们能够展示出高功能领域和低功能域。</view>
  79. <view class="v2-p2" style="margin-top: 16px;">下面图中的位置标记显示了团队按主题划分的总分。</view>
  80. <view class="vb-category">
  81. <view class="vbc-pre adfac">
  82. <view class="vbcp-yuan y1"></view>
  83. <view class="vbcp-text">团队Leader</view>
  84. </view>
  85. <view class="vbc-pre adfac">
  86. <view class="vbcp-yuan y2"></view>
  87. <view class="vbcp-text">团队Member</view>
  88. </view>
  89. <view class="vbc-pre adfac">
  90. <view class="vbcp-yuan y3"></view>
  91. <view class="vbcp-text">利益相关方Stakeholder</view>
  92. </view>
  93. <view class="vbc-pre adfac">
  94. <view class="vbcp-yuan y4"></view>
  95. <view class="vbcp-text">赞助人Sponsor</view>
  96. </view>
  97. </view>
  98. <view style="width:360px;height:360px;margin: 0 auto;" class="pdfEchart">
  99. <l-echart ref="ztzdfxRef" :canvas2d="true" @finished="initZtzdfxChart" style="width: 100%;height: 100%;"></l-echart>
  100. </view>
  101. </view>
  102. <view class="v2-data">
  103. <view class="vd-title" :style="{'background-image':'url(https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/'+'intro'+'_title_bg1.png)'}">评估结果</view>
  104. <view class="v2-p" v-html="(reportData.totalDiagnosticOutput||'').replaceAll('\n\n','<br>')"></view>
  105. </view>
  106. <view class="v2-data" style="flex: 1;margin-top: 20px;">
  107. <view class="vd-title vt2" :style="{'background-image':'url(https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/'+'intro'+'_title_bg2.png)'}">团队提升&教练建议</view>
  108. <view class="v2-p" v-html="(reportData.totalDiagnosisSuggest||'').replaceAll('\n\n','<br>')"></view>
  109. </view>
  110. </view>
  111. <!-- 多维度 -->
  112. <canvas type="2d" id="table-canvas" canvas-id="table-canvas" class="offscreen-canvas"></canvas>
  113. <template v-if="reportData&&reportData.dimensionAnalysis&&reportData.dimensionAnalysis.length">
  114. <view class="cd_box adffc" style="border: none;" :style="{'background-image':'url('+'https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/'+typeDict[item.title]+'_bg.png)'}" v-for="(item,index) in reportData.dimensionAnalysis" :key="index">
  115. <view class="v2-top adfacjb" :style="{'background-image':'url('+'https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/'+typeDict[item.title]+'_title_bg.png)'}">
  116. <view class="vt-left" :class="{'black':(item.title=='人际关系'||item.title=='学习')}">{{ item.title }}</view>
  117. <view class="vt-right">PERILL团队发展动态评估报告(专业版)</view>
  118. </view>
  119. <view class="v2-box" :style="{'border':'1px solid '+item.bcolor}">
  120. <img class="vb-img1" :src="'https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/'+typeDict[item.title]+'_box_img1.png'">
  121. <img class="vb-img2" :src="'https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/'+typeDict[item.title]+'_box_img2.png'">
  122. <view class="v2-p2">{{ item.desc }}</view>
  123. <!-- <view class="v2-p2" style="margin-top: 16px;">评分总体分布</view> -->
  124. <view class="vb-table" :style="{'border':'1px solid '+item.bcolor,'margin-top':'22px'}">
  125. <view class="vbt-th adfac" :class="{'black':(item.title=='人际关系'||item.title=='学习')}" :style="{'background':item.thcolor}">
  126. <view class="vbtt-w1">主题</view>
  127. <view class="vbtt-w2">最低分</view>
  128. <view class="vbtt-w2">平均分</view>
  129. <view class="vbtt-w2">最高分</view>
  130. <view class="vbtt-w3">问卷陈述</view>
  131. </view>
  132. <view class="vbt-pre adfac" v-for="(ss,si) in item.scoreSpreads" :key="si">
  133. <view class="vbtp-left vbtt-w1 adfacjc" :class="{'black':(item.title=='人际关系'||item.title=='学习'||item.title=='内部流程及系统与架构')}" :style="{'background':item.titlecolor,'padding':'0 16px'}">{{ ss.theme||'' }}</view>
  134. <view class="vbtp-num vbtt-w2" :style="{'border-bottom':'1px solid '+item.bcolor}">{{ ss.minScore||0 }}</view>
  135. <view class="vbtp-num vbtt-w2 green" :style="{'border-bottom':'1px solid '+item.bcolor}">{{ ss.avgScore||0 }}</view>
  136. <view class="vbtp-num vbtt-w2" :style="{'border-bottom':'1px solid '+item.bcolor}">{{ ss.maxScore||0 }}</view>
  137. <view class="vbtp-desc" :style="{'border-bottom':'1px solid '+item.bcolor}">
  138. <view class="vbtpd-title">{{ ss.question||'' }}</view>
  139. <view class="xr_tb adfac">
  140. <view class="xt_pre p1"></view>
  141. <view class="xt_pre p2"></view>
  142. <view class="xt_pre p3"></view>
  143. <view class="xt_score adfac" :style="{'left':ss.left,'width':(((ss.maxScore>25?25:ss.maxScore)-(ss.minScore>25?25:ss.minScore))*4)+'%'}">
  144. <view class="xts_num adfacjc red">{{ ss.minScore>25?25:ss.minScore }}</view>
  145. <view class="xts_box"></view>
  146. <view class="xts_num adfacjc green">{{ ss.maxScore>25?25:ss.maxScore }}</view>
  147. </view>
  148. </view>
  149. </view>
  150. </view>
  151. </view>
  152. </view>
  153. <view class="v2-data" :style="{'border':'1px solid '+item.bcolor}">
  154. <view class="vd-title vt3" :class="{'black':(item.title=='人际关系'||item.title=='学习')}" :style="{'background-image':'url(https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/'+typeDict[item.title]+'_title_bg1.png)'}">评估结果</view>
  155. <view class="adfac">
  156. <view class="v2-p3" style="width: 76px;">纬度得分</view>
  157. <view class="vd-wd adfac" :style="{'background':item.wddf}">
  158. <view class="vdwd-pre">维度加权总分:<span>{{ item.weightedTotal||0 }}</span><span>/{{ item.weightedTotalFull||0 }}</span></view>
  159. <view class="vdwd-pre vp">维度同意度总分(未加权):<span>{{ item.consentTotal||0 }}</span><span>/{{ item.consentTotalFull||0 }}</span></view>
  160. <view class="vdwd-pre">维度权重:<span>{{ item.weight||0 }}</span><span>/{{ item.weightFull||0 }}</span></view>
  161. </view>
  162. </view>
  163. <view class="v2-p" style="margin-top: 8px;" v-html="(item.diagnosisOutput||'').replaceAll('\n\n','<br>')"></view>
  164. </view>
  165. <view class="v2-data" :style="{'border':'1px solid '+item.bcolor}" style="flex: 1;margin-top: 15px;">
  166. <view class="vd-title vt3" :class="{'black':(item.title=='人际关系'||item.title=='学习')}" :style="{'background-image':'url(https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/'+typeDict[item.title]+'_title_bg1.png)'}">评估建议</view>
  167. <view class="v2-p" v-html="(item.diagnosisSuggest||'').replaceAll('\n\n','<br>')"></view>
  168. </view>
  169. </view>
  170. </template>
  171. </view>
  172. <view class="pdf_btn" @click="createPdf">生成PDF</view>
  173. </view>
  174. </template>
  175. <script name="">
  176. import { BaseApi } from '@/http/baseApi.js';
  177. import * as echarts from '@/pagesHome/components/lime-echart/static/echarts.min.js'
  178. import lEchart from '@/pagesHome/components/lime-echart/components/l-echart/l-echart.vue'
  179. export default {
  180. name: 'ZtzdfxChart',
  181. components:{ lEchart },
  182. data() {
  183. return {
  184. reportId:'',
  185. reportData: null,
  186. isChartReady: false,
  187. scale:1,
  188. originalContainerHeight: 0,
  189. containerScaledHeight: 'auto',
  190. typeDict: {
  191. '宗旨与动机': 'zzdj',
  192. '外部流程及系统与架构': 'wbjg',
  193. '人际关系': 'rjgx',
  194. '内部流程及系统与架构': 'nbjg',
  195. '学习': 'xx',
  196. '领导力': 'ldl'
  197. },
  198. sixWd: [
  199. {
  200. image: 'https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/intro_img_p.png',
  201. type: 'P',
  202. title: '宗旨与动机',
  203. desc: '指团队共享的目的和存在的意义, 包含对共同的愿景,目标和优先级的清晰度。',
  204. color: '#761E6A'
  205. },
  206. {
  207. image: 'https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/intro_img_e.png',
  208. type: 'E',
  209. title: '外部流程、系统与结构',
  210. desc: '指团队与其外部利益相关者 - 客户,供应商,股东,组织内的其他团队等的互动关联。',
  211. color: '#009191'
  212. },
  213. {
  214. image: 'https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/intro_img_r.png',
  215. type: 'R',
  216. title: '人际关系',
  217. desc: '指团队成员如何共同工作–他们是否相互尊重对方的能力,足够心理安全以能够坦诚相对,真正关心彼此的幸福感。',
  218. color: '#FFD750'
  219. },
  220. {
  221. image: 'https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/intro_img_i.png',
  222. type: 'I',
  223. title: '内部流程、系统与结构',
  224. desc: '指团队如何管理工作流程,互相支持和高质量的沟通和决策(包括工作任务和团队感情)。',
  225. color: '#4EB2B2'
  226. },
  227. {
  228. image: 'https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/intro_img_l.png',
  229. type: 'L',
  230. title: '学习',
  231. desc: '指团队应对多变的环境和保持持续的进步和成长的能力。团队如何提高绩效(如何完成今天的任务)、能力(如何提高技能和资源以处理明天的任务)和容量(长期的愿景, 如何用更少的资源做更多的事情)',
  232. color: '#AFCDF5'
  233. },
  234. {
  235. image: 'https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/versionTwo/intro_img_l2.png',
  236. type: 'L',
  237. title: '领导力',
  238. desc: '指团队认为需要怎样的领导行为能够让他们,作为个人或者团队做到最好。团队可以和他们的领导者讨论他们的责任,以帮助领导者成为他们需要的领导者。',
  239. color: '#002846'
  240. }
  241. ],
  242. pdfImages:[],
  243. };
  244. },
  245. onLoad(options) {
  246. this.reportId = options.reportId;
  247. this.getReportData();
  248. },
  249. mounted() {
  250. this.calculateScaleAndPosition();
  251. uni.onWindowResize(() => {
  252. this.calculateScaleAndPosition();
  253. });
  254. },
  255. methods: {
  256. getReportData(){
  257. this.$api.get(`/core/report/previewReport/${this.reportId}`).then(({data:res})=>{
  258. if(res.code!==0) return this.$showToast(res.msg)
  259. this.reportData = res.data;
  260. const tempDimensionAnalysis = [
  261. {title:'宗旨与动机',bcolor:'#E4D2E1',thcolor:'#761E6A',titlecolor:'#BA8EB4',wddf:'linear-gradient( 90deg, #F5EFF5 0%, #FAF2F9 100%)',
  262. desc:`「宗旨与动机」维度,我们旨在探究是否存在一个清晰的存在理由和明确的方向,能够激发团队成员的动力并吸引他们的想象力,以及个人与集体的身份认同是否围绕共同的目标,并达成一致。`},
  263. {title:'外部流程及系统与架构',bcolor:'#B3DEDE',thcolor:'#009191',titlecolor:'#80C8C8',wddf:'linear-gradient( 90deg, #E8F5F5 0%, #F0F8F8 100%)',
  264. desc:`「外部流程、系统与结构」维度,我们旨在探究团队如何与各种利益相关者互动,他们与团队的利益相关方各自如何寻求了解对方,以及现有系统和流程的有效性,以帮助管理不同的期望和需求。`},
  265. {title:'人际关系',bcolor:'#FFDF73',thcolor:'#FFD750',titlecolor:'#FFEBA8',wddf:'linear-gradient( 90deg, rgba(255,215,80,0.34) 0%, rgba(251,225,130,0.09) 100%)',
  266. desc:`「人际关系」维度,我们旨在探究团队成员如何相互交流、信任程度、尊重和关心的程度,以及团队成员之间的关系如何促进(或破坏)协作。`},
  267. {title:'内部流程及系统与架构',bcolor:'#B3DEDE',thcolor:'#4EB2B2',titlecolor:'#CDE9EA',wddf:'linear-gradient( 90deg, #E8F5F5 0%, #F0F8F8 100%)',
  268. desc:`「内部流程、系统与结构」维度,我们旨在探究团队如何在平衡责任与自主权方面进行协作。我们关注团队的敏捷程度、沟通方式以及决策过程的有效性。`},
  269. {title:'学习',bcolor:'#C7DCF8',thcolor:'#AFCDF5',titlecolor:'#D7E5FA',wddf:'linear-gradient( 270deg, #F2F5F9 0%, #E3ECF8 100%)',
  270. desc:`「学习」维度,我们旨在探究团队如何提高其绩效、技能和资源以应对当前和未来的任务。我们还希望了解团队如何管理能力和提高效率。`},
  271. {title:'领导力',bcolor:'#E6EAED',thcolor:'#002846',titlecolor:'#8093A3',wddf:'linear-gradient( 270deg, #F2F4F6 0%, #EDF0F2 100%)',
  272. desc:`「领导力」维度,我们旨在探究领导素质和行为如何对团队功能和其他因素产生调节影响,以及这是积极的还是消极的。`}
  273. ]
  274. this.reportData.dimensionAnalysis.forEach((d,i)=>{
  275. d.scoreSpreads.forEach(s=>{
  276. if((s.minScore+'').length>2) s.minScore = (s.minScore||0).toFixed(2)
  277. if((s.maxScore+'').length>2) s.maxScore = (s.maxScore||0).toFixed(2)
  278. if((s.avgScore+'').length>2) s.avgScore = (s.avgScore||0).toFixed(2)
  279. s.theme = s.theme.replaceAll(',','').replaceAll(',','');
  280. s.range = [s.minScore>25?25:s.minScore,s.maxScore>25?25:s.maxScore];
  281. if(s.minScore==0) s.left = '0%';
  282. else if(s.minScore>=25) s.left = 'calc(100% - 48px)';
  283. else s.left = s.minScore*4+'%';
  284. })
  285. this.reportData.dimensionAnalysis[i] = {...d,...tempDimensionAnalysis[i]}
  286. })
  287. })
  288. },
  289. async createPdf(){
  290. uni.showLoading({
  291. title:'正在生成PDF所需的图片...'
  292. })
  293. try {
  294. const ztzdfxImgPromise = this.downloadZtzdfxImg();
  295. const dimensionImagePromises = this.reportData.dimensionAnalysis.map(d => {
  296. return this.generateTableImage(d,d.scoreSpreads);
  297. });
  298. const allImageUrls = await Promise.all([
  299. ztzdfxImgPromise,
  300. ...dimensionImagePromises
  301. ]);
  302. this.pdfImages = allImageUrls;
  303. this.$api.post('/core/report/reportToPdf',{
  304. images:this.pdfImages,
  305. reportId:this.reportId
  306. }).then(({data:res})=>{
  307. if(res.code!==0) return this.$showToast(res.msg)
  308. uni.hideLoading();
  309. this.$showToast('生成成功');
  310. setTimeout(()=>{
  311. uni.redirectTo({
  312. url:'/pagesHome/report'
  313. })
  314. },1500)
  315. })
  316. } catch (error) {
  317. uni.hideLoading();
  318. console.error('生成图片过程中发生错误:', error);
  319. uni.showToast({ title: '生成图片失败,请重试', icon: 'none' });
  320. }
  321. },
  322. /**
  323. * @description 使用 Canvas 绘制表格并生成图片
  324. * @param {Object} dimensionData 维度数据
  325. * @param {Array} tableData 表格数据
  326. * @returns {Promise<string>} 返回生成的图片临时文件路径
  327. */
  328. generateTableImage(dimensionData, tableData) {
  329. return new Promise((resolve, reject) => {
  330. const query = uni.createSelectorQuery().in(this);
  331. query.select('#table-canvas')
  332. .fields({ node: true, size: true })
  333. .exec(async (res) => {
  334. if (!res || !res[0] || !res[0].node) {
  335. return reject('获取Canvas节点失败');
  336. }
  337. const canvasNode = res[0].node;
  338. const ctx = canvasNode.getContext('2d');
  339. const dpr = uni.getSystemInfoSync().pixelRatio;
  340. // --- 1. 定义布局和尺寸常量
  341. const TABLE_WIDTH = 548;
  342. const HEADER_HEIGHT = 38;
  343. const ROW_HEIGHT = 49;
  344. const FONT_FAMILY = 'sans-serif';
  345. const COL_WIDTHS = { theme: 72, min: 49, avg: 49, max: 49, statement: 329 };
  346. const COL_POSITIONS = {
  347. theme: 0,
  348. min: COL_WIDTHS.theme,
  349. avg: COL_WIDTHS.theme + COL_WIDTHS.min,
  350. max: COL_WIDTHS.theme + COL_WIDTHS.min + COL_WIDTHS.avg,
  351. statement: COL_WIDTHS.theme + COL_WIDTHS.min * 3
  352. };
  353. const CANVAS_HEIGHT = HEADER_HEIGHT + tableData.length * ROW_HEIGHT;
  354. const CANVAS_WIDTH = TABLE_WIDTH;
  355. canvasNode.width = CANVAS_WIDTH * dpr;
  356. canvasNode.height = CANVAS_HEIGHT * dpr;
  357. ctx.scale(dpr, dpr);
  358. ctx.fillStyle = '#FFFFFF';
  359. ctx.fillRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
  360. ctx.strokeStyle = dimensionData.bcolor;
  361. ctx.lineWidth = 1;
  362. ctx.strokeRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
  363. // --- 4. 绘制表头 ---
  364. const isBlackHeader = (dimensionData.title == '人际关系'||dimensionData.title == '学习');
  365. ctx.fillStyle = dimensionData.thcolor;
  366. ctx.fillRect(1, 1, CANVAS_WIDTH - 2, HEADER_HEIGHT - 1);
  367. ctx.fillStyle = isBlackHeader ? '#002846' : '#FFFFFF';
  368. ctx.font = `bold 10px ${FONT_FAMILY}`;
  369. ctx.textAlign = 'center';
  370. ctx.textBaseline = 'middle';
  371. ctx.fillText('主题', COL_POSITIONS.theme + COL_WIDTHS.theme / 2, HEADER_HEIGHT / 2);
  372. ctx.fillText('最低分', COL_POSITIONS.min + COL_WIDTHS.min / 2, HEADER_HEIGHT / 2);
  373. ctx.fillText('平均分', COL_POSITIONS.avg + COL_WIDTHS.avg / 2, HEADER_HEIGHT / 2);
  374. ctx.fillText('最高分', COL_POSITIONS.max + COL_WIDTHS.max / 2, HEADER_HEIGHT / 2);
  375. ctx.fillText('问卷陈述', COL_POSITIONS.statement + COL_WIDTHS.statement / 2, HEADER_HEIGHT / 2);
  376. // --- 5. 循环绘制每一行---
  377. tableData.forEach((row, index) => {
  378. const y = HEADER_HEIGHT + index * ROW_HEIGHT;
  379. const isBlackLeftTitle = (dimensionData.title == '人际关系' || dimensionData.title == '学习' || dimensionData.title == '内部流程及系统与架构');
  380. ctx.fillStyle = dimensionData.titlecolor;
  381. ctx.fillRect(1, y, COL_WIDTHS.theme - 1, ROW_HEIGHT);
  382. // 绘制主题文字
  383. ctx.textAlign = 'center';
  384. ctx.textBaseline = 'middle';
  385. ctx.fillStyle = isBlackLeftTitle ? '#002846' : '#FFFFFF';
  386. ctx.font = `10px ${FONT_FAMILY}`;
  387. this.drawWrappedText(ctx, row.theme, COL_POSITIONS.theme + COL_WIDTHS.theme / 2, y + ROW_HEIGHT / 2, 12, COL_WIDTHS.theme - 32);
  388. // 绘制主题单元格的白色下边框
  389. ctx.strokeStyle = '#FFFFFF';
  390. ctx.lineWidth = 1;
  391. ctx.beginPath();
  392. ctx.moveTo(1, y + ROW_HEIGHT - 1);
  393. ctx.lineTo(COL_WIDTHS.theme - 1, y + ROW_HEIGHT - 1);
  394. ctx.stroke();
  395. // 绘制其他单元格的下边框
  396. ctx.strokeStyle = dimensionData.bcolor;
  397. ['min', 'avg', 'max', 'statement'].forEach(key => {
  398. ctx.beginPath();
  399. ctx.moveTo(COL_POSITIONS[key], y + ROW_HEIGHT);
  400. ctx.lineTo(COL_POSITIONS[key] + COL_WIDTHS[key], y + ROW_HEIGHT);
  401. ctx.stroke();
  402. });
  403. const minScore = ((row.minScore||0)+'').length>2?Number(row.minScore||0).toFixed(2):row.minScore;
  404. const avgScore = ((row.avgScore||0)+'').length>2?Number(row.avgScore||0).toFixed(2):row.avgScore;
  405. const maxScore = ((row.maxScore||0)+'').length>2?Number(row.maxScore||0).toFixed(2):row.maxScore;
  406. ctx.font = `bold 14px ${FONT_FAMILY}`;
  407. ctx.fillStyle = '#667E90';
  408. ctx.fillText(minScore, COL_POSITIONS.min + COL_WIDTHS.min / 2, y + ROW_HEIGHT / 2);
  409. ctx.fillStyle = '#27AE60';
  410. ctx.fillText(avgScore, COL_POSITIONS.avg + COL_WIDTHS.avg / 2, y + ROW_HEIGHT / 2);
  411. ctx.fillStyle = '#667E90';
  412. ctx.fillText(maxScore, COL_POSITIONS.max + COL_WIDTHS.max / 2, y + ROW_HEIGHT / 2);
  413. // 5.3 绘制问卷陈述列
  414. const statementX = COL_POSITIONS.statement;
  415. const statementPadding = 10;
  416. ctx.textAlign = 'left';
  417. ctx.textBaseline = 'top';
  418. ctx.fillStyle = '#193D59';
  419. ctx.font = `9px ${FONT_FAMILY}`;
  420. this.drawWrappedText(ctx, row.question, statementX + statementPadding, y + 8, 10, COL_WIDTHS.statement - statementPadding * 2);
  421. // 绘制范围指示器
  422. const rangeBarY = y + 33;
  423. const rangeBarWidth = COL_WIDTHS.statement - statementPadding * 2;
  424. const rangeBarHeight = 4;
  425. const rangeBarX = statementX + statementPadding;
  426. // 绘制三段色背景
  427. const segWidth = rangeBarWidth / 3;
  428. ctx.fillStyle = '#BA8EB4';
  429. ctx.fillRect(rangeBarX, rangeBarY, segWidth, rangeBarHeight);
  430. ctx.fillStyle = '#66BDBD';
  431. ctx.fillRect(rangeBarX + segWidth, rangeBarY, segWidth, rangeBarHeight);
  432. ctx.fillStyle = '#AFCDF5';
  433. ctx.fillRect(rangeBarX + segWidth * 2, rangeBarY, segWidth, rangeBarHeight);
  434. // --- 开始绘制滑块 ---
  435. const scaleFactor = rangeBarWidth / 25;
  436. const minVal = row.range[0];
  437. const maxVal = row.range[1];
  438. const rangeLeft = minVal * scaleFactor;
  439. const rangeWidth = (maxVal - minVal) * scaleFactor;
  440. // 绘制中间的连接条
  441. const connectorY = rangeBarY - (8 - rangeBarHeight) / 2;
  442. const connectorHeight = 8;
  443. ctx.fillStyle = '#199C9C';
  444. ctx.fillRect(rangeBarX + rangeLeft, connectorY, rangeWidth, connectorHeight);
  445. // 绘制左右数字框
  446. const numBoxPadding = { h: 7, v: 4 };
  447. const numBoxFont = `bold 12px ${FONT_FAMILY}`;
  448. // 封装一个绘制数字框的函数
  449. const drawNumberBox = (text, side) => {
  450. ctx.font = numBoxFont;
  451. const metrics = ctx.measureText(text);
  452. const boxWidth = metrics.width + numBoxPadding.h * 2;
  453. const boxHeight = 12 + numBoxPadding.v * 2;
  454. const value = parseFloat(text);
  455. const centerPointX = rangeBarX + value * scaleFactor;
  456. let x;
  457. // 核心逻辑:判断两值是否相等
  458. if (minVal === maxVal) {
  459. // 如果相等,左右滑块并排显示,整体居中
  460. if (side === 'left') {
  461. x = centerPointX - boxWidth;
  462. } else { // 'right'
  463. x = centerPointX;
  464. }
  465. // --- 边界检查(针对组合滑块)---
  466. let combinedLeftX = centerPointX - boxWidth;
  467. if (combinedLeftX < rangeBarX) {
  468. const shift = rangeBarX - combinedLeftX;
  469. x += shift; // 将两个滑块一起向右移动
  470. }
  471. let combinedRightX = centerPointX + boxWidth;
  472. if (combinedRightX > rangeBarX + rangeBarWidth) {
  473. const shift = combinedRightX - (rangeBarX + rangeBarWidth);
  474. x -= shift; // 将两个滑块一起向左移动
  475. }
  476. } else {
  477. // 如果不相等,各自居中显示
  478. x = centerPointX - boxWidth / 2;
  479. // --- 边界检查(针对单个滑块)---
  480. if (x < rangeBarX) {
  481. x = rangeBarX;
  482. }
  483. if (x + boxWidth > rangeBarX + rangeBarWidth) {
  484. x = rangeBarX + rangeBarWidth - boxWidth;
  485. }
  486. }
  487. const boxY = connectorY + (connectorHeight - boxHeight) / 2;
  488. // 绘制阴影
  489. ctx.shadowColor = 'rgba(118, 30, 106, 0.08)';
  490. ctx.shadowBlur = 10;
  491. ctx.shadowOffsetY = 4;
  492. // 绘制圆角矩形背景
  493. ctx.fillStyle = '#FFFFFF';
  494. ctx.beginPath();
  495. ctx.moveTo(x + 4, boxY);
  496. ctx.arcTo(x + boxWidth, boxY, x + boxWidth, boxY + boxHeight, 4);
  497. ctx.arcTo(x + boxWidth, boxY + boxHeight, x, boxY + boxHeight, 4);
  498. ctx.arcTo(x, boxY + boxHeight, x, boxY, 4);
  499. ctx.arcTo(x, boxY, x + boxWidth, boxY, 4);
  500. ctx.closePath();
  501. ctx.fill();
  502. // 重置阴影
  503. ctx.shadowColor = 'transparent';
  504. ctx.shadowBlur = 0;
  505. ctx.shadowOffsetY = 0;
  506. // 绘制边框
  507. ctx.strokeStyle = 'rgba(131, 52, 120, 0.19)';
  508. ctx.lineWidth = 1;
  509. ctx.stroke();
  510. // 绘制文字
  511. ctx.fillStyle = side === 'left' ? '#904A87' : '#199C9C';
  512. ctx.textAlign = 'center';
  513. ctx.textBaseline = 'middle';
  514. ctx.fillText(text, x + boxWidth / 2, boxY + boxHeight / 2);
  515. };
  516. drawNumberBox(minVal.toString(), 'left');
  517. drawNumberBox(maxVal.toString(), 'right');
  518. });
  519. // --- 6. 生成图片文件 ---
  520. uni.canvasToTempFilePath({
  521. canvas: canvasNode,
  522. success: async (result) => {
  523. const fileurl = await this.uploadFilePromise(result.tempFilePath);
  524. resolve(fileurl);
  525. },
  526. fail: (err) => {
  527. console.error('图片生成失败', err);
  528. uni.showToast({ title: '图片生成失败', icon: 'none' });
  529. reject(err);
  530. }
  531. }, this);
  532. });
  533. });
  534. },
  535. /**
  536. * @description 辅助函数:在Canvas中绘制可自动换行的文本
  537. * @param {CanvasRenderingContext2D} ctx
  538. * @param {string} text 要绘制的文本
  539. * @param {number} x 起始x坐标
  540. * @param {number} y 起始y坐标(对于居中对齐,这是中心y;对于top对齐,这是第一行的y)
  541. * @param {number} lineHeight 行高
  542. * @param {number} maxWidth 最大宽度
  543. */
  544. drawWrappedText(ctx, text, x, y, lineHeight, maxWidth) {
  545. let words = text.split('');
  546. let line = '';
  547. let lines = [];
  548. for (let n = 0; n < words.length; n++) {
  549. let testLine = line + words[n];
  550. let metrics = ctx.measureText(testLine);
  551. if (metrics.width > maxWidth && n > 0) {
  552. lines.push(line);
  553. line = words[n];
  554. } else {
  555. line = testLine;
  556. }
  557. }
  558. lines.push(line);
  559. let startY;
  560. if (ctx.textBaseline === 'middle') {
  561. startY = y - (lineHeight * (lines.length - 1)) / 2;
  562. } else { // top
  563. startY = y;
  564. }
  565. for (let i = 0; i < lines.length; i++) {
  566. ctx.fillText(lines[i], x, startY + (i * lineHeight));
  567. }
  568. },
  569. calculateScaleAndPosition() {
  570. uni.getSystemInfo({
  571. success: (res) => {
  572. const screenWidth = res.windowWidth; // 手机屏幕的宽度
  573. const pcContentWidth = 630; // PC端内容的原始宽度
  574. this.scale = screenWidth / pcContentWidth;
  575. this.$nextTick(() => {
  576. if (this.$refs.ztzdfxRef) {
  577. this.initZtzdfxChart();
  578. }
  579. });
  580. }
  581. });
  582. },
  583. calculatePdfContainerHeight() {
  584. uni.createSelectorQuery().in(this).select('#pdfContainer').boundingClientRect(rect => {
  585. if (rect) {
  586. this.originalContainerHeight = rect.height;
  587. this.containerScaledHeight = this.originalContainerHeight * this.scale;
  588. // console.log('原始高度:', this.originalContainerHeight, '缩放比例:', this.scale, '缩放后高度:', this.containerScaledHeight);
  589. }
  590. }).exec();
  591. },
  592. downloadZtzdfxImg(){
  593. return new Promise(resolve=>{
  594. if (!this.isChartReady) return console.log('图表尚未准备好');
  595. const chartRef = this.$refs.ztzdfxRef;
  596. if (!chartRef) return console.log('无法找到图表组件');
  597. chartRef.canvasToTempFilePath({
  598. success: async (res) => {
  599. const imgUrl = await this.uploadFilePromise(res.tempFilePath);
  600. console.log(imgUrl,'imgUrl');
  601. resolve(imgUrl)
  602. },
  603. fail: (err) => {
  604. console.log('生成图片失败:', err);
  605. }
  606. });
  607. })
  608. },
  609. uploadFilePromise(url) {
  610. return new Promise((resolve, reject) => {
  611. let a = uni.uploadFile({
  612. url: BaseApi+'/uploadFile',
  613. filePath: url,
  614. name: 'file',
  615. success: (res) => {
  616. setTimeout(() => {
  617. let data = JSON.parse(res.data)
  618. if(data&&data.code===0){
  619. resolve(data.data);
  620. }else this.$showToast(data?.msg)
  621. }, 1000);
  622. },
  623. fail: err =>{
  624. resolve('');
  625. }
  626. });
  627. });
  628. },
  629. async initZtzdfxChart() {
  630. let dataSum = this.reportData.overall.length*this.reportData.overall[0].themeTotalSpreads.length;
  631. const leaderData = [],memberData = [],stakeholderData=[],sponsorData=[];
  632. const overall = this.reportData.overall||[];
  633. overall.forEach(o=>{
  634. let themeTotalSpreads = o.themeTotalSpreads||[];
  635. if(['内部流程、系统与结构','学习','领导力'].includes(o.dimension)) themeTotalSpreads = o.themeTotalSpreads.reverse()||[];
  636. themeTotalSpreads.forEach(t=>{
  637. leaderData.push(t.scoreLeader||0);
  638. memberData.push(t.scoreMember||0);
  639. stakeholderData.push(t.scoreStakeholder||0);
  640. sponsorData.push(t.scoreSponsor||0);
  641. })
  642. })
  643. const sumArr = leaderData.concat(memberData).concat(stakeholderData).concat(sponsorData);
  644. const maxValue = sumArr.reduce((a,b)=>Math.max(a,b));
  645. const minValue = sumArr.reduce((a,b)=>Math.min(a,b));
  646. const chart = await this.$refs.ztzdfxRef.init(echarts);
  647. let option = {
  648. graphic: [
  649. {
  650. type: 'image',
  651. id: 'radar-bg',
  652. z: -1,
  653. bounding: 'raw',
  654. left: 'center',
  655. top: 'center',
  656. style: {
  657. image:'https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/six_chart_bg.png',
  658. width: 360*this.scale-20,
  659. height: 360*this.scale-20,
  660. opacity: 1
  661. }
  662. },
  663. {
  664. type: 'circle',
  665. z: 100, // 设置一个较高的 z 值,确保它在最顶层
  666. left: 'center', // 水平居中
  667. top: 'center', // 垂直居中
  668. shape: {
  669. r: 12*this.scale // 圆形的半径,您可以根据需要调整大小
  670. },
  671. style: {
  672. fill: '#FFFFFF', // 填充色为白色
  673. shadowBlur: 20*this.scale, // 阴影的模糊范围
  674. shadowColor: 'rgba(0, 0, 0, 0.15)', // 阴影颜色
  675. shadowOffsetY: 4*this.scale // 向下的阴影偏移,产生悬浮效果
  676. }
  677. }
  678. ],
  679. radar: {
  680. // shape: 'circle',
  681. indicator: new Array(dataSum).fill({ max:maxValue, min:minValue }),
  682. axisName: {
  683. show: false
  684. },
  685. splitArea:{
  686. show:false
  687. },
  688. splitLine: {
  689. show: false
  690. },
  691. axisLine: {
  692. show: false
  693. },
  694. startAngle: 95
  695. },
  696. series: [
  697. {
  698. type: 'radar',
  699. data: [
  700. {
  701. value: sponsorData,
  702. itemStyle: {
  703. color: '#012846'
  704. },
  705. lineStyle: {
  706. color: '#012846',
  707. width:1.5
  708. },
  709. areaStyle: {
  710. color: 'rgba(255, 255, 255, 0.4)'
  711. },
  712. symbolSize: 3
  713. },
  714. {
  715. value: stakeholderData,
  716. itemStyle: {
  717. color: '#FFD650'
  718. },
  719. lineStyle: {
  720. color: '#FFD650',
  721. width:1.5
  722. },
  723. areaStyle: {
  724. color: 'rgba(255, 255, 255, 0.4)'
  725. },
  726. symbolSize: 3
  727. },
  728. {
  729. value: memberData,
  730. itemStyle: {
  731. color: '#AFCDF5'
  732. },
  733. lineStyle: {
  734. color: '#AFCDF5',
  735. width:1.5
  736. },
  737. areaStyle: {
  738. color: 'rgba(255, 255, 255, 0.4)'
  739. },
  740. symbolSize: 3
  741. },
  742. {
  743. value: leaderData,
  744. itemStyle: {
  745. color: '#9F6196'
  746. },
  747. lineStyle: {
  748. color: '#9F6196',
  749. width:1.5
  750. },
  751. areaStyle: {
  752. color: 'rgba(255, 255, 255, 0.4)'
  753. },
  754. symbolSize: 3
  755. }
  756. ]
  757. }
  758. ]
  759. };
  760. chart.setOption(option);
  761. this.isChartReady = true;
  762. this.$nextTick(() => {
  763. this.calculatePdfContainerHeight();
  764. });
  765. },
  766. }
  767. };
  768. </script>
  769. <style scoped lang="scss">
  770. .page-wrappe{
  771. width: 100%;
  772. background: #FFFFFF;
  773. overflow-x: hidden;
  774. overflow-y: auto;
  775. .pdf-container{
  776. width: 630px;
  777. padding: 0 20rpx;
  778. box-sizing: border-box;
  779. transform-origin: top left;
  780. }
  781. }
  782. .offscreen-canvas {
  783. position: fixed;
  784. top: -9999px;
  785. left: -9999px;
  786. }
  787. .pdf_btn{
  788. padding: 15rpx 20rpx;
  789. border-radius: 20rpx;
  790. font-size: 28rpx;
  791. color: #FFFFFF;
  792. background: #189B9B;
  793. position: fixed;
  794. right: 30rpx;
  795. bottom: 100rpx;
  796. z-index: 1000;
  797. }
  798. @import '../static/pdf.scss';
  799. </style>