toPrintTables.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <script setup lang="ts">
  2. import { ElMessageBox } from "element-plus";
  3. import {
  4. consistencyTestData,
  5. moduleScreeningData,
  6. productAcceptanceData,
  7. } from "@/api/statistic/reportMockData";
  8. const detail = ref<any>({});
  9. const dialogVisible = ref(false);
  10. const openPrintDialog = (row) => {
  11. dialogVisible.value = true;
  12. console.info("openPrintDialog", row);
  13. // 在这里调接口
  14. detail.value = row;
  15. };
  16. const handleClose = (done: () => void) => {};
  17. defineExpose({
  18. openPrintDialog: openPrintDialog,
  19. });
  20. </script>
  21. <template>
  22. <el-dialog
  23. v-model="dialogVisible"
  24. width="1000"
  25. append-to-body
  26. align-center
  27. :close-on-click-modal="false"
  28. >
  29. <div>
  30. <el-scrollbar class="scroll-container">
  31. <div id="print">
  32. <div class="tableInfo">
  33. <div style="page-break-after: always">
  34. <div
  35. class="title"
  36. style="text-align: center"
  37. v-if="detail.reportType == 1"
  38. >
  39. 质量日报({{ detail.generationDate }})
  40. </div>
  41. <div
  42. class="title"
  43. style="text-align: center"
  44. v-if="detail.reportType == 2"
  45. >
  46. 质量月报({{ detail.generationDate }})
  47. </div>
  48. <div class="tableTitle">模块筛选情况</div>
  49. <table>
  50. <thead>
  51. <tr>
  52. <th rowspan="2">序号</th>
  53. <th id="lineId" rowspan="2">
  54. <span style="float: left">筛选项目</span>
  55. <span style="float: right; margin-top: 10px"
  56. >产品型号<br />检验批号</span
  57. >
  58. </th>
  59. <th colspan="2">JMT332024</th>
  60. </tr>
  61. <tr>
  62. <th class="vertical-text">数量</th>
  63. <th class="vertical-text">剔除数</th>
  64. </tr>
  65. </thead>
  66. <tbody>
  67. <tr v-for="(item, index) in moduleScreeningData" :key="index">
  68. <td>{{ index + 1 }}</td>
  69. <td>封前目检验</td>
  70. <td>52</td>
  71. <td>66</td>
  72. </tr>
  73. </tbody>
  74. </table>
  75. </div>
  76. <div style="page-break-after: always">
  77. <div class="tableTitle" style="margin-top: 100px">
  78. 销售信息反馈
  79. </div>
  80. <table>
  81. <thead>
  82. <tr>
  83. <th rowspan="2">日期</th>
  84. <th colspan="3">返回产品</th>
  85. <th rowspan="2">用户</th>
  86. <th rowspan="2">反馈内容</th>
  87. <th rowspan="2">原因</th>
  88. <th rowspan="2">纠正措施</th>
  89. <th rowspan="2">备注</th>
  90. </tr>
  91. <tr>
  92. <th>型号</th>
  93. <th>批次</th>
  94. <th>数量</th>
  95. </tr>
  96. </thead>
  97. <tbody>
  98. <tr v-for="(item, index) in consistencyTestData" :key="index">
  99. <td>{{ item.id }}</td>
  100. <td>{{ item.model }}</td>
  101. <td>{{ item.batch }}</td>
  102. <td>{{ item.inspectionStatus }}</td>
  103. <td>{{ item.sampleQuantity }}</td>
  104. </tr>
  105. </tbody>
  106. </table>
  107. </div>
  108. <div style="page-break-after: always; margin-top: 50px">
  109. <div class="tableTitle">质量管理部成品率统计快报</div>
  110. <table>
  111. <thead>
  112. <tr>
  113. <th id="lineId" rowspan="2">
  114. <span style="float: right">产品分类</span>
  115. <span style="float: left; margin-top: 10px">工序</span>
  116. </th>
  117. <th colspan="3">HTH328MJ</th>
  118. </tr>
  119. <tr>
  120. <th class="vertical-text">目标%</th>
  121. <th class="vertical-text">实际%</th>
  122. <th class="vertical-text">增量%</th>
  123. </tr>
  124. </thead>
  125. <tbody>
  126. <tr v-for="(item, index) in moduleScreeningData" :key="index">
  127. <td>清洗</td>
  128. <td>100</td>
  129. <td>100</td>
  130. <td>0</td>
  131. </tr>
  132. <tr>
  133. <td>备注</td>
  134. <td :colspan="1 * 3">这是备注内容</td>
  135. </tr>
  136. </tbody>
  137. </table>
  138. </div>
  139. <div class="tableTitle" style="margin-top: 50px">入库</div>
  140. <div class="info">
  141. <div class="text">产品型号:</div>
  142. <div class="text">产品批次:</div>
  143. <div class="text">报告日期:2025年03月23日</div>
  144. </div>
  145. <table>
  146. <thead>
  147. <tr>
  148. <th>序号</th>
  149. <th>产品型号</th>
  150. <th>批号</th>
  151. <th>数量</th>
  152. </tr>
  153. </thead>
  154. <tbody>
  155. <tr v-for="(item, index) in productAcceptanceData" :key="index">
  156. <td>{{ item.id }}</td>
  157. <td>{{ item.model }}</td>
  158. <td>{{ item.batch }}</td>
  159. <td>{{ item.sampleQuantity }}</td>
  160. </tr>
  161. </tbody>
  162. </table>
  163. </div>
  164. </div>
  165. </el-scrollbar>
  166. </div>
  167. <template #header>
  168. <div class="dialog-header">
  169. <div>报告预览</div>
  170. <el-button type="primary" size="small" @click="dialogVisible = false">
  171. 打印
  172. </el-button>
  173. </div>
  174. </template>
  175. </el-dialog>
  176. </template>
  177. <style scoped lang="scss">
  178. .dialog-header {
  179. display: flex;
  180. justify-content: start;
  181. align-items: center;
  182. gap: 20px;
  183. }
  184. .scroll-container {
  185. height: calc(100vh - 200px);
  186. }
  187. #lineId {
  188. background: #f2f2f2
  189. url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiPjxsaW5lIHgxPSIwIiB5MT0iMCIgeDI9IjEwMCUiIHkyPSIxMDAlIiBzdHJva2U9ImJsYWNrIiBzdHJva2Utd2lkdGg9IjEiLz48L3N2Zz4=)
  190. no-repeat 100% center;
  191. }
  192. @media print {
  193. #print {
  194. position: absolute; /* 或 absolute, fixed, 根据需要调整 */
  195. top: 20px; /* 调整顶部位置 */
  196. margin: 0; /* 重置边距 */
  197. width: 700px;
  198. }
  199. }
  200. table {
  201. width: 100%;
  202. border-collapse: collapse; /* 合并表格边框 */
  203. }
  204. th,
  205. td {
  206. border: 1px solid rgba(0, 0, 0, 0.3); /* 设置所有单元格的边框 */
  207. //padding: 8px;
  208. text-align: left;
  209. }
  210. th {
  211. text-align: center;
  212. background-color: #f2f2f2; /* 设置表头的背景颜色 */
  213. }
  214. .bgColor {
  215. position: fixed;
  216. width: 100vw;
  217. height: 100vh;
  218. z-index: 99999;
  219. background-color: rgba(0, 0, 0, 0.3);
  220. top: 0;
  221. display: flex;
  222. align-items: center;
  223. justify-content: center;
  224. left: 0;
  225. .body {
  226. width: 80%;
  227. height: 85vh;
  228. background-color: white;
  229. display: flex;
  230. flex-direction: column;
  231. padding: 20px;
  232. .header {
  233. width: 100%;
  234. height: 40px;
  235. display: flex;
  236. padding-bottom: 10px;
  237. justify-content: space-between;
  238. border-bottom: 1px solid rgba(0, 0, 0, 0.3);
  239. }
  240. .box {
  241. height: calc(100% - 40px);
  242. }
  243. }
  244. }
  245. .tableInfo {
  246. width: 100%;
  247. height: 60px;
  248. .tableTitle {
  249. margin: 10px 0;
  250. font-size: 20px;
  251. font-weight: 600;
  252. letter-spacing: 20px;
  253. text-align: center;
  254. }
  255. .title {
  256. margin: 10px 0;
  257. font-size: 20px;
  258. font-weight: 600;
  259. }
  260. .info {
  261. display: flex;
  262. padding: 0 20px;
  263. justify-content: space-between;
  264. }
  265. }
  266. .slash {
  267. position: relative;
  268. }
  269. .slash::before {
  270. content: "";
  271. position: absolute;
  272. left: 0;
  273. top: 0;
  274. width: 100%;
  275. height: 100%;
  276. border-left: 1px solid #444;
  277. transform: rotate(45deg);
  278. transform-origin: 0 0;
  279. }
  280. .split-line {
  281. border-bottom: 1px solid #444;
  282. padding: 4px 0;
  283. }
  284. //上下分割成两行的
  285. .top-and-bottom {
  286. display: flex;
  287. flex-direction: column;
  288. align-items: center;
  289. justify-content: space-around;
  290. border: 0;
  291. .content {
  292. display: flex;
  293. justify-content: center;
  294. align-items: center;
  295. }
  296. .middle-line {
  297. width: 100%;
  298. height: 1px;
  299. background-color: rgba(0, 0, 0, 0.3);
  300. }
  301. }
  302. .vertical-text {
  303. writing-mode: vertical-rl; /* 竖排从右到左 */
  304. text-orientation: upright; /* 保持字符直立 */
  305. }
  306. </style>