快乐的昕的电脑
2025-12-03 0e33ef271afb81adeeff152dafac744ec1a50a0c
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
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
<template>
 
    <view>
        <view class="tab-bar">
            <view class="tab-item" :class="{ active: currentTab === 7 }" @click="changeTab(7)">
                工单选择
            </view>
            <view class="tab-item" :class="{ active: currentTab === 0 }" @click="changeTab(0)">
                主界面
            </view>
            <view class="tab-item" :class="{ active: currentTab === 2 }" @click="changeTab(2)">
                上刀下刀
            </view>
            <view class="tab-item" :class="{ active: currentTab === 3 }" @click="changeTab(3)">
                调机送检
            </view>
            <view class="tab-item" :class="{ active: currentTab === 4 }" @click="changeTab(4)">
                生产报工
            </view>
            <view class="tab-item" :class="{ active: currentTab === 1 }" @click="changeTab(1)">
                开工完工
            </view>
            <view class="tab-item" :class="{ active: currentTab === 5 }" @click="changeTab(5)">
                e-SOP
            </view>
            <view class="tab-item" :class="{ active: currentTab === 6 }" @click="changeTab(6)">
                工艺参数
            </view>
            <view class="tab-item" :class="{ active: currentTab === 9 }" @click="changeTab(9)">
                设备点检
            </view>
            <!-- <view class="tab-item" :class="{ active: currentTab === 8 }" @click="changeTab(8)">
            打印机设置
        </view> -->
 
        </view>
        <view class="font"></view>
        <scroll-view class="content">
            <view v-if="currentTab === 7" class="tab-content">
                <view class="content">
                    <!--<view class="top-right">
                        <button class="refresh-btn" @click="refresh">刷新</button>
                    </view>-->
                    <view>
                        <h4>一台机台只能选择一条工单(多选默认为最后一条)</h4>
                    </view>
                    <view class="section top-section">
                        <view class="form-row align-row">
                            <input v-model="machineName"
                                   disabled="true"
                                   type="text"
                                   class="machine-name-box" />
                            <view class="form-group">
                                <label class="order-label">第一步选择工单:</label>
                                <button class="print-btn" @click="isShowTab">选择工单</button>
                            </view>
                            <view class="top-right">
                                <button class="refresh-btn" @click="refresh">刷新</button>
                            </view>
                        </view>
                    </view>
 
                    <!--          &lt;!&ndash; 中部:运行状态-->
                    <view class="section card">
                        <uni-table border stripe emptyText="暂无更多数据" @selection-change="selectionChange">
                            <uni-tr>
                                <uni-th align="center" class="th" style="color: #FFFFFF; width: 100px;">工序</uni-th>
                                <uni-th align="center" class="th" style="color: #FFFFFF; width: 200px;">工单号</uni-th>
                                <uni-th align="center" class="th" style="color: #FFFFFF; width: 150px;">产品编码</uni-th>
                                <uni-th align="center" class="th" style="color: #FFFFFF; width: 260px;">产品名称</uni-th>
                                <uni-th align="center" class="th" style="color: #FFFFFF; width: 200px;">规格</uni-th>
                                <uni-th align="center" class="th" style="color: #FFFFFF; width: 75px;">已生产数量</uni-th>
                                <uni-th align="center" class="th" style="color: #FFFFFF; width: 75px;">未生产数量</uni-th>
                                <uni-th align="center" class="th" style="color: #FFFFFF; width: 75px;">派工数量</uni-th>
                                <!--<uni-th align="center" class="th" style="color: #FFFFFF; width: 70px;">工单数量</uni-th>-->
                                <uni-th align="center" class="th" style="color: #FFFFFF; width: 90px;">工单状态</uni-th>
                                <uni-th align="center" class="th" style="color: #FFFFFF; width: 90px;">报工人</uni-th>
                                <uni-th align="center" class="th" style="color: #FFFFFF; width: 90px;">选择</uni-th>
                            </uni-tr>
                            <uni-tr v-for="(item, index) in isShowTableData" :key="index">
                                <uni-td align="center">
                                    <input class="form-input" disabled="true" type="text" v-model="item.procName" /><!--工序-->
                                </uni-td>
                                <uni-td align="center">
                                    <div class="form-input">{{ item.daa001 }}</div><!--工单号-->
                                </uni-td>
                                <uni-td align="center">
                                    <div class="form-input">{{ item.daa002 }}</div><!--产品编码-->
                                </uni-td>
                                <uni-td align="center">
                                    <div class="form-input">{{ item.daa003 }}</div><!--产品名称-->
                                </uni-td>
                                <uni-td align="center">
                                    <div class="form-input">{{ item.daa004 }}</div><!--规格-->
                                </uni-td>
                                <uni-td align="center">
                                    <input class="form-input" disabled="true" type="text" v-model="item.daa011" /><!--已生产数量-->
                                </uni-td>
                                <uni-td align="center">
                                    <input class="form-input" disabled="true" type="text" :value="(item.daa008 || 0) - (item.daa011 || 0)" /><!--未生产数量-->
                                </uni-td>
                                <uni-td align="center">
                                    <input class="form-input" disabled="true" type="text" v-model="item.daa008" /><!--派工数量-->
                                </uni-td>
                                <!--<uni-td align="center">
        <input class="form-input" disabled="true" type="text" v-model="item.daa008" />-->
                                <!--工单数量-->
                                <!--</uni-td>-->
                                <uni-td align="center">
                                    <input class="form-input" disabled="true" type="text" v-model="item.daa018" /><!--工单状态-->
                                </uni-td>
                                <uni-td align="center">
                                    <input class="form-input" disabled="true" type="text" v-model="item.staffName" /><!--报工人-->
                                </uni-td>
                                <uni-td>
                                    <view class="uni-group">
                                        <button class="select-btn" type="default" @click="toDetail(item)">
                                            选择
                                        </button>
                                    </view>
                                </uni-td>
                            </uni-tr>
                        </uni-table>
                    </view>
 
                    <view class="bottom-section">
                        <button class="cancel-btn" @click="cancel">清空重选</button>
                    </view>
 
                    <view>
                        <!--<text style="color: red;">
                        说明:只能同时开工一个工单。选择完成,点击保存选择。系统保留选中的工单。
                        如果要重选,点击清空重选功能。
                    </text>-->
                    </view>
                </view>
            </view>
            <view v-if="currentTab === 0" class="tab-content">
                <WorkOrder :orderId="orderId" :orderNo="selectedOrder" :machineNo="machineNo"
                           :deviceNumber="machineName" />
            </view>
            <view v-if="currentTab === 1" class="tab-content">
                <!--        &lt;!&ndash; 调用 WorkOrderStatus 组件 &ndash;&gt;-->
                <WorkOrderStatus :orderId="orderId" :orderNo="selectedOrder" :machineNo="machineNo" />
            </view>
            <view v-if="currentTab === 2" class="tab-content">
                <!--        &lt;!&ndash; 调用 mold 组件 &ndash;&gt;-->
                <mold :orderId="orderId" :orderNo="selectedOrder" :machineNo="machineNo" />
            </view>
            <view v-if="currentTab === 3" class="tab-content">
                <!--        &lt;!&ndash; 调用 mold 组件 &ndash;&gt;-->
                <machine :orderId="orderId" :orderNo="selectedOrder" :machineNo="machineNo" />
            </view>
            <view v-if="currentTab === 4" class="tab-content">
                <!--  调用 mold 组件 -->
                <WorkOrderPrint :orderId="orderId" :orderNo="selectedOrder" :machineNo="machineNo" />
            </view>
            <view v-if="currentTab === 8" class="tab-content">
                <!-- 调用 mold 组件 -->
                <PrintInit :orderId="orderId" :orderNo="selectedOrder" :machineNo="machineNo" />
            </view>
            <view v-if="currentTab === 5" class="tab-content">
                <PDFShow :orderId="orderId" :orderNo="selectedOrder" :machineNo="machineNo" />
            </view>
            <view v-if="currentTab === 6" class="tab-content">
                <Technology :orderId="orderId" :orderNo="selectedOrder" :machineNo="machineNo" />
            </view>
            <view v-if="currentTab === 9" class="tab-content">
                <!-- 设备点检视图 -->
                <EquipmentInspection :machineNo="machineNo" />
            </view>
        </scroll-view>
 
 
        <!-- 弹窗下拉框只显示工单状态 -->
        <view v-if="isShow" class="overlay">
            <view class="popup">
                <view class="form-row">
                    <view style="display: flex; align-items: center;">
                        <label style="float: left;margin-top: 18px;">点击按钮筛选工单状态:</label>
                        <superwei-combox :candidates="engineeringNoMapList" placeholder="请选择" v-model="engineeringNo"
                                         @select="onEngineeringNoChange" class="picker"
                                         style="padding: 7px 46px;width: 650px;"></superwei-combox>
                        <span style="margin-left: 20px; color: #ff6600; font-size: 18px;">多选时只保留最后一条工单</span>
                    </view>
                </view>
 
                <div style="height: 400px; overflow: auto;">
                    <table>
 
                        <view class="section card">
                            <uni-table ref="table" type="selection" border stripe emptyText="暂无更多数据"
                                       class="large-selection-table" @selection-change="selectionChange">
                                <uni-tr>
                                    <uni-th align="center" class="th" style="color: #FFFFFF; width: 170px;">工序</uni-th>
                                    <uni-th align="center" class="th" style="color: #FFFFFF; width: 490px;">工单号</uni-th>
                                    <uni-th align="center" class="th" style="color: #FFFFFF; width: 250px;">产品编码</uni-th>
                                    <uni-th align="center" class="th" style="color: #FFFFFF; width: 260px;">产品名称</uni-th>
                                    <uni-th align="center" class="th" style="color: #FFFFFF; width: 260px;">规格</uni-th>
                                    <uni-th align="center" class="th" style="color: #FFFFFF; width: 80px;">已生产数量</uni-th>
                                    <uni-th align="center" class="th" style="color: #FFFFFF; width: 80px;">未生产数量</uni-th>
                                    <uni-th align="center" class="th" style="color: #FFFFFF; width: 80px;">派工数量</uni-th>
                                    <!--<uni-th align="center" class="th" style="color: #FFFFFF; width: 80px;">工单数量</uni-th>-->
                                    <uni-th align="center" class="th" style="color: #FFFFFF; width: 100px;">工单状态</uni-th>
                                    <uni-th align="center" class="th" style="color: #FFFFFF; width: 100px;">报工人</uni-th>
                                    <!--<uni-th align="center" class="th" style="color: #FFFFFF; width: 100px;">选择</uni-th>-->
                                </uni-tr>
                                <uni-tr v-for="(item, index) in tableData"
                                        :key="index"
                                        :class="{'row-selected': selectedIndexs.includes(index)}"
                                        @click="onRowClick(index)"
                                        style="cursor: pointer;">
                                    <uni-td align="center">
                                        <input class="form-input" disabled="true" type="text" v-model="item.procName" /><!--工序-->
                                    </uni-td>
                                    <uni-td align="center">
                                        <div class="form-input">{{ item.daa001 }}</div>
                                    </uni-td>
                                    <uni-td align="center">
                                        <div class="form-input">{{ item.daa002 }}</div>
                                    </uni-td>
                                    <uni-td align="center">
                                        <div class="form-input">{{ item.daa003 }}</div>
                                    </uni-td>
                                    <uni-td align="center">
                                        <div class="form-input">{{ item.daa004 }}</div><!--规格-->
                                    </uni-td>
                                    <uni-td align="center">
                                        <input class="form-input" disabled="true" type="text" v-model="item.daa011" /><!--已生产数量-->
                                    </uni-td>
                                    <uni-td align="center">
                                        <input class="form-input" disabled="true" type="text" :value="(item.daa008 || 0) - (item.daa011 || 0)" /><!--未生产数量-->
                                    </uni-td>
                                    <uni-td align="center">
                                        <input class="form-input" disabled="true" type="text" v-model="item.daa008" /><!--派工数量-->
                                    </uni-td>
                                    <!--<uni-td align="center">
        <input class="form-input" disabled="true" type="text" v-model="item.daa008" />-->
                                    <!--工单数量-->
                                    <!--</uni-td>-->
                                    <uni-td align="center">
                                        <input class="form-input" disabled="true" type="text" v-model="item.daa018" /><!--工单状态-->
                                    </uni-td>
                                    <uni-td align="center">
                                        <input class="form-input" disabled="true" type="text" v-model="item.staffName" /><!--报工人-->
                                    </uni-td>
                                </uni-tr>
                            </uni-table>
                        </view>
 
                    </table>
                </div>
 
                <view class="bottom-section">
                    <button class="save-btn" @click="save">保存选择</button>
                    <button class="cancel-btn" @click="isShow = !isShow">取消</button>
                </view>
            </view>
        </view>
    </view>
