//
|
// 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
|