gaoluyang
昨天 29be8639dc16b5d82bddc6099b1fa5cdca75f77a
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
<template>
  <!--  7.7质量监控计划-->
  <div class="app-container">
    <section v-if="pageMode === 'list'" class="plan-list-card">
      <div class="plan-list-toolbar">
        <div class="plan-list-filters">
          <span class="annual-plan-label">计划年度</span>
          <el-date-picker v-model="selectedYear" type="year" value-format="YYYY" format="YYYY年" :clearable="false"
            size="small" style="width: 130px" @change="handleYearChange" />
          <span class="filter-label">计划名称</span>
          <el-input v-model="yearForm.monitorName" clearable placeholder="请输入" size="small" style="width: 220px"
            @keyup.enter="getYearPlanList" />
          <el-button type="primary" size="small" @click="getYearPlanList">查询</el-button>
          <el-button size="small" @click="clearYear">重置</el-button>
        </div>
        <div class="plan-list-actions">
          <el-button size="small" @click="leadInto">导入</el-button>
          <el-button type="primary" size="small" @click="openCreatePlan">新建年度计划</el-button>
        </div>
      </div>
      <lims-table :tableData="yearTableData" :column="yearColumnData" :page="yearPage"
        :tableLoading="yearLoading" :height="'calc(100vh - 11em)'" @pagination="pagination" key="yearTableData">
        <template #planActions="{ row }">
          <div class="detail-actions">
            <el-button link type="primary" size="small" @click="openPlan(row)">查看计划</el-button>
            <el-button v-if="canReviewRow(row)" link type="primary" size="small" @click="examinePlan(row)">审核</el-button>
            <el-button v-if="canApproveRow(row)" link type="primary" size="small" @click="approvalPlan(row)">批准</el-button>
            <el-dropdown trigger="click" @command="command => handlePlanCommand(command, row)">
              <el-button link type="primary" size="small">更多⌄</el-button>
              <template #dropdown>
                <el-dropdown-menu>
                  <el-dropdown-item command="export" :disabled="row.ratifyStatus !== 1">导出年度计划</el-dropdown-item>
                  <el-dropdown-item command="delete" divided :disabled="!canDeleteRow(row)">删除</el-dropdown-item>
                </el-dropdown-menu>
              </template>
            </el-dropdown>
          </div>
        </template>
      </lims-table>
    </section>
 
    <template v-else>
    <div class="annual-plan-header">
      <div class="annual-plan-main">
        <el-button link type="primary" size="small" @click="backToPlanList">← 返回年度计划</el-button>
        <span class="annual-plan-label">{{ selectedYear }}年度</span>
        <template v-if="currentPlan">
          <strong>{{ currentPlan.monitorName }}</strong>
          <el-tag :type="planStatusType">{{ planStatusText }}</el-tag>
          <span>编制:{{ currentPlan.writeName || '-' }} {{ formatDate(currentPlan.writeTime) }}</span>
          <span>审核:{{ currentPlan.examineName || '-' }}</span>
          <span>批准:{{ currentPlan.ratifyName || '-' }}</span>
        </template>
        <el-tag v-else type="info">该年度尚未建立计划</el-tag>
      </div>
      <div class="annual-plan-actions">
        <el-button v-if="canEditPlan" type="primary" size="small" @click="submitPlan">提交审核</el-button>
        <el-button v-if="canReviewPlan" type="primary" size="small" @click="examinePlan(currentPlan)">审核</el-button>
        <el-button v-if="canApprovePlan" type="primary" size="small" @click="approvalPlan(currentPlan)">批准</el-button>
        <el-button size="small" @click="leadInto">导入</el-button>
        <el-button v-if="currentPlan" size="small" :disabled="currentPlan.ratifyStatus !== 1" @click="handleDown(currentPlan)">导出年度计划</el-button>
      </div>
    </div>
    <div class="plan-detail-card">
      <el-alert v-if="currentPlan && currentPlan.ratifyStatus !== 1" type="info" :closable="false" show-icon
        style="margin-bottom: 12px"
        title="检测类质控项目需在年度计划审核、批准通过后,点击对应行的“下发任务”进行下发;非检测类项目无需下发。" />
      <div class="plan-detail-toolbar">
        <div style="display: flex;">
          <div style="margin-bottom: 18px;margin-right: 10px;display: flex;align-items: center;line-height: 32px;">
            <span style="width: 88px;font-size: 14px;font-weight: 700;color: var(--lims-text-2);">质控项目</span>
            <el-input v-model="yearDetailForm.monitorProject" placeholder="请输入" size="small"
                      @keyup.enter="getYearDetailPlanList"></el-input>
          </div>
          <div style="margin-bottom: 18px;margin-right: 10px;display: flex;align-items: center;line-height: 32px;">
            <span style="width: 70px;font-size: 14px;font-weight: 700;color: var(--lims-text-2);">负责人</span>
            <el-select v-model="yearDetailForm.responsibleUserId" clearable filterable size="small" style="width: 160px">
              <el-option v-for="item in responsibleOptions" :key="item.id" :label="item.name" :value="item.id" />
            </el-select>
          </div>
          <div style="line-height: 30px;">
            <el-button type="primary" size="small" @click="getYearDetailPlanList">查询</el-button>
            <el-button size="small" @click="clearDetail">重置</el-button>
          </div>
        </div>
        <div style="line-height: 30px;">
