dedsudiyu 4 napja
szülő
commit
bd87c9d199

+ 202 - 0
src/views/safetyEducationExaminationNew/components/safetyCommitmentLetter.vue

@@ -0,0 +1,202 @@
+<template>
+  <div class="safetyCommitmentLetter-max-big-box">
+    <div class="max-img-box" ref="viewBox" v-if="showType">
+      <transition name="fade" mode="in-out">
+        <vue-office-docx
+          v-if="officeType === 'docx'&&!officeNullType"
+          :src="lookUrl"
+          :class="pdfType == 1?'':'vertical'"
+          @rendered="renderedHandler"
+          @error="errorHandler"
+        />
+        <vue-office-excel
+          v-if="officeType === 'excel'&&!officeNullType"
+          :src="lookUrl"
+          @rendered="renderedHandler"
+          @error="errorHandler"
+        />
+        <vue-office-pdf
+          v-if="officeType === 'pdf'&&!officeNullType"
+          :src="lookUrl"
+          :class="pdfType == 1?'':'vertical'"
+          @rendered="renderedHandler"
+          @error="errorHandler"/>
+      </transition>
+    </div>
+  </div>
+</template>
+
+<script>
+  //引入VueOfficeDocx组件
+  import VueOfficeDocx from '@vue-office/docx'
+  import '@vue-office/docx/lib/index.css'
+  //引入VueOfficeExcel组件
+  import VueOfficeExcel from '@vue-office/excel'
+  import '@vue-office/excel/lib/index.css'
+  //引入VueOfficePdf组件
+  import VueOfficePdf from '@vue-office/pdf'
+  export default {
+    name: 'safetyCommitmentLetter',
+    components: {
+      VueOfficeDocx,
+      VueOfficeExcel,
+      VueOfficePdf,
+    },
+    props: {
+      answerKeyPropsData: {}
+    },
+    data() {
+      return {
+        showType:false,
+        officeNullType:false,
+        //文档类型
+        officeType:null,
+        //文档名称
+        lookName:"",
+        //文档地址
+        lookUrl:"",
+        currentPage: 1,
+        totalPages: 1,
+        currentScale: 1.0, // 初始缩放比例
+        pdfType:1,
+        buttonState:false,
+      }
+    },
+    mounted() {
+      this.initialize('安全承诺书','http://192.168.1.88/statics/study/bigFile/2026/09/29/f2384978-355f-4dab-ba05-7738e8423a30.docx','docx');
+    },
+    methods: {
+      //初始化
+      initialize(name,url,type){
+        let self = this;
+        this.$set(this,'officeNullType',true);
+        this.$set(this,'showType',false);
+        this.$nextTick(()=>{
+          if(name&&url&&type){
+            this.$set(this,'officeType',type);
+            this.$set(this,'lookName',name);
+            this.$set(this,'lookUrl',url);
+            this.$set(this,'officeNullType',false);
+            this.$set(this,'pdfType',1);
+            this.$set(this,'showType',true);
+            if(type === 'docx'){
+              this._detectDocxOrientation(url);
+            }
+          }else{
+            this.msgError('文件参数异常')
+          }
+        })
+      },
+      // 解析 docx XML 自动判断纸张方向,设置 pdfType(1纵向 2横向)
+      async _detectDocxOrientation(url) {
+        try {
+          const res = await fetch(url);
+          const buf = await res.arrayBuffer();
+          const zip = await JSZip.loadAsync(buf);
+          const xmlStr = await zip.file('word/document.xml').async('string');
+          const orientMatch = xmlStr.match(/w:pgSz[^/]*?w:orient="([^"]+)"/);
+          if (orientMatch) {
+            this.$set(this, 'pdfType', orientMatch[1] === 'landscape' ? 2 : 1);
+            return;
+          }
+          // 无 orient 属性时比较 w:w 与 w:h
+          const sizeMatch = xmlStr.match(/w:pgSz[^/]*?w:w="(\d+)"[^/]*?w:h="(\d+)"/);
+          if (sizeMatch) {
+            this.$set(this, 'pdfType', parseInt(sizeMatch[1]) > parseInt(sizeMatch[2]) ? 2 : 1);
+          }
+        } catch (e) {
+          // 解析失败保持默认纵向
+        }
+      },
+    },
+  }
+</script>
+
+<style scoped lang="scss">
+  .vertical{
+    ::v-deep .docx{
+      padding:0!important;
+    }
+  }
+  .safetyCommitmentLetter-max-big-box {
+    flex: 1;
+    display: flex;
+    flex-direction: column;
+    overflow: hidden;
+
+    .max-img-box{
+      flex:1;
+      display: flex;
+      flex-direction: column;
+      overflow: hidden;
+      position: relative;
+      overflow-y: scroll;
+      .office-null-text{
+        line-height:700px;
+        text-align: center;
+        color:#dedede;
+        font-size:16px;
+      }
+      .video-box{
+        width:1458px;
+        height:797px;
+      }
+      .rich-text-box {
+        padding:20px 100px;
+        flex:1;
+        background-color: #fff;
+        line-height: 1.6; /* 基础行高 */
+        word-break: break-word; /* 防止长单词或长链接撑破布局 */
+      }
+
+      /* 穿透样式,控制富文本内部的标签 */
+      .rich-text-box ::v-deep img {
+        max-width: 100% !important; /* 防止图片超出容器 */
+        height: auto !important;
+        display: block;
+        margin: 10px auto;
+      }
+
+      .rich-text-box ::v-deep table {
+        width: 100%;
+        border-collapse: collapse;
+      }
+
+      .rich-text-box ::v-deep p {
+        margin-bottom: 10px;
+      }
+    }
+
+    //滚动条样式
+    .max-img-box::-webkit-scrollbar{
+      width: 6px;     /*高宽分别对应横竖滚动条的尺寸*/
+      height: 6px;
+    }
+    .max-img-box::-webkit-scrollbar-thumb{
+      border-radius: 5px;
+      background: #D3D7D4;
+    }
+    .max-img-box::-webkit-scrollbar-track{
+      -webkit-box-shadow: inset 0 0 5px #FFFFFF;
+      border-radius: 0;
+      background: #FFFFFF;
+    }
+    //滚动条样式
+    ::v-deep .ofd-footer{
+      padding:10px 0;
+    }
+    ::v-deep .ofd-body::-webkit-scrollbar{
+      width: 6px;     /*高宽分别对应横竖滚动条的尺寸*/
+      height: 6px;
+    }
+    ::v-deep .ofd-body::-webkit-scrollbar-thumb{
+      border-radius: 5px;
+      background: #D3D7D4;
+    }
+    ::v-deep .ofd-body::-webkit-scrollbar-track{
+      -webkit-box-shadow: inset 0 0 5px #FFFFFF;
+      border-radius: 0;
+      background: #FFFFFF;
+    }
+  }
+</style>

