printBilletSampleCard.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <template>
  2. <BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose title="钢坯送样卡" :width="800" :height="930" ok-text="打印" @ok="onPrint">
  3. <section
  4. ref="print"
  5. style="padding: 10px 10px 0; position: relative; border: 1px solid #c5c5c5; background: #fff; width: 98%"
  6. id="printBilletSampleCard"
  7. >
  8. <div class="ticket next-ticket">
  9. <div style="text-align: center">
  10. <p style="font-size: 24px; font-weight: 800; display: inline-block; border-bottom: 2px solid #000; margin-bottom: 16px; line-height: 30px">
  11. 钢 坯 送 样 卡
  12. </p>
  13. </div>
  14. <div class="flex ccmno-info" style="line-height: 24px">
  15. <div class="flex-1">
  16. <span class="ccmno">{{ hostNumber }}</span>
  17. 号连铸机
  18. </div>
  19. <div class="flex-1" style="text-align: center; font-size: 13px">
  20. {{ dayjs().format('YYYY 年 MM 月 DD 日') }}&nbsp;&nbsp; {{ shiftInfoTxt }}
  21. </div>
  22. <div class="flex-1" style="text-align: right; font-size: 12px"> zj / R177 </div>
  23. </div>
  24. <a-descriptions style="margin-top: 6px; margin-bottom: 4px" bordered :column="6" size="small">
  25. <a-descriptions-item label="序号" :labelStyle="labelStyle" :contentStyle="contentStyle">炉号</a-descriptions-item>
  26. <a-descriptions-item :labelStyle="sizeLabelStyle" :contentStyle="sizeContentStyle">
  27. <div class="size-items-title">
  28. 定尺&nbsp;&nbsp;&nbsp;&nbsp;
  29. <span class="s-txt">{{ sizeArrs[0] ? '170' : '' }}</span>
  30. </div>
  31. <div class="size-num-title">
  32. 支数 <span class="s-txt">{{ sizeArrs[0] ? Number(sizeArrs[0]) / 1000 + 'm' : '' }}</span>
  33. </div>
  34. </a-descriptions-item>
  35. <a-descriptions-item :labelStyle="sizeLabelStyle" :contentStyle="sizeContentStyle">
  36. <div class="size-items-title">
  37. 定尺&nbsp;&nbsp;&nbsp;&nbsp;
  38. <span class="s-txt">{{ sizeArrs[1] ? '170' : '' }}</span>
  39. </div>
  40. <div class="size-num-title">
  41. 支数 <span class="s-txt">{{ sizeArrs[1] ? Number(sizeArrs[1]) / 1000 + 'm' : '' }}</span>
  42. </div>
  43. </a-descriptions-item>
  44. <a-descriptions-item label="序号" :labelStyle="labelStyle" :contentStyle="contentStyle">
  45. 炉号
  46. <div class="two-num-wrapper">
  47. <span class="s-txt">{{ sizeArrs[2] ? '170' : '' }}</span>
  48. <span class="s-txt">{{ sizeArrs[2] ? Number(sizeArrs[2]) / 1000 + 'm' : '' }}</span>
  49. </div>
  50. </a-descriptions-item>
  51. <a-descriptions-item :labelStyle="sizeLabelStyle" :contentStyle="sizeContentStyle">
  52. <div class="size-items-title">
  53. 定尺&nbsp;&nbsp;&nbsp;&nbsp;
  54. <span class="s-txt">{{ sizeArrs[3] ? '170' : '' }}</span>
  55. </div>
  56. <div class="size-num-title">
  57. 支数 <span class="s-txt">{{ sizeArrs[3] ? Number(sizeArrs[3]) / 1000 + 'm' : '' }}</span>
  58. </div>
  59. </a-descriptions-item>
  60. <a-descriptions-item :labelStyle="sizeLabelStyle" :contentStyle="sizeContentStyle">
  61. <div class="size-items-title">
  62. 定尺&nbsp;&nbsp;&nbsp;&nbsp;
  63. <span class="s-txt">
  64. {{ sizeArrs[4] ? '170' : '' }}
  65. </span>
  66. </div>
  67. <div class="size-num-title">
  68. 支数 <span class="s-txt">{{ sizeArrs[4] ? Number(sizeArrs[4]) / 1000 + 'm' : '' }}</span>
  69. </div>
  70. </a-descriptions-item>
  71. <template v-for="i in 20">
  72. <!-- 第一组 -->
  73. <a-descriptions-item :label="i - 1" :labelStyle="labelStyle" :contentStyle="contentStyle">{{
  74. heatList[i - 1] ? heatList[i - 1].heatNo : ''
  75. }}</a-descriptions-item>
  76. <a-descriptions-item :labelStyle="sizeLabelStyle" :contentStyle="sizeContentStyle">
  77. <div class="size-items-content">{{
  78. heatList[i - 1] && heatList[i - 1].sizeInfo && heatList[i - 1].sizeInfo[sizeArrs[0]]
  79. ? heatList[i - 1].sizeInfo[sizeArrs[0]].lengthTotalCount
  80. : ''
  81. }}</div>
  82. </a-descriptions-item>
  83. <a-descriptions-item :labelStyle="sizeLabelStyle" :contentStyle="sizeContentStyle">
  84. <div class="size-items-content">{{
  85. heatList[i - 1] && heatList[i - 1].sizeInfo && heatList[i - 1].sizeInfo[sizeArrs[1]]
  86. ? heatList[i - 1].sizeInfo[sizeArrs[1]].lengthTotalCount
  87. : ''
  88. }}</div>
  89. </a-descriptions-item>
  90. <!-- 第二组 -->
  91. <a-descriptions-item :label="19 + i" :labelStyle="labelStyle" :contentStyle="contentStyle">
  92. {{
  93. heatList[i - 1] && heatList[i - 1].sizeInfo && heatList[i - 1].sizeInfo[sizeArrs[2]]
  94. ? heatList[i - 1].sizeInfo[sizeArrs[2]].lengthTotalCount
  95. : ''
  96. }}
  97. </a-descriptions-item>
  98. <a-descriptions-item :labelStyle="sizeLabelStyle" :contentStyle="sizeContentStyle">
  99. <div class="size-items-content">{{
  100. heatList[i - 1] && heatList[i - 1].sizeInfo && heatList[i - 1].sizeInfo[sizeArrs[3]]
  101. ? heatList[i - 1].sizeInfo[sizeArrs[3]].lengthTotalCount
  102. : ''
  103. }}</div>
  104. </a-descriptions-item>
  105. <a-descriptions-item :labelStyle="sizeLabelStyle" :contentStyle="sizeContentStyle">
  106. <div class="size-items-content">{{
  107. heatList[i - 1] && heatList[i - 1].sizeInfo && heatList[i - 1].sizeInfo[sizeArrs[4]]
  108. ? heatList[i - 1].sizeInfo[sizeArrs[4]].lengthTotalCount
  109. : ''
  110. }}</div>
  111. </a-descriptions-item>
  112. </template>
  113. </a-descriptions>
  114. <a-descriptions style="padding: 0" size="small" :column="6">
  115. <a-descriptions-item label="备注" :span="1">
  116. <div class="size-items-remark flex">
  117. <!-- <div class="size-remark-item" v-for="(ele, size) in sizeObjs">
  118. <span class="size-remark-size">{{ Number(size) / 1000 }} m:</span>
  119. <span class="size-remark-num">{{ ele.num }}</span>
  120. <span>{{ ele.weight.toFixed(3) }}t</span>
  121. </div> -->
  122. </div>
  123. </a-descriptions-item>
  124. </a-descriptions>
  125. </div>
  126. </section>
  127. </BasicModal>
  128. </template>
  129. <script lang="ts" setup>
  130. import { ref } from 'vue';
  131. import { BasicModal, useModalInner } from '/@/components/Modal';
  132. import dayjs from 'dayjs';
  133. import { printJS } from '/@/hooks/web/usePrintJS';
  134. import { queryHeatsActualsByCcmNo } from '../operator.api';
  135. // 主机号
  136. const hostNumber = ref('5');
  137. const shiftInfoTxt = ref('');
  138. // label 样式
  139. const labelStyle = {
  140. width: '60px',
  141. textAlign: 'center',
  142. padding: '0',
  143. background: '#fff',
  144. border: '1px solid #bfbfbf',
  145. };
  146. const sizeLabelStyle = {
  147. padding: '0',
  148. border: '1px solid #bfbfbf',
  149. display: 'none',
  150. };
  151. // content 样式
  152. const contentStyle = {
  153. width: '120px',
  154. textAlign: 'center',
  155. padding: '0',
  156. color: '#000',
  157. border: '1px solid #bfbfbf',
  158. position: 'relative',
  159. };
  160. const sizeContentStyle = {
  161. padding: '0',
  162. color: '#000',
  163. border: '1px solid #bfbfbf',
  164. };
  165. //表单赋值
  166. const [registerModal, { changeOkLoading }] = useModalInner(async (data) => {
  167. const { ccmNo, shiftText, queryType } = data;
  168. hostNumber.value = ccmNo;
  169. shiftInfoTxt.value = shiftText.replace('-', '/');
  170. getHeatList({
  171. ccmNo,
  172. queryType,
  173. });
  174. });
  175. // 获取当前班次所有的炉次信息
  176. const sizeArrs = ref<string[]>([]);
  177. const heatList = ref<any[]>([]);
  178. const sizeObjs = ref<any>({});
  179. const getHeatList = async (params) => {
  180. try {
  181. let sizeList: string[] = [];
  182. let sizeObj: any = {};
  183. const res = await queryHeatsActualsByCcmNo(params);
  184. if (res && Array.isArray(res)) {
  185. res.forEach((item) => {
  186. const lengthObj: Record<string, any> = JSON.parse(item.length);
  187. const sizeArr: string[] = Object.keys(lengthObj);
  188. sizeList = sizeList.concat(sizeArr);
  189. item.sizeInfo = lengthObj;
  190. sizeArr.forEach((size) => {
  191. if (!sizeObj[size]) {
  192. sizeObj[size] = {
  193. num: lengthObj[size].lengthTotalCount,
  194. weight: lengthObj[size].lengthTotalWeight,
  195. };
  196. } else {
  197. sizeObj[size].num += lengthObj[size].lengthTotalCount;
  198. sizeObj[size].weight += lengthObj[size].lengthTotalWeight;
  199. }
  200. });
  201. });
  202. sizeList = [...new Set(sizeList)];
  203. sizeArrs.value = sizeList;
  204. heatList.value = res;
  205. sizeObjs.value = sizeObj;
  206. }
  207. } catch (error) {
  208. console.log(error);
  209. }
  210. };
  211. function onPrint() {
  212. changeOkLoading(true);
  213. printJS({
  214. printable: '#printBilletSampleCard',
  215. type: 'html',
  216. });
  217. setTimeout(() => {
  218. changeOkLoading(false);
  219. }, 1000);
  220. }
  221. </script>
  222. <style scoped lang="less">
  223. .ticket {
  224. max-width: 900px;
  225. .ccmno-info {
  226. font-family: 'Kingsoft_Cloud_Font';
  227. }
  228. .ccmno {
  229. display: inline-block;
  230. width: 60px;
  231. border-bottom: 1px solid black;
  232. text-align: center;
  233. }
  234. .size-items-title {
  235. font-size: 12px;
  236. line-height: 32px;
  237. border-bottom: 1px solid #bfbfbf;
  238. padding-left: 10px;
  239. min-width: 100px;
  240. }
  241. .size-num-title {
  242. font-size: 12px;
  243. line-height: 32px;
  244. padding-left: 10px;
  245. }
  246. .size-items-content {
  247. height: 32px;
  248. text-align: center;
  249. line-height: 32px;
  250. }
  251. .size-items-remark {
  252. width: 100%;
  253. min-height: 90px;
  254. flex-wrap: wrap;
  255. font-family: 'Kingsoft_Cloud_Font';
  256. align-content: flex-start;
  257. .size-remark-item {
  258. width: 50%;
  259. height: 30px;
  260. color: #000;
  261. }
  262. .size-remark-size {
  263. display: inline-block;
  264. width: 80px;
  265. }
  266. .size-remark-num {
  267. display: inline-block;
  268. width: 80px;
  269. padding: 0 40px 0 0;
  270. font-size: 12px;
  271. }
  272. }
  273. .two-num-wrapper {
  274. position: absolute;
  275. left: 0;
  276. top: 0;
  277. width: 100%;
  278. height: 100%;
  279. z-index: 10;
  280. display: flex;
  281. flex-direction: column;
  282. justify-content: center;
  283. align-items: flex-end;
  284. padding-right: 6px;
  285. }
  286. .s-txt {
  287. font-family: 'Kingsoft_Cloud_Font';
  288. }
  289. }
  290. </style>
  291. <style lang="less">
  292. @media print {
  293. header,
  294. footer,
  295. .noprint {
  296. display: none;
  297. }
  298. @page :first {
  299. margin-top: 10px; /* 第一页的页眉距离顶部为0 */
  300. margin-bottom: 0; /* 第一页的页脚距离底部为0 */
  301. }
  302. }
  303. </style>