Houjie
4 天以前 30590221cd34912a61f4734ea474859a0df98be6
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
<template>
    <view class="container">
        <cu-custom :bgColor="NavBarColor" :isBack="true" backRouterName="productionTask">
            <block slot="backText">返回</block>
            <block slot="content">报工</block>
            <block slot="right">
                <view @click="printHandel">
                    <image class="search" src="/static/icon_dayin.png" style="width: 25px; height: 25px;" alt="打印按钮" />
                </view>
            </block>
        </cu-custom>
        
        <!-- 骨架屏 -->
        <view v-if="loading" class="skeleton-container">
            <view class="skeleton-group">
                <view class="skeleton-divider"></view>
                <view class="skeleton-item">
                    <view class="skeleton-label"></view>
                    <view class="skeleton-input"></view>
                </view>
                <view class="skeleton-item">
                    <view class="skeleton-label"></view>
                    <view class="skeleton-input"></view>
                </view>
                <view class="skeleton-item">
                    <view class="skeleton-label"></view>
                    <view class="skeleton-input"></view>
                </view>
                <view class="skeleton-item">
                    <view class="skeleton-label"></view>
                    <view class="skeleton-input"></view>
                </view>
            </view>
            
            <view class="skeleton-group">
                <view class="skeleton-divider"></view>
                <view class="skeleton-item">
                    <view class="skeleton-label"></view>
                    <view class="skeleton-input"></view>
                </view>
                <view class="skeleton-item">
                    <view class="skeleton-label"></view>
                    <view class="skeleton-select"></view>
                </view>
                <view class="skeleton-item">
                    <view class="skeleton-label"></view>
                    <view class="skeleton-select"></view>
                </view>
                <view class="skeleton-item">
                    <view class="skeleton-label"></view>
                    <view class="skeleton-input"></view>
                </view>
                <view class="skeleton-item">
                    <view class="skeleton-label"></view>
                    <view class="skeleton-select"></view>
                </view>
                <view class="skeleton-item">
                    <view class="skeleton-label"></view>
                    <view class="skeleton-datetime"></view>
                </view>
            </view>
            
            <view class="skeleton-button"></view>
        </view>
        
        <!-- 实际内容 -->
        <view v-else class="container">
            <uni-forms 
                ref="form" 
                :modelValue="formData" 
                :rules="rules" 
                validate-trigger="bind" 
                err-show-type="undertext">
                <uni-group top="1">
                    <view class="divider"><text>工单信息</text></view>
                    <uni-forms-item :label-width="100" name="workOrderNumber" label="单据编号:">
                        <uni-easyinput v-model="formData.workOrderNumber" :disabled="true" />
                    </uni-forms-item>
                    <uni-forms-item :label-width="100" name="materialCode" label="物料编码:">
                        <uni-easyinput v-model="formData.materialCode" :disabled="true" />
                    </uni-forms-item>
 
                    <uni-forms-item :label-width="100" name="materialDescription" label="物料描述:">
                        <uni-easyinput v-model="formData.materialDescription" :disabled="true" />
                    </uni-forms-item>
                    <uni-forms-item :label-width="100" name="plannedQuantity" label="计划数量:">
                        <uni-easyinput v-model="formData.plannedQuantity" :disabled="true" />
                    </uni-forms-item>
 
                    <view class="divider"><text>报工信息</text></view>
 
                    <uni-forms-item  :label-width="140" required name="inspectionOrderNumber"
                        label="报工单号:">
                        <uni-easyinput v-model="formData.inspectionOrderNumber" placeholder="系统生成" :disabled="true" />
                    </uni-forms-item>
                    <uni-forms-item :label-width="140" required name="process" label="仓库">
                        <uni-data-select v-model="formData.process" :localdata="SpareList" @change="changeisSpareList"
                            placeholder="请选择" />
                    </uni-forms-item>
                    <uni-forms-item  :label-width="140" required name="inspectionQuantity" label="报工数量:">
                        <uni-number-box v-model="formData.inspectionQuantity"  />
                    </uni-forms-item>
                    <uni-forms-item :label-width="140" required name="inspectionPlan" label="检验人员">
                        <uni-data-select v-model="formData.inspectionPlan" :localdata="SpareList"
                            @change="changeisSpareList" placeholder="请选择" />
                    </uni-forms-item>
                    <uni-forms-item :label-width="140" required name="inspectionTime" label="报工时间">
                        <uni-datetime-picker type="datetime" v-model="formData.inspectionTime" />
                    </uni-forms-item>
                </uni-group>
            </uni-forms>
 
            <view class="padding flex flex-direction">
                <view class="flex-sub bg-blue padding-sm margin-xl radius text-sm text-center text-white"
                    @click.stop="ProductionTask()" hover-class="is-hover">确定</view>
            </view>
        </view>
        
        <pdaScanVue></pdaScanVue>
    </view>