<!--          <el-button size="small" type="primary" @click="exportSignatureTemplate">导出签名模板</el-button>-->
          <el-button size="small" type="primary" :disabled="!canEditPlan" @click="showDialog('add')">新增质控项目</el-button>
        </div>
      </div>
      <lims-table :tableData="yearDetailTableData" :column="yearDetailColumnData" :page="yearDetailPage"
        :tableLoading="yearDetailLoading" :height="'calc(100vh - 15em)'" @pagination="pagination1" ref="yearDetailTableData"
        key="yearDetailTableData">
        <template #detailActions="{ row }">
          <div class="detail-actions">
            <el-button link type="primary" size="small" :disabled="!canEditPlan || !!row.inspectionTaskId"
              @click="showDialog('edit', row)">编辑</el-button>
 
            <el-button v-if="row.itemKind !== 'INSPECTION'" link type="primary" size="small"
              @click="carryOut(row)">实施</el-button>
            <el-button v-else-if="!row.inspectionTaskId" link type="primary" size="small"
              :disabled="row.planRatifyStatus !== 1" @click="dispatchTask(row)">下发任务</el-button>
            <el-button v-else link type="primary" size="small" @click="evaluate(row)">
              {{ row.inspectionTaskState === 5 ? '评价记录' : '评价要求' }}
            </el-button>
 
            <el-dropdown trigger="click" @command="command => handleDetailCommand(command, row)">
              <el-button link type="primary" size="small">更多⌄</el-button>
              <template #dropdown>
                <el-dropdown-menu>
                  <el-dropdown-item v-if="row.itemKind !== 'INSPECTION'" command="complete">完成报告</el-dropdown-item>
                  <el-dropdown-item v-if="row.itemKind !== 'INSPECTION'" command="evaluate">评价</el-dropdown-item>
                  <el-dropdown-item v-if="row.itemKind === 'INSPECTION' && !row.inspectionTaskId" command="requirement">评价要求</el-dropdown-item>
                  <el-dropdown-item v-if="row.itemKind === 'INSPECTION' && row.inspectionTaskId" command="cancel"
                    :disabled="row.inspectionTaskOrderState !== 1 || row.inspectionTaskState !== 0">取消任务</el-dropdown-item>
                  <el-dropdown-item command="attachment">附件上传</el-dropdown-item>
                  <el-dropdown-item command="export">导出</el-dropdown-item>
                  <el-dropdown-item command="delete" divided
                    :disabled="!canEditPlan || !!row.inspectionTaskId">删除</el-dropdown-item>
                </el-dropdown-menu>
              </template>
            </el-dropdown>
          </div>
        </template>
      </lims-table>
    </div>
    </template>
    <el-dialog v-model="createPlanDialog" title="新建年度质量控制计划" width="520px">
      <el-form :model="planForm" label-width="90px">
        <el-form-item label="年度">
          <el-date-picker v-model="planForm.monitorYear" type="year" value-format="YYYY" format="YYYY年"
            :clearable="false" style="width: 100%" placeholder="请选择年度" />
        </el-form-item>
        <el-form-item label="计划名称"><el-input v-model="planForm.monitorName" /></el-form-item>
        <el-form-item label="审核人">
          <el-select v-model="planForm.examineUserId" filterable style="width:100%">
            <el-option v-for="item in responsibleOptions" :key="item.id" :label="item.name" :value="item.id" />
          </el-select>
        </el-form-item>
      </el-form>
      <template #footer>
        <el-button @click="createPlanDialog=false">取消</el-button>
        <el-button type="primary" :loading="createPlanLoading" @click="createPlan">确定</el-button>
      </template>
    </el-dialog>
    <!--新增修改弹框-->
    <detail-form-dialog v-if="formDia" ref="formDia" :qualityMonitorId="qualityMonitorId"
      @closeDia="closeDia"></detail-form-dialog>
    <!--实施流程弹框-->
    <carry-out-dialog v-if="carryOutDia" ref="carryOutDia" :qualityMonitorId="qualityMonitorId"
      @closeCarryOutDia="closeCarryOutDia"></carry-out-dialog>
    <!--评价流程弹框-->
    <evaluate-dialog v-if="evaluateDialog" ref="evaluateDialog" @closeEvaDia="closeEvaDia"></evaluate-dialog>
    <inspection-evaluation-dialog v-if="inspectionEvaluateDialog" ref="inspectionEvaluateDialog"
      @close="closeInspectionEvaluateDialog" />
    <el-dialog v-model="examineDialog" title="审核" width="30%" @close="closeExamineDia">
      <span>
        审核备注:
        <el-input v-model="examineInfo.examineRemark" type="textarea"></el-input>
      </span>
      <span style="margin-top: 10px;display: inline-block">
        批准人:
        <el-select v-model="examineInfo.ratifyUserId" clearable filterable size="small" style="width: 70%;">
          <el-option v-for="item in responsibleOptions" :key="item.id" :label="item.name" :value="item.id">
          </el-option>
        </el-select>
      </span>
      <template #footer><span  class="dialog-footer">
        <el-button :loading="examineLoading" @click="handleReview(0)">不通过</el-button>
        <el-button :loading="examineLoading" type="primary" @click="handleReview(1)">通 过</el-button>
      </span></template>
    </el-dialog>
    <el-dialog v-model="ratifyDialog" title="批准" width="30%" @close="closeRatifyDia">
      <span>
        批准备注:
        <el-input v-model="ratifyInfo.ratifyRemark" type="textarea"></el-input>
      </span>
      <template #footer><span  class="dialog-footer">
        <el-button :loading="ratifyLoading" @click="handleRatify(0)">不批准</el-button>
        <el-button :loading="ratifyLoading" type="primary" @click="handleRatify(1)">批 准</el-button>
      </span></template>
    </el-dialog>
    <!--预览报告-->
    <el-dialog v-model="lookDialogVisible" fullscreen title="查看附件" top="5vh" width="800px">
      <filePreview v-if="lookDialogVisible" :currentFile="{}" :option="option"
        :fileUrl="javaApi + '/word/' + currentInfo.finishReportUrl" style="height: 70vh;overflow-y: auto;" />
      <div>
        批准状态:
        <el-tag v-if="ratifyStatus === 1" type="success">批准</el-tag>
        <el-tag v-if="ratifyStatus === 0" type="danger">不批准</el-tag>
      </div>
      <div>
        批准意见:
        <el-input v-model="ratifyRemark" :disabled="ratifyStatus === 1" type="textarea"></el-input>
      </div>
      <template #footer><span v-if="ratifyStatus !== 1"  class="dialog-footer">
        <el-button :loading="lookDialogLoading" @click="handleApproval(0)">不批准</el-button>
        <el-button :loading="lookDialogLoading" type="primary" @click="handleApproval(1)">批 准</el-button>
      </span></template>
    </el-dialog>
    <el-dialog v-model="downloadDialog" title="导出" width="600px">
      <span>
        <el-button plain type="primary" :disabled="download.detailsRatifyStatus !== 3"
          @click="controlDown">实施计划导出</el-button>
        <el-button plain type="primary" :disabled="!download.finishReportUrl"
                           @click="finishReportExport">完成报告导出</el-button>
        <el-button plain type="primary" :disabled="download.evaluateStatus !== 3"
          @click="processingDown">评价导出</el-button>
      </span>
      <template #footer><span  class="dialog-footer">
        <el-button @click="downloadDialog = false">取 消</el-button>
      </span></template>
    </el-dialog>
    <!--导入计划-->
    <el-dialog v-model="uploadDia" title="数据导入" width="500px" :close-on-click-modal="false"
      :close-on-press-escape="false">
      <el-form label-width="70px" size="small">
        <el-form-item label="年份">
          <el-date-picker v-model="planYear" type="year" value-format="YYYY" clearable format="YYYY"
            placeholder="选择年" style="width: 100%">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="审核人">
          <el-select v-model="examineUserId" clearable filterable style="width: 100%">
            <el-option v-for="item in responsibleOptions" :key="item.id" :label="item.name" :value="item.id">
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div style="display: flex; align-items: center; gap: 8px; margin-bottom: 10px; padding: 8px 12px; border-radius: 4px; background: var(--el-color-primary-light-9); font-size: 13px;">
        <span>第一次导入请先下载模板,按模板格式填写后再上传。</span>
        <el-button link type="primary" @click="downloadTemplate">下载导入模板</el-button>
      </div>
      <div style="margin: 0 auto;">
        <el-upload ref="upload" :action="action" :auto-upload="false" v-model:file-list="fileList" :headers="uploadHeader"
          :limit="1" accept=".xls,.xlsx"
          :on-change="beforeUpload" :on-error="onError" :on-success="handleSuccessUp" drag
          :data="{ monitorYear: planYear, examineUserId: examineUserId }" name="file">
          <lims-icon name="el-icon-upload"></lims-icon>
          <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
        </el-upload>
      </div>
      <div style="margin-top: 10px; color: var(--el-text-color-secondary); font-size: 12px; line-height: 20px;">
        <div>支持格式:.xls、.xlsx;单个文件不超过10MB。</div>
        <div>质控项目、技术标准、质控方式、完成时限、负责人为必填项。</div>
        <div>完成时限格式必须为 YYYY-MM(模板中该列为文本格式,直接输入 2026-12 即可);负责人必须填写系统中已存在的人员姓名。</div>
        <div>导入后计划保存为草稿。请在计划详情中编辑质控项目并选择事项类别;检测类还需选择检测标准、原始记录模板、检测员、评价人并填写任务截止日,确认后再提交审核。</div>
        <div>导入只读取模板的第一个工作表。</div>
      </div>
      <template #footer><span  class="dialog-footer">
        <el-button @click="uploadDia = false">取 消</el-button>
        <el-button :loading="uploading" type="primary" @click="submitUpload">上 传</el-button>
      </span></template>
    </el-dialog>
    <!--生成报告弹框-->
    <el-dialog v-model="uploadDia1" title="生成报告" width="500px">
      <div v-if="ratifyRemark">
        批准意见:
        <el-input v-model="ratifyRemark" :disabled="ratifyStatus === 1" type="textarea"></el-input>
      </div>
      <div style="margin: 0 auto;">
        <el-upload ref="upload1" :action="action1" :auto-upload="false"
          :data="{ qualityMonitorDetailsId: qualityMonitorDetailsId }" v-model:file-list="fileList1" :headers="uploadHeader"
          :limit="1" :on-change="beforeUpload1" :on-error="onError1" :on-success="onSuccess1" accept='.doc,.docx,application/pdf,' drag
          name="file">
          <lims-icon name="el-icon-upload"></lims-icon>
          <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
        </el-upload>
      </div>
      <template #footer><span  class="dialog-footer">
        <el-button @click="uploadDia1 = false">取 消</el-button>
        <el-button :loading="uploading1" type="primary" @click="submitUpload1()">上 传</el-button>
      </span></template>
    </el-dialog>
    <view-record v-if="ViewRecord" ref="ViewRecord"></view-record>
  </div>
