1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
| <template>
| <div class="header_nox">
| <el-button type="warning" circle @click="exportWord">下载</el-button>
| <el-button type="primary" circle v-show="!editable" @click="editable = !editable">编辑</el-button>
| <el-button type="primary" v-show="editable" @click="saveData">确定</el-button>
| </div>
| <div id="printContent" ref="imageWrapper">
| <h3>集罐机工序生产质量记录</h3>
| <div class="title_form">
| <div class="title_form_input">
| <span>生产线:</span>
| <span>{{ headData.head.shengcx }}</span>
| </div>
| <div class="title_form_input">
| <span>产品:</span>
| <span>{{ headData.head.chanpin }}</span>
| </div>
| <div class="title_form_input">
| <span>日期:</span>
| <span>{{ headData.head.reportTime }}</span>
| </div>
| <div class="title_form_input">
| <span>班次:</span>
| <span>{{ headData.head.banci }}</span>
| </div>
|
| <!-- <div class="title_form_input">
| <span>生产线:</span>
| <span>四线</span>
| </div> -->
| </div>
| <el-divider />
|
| <HJTABLE
| :SClist="rdList"
| :tableHeader="rdHeader"
| :labelName="labelName.b1"
| :editable="editable"
| ></HJTABLE>
| <HJTABLE
| :SClist="SClist"
| :tableHeader="tableHeader"
| :editable="editable"
| ></HJTABLE>
| <HJTABLE
| :SClist="ytfpData"
| :tableHeader="ytfpHeader"
| :labelName="labelName.b2"
| :editable="editable"
| ></HJTABLE>
| <HJTABLE
| :SClist="hjfpData"
| :tableHeader="hjfpHeader"
| :labelName="labelName.b2"
| :editable="editable"
| ></HJTABLE>
| <HJTABLE
| :SClist="zlList"
| :tableHeader="zlHeader"
| :labelName="labelName.b3"
| :editable="editable"
| ></HJTABLE>
| <HJTABLE
| :SClist="flList"
| :tableHeader="flHeader"
| :labelName="labelName.b4"
| :editable="editable"
| ></HJTABLE>
| </div>
| </template>
|
| <script>
| const item = {
| name: "",
| birth: "",
| province: "",
| city: "",
| address: "",
| phone: "",
| };
| const header = {
| prop: "key",
| label: "自定义",
| editable: false,
| type: "input",
| };
| import { ref, reactive, onMounted } from "vue";
| import { ElMessage } from "element-plus";
| import { jiguanVoLast, save } from "@/api/JiGuan";
| import html2canvas from "html2canvas";
| import docxtemplater from "docxtemplater";
| import PizZip from "pizzip";
| import JSZipUtils from "jszip-utils";
| import { saveAs } from "file-saver";
| import HJTABLE from "@/components/arj/arj-table";
| import { useRouter } from "vue-router";
| import { headReport } from "@/api/head";
| export default {
| name: "",
| components: { HJTABLE },
| props: {},
| setup(props) {
| const router = useRouter();
| const flHeader = reactive([
| {
| prop: "name",
| label: "名称",
| editable: false,
| type: "text",
| },
| {
| prop: "num",
| label: "数量",
| editable: false,
| type: "input",
| },
| {
| prop: "fuliaoGood",
| label: "合格",
| editable: false,
| type: "input",
| },
| {
| prop: "fuliaoBad",
| label: "不合格",
| editable: false,
| type: "text",
| },
| {
| prop: "fuliaoSm",
| label: "不合格说明",
| editable: false,
| type: "input",
| },
| ]);
| const zlHeader = reactive([
| {
| prop: "rdTime1",
| label: "时间",
| editable: false,
| type: "text",
| },
| {
| prop: "waiguanRy",
| label: "外观人员",
| editable: false,
| type: "input",
| },
| {
| prop: "guanneiJyy",
| label: "罐内检验员",
| editable: false,
| type: "input",
| },
| {
| prop: "jiguanRy",
| label: "集罐人员",
| editable: false,
| type: "text",
| },
| {
| prop: "choujianJg",
| label: "抽检结果",
| editable: false,
| type: "input",
| },
| {
| prop: "choujianJgzt",
| label: "抽检状态",
| editable: false,
| type: "input",
| },
| {
| prop: "wenti",
| label: "主要质量问题",
| editable: false,
| type: "input",
| },
| ]);
| const ytfpHeader = reactive([
| {
| prop: "total",
| label: "印铁废品(总计)",
| editable: false,
| type: "text",
| },
| {
| prop: "chongyingNum",
| label: "重印",
| editable: false,
| type: "input",
| },
| {
| prop: "zazhidianNum",
| label: "杂质点",
| editable: false,
| type: "input",
| },
| {
| prop: "neiyinseNum",
| label: "内印色",
| editable: false,
| type: "input",
| },
| {
| prop: "moranNum",
| label: "墨染",
| editable: false,
| type: "input",
| },
| {
| prop: "sechaNum",
| label: "色差",
| editable: false,
| type: "input",
| },
| {
| prop: "neiwaitucashangNum",
| label: "内外涂擦伤",
| editable: false,
| type: "input",
| },
|
| {
| prop: "neiwaituYwNum",
| label: "内外涂油污",
| editable: false,
| type: "input",
| },
| {
| prop: "louyinNum",
| label: "漏印",
| editable: false,
| type: "input",
| },
| {
| prop: "gaiyahenNum",
| label: "盖压痕",
| editable: false,
| type: "input",
| },
| {
| prop: "gaijianjiaoNum",
| label: "盖溅痕",
| editable: false,
| type: "input",
| },
|
| {
| prop: "zanggaiNum",
| label: "脏盖",
| editable: false,
| type: "input",
| },
| {
| prop: "sutiehexianNum",
| label: "素铁黑线",
| editable: false,
| type: "input",
| },
| ]);
|
| const hjfpHeader = reactive([
| {
| prop: "total",
| label: "生产废品(总计)",
| editable: false,
| type: "text",
| },
| {
| prop: "jianxieNum",
| label: "剪斜",
| editable: false,
| type: "input",
| },
| {
| prop: "hanjiebuliangNum",
| label: "焊接不良",
| editable: false,
| type: "input",
| },
| {
| prop: "waitubuliangNum",
| label: "外涂不良",
| editable: false,
| type: "input",
| },
| {
| prop: "gunjinBlNum",
| label: "滚筋不良",
| editable: false,
| type: "input",
| },
|
| {
| prop: "fengkouBlNum",
| label: "封口不良",
| editable: false,
| type: "input",
| },
| {
| prop: "bieguanNum",
| label: "瘪罐",
| editable: false,
| type: "input",
| },
| {
| prop: "youguanNum",
| label: "油罐",
| editable: false,
| type: "input",
| },
| {
| prop: "zangguanNum",
| label: "脏罐",
| editable: false,
| type: "input",
| },
| {
| prop: "shiyanFpNum",
| label: "实验废品",
| editable: false,
| type: "input",
| },
| {
| prop: "huashangNum",
| label: "划伤",
| editable: false,
| type: "input",
| },
| {
| prop: "hongkaoBsNum",
| label: "烘烤变色",
| editable: false,
| type: "input",
| },
| {
| prop: "suojinBlNum",
| label: "缩筋不良",
| editable: false,
| type: "input",
| },
| ]);
| const tableHeader = reactive([
| {
| prop: "shengchanTime1",
| label: "生产时间",
| editable: false,
| type: "text",
| },
| {
| prop: "fuliaoCjTime",
| label: "辅料厂家/日期",
| editable: false,
| type: "input",
| },
| {
| prop: "shengchanPh",
| label: "生产批号/包号",
| editable: false,
| type: "input",
| },
| {
| prop: "num",
| label: "数量",
| editable: false,
| type: "text",
| },
| {
| prop: "chanpinBh",
| label: "生产产品板号",
| editable: false,
| type: "input",
| },
| {
| prop: "shengchanBs",
| label: "生产包数",
| editable: false,
| type: "input",
| },
| ]);
| const rdHeader = reactive([
| {
| prop: "jiaobanFs",
| label: "包装方式",
| editable: false,
| type: "text",
| },
| {
| prop: "jiebanSy",
| label: "接班剩余",
| editable: false,
| type: "input",
| },
| {
| prop: "jiaobanSy",
| label: "交班剩余",
| editable: false,
| type: "input",
| },
| ]);
| let tableData = reactive([]);
| const formInline = reactive({
| user: "",
| region: "",
| });
| const imageWrapper = ref(null);
|
| let headData = reactive({
| head: {},
| });
| let hanjiRdData = reactive({
| jiguanRd2List: {},
| feipinYintieList: {},
| feipinJiguanList: {},
| jiguanZhiliangRdList: {},
| jiguanFuliaoRdList: {},
| jiguanRd: {},
| });
|
| let SClist = ref([]);
| let hjData = ref({});
| let ytfpData = ref([]);
| let hjfpData = ref([]);
| let zlList = ref([]);
| let flList = ref([]);
| let rdList = ref([]);
| let labelName = {
| b1: "生产记录",
| b2: "废品统计",
| b3: "质量记录",
| b4: "辅料检查记录",
| };
| let editable = ref(false);
|
| const submitForm = () => {};
|
| const handleEdit = (row) => {
| row.editable = true;
| };
| const handleDelete = (index) => {
| this.tableData.splice(index, 1);
| };
| const prepend = (index) => {
| item.editable = true;
| this.tableData.splice(index, 0, item);
| };
| const append = (index) => {
| item.editable = true;
| this.tableData.splice(index + 1, 0, item);
| };
| const deleteCurrentColumn = (index) => {
| this.tableHeader.splice(index, 1);
| };
| const insertBefore = (index) => {
| header.editable = true;
| this.tableHeader.splice(index, 0, header);
| };
| const getListData = async () => {
| const data = await jiguanVoLast();
| parse(data);
| };
| function parse(data) {
| headData.head = data.data.head;
| headData.head.reportTime = headData.head.reportTime.substr(0, 10);
| hanjiRdData.jiguanRd2List = data.data.jiguanRd2List;
| console.log("jiguan....", data);
| hjData.value = {
| ...headData.head,
|
| ...data.data.jiguanRd,
| t1: SClist,
| t2: ytfpData,
| t3: hjfpData,
| t4: zlList,
| t5: flList,
| };
|
| // tableHeader.forEach(e=>{
| // // SClist.push({e.})
| // })
|
| SClist.value = data.data.jiguanRd2List;
| hjfpData.value = data.data.feipinJiguanList;
| ytfpData.value = data.data.feipinYintieList;
| zlList.value = data.data.jiguanZhiliangRdList;
| flList.value = data.data.jiguanFuliaoRdList;
| rdList.value = [data.data.jiguanRd];
|
| SClist.value.filter((item) => {
| if (item != null)
| item.shengchanTime1 = item.shengchanTime.substr(11, 5);
|
| return item;
| });
|
| zlList.value.filter((item) => {
| if (item != null && item.rdTime != null)
| item.rdTime1 = item.rdTime.substr(11, 5);
|
| return item;
| });
| }
| const saveData = async () => {
| editable = false;
| let data = {
| jiguanRd2List: SClist.value,
| feipinYintieList: ytfpData.value,
| feipinJiguanList: hjfpData.value,
| jiguanZhiliangRdList: zlList.value,
| jiguanFuliaoRdList: flList.value,
| jiguanRd: rdList.value[0],
| head: headData.head,
| };
| console.log("save data...", data);
| const dt = await save(data);
| if (dt.code == 0) {
| ElMessage({
| message: "修改成功",
| type: "success",
| });
| }
| console.log(dt);
| };
| //截图
| const toImage = () => {
| html2canvas(imageWrapper.value, {
| logging: false,
| allowTaint: true,
| scale: window.devicePixelRatio,
| // width: shareContent.clientWidth, //dom 原始宽度
| // height: shareContent.clientHeight,
| scrollY: 0,
| scrollX: 0,
| useCORS: true,
| backgroundColor: "#ffffff",
| }).then(function (canvas) {
| // console.log(canvas);
| let imgUrl = canvas.toDataURL("image/png");
| var tempLink = document.createElement("a"); // 创建一个a标签
| tempLink.style.display = "none";
| tempLink.href = imgUrl;
| tempLink.setAttribute("download", "集罐机工序生产质量记录"); // 给a标签添加下载属性
| if (typeof tempLink.download === "undefined") {
| tempLink.setAttribute("target", "_blank");
| }
| document.body.appendChild(tempLink); // 将a标签添加到body当中
| tempLink.click(); // 启动下载
| document.body.removeChild(tempLink); // 下载完毕删除a标签
| window.URL.revokeObjectURL(imgUrl);
| });
| };
| // 点击导出word
| function exportWord() {
| // 读取并获得模板文件的二进制内容
| JSZipUtils.getBinaryContent("jiguan2.docx", function (error, content) {
| // input.docx是模板。我们在导出的时候,会根据此模板来导出对应的数据
| // 抛出异常
| if (error) {
| throw error;
| }
|
| // 创建一个JSZip实例,内容为模板的内容
| let zip = new PizZip(content);
| // 创建并加载docxtemplater实例对象
| let doc = new docxtemplater().loadZip(zip).setOptions({
| nullGetter: function () {
| return "";
| },
| });
| // 设置模板变量的值
| doc.setData({
| ...hjData.value,
|
| // table: hanjiRdData.hanjiRd,
| });
|
| try {
| // 用模板变量的值替换所有模板变量
| doc.render();
| } catch (error) {
| // 抛出异常
| let e = {
| message: error.message,
| name: error.name,
| stack: error.stack,
| properties: error.properties,
| };
| console.log(JSON.stringify({ error: e }));
| throw error;
| }
|
| // 生成一个代表docxtemplater对象的zip文件(不是一个真实的文件,而是在内存中的表示)
| let out = doc.getZip().generate({
| type: "blob",
| mimeType:
| "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
| });
| // 将目标文件对象保存为目标类型的文件,并命名
| saveAs(out, "集罐机工序生产质量记录.docx");
| });
| }
| const getRouterData = async (req) => {
| console.log("req....", req);
| const data = await headReport(req);
| console.log("jbj router data.....", data);
|
| parse(data);
| };
| onMounted(() => {
| console.log("rrrrrrrrrrr", router.currentRoute.value.query);
| let head_id = router.currentRoute.value.query.id;
| let leixing = router.currentRoute.value.query.leixing;
| console.log("vue recv....", head_id, leixing);
| if (head_id == null) {
| getListData();
| } else {
| getRouterData({ head_id: head_id, leixing: leixing });
| }
| });
| return {
| saveData,
| submitForm,
| formInline,
| tableData,
| ytfpHeader,
| hjfpHeader,
| zlHeader,
| flHeader,
| insertBefore,
| deleteCurrentColumn,
| append,
| prepend,
| handleDelete,
| handleEdit,
| tableHeader,
| getListData,
| headData,
| toImage,
| imageWrapper,
| SClist,
| ytfpData,
| hjfpData,
| zlList,
| flList,
| rdList,
| rdHeader,
| exportWord,
| labelName,
| editable,
| };
| },
| };
| </script>
| <style lang="scss" scoped>
| .header_nox {
| text-align: right;
| }
|
| #printContent h3 {
| text-align: center;
| margin-bottom: 40px;
| font-size: 26px;
| font-weight: bold;
| }
|
| .title_form {
| display: flex;
| justify-content: space-around;
| align-items: center;
| // margin-bottom: 20px;
| }
|
| .title_form_input {
| font-size: 16px;
| }
| </style>
|
|