gaoluyang
2025-09-16 2208346bff099670f2ab8608f2f774caa76d867e
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
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
<template>
  <view class="sales-account">
    <!-- 使用通用页面头部组件 -->
    <PageHeader title="标准作业指导" @back="goBack" />
    
    <!-- 任务信息卡片 -->
    <view class="task-info-card">
      <view class="task-header">
        <view class="task-left">
          <view class="task-icon">
            <up-icon name="file-text" size="20" color="#ffffff"></up-icon>
          </view>
          <view class="task-details">
            <text class="task-title">{{ currentTask.deviceName }}</text>
            <text class="task-subtitle">{{ currentTask.taskType }} - {{ currentTask.priority }}</text>
          </view>
        </view>
        <view class="task-status">
          <u-tag :type="getStatusType(currentTask.status)" size="small">
            {{ getStatusText(currentTask.status) }}
          </u-tag>
        </view>
      </view>
      
      <view class="task-meta">
        <view class="meta-item">
          <text class="meta-label">设备编号:</text>
          <text class="meta-value">{{ currentTask.deviceCode }}</text>
        </view>
        <view class="meta-item">
          <text class="meta-label">故障描述:</text>
          <text class="meta-value">{{ currentTask.faultDescription }}</text>
        </view>
        <view class="meta-item">
          <text class="meta-label">预计工时:</text>
          <text class="meta-value">{{ currentTask.estimatedHours }}小时</text>
        </view>
      </view>
    </view>
    
    <!-- 功能导航 -->
    <view class="nav-tabs">
      <view 
        v-for="(tab, index) in tabs" 
        :key="index"
        class="nav-tab"
        :class="{ active: activeTab === tab.key }"
        @click="switchTab(tab.key)"
      >
        <up-icon :name="tab.icon" size="18" :color="activeTab === tab.key ? '#2979ff' : '#666'"></up-icon>
        <text class="tab-text" :class="{ active: activeTab === tab.key }">{{ tab.label }}</text>
      </view>
    </view>
    
    <!-- SOP标准作业程序 -->
    <view v-if="activeTab === 'sop'" class="content-section">
      <view class="section-header">
        <text class="section-title">标准作业程序</text>
        <view class="progress-info">
          <text class="progress-text">{{ completedSteps }}/{{ sopSteps.length }}</text>
          <up-icon name="checkmark-circle" size="16" color="#4caf50" v-if="completedSteps === sopSteps.length"></up-icon>
        </view>
      </view>
      
      <view class="sop-steps">
        <view 
          v-for="(step, index) in sopSteps" 
          :key="step.id"
          class="sop-step"
          :class="{ completed: step.completed, current: currentStepIndex === index }"
        >
          <view class="step-header" @click="toggleStep(index)">
            <view class="step-number">
              <text v-if="!step.completed" class="step-num">{{ index + 1 }}</text>
              <up-icon v-else name="checkmark" size="14" color="#ffffff"></up-icon>
            </view>
            <view class="step-content">
              <text class="step-title">{{ step.title }}</text>
              <text class="step-duration">预计{{ step.duration }}分钟</text>
            </view>
            <view class="step-toggle">
              <up-icon 
                :name="step.expanded ? 'arrow-up' : 'arrow-down'" 
                size="16" 
                color="#999"
              ></up-icon>
            </view>
          </view>
          
          <view v-if="step.expanded" class="step-details">
            <view class="step-description">
              <text class="desc-text">{{ step.description }}</text>
            </view>
            
            <view v-if="step.warnings.length > 0" class="step-warnings">
              <text class="warning-title">⚠️ 注意事项</text>
              <view v-for="warning in step.warnings" :key="warning" class="warning-item">
                <text class="warning-text">• {{ warning }}</text>
              </view>
            </view>
            
            <view v-if="step.tools.length > 0" class="step-tools">
              <text class="tools-title">🔧 所需工具</text>
              <view class="tools-list">
                <u-tag 
                  v-for="tool in step.tools" 
                  :key="tool"
                  type="info"
                  size="mini"
                  class="tool-tag"
                >
                  {{ tool }}
                </u-tag>
              </view>
            </view>
            
            <view class="step-actions">
              <u-button 
                v-if="!step.completed"
                type="success"
                size="small"
                @click="completeStep(index)"
              >
                完成此步骤
              </u-button>
              <u-button 
                v-else
                type="info"
                size="small"
                plain
                @click="uncompleteStep(index)"
              >
                取消完成
              </u-button>
            </view>
          </view>
        </view>
      </view>
    </view>
    
    <!-- 配件清单 -->
    <view v-if="activeTab === 'parts'" class="content-section">
      <view class="section-header">
        <text class="section-title">配件清单</text>
        <view class="parts-summary">
          <text class="summary-text">共{{ partsList.length }}项配件</text>
        </view>
      </view>
      
      <view class="parts-list">
        <view v-for="part in partsList" :key="part.id" class="part-item">
          <view class="part-header">
            <view class="part-info">
              <text class="part-name">{{ part.name }}</text>
              <text class="part-spec">{{ part.specification }}</text>
            </view>
            <view class="part-status">
              <u-tag 
                :type="part.available ? 'success' : 'error'"
                size="mini"
              >
                {{ part.available ? '库存充足' : '库存不足' }}
              </u-tag>
            </view>
          </view>
          
          <view class="part-details">
            <view class="detail-row">
              <text class="detail-label">配件编号:</text>
              <text class="detail-value">{{ part.partNumber }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">需要数量:</text>
              <text class="detail-value">{{ part.requiredQuantity }}{{ part.unit }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">库存数量:</text>
              <text class="detail-value" :class="{ danger: !part.available }">
                {{ part.stockQuantity }}{{ part.unit }}
              </text>
            </view>
            <view class="detail-row">
              <text class="detail-label">存放位置:</text>
              <text class="detail-value">{{ part.location }}</text>
            </view>
          </view>
          
          <view class="part-actions">
            <u-button 
              type="primary"
              size="small"
              plain
              @click="requestPart(part)"
              :disabled="part.available"
            >
              申请配件
            </u-button>
            <u-button 
              type="info"
              size="small"
              plain
              @click="viewPartDetail(part)"
            >
              查看详情
            </u-button>
          </view>
        </view>
      </view>
    </view>
    
    <!-- 安全提示 -->
    <view v-if="activeTab === 'safety'" class="content-section">
      <view class="section-header">
        <text class="section-title">安全提示</text>
        <view class="safety-level">
          <u-tag :type="getSafetyLevelType(safetyInfo.level)" size="small">
            {{ safetyInfo.level }}
          </u-tag>
        </view>
      </view>
      
      <!-- 安全等级说明 -->
      <view class="safety-overview">
        <view class="safety-icon">
          <up-icon name="warning" size="24" color="#ff6b35"></up-icon>
        </view>
        <view class="safety-content">
          <text class="safety-title">{{ safetyInfo.title }}</text>
          <text class="safety-desc">{{ safetyInfo.description }}</text>
        </view>
      </view>
      
      <!-- 个人防护设备 -->
      <view class="safety-section">
        <text class="safety-section-title">🛡️ 个人防护设备</text>
        <view class="ppe-list">
          <view v-for="ppe in safetyInfo.ppe" :key="ppe.name" class="ppe-item">
            <view class="ppe-icon">
              <text class="ppe-emoji">{{ ppe.icon }}</text>
            </view>
            <view class="ppe-info">
              <text class="ppe-name">{{ ppe.name }}</text>
              <text class="ppe-desc">{{ ppe.description }}</text>
            </view>
            <view class="ppe-status">
              <up-icon 
                :name="ppe.checked ? 'checkmark-circle' : 'close-circle'" 
                :color="ppe.checked ? '#4caf50' : '#ccc'"
                size="20"
                @click="togglePPE(ppe)"
              ></up-icon>
            </view>
          </view>
        </view>
      </view>
      
      <!-- 安全注意事项 -->
      <view class="safety-section">
        <text class="safety-section-title">⚠️ 安全注意事项</text>
        <view class="safety-warnings">
          <view v-for="(warning, index) in safetyInfo.warnings" :key="index" class="safety-warning">
            <view class="warning-icon">
              <up-icon name="info-circle" size="16" color="#ff6b35"></up-icon>
            </view>
            <text class="warning-content">{{ warning }}</text>
          </view>
        </view>
      </view>
      
      <!-- 应急处理 -->
      <view class="safety-section">
        <text class="safety-section-title">🚨 应急处理</text>
        <view class="emergency-procedures">
          <view v-for="(procedure, index) in safetyInfo.emergencyProcedures" :key="index" class="emergency-item">
            <view class="emergency-header">
              <text class="emergency-title">{{ procedure.situation }}</text>
            </view>
            <view class="emergency-steps">
              <view v-for="(step, stepIndex) in procedure.steps" :key="stepIndex" class="emergency-step">
                <text class="step-number">{{ stepIndex + 1 }}.</text>
                <text class="step-content">{{ step }}</text>
              </view>
            </view>
          </view>
        </view>
      </view>
      
      <!-- 安全确认 -->
      <view class="safety-confirmation">
        <view class="confirmation-header">
          <up-icon name="checkmark-circle" size="20" color="#4caf50"></up-icon>
          <text class="confirmation-title">安全确认</text>
        </view>
        <view class="confirmation-content">
          <text class="confirmation-text">我已仔细阅读并理解以上安全提示,将严格按照安全规程进行作业</text>
        </view>
        <view class="confirmation-actions">
          <u-button 
            type="success"
            @click="confirmSafety"
            :disabled="safetyConfirmed"
          >
            {{ safetyConfirmed ? '已确认' : '确认并开始作业' }}
          </u-button>
        </view>
      </view>
    </view>
    
    <!-- 底部操作按钮 -->
    <view class="bottom-actions">
      <u-button 
        type="primary"
        size="large"
        @click="startWork"
        :disabled="!canStartWork"
      >
        开始作业
      </u-button>
      <u-button 
        type="info"
        size="large"
        plain
        @click="saveProgress"
      >
        保存进度
      </u-button>
    </view>
  </view>
</template>
 
<script setup>
import { ref, computed, onMounted } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import PageHeader from '@/components/PageHeader.vue'
 
const showToast = (message) => {
  uni.showToast({
    title: message,
    icon: 'none'
  })
}
 
// 当前任务信息
const currentTask = ref({
  id: 1,
  deviceName: '数控车床CK6140',
  deviceCode: 'CNC-001',
  taskType: '设备维修',
  priority: '紧急',
  status: 'in_progress',
  faultDescription: '主轴异响,切削精度下降',
  estimatedHours: 4,
  assignedTechnician: '李师傅',
  startTime: '2024-01-15 09:00:00'
})
 
// 导航标签
const tabs = ref([
  { key: 'sop', label: 'SOP', icon: 'list' },
  { key: 'parts', label: '配件', icon: 'grid' },
  { key: 'safety', label: '安全', icon: 'info' }
])
 
const activeTab = ref('sop')
 
// SOP步骤数据
const sopSteps = ref([
  {
    id: 1,
    title: '安全准备与设备断电',
    description: '确保设备完全断电,挂上安全标识牌,穿戴好个人防护设备,检查工作环境安全。',
    duration: 10,
    completed: false,
    expanded: false,
    warnings: [
      '必须确认设备完全断电后才能进行后续操作',
      '挂上"正在维修,禁止操作"的安全标识牌',
      '检查周围是否有其他人员,确保安全距离'
    ],
    tools: ['万用表', '安全标识牌', '个人防护设备']
  },
  {
    id: 2,
    title: '拆卸主轴防护罩',
    description: '使用专用工具小心拆卸主轴防护罩,注意保护罩的完整性,避免损坏密封件。',
    duration: 15,
    completed: false,
    expanded: false,
    warnings: [
      '拆卸时注意防护罩重量,避免掉落砸伤',
      '密封件容易老化,拆卸时要格外小心',
      '记录拆卸顺序,便于后续安装'
    ],
    tools: ['内六角扳手', '橡胶锤', '密封胶']
  },
  {
    id: 3,
    title: '检查主轴轴承状态',
    description: '仔细检查主轴轴承的磨损情况,测量轴承间隙,检查润滑油状态和轴承座的配合情况。',
    duration: 25,
    completed: false,
    expanded: false,
    warnings: [
      '轴承检查时避免用力过大,防止进一步损坏',
      '注意观察轴承表面是否有裂纹或异常磨损',
      '测量数据要准确记录,作为更换依据'
    ],
    tools: ['游标卡尺', '千分尺', '内窥镜', '润滑油检测仪']
  },
  {
    id: 4,
    title: '更换损坏轴承',
    description: '使用专用拉拔器拆卸损坏轴承,清洁轴承座,安装新轴承时确保配合精度。',
    duration: 45,
    completed: false,
    expanded: false,
    warnings: [
      '轴承拆卸时必须使用专用工具,避免损坏轴颈',
      '新轴承安装前要检查型号规格是否正确',
      '安装时要均匀用力,确保轴承完全就位'
    ],
    tools: ['轴承拉拔器', '轴承加热器', '专用安装工具', '润滑脂']
  },
  {
    id: 5,
    title: '调整主轴间隙',
    description: '根据技术要求调整主轴轴向和径向间隙,确保主轴运转平稳,精度符合标准。',
    duration: 30,
    completed: false,
    expanded: false,
    warnings: [
      '间隙调整要严格按照技术标准执行',
      '调整过程中要多次测量确认',
      '调整完成后要进行试运转检验'
    ],
    tools: ['百分表', '塞尺', '扭力扳手']
  },
  {
    id: 6,
    title: '安装防护罩并测试',
    description: '按照拆卸的逆序安装防护罩,加注润滑油,进行低速试运转,检查运转状态。',
    duration: 20,
    completed: false,
    expanded: false,
    warnings: [
      '安装时要确保所有密封件正确就位',
      '润滑油加注量要符合规定要求',
      '试运转时要密切观察设备状态'
    ],
    tools: ['润滑油', '密封胶', '清洁布']
  }
])
 
const currentStepIndex = ref(0)
 
// 配件清单数据
const partsList = ref([
  {
    id: 1,
    name: '主轴轴承',
    specification: 'NSK 7020C',
    partNumber: 'BRG-7020C-001',
    requiredQuantity: 2,
    stockQuantity: 5,
    unit: '个',
    available: true,
    location: '仓库A区-03货架',
    supplier: '日本NSK公司',
    price: 1250.00
  },
  {
    id: 2,
    name: '密封圈',
    specification: 'O型圈 φ45×3',
    partNumber: 'SEAL-045-003',
    requiredQuantity: 4,
    stockQuantity: 2,
    unit: '个',
    available: false,
    location: '仓库B区-12货架',
    supplier: '德国费斯托',
    price: 25.50
  },
  {
    id: 3,
    name: '润滑脂',
    specification: '高温轴承润滑脂 2#',
    partNumber: 'LUB-HT-002',
    requiredQuantity: 1,
    stockQuantity: 8,
    unit: '支',
    available: true,
    location: '仓库C区-05货架',
    supplier: '美孚石油',
    price: 180.00
  },
  {
    id: 4,
    name: '螺栓',
    specification: 'M8×25 内六角螺栓',
    partNumber: 'BOLT-M8-025',
    requiredQuantity: 8,
    stockQuantity: 50,
    unit: '个',
    available: true,
    location: '仓库A区-01货架',
    supplier: '标准件厂',
    price: 2.50
  },
  {
    id: 5,
    name: '垫片',
    specification: '调整垫片 φ40×0.1',
    partNumber: 'SHIM-040-01',
    requiredQuantity: 6,
    stockQuantity: 0,
    unit: '片',
    available: false,
    location: '仓库A区-08货架',
    supplier: '精密加工厂',
    price: 15.00
  }
])
 
// 安全信息数据
const safetyInfo = ref({
  level: '高风险',
  title: '机械设备维修安全规程',
  description: '本次维修涉及重型机械设备,存在机械伤害、电击等风险,请严格遵守安全操作规程。',
  ppe: [
    {
      name: '安全帽',
      icon: '⛑️',
      description: '防止头部受到撞击伤害',
      checked: false
    },
    {
      name: '安全眼镜',
      icon: '🥽',
      description: '防止金属屑飞溅伤眼',
      checked: false
    },
    {
      name: '防护手套',
      icon: '🧤',
      description: '防止手部割伤和烫伤',
      checked: false
    },
    {
      name: '安全鞋',
      icon: '👢',
      description: '防止足部被重物砸伤',
      checked: false
    },
    {
      name: '工作服',
      icon: '🦺',
      description: '防止衣物被机械卷入',
      checked: false
    }
  ],
  warnings: [
    '维修前必须确认设备完全断电,并挂上安全标识牌',
    '使用工具前要检查工具状态,确保完好无损',
    '拆卸重型部件时要使用起重设备,不得徒手操作',
    '工作区域要保持整洁,及时清理油污和杂物',
    '发现异常情况要立即停止作业,报告现场负责人',
    '严禁在疲劳状态下进行精密操作',
    '多人协作时要明确分工,加强沟通协调'
  ],
  emergencyProcedures: [
    {
      situation: '人员受伤',
      steps: [
        '立即停止所有作业活动',
        '评估伤情严重程度',
        '轻伤进行现场急救处理',
        '重伤立即拨打120急救电话',
        '通知安全管理人员和项目负责人',
        '保护现场,配合事故调查'
      ]
    },
    {
      situation: '设备故障',
      steps: [
        '立即按下急停按钮',
        '切断设备电源',
        '疏散周围人员到安全区域',
        '通知设备管理人员',
        '记录故障现象和时间',
        '等待专业人员处理'
      ]
    },
    {
      situation: '火灾事故',
      steps: [
        '立即切断电源',
        '使用适当的灭火器材',
        '疏散现场人员',
        '拨打119火警电话',
        '通知消防安全管理人员',
        '配合消防部门救援'
      ]
    }
  ]
})
 
const safetyConfirmed = ref(false)
 
// 计算属性
const completedSteps = computed(() => {
  return sopSteps.value.filter(step => step.completed).length
})
 
const canStartWork = computed(() => {
  return safetyConfirmed.value && completedSteps.value > 0
})
 
// 返回上一页
const goBack = () => {
  uni.navigateBack()
}
 
// 获取任务状态类型
const getStatusType = (status) => {
  const statusMap = {
    'pending': 'warning',
    'in_progress': 'primary',
    'completed': 'success',
    'paused': 'info'
  }
  return statusMap[status] || 'info'
}
 
// 获取任务状态文本
const getStatusText = (status) => {
  const statusMap = {
    'pending': '待开始',
    'in_progress': '进行中',
    'completed': '已完成',
    'paused': '已暂停'
  }
  return statusMap[status] || '未知'
}
 
// 切换标签
const switchTab = (tabKey) => {
  activeTab.value = tabKey
}
 
// 切换步骤展开状态
const toggleStep = (index) => {
  sopSteps.value[index].expanded = !sopSteps.value[index].expanded
}
 
// 完成步骤
const completeStep = (index) => {
  sopSteps.value[index].completed = true
  showToast('步骤已完成')
  
  // 自动展开下一步
  if (index < sopSteps.value.length - 1) {
    currentStepIndex.value = index + 1
    sopSteps.value[index + 1].expanded = true
  }
}
 
// 取消完成步骤
const uncompleteStep = (index) => {
  sopSteps.value[index].completed = false
  showToast('已取消完成状态')
}
 
// 申请配件
const requestPart = (part) => {
  uni.showModal({
    title: '申请配件',
    content: `确认申请配件"${part.name}"?`,
    confirmText: '确认',
    cancelText: '取消',
    success: (res) => {
      if (res.confirm) {
        showToast('配件申请已提交')
        // 这里可以调用API提交申请
      }
    }
  })
}
 
// 查看配件详情
const viewPartDetail = (part) => {
  uni.showModal({
    title: part.name,
    content: `配件编号: ${part.partNumber}\n规格: ${part.specification}\n供应商: ${part.supplier}\n单价: ¥${part.price}`,
    showCancel: false,
    confirmText: '知道了'
  })
}
 
// 获取安全等级类型
const getSafetyLevelType = (level) => {
  const levelMap = {
    '低风险': 'success',
    '中风险': 'warning',
    '高风险': 'error'
  }
  return levelMap[level] || 'info'
}
 
// 切换PPE状态
const togglePPE = (ppe) => {
  ppe.checked = !ppe.checked
  if (ppe.checked) {
    showToast(`已确认佩戴${ppe.name}`)
  }
}
 
// 确认安全
const confirmSafety = () => {
  const uncheckedPPE = safetyInfo.value.ppe.filter(ppe => !ppe.checked)
  if (uncheckedPPE.length > 0) {
    showToast('请确认已佩戴所有个人防护设备')
    return
  }
  
  safetyConfirmed.value = true
  showToast('安全确认完成,可以开始作业')
}
 
// 开始作业
const startWork = () => {
  if (!safetyConfirmed.value) {
    showToast('请先完成安全确认')
    return
  }
  
  if (completedSteps.value === 0) {
    showToast('请至少完成一个SOP步骤')
    return
  }
  
  uni.showModal({
    title: '开始作业',
    content: '确认开始正式作业?',
    confirmText: '开始',
    cancelText: '取消',
    success: (res) => {
      if (res.confirm) {
        currentTask.value.status = 'in_progress'
        showToast('作业已开始,请按照SOP执行')
      }
    }
  })
}
 
// 保存进度
const saveProgress = () => {
  const progress = {
    taskId: currentTask.value.id,
    completedSteps: completedSteps.value,
    safetyConfirmed: safetyConfirmed.value,
    timestamp: new Date().toISOString()
  }
  
  // 这里可以调用API保存进度
  showToast('进度已保存')
  console.log('保存的进度:', progress)
}
 
onMounted(() => {
  // 页面加载时的初始化逻辑
  // 可以根据任务ID加载对应的SOP、配件清单和安全提示
})
 
onShow(() => {
  // 页面显示时的逻辑
})
</script>
 
<style scoped lang="scss">
@import '@/styles/sales-common.scss';
 
// 标准作业指导特有样式
.sales-account {
  padding-bottom: 100px;
}
 
// 任务信息卡片
.task-info-card {
  margin: 20px;
  background: #ffffff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
 
.task-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
 
.task-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
 
.task-icon {
  width: 40px;
  height: 40px;
  background: #2979ff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
 
.task-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
 
.task-title {
  font-size: 16px;
  font-weight: 500;
  color: #333;
}
 
.task-subtitle {
  font-size: 12px;
  color: #666;
}
 
.task-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
 
.meta-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
 
.meta-label {
  font-size: 12px;
  color: #777;
  min-width: 70px;
}
 
.meta-value {
  font-size: 12px;
  color: #333;
  flex: 1;
  text-align: right;
}
 
// 导航标签
.nav-tabs {
  display: flex;
  background: #ffffff;
  margin: 0 20px;
  border-radius: 12px;
  padding: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
 
.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border-radius: 8px;
  transition: all 0.3s ease;
  
  &.active {
    background: #f3f7ff;
  }
}
 
.tab-text {
  font-size: 12px;
  color: #666;
  
  &.active {
    color: #2979ff;
    font-weight: 500;
  }
}
 
// 内容区域
.content-section {
  margin: 20px;
}
 
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
 
.section-title {
  font-size: 16px;
  font-weight: 500;
  color: #333;
}
 
.progress-info {
  display: flex;
  align-items: center;
  gap: 4px;
}
 
.progress-text {
  font-size: 12px;
  color: #666;
}
 
// SOP步骤样式
.sop-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
 
.sop-step {
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #f0f0f0;
  overflow: hidden;
  transition: all 0.3s ease;
  
  &.completed {
    border-color: #4caf50;
    background: #f8fff8;
  }
  
  &.current {
    border-color: #2979ff;
    box-shadow: 0 2px 8px rgba(41, 121, 255, 0.1);
  }
}
 
.step-header {
  display: flex;
  align-items: center;
  padding: 16px;
  cursor: pointer;
}
 
.step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  
  .sop-step.completed & {
    background: #4caf50;
  }
}
 
.step-num {
  font-size: 12px;
  font-weight: 500;
  color: #666;
  
  .sop-step.completed & {
    color: #ffffff;
  }
}
 
.step-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
 
.step-title {
  font-size: 14px;
  font-weight: 500;
  color: #333;
}
 
.step-duration {
  font-size: 12px;
  color: #666;
}
 
.step-details {
  padding: 0 16px 16px 16px;
  border-top: 1px solid #f0f0f0;
}
 
.step-description {
  margin: 16px 0;
}
 
.desc-text {
  font-size: 13px;
  color: #555;
  line-height: 1.5;
}
 
.step-warnings {
  margin: 16px 0;
  padding: 12px;
  background: #fff3e0;
  border-radius: 8px;
  border-left: 4px solid #ff9800;
}
 
.warning-title {
  font-size: 13px;
  font-weight: 500;
  color: #e65100;
  margin-bottom: 8px;
}
 
.warning-item {
  margin-bottom: 4px;
}
 
.warning-text {
  font-size: 12px;
  color: #bf360c;
  line-height: 1.4;
}
 
.step-tools {
  margin: 16px 0;
}
 
.tools-title {
  font-size: 13px;
  font-weight: 500;
  color: #333;
  margin-bottom: 8px;
}
 
.tools-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
 
.tool-tag {
  margin: 0;
}
 
.step-actions {
  margin-top: 16px;
  display: flex;
  gap: 8px;
}
 
// 配件清单样式
.parts-summary {
  display: flex;
  align-items: center;
}
 
.summary-text {
  font-size: 12px;
  color: #666;
}
 
.parts-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
 
.part-item {
  background: #ffffff;
  border-radius: 12px;
  padding: 16px;
  border: 1px solid #f0f0f0;
}
 
.part-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}
 
.part-info {
  flex: 1;
}
 
.part-name {
  font-size: 14px;
  font-weight: 500;
  color: #333;
  display: block;
  margin-bottom: 4px;
}
 
.part-spec {
  font-size: 12px;
  color: #666;
}
 
.part-details {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
 
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
 
.detail-label {
  font-size: 12px;
  color: #777;
  min-width: 70px;
}
 
.detail-value {
  font-size: 12px;
  color: #333;
  
  &.danger {
    color: #f44336;
    font-weight: 500;
  }
}
 
.part-actions {
  display: flex;
  gap: 8px;
}
 
// 安全提示样式
.safety-level {
  display: flex;
  align-items: center;
}
 
.safety-overview {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: #fff3e0;
  border-radius: 12px;
  margin-bottom: 20px;
  border-left: 4px solid #ff6b35;
}
 
.safety-icon {
  margin-top: 2px;
}
 
.safety-content {
  flex: 1;
}
 
.safety-title {
  font-size: 14px;
  font-weight: 500;
  color: #e65100;
  display: block;
  margin-bottom: 4px;
}
 
.safety-desc {
  font-size: 12px;
  color: #bf360c;
  line-height: 1.4;
}
 
.safety-section {
  margin-bottom: 20px;
  background: #ffffff;
  border-radius: 12px;
  padding: 16px;
  border: 1px solid #f0f0f0;
}
 
.safety-section-title {
  font-size: 14px;
  font-weight: 500;
  color: #333;
  margin-bottom: 12px;
}
 
// PPE列表
.ppe-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
 
.ppe-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
}
 
.ppe-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}
 
.ppe-emoji {
  font-size: 20px;
}
 
.ppe-info {
  flex: 1;
}
 
.ppe-name {
  font-size: 13px;
  font-weight: 500;
  color: #333;
  display: block;
  margin-bottom: 2px;
}
 
.ppe-desc {
  font-size: 11px;
  color: #666;
}
 
// 安全警告
.safety-warnings {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
 
.safety-warning {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
}
 
.warning-icon {
  margin-top: 2px;
}
 
.warning-content {
  flex: 1;
  font-size: 12px;
  color: #555;
  line-height: 1.4;
}
 
// 应急处理
.emergency-procedures {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
 
.emergency-item {
  border: 1px solid #ffcdd2;
  border-radius: 8px;
  overflow: hidden;
}
 
.emergency-header {
  background: #ffebee;
  padding: 12px 16px;
  border-bottom: 1px solid #ffcdd2;
}
 
.emergency-title {
  font-size: 13px;
  font-weight: 500;
  color: #c62828;
}
 
.emergency-steps {
  padding: 12px 16px;
}
 
.emergency-step {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
  
  &:last-child {
    margin-bottom: 0;
  }
}
 
.step-number {
  font-size: 12px;
  font-weight: 500;
  color: #d32f2f;
  min-width: 16px;
}
 
.step-content {
  font-size: 12px;
  color: #555;
  line-height: 1.4;
}
 
// 安全确认
.safety-confirmation {
  background: #e8f5e8;
  border-radius: 12px;
  padding: 16px;
  border: 1px solid #c8e6c9;
}
 
.confirmation-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
 
.confirmation-title {
  font-size: 14px;
  font-weight: 500;
  color: #2e7d32;
}
 
.confirmation-content {
  margin-bottom: 16px;
}
 
.confirmation-text {
  font-size: 12px;
  color: #388e3c;
  line-height: 1.4;
}
 
.confirmation-actions {
  display: flex;
  justify-content: center;
}
 
// 底部操作按钮
.bottom-actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  padding: 16px 20px;
  border-top: 1px solid #f0f0f0;
  display: flex;
  gap: 12px;
  z-index: 100;
}
 
.bottom-actions .u-button {
  flex: 1;
}
</style>