+ 20 - 20
src/views/safetyEducationExaminationNew/examManagement/examinationArrange/addPage.vue

@@ -556,27 +556,27 @@
                   </div>
                 </el-form-item>
 
-                <el-form-item label="安全承诺书" prop="securityCommitmentEnabled">
-                  <div class="switch-row">
-                    <el-switch :disabled="showType" v-model="newData.securityCommitmentEnabled" :active-value="1" :inactive-value="0"
-                               active-color="#0183FB" inactive-color="#AAAAAA"
-                    />
-                    <p v-if="newData.securityCommitmentEnabled==1&&!showType" class="checkButton-p" style="margin-left:20px;"
-                       @click="openSafetyCommitmentLetterDrawer"
-                    >选择模板</p>
-                  </div>
-                  <div class="mock-stat-bar" style="padding:0 20px;"
-                       v-if="newData.securityCommitmentTemplateId&&newData.securityCommitmentEnabled == 1">
-                    <span style="margin-right:20px;"><b>{{ newData.securityCommitmentTemplateName}}</b></span>
-                    <!--<i class="el-icon-close" @click="newData.certificateTemplateId = null;newData.certificateTemplateName = '';"></i>-->
-                  </div>
-                </el-form-item>
+                <!--<el-form-item label="安全承诺书" prop="securityCommitmentEnabled">-->
+                  <!--<div class="switch-row">-->
+                    <!--<el-switch :disabled="showType" v-model="newData.securityCommitmentEnabled" :active-value="1" :inactive-value="0"-->
+                               <!--active-color="#0183FB" inactive-color="#AAAAAA"-->
+                    <!--/>-->
+                    <!--<p v-if="newData.securityCommitmentEnabled==1&&!showType" class="checkButton-p" style="margin-left:20px;"-->
+                       <!--@click="openSafetyCommitmentLetterDrawer"-->
+                    <!--&gt;选择模板</p>-->
+                  <!--</div>-->
+                  <!--<div class="mock-stat-bar" style="padding:0 20px;"-->
+                       <!--v-if="newData.securityCommitmentTemplateId&&newData.securityCommitmentEnabled == 1">-->
+                    <!--<span style="margin-right:20px;"><b>{{ newData.securityCommitmentTemplateName}}</b></span>-->
+                    <!--&lt;!&ndash;<i class="el-icon-close" @click="newData.certificateTemplateId = null;newData.certificateTemplateName = '';"></i>&ndash;&gt;-->
+                  <!--</div>-->
+                <!--</el-form-item>-->
 