</template>
 
<script>
import WorkOrderStatus from '../components/WorkOrderStatus.vue'; // 确保路径正确
import UniTable from "../uni_modules/uni-table/components/uni-table/uni-table.vue";
import Mold from "../components/mold.vue";
import Machine from "../components/machine.vue";
import WorkOrderPrint from "../components/WorkOrderPrint.vue";
import WorkOrder from "../components/WorkOrder.vue";
import Technology from "../components/Technology.vue";
import PDFShow from "../components/PDFShow.vue";
import PrintInit from "../components/PrintInit.vue";
import PrintTest from "../components/PrintTest.vue";
import EquipmentInspection from "../components/EquipmentInspection.vue";
 
    export default {
        components: {
            Technology,
            WorkOrder,
            WorkOrderPrint,
            Machine,
            Mold,
            UniTable,
            WorkOrderStatus,
            PDFShow,
            PrintInit,
            PrintTest,
            EquipmentInspection
        },
        data() {
            return {
                orderStatus: '', // 默认全部
                currentTab: 7,
 
                productCode: '', // 产品编码
                productSpec: '', // 产品规格
 
                machineList: [],
 
                machine: [],
 
                engineeringNoList: [],
                engineeringNoMapList: [],
                engineeringNo: '',
 
                machineNo: '',
                machineName: '',
 
                tableData: [],
                isShowTableData: [],
 
                orderStatus: '开工',
                selectedOrder: '',
                orderId: 0,
 
                selectedIndexs: [],
 
                isShow: false,
            };
        },
        created() {
 
            //调试使用的代码
            // this.machineNo = uni.getStorageSync('machineNo');
            // this.machineName = uni.getStorageSync('machineName');
            //
            // if (this.machineNo) {
            //   this.getWomdaaIsShow();
            // }
 
            uni.clearStorageSync();
            
            this.checkForUpdate();
            
            //工控机使用的代码
            this.getPrintInfo();
            
        },
        onLoad(options) {
            this.getMachineList();
        },
        onShow() {
            this.refresh();
        },
        methods: {
            onRowClick(index) {
                this.selectedIndexs = [index]; // 单选
                // 手动触发 selectionChange 以同步复选框
                this.selectionChange({ detail: { index } });
            },
            checkForUpdate() {
                this.$post({
                    url: "/DevMachine/getAppUpgradeInfo",
                    data: {}
                }).then(res => {
                    
                    let newVersion = res.data.version;
                    let currentVersion = uni.getSystemInfoSync(); // 获取当前 APK 版本号
                     
                    if (newVersion > currentVersion.appVersion) {
                        uni.showModal({
                            title: "发现新版本",
                            content: "是否下载最新版本?",
                            success: (modalRes) => {
                                if (modalRes.confirm) {
                                    this.downloadNewApk(res.data.apkUrl);
                                }
                            }
                        });
                        //this.downloadNewApk(res.data.apkUrl);
                        this.updateChecked = true; // 标记更新已检查过
                        //      // 如果有新版本,开始下载
                        //download(res.data.apkUrl);
                    }
                })
                
            },
            
            downloadNewApk(apkUrl) {
                uni.showToast({
                    title: "开始下载更新...",
                    icon: "none",
                    duration: 2000
                });
            
                uni.downloadFile({
                    url: apkUrl,
                    success: (res) => {
                        if (res.statusCode === 200) {
                            plus.runtime.install(res.tempFilePath, {
                                force: true
                            }, function() {
                                console.log("安装成功,重启应用");
                                //plus.runtime.restart();
                                //plus.runtime.quit();
                                // uni.navigateBack()
                            }, function(e) {
                                console.error("安装失败:", e);
                            });
                        }
                    },
                    fail: (err) => {
                        console.error("下载失败:", err);
                        uni.showToast({
                            title: "下载失败,请检查网络",
                            icon: "none",
                            duration: 2000
                        });
                    }
                });
            },
            
            refresh() {
                this.getMachineList();
                this.getPrintInfo();
                this.getWomdaaIsShow();
            },
            getPrintInfo() {
                var mac = "";
                
                mac = "74:24:ca:4f:b7:9b";
                this.$post({
                    url: "/DevMachine/GetDevMachineByPdaMac",
                    data: {
                        pdaMac: mac,
                    }
                }).then(res => {
                    let devMachine = res.data.tbBillList;
                    this.machineNo = devMachine.machineNo;
                    this.machineName = "调试模式:" + this.machineNo + "号齿轮机"
 
                    uni.setStorageSync('machineNo', this.machineNo);
                    uni.setStorageSync('printMac', devMachine.printMac);
 
                    console.log(devMachine.printMac);
 
                    this.getWomdaaIsShow();
                });
                return;
                
                
                 if (plus.os.name == "Android") {
                     //获取手机MAC地址
                     var Context = plus.android.importClass("android.content.Context");
                     var WifiManager = plus.android.importClass("android.net.wifi.WifiManager");
                     var wifiManager = plus.android.runtimeMainActivity().getSystemService(Context.WIFI_SERVICE);
                     var WifiInfo = plus.android.importClass("android.net.wifi.WifiInfo");
                     var wifiInfo = wifiManager.getConnectionInfo();
                     mac = wifiInfo.getMacAddress();
                    
                     //如果mac为“02:00:00:00:00:00”,则可能是安卓6.0以上版本,则使用另一种方法获取mac地址
                     if (mac == "02:00:00:00:00:00") {
                         mac = this.getMacNew();
                     }
                     //如果mac使用新方法依然是“02:00:00:00:00:00”则不进行保存
                     if (mac == "02:00:00:00:00:00") {
                         return;
                     }
                     uni.setStorageSync('pdaMac', mac);
 
                     this.$post({
                         url: "/DevMachine/GetDevMachineByPdaMac",
                         data: {
                             pdaMac: mac,
                         }
                     }).then(res => {
                         let devMachine = res.data.tbBillList;
                         this.machineNo = devMachine.machineNo;
                         this.machineName = "当前机台:" + this.machineNo + "号齿轮机";
 
                         uni.setStorageSync('machineNo', this.machineNo);
                         uni.setStorageSync('printMac', devMachine.printMac);
 
 
                         this.getWomdaaIsShow();
 
                     });
                 }
            },
            save() {
                let data = this.selectedItems();
 
                if (data.length === 0) {
                    this.$showMessage("请选择一个工单");
                    return;
                }
 
                if (data.length > 1) {
                    this.$showMessage("一次只能选取一个工单");
                    return;
                }
 
                //let firstValue = data[0]["moldId"]; // 获取第一个对象的指定属性值
 
                //// 使用 every 方法检查所有对象的该属性值是否一致
                //let flag = data.every(item => item["moldId"] === firstValue);
                //if (!flag) {
                //    this.$showMessage("选取的" + data.length + "个工单中的模具编号不一致");
                //    return;
                //}
 
                let orderSelect = [];
 
                data.forEach(s => {
                    let entity = {
                        orderId: s.id,
                        orderNo: s.daa001,
                    }
                    orderSelect.push(entity);
                });
 
                let editDate = this.formatDate(new Date());
 
                this.$post({
                    url: "/MesOrderSelect/Add",
                    data: {
                        machineNo: this.machineNo,
                        editDate: editDate,
                        item: orderSelect
                    }
                }).then(res => {
                    if (res.data.tbBillList) {
                        this.getWomdaaIsShow();
                        uni.showToast({
                            title: '保存工单成功',
                            //title: '将注塑机开合模数清0',
                            //将值设置为 success 或者直接不用写icon这个参数
                            icon: 'success',
                            //显示持续时间为 5秒
                            duration: 5000
                        });
                    }
                    this.isShow = false;
                })
 
            },
            getMacNew() {
                var str = "";
                try {
                    if (plus.os.name == "Android") {
                        var NetworkInterface = plus.android.importClass("java.net.NetworkInterface");
                        var networkInterface = NetworkInterface.getByName("wlan0");
                        var bytes = networkInterface.getHardwareAddress();
            
                        //将byte[] 转换成 String
                        for (var i = 0; i < bytes.length; i++) {
                            var tmp = "";
                            var num = bytes[i];
                            if (num < 0) {
                                tmp = (255 + num + 1).toString(16);
                            } else {
                                tmp = num.toString(16);
                            }
                            if (tmp.length == 1) {
                                tmp = "0" + tmp;
                            }
                            str += (i == 0) ? (tmp) : (":" + tmp);
                        }
                    }
                } catch (err) {
                    str = "02:00:00:00:00:00";
                }
                return str;
            },
 
            cancel() {
                if (!this.machineNo) {
                    return;
                }
 
                // 直接用 flag 判断
                if (this.hasBindedCutterFlag) {
                    uni.showToast({
                        title: '当前工单已绑定刀具,不能清空重选',
                        icon: 'error',
                        duration: 2000
                    });
                    return;
                }
 
                let editDate = this.formatDate(new Date());
                this.selectedIndexs = [];
 
                this.$post({
                    url: "/MesOrderSelect/Remove",
                    data: {
                        machineNo: this.machineNo,
                        editDate: editDate
                    },
                }).then(res => {
                    if (res.data.tbBillList > 0) {
                        this.isShowTableData = [];
                    }
                });
            },
 
            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}`; // 返回格式化后的字符串
            },
            selectionChange(e) {
                // 单选直接赋值
                this.selectedIndexs = [e.detail.index];
            },
 
            selectedItems() {
                return this.selectedIndexs.map(i => this.tableData[i])
            },
 
 
            changeTab(index) {
                this.currentTab = index;
                // 当切换到工单选择页面(index === 7)时自动刷新
                if (index === 7) {
                    this.refresh();
                }
                console.log(index);
            },
            onMachineChange(event) {
 
                this.machineName = event;
 
                this.machineNo = this.machine[this.machineList.indexOf(event)].machineNo;
 
                uni.clearStorageSync();
 
                uni.setStorageSync('machineNo', this.machineNo);
                uni.setStorageSync('machineName', this.machineName);
 
                this.getWomdaaIsShow();
            },
            onEngineeringNoChange(event) {
 
                let orde = this.engineeringNoList[this.engineeringNoMapList.indexOf(event)];
 
                this.engineeringNo = orde.moldId;
 
                this.getWomdaa();
 
            },
            getMachineList() {
                this.$post({
                    url: "/MesMachine/GetInjectionMachine",
                }).then(res => {
                    this.machine = res.data.tbBillList;
                    this.machineList = this.machine.map(s => s.machineName);
                })
            },
            //获取表格的数据源
            getWomdaaIsShow() {
                this.$post({
                    url: "/Womdaa/GetWomdaasByShow",
                    data: {
                        machineNo: this.machineNo,
                    }
                }).then(res => {
                    this.isShowTableData = res.data.tbBillList;
 
                    // 只判断第一条(只允许一条工单)
                    const order = this.isShowTableData[0];
                    let hasBindedCutter = false;
                    if (order) {
                        hasBindedCutter =
                            (order.outToolId && order.outToolId.toString().trim() !== '') ||
                            (order.outToolCode && order.outToolCode.trim() !== '') ||
                            (order.outToolName && order.outToolName.trim() !== '');
                    }
                    // 存储到 data 变量
                    this.hasBindedCutterFlag = hasBindedCutter;
 
                    if (this.isShowTableData.length == 1) {
                        uni.setStorageSync('daa001', this.isShowTableData[0].daa001);
                        uni.setStorageSync('id', this.isShowTableData[0].id);
                    }
                });
            },
 
            isShowTab() {
                if (this.isShowTableData.length > 0) {
                    uni.showToast({
                        title: '已有正在操作的工单,不能再次选择',
                        icon: 'error',
                        duration: 2000
                    });
                    return;
                }
 
                this.isShow = true;
                // 默认选中“待开工”
                this.engineeringNo = '待开工、未开工、暂停';
                this.tableData = [];
                // 下拉框只显示合并后的状态和其它状态
                this.engineeringNoMapList = [
                    '待开工、未开工、暂停',
                    '开工',
                    '完工'
                ];
                // 默认显示“待开工”工单
                this.getWomdaaByStatus();
            },
            // 下拉框选中后,按状态筛选工单
            onEngineeringNoChange(status) {
                this.engineeringNo = status;
                this.getWomdaaByStatus();
            },
            getWomdaa() {
 
                let editDate = this.formatDate(new Date());
 
                this.$post({
                    url: "/Womdaa/GetWomdaasByMachine",
                    data: {
                        machineNo: this.machineNo,
                        editDate: editDate
                    }
                }).then(res => {
                    this.tableData = res.data.tbBillList;
                })
            },
            // 按工单状态筛选工单
            getWomdaaByStatus() {
                let editDate = this.formatDate(new Date());
                let statusArr = [];
                if (this.engineeringNo === '待开工、未开工、暂停') {
                    statusArr = ['待开工', '未开工', '暂停'];
                } else {
                    statusArr = [this.engineeringNo];
                }
                this.$post({
                    url: "/Womdaa/GetWomdaasByEngineeringNo",
                    data: {
                        machineNo: this.machineNo,
                        orderStatus: statusArr,
                        editDate: editDate
                    }
                }).then(res => {
                    this.tableData = res.data.tbBillList;
                });
            },
            toDetail(item) {
                this.orderId = item.id;
                this.selectedOrder = item.daa001;
                this.productCode = item.daa002; // 产品编码
                this.productSpec = item.daa004; // 产品规格
                this.currentTab = 0;
            }
        },
        computed: {}
    };
</script>
 
<style lang="scss">
 
    :deep(.checkbox),
    :deep(.checkbox__inner) {
        width: 60px !important;
        height: 60px !important;
        min-width: 60px !important;
        min-height: 60px !important;
        padding: 16px !important;
        margin-right: 20px !important;
    }
 
    .popup .large-selection-table {
        width: 100% !important;
        table-layout: auto !important; // 让表格自动分配宽度
    }
 
    .row-selected {
        background-color: #e0f3ff !important;
    }
 
    .font {
        background-color: #666666;
        height: 30px;
        width: 100vw;
    }
 
 
    /* 上部区域样式,左70% 右30% */
    .top-section {
        display: flex;
        justify-content: space-around;
        margin-bottom: 20px;
        padding: 20px 10px;
        flex-direction: row;
        flex-wrap: wrap;
        align-content: center;
        align-items: stretch;
        /* 增加上下的padding */
    }
 
    .right-side {
        background-color: #f3f3f3;
        padding: 16px;
        text-align: center;
        border-radius: 8px;
        width: 25%;
        font-size: 14px;
    }
 
    .form-row {
        display: flex;
        justify-content: space-between;
        margin-bottom: 1.2vh;
    }
 
    .form-item {
        width: 30%;
    }
 
    .inp {
        width: 90%;
        padding: 4px;
        border: 1px solid #ccc;
        border-radius: 4px;
        margin-top: 4px;
    }
 
    .status-block {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
 
    .status-block p {
        margin: 8px 0;
        font-size: 16px;
        font-weight: bold;
    }
 
    .left-side {
        width: 65%;
    }
 
    .table-row {
        display: flex;
        justify-content: space-between;
        padding: 8px;
        border: 1px solid #000000;
        font-size: 20px;
        font-weight: bold;
    }
 
    .table-cell {
        width: 50%;
        text-align: center;
    }
 
    /* 卡片样式 */
    .card {
        background-color: #fff;
        border-radius: 10px;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        padding: 0; // 去除多余内边距
        position: relative;
        margin-bottom: 25px;
        width: 100%; // 填满父容器
        box-sizing: border-box;
    }
 
/*    //.content {
    //    flex: 1;
    //    padding: 1vh 1vw; // 保证整体有左右留白
    //    background-color: white;
    //    font-size: 1.5vw;
    //}*/
 
    /* 卡片标题在左上角 */
    .card-header {
        position: absolute;
        top: -10px;
        left: 16px;
        background-color: #ffffff;
        padding: 2px 8px;
        border-radius: 4px;
        font-weight: bold;
    }
 
    /* 中部区域,每行3个字段 */
    .status-row,
    .check-row {
        display: flex;
        justify-content: space-between;
        margin-bottom: 10px;
    }
 
    .status-row label,
    .check-row label {
        width: 30%;
        padding-right: 10px;
        text-align: right;
    }
 
    .status-row input,
    .check-row input {
        width: 65%;
    }
 
    //基础样式
    .container {
        display: flex;
        flex-direction: column;
    }
 
    .tab-bar {
        display: flex;
        justify-content: space-around;
        background-color: #f5f5f5;
        padding: 1vh;
        padding-top: 30px;
        border-bottom: 1px solid #ccc;
    }
 
    .top-right {
        position: absolute;
        top: 10px;
        right: 50px;
        z-index: 1000;
    }
 
    .refresh-btn {
        padding: 10px;
        background-color: #00A2E9;
        color: white;
        border: none;
        font-size: 1.5vw;
        border-radius: 5px;
    }
 
    .tab-item {
        flex: 1;
        text-align: center;
        margin-right: 0.5vw;
        padding: 1vh;
        border-radius: 0.5vw;
        background-color: #fff;
        color: #007aff;
        cursor: pointer;
        font-size: 1.8vw;
        /* Increased font size */
        transition: background-color 0.3s, color 0.3s;
    }
 
    .tab-item.active {
        background-color: #007aff;
        color: #fff;
        font-weight: bold;
    }
 
    .content {
        flex: 1;
        padding: 1vh 1vw;
        background-color: white;
        font-size: 1.5vw;
        /* Increased font size for content */
    }
 
    .picker {
        float: left;
        margin-top: 7px;
        margin-left: 10px;
        text-align: center;
        font-size: 32px !important; // 强制大字体,适配低密度
        min-height: 60px; // 让选择框高度也变大
        line-height: 60px;
        padding: 5.5px 1px;
        background-color: #fff; // 这里改为蓝色
        border: 2px solid #007aff; // 边框也改为蓝色
        color: #007aff; // 字体颜色改为白色,保证可读性
        border-radius: 6px;
        transition: background 0.2s;
    }
 
    .th {
        background-color: lightskyblue;
        height: 6vh;
        font-size: 2vw;
        font-size: 2.6vw; /* 字体更大 */
        /* Increased font size for table headers */
    }
 
    .form-input {
        word-break: break-all;
        white-space: normal;
        line-height: 1.4;
        text-align: center;
        vertical-align: middle;
        max-width: 180px;
        overflow-wrap: break-word;
        font-size: 1.8vw;
    }
 
    /* 底部保存和取消按钮 */
    .bottom-section {
        display: flex;
        justify-content: space-around;
        margin-bottom: 2vh;
        padding: 2vh 1vw;
        margin-top: 160px; // 原来是40px,改成80px,按钮整体下移
    }
 
    .save-btn,
    .cancel-btn {
        width: 48%;
        padding: 1.5vh;
        background-color: #00a2e9;
        color: white;
        font-size: 1.8vw;
        /* Increased button font size */
        border: none;
        text-align: center;
        cursor: pointer;
    }
 
    .overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        display: flex;
        justify-content: center;
        align-items: center;
        z-index: 2000; // 增加z-index,确保弹窗在刷新按钮之上
    }
 
    .popup {
        background-color: #fff;
        padding: 2vh;
        border: 1px solid #ccc;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        width: 98vw; // 原来是 90vw,改成 98vw
        height: 85vh;
        font-size: 1.6vw;
    }
 
    .print-btn {
        float: left;
        margin-top: 4px;
        margin-left: 10px;
        text-align: center;
        font-size: 100%;
        color: black;
        padding: 0px 90px;
        border: 2px solid #ccc;
        cursor: pointer;
        border-radius: 0.8vw;
    }
 
    .machine-name-box {
        border: 2px solid #007aff; /* 蓝色边框 */
        border-radius: 8px;
        font-family: fantasy;
        font-size: 33px;
        margin-top: 20px;
        padding: 15px 28px; /* 上下20px,左右48px,增加内边距 */
        width: 300px; /* 更宽,保证内容完整显示 */
        height: 70px; /* 增加高度 */
        box-sizing: border-box;
        background: #fff;
        color: #222;
        font-weight: bold;
        text-align: left;
        display: block;
    }
 
/*    //v-deep .checkbox {
    //    padding: 10 10px;
    //    width: 26px;
    //    padding-left: 12px;
    //    display: table-cell;
    //    vertical-align: middle;
    //    color: #333;
    //    font-weight: 500;
    //    border-bottom: 1px #ebeef5 solid;
    //    font-size: 14px;
    //}*/
 
    @media screen and (max-width: 1920px) {
        .tab-item {
            font-size: 1.6vw;
        }
 
        .content {
            padding: 1vw;
            font-size: 1.5vw;
        }
 
        .form-input {
            font-size: 1.6vw;
        }
    }
 
    .uni-td,
    td {
        white-space: normal !important; // 允许自动换行
        word-break: break-all !important; // 单词/中文都能断行
        line-height: 1.4; // 行高适当,便于多行显示
        text-align: center; // 居中显示(如需左对齐可改为 left)
        vertical-align: middle; // 垂直居中
        max-width: 180px; // 保持单元格最大宽度
        overflow-wrap: break-word; // 兼容性更好
    }
 
    // 放大弹窗内表格字体(表头和内容)
    .popup .large-selection-table,
    .popup .large-selection-table .uni-th,
    .popup .large-selection-table .uni-td,
    .popup .large-selection-table input.form-input {
        font-size: 2.2vw !important; // 可根据实际需求调整
    }
 
    .select-btn {
        width: 180px; // 更宽
        height: 80px; // 更高
        font-size: 1.8vw; // 字体也略大
        border-radius: 10px;
        background-color: #f5f5f5;
        color: #007aff;
        border: 2px solid #007aff;
        margin: 0 auto;
        display: block;
    }
 
    .top-section {
        position: relative;
        display: flex;
        flex-direction: column;
        margin-bottom: 20px;
        padding: 20px 10px;
    }
 
    .form-row.align-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: relative;
        width: 100%;
    }
 
    .machine-name-box {
        flex: 1 1 45%;
        margin-right: 20px;
    }
 
    .form-group {
        display: flex;
        align-items: center;
        flex: 1 1 45%;
        justify-content: flex-start;
    }
 
    .order-label {
        font-family: fantasy;
        font-size: 33px;
        margin-top: 20px;
        margin-right: 10px;
        float: none;
    }
 
    .print-btn {
        margin-top: 20px;
    }
 
    .top-right {
        position: absolute;
        top: -30px; // 往上移
        right: 0;
        z-index: 1000;
    }
 
/* 放大表头和表格内容字体 */
    .th,
    .uni-th,
    th {
        font-size: 1.7vw !important;
        font-weight: bold;
        letter-spacing: 2px;
    }
 
    /* 针对1280x800的平板使用媒体查询进行适配 */
    @media screen and (min-width: 1280px) and (max-width: 1920px) {
        .right-side {
            width: 30%;
        }
 
        .save-btn,
        .cancel-btn {
            font-size: 1.6vw;
        }
 
        .inp {
            width: 85%;
            font-size: 20px;
        }
 
        .status-block p {
            font-size: 20px;
        }
 
        .uni-tr,
        .uni-td {
            font-size: 20px;
        }
    }
 
</style>