chenhaozhe
2026-03-13 b7b47130b76637898f76197a2d0eaa29f5f73ff3
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
<template>
    <view class="content">
        <view class="list">
            <uni-card :title="'当期订单:'+currentOrder[0].HSourceBillNo" 
            style="margin: 10px;">
                <view class="card-detail">
                    <view class="detail" v-if="currentOrder[0].HSourceName" style="width: 100%;">
                        <text>当前设备:</text>{{currentOrder[0].HSourceName}}
                    </view>
                    <view class="detail" v-if="currentOrder[0].首检次数?currentOrder[0].首检次数:0" style="width: 100%;">
                        <text>首检次数:</text>{{currentOrder[0].首检次数}}
                    </view>
                    <view class="detail">
                        <text>巡检次数:</text>{{currentOrder[0].巡检次数?currentOrder[0].巡检次数:0}}
                    </view>
                    <view class="detail">
                        <text>过程检次数:</text>{{currentOrder[0].过程检次数?currentOrder[0].过程检次数:0}}
                    </view>
                    <view class="detail" v-if="currentOrder[0].当日点检完成情况">
                        <text>点检完成情况:</text>{{currentOrder[0].当日点检完成情况}}
                    </view>
                    <view class="detail" v-if="currentOrder[0].安灯未验收数量">
                        <text>异常反馈未验收:</text>{{currentOrder[0].安灯未验收数量}}
                        <view style="width: 6rpx; display: inline-block;"></view>
                        <template v-if="currentOrder[0].安灯未验收数量 == 0">
                            <uni-icons type="smallcircle-filled" size="12"
                                color="#13ad4c"></uni-icons>
                        </template>
                        <template v-else-if="currentOrder[0].安灯未验收数量 != 0">
                            <uni-icons type="smallcircle-filled" size="12"
                                color="#e74c3c"></uni-icons>
                        </template>
                    </view>
                </view>
            </uni-card>
        </view>
        <view class="list" v-for="(item,index) in listData" :key="index">
            <uni-card :title="'工单号:'+item.HICMOBillNo" :extra="'日期:'+item.计划日期" style="margin: 10px;" @tap="edit(item)">
                <view class="card-detail">
                    <view class="detail" v-if="item.HMaterName" style="width: 100%;">
                        <text>产品名称:</text>{{item.HMaterName}}
                    </view>
                    <view class="detail" v-if="item.HModel" style="width: 100%;">
                        <text>产品型号:</text>{{item.HModel}}
                    </view>
                    <view class="detail">
                        <text>计划数量:</text>{{item.HDatePlanQty?item.HDatePlanQty:0}}
                    </view>
                    <view class="detail">
                        <text>汇报总数:</text>{{item.HDateFinishQty?item.HDateFinishQty:0}}
                    </view>
                    <view class="detail" v-if="item.HICMOStatus">
                        <text>当前状态:</text>{{item.HICMOStatus}}
                    </view>
                    <view class="detail" v-if="item.领料状态">
                        <text>领料状态:</text>{{item.领料状态}}
                    </view>
                    <view class="detail" style="width: 100%;display: flex;align-items: center;">
                        <text>生产进度:</text>
                        <zui-progress-bar :value="item.percent" :width="210" type="follow-left" />
                    </view>
                </view>
            </uni-card>
        </view>
        <uni-popup ref="popup" background-color="#fff">
            <view class="popup-content">
                <view class="tit">异常类型</view>
                <view class="item" v-for="(item,index) in popList" :key="index" @tap="toAbnm(item)">{{item}}</view>
            </view>
        </uni-popup>
        <view class="over" v-if="listData.length == 0">暂无数据</view>
        <view class="over" v-if="listData.length != 0">已到底</view>
    </view>
</template>
 
