teRuiPrintOne.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. <template>
  2. <ele-modal
  3. title="打印标签"
  4. :visible.sync="QRvisible"
  5. v-if="QRvisible"
  6. width="800px"
  7. :maxable="true"
  8. >
  9. <div id="printSection">
  10. <div
  11. style="
  12. border: 1px solid #000;
  13. padding: 20px 0;
  14. width: 85mm;
  15. height: 60mm;
  16. box-sizing: border-box;
  17. font-weight: 700;
  18. font-size: 6px;
  19. color: #333;
  20. margin: 0 auto;
  21. "
  22. >
  23. <!-- 第一行信息 -->
  24. <div style="display: flex; flex-direction: row; padding: 0 20px">
  25. <div
  26. style="
  27. display: flex;
  28. flex: 1;
  29. flex-direction: column;
  30. flex-wrap: wrap;
  31. "
  32. >
  33. <div style="margin: 2px 0">产品名称:{{ productName }}</div>
  34. <div style="margin: 2px 0">生产批号:{{ batchNo }}</div>
  35. <div style="margin: 2px 0">生产日期:{{ createDate }}</div>
  36. <div style="margin: 2px 0">失效日期:2029-11-11</div>
  37. <div style="margin: 2px 0">产品数量:5套</div>
  38. <div style="margin: 2px 0">刃径:Φ4.2</div>
  39. </div>
  40. <div
  41. style="
  42. display: flex;
  43. flex: 2;
  44. flex-direction: column;
  45. align-items: center;
  46. "
  47. >
  48. <div>
  49. 规格型号:A07SF
  50. <input type="checkbox" checked style="width: 8px; height: 8px" />
  51. A07SS
  52. <input type="checkbox" style="width: 8px; height: 8px" /> A07ST
  53. <input type="checkbox" style="width: 8px; height: 8px" />
  54. </div>
  55. <!-- 刀刃图示 -->
  56. <table
  57. style="
  58. border-collapse: collapse;
  59. width: 100%;
  60. margin: 8px 0;
  61. text-align: center;
  62. font-size: 6px;
  63. "
  64. >
  65. <thead>
  66. <tr>
  67. <th style="border: 1px solid #000; padding: 4px">刀刃形状</th>
  68. <th style="border: 1px solid #000; padding: 4px">外刃图示</th>
  69. <th style="border: 1px solid #000; padding: 4px">内刃图示</th>
  70. </tr>
  71. </thead>
  72. <tbody style="height: 30px">
  73. <tr>
  74. <td
  75. style="width: 25px; border: 1px solid #000; padding: 4px"
  76. >{{ productName }}</td
  77. >
  78. <td style="width: 33px; border: 1px solid #000; padding: 4px"
  79. ><img src="outer.png" alt="外刃"
  80. /></td>
  81. <td style="width: 33px; border: 1px solid #000; padding: 4px"
  82. ><img src="inner.png" alt="内刃"
  83. /></td>
  84. </tr>
  85. </tbody>
  86. </table>
  87. </div>
  88. </div>
  89. <div style="display: flex; flex-direction: row; padding: 0 20px">
  90. <div style="flex: 1; margin-right: 5px">
  91. <p style="padding: 0; margin: 1px 0"
  92. >医疗器械注册证编号:{{ enforceStandards }}</p
  93. >
  94. <p style="padding: 0; margin: 1px 0"
  95. >生产许可证编号:湘食药监械生产许20170012号</p
  96. >
  97. <p style="padding: 0; margin: 1px 0"
  98. >注册人/生产企业名称:{{ enterpriseDTO.name }}</p
  99. >
  100. <p style="padding: 0; margin: 1px 0">
  101. 注册人/生产企业住址:{{ enterpriseDTO.address }}
  102. </p>
  103. </div>
  104. <div style="flex: 1">
  105. <p style="padding: 0; margin: 0">
  106. 生产地址:{{ purchaseOrigins }}
  107. </p>
  108. <div style="width: 100%; display: flex; justify-content: flex-end">
  109. <canvas
  110. id="barCodeOne"
  111. style="width: 70px; height: 20px; margin-top: 8px"
  112. ></canvas>
  113. </div>
  114. </div>
  115. </div>
  116. <div style="display: flex; flex-direction: row; padding: 0 20px">
  117. <div style="width: 160px">
  118. <p style="margin: 0; padding: 0"
  119. >联系电话:{{ enterpriseDTO.tel }}</p
  120. >
  121. <p style="margin: 0; padding: 0"
  122. >其他内容详见说明书<span>合格</span></p
  123. >
  124. </div>
  125. <div style="display: flex; width: 100%; justify-content: flex-end">
  126. <canvas id="barCodeTwo" style="width: 170px; height: 35px"></canvas>
  127. </div>
  128. </div>
  129. <!-- 图标与条码 -->
  130. <div style="display: flex; gap: 10px; padding: 0 20px">
  131. {{ notice }}
  132. <!-- <span>STERILE EO</span>
  133. <span>经环氧乙烷灭菌</span>
  134. <span>不得二次使用</span>
  135. <span>包装破损时切勿使用</span>
  136. <span>查阅使用说明</span> -->
  137. </div>
  138. <!-- 标签尺寸 -->
  139. <!-- <div class="size">标签尺寸:60*90</div> -->
  140. <!-- 有效期 -->
  141. <!-- <div
  142. style="
  143. display: flex;
  144. text-align: left;
  145. font-size: 14px;
  146. font-weight: normal;
  147. align-items: center;
  148. margin-left: 10px;
  149. "
  150. >有效期变更为 <strong>5 </strong>年</div
  151. > -->
  152. </div>
  153. </div>
  154. <div slot="footer">
  155. <el-button @click="print">打印预览</el-button>
  156. <el-button @click="close">关闭</el-button>
  157. </div>
  158. </ele-modal>
  159. </template>
  160. <script>
  161. import JsBarcode from 'jsbarcode';
  162. export default {
  163. data() {
  164. return {
  165. QRvisible: false,
  166. batchNo: '', //批次号
  167. productName: '', //产品名称
  168. createDate: '', //生产日期
  169. enforceStandards: '', //执行标准
  170. warrantyPeriodUnit: '', //保质日期单位
  171. layBy: '', //贮藏
  172. specification: '', //规格
  173. purchaseOrigins: '', //产地
  174. notice: '', //注意
  175. enterpriseDTO: {},
  176. expiryDate: '' //失效日期
  177. };
  178. },
  179. methods: {
  180. open(item, shortBarcode, longBarcode) {
  181. this.batchNo = item.batchNo;
  182. this.productName = item.productName;
  183. this.createDate = item.createDate;
  184. this.enforceStandards = item.enforceStandards;
  185. this.warrantyPeriodUnit = item.warrantyPeriodUnit;
  186. this.layBy = item.layBy;
  187. this.specification = item.specification;
  188. this.notice = item.notice;
  189. this.enterpriseDTO = item.enterpriseDTO;
  190. const newData = this.createDate.join('-')
  191. this.QRvisible = true;
  192. this.$nextTick(() => {
  193. JsBarcode('#barCodeOne', shortBarcode, {
  194. format: 'CODE128',
  195. width: 2,
  196. height: 40,
  197. displayValue: true
  198. });
  199. JsBarcode('#barCodeTwo', longBarcode, {
  200. format: 'CODE128',
  201. width: 2,
  202. height: 40,
  203. displayValue: true
  204. });
  205. });
  206. },
  207. close() {
  208. this.QRvisible = false;
  209. },
  210. print() {
  211. const printSection = document.getElementById('printSection');
  212. const canvasOne = document.getElementById('barCodeOne');
  213. const imgOne = document.createElement('img');
  214. imgOne.src = canvasOne.toDataURL('image/png');
  215. imgOne.style.width = '70px';
  216. imgOne.style.height = '20px';
  217. // const tempOne = canvasOne.cloneNode(true);
  218. canvasOne.parentNode.replaceChild(imgOne, canvasOne);
  219. const canvasTwo = document.getElementById('barCodeTwo');
  220. const imgTwo = document.createElement('img');
  221. imgTwo.src = canvasTwo.toDataURL('image/png');
  222. imgTwo.style.width = '170px';
  223. imgTwo.style.height = '35px';
  224. // const tempTwo = canvasTwo.cloneNode(true);
  225. canvasTwo.parentNode.replaceChild(imgTwo, canvasTwo);
  226. // 创建打印任务
  227. const printWindow = window.open('', '_blank');
  228. printWindow.document.open();
  229. printWindow.document.write('<html><head><title>打印预览</title>');
  230. printWindow.document.write(
  231. '<link rel="stylesheet" href="your-stylesheet-url.css" type="text/css" />'
  232. );
  233. printWindow.document.write('</head><body>');
  234. printWindow.document.write(printSection.innerHTML);
  235. printWindow.document.write('</body></html>');
  236. printWindow.document.close();
  237. // printWindow.onload = function () {
  238. // printWindow.print();
  239. // };
  240. // 4. 等待图片加载完再打印
  241. printWindow.onload = function () {
  242. setTimeout(() => {
  243. printWindow.print();
  244. // printWindow.close();
  245. }, 500);
  246. };
  247. }
  248. }
  249. };
  250. </script>
  251. <style scoped lang="scss">
  252. .label-container {
  253. border: 1px solid #000;
  254. padding: 20px 0;
  255. width: 85mm;
  256. height: 63mm;
  257. box-sizing: border-box;
  258. font-weight: 700;
  259. font-size: 6px;
  260. color: #333;
  261. }
  262. .label-title {
  263. display: flex;
  264. flex-direction: row;
  265. padding: 0 20px;
  266. }
  267. .label-info-left {
  268. display: flex;
  269. flex: 1;
  270. flex-direction: column;
  271. flex-wrap: wrap;
  272. div {
  273. margin: 2px 0;
  274. }
  275. }
  276. .label-info-right {
  277. display: flex;
  278. flex: 2;
  279. flex-direction: column;
  280. align-items: center;
  281. input {
  282. width: 8px;
  283. height: 8px;
  284. }
  285. }
  286. .row {
  287. display: flex;
  288. justify-content: space-between;
  289. margin-bottom: 4px;
  290. }
  291. .knife-table {
  292. border-collapse: collapse;
  293. width: 100%;
  294. margin: 8px 0;
  295. text-align: center;
  296. }
  297. .knife-table th,
  298. .knife-table td {
  299. border: 1px solid #000;
  300. padding: 4px;
  301. }
  302. .knife-table tbody {
  303. height: 30px;
  304. .knife-title {
  305. width: 33px;
  306. }
  307. }
  308. .knife-table img {
  309. height: 80px;
  310. }
  311. .info {
  312. display: flex;
  313. flex-direction: row;
  314. padding: 0 20px;
  315. .info-left-box {
  316. flex: 1;
  317. margin-right: 5px;
  318. p {
  319. padding: 0;
  320. margin: 1px 0;
  321. }
  322. }
  323. .info-right-box {
  324. flex: 1;
  325. p {
  326. padding: 0;
  327. margin: 0;
  328. }
  329. .canvas-box {
  330. width: 100%;
  331. display: flex;
  332. justify-content: flex-end;
  333. canvas {
  334. width: 70px;
  335. height: 20px;
  336. margin-top: 8px;
  337. }
  338. }
  339. }
  340. }
  341. .phone-box {
  342. display: flex;
  343. flex-direction: row;
  344. padding: 0 20px;
  345. div {
  346. width: 160px;
  347. p {
  348. margin: 0;
  349. padding: 0;
  350. span {
  351. margin-left: 20px;
  352. font-size: 12px;
  353. border: 1px solid #333;
  354. }
  355. }
  356. }
  357. .phone-canvas-box {
  358. display: flex;
  359. width: 100%;
  360. justify-content: flex-end;
  361. canvas {
  362. width: 170px;
  363. height: 35px;
  364. }
  365. }
  366. }
  367. .icons {
  368. display: flex;
  369. gap: 10px;
  370. padding: 0 20px;
  371. }
  372. .barcode {
  373. text-align: center;
  374. margin: 10px 0;
  375. }
  376. .size {
  377. text-align: center;
  378. font-size: 8px;
  379. font-weight: normal;
  380. margin-top: 8px;
  381. }
  382. .expiry {
  383. display: flex;
  384. text-align: left;
  385. font-size: 14px;
  386. font-weight: normal;
  387. align-items: center;
  388. margin-left: 10px;
  389. }
  390. </style>