zouyu
2023-09-08 2c38eea08bc6060c3371885e9f7fe79473968223
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
<template>
  <div class="ledger-main">
    <div class="page-header-search">
      <div class="serve-btn">
        <el-button size="small" type="primary" icon="el-icon-plus"
          @click="showAddDrawer()">新增仪器</el-button>
      </div>
    </div>
    <div class="content-main">
      <div class="library-bom">
        <div class="bom-item-search">
          <el-row>
            <el-col :span="19">
              <el-input size="small" v-model="filterText" clearable placeholder="输入关键字进行过滤" />
            </el-col>
            <el-col :span="5">
              <el-button type="primary" size="small" @click="addClassVisible = true"><i
                  class="el-icon-plus" /></el-button>
            </el-col>
          </el-row>
        </div>
        <el-tree :highlight-current="true" ref="classTree" :data="classTree" :props="defaultProps" :default-expand-all="true"
          :filter-node-method="filterNode" @node-click="nodeClickHandler" />
      </div>
      <div class="library-table">
        <div class="table-header">
          <div class="search-bar">
            <el-row :gutter="20">
              <el-col :span="8">
                <el-form ref="form" :inline="true" :model="searchData">
                  <el-form-item width="200">
                    <el-input size="small" v-model="searchData.keyword" placeholder="请输入编号/设备名称/型号规格">
                      <i slot="prefix" class="el-input__icon el-icon-search" />
                    </el-input>
                  </el-form-item>
                  <el-form-item>
                    <el-button size="small" type="primary" @click="filterTableData">查询</el-button>
                    <el-button size="small" type="primary" plain @click="resetBtn">重置</el-button>
                  </el-form-item>
                </el-form>
              </el-col>
              <el-col :span="16">
                <el-radio-group v-model="radioValue" @change="getConditionTable">
                  <el-radio-button v-for="item in conditionsOptions" :key="item.value" :label="item.value">
                    {{ item.label }}
                  </el-radio-button>
                </el-radio-group>
                <el-checkbox v-model="isOut" @change="getExpireTable" :style="{ 'marginLeft': '12px' }">已过期</el-checkbox>
              </el-col>
            </el-row>
          </div>
        </div>
        <div class="table-box">
          <el-table ref="equipmentTable" node-key="father_name" :cell-style="{ textAlign: 'left' }"
            :header-cell-style="{ border: '0px', background: '#f5f7fa', color: '#606266', boxShadow: 'inset 0 1px 0 #ebeef5', textAlign: 'left' }"
            :data="equipmentTable" style="width: 100%;height: 100vh">
            <el-table-column type="index" label="序号" min-width="90" />
            <el-table-column prop="equipment_code" label="仪器设备编号" min-width="200" />
            <el-table-column prop="equipment_name" label="仪器设备名称" min-width="150" />
            <el-table-column prop="specifications_models" label="规格型号" min-width="150" />
            <el-table-column prop="name" label="保管人" min-width="200" />
            <el-table-column prop="termValidity" label="计量截止有效期" min-width="200" />
            <el-table-column prop="conditions" label="设备状态" min-width="120">
              <template slot-scope="scope">
                <el-tag v-if="scope.row.conditions === 1" type="success" disable-transitions>运行</el-tag>
                <el-tag v-if="scope.row.conditions === 2" type="danger" disable-transitions>故障</el-tag>
                <el-tag v-if="scope.row.conditions === 3" type="warning" disable-transitions>报修</el-tag>
                <el-tag v-if="scope.row.conditions === 4" type="warning" disable-transitions>检修</el-tag>
                <el-tag v-if="scope.row.conditions === 5" disable-transitions>待机</el-tag>
              </template>
            </el-table-column>
            <el-table-column prop="storage_place" label="存放地" min-width="200" />
            <el-table-column label="操作" min-width="120" fixed="right">
              <template slot-scope="scope">
                <el-button type="text" size="small" @click="openDetail(scope.row)">编辑</el-button>
                <el-button type="text" size="small" @click="clickDelete(scope.row)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
          <!-- 弹出表单页 -->
          <div>
            <!-- 添加分类 -->
            <el-dialog title="添加分类" :visible.sync="addClassVisible" width="33%">
              <el-form :model="addTreeForm" ref="addTreeForm">
                <el-form-item prop="name" label="分类名称" label-width="100px" :rules="[
                  { required: true, message: '分类名称不能为空' }
                ]">
                  <el-input placeholder="请填写分类名称" v-model="addTreeForm.name" />
                </el-form-item>
                <el-form-item label="父级分类" label-width="100px">
                  <el-cascader v-model="addTreeForm.type" :options="addTreeFormClassTree" style="width: 374.88px;"
                    :show-all-levels="false" />
                </el-form-item>
              </el-form>
              <div slot="footer" class="dialog-footer">
                <el-button @click="resetTreeForm('addTreeForm')">取 消</el-button>
                <el-button type="primary" @click="submitTreeForm('addTreeForm')">确 定</el-button>
              </div>
            </el-dialog>
          </div>
          <div>
            <el-pagination :current-page="currentPage" :page-sizes="[10, 15, 20, 25]" :page-size="pageSize"
              layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handleSizeChange"
              @current-change="handleCurrentChange" />
          </div>
        </div>
      </div>
    </div>
    <!-- 仪器详情-->
    <el-drawer title="仪器设备详情" :visible.sync="detailDrawer" size="80%" class="detailDrawer" @close="closeDetailDrawer">
      <div>
        <div class="detail-info">
          <div class="tips-main">
            <div class="tips">
              <span />
              <div>基本信息</div>
            </div>
            <div class="tips-btn">
              <el-button type="primary" @click="addDrawerVisible = true">编辑</el-button>
            </div>
          </div>
          <div class="message">
            <div class="message-item"><span><i class="el-icon-edit" />所属分类:{{ equipmentDetail.classifyId }}</span></div>
            <div class="message-item">
              <span><i class="el-icon-user" />创建人:{{ equipmentDetail.createUserId }}</span>
              <!-- <el-tag type="primary"><i class="el-icon-info" :style="{ marginRight: '4px', color: '#409EFF' }" /></el-tag> -->
            </div>
            <div class="message-item">
              <span><i class="el-icon-edit" />建档日期:{{ equipmentDetail.acceptanceDate }}</span>
            </div>
            <div class="message-item">
              <span><i class="el-icon-edit" />设备编号:{{ equipmentDetail.equipmentCode }}</span>
            </div>
            <div class="message-item">
              <span><i class="el-icon-edit" />型号规格:{{ equipmentDetail.specificationsModels }}</span>
            </div>
            <div class="message-item">
              <span><i class="el-icon-edit" />测量范围:{{ equipmentDetail.measuringRange }}</span>
            </div>
            <div class="message-item">
              <span><i class="el-icon-edit" />不确定度/误差:{{ equipmentDetail.errorRate }}</span>
            </div>
            <div class="message-item">
              <span><i class="el-icon-edit" />生产厂家:{{ equipmentDetail.manufacturer }}</span>
            </div>
            <div class="message-item">
              <span><i class="el-icon-edit" />存放地点:{{ equipmentDetail.storagePlace }}</span>
            </div>
            <div class="message-item">
              <span><i class="el-icon-edit" />到货日期:{{ equipmentDetail.arrivalDate }}</span>
            </div>
            <div class="message-item">
              <span><i class="el-icon-edit" />验收日期:{{ equipmentDetail.acceptanceDate }}</span>
            </div>
            <div class="message-item">
              <span><i class="el-icon-edit" />保管人:{{ equipmentDetail.userName }}</span>
            </div>
            <div class="message-item">
              <span><i class="el-icon-edit" />是否支持数采:{{ equipmentDetail.whetherDataAcquisition == 1 ? '支持' : '不支持'
              }}</span>
            </div>
            <div class="message-item">
              <span><i class="el-icon-edit" />仪器设备计量:{{ equipmentDetail.equipmentMeasurement == 1 ? '需要' : '不需要' }}</span>
            </div>
            <div class="message-item">
              <span><i class="el-icon-edit" />计量周期:{{ equipmentDetail.termValidity }}</span>
            </div>
            <div class="message-item">
              <span><i class="el-icon-edit" />描述:{{ equipmentDetail.descriptiveness }}</span>
            </div>
          </div>
        </div>
        <el-tabs v-model="activeTabsName">
          <el-tab-pane label="设备码点" name="codePoints">
            <div :style="{ marginBottom: '18px' }" class="btns">
              <el-button @click="addNewCodePoints">添加</el-button>
              <el-button v-show="codePointesTableStatus" @click="saveCodePoins">保存</el-button>
              <el-button @click="closeCodePoins">取消</el-button>
            </div>
 
            <el-table ref="codePointsTable" :cell-style="{ textAlign: 'center' }"
              :header-cell-style="{ border: '0px', background: '#f5f7fa', color: '#606266', boxShadow: 'inset 0 1px 0 #ebeef5', textAlign: 'center' }"
              :data="codePointsTable" style="width: 100%;overflow: scroll;height:314px;">
              <el-table-column type="index" label="序号" min-width="90" />
              <el-table-column prop="equipmentPoint" label="码点编码" min-width="150">
                <template slot-scope="scope">
                  <el-input v-if="codePointesTableStatus && scope.row.isInput" v-model="scope.row.equipmentPoint" />
                  <span v-else>{{ scope.row.equipmentPoint }}</span>
                </template>
              </el-table-column>
              <el-table-column prop="equipmentPointName" label="码点名称" min-width="150">
                <template slot-scope="scope">
                  <el-input v-if="codePointesTableStatus && scope.row.isInput" v-model="scope.row.equipmentPointName" />
                  <span v-else>{{ scope.row.equipmentPointName }}</span>
                </template>
              </el-table-column>
              <el-table-column prop="unit" label="单位" min-width="150">
                <template slot-scope="scope">
                  <el-input v-if="codePointesTableStatus && scope.row.isInput" v-model="scope.row.unit" />
                  <span v-else>{{ scope.row.unit }}</span>
                </template>
              </el-table-column>
              <el-table-column prop="descriptiveness" label="描述" min-width="200">
                <template slot-scope="scope">
                  <el-input v-if="codePointesTableStatus && scope.row.isInput" v-model="scope.row.descriptiveness" />
                  <span v-else>{{ scope.row.descriptiveness }}</span>
                </template>
              </el-table-column>
 
            </el-table>
          </el-tab-pane>
          <el-tab-pane label="计量信息" name="measure">
            <el-button :style="{ marginBottom: '18px' }" @click="measureFormVisible = true">新增计量信息</el-button>
            <el-table ref="measureTable" :cell-style="{ textAlign: 'center' }"
              :header-cell-style="{ border: '0px', background: '#f5f7fa', color: '#606266', boxShadow: 'inset 0 1px 0 #ebeef5', textAlign: 'center' }"
              :data="measureTable" style="width: 100%">
              <el-table-column type="index" label="序号" min-width="90" />
              <el-table-column prop="name" label="负责人" min-width="200" />
              <el-table-column prop="measurement_unit" label="计量单位" min-width="150" />
              <el-table-column prop="beginDate" label="开始日期" min-width="150" />
              <el-table-column prop="endDate" label="结束日期" min-width="150" />
              <el-table-column prop="performance_index" label="性能指标" min-width="200" />
              <el-table-column prop="uncertainty" label="不确定度" min-width="200" />
              <el-table-column prop="conditions" label="结果" min-width="120">
                <template slot-scope="scope">
                  {{ scope.row.result }}
                  <!-- <el-tag
                    :type="scope.row.result === 0 ? 'primary' : 'success'"
                    disable-transitions
                  >{{ scope.row.result === 0 ? '未同意' : '已同意' }}</el-tag> -->
                </template>
              </el-table-column>
              <el-table-column prop="remarks" label="备注" min-width="200" />
            </el-table>
          </el-tab-pane>
        </el-tabs>
      </div>
    </el-drawer>
    <!-- 添加仪器/修改仪器信息 -->
    <el-drawer ref="addDrawer" :title="equipmentDetail.id ? '修改仪器设备信息' : '新增仪器设备'" :append-to-body="true"
      :visible.sync="addDrawerVisible" class="addDrawer" size="40%" @close="closeAddOrChangeDrawer">
      <div class="demo-drawer__content">
        <el-form label-position="top" ref="addNewEquipment" :model="equipmentform">
          <el-row :gutter="50">
            <el-col :span="11">
              <el-form-item label="所属分类:" prop="classifyId" label-width="80" :rules="[
                { required: true, message: '请选择所属分类', trigger: 'blur' }
              ]">
                <el-cascader style="width: 100%;" v-model="equipmentform.classifyId" :options="classTree" :show-all-levels="false" />
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="设备编号:" prop="equipmentCode"
                :rules="[{ required: true, message: '请填写设备编号', trigger: 'blur' }]" label-width="80">
                <el-input v-model="equipmentform.equipmentCode" placeholder="请填写设备编号" autocomplete="off" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="50">
            <el-col :span="11">
              <el-form-item label="仪器设备名称:" prop="equipmentName"
                :rules="[{ required: true, message: '请填写仪器设备名称', trigger: 'blur' }]" label-width="80">
                <el-input v-model="equipmentform.equipmentName" placeholder="请填写仪器设备名称" autocomplete="off" />
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="状态:" prop="conditions"
                :rules="[{ required: true, message: '请选择仪器设备状态', trigger: 'blur' }]" label-width="80">
                <el-select v-model="equipmentform.conditions" clearable :allow-create="true"
                  placeholder="请选择仪器设备状态" style="width:100%">
                  <el-option v-for="item in conditionsOptions" :key="item.value" :label="item.label"
                    :value="item.value" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="50">
            <el-col :span="11">
              <el-form-item label="型号规格:" prop="specificationsModels"
                :rules="[{ required: true, message: '请填写型号规格', trigger: 'blur' }]" label-width="80">
                <el-input v-model="equipmentform.specificationsModels" placeholder="请填写型号规格" autocomplete="off" />
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="测量范围:" label-width="80">
                <el-input v-model="equipmentform.measuringRange" placeholder="请填写测量范围" autocomplete="off" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="50">
            <el-col :span="11">
              <el-form-item label="不确定度/准确度/最大允许误差:" label-width="80">
                <el-input v-model="equipmentform.errorRate" placeholder="请填写不确定度/准确度/最大允许误差" autocomplete="off" />
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="生产厂家:" label-width="80">
                <el-input v-model="equipmentform.manufacturer" placeholder="请填写生产厂家" autocomplete="off" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="50">
            <el-col :span="11">
              <el-form-item label="存放地点:" label-width="80">
                <el-input v-model="equipmentform.storagePlace" placeholder="请填写存放地点" autocomplete="off" />
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="到货日期:" label-width="80">
                <el-date-picker value-format="yyyy-MM-dd" v-model="equipmentform.arrivalDate" type="date" placeholder="请选择到货日期"
                  style="width:100%" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="50">
            <el-col :span="11">
              <el-form-item label="验收日期:" label-width="80">
                <el-date-picker  value-format="yyyy-MM-dd" v-model="equipmentform.acceptanceDate" type="date" placeholder="请选择验收日期"
                  style="width:100%" />
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="保管人:" label-width="80">
                <el-select v-model="equipmentform.userId" clearable :allow-create="true" placeholder="请选择保管人"
                  style="width:100%">
                  <el-option v-for="item in userOpetions" :key="item.id" :label="item.label" :value="item.value" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="50">
            <el-col :span="11">
              <el-form-item label="是否支持数采:" label-width="80">
                <el-radio v-model="equipmentform.whetherDataAcquisition" :label="1">支持</el-radio>
                <el-radio v-model="equipmentform.whetherDataAcquisition" :label="0">不支持</el-radio>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="仪器设备计量:" label-width="80">
                <el-radio v-model="equipmentform.equipmentMeasurement" :label="1">需要</el-radio>
                <el-radio v-model="equipmentform.equipmentMeasurement" :label="0">不需要</el-radio>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row v-show="equipmentform.equipmentMeasurement === 1" :gutter="50">
            <el-col :span="12">
              <el-form-item label="计量周期(月):" label-width="80">
                <el-input min="0" v-model="equipmentform.termValidity" placeholder="请填写计量周期" type="number" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="50">
            <el-col :span="11">
              <el-form-item label="描述:" label-width="80">
                <el-input v-model="equipmentform.descriptiveness" type="textarea" :rows="2" placeholder="请输入内容"
                  style="width:217%" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div class="demo-drawer__footer">
          <el-button class="el-button--default" @click="cancelAddEq">取 消</el-button>
          <el-button type="primary" class="el-button--primary el-button--medium" @click="addNewEquipment">确 定</el-button>
        </div>
      </div>
    </el-drawer>
    <!-- 新增计量信息弹窗 -->
    <el-dialog class="measureForm" title="新增计量" :visible.sync="measureFormVisible">
      <el-form label-position="top" ref="addmeasureForm" :model="measureForm">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="负责人" prop="userId" :rules="[{ required: true, message: '请选择负责人', trigger: 'change' }]">
              <el-select v-model="measureForm.userId" clearable filterable :allow-create="true" placeholder="负责人"
                style="width:100%">
                <el-option v-for="item in userOpetions" :key="item.id" :label="item.label" :value="item.value" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="计量单位" prop="measurementUnit"
              :rules="[{ required: true, message: '请填写计量单位', trigger: 'blur' }]">
              <el-input placeholder="请填写计量单位" v-model="measureForm.measurementUnit" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="检定有效期" prop="date" :rules="[{ required: true, message: '请选择检定有效期', trigger: 'blur' }]">
              <el-date-picker v-model="measureForm.date" type="daterange" range-separator="至" start-placeholder="开始日期"
                end-placeholder="结束日期" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="不确定度" prop="uncertainty"
              :rules="[{ required: true, message: '请填写不确定度', trigger: 'blur' }]">
              <el-input placeholder="请填写不确定度" v-model="measureForm.uncertainty" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="结果" prop="result" :rules="[{ required: true, message: '请选择结果', trigger: 'change' }]">
              <el-select v-model="measureForm.result" clearable filterable :allow-create="true" placeholder="请选择结果"
                style="width:100%">
                <el-option v-for="item in resultOptions" :key="item.id" :label="item.label" :value="item.value" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="性能指标">
              <el-input v-model="measureForm.performanceIndex" type="textarea" :rows="2" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="备注">
              <el-input v-model="measureForm.remarks" type="textarea" :rows="2" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="" prop="file">
              <el-upload ref="upload" class="upload-demo" action="#" :on-change="handleUpload" :auto-upload="false">
                <el-button size="small" type="primary">点击上传</el-button>
              </el-upload>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="addMeasure">确 定</el-button>
 
        <el-button @click="cancelAddMeasure">取 消</el-button>
      </span>
    </el-dialog>
    <!-- 删除仪器弹出框 -->
    <el-dialog title="提示" :visible.sync="deletedialogVisible" width="30%">
      <span>确定删除该仪器吗?</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="deletedialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="deleteInstrument">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
 
