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
//
//  PBAddExamineViewController.m
//  IphoneBIMe
//
//  Created by zjf on 2020/9/16.
//  Copyright © 2020 ProBIM. All rights reserved.
//
 
#import "PBAddExamineViewController.h"
#import "PBExamineAddModel.h"
#import "PBExamineListModel.h"
#import "PBExamineInputTableViewCell.h"
#import "PBTextShowTableViewCell.h"
#import "PBEditTimeTableViewCell.h"
#import "PBListTableViewCell.h"
#import "PBCheckViewController.h"
#import "PBRoleModel.h"
#import "PBEditTextController.h"
#import "PBPersonTableViewCell.h"
#import "PBOneChooseTableViewCell.h"
#import "PBEditPersonView.h"
#import "PBTimeChooseView.h"
#import "PBEditTimeTableViewCell.h"
#import "PBArtifactsViewController.h"
#import "PBPersonModel.h"
#import "PBArtifactsInfoModel.h"
#import "PBProjectModel.h"
#import "PBTextInputTableViewCell.h"
#import "PBTopTitleTableViewCell.h"
#import "PBTimeChooseTableViewCell.h"
#import "PBEditTimeView.h"
#import "PBPersonChooseTableViewCell.h"
#import "PBArtifactsListTableViewCell.h"
#import "PBPersonListViewController.h"
#import "PBSelectedPersonController.h"
#import "PBSeleceArtifactsViewController.h"
#import "PBEAddImageView.h"
#import "PBTaskViewController.h"
#import "PBETaskInfoModel.h"
#import "PBCheckBoxTableViewCell.h"
#import "PBRadioTableViewCell.h"
#import "PBStatusTableViewCell.h"
#import "PBInstructionsTableViewCell.h"
#import "PBUserModel.h"
#import "PBCheckHeaderView.h"
#import "LXFCameraController.h"
#import "PBVideoPlayViewController.h"
#import "LBKeyWordLayout.h"
#import "KeyWordCell.h"
static NSString *const inputCellID = @"InputCellID";
static NSString *const titleCellID = @"titleCellID";
static NSString *const oneChooseCellID = @"oneChooseCellID";
static NSString *const timeChooseCellID = @"timeChooseCellID";
static NSString *const personCellID = @"personCellID";
static NSString *const listCellID = @"listCellID";
static NSString *const checkBoxCellID = @"checkBoxCellID";
static NSString *const radioCellID = @"radioCellID";
static NSString *const statusCellID = @"statusCellID";
static NSString *const instructionsCellID = @"instructionsCellID";
 
@interface PBAddExamineViewController ()<UITableViewDelegate, UITableViewDataSource, UIGestureRecognizerDelegate, LFImagePickerControllerDelegate, UICollectionViewDelegate, UICollectionViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray<PBExamineAddModel *> *dataListM;
@property (nonatomic, strong) NSDictionary *examinDetailDic;
@property (nonatomic, strong) PBRoleModel *roleModel;
@property (nonatomic, strong) PBEditPersonView *editPersonView;
@property (nonatomic, strong) PBTimeChooseView *timeChooseView;
@property (nonatomic, strong) PBEditTimeView *editTimeView;
@property (nonatomic, strong) UIView *backgroundView;
@property (nonatomic, weak) UIButton *typeListBtn;
@property (nonatomic, strong) NSDictionary *typeDict;
@property (nonatomic, strong) PBCheckHeaderView *tableheaderView1;
@property (nonatomic, strong) NSMutableArray *selectedPhotos;
@property (nonatomic, strong) NSMutableArray *selectedVideo;
@property (nonatomic, strong) NSMutableArray *selectAssetArr;
@property (nonatomic, assign) NSInteger personIndex;
@property (nonatomic, assign) BOOL isSupervisor;//是否为监理人
@property (nonatomic, assign) BOOL isQualified;//是否状态为已合格
@property (nonatomic, strong) UICollectionView *collectionView;
@property (strong, nonatomic) LBKeyWordLayout *layout;
@property (strong, nonatomic) NSArray *items;
@end
 
