快乐的昕的电脑
2025-10-14 659b846fc00d2626520fde8fca26b7abbcf04cbb
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
<template>
    <view>
 
        <view class="container" style="display: flex;
               flex-direction: row;
               flex-wrap: nowrap;
               align-content: flex-start;
               justify-content: flex-start;">
            <!-- 上部:工单选择和机台信息 -->
            <view class="top-order" style=" display:inline-block;">
                <view class="form-row4">
                    <view class="form-row" style="display: flex;
                                            flex-direction: column;
                                            flex-wrap: nowrap;
                                            justify-content: flex-start;
                                            align-items: center;">
                        <view class="form-item">
                            <label>工单编号:</label>
                            <input class="inp" type="text" v-model="order.daa001" disabled="true" />
                        </view>
                        <view class="form-item">
                            <label>刀具名称:</label>
                            <input class="inp" type="text" v-model="order.cutterName" disabled="true" />
                        </view>
                        <view class="form-item">
                            <label>工单数量:</label>
                            <input class="inp" type="text" v-model="order.daa008" disabled="true" />
                        </view>
                        <view class="form-item">
                            <label>开工数采:</label><!--开工数采:开工时的累计生产数???-->
                            <input class="inp" type="text" v-model="order.daa004" disabled="true" />
                        </view>
                    </view>
                    <view class="form-row3">
                        <view class="form-item">
                            <label>产品名称:</label>
                            <!--<input class="inp" type="text" v-model="order.daa003" disabled="true" />-->
                            <superwei-combox :candidates="DAA003List" v-model="order.daa003" @select="onDaa003Change"
                                             class="inp" style="font-size: 20px;"></superwei-combox>
                        </view>
                        <view class="form-item">
                            <label>刀具编号:</label><!--刀具编号???-->
                            <input class="inp" type="text" v-model="order.cutterId" disabled="true" />
                        </view>
                        <view class="form-item">
                            <label>刀具规格:</label><!--刀具规格???-->
                            <input class="inp" type="text" v-model="order.cutterModel" disabled="true" />
                        </view>
                        <view class="form-item">
                            <label>当前数采:</label><!--当前数采:当前时间的累计生产数???-->
                            <input class="inp" type="text" v-model="order.daa004" disabled="true" />
                        </view>
                    </view>
                    <view class="form-row3">
                        <view class="form-item">
                            <label>产品编码:</label>
                            <input class="inp" type="text" v-model="order.daa002" disabled="true" />
                        </view>
                        <view class="form-item">
                            <label>产品规格:</label>
                            <input class="inp" type="text" v-model="order.daa004" disabled="true" />
                        </view>
                        <view class="form-item">
                            <label>报工数量:</label>
                            <input class="inp" type="text" v-model="order.daa011" disabled="true" />
                        </view>
                    </view>
                </view>
            </view>
            <view class="form-row1">
                <view class="form-item" style=" display:inline-block;">
                    <label>工单状态:</label>
                    <input class="inp1" type="text" v-model="order.daa018" disabled="true" />
                    <!-- 刷新按钮 -->
                    <button @click="handleRefresh" class="refresh-btn">刷新</button>
                </view>
                <view class="form-item">
                    <label>机台编号:</label>
                    <input class="inp2" type="text" v-model="order.machineNo" disabled="true" />
                </view>
            </view>
        </view>
 
        <!-- 中部:品质检验 -->
        <view class="section card">
            <view class="form-row">
                <view class="form-item">
                    <label style="color: red;">日停机次数(时长超5分钟):</label>
                    <input class="inp" style="width: 40%;" type="number" v-model="todayFaultNum" disabled="true" />
                </view>
                <view class="form-item">
                    <label>日停机时长(mi):</label>
                    <input class="inp" type="text" v-model="todayRunTime" disabled="true" />
                </view>
                <view class="form-item">
                    <label>设备稼动率:</label>
                    <input class="inp" type="text" v-model="utilizationRate" disabled="true" />
                </view>
            </view>
            <view class="form-row">
                <view class="form-item">
                    <label>生产时间开始:</label>
                    <input class="inp" type="text" v-model="startTime" disabled="true" />
                </view>
                <view class="form-item">
                    <label>生产时间结束:</label>
                    <input class="inp" type="text" v-model="endTime" disabled="true" />
                </view>
                <view class="form-item">
                    <label>生产时长(mi):</label>
                    <input class="inp" type="text" v-model="productionDuration" disabled="true" />
                </view>
            </view>
        </view>
 
        <!-- 下部:运行状态 -->
        <view class="section card">
            <view class="form-row">
                <view class="form-item">
                    <label>最近首检时间:</label>
                    <input class="inp" type="text" v-model="lastInitialCheck" disabled="true" />
                </view>
                <view class="form-item">
                    <label>首检结论:</label>
                    <input class="inp" type="text" v-model="initialConclusion" disabled="true" />
                </view>
                <view class="form-item">
                    <label>巡检次数:</label><!--首检次数???-->
                    <input class="inp" type="number" v-model="patrolCount" disabled="true" />
                </view>
            </view>
            <view class="form-row">
                <view class="form-item">
                    <label>最近巡检时间:</label>
                    <input class="inp" type="text" v-model="lastPatrolCheck" disabled="true" />
                </view>
                <view class="form-item">
                    <label>巡检结论:</label>
                    <input class="inp" type="text" v-model="patrolConclusion" disabled="true" />
                </view>
                <view class="form-item">
                    <label>巡检次数:</label>
                    <input class="inp" type="number" v-model="patrolCount" disabled="true" />
                </view>
            </view>
        </view>
    </view>
