indexMultiple.vue 17 KB

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