<script>
    import {
        CommonUtils
    } from "../../utils/common";
    import {
        getUserInfo
    } from "@/utils/auth.js";
    export default {
        data() {
            return {
                userInfo: getUserInfo(),
                serverUrl: uni.getStorageSync('serverUrl') || 'http://47.96.97.237/API',
                HSourceID: '',
                HSourceName: '',
                number: 1,
                listData: [],
                chooseIt: '',
                popList: ['人员原因', '设备原因', '材料原因', '工艺原因', '模具原因', '测试原因', '环境原因'],
                badReasonBackTypeList: [],
                currentOrder: [],
                // 定义操作映射配置
                actionConfig: {
                    '开工': {
                        apiUrl: '/Sc_MESBeginWorkBill/FastBeginWorkBill',
                        type: '开工',
                        handler: 'handleBegin',
                        checkStatus: true, // 需要检查状态
                        denyMsg: '单据状态不满足开工条件!' // 固定错误提示
                    },
                    '完工': {
                        apiUrl: '/Sc_MESEndWorkBill/FastEndWorkBill',
                        type: '完工',
                        handler: 'handleEnd',
                        checkStatus: true,
                        denyMsg: '单据状态不满足完工条件!' // 固定错误提示
                    },
                    '停工': {
                        apiUrl: '/Sc_MESStopWorkBill/FastStopWorkBill',
                        type: '停工',
                        handler: 'handleStop',
                        checkStatus: true,
                        denyMsg: '单据状态不满足停工条件!' // 固定错误提示
                    },
                    '异常反馈': {
                        apiUrl: '',
                        type: '异常反馈',
                        handler: 'handleAbnormal',
                        checkStatus: true,
                        denyMsg: '单据状态不满足异常反馈条件!' // 固定错误提示
                    },
                    '工艺参数点检': {
                        apiUrl: '',
                        type: '工艺参数点检',
                        handler: 'handleICMOTechParam',
                        checkStatus: true,
                        denyMsg: '单据状态不满足工艺参数点检条件!' // 固定错误提示
                    },
                    '首检': {
                        apiUrl: '',
                        type: '首检',
                        handler: 'handleFirstCheck',
                        checkStatus: false,
                        denyMsg: '单据状态不满足工艺参数点检条件!'
                    },
                    '巡检': {
                        apiUrl: '', // 巡检需要检查首件是否完成
                        type: '巡检',
                        handler: 'handlePatrolCheck',
                        checkStatus: false,
                        denyMsg: '单据状态不满足巡检条件!'
                    },
                    '末检': {
                        apiUrl: '',
                        type: '末检',
                        handler: 'handleProcessCheck',
                        checkStatus: false,
                        denyMsg: '单据状态不满足末检条件!'
                    }
                }
            }
        },
        onLoad(e) {
            console.log(e)
            uni.showLoading({
                title: '加载中...'
            })
            this.HSourceName = e.HSourceName
            this.HSourceID = e.HSourceID
            this.getList(e.HSourceID)
            this.getErrMsgBackType()
        },
        onPullDownRefresh: function() {
            this.getList(this.HSourceID)
            setTimeout(() => {
                uni.stopPullDownRefresh();
            }, 1000);
        },
        methods: {
            async getErrMsgBackType() {
                try {
                    let res = await CommonUtils.doRequest2Async({
                        url: '/Gy_BadReason/Gy_ErrMsgBackTypeList',
                        data: {
                            sWhere: ` and  使用组织名称 = '${uni.getStorageSync('Organization')}'`,
                            user: getUserInfo()['Czymc']
                        }
                    })
 
                    let {
                        data,
                        count,
                        Message
                    } = res.data
                    if (count == 1) {
                        this.popList = Array.from(data).map(item => item['异常反馈类型名称'])
                        this.badReasonBackTypeList = data
                    } else {
                        CommonUtils.showTips({
                            title: '温馨提示',
                            message: `获取异常反馈类型失败: ${Message}`
                        })
                    }
                } catch (err) {
                    CommonUtils.showTips({
                        title: '温馨提示',
                        message: `获取异常反馈类型失败: ${err}`
                    })
                }
            },
            getList(e) {
                uni.request({
                    url: this.serverUrl + '/ReportPlatForm/SearchGetWorkBillList',
                    data: {
                        "HSourceID": e
                    },
                    success: (res) => {
                        if (res.data.count == 1) {
                            console.log(res.data.data.h_p_JIT_GetWorkBillListInfoBySource)
                            this.listData = res.data.data.h_p_JIT_GetWorkBillListInfoBySource
                            this.currentOrder = res.data.data.h_p_JIT_GetWorkBillListInfoBySource1
                            for (var i = 0; i < this.listData.length; i++) {
                                this.listData[i].percent = (this.listData[i].HDateFinishQty / this.listData[
                                    i].HDatePlanQty).toFixed(4)
                            }
                            setTimeout(() => {
                                uni.hideLoading()
                            }, 1000);
                        } else {
                            setTimeout(() => {
                                uni.hideLoading()
                            }, 1000);
                            uni.showToast({
                                title: '获取列表出错!',
                                icon: 'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        setTimeout(() => {
                            uni.hideLoading()
                        }, 1000);
                        uni.showToast({
                            title: '获取列表接口请求失败',
                            icon: 'none'
                        })
                    },
                });
            },
            toAbnm(item) {
                console.log(item, this.chooseIt)
                this.$refs.popup.close()
                uni.navigateTo({
                    url: './OA_ErrMsgBackBill?HICMOBillNo=' + this.chooseIt.HICMOBillNo +
                        '&HSourceName=' + this.HSourceName +
                        '&HSourceBillNo=' + this.chooseIt.HSourceBillNo +
                        '&HType=' + item +
                        '&OperationType=4&linterid=&HSouceBillType=3772'
                })
            },
            edit(item) {
                console.log(item)
                this.chooseIt = item
 
                // 使用对象映射配置生成可用的操作列表
                const availableActions = Object.keys(this.actionConfig)
 
                uni.showActionSheet({
                    itemList: availableActions,
                    success: (res) => {
                        const actionKey = availableActions[res.tapIndex]
                        const actionConfig = this.actionConfig[actionKey]
 
                        // 调用对应的处理方法
                        this[actionConfig.handler](item, actionConfig)
                    },
                    fail: function(res) {
                        console.log(res.errMsg);
                    }
                });
            },
            // 开工处理
            handleBegin(item, config) {
                const upData = this.createUpData(item)
                this.checkAndExecuteWorkStatus(
                    item,
                    config,
                    config.apiUrl,
                    upData
                )
            },
            // 完工处理
            handleEnd(item, config) {
                const upData = this.createUpData(item)
                this.checkAndExecuteWorkStatus(
                    item,
                    config,
                    config.apiUrl,
                    upData
                )
            },
            // 停工处理
            handleStop(item, config) {
                const upData = this.createUpData(item)
                this.checkAndExecuteWorkStatus(
                    item,
                    config,
                    config.apiUrl,
                    upData
                )
            },
            // 异常反馈处理
            handleAbnormal(item, config) {
                const sWhere = {
                    "HSourceID": this.HSourceID,
                    "HICMOBillNo": item.HICMOBillNo,
                    "HInterID": item.HSourceInterID,
                    "type": config.type
                }
 
                uni.request({
                    url: this.serverUrl + '/Sc_MESBeginWorkBill/GetMESBeginWorkBillStaus',
                    type: "GET",
                    data: {
                        "sWhere": JSON.stringify(sWhere)
                    },
                    dataType: "json",
                    async: false,
                    success: (res) => {
                        console.log('异常反馈状态检查:', res.data)
                        // 根据第二个页面的逻辑:如果count>0,表示不允许操作
                        if (res.data.count > 0) {
                            // 不允许操作,显示错误提示
                            const status = item.HICMOStatus || '未知状态'
                            uni.showToast({
                                title: `工单【${item.HICMOBillNo}】当前状态为【${status}】,${config.denyMsg}`,
                                icon: 'none',
                                duration: 3000
                            })
                        } else {
                            // count<=0,表示允许操作
                            this.$refs.popup.open('center')
                        }
                    },
                    fail: (res) => {
                        console.log(res)
                        uni.hideLoading()
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        })
                    },
                })
            },
            // 工艺参数点检
            handleICMOTechParam(item, config) {
                const upData = this.createUpData(item)
                this.checkAndExecuteWorkStatus(
                    item,
                    config,
                    config.apiUrl,
                    upData
                )
            },
            handleFirstCheck(item, config) {
                let uri = `?HSouceBillType=${item.HBillType}&HBillNo=${item.HICMOBillNo}` +
                    `&linterid=${item.HProcExchInterID}&hsubid=${item.HProcExchEntryID || 1}`
                uni.navigateTo({
                    url: '/pages/ZLGL/shoujianjianyan/firstCheckBill' + uri + `&operationType=2`
                })
            },
            handlePatrolCheck(item, config) {
                let uri = `?HSouceBillType=${item.HBillType}&HBillNo=${item.HICMOBillNo}` +
                    `&linterid=${item.HProcExchInterID}&hsubid=${item.HProcExchEntryID || 1}`
                uni.navigateTo({
                    url: '/pages/ZLGL/xunjianjianyan/PatrolProcCheckBill' + uri + `&operationType=2`
                })
            },
            handleProcessCheck(item, config) {
                let uri = `?HSouceBillType=${item.HBillType}&HBillNo=${item.HICMOBillNo}` +
                    `&linterid=${item.HProcExchInterID}&hsubid=${item.HProcExchEntryID || 1}`
                uni.navigateTo({
                    url: '/pages/ZLGL/mojianjianyan/ProcessCheckBill' + uri + `&operationType=2`
                })
            },
            // 创建通用的请求数据
            createUpData(item) {
                return {
                    HBillType: item.HBillType,
                    HSourceInterID: item.HSourceInterID,
                    HSourceEntryID: item.HSourceEntryID,
                    HSourceBillNo: item.HSourceBillNo,
                    HSourceBillType: item.HSourceBillType,
                    user: uni.getStorageSync('HUserName')
                }
            },
            // 通用的检查和执行方法
            checkAndExecuteWorkStatus(item, config, apiUrl, upData) {
                const sWhere = {
                    "HSourceID": this.HSourceID,
                    "HICMOBillNo": item.HICMOBillNo,
                    "HInterID": item.HSourceInterID,
                    "type": config.type
                }
 
                console.log('状态检查参数:', JSON.stringify(sWhere))
 
                uni.request({
                    url: this.serverUrl + '/Sc_MESBeginWorkBill/GetMESBeginWorkBillStaus',
                    type: "GET",
                    data: {
                        "sWhere": JSON.stringify(sWhere)
                    },
                    dataType: "json",
                    async: false,
                    success: (res) => {
                        console.log('状态检查结果:', res.data)
                        // 根据第二个页面的逻辑:如果data.count>0,表示不允许操作
                        if (res.data.count > 0) {
                            // 不允许操作,显示错误提示
                            const status = item.HICMOStatus || '未知状态'
                            const operationMap = {
                                '开工': '开工',
                                '完工': '完工',
                                '停工': '停工',
                                '异常反馈': '异常反馈',
                                '工艺参数点检': '工艺参数点检'
                            }
                            const operationName = operationMap[config.type] || config.type
 
                            // 根据操作类型给出不同的建议
                            let suggestion = ''
                            switch (config.type) {
                                case '开工':
                                    suggestion = '开工操作需要工单状态为"待生产"或"挂起"状态,请检查当前状态是否符合要求'
                                    break
                                case '完工':
                                    suggestion = '完工操作需要工单处于"生产中"状态,请检查当前状态是否符合要求'
                                    break
                                case '停工':
                                    suggestion = '停工操作需要工单处于"生产中"状态,请检查当前状态是否符合要求'
                                    break
                                case '异常反馈':
                                    suggestion = '异常反馈需要工单处于"生产中"或"开工"状态,请检查当前状态是否符合要求'
                                    break
                                case '工艺参数点检':
                                    suggestion = '工艺参数点检需要工单处于"生产中"或"开工"状态,请检查当前状态是否符合要求'
                                    break
                                default:
                                    suggestion = '请检查工单状态是否符合操作要求'
                            }
 
                            uni.showToast({
                                title: `工单【${item.HICMOBillNo}】当前状态为【${status}】,无法进行【${operationName}】操作。\n${suggestion}`,
                                icon: 'none',
                                duration: 4000
                            })
                        } else {
                            // data.count<=0,表示允许操作
                            this.showConfirmDialog(config.type, item, apiUrl, upData)
                        }
                    },
                    fail: (res) => {
                        console.log(res)
                        uni.hideLoading()
                        uni.showToast({
                            title: '状态检查接口请求失败',
                            icon: 'none'
                        })
                    },
                })
            },
            // 显示确认对话框
            showConfirmDialog(actionType, item, apiUrl, upData) {
                // 获取当前工单状态显示在确认框中
                const status = item.HICMOStatus || '未知状态'
 
                uni.showModal({
                    title: actionType + '确认',
                    content: `设备:${this.HSourceName}\n工单:${item.HICMOBillNo}\n产品:${item.HMaterName}\n当前状态:${status}\n\n确定要执行【${actionType}】操作吗?`,
                    success: (res) => {
                        if (res.confirm) {
                            console.log('用户点击确定')
                            this.executeWork(apiUrl, upData, item, actionType)
                        } else if (res.cancel) {
                            console.log('用户点击取消')
                        }
                    }
                })
            },
            // 执行工作操作
            executeWork(apiUrl, upData, item, actionType) {
                uni.showLoading({
                    title: `正在${actionType}...`,
                    mask: true
                })
                console.log('执行操作参数:', upData)
 
                if (actionType == '工艺参数点检') {
                    uni.hideLoading()
                    console.log('item: ', item);
                    uni.navigateTo({
                        url: `/pages/MJGL/SB_EquipICMOTechParamBill/SB_EquipICMOTechParamBillEdit?hinterid=${item.HSourceInterID}&hsubid=${item.HSourceEntryID}&operationType=5`
                    })
                } else {
                    uni.request({
                        url: this.serverUrl + apiUrl,
                        data: upData,
                        success: (res) => {
                            console.log('执行操作结果:', res)
                            if (res.data.count == 1) {
                                // 操作成功后刷新列表
                                this.getList(this.HSourceID)
                                uni.showToast({
                                    title: `${actionType}成功!`,
                                    icon: 'success'
                                })
 
                                if (actionType == '完工') {
                                    // 完工单提交成功后。提示是否需要跳转达到下模单
                                    uni.showModal({
                                        title: "跳转页面",
                                        content: "完工单保存成功,是否跳转到下模单页面。",
                                        success: (res) => {
                                            if (res.confirm) {
                                                console.log('用户点击确定')
                                                uni.redirectTo({
                                                    url: "/pages/MJGL/xiamodan/MouldLowerBillList"
                                                })
                                            } else if (res.cancel) {
                                                console.log('用户点击取消')
                                            }
                                        }
                                    })
 
                                }
                            } else {
                                uni.hideLoading()
                                // 显示更详细的操作失败提示
                                let errorMsg = res.data.Message || `${actionType}失败`
                                uni.showToast({
                                    title: `${actionType}失败:${errorMsg}`,
                                    icon: 'none',
                                    duration: 3000
                                })
                            }
                        },
                        fail: (res) => {
                            console.log(res)
                            uni.hideLoading()
                            uni.showToast({
                                title: `${actionType}接口请求失败,请检查网络`,
                                icon: 'none'
                            })
                        },
                    })
                }
            },
            changeTab(e) {
                this.number = e
                if (e == 1) {
                    this.listData = this.listData1
                } else {
                    this.listData = this.listData2
                }
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    .list {
        width: 100%;
 
        .card-detail {
            width: 100%;
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
            line-height: 120%;
 
            .detail {
                width: 46%;
                font-size: 26rpx;
                margin-bottom: 12rpx;
                color: #555;
                margin-right: 20rpx;
 
                text {
                    color: #999;
                    font-size: 26rpx;
                }
            }
        }
 
        .more {
            color: #888;
            font-size: 24rpx;
            display: flex;
            border-top: 1px solid #eee;
            padding-top: 20rpx;
 
            .part {
                width: 50%;
                text-align: center;
            }
        }
    }
 
    .popup-content {
        width: 500rpx;
        border-radius: 20rpx;
        text-align: center;
        padding-bottom: 20rpx;
 
        .tit {
            height: 120rpx;
            line-height: 120rpx;
            font-size: 34rpx;
            color: #222;
            font-weight: bold;
        }
 
        .item {
            height: 88rpx;
            line-height: 88rpx;
            border-top: 1px solid #eee;
            font-size: 32rpx;
            color: #444;
        }
    }
</style>