@implementation PBAddExamineViewController
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
//    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.f) {
        self.edgesForExtendedLayout = UIRectEdgeNone;
        self.navigationController.interactivePopGestureRecognizer.enabled = NO;    //让rootView禁止滑动
    }
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = PBColor(244, 245, 246);
    [PBNoteCenter addObserver:self selector:@selector(updateAddArtifacts:) name:PBNoteCenterUpdateArtifacts object:nil];
    [PBNoteCenter addObserver:self selector:@selector(updateAddPerson:) name:PBNoteCenterUpdatePerson object:nil];
    [PBNoteCenter addObserver:self selector:@selector(updateAddTask:) name:PBNoteCenterUpdateTask object:nil];
    [self setupNav];
    [self loadData];
    [self setupUI];
}
- (void)updateAddArtifacts:(NSNotification *)noti {
    PBExamineAddModel *examineAddModel = self.dataListM[self.personIndex];
    examineAddModel.dataArr = noti.object;
    NSIndexPath *path = [NSIndexPath indexPathForRow:self.personIndex inSection:0];
    [self.tableView reloadRowsAtIndexPaths:@[path] withRowAnimation:UITableViewRowAnimationFade];
}
- (void)updateAddPerson:(NSNotification *)noti {
    PBExamineAddModel *examineAddModel = self.dataListM[self.personIndex];
    examineAddModel.personArr = noti.object;
    NSIndexPath *path = [NSIndexPath indexPathForRow:self.personIndex inSection:0];
    [self.tableView reloadRowsAtIndexPaths:@[path] withRowAnimation:UITableViewRowAnimationFade];
}
- (void)updateAddTask:(NSNotification *)noti {
    PBExamineAddModel *examineAddModel = self.dataListM[self.personIndex];
    examineAddModel.dataArr = noti.object;
    NSIndexPath *path = [NSIndexPath indexPathForRow:self.personIndex inSection:0];
    [self.tableView reloadRowsAtIndexPaths:@[path] withRowAnimation:UITableViewRowAnimationFade];
}
- (void)setupNav {
    NSString *btnTitle = @"无";
    if (self.typeArr.count > 0) {
        self.typeDict = self.typeArr[0];
        btnTitle = [NSString stringWithFormat:@"%@ ⋁",[self.typeDict valueForKey:@"aedt_name"]];
    }
    UIButton *typeListBtn = [[UIButton alloc] init];
    [typeListBtn setTitle:btnTitle forState:UIControlStateNormal];
    [typeListBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [typeListBtn setTitleColor:PBColor(169, 176, 185) forState:UIControlStateDisabled];
    [typeListBtn addTarget:self action:@selector(typeListShow) forControlEvents:UIControlEventTouchUpInside];
    self.typeListBtn = typeListBtn;
    self.navigationItem.titleView = typeListBtn;
    
    UIBarButtonItem *backNavItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"arrow_left"] style:UIBarButtonItemStylePlain target:self action:@selector(backItemAction)];
    self.navigationItem.leftBarButtonItem = backNavItem;
  
    UIBarButtonItem *stateNavItem = [[UIBarButtonItem alloc] initWithTitle:nil style:UIBarButtonItemStylePlain target:self action:nil];
    [stateNavItem setImage:[[UIImage imageNamed:@"Rectify_ check"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    [stateNavItem setImageInsets:UIEdgeInsetsMake(0, 20, 0, -20)];
    self.navigationItem.rightBarButtonItem = stateNavItem;
}
- (void)backItemAction {
    [PBNoteCenter removeObserver:self];
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)loadData {
    NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"examineAdd1" ofType:@"plist"];
    NSArray *list = [NSArray arrayWithContentsOfFile:plistPath];
    NSMutableArray *listM = [[NSMutableArray alloc] init];
    for (NSInteger i = 0; i < list.count; i++) {
        NSDictionary *dict = list[i];
        PBExamineAddModel *model = [PBExamineAddModel yy_modelWithDictionary:dict];
//        model.isAddExamine = self.isAddExamine;
//        model.isIssueManage = self.isIssueManage;
        model.isAddExamine = YES;
        [listM addObject:model];
    }
    self.dataListM = listM;
}
 
- (void)setupUI {
    __weak typeof(self) weakSelf = self;
    self.view.backgroundColor = PBColor(244, 245, 246);
    self.tableView = [[UITableView alloc] init];
    self.tableView.backgroundColor = PBColor(244, 245, 246);
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    self.tableView.bounces = NO;
    self.tableView.rowHeight = UITableViewAutomaticDimension;
    self.tableView.estimatedRowHeight = 100.f;
    self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
    self.tableView.separatorStyle = UITableViewCellSelectionStyleNone;
    self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
    [self.tableView registerClass:[PBTextInputTableViewCell class] forCellReuseIdentifier:inputCellID];
    [self.tableView registerClass:[PBTopTitleTableViewCell class] forCellReuseIdentifier:titleCellID];
    [self.tableView registerClass:[PBOneChooseTableViewCell class] forCellReuseIdentifier:oneChooseCellID];
    [self.tableView registerClass:[PBTimeChooseTableViewCell class] forCellReuseIdentifier:timeChooseCellID];
    [self.tableView registerClass:[PBPersonChooseTableViewCell class] forCellReuseIdentifier:personCellID];
    [self.tableView registerClass:[PBArtifactsListTableViewCell class] forCellReuseIdentifier:listCellID];
    [self.tableView registerClass:[PBCheckBoxTableViewCell class] forCellReuseIdentifier:checkBoxCellID];
    [self.tableView registerClass:[PBRadioTableViewCell class] forCellReuseIdentifier:radioCellID];
    [self.tableView registerClass:[PBStatusTableViewCell class] forCellReuseIdentifier:statusCellID];
    [self.tableView registerClass:[PBInstructionsTableViewCell class] forCellReuseIdentifier:instructionsCellID];
    [self.view addSubview:self.tableView];
    CGFloat bottomH = 64.f;
    if (IS_IPHONE_X) {
        bottomH = 64.f + IPHONE_X_BOTTOM;
    }
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view);
        make.left.equalTo(self.view).offset(10);
        make.right.equalTo(self.view).offset(-10);
        make.bottom.equalTo(self.view).offset(-(bottomH));
    }];
    UIButton *checkBtn = [[UIButton alloc] init];
    [checkBtn setImage:[UIImage imageNamed:@"submit_dis"] forState:UIControlStateDisabled];
    [checkBtn setImage:[UIImage imageNamed:@"submit_nor"] forState:UIControlStateNormal];
    [checkBtn addTarget:self action:@selector(checkAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:checkBtn];
    [checkBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.tableView.mas_bottom).offset(7);
        make.left.equalTo(self.view).offset(10);
        make.right.equalTo(self.view).offset(-10);
        make.height.equalTo(@50);
    }];
    self.tableheaderView1 = [[PBCheckHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, 100)];
    self.tableheaderView1.ChooseImageBlock = ^{
        [weakSelf.view endEditing:YES];
        [weakSelf chooseImageOrVideo];
//        [weakSelf takePhotoLibrary];
//        [weakSelf videoBtnFunc];
    };
    self.tableheaderView1.DeleteImageBlock = ^(NSInteger index) {
        [weakSelf.selectedPhotos removeObjectAtIndex:index];
        [weakSelf setTableHeaderViewImage];
    };
    self.tableheaderView1.DeleteVideoBlock = ^{
        [weakSelf.selectedVideo removeAllObjects];
        [weakSelf setTableHeaderViewImage];
    };
    self.tableheaderView1.PlayVideoBlock = ^{
        [weakSelf.view endEditing:YES];
        NSLog(@"打开视频");
        PBVideoPlayViewController *playVC = [[PBVideoPlayViewController alloc] init];
        PBResultVideo *result = weakSelf.selectedVideo[0];
        playVC.filePath = result.url;
        [weakSelf.navigationController pushViewController:playVC animated:YES];
    };
    self.tableheaderView1.projectModel = self.projectModel;
    self.tableheaderView1.isAddExamine = YES;
    self.tableView.tableHeaderView = self.tableheaderView1;
}
- (void)chooseImageOrVideo {
    if (self.selectedPhotos.count > 0) {
        [self takePhotoLibrary];
        return;;
    }
    UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"" message:@"请选择" preferredStyle:UIAlertControllerStyleActionSheet];
    UIAlertAction *videoAction  = [UIAlertAction actionWithTitle:@"拍摄" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [self videoBtnFunc];
    }];
    UIAlertAction *imageAction  = [UIAlertAction actionWithTitle:@"从手机相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [self takePhotoLibrary];
    }];
    UIAlertAction *cancelAction  = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
    [alertVC addAction:videoAction];
    [alertVC addAction:imageAction];
    [alertVC addAction:cancelAction];
    [self presentViewController:alertVC animated:YES completion:nil];
    
}
- (void)videoBtnFunc {
    LXFCameraController *cameraController = [LXFCameraController defaultCameraController];
    
    __weak LXFCameraController *weakCameraController = cameraController;
    
    cameraController.takePhotosCompletionBlock = ^(UIImage *image, NSError *error) {
        NSLog(@"takePhotosCompletionBlock");
        [weakCameraController dismissViewControllerAnimated:YES completion:nil];
        NSData *imageData = UIImageJPEGRepresentation(image, 0.5);
        UIImage *originalImage = [UIImage imageWithData:imageData];
        [self.selectedPhotos addObject:originalImage];
        [self setTableHeaderViewImage];
    };
    
    cameraController.shootCompletionBlock = ^(NSURL *videoUrl, CGFloat videoTimeLength, UIImage *thumbnailImage, NSError *error) {
        NSLog(@"shootCompletionBlock");
        [weakCameraController dismissViewControllerAnimated:YES completion:nil];
        PBResultVideo *video = [[PBResultVideo alloc] init];
        video.coverImage = thumbnailImage;
        video.url = videoUrl;
        video.data = [NSData dataWithContentsOfURL:videoUrl];
        [self.selectedVideo addObject:video];
        [self setTableHeaderViewImage];
    };
    
    cameraController.modalPresentationStyle = UIModalPresentationFullScreen;
    [self presentViewController:cameraController animated:YES completion:nil];
}
//新增图片选择图片后填充
- (void)setTableHeaderViewImage {
    if (self.selectedVideo.count > 0) {
        self.tableheaderView1.videoArr = self.selectedVideo;
    }else {
        self.tableheaderView1.imageArr = self.selectedPhotos;
    }
}
- (void)takePhotoLibrary {
    PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus];
    if (status == PHAuthorizationStatusNotDetermined) {//未作出回应
        [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
            if(status == PHAuthorizationStatusAuthorized) {
                dispatch_async(dispatch_get_main_queue(), ^{//用户点击ok
                    [self pushLFImagePickerController];
                });
            } else {
                dispatch_async(dispatch_get_main_queue(), ^{//点击不允许访问
                    NSLog(@"点击不允许访问");
                });
            }
        }];
    }else if (status == PHAuthorizationStatusRestricted) {//没有被授权访问 可能家长控制
 
    }else if (status == PHAuthorizationStatusDenied) {//已明确否认相册权限
        UIAlertController * alertController = [UIAlertController alertControllerWithTitle:@"无法访问相册" message:@"请在iPhone的""设置-隐私-相册""中允许访问相册" preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
        UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"设置" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            if (@available(iOS 10.0, *)) {
                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
            } else {
                NSLog(@"选择取消");
            }
        }];
        [alertController addAction:cancelAction];
        [alertController addAction:okAction];
        [self presentViewController:alertController animated:YES completion:nil];
    }else if (status == PHAuthorizationStatusAuthorized){//有权限访问
        [self pushLFImagePickerController];
    }
}
- (void)pushLFImagePickerController {
    NSInteger maxImageCount = 9 - self.selectedPhotos.count;
    
    LFImagePickerController *imagePicker = [[LFImagePickerController alloc] initWithMaxImagesCount:maxImageCount delegate:self];
    imagePicker.maxVideosCount = 1;
    imagePicker.allowTakePicture = YES;//内部显示相机
    imagePicker.isSelectOriginalPhoto = YES;//是否选择原图
    if (self.selectedPhotos.count > 0) {
        imagePicker.allowPickingType = LFPickingMediaTypePhoto;//用户是否可以选择视频
    }else {
        imagePicker.allowPickingType = LFPickingMediaTypeALL;//用户是否可以选择视频
    }
    imagePicker.allowPickingOriginalPhoto = NO;//原图按钮将隐藏,用户将不能发送原图
    imagePicker.maxPhotoBytes = 1024 * 1024 * 100;//最大图片所选字节大小
    if ([UIDevice currentDevice].systemVersion.floatValue >= 8.0f) {
        imagePicker.syncAlbum = YES; /** 实时同步相册 */
    }
//    imagePicker.selectedAssets = self.selectAssetArr;
    [self presentViewController:imagePicker animated:YES completion:nil];
}
#pragma mark - LFImagePickerControllerDelegate
 
