printFlowCard.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. <template>
  2. <ele-modal
  3. title="工序流转卡"
  4. :visible.sync="QRvisible"
  5. v-if="QRvisible"
  6. width="900px"
  7. :maxable="true"
  8. >
  9. <div id="printSection" class="flow-card-print">
  10. <div
  11. class="flow-card-page"
  12. v-for="(card, cIndex) in printList"
  13. :key="cIndex"
  14. >
  15. <div class="flow-card-title">工&nbsp;&nbsp;序&nbsp;&nbsp;流&nbsp;&nbsp;转&nbsp;&nbsp;卡</div>
  16. <table class="flow-card-header">
  17. <tr>
  18. <td class="label">产&nbsp;&nbsp;品&nbsp;&nbsp;代&nbsp;&nbsp;号</td>
  19. <td class="value">{{ card.topCategoryCode }}</td>
  20. <td class="label">产&nbsp;&nbsp;品&nbsp;&nbsp;名&nbsp;&nbsp;称</td>
  21. <td class="value">{{ card.topCategoryName }}</td>
  22. </tr>
  23. <tr>
  24. <td class="label">零(部)件代号</td>
  25. <td class="value">{{ card.productCode }}</td>
  26. <td class="label">零(部)件名称</td>
  27. <td class="value">{{ card.productName }}</td>
  28. </tr>
  29. <tr>
  30. <td class="label">产品批号(编号)</td>
  31. <td class="value">{{ card.batchNo }}</td>
  32. <td class="label">原材料本厂合格证号</td>
  33. <td class="value">{{ card.materialFactoryCertNo }}</td>
  34. </tr>
  35. <tr>
  36. <td class="label">原材料炉(批)号</td>
  37. <td class="value">{{ card.materialFurnaceNo }}</td>
  38. <td class="label">半成品合格证号</td>
  39. <td class="value">{{ card.semiProductCertNo }}</td>
  40. </tr>
  41. </table>
  42. <table class="flow-card-detail">
  43. <thead>
  44. <tr>
  45. <th rowspan="2" class="col-no">工<br />序<br />号</th>
  46. <th rowspan="2" class="col-name">工序名称</th>
  47. <th rowspan="2" class="col-num">转<br />入<br />数</th>
  48. <th rowspan="2" class="col-leader">工序负<br />责人</th>
  49. <th rowspan="2" class="col-num">转<br />出<br />数</th>
  50. <th colspan="2" class="col-bad">不&nbsp;&nbsp;合&nbsp;&nbsp;格&nbsp;&nbsp;数</th>
  51. <th rowspan="2" class="col-date">日&nbsp;&nbsp;&nbsp;期</th>
  52. <th rowspan="2" class="col-remark">备&nbsp;&nbsp;注</th>
  53. </tr>
  54. <tr>
  55. <th class="col-bad-sub">返工<br />品数</th>
  56. <th class="col-bad-sub">废品<br />数</th>
  57. </tr>
  58. </thead>
  59. <tbody>
  60. <tr v-for="(row, idx) in getRows(card)" :key="idx">
  61. <td>{{ row.taskNo }}</td>
  62. <td>{{ row.taskName }}</td>
  63. <td>{{ row.inNum }}</td>
  64. <td>{{ row.leader }}</td>
  65. <td>{{ row.outNum }}</td>
  66. <td>{{ row.reworkNum }}</td>
  67. <td>{{ row.scrapNum }}</td>
  68. <td>{{ row.date }}</td>
  69. <td>{{ row.remark }}</td>
  70. </tr>
  71. </tbody>
  72. </table>
  73. <div class="flow-card-footer">
  74. <div class="footer-item">发出日期:{{ card.issueDate }}</div>
  75. <div class="footer-item">收回日期:{{ card.recoverDate }}</div>
  76. </div>
  77. </div>
  78. </div>
  79. <div slot="footer">
  80. <el-button @click="print">打印预览</el-button>
  81. <el-button @click="close">关闭</el-button>
  82. </div>
  83. </ele-modal>
  84. </template>
  85. <script>
  86. import { getTaskInstanceList } from '@/api/produce/job';
  87. export default {
  88. name: 'print-flow-card',
  89. data() {
  90. return {
  91. QRvisible: false,
  92. rowCount: 25,
  93. printList: []
  94. };
  95. },
  96. methods: {
  97. async open(rows) {
  98. const list = Array.isArray(rows) ? rows : rows ? [rows] : [];
  99. if (!list.length) {
  100. this.printList = [this.buildEmptyCard()];
  101. this.QRvisible = true;
  102. return;
  103. }
  104. const cards = await Promise.all(
  105. list.map((row) =>
  106. getTaskInstanceList(row.id)
  107. .then((res) => this.buildCard(row, Array.isArray(res) ? res : []))
  108. .catch(() => this.buildCard(row, []))
  109. )
  110. );
  111. this.printList = cards;
  112. this.QRvisible = true;
  113. },
  114. close() {
  115. this.QRvisible = false;
  116. },
  117. buildEmptyCard() {
  118. return {
  119. topCategoryCode: '',
  120. topCategoryName: '',
  121. productCode: '',
  122. productName: '',
  123. batchNo: '',
  124. materialFactoryCertNo: '',
  125. materialFurnaceNo: '',
  126. semiProductCertNo: '',
  127. issueDate: '',
  128. recoverDate: '',
  129. taskList: []
  130. };
  131. },
  132. buildCard(row, taskList) {
  133. return {
  134. topCategoryCode: row.topCategoryCode || '',
  135. topCategoryName: row.topCategoryName || '',
  136. productCode: row.productCode || '',
  137. productName: row.productName || '',
  138. batchNo: row.batchNo || '',
  139. materialFactoryCertNo: row.materialFactoryCertNo || '',
  140. materialFurnaceNo: row.materialFurnaceNo || '',
  141. semiProductCertNo: row.semiProductCertNo || '',
  142. issueDate: row.issueDate || '',
  143. recoverDate: row.recoverDate || '',
  144. taskList: taskList.map((item, idx) => ({
  145. taskNo: idx + 1,
  146. taskName: item.taskTypeName || item.taskName || ''
  147. }))
  148. };
  149. },
  150. getRows(card) {
  151. const list = Array.isArray(card.taskList) ? card.taskList.slice() : [];
  152. const rows = list.map((item, i) => ({
  153. taskNo: item.taskNo || i + 1,
  154. taskName: item.taskName || '',
  155. inNum: item.inNum || '',
  156. leader: item.leader || '',
  157. outNum: item.outNum || '',
  158. reworkNum: item.reworkNum || '',
  159. scrapNum: item.scrapNum || '',
  160. date: item.date || '',
  161. remark: item.remark || ''
  162. }));
  163. while (rows.length < this.rowCount) {
  164. rows.push({
  165. taskNo: '',
  166. taskName: '',
  167. inNum: '',
  168. leader: '',
  169. outNum: '',
  170. reworkNum: '',
  171. scrapNum: '',
  172. date: '',
  173. remark: ''
  174. });
  175. }
  176. return rows;
  177. },
  178. print() {
  179. const printSection = document.getElementById('printSection');
  180. const printWindow = window.open('', '_blank');
  181. printWindow.document.open();
  182. printWindow.document.write(`<!DOCTYPE html>
  183. <html>
  184. <head>
  185. <meta charset="UTF-8" />
  186. <title>工序流转卡</title>
  187. <style>
  188. @page { size: A4 portrait; margin: 12mm 10mm; }
  189. html, body {
  190. margin: 0;
  191. padding: 0;
  192. width: 190mm;
  193. font-family: 'SimSun', '宋体', 'Microsoft YaHei', serif;
  194. color: #000;
  195. -webkit-print-color-adjust: exact;
  196. print-color-adjust: exact;
  197. }
  198. .flow-card-page {
  199. width: 190mm;
  200. box-sizing: border-box;
  201. page-break-after: always;
  202. }
  203. .flow-card-page:last-child { page-break-after: auto; }
  204. .flow-card-title {
  205. text-align: center;
  206. font-size: 28px;
  207. font-weight: bold;
  208. letter-spacing: 16px;
  209. text-decoration: underline;
  210. margin: 0 0 8mm 0;
  211. padding-top: 2mm;
  212. }
  213. table {
  214. width: 190mm;
  215. border-collapse: collapse;
  216. table-layout: fixed;
  217. }
  218. .flow-card-header td {
  219. border: 1px solid #000;
  220. height: 11mm;
  221. padding: 0 6px;
  222. font-size: 16px;
  223. vertical-align: middle;
  224. }
  225. .flow-card-header td.label {
  226. width: 22%;
  227. text-align: center;
  228. }
  229. .flow-card-header td.value { width: 28%; }
  230. .flow-card-detail th,
  231. .flow-card-detail td {
  232. border: 1px solid #000;
  233. text-align: center;
  234. vertical-align: middle;
  235. font-size: 14px;
  236. padding: 1px 2px;
  237. line-height: 1.3;
  238. white-space: nowrap;
  239. }
  240. .flow-card-detail th { font-weight: bold; }
  241. .flow-card-detail thead th { height: 7mm; }
  242. .flow-card-detail tbody td { height: 9mm; }
  243. .col-no { width: 7%; }
  244. .col-name { width: 17%; }
  245. .col-num { width: 7%; }
  246. .col-leader { width: 10%; }
  247. .col-bad { width: 14%; }
  248. .col-bad-sub { width: 7%; }
  249. .col-date { width: 13%; }
  250. .col-remark { width: 11%; }
  251. .flow-card-footer {
  252. display: flex;
  253. justify-content: space-between;
  254. margin-top: 6mm;
  255. font-size: 16px;
  256. }
  257. .flow-card-footer .footer-item { width: 45%; }
  258. </style>
  259. </head>
  260. <body>
  261. ${printSection.innerHTML}
  262. </body>
  263. </html>`);
  264. printWindow.document.close();
  265. printWindow.onload = function () {
  266. printWindow.focus();
  267. printWindow.print();
  268. };
  269. }
  270. }
  271. };
  272. </script>
  273. <style lang="scss" scoped>
  274. .flow-card-print {
  275. background: #fff;
  276. color: #000;
  277. font-family: 'SimSun', '宋体', 'Microsoft YaHei', serif;
  278. padding: 6mm 4mm;
  279. *,
  280. *::before,
  281. *::after {
  282. box-sizing: border-box;
  283. }
  284. }
  285. .flow-card-page {
  286. width: 186mm;
  287. margin: 0 auto 12mm auto;
  288. }
  289. .flow-card-title {
  290. text-align: center;
  291. font-size: 26pt;
  292. font-weight: bold;
  293. letter-spacing: 14px;
  294. text-decoration: underline;
  295. margin: 0 0 6mm 0;
  296. padding-bottom: 2mm;
  297. }
  298. .flow-card-header,
  299. .flow-card-detail {
  300. width: 100%;
  301. border-collapse: collapse;
  302. table-layout: fixed;
  303. }
  304. .flow-card-header td {
  305. border: 1px solid #000;
  306. height: 11mm;
  307. padding: 0 6px;
  308. font-size: 13pt;
  309. vertical-align: middle;
  310. &.label {
  311. width: 22%;
  312. text-align: center;
  313. }
  314. &.value {
  315. width: 28%;
  316. }
  317. }
  318. .flow-card-detail {
  319. th,
  320. td {
  321. border: 1px solid #000;
  322. text-align: center;
  323. vertical-align: middle;
  324. font-size: 11pt;
  325. padding: 1px 2px;
  326. line-height: 1.25;
  327. }
  328. th {
  329. font-weight: bold;
  330. }
  331. thead th {
  332. height: 7mm;
  333. }
  334. tbody td {
  335. height: 9mm;
  336. }
  337. }
  338. .col-no { width: 7%; }
  339. .col-name { width: 17%; }
  340. .col-num { width: 7%; }
  341. .col-leader { width: 10%; }
  342. .col-bad { width: 14%; }
  343. .col-bad-sub { width: 7%; }
  344. .col-date { width: 13%; }
  345. .col-remark { width: 11%; }
  346. .flow-card-footer {
  347. display: flex;
  348. justify-content: space-between;
  349. margin-top: 6mm;
  350. font-size: 13pt;
  351. .footer-item {
  352. width: 45%;
  353. }
  354. }
  355. </style>