Browse Source

pdf部分优化

htc 1 day ago
parent
commit
ac61334a75

+ 5 - 10
src/components/reportList/index.vue

@@ -59,7 +59,7 @@
                 <el-button link type="text" size="mini" @click="handledDelete(scope.row)" v-hasPermi="['core:report:delete']">删除</el-button>
                 <el-button link type="text" size="mini" @click="handleSend(scope.row)" v-if="[1,2].includes(scope.row.state)">发送报告</el-button>
                 <el-button link type="text" size="mini" @click="handleCreate(scope.row)" v-if="scope.row.state=='-1'">重新生成</el-button>
-                <el-button link type="text" size="mini" @click="handleExport(scope.row)" v-if="scope.row.state>0">导出报告</el-button>
+                <el-button link type="text" size="mini" @click="handleExport(scope.row)" v-if="scope.row.state>0&&scope.row.fileUrl">导出报告</el-button>
             </template>
         </el-table-column>
     </el-table>
@@ -123,20 +123,15 @@
     emit('toggleReport', item.value)
   }
 
-  const reviewReport = (item) => {
-    emit('reviewReport', item)
-  }
-
   const pdfCancel = () => {
-    // emit('refreshReportList', reportParentId.value)
     pdfShow.value = false;
     reportData.value = {};
     reportParentId.value = '';
     reportId.value = '';
     reportName.value = '';
   }
