Преглед изворни кода

Merge branch 'master' of http://121.4.203.192:9000/mingxue/front

hare8999@163.com пре 2 година
родитељ
комит
f531abcb8a
3 измењених фајлова са 36 додато и 8 уклоњено
  1. 1 0
      package.json
  2. 24 7
      src/views/elective/dispatch/master/info/student.vue
  3. 11 1
      vue.config.js

+ 1 - 0
package.json

@@ -80,6 +80,7 @@
     "babel-eslint": "10.1.0",
     "babel-plugin-macros": "^3.1.0",
     "chalk": "4.1.0",
+    "compression-webpack-plugin": "5.0.2",
     "connect": "3.6.6",
     "eslint": "7.15.0",
     "eslint-plugin-vue": "7.2.0",

+ 24 - 7
src/views/elective/dispatch/master/info/student.vue

@@ -159,22 +159,39 @@ export default {
             size: A4 landscape;
         }
       }
+      .el-table__empty-block {
+        width: calc(11.7in - 1.27cm) !important;
+      }
+      th:nth-last-child(2) {
+        display: none !important;
+      }
+      td:last-child {
+        display: none;
+      }
+      .title {
+        line-height: 44px;
+        text-align: center;
+        font-size: 16px;
+        background-color: #ffffff;
+      }
       </style>`
       const iframe = document.createElement('iframe');
-      iframe.setAttribute('style', `position: absolute;top: 0;left: 0;width: 11.7in;height: 300px;z-index: -1;opacity: 0;border: none;background-color: #efefef;`)
+      iframe.setAttribute('style', `position: absolute;top: 0;left: 0;width: calc(11.7in - 1.27cm);height: 300px;z-index: -1;opacity: 0;border: none;background-color: #efefef;`)
       document.body.appendChild(iframe);
       const doc = iframe.contentDocument;
-      doc.write(style + content);
-      if (title) {
-        doc.title = title;
-      }
+      const titleDom = `<div class="title">${title}</div>`;
+      doc.write(style + titleDom + content);
+      // if (title) {
+      //   doc.title = title;
+      // }
       // 以下设置只对el-table有效,如果打印的不是el-table请注释
       const thead = doc.querySelector('.el-table__header-wrapper thead');
       thead.classList.add('el-table__header-wrapper');
-      thead.style.width='100%';
+      thead.style.width='calc(11.7in - 1.27cm)';
       const tbody = doc.querySelector('.el-table__body-wrapper table');
+      tbody.removeChild(tbody.firstElementChild);
       tbody.appendChild(thead);
-      tbody.style.width='100%';
+      tbody.style.width='calc(11.7in - 1.27cm)';
       // 打印并移除iframe
       iframe.contentWindow.print();
       document.body.removeChild(iframe);

+ 11 - 1
vue.config.js

@@ -6,6 +6,8 @@ function resolve(dir) {
   return path.join(__dirname, dir)
 }
 
+const CompressionPlugin = require("compression-webpack-plugin");
+
 const name = defaultSettings.title || '名学金榜生涯志愿系统' // 标题
 
 const port = process.env.port || process.env.npm_config_port || 80 // 端口
@@ -61,7 +63,15 @@ module.exports = {
       alias: {
         '@': resolve('src')
       }
-    }
+    },
+    plugins: [
+      new CompressionPlugin({
+        test: /\.(js|css|html)?$/i, // 压缩文件格式
+        filename: "[path].gz[query]", // 压缩后的文件名
+        algorithm: "gzip", // 使用gzip压缩
+        minRatio: 0.8, // 压缩率小于1才会压缩
+      }),
+    ],
   },
   chainWebpack(config) {
     config.plugins.delete('preload') // TODO: need test