-                <el-form-item label="承诺书打印" v-if="newData.securityCommitmentEnabled == 1">
-                  <el-switch :disabled="showType" v-model="newData.securityCommitmentPrintEnabled" :active-value="1" :inactive-value="0"
-                             active-color="#0183FB" inactive-color="#AAAAAA"
-                  />
-                </el-form-item>
+                <!--<el-form-item label="承诺书打印" v-if="newData.securityCommitmentEnabled == 1">-->
+                  <!--<el-switch :disabled="showType" v-model="newData.securityCommitmentPrintEnabled" :active-value="1" :inactive-value="0"-->
+                             <!--active-color="#0183FB" inactive-color="#AAAAAA"-->
+                  <!--/>-->
+                <!--</el-form-item>-->
               </div>
             </div>
           </el-form>

+ 28 - 1
src/views/safetyEducationExaminationNew/safetyTest/myGrades/index.vue

@@ -93,6 +93,24 @@
         <p class="dialog-footer-button-null"></p>
       </div>
     </el-dialog>
+    <el-dialog class="safetyCommitmentLetter-dialog"
+               :modal-append-to-body="false"
+               :close-on-click-modal="false" :close-on-press-escape="false"
+               title="安全承诺书"
+               :visible.sync="safetyCommitmentLetterDialogType"
+               v-if="safetyCommitmentLetterDialogType"
+               width="908px"
+               append-to-body>
+      <div style="height:600px;display: flex;flex-direction: column;overflow: hidden">
+        <safetyCommitmentLetter ref="dataStatisticsReport" :safetyCommitmentLetterPropsData="safetyCommitmentLetterPropsData"></safetyCommitmentLetter>
+      </div>
+      <div slot="footer" class="dialog-footer dialog-footer-box">
+        <p class="dialog-footer-button-null"></p>
+        <p class="dialog-footer-button-border" @click="safetyCommitmentLetterDialogButton(type)">下载</p>
+        <p class="dialog-footer-button-primary" @click="safetyCommitmentLetterDialogButton(type)">确认</p>
+        <p class="dialog-footer-button-null"></p>
+      </div>
+    </el-dialog>
   </div>
 </template>
 <script>
@@ -102,13 +120,15 @@
   import dataStatisticsReport from "./dataStatisticsReport.vue";
   import historyOfIncorrectQuestions from "@/views/safetyEducationExaminationNew/components/historyOfIncorrectQuestions.vue";
   import examRecords from "@/views/safetyEducationExaminationNew/components/examRecords.vue";
+  import safetyCommitmentLetter from "@/views/safetyEducationExaminationNew/components/safetyCommitmentLetter.vue";
   import { examElExamUserResultMyScoreListPage,examUserExamTypeSelectExamType,examElLabEduRelationGraduationReport, } from "@/api/safetyEducationExaminationNew/index";
   export default {
     name: 'index',
     components: {
       historyOfIncorrectQuestions,
       examRecords,
-      dataStatisticsReport
+      dataStatisticsReport,
+      safetyCommitmentLetter
     },
     data() {
       return {
@@ -136,6 +156,9 @@
         historyOfIncorrectQuestionsPropsData:{},
         dialogType:false,
         dataStatisticsReportPropsData:{},
+        //安全承诺书
+        safetyCommitmentLetterDialogType:false,
+        safetyCommitmentLetterPropsData:null,
       }
     },
     created() {
@@ -267,6 +290,10 @@
         m=Math.pow(10,Math.max(r1,r2))
         return ((arg1*m+arg2*m)/m).toFixed(0);
       },
+      //安全承诺书
+      safetyCommitmentLetterDialogButton(type){
+
+      },
     },
     beforeRouteLeave(to, from, next) {
       if (to.name === 'startTraining') {