</template>
 
<script>
    export default {
        name: "WorkOrder",
        props: {
            orderNo: String,
            orderId: Number,
            deviceNumber: String,
            machineNo: String,
        },
        data() {
            return {
                order: {},
                orderStatus: '开工',
 
                collectedAmount: 0,
                todayFaultNum: 0,
                todayRunTime: '',
                utilizationRate: '',
                startTime: '',
                endTime: '',
                productionDuration: '',
                lastInitialCheck: '',
                initialConclusion: '',
                lastPatrolCheck: '',
                patrolConclusion: '',
                patrolCount: 0,
                timer: null, // Timer reference
 
                DAA003List: [],
                lineList: [],
            };
        },
        created() {
            this.fetchData(true);
            this.sumbit();
            this.init();
        },
        mounted() {
            this.fetchData(false); // Initial fetch
            this.timer = setInterval(this.fetchData, 120000); // Call fetchData every 3 minutes
        },
        beforeDestroy() {
            clearInterval(this.timer); // Clear the timer on component destruction
        },
        methods: {
            init() {
                this.$post({
                    url: "/MesOrderSta/init",
                    data: {
                        orderId: this.orderId,
                        orderNo: this.orderNo,
                        machineNo: this.machineNo
                    }
                }).then(res => {
                    this.findByOrderId();
                });
 
                this.$post({
                    url: "/MesOrderSelect/AddMesOrderSelect",
                    data: {
                        machineNo: this.machineNo,
                    }
                }).then(res => {
 
                })
            },
            // 添加刷新按钮的处理方法
            handleRefresh() {
                this.$sendPostRequest({
                    url: "http://192.168.0.94:9095/Numerical/RefreshDev",
                    data: {
                        machineNo: this.order.machineNo
                    },
                    contentType: "application/json"
                }).then(res1 => {
                    if (res1.code == 200) {
                        this.fetchData(true); // 重新请求数据
                        this.sumbit(); // 重新提交相关数据
                    } else {
                        this.$showMessage("同步失败");
                    }
                });
            },
 
            onDaa003Change(event) {
                let orde = this.lineList[this.DAA003List.indexOf(event)];
                this.orderId = orde.id;
                this.orderNo = orde.daa001;
                //切换为新的id
                uni.setStorageSync('machine', this.machineNo);
                uni.setStorageSync('orderId', this.orderId);
                uni.setStorageSync('orderNo', this.orderNo);
                this.fetchData(false);
                this.sumbit();
            },
            sumbit() {
                this.$post({
                    url: "/MesOrderSta/FindByOrderNo",
                    data: {
                        orderId: this.orderId,
                        orderNo: this.orderNo
                    }
                }).then(res => {
                    let statusForm = res.data.tbBillList;
                    this.startTime = res.data.tbBillList.startTime;
                    this.endTime = res.data.tbBillList.endTime;
                    this.productionDuration = "0m";
                    if (this.startTime) {
                        let date1 = new Date(this.startTime);
                        let date2 = new Date();
                        if (this.endTime) {
                            date2 = new Date(this.endTime);
                        }
                        // 计算两个日期之间的差异(以毫秒为单位)
                        let differenceInMilliseconds = date2 - date1;
                        this.productionDuration = (differenceInMilliseconds / 60000).toFixed(2);
                    }
 
 
                    // this.$post({
                    //     url: "/MesOrderSta/Binding",
                    //     data: {
                    //         id: statusForm.id,
                    //         orderId: this.orderId,
                    //         machineNo: this.machineNo
                    //     }
                    // }).then(res1 => {
 
                    // })
                });
            },
            fetchData(flag) {
                //let machine = uni.getStorageSync('machine');
                // let orderId = uni.getStorageSync('orderId');
                // let orderNo = uni.getStorageSync('orderNo');
 
                // if (orderId) {
                //     this.orderId = orderId;
                // } else {
                //     if (!this.orderId) {
                //         this.orderId = uni.getStorageSync('id');
                //     }
 
                // }
 
                // if (orderNo) {
                //     this.orderNo = orderNo;
                // } else {
                //     if (!this.orderNo) {
                //         this.orderNo = uni.getStorageSync('daa001');
                //     }
                // }
 
                // if (machine) {
                //     this.machineNo = machine;
                // } else {
                //     if (!this.machineNo) {
                //         this.machineNo = uni.getStorageSync('machineNo');
                //     }
                // }
 
 
                if (!this.orderId && !this.orderNo) {
                    return;
                }
                this.getOrderById();
                this.getSJByOrder();
                this.getXJByOrder();
                if (flag) {
                    this.$post({
                        url: "/Womdaa/GetWomdaasByShow",
                        data: {
                            machineNo: this.machineNo
                        }
                    }).then(res => {
                        this.lineList = res.data.tbBillList;
                        this.DAA003List = res.data.tbBillList.map(item => item.daa003);
                    })
                }
            },
            formatDate(date) {
                let year = date.getFullYear(); // 获取年份
                let month = String(date.getMonth() + 1).padStart(2, '0'); // 获取月份并补零
                let day = String(date.getDate()).padStart(2, '0'); // 获取日期并补零
                return `${year}-${month}-${day}`; // 返回格式化后的字符串
            },
            getOrderById() {
                this.$post({
                    url: "/Womdaa/GetWomdaaById",
                    data: {
                        orderId: this.orderId,
                        orderNo: this.orderNo
                    }
                }).then(res => {
                    if (res.data.tbBillList == null) {
                        this.$showMessage("工单不存在或者未开工,请检查");
                        // 保证order为对象,避免模板报错
                        this.order = {
                            daa001: '',
                            moldId: '',
                            daa008: '',
                            daa004: '',
                            daa003: '',
                            daa002: '',
                            daa005: '',
                            daa011: '',
                            daa018: '',
                            machineNo: '',
                            engineeringNo: '',
                            todayOutput: 0,
                            todayRunTime: '',
                            todayFaultNum: 0,
                            cutterId,    //刀具代码
                            cutterName,  //刀具名称
                            cutterModel, //刀具规格
                            jdl: '',
                        };
                        return;
                    }
                    this.order = res.data.tbBillList;
                    uni.setStorageSync('engineeringNo', this.order.engineeringNo);
                    this.orderStatus = this.order.daa018;
                    this.collectedAmount = this.order.todayOutput;
                    if (!this.order.todayOutput) {
                        this.collectedAmount = 0;
                    }
                    this.todayRunTime = this.order.todayRunTime;
                    if (!this.order.todayRunTime) {
                        this.todayRunTime = "0";
                    }
                    //this.productionDuration = (this.order.todayOnlineTime / 3600).toFixed(2) + "h";
                    this.todayFaultNum = this.order.todayFaultNum;
                    this.utilizationRate = this.order.jdl + '%';
                    // this.startTime = this.order.workStartDate;
                    // this.endTime = this.order.workEndDate;
                    let title = this.machineNo + '号机台 工单号' + this.order.daa001 + ',已采集' + this.collectedAmount;
                    this.setTitle(title);
                })
            },
            setTitle(title) {
                // 修改页面标题的方法,uni-app中可以通过api直接设置当前页面的标题
                uni.setNavigationBarTitle({
                    title: title
                });
            },
            getSJByOrder() {
                this.$post({
                    url: "/MesQaItemsDetect02/FindSJByOrderNo",
                    data: {
                        orderNo: this.orderNo
                    }
                }).then(res => {
                    //this.order = res.data.tbBillList;
                    this.lastInitialCheck = res.data.tbBillList.fcheckDate;
                    this.initialConclusion = res.data.tbBillList.fcheckResu;
                })
            },
            getXJByOrder() {
                this.$post({
                    url: "/MesQaItemsDetect02/FindXJByOrderNo",
                    data: {
                        orderNo: this.orderNo
                    }
                }).then(res => {
                    //this.order = res.data.tbBillList;
                    this.lastPatrolCheck = res.data.tbBillList.fcheckDate;
                    this.patrolConclusion = res.data.tbBillList.fcheckResu;
                    this.patrolCount = res.data.tbBillList.xjCount;
                })
            }
        }
    }
