printYgjjmx.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. <template>
  2. <div style="width: 30vw; height: 50vh">
  3. <el-form inline @submit.prevent>
  4. <el-form-item label="日期选择">
  5. <div class="block">
  6. <el-date-picker
  7. v-model="date"
  8. type="daterange"
  9. range-separator="到"
  10. start-placeholder="起始日期"
  11. end-placeholder="结束日期"
  12. value-format="YYYY.MM.DD"
  13. style="width: 250px"
  14. />
  15. </div>
  16. </el-form-item>
  17. <el-form-item label="员工编号">
  18. <el-input
  19. v-model="input"
  20. autocomplete="off"
  21. style="width: 110px"
  22. @keyup.enter="handleEnter"
  23. />
  24. </el-form-item>
  25. <el-form-item label="">
  26. <el-input
  27. v-model="ygxm"
  28. autocomplete="off"
  29. style="width: 128px"
  30. readonly
  31. />
  32. </el-form-item>
  33. <br />
  34. <el-form-item label="">
  35. <el-button @click="handlePrint"> 打印 </el-button>
  36. </el-form-item>
  37. </el-form>
  38. </div>
  39. </template>
  40. <script>
  41. export default {
  42. name: "Ygjjmx",
  43. };
  44. // 2工单超节损统计(按工序)
  45. import service from "@/utils/request";
  46. //获取员工姓名
  47. const reportName = (params) => {
  48. return service({
  49. url: "/mes_server/reporting_work/getStaffName",
  50. method: "get",
  51. params,
  52. });
  53. };
  54. //员工计件明细
  55. const getPieceDetail = (params) => {
  56. return service({
  57. url: "/mes_server/employee_daily_salary/getPieceDetail",
  58. method: "get",
  59. params,
  60. });
  61. };
  62. </script>
  63. <script setup>
  64. import { ref, defineProps } from "vue";
  65. import { hiprint } from "vue-plugin-hiprint";
  66. import { ElMessage, dayjs } from "element-plus";
  67. // const props = defineProps(['gdbh'])
  68. const props = defineProps({
  69. ygbh: {
  70. type: String,
  71. default: "",
  72. },
  73. });
  74. const input = ref(props["ygbh"]);
  75. const ygxm = ref("");
  76. const date = ref([
  77. dayjs().startOf("month").format("YYYY.MM.DD"),
  78. dayjs().format("YYYY.MM.DD"),
  79. ]);
  80. const handlePrint = async () => {
  81. // 引入后初始化
  82. hiprint.init();
  83. const template = {
  84. panels: [
  85. {
  86. index: 0,
  87. name: 1,
  88. paperType: "A4",
  89. height: 210,
  90. width: 297,
  91. paperHeader: 78,
  92. paperFooter: 577.5,
  93. printElements: [
  94. {
  95. options: {
  96. left: 320,
  97. top: 20,
  98. height: 18,
  99. width: 130,
  100. title: "员工计件明细记录",
  101. coordinateSync: false,
  102. widthHeightSync: false,
  103. fontSize: 15,
  104. textAlign: "center",
  105. textContentVerticalAlign: "middle",
  106. qrCodeLevel: 0,
  107. draggable: false,
  108. },
  109. printElementType: {
  110. title: "文本",
  111. type: "text",
  112. },
  113. },
  114. {
  115. options: {
  116. left: 320,
  117. top: 45,
  118. height: 12,
  119. width: 130,
  120. title: "文本",
  121. right: 451.83339436848956,
  122. bottom: 57.08334859212239,
  123. vCenter: 391.83339436848956,
  124. hCenter: 52.20834859212239,
  125. field: "rqfw",
  126. coordinateSync: false,
  127. widthHeightSync: false,
  128. hideTitle: true,
  129. textAlign: "center",
  130. textContentVerticalAlign: "middle",
  131. qrCodeLevel: 0,
  132. draggable: false,
  133. },
  134. printElementType: {
  135. title: "文本",
  136. type: "text",
  137. },
  138. },
  139. {
  140. options: {
  141. left: 30,
  142. top: 65,
  143. height: 12,
  144. width: 130,
  145. right: 451.83339436848956,
  146. bottom: 57.08334859212239,
  147. vCenter: 391.83339436848956,
  148. hCenter: 52.20834859212239,
  149. field: "ygzl",
  150. coordinateSync: false,
  151. widthHeightSync: false,
  152. hideTitle: true,
  153. textContentVerticalAlign: "middle",
  154. qrCodeLevel: 0,
  155. draggable: false,
  156. fontSize: 9.75,
  157. color: "#0000ff",
  158. },
  159. printElementType: {
  160. title: "文本",
  161. type: "text",
  162. },
  163. },
  164. {
  165. options: {
  166. left: 600,
  167. top: 66,
  168. height: 12,
  169. width: 140,
  170. title: "文本",
  171. right: 756.5624885559082,
  172. bottom: 76.50000286102295,
  173. vCenter: 691.3124885559082,
  174. hCenter: 70.50000286102295,
  175. coordinateSync: false,
  176. widthHeightSync: false,
  177. textAlign: "right",
  178. textContentVerticalAlign: "middle",
  179. qrCodeLevel: 0,
  180. draggable: false,
  181. field: "dysj",
  182. hideTitle: true,
  183. },
  184. printElementType: {
  185. title: "文本",
  186. type: "text",
  187. },
  188. },
  189. {
  190. options: {
  191. left: 20,
  192. top: 80,
  193. height: 470,
  194. width: 795,
  195. field: "table",
  196. coordinateSync: false,
  197. widthHeightSync: false,
  198. fontSize: 7.5,
  199. lineHeight: 12,
  200. tableHeaderRowHeight: 30,
  201. tableHeaderBackground: "#ffffff",
  202. tableHeaderFontSize: 9,
  203. tableBodyRowHeight: 25,
  204. columns: [
  205. [
  206. {
  207. width: 50,
  208. title: "日期",
  209. titleSync: false,
  210. field: "rq",
  211. checked: true,
  212. columnId: "rq",
  213. fixed: false,
  214. rowspan: 1,
  215. colspan: 1,
  216. align: "center",
  217. tableQRCodeLevel: 0,
  218. tableSummaryTitle: true,
  219. tableSummary: "",
  220. },
  221. {
  222. width: 40,
  223. title: "工单编号",
  224. titleSync: false,
  225. field: "gdbh",
  226. checked: true,
  227. columnId: "gdbh",
  228. fixed: false,
  229. rowspan: 1,
  230. colspan: 1,
  231. align: "center",
  232. tableQRCodeLevel: 0,
  233. tableSummaryTitle: true,
  234. tableSummary: "",
  235. },
  236. {
  237. width: 135,
  238. title: "工序名称",
  239. titleSync: false,
  240. field: "gxmc",
  241. checked: true,
  242. columnId: "gxmc",
  243. fixed: false,
  244. rowspan: 1,
  245. colspan: 1,
  246. tableQRCodeLevel: 0,
  247. tableSummaryTitle: true,
  248. tableSummary: "",
  249. },
  250. {
  251. width: 40,
  252. title: "机台",
  253. titleSync: false,
  254. field: "jt",
  255. checked: true,
  256. columnId: "jt",
  257. fixed: false,
  258. rowspan: 1,
  259. colspan: 1,
  260. tableQRCodeLevel: 0,
  261. tableSummaryTitle: true,
  262. tableSummary: "",
  263. },
  264. {
  265. width: 50,
  266. title: "班组产量",
  267. titleSync: false,
  268. field: "bzcl",
  269. checked: true,
  270. columnId: "bzcl",
  271. fixed: false,
  272. rowspan: 1,
  273. colspan: 1,
  274. align: "right",
  275. halign: "center",
  276. tableQRCodeLevel: 0,
  277. tableSummaryTitle: true,
  278. tableSummary: "",
  279. },
  280. {
  281. width: 30,
  282. title: "保养工时",
  283. titleSync: false,
  284. field: "bygs",
  285. checked: true,
  286. columnId: "bygs",
  287. fixed: false,
  288. rowspan: 1,
  289. colspan: 1,
  290. align: "right",
  291. halign: "center",
  292. tableQRCodeLevel: 0,
  293. tableSummaryTitle: true,
  294. tableSummary: "",
  295. },
  296. {
  297. width: 30,
  298. title: "装版工时",
  299. titleSync: false,
  300. field: "zbgs",
  301. checked: true,
  302. columnId: "zbgs",
  303. fixed: false,
  304. rowspan: 1,
  305. colspan: 1,
  306. align: "right",
  307. halign: "center",
  308. tableQRCodeLevel: 0,
  309. tableSummaryTitle: true,
  310. tableSummary: "",
  311. },
  312. {
  313. width: 30,
  314. title: "打样工时",
  315. titleSync: false,
  316. field: "dygs",
  317. checked: true,
  318. columnId: "dygs",
  319. fixed: false,
  320. rowspan: 1,
  321. colspan: 1,
  322. align: "right",
  323. halign: "center",
  324. tableQRCodeLevel: 0,
  325. tableSummaryTitle: true,
  326. tableSummary: "",
  327. },
  328. {
  329. width: 30,
  330. title: "异常停机",
  331. titleSync: false,
  332. field: "yctj",
  333. checked: true,
  334. columnId: "yctj",
  335. fixed: false,
  336. rowspan: 1,
  337. colspan: 1,
  338. align: "right",
  339. halign: "center",
  340. tableQRCodeLevel: 0,
  341. tableSummaryTitle: true,
  342. tableSummary: "",
  343. },
  344. {
  345. width: 45,
  346. title: "补产标准",
  347. titleSync: false,
  348. field: "bcbz",
  349. checked: true,
  350. columnId: "bcbz",
  351. fixed: false,
  352. rowspan: 1,
  353. colspan: 1,
  354. align: "right",
  355. halign: "center",
  356. tableQRCodeLevel: 0,
  357. tableSummaryTitle: true,
  358. tableSummary: "",
  359. },
  360. {
  361. width: 45,
  362. title: "班组补产",
  363. titleSync: false,
  364. field: "bzbc",
  365. checked: true,
  366. columnId: "bzbc",
  367. fixed: false,
  368. rowspan: 1,
  369. colspan: 1,
  370. align: "right",
  371. halign: "center",
  372. tableQRCodeLevel: 0,
  373. tableSummaryTitle: true,
  374. tableSummary: "",
  375. },
  376. {
  377. width: 45,
  378. title: "日定额",
  379. titleSync: false,
  380. field: "rde",
  381. checked: true,
  382. columnId: "rde",
  383. fixed: false,
  384. rowspan: 1,
  385. colspan: 1,
  386. align: "right",
  387. halign: "center",
  388. tableQRCodeLevel: 0,
  389. tableSummaryTitle: true,
  390. tableSummary: "",
  391. },
  392. {
  393. width: 45,
  394. title: "达标定额",
  395. titleSync: false,
  396. field: "dbde",
  397. checked: true,
  398. columnId: "dbde",
  399. fixed: false,
  400. rowspan: 1,
  401. colspan: 1,
  402. align: "right",
  403. halign: "center",
  404. tableQRCodeLevel: 0,
  405. tableSummaryTitle: true,
  406. tableSummary: "",
  407. },
  408. {
  409. width: 45,
  410. title: "千件工价",
  411. titleSync: false,
  412. field: "qjgj",
  413. checked: true,
  414. columnId: "qjgj",
  415. fixed: false,
  416. rowspan: 1,
  417. colspan: 1,
  418. align: "right",
  419. halign: "center",
  420. tableQRCodeLevel: 0,
  421. tableSummaryTitle: true,
  422. tableSummary: "",
  423. },
  424. {
  425. width: 45,
  426. title: "个人计件工资",
  427. titleSync: false,
  428. field: "grjjgz",
  429. checked: true,
  430. columnId: "grjjgz",
  431. fixed: false,
  432. rowspan: 1,
  433. colspan: 1,
  434. align: "right",
  435. halign: "center",
  436. tableQRCodeLevel: 0,
  437. tableSummaryTitle: true,
  438. tableSummary: "",
  439. },
  440. {
  441. width: 45,
  442. title: "个人加班工资",
  443. titleSync: false,
  444. field: "grjbgz",
  445. checked: true,
  446. columnId: "grjbgz",
  447. fixed: false,
  448. rowspan: 1,
  449. colspan: 1,
  450. align: "right",
  451. halign: "center",
  452. tableQRCodeLevel: 0,
  453. tableSummaryTitle: true,
  454. tableSummary: "",
  455. },
  456. {
  457. width: 45,
  458. title: "比例",
  459. titleSync: false,
  460. field: "bl",
  461. checked: true,
  462. columnId: "bl",
  463. fixed: false,
  464. rowspan: 1,
  465. colspan: 1,
  466. align: "right",
  467. halign: "center",
  468. tableQRCodeLevel: 0,
  469. tableSummaryTitle: true,
  470. tableSummary: "",
  471. },
  472. ],
  473. ],
  474. },
  475. printElementType: {
  476. title: "表格",
  477. type: "table",
  478. editable: true,
  479. columnDisplayEditable: true,
  480. columnDisplayIndexEditable: true,
  481. columnTitleEditable: true,
  482. columnResizable: true,
  483. columnAlignEditable: true,
  484. isEnableEditField: true,
  485. isEnableContextMenu: true,
  486. isEnableInsertRow: true,
  487. isEnableDeleteRow: true,
  488. isEnableInsertColumn: true,
  489. isEnableDeleteColumn: true,
  490. isEnableMergeCell: true,
  491. },
  492. },
  493. ],
  494. paperNumberLeft: 736.5,
  495. paperNumberTop: 66,
  496. paperNumberContinue: true,
  497. paperNumberFormat: "(第paperNo页 共paperCount页)",
  498. backgroundColor: "#ffffff",
  499. overPrintOptions: {
  500. content: "",
  501. opacity: 0.7,
  502. type: 1,
  503. },
  504. watermarkOptions: {
  505. content: "",
  506. fillStyle: "rgba(87, 13, 248, 0.5)",
  507. fontSize: "36px",
  508. rotate: 25,
  509. width: 413,
  510. height: 310,
  511. timestamp: true,
  512. format: "YYYY-MM-DD HH:mm",
  513. },
  514. },
  515. ],
  516. };
  517. const hiprintTemplate = new hiprint.PrintTemplate({ template });
  518. const params = {
  519. start_time: date.value[0],
  520. end_time: date.value[1],
  521. code: input.value,
  522. };
  523. console.log(params);
  524. const res = await getPieceDetail(params);
  525. if (res?.["code"] === 0) {
  526. const { data } = res;
  527. if (!data) {
  528. ElMessage({
  529. type: "info",
  530. message: res["msg"],
  531. });
  532. return;
  533. }
  534. let preRq = "";
  535. const getRq = (val) => {
  536. const result = val === preRq ? "" : val;
  537. preRq = val;
  538. return result;
  539. };
  540. const tableData = {
  541. rqfw: `(${params["start_time"]} - ${params["end_time"]})`,
  542. ygzl: `员工资料:${data?.[0]?.["员工资料"]}`,
  543. dysj: `打印时间:${dayjs().format("YYYY.MM.DD HH:mm:ss")}`,
  544. table: data?.map((item, index) => ({
  545. rq: getRq(item["sczl_rq"]),
  546. gdbh: item["sczl_gdbh"],
  547. gxmc: item["sczl_type"].substring(0, 20),
  548. jt: item["sczl_jtbh"],
  549. bzcl: item["班组车头产量"],
  550. bygs: item["保养工时"],
  551. zbgs: item["装版工时"],
  552. dygs: item["打样工时"],
  553. yctj: item["异常停机工时"],
  554. bcbz: item["补产标准"],
  555. bzbc: item["班组补产"],
  556. rde: item["日定额"],
  557. dbde: item["达标定额"],
  558. qjgj: item["千件工价"],
  559. grjjgz: item["个人计件工资"],
  560. grjbgz: item["个人加班工资"],
  561. bl: item["个人比例"],
  562. })),
  563. };
  564. hiprintTemplate.print(tableData);
  565. }
  566. };
  567. async function handleEnter(params) {
  568. const res = await reportName({ code: input.value });
  569. if (res?.["code"] === 0) {
  570. ygxm.value = res?.["data"];
  571. }
  572. }
  573. </script>
  574. <style scoped></style>