- (void)lf_imagePickerController:(LFImagePickerController *)picker didFinishPickingResult:(NSArray <LFResultObject /* <LFResultImage/LFResultVideo> */*> *)results {
    NSMutableArray *videoArr = [[NSMutableArray alloc] init];
    NSMutableArray *imageArrM = [[NSMutableArray alloc] init];
    for (NSInteger i = 0; i < results.count; i++) {
        LFResultObject *result = results[i];
        if ([result isKindOfClass:[LFResultImage class]]){
            LFResultImage *resultImage = (LFResultImage *)result;
            NSData *imageData = UIImageJPEGRepresentation(resultImage.originalImage, 0.5);
            UIImage *originalImage = [UIImage imageWithData:imageData];
            [imageArrM addObject:originalImage];
        }else {
            LFResultVideo *resultVideo = (LFResultVideo *)result;
            PBResultVideo *video = [[PBResultVideo alloc] init];
            video.coverImage = resultVideo.coverImage;
            video.url = resultVideo.url;
            video.data = resultVideo.data;
            [videoArr addObject:video];
        }
    }
    if (videoArr.count > 0) {
        self.selectedVideo = videoArr;
        [self.selectedPhotos removeAllObjects];
    }else {
        [self.selectedPhotos addObjectsFromArray:imageArrM.copy];
    }
//    self.selectAssetArr = assetArr;
    [self setTableHeaderViewImage];
    
}
#pragma mark - 上传图片
- (void)uploadFileWithFile:(NSArray *)files andData:(NSMutableDictionary *)dictM andCheckData:(NSMutableDictionary *)checkDictM {
    [YJProgressHUD showProgress:@"" inView:self.view];
//    NSString *issueID = self.issueListModel.IssueId;
//    if (self.isAddIssue) {
//        issueID = @"";
//    }
    [[PBNetworkTools sharedTools] UploadImagesWithFiles:files andIssueID:nil andCallBack:^(NSURLSessionDataTask *task, id response, NSError *error) {
        if (error) {
            [YJProgressHUD showMessage:@"上传文件失败" inView:self.view];
            return;
        }
        NSString *str = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
        NSLog(@"%@",str);
        PBNetworkModel *networkModel = [PBNetworkModel yy_modelWithJSON:str];
        if (networkModel.Ret == 1) {
//            if (self.isAddIssue) {
                NSMutableString *strM = [[NSMutableString alloc] init];
                NSString *fileID = @"";
                for (NSDictionary *obj in networkModel.Data) {
                    [strM appendFormat:@"%@,",[obj valueForKey:@"bf_guid"]];
                }
                if([strM length] > 0){
                    fileID = [strM substringToIndex:([strM length]-1)];
                }
                [self saveExamineWithFileId:fileID andData:dictM andCheckData:checkDictM];
//            }else {
//                [YJProgressHUD hide];
//                [self.associatedDocs addObjectsFromArray:networkModel.Data];
//                [self setTableViewHeaderView];
//            }
        }else {
            [YJProgressHUD showMessage:@"上传文件失败" inView:self.view];
        }
    }];
}
#pragma mark - 保存
- (void)saveExamineWithFileId:(NSString *)fileId andData:(NSMutableDictionary *)dictM andCheckData:(NSMutableDictionary *)checkDictM{
    [YJProgressHUD showProgress:@"" inView:self.view];
    [dictM setObject:fileId forKey:@"ImageIds"];
    [[PBNetworkTools sharedTools] AddMissionWithDictM:dictM andCallBack:^(NSURLSessionDataTask *task, id response, NSError *error) {
        if (error) {
            [YJProgressHUD showMessage:@"发起任务失败" inView:self.view afterDelayTime:1];
            return;
        }
        NSString *str = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
        NSLog(@"%@",str);
        PBNetworkModel *networkModel = [PBNetworkModel yy_modelWithJSON:str];
        if (networkModel.Ret == 1) {
            if (self.isSupervisor) {
                [self saveCheckDate:checkDictM andExamineID:[networkModel.Data valueForKey:@"ExamId"]];
            }else {
                [YJProgressHUD hide];
                [PBNoteCenter removeObserver:self];
                [self.navigationController popViewControllerAnimated:YES];
            }
        }else {
            [YJProgressHUD showMessage:networkModel.Msg inView:self.view afterDelayTime:1];
        }
    }];
}
#pragma mark - 保存检查数据
- (void)saveCheckDate:(NSMutableDictionary *)checkDate andExamineID:(NSString *)examineId {
    [[PBNetworkTools sharedTools] checkMissionWithExamineID:examineId andOrganizeId:self.projectModel.organizeid andData:checkDate andImageArr:[NSMutableArray new] andCallBack:^(NSURLSessionDataTask *task, id response, NSError *error) {
        if (error) {
            NSLog(@"%@",error);
            return;
        }
        NSString *str = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
        NSLog(@"%@",str);
        PBNetworkModel *networkModel = [PBNetworkModel yy_modelWithJSON:str];
        if (networkModel.Ret == 1) {
            [YJProgressHUD hide];
            [PBNoteCenter removeObserver:self];
            [self.navigationController popViewControllerAnimated:YES];
        }else {
            [YJProgressHUD showMessage:networkModel.Msg inView:self.view];
        }
    }];
}
 