</script>
 
<style>
    .top-order {
        margin-bottom: 1vh;
    }
 
    .refresh-btn {
        position: absolute;
        top: -11px;
        right: 21px;
        /* padding: 10px 20px; */
        cursor: pointer;
        float: right;
        background-color: #00A2E9;
        color: white;
        border: none;
        font-size: 29px;
        border-radius: 15px;
        margin-top: -23px;
        padding-left: 25px;
        padding-right: 25px;
        margin-top: 9px;
        margin-bottom: 20px;
    }
 
        .refresh-btn:hover {
            background-color: #00A2E9;
        }
 
    .form-row {
        display: flex;
        justify-content: space-between;
        margin-bottom: 1.5vh;
    }
 
    .form-item {
        width: 100%;
        padding: 4px;
        margin: 10px 10px;
    }
 
    .inp {
        float: left;
        width: 63%;
        padding: 0.5vh;
        border: 1px solid #ccc;
        border-radius: 0.5vw;
        margin-top: 0.3vh;
        font-size: 1.3vw;
        /* Larger font for inputs */
    }
 
 
    .status-block p {
        margin: 1vh 0;
        font-size: 1.5vw;
        font-weight: bold;
    }
 
    /* 卡片样式 */
    .card {
        background-color: #fff;
        border-radius: 0.8vw;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        padding: 1.5vh;
        border: 1px solid black;
        margin-top: -1vh;
        margin-bottom: 2vh;
        font-size: 1.5vw;
        /* Base font size for card content */
    }
 
    /* 卡片标题在左上角 */
    .card-header {
        position: absolute;
        top: -1vh;
        left: 2vw;
        background-color: #ffffff;
        padding: 0.5vh 1vw;
        border-radius: 0.5vw;
        font-weight: bold;
        font-size: 1.8vw;
        /* Larger font for headers */
    }
 
    .form-item label {
        float: left;
        margin-top: 8px;
        font-size: 1.5vw;
        /* Larger font for labels */
        display: inline-block;
        margin-bottom: 0.5vh;
        color: #333;
    }
 
 
    .status-row label,
    .check-row label {
        width: 30%;
        padding-right: 1vw;
        text-align: right;
        font-size: 1.5vw;
        /* Increased font for labels in status sections */
    }
 
    .status-row input,
    .check-row input {
        width: 65%;
        font-size: 1.5vw;
    }
 
    .form-row2 {
        display: flex;
        float: left;
        margin-left: -65px;
        flex-direction: column;
        margin-top: -13px;
        line-height: 48px;
        align-content: flex-start;
    }
 
    .form-row3 {
        display: flex;
        flex-direction: column;
        flex-wrap: nowrap;
        align-content: flex-start;
        justify-content: flex-start;
        align-items: flex-start;
        margin-bottom: 2.5vh
    }
 
    .form-row4 {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
    }
 
    .inp1 {
        width: 42%;
        height: 3.5em;
        font-weight: bolder;
        margin-top: -41px;
        font-size: 39px;
        text-align: center;
        color: red;
    }
 
    .inp2 {
        float: right;
        width: 220px;
        height: 220px;
        border-radius: 100%;
        text-align: center;
        margin-top: -42px;
        /*     margin-left: 37px; */
        font-size: 96px;
        background-color: #476ee1fc;
        color: #ffffff;
        margin-right: 172px;
    }
</style>