index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. <template>
  2. <div>
  3. <!-- 打印窗口 -->
  4. <el-dialog
  5. title="打印条码"
  6. width="1000px"
  7. :before-close="handleClose"
  8. :visible.sync="openBarCode"
  9. >
  10. <div id="content" ref="print-content">
  11. <div
  12. :class="config.putType == 1 ? 'crosswise' : 'lengthways'"
  13. :style="
  14. 'width:' +
  15. config.sizeWide +
  16. 'cm;' +
  17. 'height:' +
  18. config.sizeLong +
  19. 'cm;' +
  20. 'border: 2px black solid;'
  21. "
  22. >
  23. <div class="active-top" v-show="config.putType == 1">
  24. <div class="span-con">
  25. <div class="con-top">
  26. <span
  27. :style="
  28. 'font-size:' +
  29. config.fontSizeCode1 +
  30. 'cm;font-family:' +
  31. config.typefaceCode1
  32. "
  33. >{{ config.code1 }}</span
  34. >
  35. <span
  36. :style="
  37. 'font-size:' +
  38. config.fontSizeCode2 +
  39. 'cm;font-family:' +
  40. config.typefaceCode2
  41. "
  42. >{{ config.code2 }}</span
  43. >
  44. <span
  45. :style="
  46. 'font-size:' +
  47. config.fontSizeCode3 +
  48. 'cm;font-family:' +
  49. config.typefaceCode3
  50. "
  51. >{{ config.code3 }}</span
  52. >
  53. </div>
  54. <div class="con-bottom">
  55. <span
  56. :style="
  57. 'font-size:' +
  58. config.fontSizeCode4 +
  59. 'cm;font-family:' +
  60. config.typefaceCode4
  61. "
  62. >{{ config.code4 }}</span
  63. >
  64. <span
  65. :style="
  66. 'font-size:' +
  67. config.fontSizeCode5 +
  68. 'cm;font-family:' +
  69. config.typefaceCode5
  70. "
  71. >{{ config.code5 }}</span
  72. >
  73. <span
  74. :style="
  75. 'font-size:' +
  76. config.fontSizeCode6 +
  77. 'cm;font-family:' +
  78. config.typefaceCode6
  79. "
  80. >{{ config.code6 }}</span
  81. >
  82. </div>
  83. </div>
  84. <div class="logoImg">
  85. <!-- <img src="@/assets/img/codeLogo.png" alt="" /> -->
  86. </div>
  87. </div>
  88. <div class="active-bottom" v-show="config.putType == 1">
  89. <div class="left-con">
  90. <div class="span-box">
  91. <span
  92. :style="
  93. 'font-size:' +
  94. config.fontSizeCode7 +
  95. 'cm;font-family:' +
  96. config.typefaceCode7
  97. "
  98. >{{ config.code7 }}</span
  99. >
  100. <span
  101. :style="
  102. 'font-size:' +
  103. config.fontSizeCode8 +
  104. 'cm;font-family:' +
  105. config.typefaceCode8
  106. "
  107. >{{ config.code8 }}</span
  108. >
  109. </div>
  110. <div class="span-box">
  111. <span
  112. :style="
  113. 'font-size:' +
  114. config.fontSizeCode9 +
  115. 'cm;font-family:' +
  116. config.typefaceCode9
  117. "
  118. >{{ config.code9 }}</span
  119. >
  120. <span
  121. :style="
  122. 'font-size:' +
  123. config.fontSizeCode10 +
  124. 'cm;font-family:' +
  125. config.typefaceCode10
  126. "
  127. >{{ config.code10 }}</span
  128. >
  129. </div>
  130. <div class="span-box">
  131. <span
  132. :style="
  133. 'font-size:' +
  134. config.fontSizeCode11 +
  135. 'cm;font-family:' +
  136. config.typefaceCode11
  137. "
  138. >{{ config.code11 }}</span
  139. >
  140. <span
  141. :style="
  142. 'font-size:' +
  143. config.fontSizeCode12 +
  144. 'cm;font-family:' +
  145. config.typefaceCode12
  146. "
  147. >{{ config.code12 }}</span
  148. >
  149. </div>
  150. <div class="span-box">
  151. <span
  152. :style="
  153. 'font-size:' +
  154. config.fontSizeCode13 +
  155. 'cm;font-family:' +
  156. config.typefaceCode13
  157. "
  158. >{{ config.code13 }}</span
  159. >
  160. <span
  161. :style="
  162. 'font-size:' +
  163. config.fontSizeCode14 +
  164. 'cm;font-family:' +
  165. config.typefaceCode14
  166. "
  167. >{{ config.code14 }}</span
  168. >
  169. </div>
  170. </div>
  171. <div class="vue-qr">
  172. <vue-qr
  173. :logoSrc="config.imagePath"
  174. :text="config.qrCode ? config.qrCode : ''"
  175. class="vueQrSize"
  176. ></vue-qr>
  177. </div>
  178. </div>
  179. <div v-show="config.putType == 2" class="vertical-top1">
  180. <div class="top-img">
  181. <div class="top-span">
  182. <p
  183. :style="
  184. 'font-size:' +
  185. config.fontSizeCode1 +
  186. 'cm;font-family:' +
  187. config.typefaceCode1
  188. "
  189. >
  190. {{ config.code1 }}
  191. </p>
  192. <p
  193. :style="
  194. 'font-size:' +
  195. config.fontSizeCode2 +
  196. 'cm;font-family:' +
  197. config.typefaceCode2
  198. "
  199. >
  200. {{ config.code2 }}
  201. </p>
  202. </div>
  203. <div class="logoImg">
  204. <!-- <img src="@/assets/img/codeLogo.png" alt="" /> -->
  205. </div>
  206. </div>
  207. <div class="bottom-span">
  208. <div class="top">
  209. <span
  210. :style="
  211. 'font-size:' +
  212. config.fontSizeCode3 +
  213. 'cm;font-family:' +
  214. config.typefaceCode3
  215. "
  216. >{{ config.code3 }}</span
  217. >
  218. <span
  219. :style="
  220. 'font-size:' +
  221. config.fontSizeCode4 +
  222. 'cm;font-family:' +
  223. config.typefaceCode4
  224. "
  225. >{{ config.code4 }}</span
  226. >
  227. </div>
  228. <div class="bottom">
  229. <span
  230. :style="
  231. 'font-size:' +
  232. config.fontSizeCode5 +
  233. 'cm;font-family:' +
  234. config.typefaceCode5
  235. "
  236. >{{ config.code5 }}</span
  237. >
  238. <span
  239. :style="
  240. 'font-size:' +
  241. config.fontSizeCode6 +
  242. 'cm;font-family:' +
  243. config.typefaceCode6
  244. "
  245. >{{ config.code6 }}</span
  246. >
  247. </div>
  248. </div>
  249. </div>
  250. <div v-show="config.putType == 2" class="vertical-bottom1">
  251. <div class="bot-top">
  252. <div class="bot-con">
  253. <span
  254. :style="
  255. 'font-size:' +
  256. config.fontSizeCode7 +
  257. 'cm;font-family:' +
  258. config.typefaceCode7
  259. "
  260. >{{ config.code7 }}</span
  261. >
  262. <span
  263. :style="
  264. 'font-size:' +
  265. config.fontSizeCode8 +
  266. 'cm;font-family:' +
  267. config.typefaceCode8
  268. "
  269. >{{ config.code8 }}</span
  270. >
  271. </div>
  272. <div class="bot-con">
  273. <span
  274. :style="
  275. 'font-size:' +
  276. config.fontSizeCode9 +
  277. 'cm;font-family:' +
  278. config.typefaceCode9
  279. "
  280. >{{ config.code9 }}</span
  281. >
  282. <span
  283. :style="
  284. 'font-size:' +
  285. config.fontSizeCode10 +
  286. 'cm;font-family:' +
  287. config.typefaceCode10
  288. "
  289. >{{ config.code10 }}</span
  290. >
  291. </div>
  292. <div class="bot-con">
  293. <span
  294. :style="
  295. 'font-size:' +
  296. config.fontSizeCode11 +
  297. 'cm;font-family:' +
  298. config.typefaceCode11
  299. "
  300. >{{ config.code11 }}</span
  301. >
  302. <span
  303. :style="
  304. 'font-size:' +
  305. config.fontSizeCode12 +
  306. 'cm;font-family:' +
  307. config.typefaceCode12
  308. "
  309. >{{ config.code12 }}</span
  310. >
  311. </div>
  312. </div>
  313. <div class="bot-bottom">
  314. <div class="qr-span">
  315. <span
  316. :style="
  317. 'font-size:' +
  318. config.fontSizeCode13 +
  319. 'cm;font-family:' +
  320. config.typefaceCode13
  321. "
  322. >{{ config.code13 }}</span
  323. >
  324. <span
  325. :style="
  326. 'font-size:' +
  327. config.fontSizeCode14 +
  328. 'cm;font-family:' +
  329. config.typefaceCode14
  330. "
  331. >{{ config.code14 }}</span
  332. >
  333. </div>
  334. <div class="vue-qr">
  335. <vue-qr
  336. :logoSrc="config.imagePath"
  337. :text="config.qrCode ? config.qrCode : ''"
  338. class="vueQrSize"
  339. ></vue-qr>
  340. </div>
  341. </div>
  342. </div>
  343. </div>
  344. </div>
  345. <div slot="footer" class="dialog-footer" style="margin-right: 2%">
  346. <el-button size="small" @click="Print" v-show="!isPrint" type="primary"
  347. >打印</el-button
  348. >
  349. <el-button size="small" @click="handleClose">关闭</el-button>
  350. </div>
  351. </el-dialog>
  352. </div>
  353. </template>
  354. <script>
  355. import VueQr from 'vue-qr'
  356. export default {
  357. components: {
  358. VueQr
  359. },
  360. props: {
  361. config: {
  362. type: Object,
  363. default () {
  364. return config
  365. }
  366. },
  367. openBarCode: {
  368. type: Boolean,
  369. default: false
  370. }
  371. },
  372. data () {
  373. return {
  374. isPrint: false
  375. }
  376. },
  377. methods: {
  378. //打印
  379. Print () {
  380. this.isPrint = true
  381. setTimeout(() => {
  382. this.$print(this.$refs['print-content']) //打印
  383. this.isPrint = false
  384. })
  385. },
  386. handleClose () {
  387. this.$emit('update:openBarCode', false)
  388. }
  389. }
  390. }
  391. </script>
  392. <style lang="scss" scoped>
  393. * {
  394. letter-spacing: 0.1px !important;
  395. }
  396. #content {
  397. display: flex;
  398. justify-content: center;
  399. .active-top {
  400. width: 100%;
  401. height: 40%;
  402. display: flex;
  403. border-bottom: 2px black solid;
  404. .span-con {
  405. width: 80%;
  406. height: 100%;
  407. padding: 5px 10px;
  408. .con-top,
  409. .con-bottom {
  410. width: 100%;
  411. height: 50%;
  412. display: flex;
  413. justify-content: space-between;
  414. span {
  415. font-weight: bold;
  416. display: inline-block;
  417. margin-top: 10px;
  418. }
  419. }
  420. }
  421. .logoImg {
  422. width: 20%;
  423. height: 70%;
  424. margin: 10px;
  425. text-align: right;
  426. img {
  427. width: 100%;
  428. height: 80%;
  429. }
  430. }
  431. }
  432. .active-bottom {
  433. height: 60%;
  434. display: flex;
  435. justify-content: space-between;
  436. .left-con {
  437. padding: 5px;
  438. width: 70%;
  439. height: 100%;
  440. display: flex;
  441. flex-wrap: wrap;
  442. .span-box {
  443. margin-top: 10px;
  444. width: 100%;
  445. display: flex;
  446. justify-content: space-between;
  447. span {
  448. font-weight: bold;
  449. display: inline-block;
  450. margin: 0 5px;
  451. }
  452. }
  453. }
  454. .vue-qr {
  455. width: 40%;
  456. height: 100%;
  457. border-left: 2px black solid;
  458. display: flex;
  459. justify-content: center;
  460. align-items: center;
  461. .vueQrSize {
  462. width: 100%;
  463. height: 100%;
  464. object-fit: contain;
  465. }
  466. }
  467. }
  468. .vertical-top1 {
  469. width: 100%;
  470. height: 40%;
  471. border-bottom: 2px black solid;
  472. .top-img {
  473. width: 100%;
  474. height: 50%;
  475. padding: 10px;
  476. display: flex;
  477. .top-span {
  478. width: 70%;
  479. height: 100%;
  480. margin-top: 10px;
  481. p {
  482. font-weight: bold;
  483. height: 50%;
  484. line-height: 50%;
  485. }
  486. }
  487. .logoImg {
  488. width: 30%;
  489. height: 80%;
  490. text-align: right;
  491. img {
  492. width: 100%;
  493. height: 100%;
  494. }
  495. }
  496. }
  497. .bottom-span {
  498. padding: 10px;
  499. width: 100%;
  500. height: 50%;
  501. .top,
  502. .bottom {
  503. width: 100%;
  504. height: 50%;
  505. margin-top: 2%;
  506. display: flex;
  507. justify-content: space-between;
  508. span {
  509. font-weight: bold;
  510. display: inline-block;
  511. height: 50%;
  512. line-height: 50%;
  513. }
  514. }
  515. }
  516. }
  517. .vertical-bottom1 {
  518. width: 100%;
  519. height: 60%;
  520. .bot-top {
  521. width: 100%;
  522. height: 55%;
  523. padding: 10px;
  524. display: flex;
  525. flex-wrap: wrap;
  526. .bot-con {
  527. width: 100%;
  528. display: flex;
  529. justify-content: space-between;
  530. font-weight: bold;
  531. margin-top: 5%;
  532. span {
  533. font-weight: bold;
  534. }
  535. }
  536. }
  537. .bot-bottom {
  538. width: 100%;
  539. height: 45%;
  540. display: flex;
  541. .qr-span {
  542. width: 60%;
  543. height: 100%;
  544. padding: 10px;
  545. span {
  546. display: inline-block;
  547. width: 100%;
  548. height: 50%;
  549. font-weight: bold;
  550. line-height: 50%;
  551. }
  552. }
  553. .vue-qr {
  554. width: 50%;
  555. height: 100%;
  556. border-left: 2px black solid;
  557. border-top: 2px black solid;
  558. display: flex;
  559. justify-content: center;
  560. align-items: center;
  561. .vueQrSize {
  562. width: 100%;
  563. height: 100%;
  564. object-fit: contain;
  565. }
  566. }
  567. }
  568. }
  569. .crosswise,
  570. .lengthways {
  571. transition: all 0.5s;
  572. }
  573. }
  574. </style>