preview.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <el-dialog
  3. class="sub-main"
  4. :visible.sync="visible"
  5. :show-close="false"
  6. :maskClosable="false"
  7. :close-on-click-modal="false"
  8. @cancel="hideModal"
  9. :width="350 + 'mm'"
  10. >
  11. <div v-loading="spinning" style="min-height: 100px">
  12. <div id="preview_content" ref="printDom"></div>
  13. </div>
  14. <template slot="title">
  15. <div>
  16. <!-- <div style="margin-right: 20px">打印预览</div> -->
  17. <el-button
  18. :loading="waitShowPrinter"
  19. type="primary"
  20. icon="printer"
  21. @click.stop="print"
  22. >打印</el-button
  23. >
  24. <!-- <el-button type="primary" icon="printer" @click.stop="toPdf">pdf</el-button> -->
  25. </div>
  26. </template>
  27. <template slot="footer">
  28. <el-button key="close" type="info" @click="hideModal"> 关闭 </el-button>
  29. </template>
  30. </el-dialog>
  31. </template>
  32. <script>
  33. // import { downloadPDF } from '@/utils/pdf'
  34. import { addPrint } from "./print-data";
  35. import { detailArr } from "./print-data";
  36. export default {
  37. name: "printPreview",
  38. props: {},
  39. data() {
  40. return {
  41. visible: false,
  42. spinning: true,
  43. waitShowPrinter: false,
  44. // 纸张宽 mm
  45. width: 0,
  46. // 模板
  47. hiprintTemplate: {},
  48. // 数据
  49. printData: {},
  50. loading:true
  51. };
  52. },
  53. computed: {},
  54. watch: {},
  55. created() {},
  56. mounted() {},
  57. methods: {
  58. // handleExport() {
  59. // downloadPDF(this.$refs.printDom);
  60. // },
  61. hideModal() {
  62. this.visible = false;
  63. this.waitShowPrinter = false;
  64. this.$parent.initPrint();
  65. // console.log(this.$parent);
  66. },
  67. show(hiprintTemplate, printData, width = "210") {
  68. this.visible = true;
  69. this.width = width;
  70. this.hiprintTemplate = hiprintTemplate;
  71. this.printData = printData;
  72. setTimeout(() => {
  73. // eslint-disable-next-line no-undef
  74. $("#preview_content").html(hiprintTemplate.getHtml(printData));
  75. this.spinning = false;
  76. }, 500);
  77. },
  78. print() {
  79. this.hiprintTemplate.print(
  80. this.printData,
  81. {},
  82. {
  83. callback: () => {
  84. this.$parent.addPrint('addPrints');
  85. this.hiprintTemplate = {};
  86. this.$parent.tableSelection = [];
  87. setTimeout(() => {
  88. this.$parent.getList();
  89. console.error("更新发货汇总列表");
  90. }, 1000);
  91. },
  92. }
  93. );
  94. setTimeout(() => {
  95. this.hideModal();
  96. }, 2000);
  97. },
  98. // toPdf() {
  99. // downloadPDF(this.$refs.printDom);
  100. // this.hiprintTemplate.toPdf({}, '打印预览');
  101. // },
  102. },
  103. };
  104. </script>
  105. <style scoped>
  106. ::v-deep .el-dialog__body {
  107. padding: 0;
  108. }
  109. ::v-deep tr {
  110. height: 40px !important;
  111. }
  112. ::v-deep td {
  113. height: 40px !important;
  114. overflow: hidden;
  115. /* display: -webkit-box; */
  116. -webkit-line-clamp: 2;
  117. /* 数值代表显示几行 */
  118. -webkit-box-orient: vertical;
  119. }
  120. ::v-deep .hiprint-printPaper {
  121. margin: 0 auto;
  122. }
  123. /* ::v-deep tr td {
  124. border: 0 !important;
  125. } */
  126. ::v-deep .hiprint-paperNumber {
  127. display: none;
  128. }
  129. .ant-modal-body {
  130. padding: 0px;
  131. }
  132. .ant-modal-content {
  133. margin-bottom: 24px;
  134. }
  135. @media print {
  136. /*
  137. td {
  138. border: none !important;
  139. } */
  140. .drag_item_box {
  141. height: 100%;
  142. padding: 6px;
  143. }
  144. .drag_item_box > div {
  145. height: 100%;
  146. width: 100%;
  147. background-color: #fff;
  148. display: flex;
  149. justify-content: center;
  150. align-items: center;
  151. }
  152. .drag_item_box > div > a {
  153. text-align: center;
  154. text-decoration-line: none;
  155. }
  156. .drag_item_box > div > a > span {
  157. font-size: 28px;
  158. }
  159. .drag_item_box > div > a > p {
  160. margin: 0;
  161. }
  162. .drag_item_title {
  163. font-size: 16px;
  164. padding: 12px 6px 0 6px;
  165. font-weight: bold;
  166. }
  167. .card-design {
  168. overflow: hidden;
  169. overflow-x: auto;
  170. overflow-y: auto;
  171. }
  172. ::v-deep .el-dialog__body {
  173. padding: 0;
  174. }
  175. ::v-deep table {
  176. height: 240px !important;
  177. }
  178. ::v-deep tr {
  179. height: 40px !important;
  180. }
  181. ::v-deep .hiprint-printPaper {
  182. margin: 0 auto;
  183. }
  184. ::v-deep tr td {
  185. border: 0 !important;
  186. /* width: 911px !important;
  187. height: 529px !important; */
  188. }
  189. .ant-modal-body {
  190. padding: 0px;
  191. }
  192. .ant-modal-content {
  193. margin-bottom: 24px;
  194. }
  195. }
  196. </style>