-  const refreshReportList = () => {
-    emit('refreshReportList', reportParentId.value)
+  const refreshReportList = (relationId) => {
+    emit('refreshReportList', relationId)
   }
 
   const handleReive = (row) => {
@@ -144,7 +139,7 @@
     reportName.value = row.reportName;
     getReportPdfData(row.id).then(res => {
       if(res.code!==0) proxy.$message.error(res.msg);
-      reportData.value = res.data;
+      reportData.value = {...res.data,id:row.id,relationId:row.relationId};
       nextTick(() => {
         pdfShow.value = true;
       })
@@ -167,7 +162,7 @@
     emit('reCreateReport', row.id)
   }
   const handleExport = (row) => {
-    if(!row.fileUrl) return proxy.$message.error('报告不存在,请联系管理员');
+    if(!row.fileUrl) return proxy.$message.error('PDF报告未生成,无法导出!');
     window.open(row.fileUrl)
   }
 </script>

+ 16 - 5
src/components/reportPdf/index.vue

@@ -25,7 +25,7 @@
     </div>
 </template>
 
-<script setup name="">
+<script lang="ts" setup name="">
     import { exportPDF } from './exportPDF';
     import pdf from './pdf.vue'
     const props = defineProps({
@@ -47,21 +47,33 @@
       }
     })
 
+    import _this from '@/main.js'
     import { ref, getCurrentInstance, onMounted } from 'vue'
     const { proxy } = getCurrentInstance();
     const reportData = ref(props.reportData);
     const reportId = ref(props.reportId);
     const reportName = ref(props.reportName);
     const reportShow = ref(false);
+    const isCreateReport = ref(false);
     const emit = defineEmits(['cancel','refreshReportList']);
     import { updateReportPdfUrl } from '@/api/agent/index.js';
 
     const cancel = () => {
-        emit('cancel');
+        if(isCreateReport.value){
+            _this.$alert('PDF报告正在生成中,取消操作将会停止生成,是否取消?', '温馨提示', {
+                confirmButtonText: '确定'
+                }
+            ).then(res=>{
+                emit('cancel');
+            }).catch((err)=>{
+                
+            });
+        }else emit('cancel');
     }
 
     const exportToPDF = async () => {
         try {
+            isCreateReport.value = true;
             props.show = false;
             reportShow.value = true;
             // 滚动到顶部确保完整渲染
@@ -69,19 +81,18 @@
             // 避免异步渲染问题
             await new Promise(resolve => setTimeout(resolve, 500));
             const res = await exportPDF('pdf-content', reportName.value+'.pdf');
+            isCreateReport.value = false;
             if(res.data && res.data.code === 0) {
                 updateReportPdfUrl({id:reportId.value, fileUrl:res.data.data}).then(resu => {
                     if(resu.code!==0) return proxy.$message.error(res.msg)
                     proxy.$message.success('生成成功!');
                     props.show = false;
                     reportShow.value = false;
-                    emit('refreshReportList');
+                    emit('refreshReportList',reportData.value.relationId);
                     cancel();
                 })
             }
         } catch (error) {
-            console.error('导出失败:', error);
-            proxy.$message.error('导出失败:')
             props.show = false;
             reportShow.value = false;
         }

+ 22 - 17
src/components/reportPdf/pdf.vue

@@ -132,7 +132,7 @@
                         </div>
                         <p class="p2" style="margin-top: 43px;">在目标与动机支柱中,我们旨在探究是否存在一个清晰的存在理由和明确的方向,能够激发团队成员的动力并吸引他们的想象力,以及个人与集体的身份认同是否围绕共同目标达成一致。</p>
                         <p class="p3" style="margin-top: 42px;">为了帮助我们理解这一点,我们将从 5 个关键主题的角度审视团队的运作情况,具体如下:</p>
-                        <div class="mddj_boxs" v-if="rd?.performanceRatings?.title=='目的动机'">
+                        <div class="mddj_boxs" v-if="rd?.performanceRatings?.title=='目的动机'">
                             <div class="mb_item" style="border-top: 1px dotted #833478;">
                                 <div class="mbi_title">一致性:</div>
                                 <div class="mbi_text">存在共同的目标和使命意识。个人目标与集体目标之间具有凝聚力。团队成员共享价值观,且集体议程优先于个人议程。</div>
@@ -351,14 +351,14 @@
                             <img src="@/assets/images/agent/pdf_title.png">
                             <span>{{ rd?.performanceRatings?.title }}</span>
                         </div>
-                        <div class="bp" style="margin-top: 44px;">{{rd?.diagAnalysis?.title}}-诊断分析</div>
+                        <div class="bp" style="margin-top: 44px;">诊断分析</div>
                         <p style="margin-top: 17px;">{{ rd?.diagAnalysis?.summary }}</p>
                         <div class="jxpjmddj_box">
                             <div class="jb_title">主题:纬度评价分:{{ rd?.diagAnalysis?.avgScore }}<span style="margin-left: 17px;">标准方差:{{ rd?.diagAnalysis?.variance }}</span></div>
                         </div>
                         <div class="jxpjmddj_box">
                             <div class="jb_title2">诊断结果:</div>
-                            <div class="jb_text" v-html="rd?.diagAnalysis?.diagResult.replace('/\n'/g,'<br>')"></div>
+                            <div class="jb_text" v-html="rd?.diagAnalysis?.diagResult.replace(/(\r\n|\n|\r)+/g, '<br>')"></div>
                         </div>
                         <div class="jxpjmddj_box">
                             <div class="jb_title2">建议:</div>
@@ -373,12 +373,12 @@
                         <div class="cb_db_l cdl">{{ datetime }}</div>
                     </div>
                     <div class="cb_content">
-                        <!-- <div class="mddj_title adfac">
+                        <div class="mddj_title adfac">
                             <img src="@/assets/images/agent/pdf_title.png">
-                            <span>问卷题目详细分析</span>
-                        </div> -->
-                        <div class="bp">问卷题目详细分析</div>
-                        <p class="p2" style="margin-top: 41px;padding-left: 8px;">以下问题均与 “{{rd?.performanceRatings?.title}}” 这一核心支柱以及上述分析中强调的主题紧密相关。</p>
+                            <span>{{ rd?.performanceRatings?.title }}</span>
+                        </div>
+                        <div class="bp" style="margin-top: 20px;">问卷题目详细分析</div>
+                        <p class="p2" style="margin-top: 21px;padding-left: 8px;">以下问题均与 “{{rd?.performanceRatings?.title}}” 这一核心支柱以及上述分析中强调的主题紧密相关。</p>
                         <p class="p3" style="margin-top: 10px;padding-left: 8px;">此处的线性图示将从总体上展示团队的绩效得分情况、得分之间的差异百分比,同时以可视化方式呈现这些分数及其范围。</p>
                         <div class="xxfx_title adfac">
                             <div class="xt_pre">问题</div>
@@ -386,7 +386,7 @@
                             <div class="xt_pre">方差</div>
                         </div>
                         <div class="xxfx_list">
-                            <div class="xl_item adfac" v-for="(rda,index) in rd?.dataAnalysis.slice(0,9)" :key="index">
+                            <div class="xl_item adfac" v-for="(rda,index) in rd?.dataAnalysis?.slice(0,9)" :key="index">
                                 <div class="xli_l adfac">
                                     <div class="xl_pre">{{ index+1 }}</div>
                                     <div class="xl_pre red">{{ rda?.avgScore }}</div>
@@ -417,7 +417,7 @@
                     </div>
                     <div class="cb_content">
                         <div class="xxfx_list">
-                            <div class="xl_item adfac" v-for="(rda,index) in rd?.dataAnalysis.slice(9,rd?.dataAnalysis.length)" :key="index">
+                            <div class="xl_item adfac" v-for="(rda,index) in rd?.dataAnalysis?.slice(9,rd?.dataAnalysis?.length)" :key="index">
                                 <div class="xli_l adfac">
                                     <div class="xl_pre">{{ index+10 }}</div>
                                     <div class="xl_pre red">{{ rda?.avgScore }}</div>
@@ -447,11 +447,11 @@
                         <div class="cb_db_l cdl">{{ datetime }}</div>
                     </div>
                     <div class="cb_content">
-                        <!-- <div class="mddj_title adfac">
+                        <div class="mddj_title adfac">
                             <img src="@/assets/images/agent/pdf_title.png">
-                            <span>团队成员回答分数</span>
-                        </div> -->
-                        <div class="bp">团队成员回答分数</div>
+                            <span>{{ rd?.performanceRatings?.title }}</span>
+                        </div>
+                        <div class="bp" style="margin-top: 20px;">团队成员回答分数</div>
                         <p style="margin-top: 28px;font-size: 14px;font-weight: bold;" >下表向您展示了每位团队成员在每个问题上的得分情况,以及由此得出的总分和方差。</p>
                         <div class="mddj_top adf">
                             <div class="tt_pre adf">
@@ -478,7 +478,7 @@
                                 </div>
                             </div>
                             <div class="mt_list">
-                                <div class="ml_pre adf" v-for="(tms,index) in rd?.teamMemberScores.slice(0,8)" :key="index">
+                                <div class="ml_pre adf" v-for="(tms,index) in rd?.teamMemberScores?.slice(0,7)" :key="index">
                                     <div class="mt_l adfac">{{ tms.question }}</div>
                                     <div class="mt_r adfac">
                                         <div class="mp_pre adffcacjc" :class="{'mp1':score<16,'mp2':(score<36&&score>=15),'mp3':score>35}" v-for="(score,idx) in tms.scores" :key="idx">{{ score }}</div>
@@ -506,7 +506,7 @@
                                 </div>
                             </div>
                             <div class="mt_list">
-                                <div class="ml_pre adf" v-for="(tms,index) in rd?.teamMemberScores.slice(8,rd?.teamMemberScores.length)" :key="index">
+                                <div class="ml_pre adf" v-for="(tms,index) in rd?.teamMemberScores?.slice(7,rd?.teamMemberScores?.length)" :key="index">
                                     <div class="mt_l adfac">{{ tms.question }}</div>
                                     <div class="mt_r adfac">
                                         <div class="mp_pre adffcacjc" :class="{'mp1':score<16,'mp2':(score<36&&score>=15),'mp3':score>35}" v-for="(score,idx) in tms.scores" :key="idx">{{ score }}</div>
@@ -603,7 +603,7 @@
                             <td>人物简介</td>
                             <td>人物故事</td>
                         </tr>
-                        <tr v-for="(item,index) in reportData?.nextSteps?.teamInfo?.team_info.slice(0,4)" :key="index">
+                        <tr v-for="(item,index) in reportData?.nextSteps?.teamInfo?.team_info?.slice(0,4)" :key="index">
                             <td class="mw">{{ item.name }}</td>
                             <td class="mw">{{ UserCategory.find(u=>u.value==item.type)?.label }}</td>
                             <td class="tc">{{item.brief}}</td>
@@ -624,6 +624,11 @@
                     <img src="@/assets/images/agent/pdf_title.png">
                     <span>团队教练目标及方案</span>
                 </div>
+                <div class="bp" style="margin-top: 20px;">团队教练目标</div>
+                <p style="margin-top: 10px;" v-html="reportData?.nextSteps?.coachGoal?.summary.replace(/(\r\n|\n|\r)+/g, '<br>')"></p>
+                <p style="margin-top: 10px;" v-if="reportData?.nextSteps?.coachGoal?.indicators?.length">
+                    衡量指标:<span v-for="(rnci,ridx) in reportData?.nextSteps?.coachGoal?.indicators" :key="ridx">{{ rnci }}<br/></span>
+                </p>
                 <div class="cc_table">
                     <table>
                         <tr>