printBilletSampleCard.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  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="8" size="small">
  25. <a-descriptions-item label="序号" :labelStyle="labelStyle" :contentStyle="contentStyle">炉号</a-descriptions-item>
  26. <a-descriptions-item :labelStyle="sizeLabelStyle" :contentStyle="contentStyle">钢种</a-descriptions-item>
  27. <a-descriptions-item :labelStyle="sizeLabelStyle" :contentStyle="sizeContentStyle">
  28. <div class="size-items-title">
  29. 定尺&nbsp;&nbsp;&nbsp;&nbsp;
  30. <span class="s-txt">{{ sizeArrs[0] ? '170' : '' }}</span>
  31. </div>
  32. <div class="size-num-title">
  33. 支数 <span class="s-txt">{{ sizeArrs[0] ? Number(sizeArrs[0]) + 'm' : '' }}</span>
  34. </div>
  35. </a-descriptions-item>
  36. <a-descriptions-item :labelStyle="sizeLabelStyle" :contentStyle="sizeContentStyle">
  37. <div class="size-items-title">
  38. 定尺&nbsp;&nbsp;&nbsp;&nbsp;
  39. <span class="s-txt">{{ sizeArrs[1] ? '170' : '' }}</span>
  40. </div>
  41. <div class="size-num-title">
  42. 支数 <span class="s-txt">{{ sizeArrs[1] ? Number(sizeArrs[1]) + 'm' : '' }}</span>
  43. </div>
  44. </a-descriptions-item>
  45. <!-- <a-descriptions-item label="序号" :labelStyle="labelStyle" :contentStyle="contentStyle">
  46. 炉号
  47. <div class="two-num-wrapper">
  48. <span class="s-txt">{{ sizeArrs[2] ? '170' : '' }}</span>
  49. <span class="s-txt">{{ sizeArrs[2] ? Number(sizeArrs[2]) / 1000 + 'm' : '' }}</span>
  50. </div>
  51. </a-descriptions-item> -->
  52. <a-descriptions-item :labelStyle="sizeLabelStyle" :contentStyle="sizeContentStyle">
  53. <div class="size-items-title">
  54. 定尺&nbsp;&nbsp;&nbsp;&nbsp;
  55. <span class="s-txt">{{ sizeArrs[2] ? '170' : '' }}</span>
  56. </div>
  57. <div class="size-num-title">
  58. 支数 <span class="s-txt">{{ sizeArrs[2] ? Number(sizeArrs[2]) + 'm' : '' }}</span>
  59. </div>
  60. </a-descriptions-item>
  61. <a-descriptions-item :labelStyle="sizeLabelStyle" :contentStyle="sizeContentStyle">
  62. <div class="size-items-title">
  63. 定尺&nbsp;&nbsp;&nbsp;&nbsp;
  64. <span class="s-txt">{{ sizeArrs[3] ? '170' : '' }}</span>
  65. </div>
  66. <div class="size-num-title">
  67. 支数 <span class="s-txt">{{ sizeArrs[3] ? Number(sizeArrs[3]) + 'm' : '' }}</span>
  68. </div>
  69. </a-descriptions-item>
  70. <a-descriptions-item :labelStyle="sizeLabelStyle" :contentStyle="sizeContentStyle">
  71. <div class="size-items-title">
  72. 定尺&nbsp;&nbsp;&nbsp;&nbsp;
  73. <span class="s-txt">
  74. {{ sizeArrs[4] ? '170' : '' }}
  75. </span>
  76. </div>
  77. <div class="size-num-title">
  78. 支数 <span class="s-txt">{{ sizeArrs[4] ? Number(sizeArrs[4]) + 'm' : '' }}</span>
  79. </div>
  80. </a-descriptions-item>
  81. <a-descriptions-item :labelStyle="sizeLabelStyle" :contentStyle="sizeContentStyle">
  82. <div class="size-items-title">
  83. 定尺&nbsp;&nbsp;&nbsp;&nbsp;
  84. <span class="s-txt">
  85. {{ sizeArrs[5] ? '170' : '' }}
  86. </span>
  87. </div>
  88. <div class="size-num-title">
  89. 支数 <span class="s-txt">{{ sizeArrs[5] ? Number(sizeArrs[5]) + 'm' : '' }}</span>
  90. </div>
  91. </a-descriptions-item>
  92. <!-- <a-descriptions-item :labelStyle="sizeLabelStyle" :contentStyle="sizeContentStyle">
  93. <div class="size-items-title"> </div>
  94. <div class="size-num-title"> </div>
  95. </a-descriptions-item> -->
  96. <template v-for="i in 22">
  97. <!-- 第一组 -->
  98. <a-descriptions-item :label="i" :labelStyle="labelStyle" :contentStyle="contentStyle">
  99. <div style="width: 70px">
  100. {{ heatList[i - 1] ? heatList[i - 1].heatNo : '' }}
  101. </div>
  102. </a-descriptions-item>
  103. <a-descriptions-item :labelStyle="sizeLabelStyle" :contentStyle="sizeContentStyle">
  104. <div style="width: 70px; text-align: center">
  105. {{ heatList[i - 1] ? heatList[i - 1].brandNum : '' }}
  106. </div>
  107. </a-descriptions-item>
  108. <a-descriptions-item :labelStyle="sizeLabelStyle" :contentStyle="sizeContentStyle">
  109. <div class="size-items-content">{{
  110. heatList[i - 1] && heatList[i - 1].sizeInfo && heatList[i - 1].sizeInfo[sizeArrs[0]] ? heatList[i - 1].sizeInfo[sizeArrs[0]] : ''
  111. }}</div>
  112. </a-descriptions-item>
  113. <a-descriptions-item :labelStyle="sizeLabelStyle" :contentStyle="sizeContentStyle">
  114. <div class="size-items-content">{{
  115. heatList[i - 1] && heatList[i - 1].sizeInfo && heatList[i - 1].sizeInfo[sizeArrs[1]] ? heatList[i - 1].sizeInfo[sizeArrs[1]] : ''
  116. }}</div>
  117. </a-descriptions-item>
  118. <!-- 第二组 -->
  119. <a-descriptions-item :labelStyle="sizeLabelStyle" :contentStyle="sizeContentStyle">
  120. <div class="size-items-content">
  121. {{
  122. heatList[i - 1] && heatList[i - 1].sizeInfo && heatList[i - 1].sizeInfo[sizeArrs[2]] ? heatList[i - 1].sizeInfo[sizeArrs[2]] : ''
  123. }}
  124. </div>
  125. </a-descriptions-item>
  126. <a-descriptions-item :labelStyle="sizeLabelStyle" :contentStyle="sizeContentStyle">
  127. <div class="size-items-content">{{
  128. heatList[i - 1] && heatList[i - 1].sizeInfo && heatList[i - 1].sizeInfo[sizeArrs[3]] ? heatList[i - 1].sizeInfo[sizeArrs[3]] : ''
  129. }}</div>
  130. </a-descriptions-item>
  131. <a-descriptions-item :labelStyle="sizeLabelStyle" :contentStyle="sizeContentStyle">
  132. <div class="size-items-content">{{
  133. heatList[i - 1] && heatList[i - 1].sizeInfo && heatList[i - 1].sizeInfo[sizeArrs[4]] ? heatList[i - 1].sizeInfo[sizeArrs[4]] : ''
  134. }}</div>
  135. </a-descriptions-item>
  136. <a-descriptions-item :labelStyle="sizeLabelStyle" :contentStyle="sizeContentStyle">
  137. <div class="size-items-content">{{
  138. heatList[i - 1] && heatList[i - 1].sizeInfo && heatList[i - 1].sizeInfo[sizeArrs[4]] ? heatList[i - 1].sizeInfo[sizeArrs[5]] : ''
  139. }}</div>
  140. </a-descriptions-item>
  141. <!-- <a-descriptions-item :labelStyle="sizeLabelStyle" :contentStyle="sizeContentStyle">
  142. <div class="size-items-content"></div>
  143. </a-descriptions-item> -->
  144. </template>
  145. </a-descriptions>
  146. <a-descriptions style="padding: 0" size="small" :column="7">
  147. <a-descriptions-item label="备注" :span="1">
  148. <div class="size-items-remark flex">
  149. <!-- <div class="size-remark-item" v-for="(ele, size) in sizeObjs">
  150. <span class="size-remark-size">{{ Number(size) / 1000 }} m:</span>
  151. <span class="size-remark-num">{{ ele.num }}</span>
  152. <span>{{ ele.weight.toFixed(3) }}t</span>
  153. </div> -->
  154. </div>
  155. </a-descriptions-item>
  156. </a-descriptions>
  157. </div>
  158. </section>
  159. <template #appendFooter>
  160. <a-button @click="openJSModal = true"> 重量计算 </a-button>
  161. </template>
  162. </BasicModal>
  163. <a-modal
  164. v-model:open="openJSModal"
  165. title="重量计算"
  166. centered
  167. width="600px"
  168. :zIndex="9999"
  169. @ok="
  170. () => {
  171. openJSModal = false;
  172. }
  173. "
  174. @cancel="
  175. () => {
  176. openJSModal = false;
  177. }
  178. "
  179. >
  180. <div class="flex justify-center items-center" style="margin: 20px; line-height: 40px">
  181. <a-input-group size="large">
  182. <a-row :gutter="8">
  183. <a-col :span="5">
  184. <a-input type="number" :min="1" v-model:value="weightNum" placeholder="支数" />
  185. </a-col>
  186. <a-col :span="1" style="line-height: 40px; text-align: center">*</a-col>
  187. <a-col :span="5">
  188. <a-input type="number" v-model:value="sizeNum" placeholder="定尺" />
  189. </a-col>
  190. <a-col :span="1" style="line-height: 40px; text-align: center">*</a-col>
  191. <a-col :span="5">
  192. <a-input type="number" v-model:value="xiShu" placeholder="请输入比例" />
  193. </a-col>
  194. <a-col :span="1" style="line-height: 40px; text-align: center">=</a-col>
  195. <a-col :span="6" style="line-height: 40px; text-align: center">{{ weightCalc }}</a-col>
  196. </a-row>
  197. </a-input-group>
  198. </div>
  199. </a-modal>
  200. </template>
  201. <script lang="ts" setup>
  202. import { ref, computed } from 'vue';
  203. import { BasicModal, useModalInner } from '/@/components/Modal';
  204. import dayjs from 'dayjs';
  205. import { printJS } from '/@/hooks/web/usePrintJS';
  206. import { querySampleCard } from '../operator.api';
  207. import { isNumber } from '/@/utils/is';
  208. // 主机号
  209. const hostNumber = ref('5');
  210. const shiftInfoTxt = ref('');
  211. const shiftInfo = ref({ shift: '', shiftGroup: '' });
  212. // label 样式
  213. const labelStyle = {
  214. width: '60px',
  215. textAlign: 'center',
  216. padding: '0',
  217. background: '#fff',
  218. border: '1px solid #bfbfbf',
  219. };
  220. const sizeLabelStyle = {
  221. padding: '0',
  222. border: '1px solid #bfbfbf',
  223. display: 'none',
  224. };
  225. // content 样式
  226. const contentStyle = {
  227. width: '90px',
  228. textAlign: 'center',
  229. padding: '0',
  230. color: '#000',
  231. border: '1px solid #bfbfbf',
  232. position: 'relative',
  233. };
  234. const sizeContentStyle = {
  235. padding: '0',
  236. color: '#000',
  237. border: '1px solid #bfbfbf',
  238. };
  239. //表单赋值
  240. const [registerModal, { changeOkLoading }] = useModalInner(async (data) => {
  241. const { ccmNo, shiftText, queryType, curShiftInfo, changeShiftId } = data;
  242. hostNumber.value = ccmNo;
  243. shiftInfoTxt.value = shiftText.replace('-', '/');
  244. shiftInfo.value = curShiftInfo;
  245. getHeatList({
  246. ccmNo,
  247. queryType,
  248. changeShiftId,
  249. });
  250. });
  251. // 获取当前班次所有的炉次信息
  252. const sizeArrs = ref<string[]>([]);
  253. const heatList = ref<any[]>([]);
  254. const sizeObjs = ref<any>({});
  255. const getHeatList = async (params) => {
  256. try {
  257. let sizeList: string[] = [];
  258. let sizeObj: any = {};
  259. const res = await querySampleCard(params);
  260. let newArr: any[] = [];
  261. if (res && Array.isArray(res)) {
  262. const ln = res.length;
  263. for (let i = 0; i < ln; i++) {
  264. const item = res[i];
  265. const lengthObj: Record<string, any> = item.lengthCountMap;
  266. const sizeArr: string[] = Object.keys(lengthObj);
  267. sizeList = sizeList.concat(sizeArr);
  268. item.sizeInfo = lengthObj;
  269. sizeArr.forEach((size) => {
  270. if (!sizeObj[size]) {
  271. sizeObj[size] = {
  272. num: lengthObj[size],
  273. // weight: lengthObj[size].lengthTotalWeight,
  274. };
  275. } else {
  276. sizeObj[size].num += lengthObj[size];
  277. // sizeObj[size].weight += lengthObj[size].lengthTotalWeight;
  278. }
  279. });
  280. newArr.push(item);
  281. }
  282. // res.forEach((item) => {
  283. // });
  284. sizeList = [...new Set(sizeList)];
  285. sizeArrs.value = sizeList;
  286. heatList.value = newArr;
  287. sizeObjs.value = sizeObj;
  288. }
  289. } catch (error) {
  290. console.log(error);
  291. }
  292. };
  293. const openJSModal = ref(false);
  294. const xiShu = ref(0.2265);
  295. const sizeNum = ref();
  296. const weightNum = ref();
  297. // 重量计算按钮
  298. const weightCalc = computed(() => {
  299. const w = Number(weightNum.value);
  300. const x = Number(xiShu.value);
  301. const s = Number(sizeNum.value);
  302. if (isNumber(w) && isNumber(x) && isNumber(s)) {
  303. const r = w * x * s;
  304. return !isNaN(r) ? r.toFixed(6) : '';
  305. }
  306. return '';
  307. });
  308. function onPrint() {
  309. changeOkLoading(true);
  310. printJS({
  311. printable: '#printBilletSampleCard',
  312. type: 'html',
  313. });
  314. setTimeout(() => {
  315. changeOkLoading(false);
  316. }, 1000);
  317. }
  318. </script>
  319. <style scoped lang="less">
  320. .ticket {
  321. max-width: 900px;
  322. .ccmno-info {
  323. font-family: 'Kingsoft_Cloud_Font';
  324. }
  325. .ccmno {
  326. display: inline-block;
  327. width: 60px;
  328. border-bottom: 1px solid black;
  329. text-align: center;
  330. }
  331. .size-items-title {
  332. font-size: 12px;
  333. line-height: 32px;
  334. border-bottom: 1px solid #bfbfbf;
  335. padding-left: 10px;
  336. min-width: 77px;
  337. }
  338. .size-num-title {
  339. font-size: 12px;
  340. line-height: 32px;
  341. padding-left: 4px;
  342. }
  343. .size-items-content {
  344. height: 32px;
  345. text-align: center;
  346. line-height: 32px;
  347. }
  348. .size-items-remark {
  349. width: 100%;
  350. min-height: 90px;
  351. flex-wrap: wrap;
  352. font-family: 'Kingsoft_Cloud_Font';
  353. align-content: flex-start;
  354. .size-remark-item {
  355. width: 50%;
  356. height: 30px;
  357. color: #000;
  358. }
  359. .size-remark-size {
  360. display: inline-block;
  361. width: 80px;
  362. }
  363. .size-remark-num {
  364. display: inline-block;
  365. width: 80px;
  366. padding: 0 40px 0 0;
  367. font-size: 12px;
  368. }
  369. }
  370. .two-num-wrapper {
  371. position: absolute;
  372. left: 0;
  373. top: 0;
  374. width: 100%;
  375. height: 100%;
  376. z-index: 10;
  377. display: flex;
  378. flex-direction: column;
  379. justify-content: center;
  380. align-items: flex-end;
  381. padding-right: 6px;
  382. }
  383. .s-txt {
  384. font-family: 'Kingsoft_Cloud_Font';
  385. }
  386. }
  387. </style>
  388. <style lang="less">
  389. @media print {
  390. header,
  391. footer,
  392. .noprint {
  393. display: none;
  394. }
  395. @page {
  396. margin-top: 10px; /* 第一页的页眉距离顶部为0 */
  397. margin-bottom: 0; /* 第一页的页脚距离底部为0 */
  398. }
  399. }
  400. </style>