</template>
 
<script>
import DetailFormDialog from './components/detailFormDialog.vue';
import InspectionEvaluationDialog from './components/inspectionEvaluationDialog.vue';
import CarryOutDialog from './components/carryOutDialog.vue';
import EvaluateDialog from './components/evaluateDialog.vue';
import filePreview from "@/components/Preview/filePreview.vue";
import limsTable from "@/components/Table/lims-table.vue";
import {
  createAnnualPlan, getAnnualPlan, submitAnnualPlan,
  delQualityMonitorDetail,
  delQualitySupervise,
  examineQualityMonitor, exportQualityMonitorDetail, exportQualityMonitorEvaluate, exportQualityMonitorRatify,
  pageQualityMonitor, pageQualityMonitorDetail, ratifyFinishReport,
  ratifyQualityMonitor
} from "@/api/cnas/process/ensureResults/qualityMonitor";
import { dispatchInspectionTask, cancelInspectionTask } from "@/api/cnas/process/ensureResults/qualityMonitor";
import { selectUserCondition } from "@/api/performance/class";
import { mapGetters } from "@/utils/store-compat";
import ViewRecord from "./components/ViewRecord.vue";
 
export default {
  name: 'EnsureResultsValidity',
  // import 引入的组件需要注入到对象中才能使用
  components: {ViewRecord, limsTable, filePreview, EvaluateDialog, CarryOutDialog, DetailFormDialog, InspectionEvaluationDialog },
  data() {
    // 这里存放数据
    return {
      ViewRecord: false,
      inspectionEvaluateDialog: false,
      pageMode: 'list',
      selectedYear: String(new Date().getFullYear()),
      currentPlan: null,
      selectedPlanId: null,
      createPlanDialog: false,
      createPlanLoading: false,
      planForm: { monitorYear: String(new Date().getFullYear()), monitorName: '', examineUserId: null },
      examineUserId: '',
      responsibleOptions: [],
      yearForm: {
        monitorName: '',
      },
      yearPage: {
        current: 1,
        size: 20,
        total: 0
      },
      yearColumnData: [
        {
          label: '计划名称',
          prop: 'monitorName',
          minWidth: '220px'
        }, {
          label: '计划年度',
          prop: 'monitorYear',
          width: '100px'
        }, {
          dataType: 'tag',
          label: '计划状态',
          prop: 'workflowStatus',
          width: '110px',
          formatData: (value, row) => this.planWorkflowText(value),
          formatType: value => this.planWorkflowType(value)
        }, {
          label: '编制人',
          prop: 'writeName',
          minWidth: '100px'
        }, {
          label: '编制日期',
          prop: 'writeTime',
          minWidth: '150px',
          formatData: value => this.formatDate(value)
        }, {
          label: '审核人',
          prop: 'examineName',
          minWidth: '100px'
        }, {
          label: '审核日期',
          prop: 'examineTime',
          minWidth: '150px',
          formatData: value => this.formatDate(value)
        }, {
          label: '批准人',
          prop: 'ratifyName',
          minWidth: '100px'
        }, {
          label: '批准日期',
          prop: 'ratifyTime',
          minWidth: '150px',
          formatData: value => this.formatDate(value)
        }, {
          dataType: 'slot',
          slot: 'planActions',
          label: '操作',
          fixed: 'right',
          width: '220px'
        }],
      yearTableData: [],  // 年表
      yearLoading: false,
      yearDetailForm: {
        monitorProject: '',
        responsibleUserId: null,
      },
      yearDetailColumnData: [
        {
          label: '质控项目',
          prop: 'monitorProject',
          minWidth: '140px'
        }, {
          label: '技术标准',
          prop: 'technicalStandardText',
          minWidth: '220px'
        }, {
          label: '质控方式',
          prop: 'monitorWay',
          minWidth: '120px'
        }, {
          label: '完成时限',
          prop: 'completionMonth',
          width: '110px',
          formatData: value => value ? value.replace('-', '.') : ''
        }, {
          label: '负责人',
          prop: 'responsibleName',
          minWidth: '100px'
        }, {
          label: '评价人',
          prop: 'evaluatorName',
          minWidth: '100px'
        }, {
          label: '事项类别', prop: 'itemKind', width: '100px',
          formatData: value => value === 'INSPECTION' ? '检测类' : '非检测类'
        }, {
          label: '监控任务编号', prop: 'inspectionTaskCode', minWidth: '150px'
        }, {
          label: '任务状态', prop: 'taskStatusText', width: '110px'
        },{
          dataType: 'tag',
          label: '评价状态',
          prop: 'evaluateStatus',
          width: '100',
          formatData: (params) => {
            if (params === 0) {
              return '未开始';
            } else if (params === 1) {
              return '待评价';
            }  else if (params === 2) {
              return '待批准';
            } else if (params === 3) {
              return '已批准';
            } else {
              return null;
            }
          },
          formatType: (params) => {
            if (params === 0) {
              return '';
            } else if (params === 1) {
              return 'warning';
            } else if (params === 2) {
              return 'info';
            }  else if (params === 3) {
              return 'success';
            } else {
              return null;
            }
          }
        }, {
          dataType: 'slot',
          slot: 'detailActions',
          label: '操作',
          fixed: 'right',
          width: '220px'
        }
      ],
      yearDetailTableData: [], // 年明细表
      yearDetailLoading: false,
      yearDetailPage: {
        current: 1,
        size: 20,
        total: 0
      },
      formDia: false,
      qualityMonitorId: '',
      carryOutDia: false,
      evaluateDialog: false,
      examineDialog: false,
      examineLoading: false,
      ratifyDialog: false,
      ratifyLoading: false,
      examineInfo: {},
      ratifyInfo: {},
      upLoading: false,
      uploadDia: false,
      uploadDia1: false,
      uploading: false,
      uploading1: false,
      fileList: [],
      fileList1: [],
      lookDialogVisible: false,
      lookDialogLoading: false,
      currentInfo: {},
      qualityMonitorDetailsId: '',
      ratifyStatus: '',
      ratifyRemark: '',
      downloadDialog: false,
      download: {},
      planYear: '',
      option: {}
    };
  },
  mounted() {
    this.getUserList()
    this.getYearPlanList()
  },
  // 方法集合
  methods: {
    // 查询年度计划表
    getYearPlanList() {
      this.yearLoading = true
      const entity = {
        monitorYear: this.selectedYear,
        monitorName: this.yearForm.monitorName
      }
      return pageQualityMonitor({ ...entity, ...this.yearPage }).then(res => {
        this.yearTableData = res.data?.records || []
        this.yearPage.total = res.data?.total || 0
      }).finally(() => {
        this.yearLoading = false
      })
    },
    loadAnnualPlan() {
      if (!this.selectedPlanId) return Promise.resolve()
      return this.loadPlanVersion()
    },
    loadPlanVersion() {
      if (!this.selectedPlanId) return Promise.resolve()
      return getAnnualPlan({ monitorYear: this.selectedYear, qualityMonitorId: this.selectedPlanId }).then(res => {
        this.currentPlan = res.data || null
        this.qualityMonitorId = this.currentPlan?.qualityMonitorId || ''
        this.yearDetailPage.current = 1
        return this.getYearDetailPlanList()
      })
    },
    openPlan(row, addFirstDetail = false) {
      this.selectedYear = String(row.monitorYear || this.selectedYear)
      this.selectedPlanId = row.qualityMonitorId
      this.pageMode = 'detail'
      return this.loadPlanVersion().then(() => {
        if (addFirstDetail) this.showDialog('add')
      })
    },
    backToPlanList() {
      this.pageMode = 'list'
      this.currentPlan = null
      this.qualityMonitorId = ''
      this.yearDetailForm = { monitorProject: '', responsibleUserId: null }
      this.getYearPlanList()
    },
    handleYearChange() {
      this.yearPage.current = 1
      this.getYearPlanList()
    },
    openCreatePlan() {
      this.planForm = {
        monitorYear: String(new Date().getFullYear()),
        monitorName: '',
        examineUserId: null
      }
      this.createPlanDialog = true
    },
    createPlan() {
      if (!this.planForm.monitorYear || !this.planForm.monitorName || !this.planForm.examineUserId) {
        this.$message.warning('请选择年度、填写计划名称并选择审核人')
        return
      }
      this.createPlanLoading = true
      createAnnualPlan({ ...this.planForm }).then(res => {
        this.createPlanDialog = false
        this.selectedYear = String(res.data.monitorYear)
        this.yearPage.current = 1
        this.$message.success('年度计划已创建,请填写第一个质控项目')
        return this.getYearPlanList().then(() => this.openPlan(res.data, true))
      }).finally(() => { this.createPlanLoading = false })
    },
    submitPlan() {
      this.$confirm('提交后质控项目将锁定,确认提交审核?', '提交审核').then(() => {
        submitAnnualPlan(this.qualityMonitorId).then(() => {
          this.$message.success('已提交审核')
          this.loadPlanVersion()
          this.getYearPlanList()
        })
      }).catch(() => {})
    },
    clearYear() {
      this.yearForm.monitorName = ''
      this.yearPage.current = 1
      this.getYearPlanList()
    },
    pagination({ page, limit }) {
      this.yearPage.current = page;
      this.yearPage.size = limit;
      this.getYearPlanList();
    },
    pagination1({ page, limit }) {
      this.yearDetailPage.current = page;
      this.yearDetailPage.size = limit;
      this.getYearDetailPlanList();
    },
    leadInto() {
      this.uploadDia = true
      this.planYear = this.selectedYear
      this.fileList = []
      this.getUserList()
    },
    // 下载导入模板
    downloadTemplate() {
      const link = document.createElement('a')
      // 带版本参数避免浏览器继续使用缓存里的旧模板
      link.href = '/import-templates/质量监控计划导入模板.xlsx?v=2'
      link.download = '质量监控计划导入模板.xlsx'
      document.body.appendChild(link)
      link.click()
      document.body.removeChild(link)
    },
    // 导入流程
    beforeUpload(file) {
      if (!/\.(xls|xlsx)$/i.test(file.name || '')) {
        this.$message.error('请选择 .xls 或 .xlsx 格式的文件');
        this.$refs.upload.clearFiles()
        return false;
      }
      if (file.size > 1024 * 1024 * 10) {
        this.$message.error('上传文件不超过10M');
        this.$refs.upload.clearFiles()
        return false;
      } else {
        return true;
      }
    },
    onError(err, file, fileList) {
      this.uploading = false
      this.fileList = []
      this.$message.error('上传失败,请重新选择文件')
    },
    handleSuccessUp(response) {
      this.uploading = false;
      if (response.code == 200) {
        this.$message.success('导入成功,计划已保存为草稿,请补全质控项目后提交审核');
        const importedPlan = response.data || null
        this.timer = setTimeout(() => {
          this.uploadDia = false
          this.fileList = []
          this.examineUserId = ''
          // 导入完成后直接进入计划详情,方便继续编辑质控项目、选择检测标准等
          if (importedPlan && importedPlan.qualityMonitorId) {
            this.openPlan(importedPlan)
          } else {
            this.getYearPlanList()
          }
        }, 1000)
      } else {
        this.$message.error(response.msg || '上传失败')
        // 后端返回业务错误时 HTTP 状态仍是 200,el-upload 会把文件标记为 success,
        // 直接再次调用 submit() 不会重新上传,这里把文件恢复为待上传状态。
        this.resetUploadFiles()
      }
    },
    resetUploadFiles() {
      const files = this.$refs.upload?.uploadFiles || this.fileList || []
      files.forEach(file => {
        file.status = 'ready'
        file.response = undefined
        file.percentage = 0
      })
    },
    submitUpload() {
      if (!this.planYear) {
        this.$message.warning('请选择年份')
        return;
      }
      if (!this.examineUserId) {
        this.$message.warning('请选择审核人')
        return;
      }
      const files = this.$refs.upload?.uploadFiles || this.fileList || []
      if (!files.length) {
        this.$message.warning('请选择要导入的文件')
        return;
      }
      this.uploading = true
      this.$refs.upload.submit();
    },
    // end
    // 审核
    examinePlan(row) {
      this.examineDialog = true
      this.examineInfo = row
      this.getUserList()
    },
    handleReview(examineStatus) {
      // 审核状态 , 0 不通过, 1通过
      this.examineInfo.examineStatus = examineStatus
      this.examineLoading = true
      examineQualityMonitor(this.examineInfo).then(res => {
        this.examineLoading = false
        this.$message.success('操作成功')
        this.closeExamineDia()
      }).catch(err => {
        console.log('err---', err);
        this.examineLoading = false
      })
    },
    closeExamineDia() {
      this.examineDialog = false
      this.examineInfo.examineRemark = ''
      this.refreshPlanData()
    },
    // 批准
    approvalPlan(row) {
      this.ratifyDialog = true
      this.ratifyInfo = row
    },
    handleRatify(ratifyStatus) {
      // 批准状态 , 0 不通过, 1通过
      this.ratifyInfo.ratifyStatus = ratifyStatus
      this.ratifyLoading = true
      ratifyQualityMonitor(this.ratifyInfo).then(res => {
        this.ratifyLoading = false
        this.$message.success('操作成功')
        this.closeRatifyDia()
      }).catch(err => {
        console.log('err---', err);
        this.ratifyLoading = false
      })
    },
    closeRatifyDia() {
      this.ratifyDialog = false
      this.ratifyInfo.ratifyRemark = ''
      this.refreshPlanData()
    },
    refreshPlanData() {
      return this.getYearPlanList().then(() => {
        if (this.pageMode === 'detail' && this.selectedPlanId) {
          return this.loadPlanVersion()
        }
      })
    },
    // 批准报告
    handleApproval(status) {
      const personTrainingUpdateDto = {
        qualityMonitorDetailsId: this.currentInfo.qualityMonitorDetailsId,
        ratifyRemark: this.ratifyRemark,
        ratifyStatus: status
      }
      this.lookDialogLoading = true
      ratifyFinishReport(personTrainingUpdateDto).then(res => {
        if (res.code === 200) {
          this.$message.success('提交成功!');
          this.lookDialogVisible = false
          this.getYearDetailPlanList();
        }
        this.lookDialogLoading = false
      }).catch(() => {
        this.lookDialogLoading = false
      })
    },
    // 导出
    handleDown(row) {
      exportQualityMonitorDetail({ qualityMonitorId: row.qualityMonitorId }).then(res => {
        this.outLoading = false
        const blob = new Blob([res], { type: 'application/msword' });
        this.$download.saveAs(blob, row.monitorName + '.docx')
      })
    },
    // 删除进度计划表
    delPlan(row) {
      this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.yearLoading = true
        delQualitySupervise({ qualityMonitorId: row.qualityMonitorId }).then(res => {
          this.yearLoading = false
          this.$message.success('删除成功')
          this.getYearPlanList()
        }).catch(err => {
          this.yearLoading = false
          console.log('err---', err);
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
    // 年度计划表格,点击行数据后刷新详情
    rowClick(row) {
      this.qualityMonitorId = row.qualityMonitorId
      this.getYearDetailPlanList()
    },
    // 获取年度明细表
    getYearDetailPlanList() {
      const entity = {
        qualityMonitorId: this.qualityMonitorId,
        monitorProject: this.yearDetailForm.monitorProject,
        responsibleUserId: this.yearDetailForm.responsibleUserId,
      }
      const page = this.yearDetailPage
      this.yearDetailLoading = true
      pageQualityMonitorDetail({ ...entity, ...page }).then(res => {
        this.yearDetailLoading = false
        this.yearDetailTableData = res.data.records.map(item => ({
          ...item,
          taskStatusText: this.inspectionTaskStatus(item)
        }))
        this.yearDetailPage.total = res.data.total
        this.$nextTick(() => this.$refs.yearDetailTableData?.$refs?.multipleTable?.doLayout())
      }).catch(err => {
        console.log('err---', err);
        this.yearDetailLoading = false
      })
    },
    // 重置明细表
    clearDetail() {
      this.yearDetailForm = {
        monitorProject: '',
        responsibleUserId: null
      }
      this.getYearDetailPlanList()
    },
    // 明细表实施
    carryOut(row) {
      this.carryOutDia = true
      this.$nextTick(() => {
        this.$refs.carryOutDia.openDia(row)
      })
    },
    closeCarryOutDia() {
      this.carryOutDia = false
      this.getYearDetailPlanList()
    },
    // 打开完成报告弹框
    record(row) {
      this.qualityMonitorDetailsId = row.qualityMonitorDetailsId
      this.ratifyRemark = row.ratifyRemark
      if (row.finishReportUrl) {
        this.currentInfo = row
        this.ratifyStatus = row.ratifyStatus
        const userName = this.nickName
        const isPdf = /\.pdf$/i.test(row.finishReportUrl)
        if (isPdf) {
          this.option = {
            url: this.javaApi + "/word/" + row.finishReportUrl,
            isEdit: false,
            fileType: 'pdf',
            title: '报告',
            lang: 'zh-CN',
            isPrint: false,
            user_id: 1,
            user_name: userName,
            editUrl: this.javaApi + "/insReport/onlyOffice/save?fileName=" + row.finishReportUrl
          }
        } else {
          this.option = {}
        }
        this.lookDialogVisible = true
      } else {
        this.fileList1 = []
        this.uploadDia1 = true
      }
    },
    onSuccess1(response, file, fileList) {
      this.$refs.upload1.clearFiles()
      this.uploading1 = false
      if (response.code == 200) {
        this.$message.success('上传成功');
        this.uploadDia1 = false
      } else {
        this.$message.error(response.msg)
      }
      this.getYearDetailPlanList()
    },
    beforeUpload1(file) {
      if (file.size > 1024 * 1024 * 10) {
        this.$message.error('上传文件不超过10M');
        this.$refs.upload1.clearFiles()
        return false;
      } else {
        return true;
      }
    },
    onError1(err, file, fileList) {
      this.$message.error('上传失败')
      this.$refs.upload1.clearFiles()
      this.uploading1 = false
    },
    submitUpload1() {
      if (!this.fileList1 || this.fileList1.length === 0) {
        this.$message.error('未选择文件')
        return
      }
      this.uploading1 = true
      this.$refs.upload1.submit();
      this.uploadDia1 = false;
    },
    // end
    // 打开评价弹框
    evaluate(row) {
      if (row.itemKind === 'INSPECTION') {
        this.inspectionEvaluateDialog = true
        this.$nextTick(() => this.$refs.inspectionEvaluateDialog.open(row))
        return
      }
      this.evaluateDialog = true
      this.$nextTick(() => {
        this.$refs.evaluateDialog.openDia(row)
      })
    },
    closeEvaDia() {
      this.evaluateDialog = false
      this.getYearDetailPlanList()
    },
    closeInspectionEvaluateDialog() {
      this.inspectionEvaluateDialog = false
      this.getYearDetailPlanList()
    },
    dispatchTask(row) {
      this.$confirm(`确认下发“${row.monitorProject}”的质量监控检验任务?`, '下发任务').then(() => {
        dispatchInspectionTask(row.qualityMonitorDetailsId).then(res => {
          this.$message.success(`已下发监控任务:${res.data.entrustCode}`)
          this.getYearDetailPlanList()
        })
      }).catch(() => {})
    },
    cancelTask(row) {
      this.$confirm(`确认取消监控任务“${row.inspectionTaskCode}”?已取消任务会保留历史记录。`, '取消任务').then(() => {
        cancelInspectionTask(row.qualityMonitorDetailsId).then(() => {
          this.$message.success('任务已取消')
          this.getYearDetailPlanList()
        })
      }).catch(() => {})
    },
    // 附件上传
    viewTestRecord (row) {
      this.ViewRecord = true
      this.$nextTick(() => {
        this.$refs.ViewRecord.openDia(row)
      })
    },
    // 打开导出弹框
    downLoadPost(row) {
      this.downloadDialog = true
      this.download = row
    },
    // 打开年度明细新增、修改弹框
    showDialog(type, row) {
      if (!this.qualityMonitorId) {
        this.$message.warning('请先新建年度质量控制计划')
        return
      }
      if (!this.canEditPlan) {
        this.$message.warning('当前计划状态不能维护质控项目')
        return
      }
      this.formDia = true
      this.$nextTick(() => {
        this.$refs.formDia.openDia(type, row)
      })
    },
    closeDia() {
      this.formDia = false
      this.getYearDetailPlanList()
    },
    // 控制单导出
    controlDown() {
      exportQualityMonitorRatify({ qualityMonitorDetailsId: this.download.qualityMonitorDetailsId }).then(res => {
        this.outLoading = false
        const blob = new Blob([res], { type: 'application/msword' });
        this.$download.saveAs(blob, '质量监控实施计划.docx')
      })
    },
    // 完成报告导出
    finishReportExport() {
      let url = this.download.finishReportUrl;
      const link = document.createElement('a');
      link.href = this.javaApi +'/word/' + url;
      link.target = '_blank';
      document.body.appendChild(link);
      link.click();
    },
    // 处理单导出
    processingDown() {
      exportQualityMonitorEvaluate({ qualityMonitorDetailsId: this.download.qualityMonitorDetailsId }).then(res => {
        this.outLoading = false
        const blob = new Blob([res], { type: 'application/msword' });
        this.$download.saveAs(blob, '质量监控评价.docx')
      })
    },
    delYearPlanDetail(row) {
      this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.yearDetailLoading = true
        delQualityMonitorDetail({ qualityMonitorDetailsId: row.qualityMonitorDetailsId }).then(res => {
          this.yearDetailLoading = false
          this.$message.success('删除成功')
          this.getYearDetailPlanList()
        }).catch(err => {
          this.yearDetailLoading = false
          console.log('err---', err);
        })
      })
    },
    // 获取负责人信息接口
    getUserList() {
      selectUserCondition().then((res) => {
        this.responsibleOptions = res.data;
      })
    },
    exportSignatureTemplate() {
      let url = '质量监控记录签名模板.docx';
      const link = document.createElement('a');
      link.href = this.javaApi +'/word/' + url;
      link.target = '_blank';
      document.body.appendChild(link);
      link.click();
    },
    formatDate(value) {
      return value ? String(value).slice(0, 10) : '-'
    },
    planWorkflowText(value) {
      return ({
        DRAFT: '草稿',
        PENDING_REVIEW: '待审核',
        REVIEW_REJECTED: '审核退回',
        PENDING_APPROVAL: '待批准',
        APPROVAL_REJECTED: '批准退回',
        APPROVED: '已批准'
      })[value] || '历史计划'
    },
    planWorkflowType(value) {
      return ({
        DRAFT: 'info',
        PENDING_REVIEW: 'warning',
        REVIEW_REJECTED: 'danger',
        PENDING_APPROVAL: 'warning',
        APPROVAL_REJECTED: 'danger',
        APPROVED: 'success'
      })[value] || 'info'
    },
    canReviewRow(row) {
      return row.workflowStatus === 'PENDING_REVIEW'
        && Number(this.userId) === Number(row.examineUserId)
    },
    canApproveRow(row) {
      return row.workflowStatus === 'PENDING_APPROVAL'
        && Number(this.userId) === Number(row.ratifyUserId)
    },
    canDeleteRow(row) {
      return Number(this.userId) === Number(row.writeUserId)
        && ['DRAFT', 'REVIEW_REJECTED', 'APPROVAL_REJECTED'].includes(row.workflowStatus || 'DRAFT')
    },
    handlePlanCommand(command, row) {
      if (command === 'export') this.handleDown(row)
      if (command === 'delete') this.delPlan(row)
    },
    inspectionTaskStatus(row) {
      if (row.itemKind !== 'INSPECTION') return '无需下发'
      const value = row.inspectionTaskState
      if (value === null || value === undefined) {
        return Number(row.planRatifyStatus) === 1 ? '未下发' : '待计划批准'
      }
      const map = { 0: '待检测', 1: '检测中', 2: '检测中', 3: '待复核', 4: '复核退回', 5: '待评价' }
      return map[value] || '处理中'
    },
    handleDetailCommand(command, row) {
      const handlers = {
        complete: () => this.record(row),
        evaluate: () => this.evaluate(row),
        requirement: () => this.evaluate(row),
        cancel: () => this.cancelTask(row),
        attachment: () => this.viewTestRecord(row),
        export: () => this.downLoadPost(row),
        delete: () => this.delYearPlanDetail(row)
      }
      handlers[command]?.()
    }
  },
  // 用于上传文件的信息
  computed: {
    ...mapGetters(["userId", "nickName"]),
    effectivePlanStatus() {
      if (!this.currentPlan) return ''
      if (this.currentPlan.workflowStatus) return this.currentPlan.workflowStatus
      if (this.currentPlan.ratifyStatus === 1) return 'APPROVED'
      if (this.currentPlan.ratifyStatus === 0) return 'APPROVAL_REJECTED'
      if (this.currentPlan.examineStatus === 1) return 'PENDING_APPROVAL'
      if (this.currentPlan.examineStatus === 0) return 'REVIEW_REJECTED'
      return 'DRAFT'
    },
    planStatusText() {
      return ({DRAFT:'草稿',PENDING_REVIEW:'待审核',REVIEW_REJECTED:'审核退回',PENDING_APPROVAL:'待批准',APPROVAL_REJECTED:'批准退回',APPROVED:'已批准'})[this.effectivePlanStatus] || '历史计划'
    },
    planStatusType() {
      return ({DRAFT:'info',PENDING_REVIEW:'warning',REVIEW_REJECTED:'danger',PENDING_APPROVAL:'warning',APPROVAL_REJECTED:'danger',APPROVED:'success'})[this.effectivePlanStatus] || 'info'
    },
    canEditPlan() {
      return !!this.currentPlan && Number(this.userId) === Number(this.currentPlan.writeUserId)
        && ['DRAFT','REVIEW_REJECTED','APPROVAL_REJECTED'].includes(this.effectivePlanStatus)
    },
    canReviewPlan() {
      return !!this.currentPlan && this.effectivePlanStatus === 'PENDING_REVIEW'
        && Number(this.userId) === Number(this.currentPlan.examineUserId)
    },
    canApprovePlan() {
      return !!this.currentPlan && this.effectivePlanStatus === 'PENDING_APPROVAL'
        && Number(this.userId) === Number(this.currentPlan.ratifyUserId)
    },
    action() {
      return this.javaApi + '/qualityMonitor/importQualityMonitor'
    },
    action1() {
      return this.javaApi + '/qualityMonitor/uploadFinishReport'
    }
  },
  beforeUnmount() {
    clearTimeout(this.timer);
  }
};
</script>
 
<style scoped>
.plan-list-card {
  min-width: 0;
  padding: 14px 16px;
  background: var(--lims-card-bg, var(--el-bg-color));
  border: 1px solid var(--el-border-color-light);
  border-radius: 4px;
}
.plan-list-toolbar,
.plan-list-filters,
.plan-list-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.plan-list-toolbar {
  justify-content: space-between;
  margin-bottom: 14px;
}
.filter-label {
  margin-left: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--lims-text-2);
  white-space: nowrap;
}
.annual-plan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  margin-bottom: 16px;
  background: var(--lims-card-bg, var(--el-bg-color));
  border: 1px solid var(--el-border-color-light);
  border-radius: 4px;
}
.annual-plan-main, .annual-plan-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.annual-plan-label { font-weight: 700; color: var(--lims-text-2); }
.plan-detail-card {
  min-width: 0;
  background: var(--lims-card-bg, var(--el-bg-color));
}
.plan-detail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.section-title {
  display: inline-flex;
  align-items: center;
  margin-right: 18px;
  font-size: 15px;
  font-weight: 700;
  color: var(--lims-text-1, var(--el-text-color-primary));
  white-space: nowrap;
}
.detail-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
@media (max-width: 1200px) {
  .annual-plan-header {
    align-items: flex-start;
    flex-direction: column;
  }
  .annual-plan-actions {
    width: 100%;
  }
}
</style>