#pragma mark - 发起任务方法
- (void)checkAction {
    NSMutableDictionary *dictM = [[NSMutableDictionary alloc] init];
    NSMutableDictionary *dict1M = [[NSMutableDictionary alloc] init];
    for (PBExamineAddModel *obj in self.dataListM) {
        if (![obj.cellType isEqualToString:@"classTitle"] && ![obj.cellType isEqualToString:@"instructions"] && ![obj.cellType isEqualToString:@"checkbox"]) {
            if ([obj.cellType isEqualToString:@"input"]) {
                if (obj.dataStr == nil) {
                    [YJProgressHUD showFailed:obj.prompt inview:self.view];
                    return;
                }else {
                    if ([obj.key isEqualToString:@"RectificationRemark"]) {
                        [dict1M setValue:obj.dataStr forKey:obj.key];
                    }else {
                        [dictM setValue:obj.dataStr forKey:obj.key];
                    }
                }
            }else if ([obj.cellType isEqualToString:@"person"]) {
                if ([obj.key isEqualToString:@"CheckerUserId"]) {
                    if (obj.personArr.count > 0) {
                        PBPersonModel *personModel = obj.personArr[0];
                        [dictM setValue:personModel.UserId forKey:obj.key];
                    }else {
                        [YJProgressHUD showFailed:obj.prompt inview:self.view];
                        return;
                    }
                }else {
                    if (self.isQualified) {
                        [dict1M setObject:@"" forKey:obj.key];
                    }else {
                        NSMutableString *userIdStrM = [[NSMutableString alloc] init];
                        for (PBPersonModel *person in obj.personArr) {
                            [userIdStrM appendString:[NSString stringWithFormat:@"%@,",person.UserId]];
                        }
                        if (userIdStrM.length == 0) {
                            if([obj.key isEqualToString:@"RelationMemberID"]) {
                                [YJProgressHUD showMessage:@"请填写完整" inView:self.view];
                                return;
                            }else {
                                [dict1M setObject:@"" forKey:obj.key];
                            }
                        }else {
                            [dict1M setObject:userIdStrM.copy forKey:obj.key];
                        }
                    }
                }
 
            }else if ([obj.cellType isEqualToString:@"time"]) {
                if (obj.dataStr == nil) {
                    [YJProgressHUD showFailed:obj.prompt inview:self.view];
                    return;
                }else {
                    [dictM setValue:obj.dataStr forKey:obj.key];
                }
            }else if ([obj.cellType isEqualToString:@"list"]) {
                if (obj.dataArr.count <= 0) {
                    [dictM setValue:@"[]" forKey:obj.key];
                }else {
                    NSMutableArray *arrM = [[NSMutableArray alloc] init];
                    if ([obj.key isEqualToString:@"rel_taskjson"]) {//任务
                        for (PBETaskInfoModel *model in obj.dataArr) {
                            NSDictionary *dict =  @{
                                @"ACTUALDURATION_" : model.ACTUALDURATION_ == nil? @"" : model.ACTUALDURATION_,
                                @"ACTUALFINISH_" : model.ACTUALFINISH_ == nil? @"" : model.ACTUALFINISH_,
                                @"ACTUALSTART_" : model.ACTUALSTART_ == nil? @"" : model.ACTUALSTART_,
                                @"ASSIGNMENTS_" : model.ASSIGNMENTS_ == nil? @"" : model.ASSIGNMENTS_,
                                @"CONSTRAINTDATE_" : model.CONSTRAINTDATE_ == nil? @"" : model.CONSTRAINTDATE_,
                                @"CONSTRAINTTYPE_" : model.CONSTRAINTTYPE_ == nil? @"" : model.CONSTRAINTTYPE_,
                                @"CRITICAL2_" : model.CRITICAL2_ == nil? @"" : model.CRITICAL2_,
                                @"CRITICAL_" : model.CRITICAL_ == nil? @"" : model.CRITICAL_,
                                @"DEPARTMENT_" : model.DEPARTMENT_ == nil? @"" : model.DEPARTMENT_,
                                @"DURATION_" : model.DURATION_ == nil? @"" : model.DURATION_,
                                @"FINISH_" : model.FINISH_ == nil? @"" : model.FINISH_,
                                @"FIXEDDATE_" : model.FIXEDDATE_ == nil? @"" : model.FIXEDDATE_,
                                @"ID_" : model.ID_ == nil? @"" : model.ID_,
                                @"MANUAL_" : model.MANUAL_ == nil? @"" : model.MANUAL_,
                                @"MILESTONE_" : model.MILESTONE_ == nil? @"" : model.MILESTONE_,
                                @"NAME_" : model.NAME_ == nil? @"" : model.NAME_,
                                @"NOTES_" : model.NOTES_ == nil? @"" : model.NOTES_,
                                @"PARENTTASKUID_" : model.PARENTTASKUID_ == nil? @"" : model.PARENTTASKUID_,
                                @"PERCENTCOMPLETE_" : model.PERCENTCOMPLETE_ == nil? @"" : model.PERCENTCOMPLETE_,
                                @"PREDECESSORLINK_" : model.PREDECESSORLINK_ == nil? @"" : model.PREDECESSORLINK_,
                                @"PRINCIPAL_" : model.PRINCIPAL_ == nil? @"" : model.PRINCIPAL_,
                                @"PRIORITY_" : model.PRIORITY_ == nil? @"" : model.PRIORITY_,
                                @"PROJECTUID_" : model.PROJECTUID_ == nil? @"" : model.PROJECTUID_,
                                @"START_" : model.START_ == nil? @"" : model.START_,
                                @"SUMMARY_" : model.SUMMARY_ == nil? @"" : model.SUMMARY_,
                                @"UID_" : model.UID_ == nil? @"" : model.UID_,
                                @"WBS_" : model.WBS_ == nil? @"" : model.WBS_,
                                @"WEIGHT_" : model.WEIGHT_ == nil? @"" : model.WEIGHT_,
                                @"WORK_" : model.WORK_ == nil? @"" : model.WORK_
                            };
                            [arrM addObject:dict];
                        }
                    }else {
                        for (PBArtifactsInfoModel *model in obj.dataArr) {
                            NSDictionary *dict =  @{
                                @"bhaselerel" : model.bhaselerel == nil? @"" : model.bhaselerel,
                                @"relelejson" : model.relelejson == nil? @"" : model.relelejson,
                                @"bm_guid" : model.bm_guid == nil? @"" : model.bm_guid,
                                @"bm_materialname" : model.bm_materialname == nil? @"" : model.bm_materialname,
                                @"bm_materialcode" : model.bm_materialcode == nil? @"" : model.bm_materialcode,
                                @"bm_materialmodel" : model.bm_materialmodel == nil? @"" : model.bm_materialmodel,
                                @"bm_materialcount" : model.bm_materialcount == nil? @"" : model.bm_materialcount,
                                @"bm_materialunit" : model.bm_materialunit == nil? @"" : model.bm_materialunit,
                                @"bm_materialfac" : model.bm_materialfac == nil? @"" : model.bm_materialfac,
                                @"bm_planarrtime" : model.bm_planarrtime == nil? @"" : model.bm_planarrtime,
                                @"bc_guid_materialtype" : model.bc_guid_materialtype == nil? @"" : model.bc_guid_materialtype,
                                @"bc_guid_materialstatus" : model.bc_guid_materialstatus == nil? @"" : model.bc_guid_materialstatus,
                                @"bm_extjson" : model.bm_extjson == nil? @"" : model.bm_extjson
                            };
                            [arrM addObject:dict];
                        }
                    }
                    
                    NSString *jsonStr = [NSString arrConvertToJson:arrM.copy];
                    [dictM setValue:jsonStr forKey:obj.key];
                }
            }else if ([obj.cellType isEqualToString:@"choose"]) {
                if ([obj.dataStr isEqualToString:@""] || obj.dataStr == nil) {
                    [YJProgressHUD showMessage:@"请填写完整" inView:self.view];
                    return;
                }
                [dict1M setObject:obj.dataStr forKey:obj.key];
            }else if ([obj.cellType isEqualToString:@"statu"]) {
                NSString *chooseValue;
                if ([obj.dataStr isEqualToString:@"已合格"]) {//statuChoosequalified
                    chooseValue = @"1";
                    self.isQualified = YES;
                }else {
                    chooseValue = @"0";
                }
                [dict1M setObject:chooseValue forKey:obj.key];
            }
 
        }
    }
    //类型
    if (self.typeDict) {
        [dictM setObject:[self.typeDict valueForKey:@"aedt_guid"] forKey:@"aedt_guid"];
    }else {
        [YJProgressHUD showFailed:@"请选择类型" inview:self.view];
        return;
    }
    [dictM setValue:self.projectModel.bimcomposerid forKey:@"bimcomposerId"];
    [dictM setValue:self.projectModel.organizeid forKey:@"organizeId"];
    //截止日期和开始日期比较
    NSInteger  result = [self compareWithDate:[dictM valueForKey:@"ExamineDate"] andDate:[dictM valueForKey:@"RectificateDate"]];
    if (result == 1) {
        [YJProgressHUD showFailed:@"截止日期应大于开始日期" inview:self.view];
        return;
    }
    if (self.selectedPhotos.count == 0 && self.selectedVideo.count == 0) {
        [YJProgressHUD showProgress:@"" inView:self.view];
        [self saveExamineWithFileId:@"" andData:dictM andCheckData:dict1M];
    }else {
        if (self.selectedVideo.count > 0){
            [self uploadFileWithFile:self.selectedVideo andData:dictM andCheckData:dict1M];
        }else {
            [self uploadFileWithFile:self.selectedPhotos andData:dictM andCheckData:dict1M];
        }
    }
}
//比较时间大小
- (NSInteger)compareWithDate:(NSString*)aDate andDate:(NSString *)bDate{
    NSDateFormatter *dateformater = [[NSDateFormatter alloc] init];
    [dateformater setDateFormat:@"yyyy年MM月dd日"];
    NSDate*dta = [[NSDate alloc]init];
    NSDate*dtb = [[NSDate alloc]init];
    dta = [dateformater dateFromString:aDate];
    dtb = [dateformater dateFromString:bDate];
    NSComparisonResult result = [dta compare:dtb];
    if (result == NSOrderedDescending) {
    //指定时间 a 大于 b
       return 1;
    }else if(result == NSOrderedAscending){
    //指定时间 b 大于 a
       return -1;
    }else{
    //刚好时间一样.
       return 0;
    }
}
#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataListM.count;
}
 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    PBExamineAddModel *examineAddModel = self.dataListM[indexPath.row];
    if ([examineAddModel.cellType isEqualToString:@"input"]) {
        PBTextInputTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:inputCellID forIndexPath:indexPath];
        cell.examineAddModel = examineAddModel;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }else if ([examineAddModel.cellType isEqualToString:@"classTitle"]) {
        PBTopTitleTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:titleCellID forIndexPath:indexPath];
        cell.examineAddModel = examineAddModel;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }else if ([examineAddModel.cellType isEqualToString:@"time"]) {
        PBTimeChooseTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:timeChooseCellID forIndexPath:indexPath];
        cell.examineAddModel = examineAddModel;
        cell.ChooseBlock = ^{
            [self.view endEditing:YES];
            [PBKeyWindow addSubview:self.editTimeView];
            self.editTimeView.examineAddModel = self.dataListM[indexPath.row];
            self.editTimeView.ChooseCompleteBlock = ^(BOOL isSelsected, NSString *date){
                if (isSelsected) {
                    [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
                }
            };
            [self.editTimeView show];
        };
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }else if ([examineAddModel.cellType isEqualToString:@"person"]) {
        PBPersonChooseTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:personCellID forIndexPath:indexPath];
        cell.examineAddModel = examineAddModel;
        cell.ChooseBlock = ^{
              [self.view endEditing:YES];
              if([examineAddModel.key isEqualToString:@"CheckerUserId"]) {
                  if (self.isSupervisor) {
                      return;
                  }
              }
              self.personIndex = indexPath.row;
              PBPersonListViewController *personListVC = [[PBPersonListViewController alloc] init];
              personListVC.projectModel = self.projectModel;
              if ([examineAddModel.key isEqualToString:@"RelationMemberID"]){
                  personListVC.isMultiSelect = YES;
              }else {
                  personListVC.isMultiSelect = NO;
              }
              personListVC.selectList = examineAddModel.personArr.mutableCopy;
              [self.navigationController pushViewController:personListVC animated:YES];
          };
          cell.LookAllBlock = ^{
              PBSelectedPersonController *selectedPersonVC = [[PBSelectedPersonController alloc] init];
              selectedPersonVC.selectList = examineAddModel.personArr.mutableCopy;
              [self.navigationController pushViewController:selectedPersonVC animated:YES];
          };
          cell.selectionStyle = UITableViewCellSelectionStyleNone;
          return cell;
    }else if ([examineAddModel.cellType isEqualToString:@"checkbox"]) {
          PBCheckBoxTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:checkBoxCellID forIndexPath:indexPath];
          cell.examineAddModel = examineAddModel;
          cell.selectionStyle = UITableViewCellSelectionStyleNone;
          cell.updateBlock = ^(NSString * _Nonnull check) {
              [self supervisorUpdate:check];
          };
          return cell;
    }else if ([examineAddModel.cellType isEqualToString:@"list"]) {
        PBArtifactsListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:listCellID forIndexPath:indexPath];
        cell.examineAddModel = examineAddModel;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.ChooseBlock = ^{
            self.personIndex = indexPath.row;
            if ([examineAddModel.key isEqualToString:@"rel_materialjson"]){
                [self.view endEditing:YES];
                PBArtifactsViewController *artifactsVC = [[PBArtifactsViewController alloc] init];
                artifactsVC.examineAddModel = examineAddModel;
                artifactsVC.projectModel = self.projectModel;
                artifactsVC.selectList = examineAddModel.dataArr.mutableCopy;
                [self.navigationController pushViewController:artifactsVC animated:YES];
            }else {
                [self.view endEditing:YES];
                PBTaskViewController *taskVC = [[PBTaskViewController alloc] init];
                taskVC.examineAddModel = examineAddModel;
                taskVC.projectModel = self.projectModel;
                taskVC.isOntPage = YES;
                taskVC.selectList = examineAddModel.dataArr.mutableCopy;
                [self.navigationController pushViewController:taskVC animated:YES];
            }
        };
        cell.LookAllBlock = ^{
            PBSeleceArtifactsViewController *selectedArtifactsVC = [[PBSeleceArtifactsViewController alloc] init];
            if ([examineAddModel.key isEqualToString:@"rel_materialjson"]) {
                selectedArtifactsVC.type = @"Artifacts";
            }else {
                selectedArtifactsVC.type = @"Task";
            }
            selectedArtifactsVC.selectList = examineAddModel.dataArr.mutableCopy;
            [self.navigationController pushViewController:selectedArtifactsVC animated:YES];
        };
        return cell;
    }else if ([examineAddModel.cellType isEqualToString:@"choose"]) {
        PBRadioTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:radioCellID forIndexPath:indexPath];
        cell.examineAddModel = examineAddModel;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }else if ([examineAddModel.cellType isEqualToString:@"statu"]) {
        PBStatusTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:statusCellID forIndexPath:indexPath];
        cell.examineAddModel = examineAddModel;
        cell.statusChange = ^(NSString * _Nonnull statu) {
            if ([statu isEqualToString:@"已合格"]) {
                examineAddModel.dataStr = statuChoosequalified;
            }else {
                examineAddModel.dataStr = @"";
            }
            [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:(UITableViewRowAnimationFade)];
        };
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }else if ([examineAddModel.cellType isEqualToString:@"instructions"]) {
        PBInstructionsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:instructionsCellID forIndexPath:indexPath];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }else {
        return nil;
    }
}
- (void)supervisorUpdate:(NSString *)check {
    if ([check isEqualToString:@"1"]) {
        //设置检查人为当前登录人 且不可更改
        PBUserModel *checkPerson = [[PBUserModel alloc] init];
        checkPerson.UserId = UserID;
        checkPerson.RealName = Realname;
        PBExamineAddModel *examineAddModel = self.dataListM[4];
        examineAddModel.personArr = @[checkPerson];
        
        self.isSupervisor = YES;
        NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"examineAdd4" ofType:@"plist"];
        NSArray *list = [NSArray arrayWithContentsOfFile:plistPath];
        NSMutableArray *listM = [[NSMutableArray alloc] init];
        for (NSInteger i = 0; i < list.count; i++) {
            NSDictionary *dict = list[i];
            PBExamineAddModel *model = [PBExamineAddModel yy_modelWithDictionary:dict];
            model.isAddExamine = YES;
    //        model.isIssueManage = self.isIssueManage;
            [listM addObject:model];
        }
        NSArray *array = listM.copy;
        NSRange range = NSMakeRange(7, [array count]);
        NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:range];
        [self.dataListM insertObjects:array atIndexes:indexSet];
    }else {
        self.isSupervisor = NO;
        NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"examineAdd4" ofType:@"plist"];
        NSArray *list = [NSArray arrayWithContentsOfFile:plistPath];
        NSRange range = NSMakeRange(7, [list count]);
        [self.dataListM removeObjectsInRange:range];
    }
    [self.tableView reloadData];
    
}
- (void)presentTypeWithIndexPath:(NSIndexPath *)indexPath andExamineAddModel:(PBExamineAddModel *)examineAddModel {
    UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"请选择类型" message:@"" preferredStyle:UIAlertControllerStyleActionSheet];
    for (NSInteger i = 0; i < self.typeArr.count; i++) {
        NSDictionary *dict = self.typeArr[i];
        NSString *title = [dict valueForKey:@"aedt_name"];
        UIAlertAction *action1 = [UIAlertAction actionWithTitle:title style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            examineAddModel.dataDict = dict;
            [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
        }];
        [alertVC addAction:action1];
    }
    
    UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
    [alertVC addAction:cancel];
    [self presentViewController:alertVC animated:YES completion:nil];
}
 
 
- (PBEditPersonView *)editPersonView {
    if (_editPersonView == nil) {
        _editPersonView = [[PBEditPersonView alloc] initWithFrame:[UIScreen mainScreen].bounds];
//        _editPersonView.isChooseOne = YES;
        CGFloat bottomH = 0.f;
        if (IS_IPHONE_X) {
            bottomH = 34.f;
        }
        _editPersonView.visualViewHeight = 468.f + bottomH;
        _editPersonView.isExamineChoose = YES;
    }
    return _editPersonView;
}
- (PBEditTimeView *)editTimeView {
    if (_editTimeView == nil) {
        _editTimeView = [[PBEditTimeView alloc] initWithFrame:[UIScreen mainScreen].bounds];
        _editTimeView.visualViewHeight = 300;
    }
    return _editTimeView;
}
- (void)setProjectModel:(PBProjectModel *)projectModel {
    _projectModel = projectModel;
}
- (void)setTypeArr:(NSArray *)typeArr {
    _typeArr = typeArr;
}
- (void)dealloc {
    [PBNoteCenter removeObserver:self];
}
 
