浏览代码

修改导出word文档行距

yangg 4 月之前
父节点
当前提交
fe94514ac2

文件差异内容过多而无法显示
+ 0 - 0
dist/index.html


文件差异内容过多而无法显示
+ 0 - 0
dist/static/css/chunk-6f317fbe.dd1e49ac.css


文件差异内容过多而无法显示
+ 0 - 0
dist/static/js/app.7ff29941.js


文件差异内容过多而无法显示
+ 0 - 0
dist/static/js/chunk-23893b40.8d479c2a.js


文件差异内容过多而无法显示
+ 0 - 0
dist/static/js/chunk-6f317fbe.3f586568.js


+ 44 - 22
src/views/project/components/dataList.vue

@@ -554,22 +554,19 @@ export default {
 
     // 更新导出方法
     async exportDocumentWithHtmlDocx(template) {
-     /*  console.log(template); */
-     const res = await searchlistDocTemplate({
-        /* page: 1,
-        pageSize: 10, */
-        project_id:this.currentData.id,
+      const res = await searchlistDocTemplate({
+        project_id: this.currentData.id,
         id: template.id
       })
-      if(res.status!==200) return
+      if(res.status !== 200) return
       let templateData
       try {
-        if(res.data.documents.length!==0){
-           templateData = JSON.parse(res.data.documents[0].data || '[]')
-        }else{
-        const template_Data = await getDocumentInfo({id:template.id})
-          if(template_Data.status!==200) return
-           templateData = JSON.parse(template_Data.data.data || '[]')
+        if(res.data.documents.length !== 0) {
+          templateData = JSON.parse(res.data.documents[0].data || '[]')
+        } else {
+          const template_Data = await getDocumentInfo({id:template.id})
+          if(template_Data.status !== 200) return
+          templateData = JSON.parse(template_Data.data.data || '[]')
         }
         const contentContainer = document.createElement('div')
         contentContainer.className = 'content'
@@ -594,10 +591,44 @@ export default {
                 <w:View>Print</w:View>
                 <w:Zoom>100</w:Zoom>
                 <w:DoNotOptimizeForBrowser/>
+                <w:SpaceForUL/>
+                <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
               </w:WordDocument>
             </xml>
             <style>
-              /* 基础表格样式 */
+              /* 基础样式 */
+              body {
+                font-family: "Times New Roman", SimSun;
+                line-height: 1.0; /* 单倍行距 */
+              }
+              
+              /* 段落样式 */
+              p {
+                margin-top: 0.5em; /* 段前0.5行 */
+                margin-bottom: 0.5em; /* 段后0.5行 */
+                line-height: 1.0 !important; /* 强制单倍行距 */
+                mso-line-height-rule: exactly; /* Word特定的行距规则 */
+              }
+              
+              /* 保持表格内容行距正常 */
+              table p {
+                margin: 0;
+                line-height: inherit;
+              }
+              
+              /* 列表样式 */
+              ul, ol {
+                margin-top: 0.5em;
+                margin-bottom: 0.5em;
+                line-height: 1.0;
+              }
+              
+              li {
+                line-height: 1.0;
+                margin: 0;
+              }
+              
+              /* 保持原有表格样式 */
               table {
                 width: 100%;
                 border-collapse: collapse !important;
@@ -638,15 +669,6 @@ export default {
                 mso-tstyle-colband-size: 0;
                 mso-padding-alt: 0cm 5.4pt 0cm 5.4pt;
               }
-              
-              /* 确保分页时边框正确显示 */
-              tr {
-                page-break-inside: avoid !important;
-              }
-              
-              td, th {
-                page-break-inside: avoid !important;
-              }
             </style>
           </head>
           <body>

部分文件因为文件数量过多而无法显示