<script>
import {
  getClassifyList, getInstrumentList,
  addInstrumentUser, addInstrument, getInstrumentDetail,
  getEquipmentPointList, addEquipmentPoint,
  getMetricalInformationList, changeInstrument, addMetricalInformation, deleteInstrument, addClassify
} from '@/api/laboratory/ledger'
import { parseTime } from '@/utils/index'
export default {
  filters: {},
  data() {
    return {
      // 用户下拉框配置项
      userOpetions: [],
      // 仪器状态配置项
      conditionsOptions: [
        {
          label: '运行',
          value: 1
        },
        {
          label: '故障',
          value: 2
        },
        {
          label: '报修',
          value: 3
        },
        {
          label: '检修',
          value: 4
        },
        {
          label: '待机',
          value: 5
        }
      ],
      // 计量状态配置项
      resultOptions: [
        {
          label: '合格',
          value: 1
        },
        {
          label: '校正后可用',
          value: 2
        },
        {
          label: '不合格',
          value: 3
        }
 
      ],
      // 分类tree数据,分类配置项
      classTree: [],
      // 添加分类参数
      addTreeForm: {
        name: null,
        type: null
      },
      // tree默认值
      defaultProps: {
        children: 'children',
        label: 'label'
      },
      // 搜索关键字
      searchData: {
        keyword: ''
      },
      // 表格搜索单选值
      radioValue: '0',
      // 表格搜索已过期
      // 是否过期
      isOut: false,
      // 控制添加分类模态框显示
      addClassVisible: false,
      // 控制新增计量模态框显示
      measureFormVisible: false,
      // 控制删除仪器模态框显示
      deletedialogVisible: false,
      // 控制添加修改仪器抽屉的显示
      addDrawerVisible: false,
      // 添加修改仪器参数对象
      equipmentform: {
        acceptanceDate: '', // 验收日期
        arrivalDate: '', // 到货日期
        classifyId: '', // 所属分类
        conditions: '', // 状态
        descriptiveness: '', // 描述
        equipmentCode: '', // 设备编号
        equipmentMeasurement: 1, // 仪器设备计量
        equipmentName: '', // 仪器设备名称
        errorRate: '', // 不确定度/准确度/最大允许误差
        userId: '', // 保管人
        manufacturer: '', // 生产厂家
        measuringRange: '', // 测量范围
        specificationsModels: '', // 型号规格
        storagePlace: '', // 存放地点
        whetherDataAcquisition: 1 // 是否支持数采
      },
      // 控制设备仪器详情抽屉显示
      detailDrawer: false,
      // 设备数据列表
      equipmentTable: [],
      // 分页参数
      currentPage: 1,
      pageSize: 10,
      total: 0,
      // 码点表格
      codePointsTable: [
        {
          'isInput':false,
          'unit': '',
          'descriptiveness': '',
          'equipmentPoint': '',
          'name': '',
          'updateTime': '',
          'id': 1,
          'equipmentPointName': ''
        }
      ],
      // 计量信息表
      measureTable: [],
      // 添加计量信息参数对象
      measureForm: {
        userId: null,
        measurementUnit: null,
        date: null,
        uncertainty: null,
        result: null,
        performanceIndex: null,
        remarks: null,
        file: ""
      },
      activeTabsName: 'codePoints',
      // 码点表格的状态:数据展示false/新增输入true
      codePointesTableStatus: false,
      // 设备详情对象
      equipmentDetail: {},
      // 过滤关键字
      filterText: '',
      // 过滤后的仪器设备表
      filterdequipmentTable: '',
      oldtableData: '',
      // 过滤不同状态设备
      conditionTable: '',
      nodeclicked: '',
      expireData: '',
      instrumentId: '',
      addTreeFormClassTree: []
    }
  },
  watch: {
    filterText(val) {
      this.$refs.classTree.filter(val)
    },
    measureFormVisible(newVal){
      if(newVal === false){
        this.cancelAddMeasure();
      }
    }
  },
  created() {
    this.getThreeData()
    this.getUserOptions()
  },
  methods: {
    //显示新增仪器模态框
    showAddDrawer(){
      this.addDrawerVisible = true; 
      this.equipmentform = {
        acceptanceDate: '', // 验收日期
        arrivalDate: '', // 到货日期
        classifyId: '', // 所属分类
        conditions: '', // 状态
        descriptiveness: '', // 描述
        equipmentCode: '', // 设备编号
        equipmentMeasurement: 1, // 仪器设备计量
        equipmentName: '', // 仪器设备名称
        errorRate: '', // 不确定度/准确度/最大允许误差
        userId: '', // 保管人
        manufacturer: '', // 生产厂家
        measuringRange: '', // 测量范围
        specificationsModels: '', // 型号规格
        storagePlace: '', // 存放地点
        whetherDataAcquisition: 1 // 是否支持数采
      }
    },
    // 获取分类数据
    async getThreeData() {
      const { data } = await getClassifyList()
      this.classTree = data.map(item => {
        if (item.children) {
          item.children = item.children.map(childrenItem => {
            return { ...childrenItem, label: childrenItem.son_name, value: childrenItem.id }
          })
        }
        return { ...item, label: item.father_name, value: item.id ? item.id : item.father_name }
      })
      this.addTreeFormClassTree = JSON.parse(JSON.stringify(this.classTree))
      let father = {
        children: null,
        father_name: "无",
        id: 0,
        label: "无",
        value: 0
      }
      this.addTreeFormClassTree.unshift(father)
      this.addTreeFormClassTree.forEach(item => {
        item.children = null
      })
    },
    // 获取用户信息配置项
    async getUserOptions() {
      const { data } = await addInstrumentUser()
      this.userOpetions = data.map(item => ({ ...item, label: item.name, value: item.id }))
    },
    // 显示仪器详情
    async openDetail(row) {
      this.detailDrawer = true
      const { data } = await getInstrumentDetail({ InstrumentId: row.id })
      this.equipmentDetail = data
      this.equipmentform = data
      const { data: pointList } = await getEquipmentPointList({ InstrumentId: this.equipmentDetail.id })
      this.codePointsTable = pointList
      const { data: informationList } = await getMetricalInformationList({ InstrumentId: this.equipmentDetail.id })
      this.measureTable = informationList
    },
    // 节点点击处理
    nodeClickHandler(data, node, element) {
      this.nodeclicked = data
      // 只有数据中携带id才能发送查询请求
      if (data.id) {
        this.getEquipmentTable({ classifyId: data.id, pageSize: this.pageSize, pageNo: this.currentPage, whetherWhether: this.isOut })
      }
    },
    // 获取仪器列表数据
    async getEquipmentTable(ages) {
      const { data } = await getInstrumentList(ages)
      this.equipmentTable = data.row
      this.total = data.total
      this.oldtableData = this.equipmentTable
    },
    // 过滤节点
    filterNode(value, data) {
      if (!value) return true
      return data.label.indexOf(value) !== -1
    },
    // 改变页面数据大小
    handleSizeChange() {
      // 当前页大小
    },
    // 改变当前页
    handleCurrentChange() {
      // 当前页更改
    },
    // 新增设备码点
    addNewCodePoints() {
      this.codePointesTableStatus = true;
      const newObj = {}
      newObj.isInput = true,
      newObj.name = '' // 当前用户的名称
      newObj.updateTime = '' // 获取当前时间
      newObj.equipmentPoint = ''
      newObj.equipmentPointName = ''
      newObj.descriptiveness = ''
      newObj.unit = ''
      newObj.instrumentId = this.equipmentDetail.id
      this.codePointsTable.unshift(newObj)
    },
    // 保存提交新增设备码点
    async saveCodePoins() {
      if (this.codePointsTable.length === 0) {
        return this.$message.error('请点击添加按钮添加数据')
      }
      let data = this.codePointsTable.filter(item => {
        return item.instrumentId != null;
      })
      await addEquipmentPoint(data).then(()=>{
        this.$message.success('添加成功')
      }).catch(error=>{
        this.$message.error(error.message)
      })
      await this.closeCodePoins()
    },
    // 取消新增设备码点
    async closeCodePoins() {
      this.codePointesTableStatus = false
      this.codePointsTable = undefined
      const { data: pointList } = await getEquipmentPointList({ InstrumentId: this.equipmentDetail.id })
      this.codePointsTable = pointList
    },
    async submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          return true
        } else {
          return false;
        }
      });
    },
    // 点击新增仪器设备或当存在仪器详情时是修改仪器设备信息
    async addNewEquipment() {
      this.$refs["addNewEquipment"].validate(async(valid)=>{
        if(valid){
          if (Array.isArray(this.equipmentform.classifyId)) {
            this.equipmentform.classifyId = this.equipmentform.classifyId.pop()
          }
          if (!this.equipmentDetail.id) {
            // 格式化日期
            this.equipmentform.arrivalDate = parseTime(this.equipmentform.arrivalDate, '{y}-{m}-{d}')
            this.equipmentform.acceptanceDate = parseTime(this.equipmentform.acceptanceDate, '{y}-{m}-{d}')
            // this.equipmentform.termValidity = parseTime(this.equipmentform?.termValidity, '{y}-{m}-{d}')
            await addInstrument(this.equipmentform).then(()=>{
              this.$message.success('添加成功')
            }).catch(error=>{
              this.$message.error(error.message);
            })
            let d = this.nodeclicked;
            this.nodeClickHandler(d);
            this.addDrawerVisible = false
            this.equipmentform = {}
            return
          }
          console.log('修改仪器参数', this.equipmentform)
          await changeInstrument(this.equipmentform).then(()=>{
            this.$message.success('修改成功')
            let d = this.nodeclicked;
            this.nodeClickHandler(d);
            this.addDrawerVisible = false
            this.detailDrawer = false
          }).catch(error=>{
            this.$message.error(error.message);
          })
        }
      });
    },
    cancelAddEq() {
      this.resetForm('addDrawer')
      this.addDrawerVisible = false
    },
    resetForm(formName) {
      this.measureForm = {
        userId: null,
        measurementUnit: null,
        date: null,
        uncertainty: null,
        result: null,
        performanceIndex: null,
        remarks: null,
        file: ""
      }
      this.$refs[formName].resetFields();
    },
    cancelAddMeasure() {
      this.measureForm.file = null;
      this.measureFormVisible = false
      this.resetForm('addmeasureForm');
      this.$refs['upload'].clearFiles();
    },
    // 添加计量信息
    async addMeasure() {
      this.$refs['addmeasureForm'].validate(async(valid)=>{
        if(valid){
          // 格式化时间
          this.measureForm.instrumentId = this.equipmentDetail.id
          if (Array.isArray(this.measureForm.date)) {
            this.measureForm.beginDate = parseTime(this.measureForm.date[0], '{y}-{m}-{d}')
            this.measureForm.endDate = parseTime(this.measureForm.date[1], '{y}-{m}-{d}')
          }
          const formData = new FormData()
          if(this.measureForm.file == null || this.measureForm.file == ""){
            this.$message.warning("请选择要上传的文件!");
            return;
          }else{
            formData.append('file', this.measureForm.file?.raw, this.measureForm.file?.name)
          }
          for (const key in this.measureForm) {
            formData.append(key, this.measureForm[key])
          }
          try {
            await addMetricalInformation(formData)
            this.$message.success('添加成功')
            const { data: informationList } = await getMetricalInformationList({ InstrumentId: this.equipmentDetail.id })
            this.measureTable = informationList
            this.measureForm = {}
            this.measureFormVisible = false
          } catch (error) {
            this.$message.error('添加失败')
          }
          this.measureForm.file = null;
          this.$refs['upload'].clearFiles();
        }
      });
    },
    // 关闭设备详情抽屉
    closeDetailDrawer() {
      this.equipmentDetail = {}
      this.codePointsTable = []
      this.measureTable = []
      this.measureForm.file = null;
    },
    // 关闭添加修改设备抽屉
    closeAddOrChangeDrawer() {
      if (!this.equipmentDetail.id) {
        this.equipmentform = {}
      }
    },
    // 文件上传
    handleUpload(file, fileList) {
      this.measureForm.file = file
    },
    // 根据输入的设备编号,设备名称或者型号规格关键字进行过滤列表
    filterTableData() {
      this.oldtableData = this.equipmentTable
      const filterdequipmentTable = this.equipmentTable.filter(item => {
        return item.equipment_code.includes(this.searchData.keyword) || item.equipment_name.includes(this.searchData.keyword) || item.specifications_models.includes(this.searchData.keyword)
      })
      this.equipmentTable = filterdequipmentTable
    },
    resetBtn() {
      this.searchData.keyword = ''
      this.radioValue = 0;
      this.isOut = false;
      this.equipmentTable = this.oldtableData
    },
    getConditionTable() {
      let filteredTable = this.oldtableData.filter(item => {
        return item.conditions === this.radioValue
      })
      // 先判断isOut
      if (this.isOut) {
        // 如果现在勾选了已过期按钮,那就从当前过滤好的列表中筛选出过期列表
        if (this.expireData.length === 0) {
          this.equipmentTable = null
        } else {
          let expireItem
          for (expireItem of this.expireData) {
            filteredTable = filteredTable.filter(item => {
              return item.equipment_code === expireItem.equipment_code
            })
          }
          this.equipmentTable = filteredTable
        }
        if (!this.radioValue) {
          this.equipmentTable = this.expireData
        }
      } else {
        this.equipmentTable = filteredTable
        if (!this.radioValue) {
          this.equipmentTable = this.oldtableData
        }
      }
    },
    async getExpireTable() {
      // const filteredTable = this.oldtableData.filter(item => {
      //   return item.conditions === this.radioValue
      // })
      if (this.isOut) {
        // 捕获点击了已过期,请求过期数据并保存
        const { data } = await getInstrumentList({ classifyId: this.nodeclicked.id, pageSize: this.pageSize, pageNo: this.currentPage, whetherWhether: this.isOut })
        this.expireData = data.row
        if (this.expireData.length === 0) {
          this.equipmentTable = null
        } else {
          if (this.radioValue !== 0) {
            let expireItem
            for (expireItem of this.expireData) {
              this.equipmentTable = this.oldtableData.filter(item => {
                console.log('item', item)
                console.log('expireItem', expireItem)
                return item.conditions === this.radioValue && item.equipment_code === expireItem.equipment_code
              })
            }
          } else {
            this.equipmentTable = this.expireData
          }
        }
      } else {
        // 捕获取消了已过期,将过期数据清空,重新更新equipmentTable
        this.expireData = ''
        this.equipmentTable = this.oldtableData.filter(item => {
          return item.conditions === this.radioValue
        })
        if (this.radioValue === 0) {
          this.equipmentTable = this.oldtableData
        }
      }
    },
    clickDelete(row) {
      this.instrumentId = row.id
      this.deletedialogVisible = true
    },
    async deleteInstrument() {
      await deleteInstrument({ instrumentId: this.instrumentId }).then(res=>{
        this.$message.success('删除成功!');
        let d = this.nodeclicked
        this.nodeClickHandler(d);
      }).catch(()=>{
        this.$message.error('删除失败!');
      });
      this.deletedialogVisible = false
    },
    async submitTreeForm(formName) {
      let _that = this
      this.$refs[formName].validate((valid) => {
        if (valid) {
          _that.addClassifyInfo()
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    async addClassifyInfo() {
      let _that = this
      let data = {
        fatherName: null,
        sonName: null
      }
 
      if (_that.addTreeForm.type != null && _that.addTreeForm.type[0] != 0) {
        data.fatherName = _that.addTreeFormClassTree.filter(item => {
          return item.value == _that.addTreeForm.type[0]
        })[0].label
        data.sonName = _that.addTreeForm.name
      } else {
        data.fatherName = _that.addTreeForm.name
      }      // return;
      let add = await addClassify(data);
      switch (add.message.split('-$')[0]) {
        case '1':
          this.$message({
            message: '操作成功!',
            type: 'success'
          });
          _that.getThreeData()
          _that.resetTreeForm('addTreeForm')
          break;
        case '2':
          this.$message({
            message: '已存在该分类',
            type: 'warning'
          });
          break;
        case '0':
          this.$message.error('添加失败!请联系管理员');
          break;
      }
 
    },
    resetTreeForm(formName) {
      this.$refs[formName].resetFields();
      this.addClassVisible = false
    }
  }
}
</script>
 
<style lang="scss" scoped>
.demo-drawer__content {
  margin-left: 50px;
}
 
.demo-drawer__footer {
  display: flex;
  justify-content: space-between;
}
 
.demo-drawer__footer .el-button--default {
  background-color: #fff;
  color: #333;
  width: 45%;
  margin-bottom: 24px;
}
 
.demo-drawer__footer .el-button--primary {
  background-color: #409EFF;
  color: #fff;
  width: 45%;
  margin-right: 60px;
  margin-bottom: 24px;
}
 
.ledger-main {
  width: 100%;
  height: 100%;
 
  // 页面头部条件搜索
  .page-header-search {
    background: #fff;
    display: flex;
    justify-content: space-between;
    padding: 15px 24px 12px 24px;
    .serve-btn{
      position: relative;
      left: 92%;
    }
    .search-bar {
      .el-radio-button.is-active {
        color: #409EFF !important;
        background: #ecf5ff !important;
        border-color: #b3d8ff !important;
      }
      .el-form {
        .el-form-item {
          margin-bottom: 0px !important;
 
          .el-input {
            width: 500px;
          }
        }
      }
    }
  }
 
  // 页面中心内容区域
  .content-main {
    display: flex;
    height: 100%;
    min-height: calc(100vh - 88px);
    padding: 15px;
 
    >div {
      padding: 20px;
      background: #fff;
    }
 
    .library-bom {
      flex: 2;
      margin-right: 12px;
            height: 80vh;
 
      .bom-item-search {
        margin-bottom: 12px;
 
        ::v-deep .el-input {
          input {
            height: 33px;
            line-height: 33px;
          }
        }
      }
 
      .bom-item-search .el-row {
 
        // display: flex;
        .el-col {
          text-align: right;
        }
      }
 
      .el-tree {
        margin-top: 12px;
      }
    }
 
    .library-table {
      flex: 8;
      max-width: 80%;
      margin-left: 12px;
      display: flex;
      flex-direction: column;
            height: 80vh;
 
      .table-box {
        margin-top: 30px;
        flex: 1;
        background: #fff;
        display: flex;
        flex-direction: column;
 
        .el-table {
          flex: 1;
        }
 
        >div:nth-child(2) {
          display: flex;
          justify-content: end;
          margin: 10px 0;
        }
      }
    }
  }
 
}
 
.addDrawer {
  ::v-deep .el-drawer__body {
    // padding: 24px !important;
    overflow-y: scroll;
    overflow-x: hidden;
  }
}
 
.detailDrawer {
  ::v-deep .el-drawer__body {
    padding: 24px !important;
    overflow-y: scroll;
  }
 
  .detail-info {
    background: #fff;
    box-shadow: rgba(100, 100, 111, 0.2) 0px 5px 15px;
    margin: 0;
    margin-bottom: 12px;
    border-radius: 6px;
    overflow: hidden;
 
    .tips-main {
      padding: 10px 20px 0 20px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      height: 50px;
 
      .tips-btn {
        margin-bottom: 10px;
      }
 
      .tips {
        height: 100%;
        display: flex;
        height: 24px;
        align-items: center;
        font-size: 16px;
 
        >span {
          display: inline-block;
          margin-right: 10px;
          width: 4px;
          height: 16px;
          background: #0077DB;
        }
 
        >div {
          height: 100%;
          line-height: 26px;
        }
 
        .el-button {
          padding: 0;
        }
      }
    }
 
    // 基本信息和企业信息的每一个信息项样式
    .message {
      padding: 0px 20px 8px 20px;
 
      display: flex;
      flex-wrap: wrap;
      border-top: 1px solid #F2F6FC;
 
      >div {
        flex: 30%;
        max-width: 30%;
        padding: 8px;
        color: #606266;
        align-items: center;
        font-size: 12px;
        height: 40px;
        display: flex;
        align-items: center;
 
        >span {
          color: #303133;
          font-size: 14px;
 
          >i {
            margin-right: 8px;
          }
        }
      }
    }
  }
}
 
.measureForm {
 
  //
  .el-form-item {
 
    //
    .el-date-editor {
      width: 100%;
    }
  }
}
</style>