</template>
 
<script>
    import pdaScanVue from "@/components/mes/pdaScan.vue";
    import QRCode from 'qrcode';
 
    export default {
        components: {
            pdaScanVue
        },
        data() {
            return {
                loading: true,
                isShow: false,
                isSubmitting: false, // 防重复提交
                SpareList: [{
                        text: "是",
                        value: 1
                    },
                    {
                        text: "否",
                        value: 0
                    }
                ],
                scrollLeft: 0,
                formData: {
                    workOrderNumber: '1111111',
                    materialCode: '120008194',
                    materialDescription: '三代轮毂轴承单元\\G3-487',
                    plannedQuantity: '200',
                    inspectionOrderNumber: '',
                    process: '',
                    inspectionType: '',
                    inspectionQuantity: '',
                    inspectionPlan: '',
                    inspectionTime: '',
                    // 新增字段用于标签数据
                    productName: '驱动轴总成',
                    palletNo: 'PAL20250822001',
                    produceDate: '',
                    workshop: '装配车间3号线'
                },
                // 表单验证规则
                rules: {
                    process: {
                        rules: [{
                            required: true,
                            errorMessage: '请选择工序'
                        }]
                    },
                    inspectionType: {
                        rules: [{
                            required: true,
                            errorMessage: '请选择检验类型'
                        }]
                    },
                    inspectionPlan: {
                        rules: [{
                            required: true,
                            errorMessage: '请选择检验方案'
                        }]
                    },
                    inspectionTime: {
                        rules: [{
                            required: true,
                            errorMessage: '请选择检验时间'
                        }]
                    },
                    inspectionQuantity: {
                        rules: [{
                            required: true,
                            errorMessage: '请输入送检数量'
                        }, {
                            format: 'number',
                            errorMessage: '送检数量必须为数字'
                        }]
                    }
                },
                NavBarColor: this.NavBarColor,
                url: {
                    upload: "/eam/sysFiles/batch_upload",
                    stallList: "/eam/eamRepairOrder/queryById",
                    getEquipmentList: 'eam/equipment/list',
                    approval: '/eam/eamRepairOrder/perform'
                },
                styles: {
                    color: '#2979FF',
                    borderColor: '#2979FF'
                },
                msg1Count: 0
            }
        },
        computed: {
            top() {
                return this.CustomBar * 2 + 160
            },
            style() {
                var StatusBar = this.StatusBar;
                var CustomBar = this.CustomBar;
                var style = `height:${CustomBar}px;padding-top:${StatusBar}px;`;
                return style
            },
        },
        mounted() {
            /**
             * 上料下料根据物料类型判断(额外信息)---扫码/手动输入 ---(手动输入调用接口返回库存信息)  扫码信息提交后端,在重新赋值 判断物料类型- 显示特殊属性值, 库存信息也要保存
             */
            const currentLineType = this.$store.getters.currentLineType;
            console.log('当前产线类型:', currentLineType);
            /**
             * 装配    ASSEMBLE
             * 内法兰INNERFLANGE
             * 外法兰OUTERFLANGE
             * 热处理HEATTREATMENT
             */
        },
        created() {
            // 初始化生产日期为当前日期
            this.formData.produceDate = this.formatDate(new Date());
            
            // 模拟数据加载
            setTimeout(() => {
                this.loading = false;
            }, 1000);
        },
        methods: {
            // 格式化日期
            formatDate(date) {
                const year = date.getFullYear();
                const month = String(date.getMonth() + 1).padStart(2, '0');
                const day = String(date.getDate()).padStart(2, '0');
                return `${year}-${month}-${day}`;
            },
            
            // 点击打印按钮:生成HTML预览并跳转
            async printHandel() {
                // 1. 验证表单信息
                if (!this.formData.inspectionQuantity || !this.formData.process) {
                    uni.showToast({
                        title: '请先填写报工数量和仓库信息',
                        icon: 'none',
                        duration: 2000
                    });
                    return;
                }
            
                try {
                    uni.showLoading({ title: '生成预览中...' });
                    
                    // 2. 收集打印数据
                    const tagData = this.getReportPrintData();
                    
                    // 3. 跳转至预览页,并携带打印数据
                    await uni.navigateTo({
                        url: `/pages/finished-product-preview/finished-product-preview?tagData=${encodeURIComponent(JSON.stringify(tagData))}`
                    });
                    
                    uni.hideLoading();
                } catch (error) {
                    uni.hideLoading();
                    console.error('生成预览失败:', error);
                    uni.showToast({ title: '预览生成失败', icon: 'none' });
                }
            },
 
            // 生成成品托标签数据(优化后)
        getReportPrintData() {
          const { formData } = this;
          return {
              
                material: '120034535',
                batch: '25098814',
                model: 'G3-2B259',
                quantity: 216,
                inspectDate: '20250408',
                inspector: '王義/合格',
                date: '2025.08.22'
              
         //    batchNo: "25158878",
         //    productModel:  "三代轮毂轴承单元\\G3-639", 
         //    palletNo:  "11236979",  
         //    quantity:  "107",
         //    workshop:  "3003",  
         //    code: "1200143912506070086",
            // planNum:"10016456466565"
          };
        },
 
            changeisSpareList(e) {
                this.formData.isSpare = e;
            },
 
            async ProductionTask() {
                // 防止重复提交
                if (this.isSubmitting) {
                    uni.showToast({
                        icon: "none",
                        title: "正在提交中,请勿重复点击",
                        duration: 2000
                    });
                    return;
                }
 
                uni.showLoading({
                    mask: true,
                    title: "提交中..."
                });
 
                try {
                    // 表单验证
                    await this.$refs.form.validate();
 
                    this.isSubmitting = true;
 
                    // 发送报工请求
                    const response = await this.$http.post(this.url.approval, {
                        workOrderNumber: this.formData.workOrderNumber,
                        materialCode: this.formData.materialCode,
                        materialDescription: this.formData.materialDescription,
                        plannedQuantity: this.formData.plannedQuantity,
                        inspectionOrderNumber: this.formData.inspectionOrderNumber,
                        process: this.formData.process,
                        inspectionType: this.formData.inspectionType,
                        inspectionQuantity: this.formData.inspectionQuantity,
                        inspectionPlan: this.formData.inspectionPlan,
                        inspectionTime: this.formData.inspectionTime
                    });
 
                    if (response.data.success) {
                        uni.showToast({
                            icon: "success",
                            title: '提交成功',
                            duration: 2000
                        });
 
                        // 延迟跳转
                        await new Promise(resolve => setTimeout(resolve, 2000));
 
                        this.$Router.replaceAll({
                            name: 'qualityInspection'
                        });
                    } else {
                        uni.showModal({
                            title: "提交失败",
                            content: response.data.message || "服务器处理失败,请稍后重试",
                            confirmText: '确定',
                            showCancel: false,
                            icon: "none"
                        });
                    }
                } catch (error) {
                    // 错误处理
                    if (error.errMsg) {
                        uni.showToast({
                            icon: "none",
                            title: error,
                            duration: 2000
                        });
                    } else {
                        console.error("请求失败:", error);
                        let errorMessage = "网络请求失败";
                        if (error.errMsg) {
                            if (error.errMsg.includes("timeout")) {
                                errorMessage = "请求超时,请检查网络连接";
                            } else if (error.errMsg.includes("fail")) {
                                errorMessage = "网络连接失败,请检查网络设置";
                            }
                        }
                        uni.showToast({
                            icon: "none",
                            title: errorMessage,
                            duration: 3000
                        });
                    }
                } finally {
                    this.isSubmitting = false;
                    uni.hideLoading();
                }
            },
        }
    }