- (void)backTapped:(UITapGestureRecognizer *)sender {
    [self hideDropDown];
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
    if (touch.view == self.backgroundView) {
        return YES;
    } else {
        return NO;
    }
}
- (void)typeListShow {
    if (self.typeArr.count <=  0) {
        [YJProgressHUD showMessage:@"没有类型相关数据" inView:self.view];
        return;
    }
    [self.view addSubview:self.backgroundView];
    [self.view addSubview:self.collectionView];
    self.typeListBtn.enabled = NO;
    self.navigationItem.leftBarButtonItem.enabled = NO;
}
- (void)hideDropDown{
    [self.collectionView removeFromSuperview];
    [self.backgroundView removeFromSuperview];
    self.typeListBtn.enabled = YES;
    self.navigationItem.leftBarButtonItem.enabled = YES;
}
- (UIView *)backgroundView {
    if (_backgroundView == nil) {
        _backgroundView = [[UIView alloc] initWithFrame:CGRectMake(0 , 0, PBScreenWidth, self.view.height)];
        _backgroundView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.3];
        [_backgroundView setOpaque:NO];
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(backTapped:)];
        tap.delegate = self;
        [_backgroundView addGestureRecognizer:tap];
    }
    return _backgroundView;
}
- (UICollectionView *)collectionView {
    if (_collectionView == nil) {
        NSMutableArray *arrM = [[NSMutableArray alloc] init];
        for (NSInteger i = 0; i < self.typeArr.count; i++) {
            NSString *str = [self.typeArr[i] valueForKey:@"aedt_name"];
            [arrM addObject:str];
        }
        self.items = arrM.copy;
        self.layout = [[LBKeyWordLayout alloc] init];
        self.layout.estimatedItemSize = CGSizeMake(80, 30);
        self.layout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
        _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, PBScreenWidth, 200) collectionViewLayout:self.layout];
        _collectionView.backgroundColor = [UIColor whiteColor];
        [_collectionView registerClass:[KeyWordCell class] forCellWithReuseIdentifier:@"KeyWordCell"];
        _collectionView.delegate = self;
        _collectionView.dataSource = self;
    }
    return _collectionView;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return self.items.count;
}
 
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    KeyWordCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"KeyWordCell" forIndexPath:indexPath];
    cell.maxWidthConstraint.constant = CGRectGetWidth(collectionView.bounds) - self.layout.sectionInset.left - self.layout.sectionInset.right - cell.layoutMargins.left - cell.layoutMargins.right - 10;
    cell.textLabel.numberOfLines = 1;
    cell.textLabel.text = self.items[indexPath.row];
    return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    self.typeDict = self.typeArr[indexPath.row];
    NSString *btnTitle = [NSString stringWithFormat:@"%@ ⋁",[self.typeDict valueForKey:@"aedt_name"]];
    [self.typeListBtn setTitle:btnTitle forState:UIControlStateNormal];
    [self hideDropDown];
}
 
- (NSMutableArray *)selectedPhotos {
    if (_selectedPhotos == nil) {
        _selectedPhotos = [[NSMutableArray alloc] init];
    }
    return _selectedPhotos;
}
- (NSMutableArray *)selectedVideo {
    if (_selectedVideo == nil) {
        _selectedVideo = [[NSMutableArray alloc] init];
    }
    return _selectedVideo;
}
 
//textFName.inputAccessoryView = self.kbToolbar;
/*
#pragma mark - Navigation
 
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
 
@end