printYgjjmx.vue 17 KB

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