|
|
@@ -28,8 +28,8 @@
|
|
|
<template v-slot:toolbar>
|
|
|
<el-button type="primary" @click="toAdd()">新增</el-button>
|
|
|
<el-button type="danger" @click="toDelAll()">批量删除</el-button>
|
|
|
- <!-- <el-button type="success" @click="toEnd()">导出</el-button>
|
|
|
- <el-button type="primary" @click="printing()">打印</el-button> -->
|
|
|
+ <!-- <el-button type="success" @click="toEnd()">导出</el-button> -->
|
|
|
+ <el-button type="primary" @click="printing()">打印</el-button>
|
|
|
</template>
|
|
|
|
|
|
<template v-slot:docNo="{ row }">
|
|
|
@@ -295,7 +295,7 @@
|
|
|
this.getOrganizationList();
|
|
|
},
|
|
|
mounted() {
|
|
|
- this.reload();
|
|
|
+ // this.reload();
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
@@ -446,7 +446,76 @@
|
|
|
},
|
|
|
|
|
|
printing() {
|
|
|
-
|
|
|
+ // 检查是否有选中的数据
|
|
|
+ if (!this.selection || this.selection.length === 0 || this.selection.length > 1) {
|
|
|
+ this.$message.warning('请选择一条要打印的数据');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取第一条选中的数据
|
|
|
+ const row = this.selection[0];
|
|
|
+
|
|
|
+ if (row.content) {
|
|
|
+ // 打开打印窗口
|
|
|
+ this.openPrintWindow(row.content);
|
|
|
+ } else {
|
|
|
+ this.$message.warning('选中的数据没有可打印的内容');
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 打开打印窗口
|
|
|
+ openPrintWindow(content) {
|
|
|
+ // 创建新窗口
|
|
|
+ const printWindow = window.open('', '_blank');
|
|
|
+ if (!printWindow) {
|
|
|
+ this.$message.error('请允许弹出窗口以进行打印');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 构建打印页面的 HTML
|
|
|
+ const printHtml = `
|
|
|
+ <!DOCTYPE html>
|
|
|
+ <html>
|
|
|
+ <head>
|
|
|
+ <meta charset="utf-8">
|
|
|
+ <title>打印</title>
|
|
|
+ <style>
|
|
|
+ body {
|
|
|
+ margin: 0;
|
|
|
+ padding: 20px;
|
|
|
+ font-family: 'SimSun', '宋体', serif;
|
|
|
+ font-size: 16px;
|
|
|
+ line-height: 1.8;
|
|
|
+ }
|
|
|
+ .print-content {
|
|
|
+ max-width: 800px;
|
|
|
+ margin: 0 auto;
|
|
|
+ }
|
|
|
+ @media print {
|
|
|
+ body {
|
|
|
+ padding: 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+ </head>
|
|
|
+ <body>
|
|
|
+ <div class="print-content">
|
|
|
+ ${content}
|
|
|
+ </div>
|
|
|
+ <script>
|
|
|
+ window.onload = function() {
|
|
|
+ setTimeout(function() {
|
|
|
+ window.print();
|
|
|
+ }, 500);
|
|
|
+ };
|
|
|
+ <\/script>
|
|
|
+ </body>
|
|
|
+ </html>
|
|
|
+ `;
|
|
|
+
|
|
|
+ // 写入内容并打印
|
|
|
+ printWindow.document.write(printHtml);
|
|
|
+ printWindow.document.close();
|
|
|
},
|
|
|
}
|
|
|
};
|