</script>
 
<style>
    .is-hover {
        color: rgba(255, 255, 255, 0.6);
        background-color: #55aaff;
        border-color: #55aaff;
    }
 
    .divider {
        display: flex;
        font-weight: bold;
        align-items: center;
        text-align: center;
        color: #1E90FF;
        font-size: 24rpx;
        margin: 20px 0;
    }
 
    .divider::before,
    .divider::after {
        content: '';
        flex: 1;
        border-bottom: 1px solid gray;
        margin: 0 16px;
    }
 
    .divider text {
        white-space: nowrap;
    }
 
    .content {
        margin-top: 5px;
    }
 
    .content scroll-view {
        scrollIndicator: "none"
    }
 
    .popupView {
        margin-top: 45px;
        height: auto;
    }
    
    /* 骨架屏样式 */
    .skeleton-container {
        padding: 20rpx;
    }
    
    .skeleton-group {
        margin-bottom: 40rpx;
    }
    
    .skeleton-divider {
        height: 40rpx;
        width: 300rpx;
        background: linear-gradient(90deg, #f2f2f2 25%, #e6e6e6 37%, #f2f2f2 63%);
        background-size: 400% 100%;
        border-radius: 4rpx;
        animation: skeleton-loading 1.4s ease infinite;
        margin-bottom: 30rpx;
    }
    
    .skeleton-item {
        display: flex;
        align-items: center;
        margin-bottom: 30rpx;
    }
    
    .skeleton-label {
        width: 160rpx;
        height: 40rpx;
        background: linear-gradient(90deg, #f2f2f2 25%, #e6e6e6 37%, #f2f2f2 63%);
        background-size: 400% 100%;
        border-radius: 4rpx;
        animation: skeleton-loading 1.4s ease infinite;
        margin-right: 20rpx;
    }
    
    .skeleton-input {
        flex: 1;
        height: 60rpx;
        background: linear-gradient(90deg, #f2f2f2 25%, #e6e6e6 37%, #f2f2f2 63%);
        background-size: 400% 100%;
        border-radius: 8rpx;
        animation: skeleton-loading 1.4s ease infinite;
    }
    
    .skeleton-select {
        flex: 1;
        height: 60rpx;
        background: linear-gradient(90deg, #f2f2f2 25%, #e6e6e6 37%, #f2f2f2 63%);
        background-size: 400% 100%;
        border-radius: 8rpx;
        animation: skeleton-loading 1.4s ease infinite;
    }
    
    .skeleton-datetime {
        flex: 1;
        height: 60rpx;
        background: linear-gradient(90deg, #f2f2f2 25%, #e6e6e6 37%, #f2f2f2 63%);
        background-size: 400% 100%;
        border-radius: 8rpx;
        animation: skeleton-loading 1.4s ease infinite;
    }
    
    .skeleton-button {
        width: 90%;
        height: 80rpx;
        background: linear-gradient(90deg, #f2f2f2 25%, #e6e6e6 37%, #f2f2f2 63%);
        background-size: 400% 100%;
        border-radius: 10rpx;
        animation: skeleton-loading 1.4s ease infinite;
        margin: 40rpx auto;
    }
    
    @keyframes skeleton-loading {
        0% {
            background-position: 100% 50%;
        }
        100% {
            background-position: 0 50%;
        }
    }
</style>