123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808 |
- //
- // MyWorkCarVC.m
- // smartRhino
- //
- // Created by niuzhen on 2019/12/26.
- // Copyright © 2019 tederen. All rights reserved.
- //
- #import "MyWorkCarVC.h"
- #import "AutoLayoutScrollView.h"
- #import "MyWorkWordModel.h"
- #import "SelectTextCell.h"
- #import "InPutTextCell.h"
- #import "InPutGongWenCell.h"
- #import "AddFileTableViewCell.h"
- #import "AddPeopleToGongWenCell.h"
- #import "MOFSPickerManager.h"
- #import "SendInfoGroupVC.h"
- #import "LYLPhotoTailoringTool.h"
- #import "MyWorkAppApprovalCell.h"
- #import "AddLookUpUserSecondVC.h"
- #import "MailListVC.h"
- #import "AddPictureCell.h"
- #import "FWZFileGetTool.h"
- #import "WaitTimePicker.h"
- #import "DownFileViewController.h"
- @interface MyWorkCarVC ()<UITableViewDelegate,UITableViewDataSource, UINavigationControllerDelegate, UIImagePickerControllerDelegate,UITextFieldDelegate,UITextViewDelegate,AddPeopleToGongWenCellDelegate,MyWorkAppApprovalCellDelegate,AddLookUpUserSecondVCDelegate,AddPictureCellDelegate,UIDocumentPickerDelegate>{
- NSIndexPath *_currentIndexPath;
- }
- @property (nonatomic, strong) UIScrollView *scrollView;
- @property (nonatomic, strong) NSMutableArray<NSMutableArray<MyWorkWordModel*>*>* viewDataArray;
- @property (nonatomic, strong) NSMutableArray<FormFieldsModel*>* viewDataArray2;
- @property (nonatomic, strong) TDTableView *myTableView;
- @property (nonatomic, strong) UIView *footerview;
- @property (nonatomic, strong) MyWorkWordModel *model;
- @property (nonatomic, assign) NSInteger isTest;
- @property (nonatomic, strong) NSMutableDictionary *reuqestParams;
- @property (nonatomic, strong) NSMutableArray *chaoSongRenArr;
- @property (nonatomic, strong) NSMutableArray *shenPiRenArr;
- @property (nonatomic, assign) NSInteger carTypeId;
- @property (nonatomic, assign) BOOL isShenPinRen;
- @end
- @implementation MyWorkCarVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.fd_prefersNavigationBarHidden = YES;
- self.isTest = 1;
- [self.navigationController.navigationItem.leftBarButtonItem setImage:IMG(@"工作_返回")];
- [self.navigationController.navigationBar setBackgroundImage:[UIImage imageWithBgColor:[UIColor colorWithRed:92/255.0 green:118.0/255.0 blue:167.0/255.f alpha:1.0] alpha:1.0] forBarMetrics:UIBarMetricsDefault];
- [self getData];
- [self.view addSubview:self.myTableView];
- self.footerview.frame = CGRectMake(0, 0, kGXScreenWidth,70);
- [self registerNotification];
- self.fd_interactivePopDisabled = YES;
-
- }
- - (void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
- [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
-
- }
- - (void)viewWillDisappear:(BOOL)animated{
- [super viewWillDisappear:animated];
- [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
- }
- - (UIStatusBarStyle)preferredStatusBarStyle{
- return UIStatusBarStyleLightContent;
- }
- - (void)getData{
- [self getOnlineData];
- }
- - (void)getOnlineData{
- SHOWLOADING
- WS(weakSelf);
- [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@%ld",BaseUrl,WorkFlowHomeData_Post,(long)self.indexID] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSDictionary *dic = responseObject;
- MyWorkWordModel *model = [[MyWorkWordModel alloc]initWithDictionary:dic error:nil];
- weakSelf.model = model;
- NSLog(@"%@",model);
- weakSelf.viewDataArray2 = [NSMutableArray arrayWithArray:model.FormFields];
- weakSelf.isTest = 2;
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.myTableView setTableFooterView:weakSelf.footerview];
- [weakSelf.myTableView reloadData];
- });
- REMOVESHOW
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- #pragma mark - UITableViewDelegate,UITableViewDataSource
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- if (self.isTest == 1) {
- return self.viewDataArray.count;
- }else{
- return self.viewDataArray2.count;
- }
-
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
-
- if (self.isTest == 1) {
- return self.viewDataArray[section].count;
- }else{
- return 1;
- }
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- WS(weakSelf);
- NSString * cellIdentifier1 = @"SelectTextCell";
- SelectTextCell *selectTextCell = (SelectTextCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier1];
-
-
-
- NSString * cellIdentifier2 = @"InPutTextCell";
- InPutTextCell *inPutTextCell = (InPutTextCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier2];
-
-
- NSString * cellIdentifier3 = @"InPutGongWenCell";
- InPutGongWenCell *inPutGongWenCell = (InPutGongWenCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier3];
-
- NSString * cellIdentifier7 = @"AddPictureCell";
- AddPictureCell *addPictureCell = (AddPictureCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier7];
- if (self.isTest == 1) {
- return selectTextCell;
- }
- else{
-
- FormFieldsModel * formFieldsModel = self.viewDataArray2[indexPath.section];
- if ([formFieldsModel.Type isEqualToString:@"Text"])//单行文本
- {
- inPutTextCell.nameLab.text = formFieldsModel.Label;
- inPutTextCell.haveNeedImageView.hidden = (formFieldsModel.Required == 1)?NO : YES;
- inPutTextCell.inputtextFeild.tag = indexPath.section;
- inPutTextCell.inputtextFeild.delegate = self;
- inPutTextCell.inputtextFeild.returnKeyType = UIReturnKeyDone;
- if (!ISEmptyString(formFieldsModel.paramString)) {
- inPutTextCell.inputtextFeild.text = formFieldsModel.paramString;
- }
-
- return inPutTextCell;
- }
- else if ([formFieldsModel.Type isEqualToString:@"TextArea"])//多行文本
- {
- inPutGongWenCell.namelab.text = formFieldsModel.Label;
- inPutGongWenCell.haveNeedImageView.hidden = (formFieldsModel.Required == 1)?NO : YES;
- inPutGongWenCell.gongwenContent.delegate = self;
- inPutGongWenCell.gongwenContent.tag = indexPath.section;
- inPutGongWenCell.gongwenContent.text = formFieldsModel.paramString;
- return inPutGongWenCell;
- }
- else if ([formFieldsModel.Type isEqualToString:@"Number"])//数字
- {
-
- inPutTextCell.nameLab.text = formFieldsModel.Label;
- inPutTextCell.haveNeedImageView.hidden = (formFieldsModel.Required == 1)?NO : YES;
- inPutTextCell.inputtextFeild.tag = indexPath.section;
- inPutTextCell.inputtextFeild.keyboardType = UIKeyboardTypeNumberPad;
- inPutTextCell.inputtextFeild.delegate = self;
- if (!ISEmptyString(formFieldsModel.paramString)) {
- inPutTextCell.inputtextFeild.text = formFieldsModel.paramString;
- }
- return inPutTextCell;
- }
- else if ([formFieldsModel.Type isEqualToString:@"Currency"])//金额
- {
- inPutTextCell.nameLab.text = formFieldsModel.Label;
- inPutTextCell.haveNeedImageView.hidden = (formFieldsModel.Required == 1)?NO : YES;
- inPutTextCell.inputtextFeild.tag = indexPath.section;
- inPutTextCell.inputtextFeild.keyboardType = UIKeyboardTypeNumberPad;
- inPutTextCell.inputtextFeild.delegate = self;
- if (!ISEmptyString(formFieldsModel.paramString)) {
- inPutTextCell.inputtextFeild.text = formFieldsModel.paramString;
- }
- return inPutTextCell;
- }
- else if ([formFieldsModel.Type isEqualToString:@"DateTime"])//日期
- {
- selectTextCell.nameLab.text = formFieldsModel.Label;
- selectTextCell.haveImageView.hidden = (formFieldsModel.Required == 1)?NO : YES;
- selectTextCell.selectButton.tag = indexPath.section;
- if (!ISEmptyString(formFieldsModel.paramString)) {
- [selectTextCell.selectButton setTitle:formFieldsModel.paramString forState:UIControlStateNormal];
- [selectTextCell.selectButton setTitleColor: UIColorHex(#333333) forState:UIControlStateNormal];
- }
- return selectTextCell;
- }
- else if ([formFieldsModel.Type isEqualToString:@"Radio"])//单选
- {
- selectTextCell.nameLab.text = formFieldsModel.Label;
- selectTextCell.haveImageView.hidden = (formFieldsModel.Required == 1)?NO : YES;
- selectTextCell.selectButton.tag = indexPath.section;
- if (!ISEmptyString(formFieldsModel.paramString)) {
- [selectTextCell.selectButton setTitle:formFieldsModel.paramString forState:UIControlStateNormal];
- [selectTextCell.selectButton setTitleColor: UIColorHex(#333333) forState:UIControlStateNormal];
- }
- return selectTextCell;
- }
- else if ([formFieldsModel.Type isEqualToString:@"Picture"])//图片
- {
- // addPictureCell.namelab.text = formFieldsModel.Label;
- // addPictureCell.haveNeedImageView.hidden = (formFieldsModel.Required == 1)?NO : YES;
- // addPictureCell.approvalSection = formFieldsModel.paraImage;
- // addPictureCell.delegate = self;
- // addPictureCell.index = indexPath;
- // addPictureCell.ClickCellBlock = ^(NSInteger index) {
- // SelectImageModel * imgModel = formFieldsModel.paraImage[index];
- // WorkFlowFileModel *mdoel = [[WorkFlowFileModel alloc]init];
- // mdoel.PreviewUrl = imgModel.FileUrl;
- // mdoel.DownloadUrl = imgModel.FileUrl;
- // mdoel.titleStr = imgModel.FileName;
- // DownFileViewController *vc = [[DownFileViewController alloc]init];
- // vc.model = mdoel;
- // [weakSelf.navigationController pushViewController:vc animated:YES];
- // };
- return addPictureCell;
- }
- else if ([formFieldsModel.Type isEqualToString:@"Attachment"])//附件
- {
- // addPictureCell.namelab.text = formFieldsModel.Label;
- // addPictureCell.haveNeedImageView.hidden = (formFieldsModel.Required == 1)?NO : YES;
- // addPictureCell.approvalSection = formFieldsModel.paraImage;
- // addPictureCell.index = indexPath;
- // addPictureCell.delegate = self;
- // addPictureCell.ClickCellBlock = ^(NSInteger index) {
- // SelectImageModel * imgModel = formFieldsModel.paraImage[index];
- // WorkFlowFileModel *mdoel = [[WorkFlowFileModel alloc]init];
- // mdoel.PreviewUrl = imgModel.FileUrl;
- // mdoel.DownloadUrl = imgModel.FileUrl;
- // DownFileViewController *vc = [[DownFileViewController alloc]init];
- // vc.title = [mdoel.PreviewUrl componentsSeparatedByString:@"/"].lastObject;
- // vc.model = mdoel;
- // [weakSelf.navigationController pushViewController:vc animated:YES];
- // };
- return addPictureCell;
- }
-
- return selectTextCell;
- }
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- WS(weakSelf);
- [MOFSPickerManager shareManger].pickView.toolBar.cancelBar.textColor = UIColorHex(#888888);
- [MOFSPickerManager shareManger].pickView.toolBar.commitBar.textColor = UIColorHex(#3979D3);
- if (self.isTest == 1){
-
-
- }else{
- FormFieldsModel * formFieldsModel = self.viewDataArray2[indexPath.section];
- if ([formFieldsModel.Type isEqualToString:@"Text"])//单行文本
- {
-
- }
- else if ([formFieldsModel.Type isEqualToString:@"TextArea"])//多行文本
- {
-
- }
- else if ([formFieldsModel.Type isEqualToString:@"Number"])//数字
- {
- }
- else if ([formFieldsModel.Type isEqualToString:@"Currency"])//金额
- {
- }
- else if ([formFieldsModel.Type isEqualToString:@"DateTime"])//日期
- {
- WaitTimePicker * picker = [[WaitTimePicker alloc] init];
- [picker setCusDateMode:UIDatePickerModeDateAndTime locale:@"zh_CN"];
- [picker showDatePickerViewWithFirstDate: [NSDate date] commit:^(NSDate * _Nonnull date) {
- NSDateFormatter *dateformat = [[NSDateFormatter alloc]init];
- dateformat.dateFormat = @"yyyy-MM-dd HH:mm";
-
- SelectTextCell *cell = [tableView cellForRowAtIndexPath:indexPath];
- [cell.selectButton setTitle: [dateformat stringFromDate:date] forState:UIControlStateNormal];
- cell.selectButton.tag = indexPath.section;
- [cell.selectButton setTitleColor:UIColorHex(#333333) forState:UIControlStateNormal];
- self.viewDataArray2[indexPath.section].paramString = [dateformat stringFromDate:date];
- } cancel:^{
- }];
- }
- else if ([formFieldsModel.Type isEqualToString:@"Radio"])//单选
- {
- [[HttpManager sharedHttpManager] GETUrl:Host(WorkFlowApp_Car_Type_Get) parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"%@",responseObject);
- NSMutableArray * nameArray = [NSMutableArray array];
- for (NSDictionary * dict in responseObject) {
- NSString * name = [dict objectForKey:@"Name"];
- [nameArray addObject:name];
- }
- [[MOFSPickerManager shareManger] showPickerViewWithDataArray:nameArray tag:1 title:nil cancelTitle:@"取消" commitTitle:@"确定" commitBlock:^(NSString *string) {
- SelectTextCell *cell = [tableView cellForRowAtIndexPath:indexPath];
- [cell.selectButton setTitle: string forState:UIControlStateNormal];
- [cell.selectButton setTitleColor:UIColorHex(#333333) forState:UIControlStateNormal];
- weakSelf.viewDataArray2[indexPath.section].paramString = string;
- for (NSDictionary * dict in responseObject) {
- if ([[dict objectForKey:@"Name"] isEqualToString:string]) {
- weakSelf.carTypeId = [[dict objectForKey:@"Id"] integerValue];
- }
- }
- } cancelBlock:^{
-
- }];
- } failure:^(NSError * _Nonnull error) {
-
- }];
- }
- else if ([formFieldsModel.Type isEqualToString:@"Picture"])//图片
- {
- }
- else if ([formFieldsModel.Type isEqualToString:@"Attachment"])//附件
- {
-
- }
- }
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- if (self.isTest == 1) {
- if (indexPath.section == 0) {
- return 45;
- }
- if (indexPath.section == 1) {
- return 45;
- }
- if (indexPath.section == 2) {
- return 120;
- }
- if (indexPath.section == 3) {
- return 120;
- }
- if (indexPath.section == 4) {
- return 120;
- }
- if (indexPath.section == 5) {
- return 120;
- }
- return 0;
- }
- else{
- FormFieldsModel * formFieldsModel = self.viewDataArray2[indexPath.section];
- if ([formFieldsModel.Type isEqualToString:@"Text"])//单行文本
- {
- return 45;
- }
- else if ([formFieldsModel.Type isEqualToString:@"TextArea"])//多行文本
- {
- return 120;
- }
- else if ([formFieldsModel.Type isEqualToString:@"Number"])//数字
- {
- return 45;
- }
- else if ([formFieldsModel.Type isEqualToString:@"Currency"])//金额
- {
- return 45;
- }
- else if ([formFieldsModel.Type isEqualToString:@"DateTime"])//日期
- {
- return 60;
- }
- else if ([formFieldsModel.Type isEqualToString:@"Radio"])//单选
- {
- return 60;
- }
- else if ([formFieldsModel.Type isEqualToString:@"Picture"])//图片
- {
- return 120;
- }
- else if ([formFieldsModel.Type isEqualToString:@"Attachment"])//附件
- {
- return 120;
- }
- return 120;
- }
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
- if (self.isTest == 1) {
- if (section == 0) {
- return 10;
- }
- if (section == 1) {
- return 10;
- }
- if (section == 2) {
- return 10;
- }
- if (section == 3) {
- return 10;
- }
- if (section == 4) {
- return 10;
- }
- if (section == 5) {
- return 10;
- }
- return 0;
- }
- else{
- return 15;
- }
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
- if (self.isTest == 1) {
- if (section == 0) {
- return 20;
- }
- if (section == 1) {
- return 10;
- }
- if (section == 2) {
- return 10;
- }
- if (section == 3) {
- return 10;
- }
- if (section == 4) {
- return 10;
- }
- if (section == 5) {
- return 10;
- }
- return 0;
- }
- else{
- return 0.01;
- }
- }
- #pragma mark - UITableViewDelegate,UITableViewDataSource
- - (NSMutableArray<NSMutableArray<MyWorkWordModel *> *> *)viewDataArray{
- if (!_viewDataArray) {
- _viewDataArray = [NSMutableArray new];
- }
- return _viewDataArray;
- }
- - (TDTableView *)myTableView{
- if (!_myTableView) {
- _myTableView = [[TDTableView alloc]initWithFrame:CGRectMake(0,kNavigationHeight,kGXScreenWidth,kGXScreenHeigh -kNavigationHeight)];
- _myTableView.delegate = self;
- _myTableView.dataSource= self;
- _myTableView.bounces = NO;
- [_myTableView registerNib:[UINib nibWithNibName:@"SelectTextCell" bundle:nil] forCellReuseIdentifier:@"SelectTextCell"];
- [_myTableView registerNib:[UINib nibWithNibName:@"InPutTextCell" bundle:nil] forCellReuseIdentifier:@"InPutTextCell"];
- [_myTableView registerNib:[UINib nibWithNibName:@"AddFileTableViewCell" bundle:nil] forCellReuseIdentifier:@"AddFileTableViewCell"];
- [_myTableView registerNib:[UINib nibWithNibName:@"InPutGongWenCell" bundle:nil] forCellReuseIdentifier:@"InPutGongWenCell"];
- [_myTableView registerNib:[UINib nibWithNibName:@"AddPeopleToGongWenCell" bundle:nil] forCellReuseIdentifier:@"AddPeopleToGongWenCell"];
- [_myTableView registerNib:[UINib nibWithNibName:@"MyWorkAppApprovalCell" bundle:nil] forCellReuseIdentifier:@"MyWorkAppApprovalCell"];
- [_myTableView registerNib:[UINib nibWithNibName:@"AddPictureCell" bundle:nil] forCellReuseIdentifier:@"AddPictureCell"];
- }
- return _myTableView;
- }
- - (UIView *)footerview{
- if (!_footerview) {
- _footerview = [[UIView alloc]init];
- _footerview.backgroundColor = UIColorHex(EEEEEE);
- TDButton *button = [[TDButton alloc]init];
- [button setTitle:@"提交" forState:UIControlStateNormal];
- [[button titleLabel] setFont: [UIFont systemFontOfSize:19]];
- [button setTitleColor:UIColorHex(FFFFFF) forState:UIControlStateNormal];
- button.backgroundColor = UIColorHex(457BC7);
- button.layer.cornerRadius = 5.f;
- button.layer.masksToBounds = YES;
- [_footerview addSubview:button];
- [button addTarget:self action:@selector(commitGonwen:) forControlEvents:UIControlEventTouchDown];
- [button mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self.footerview.mas_centerX);
- make.centerY.equalTo(self.footerview.mas_centerY);
- make.width.mas_equalTo(kGXScreenWidth - 40);
- make.height.mas_equalTo(50);
- }];
-
- }
- return _footerview;
- }
- - (void)addFile:(NSIndexPath*)indexpath Sucuss:(void (^)(id _Nullable))success failure:(void (^)(NSError * _Nonnull))failure{
- _currentIndexPath = indexpath;
-
- UIImagePickerController *picker = [[UIImagePickerController alloc] init];
-
- picker.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
-
- picker.delegate = self;
-
- picker.allowsEditing = YES;//取消白框
- UIAlertController *alertvc = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
-
- UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- [[LYLPhotoTailoringTool sharedTool] selectPhotoWithPhoroOrCamera: SelectPhotoWithTypePhoroOrCamera2 crop:YES showImgBlock:^(NSString *imageUrlStr) {
-
-
- } choosImgBlock:^(UIImage *image) {
-
- SHOWLOADING
- [[HttpManager sharedHttpManager] HeaderUploadUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Modify_UserImages_Post] parameters:@{@"":@""} pictureData:UIImageJPEGRepresentation(image,1.0f) pictureKey:@"file" success:^(id _Nonnull responseObject) {
-
- NSArray *dic = responseObject;
- SelectImageModel *model = [[SelectImageModel alloc]initWithDictionary:dic[0] error:nil];
- model.image = image;
- if (self->_isTest == 2) {
- success(model);
- }
- } failure:^(NSError * _Nonnull error) {
- failure(error);
- }];
- }];
- }];
- [action1 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
- [alertvc addAction:action1];
- UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"从相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-
- [[LYLPhotoTailoringTool sharedTool] selectPhotoWithPhoroOrCamera:SelectPhotoWithTypePhoroOrCamera1 crop:YES showImgBlock:^(NSString *imageUrlStr) {
- } choosImgBlock:^(UIImage *image) {
-
- SHOWLOADING
- [[HttpManager sharedHttpManager] HeaderUploadUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Modify_UserImages_Post] parameters:@{@"":@""} pictureData:UIImageJPEGRepresentation(image,1.0f) pictureKey:@"file" success:^(id _Nonnull responseObject) {
-
- NSArray *dic = responseObject;
- SelectImageModel *model = [[SelectImageModel alloc] initWithDictionary:dic[0] error:nil];
- model.image = image;
-
- if (self->_isTest == 2) {
- success(model);
- }
- } failure:^(NSError * _Nonnull error) {
- failure(error);
- }];
- }];
- }];
- [alertvc addAction:action2];
- [action2 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
- UIAlertAction *action3 = [UIAlertAction actionWithTitle:@"从收藏选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- SHOWERROR(@"暂不支持,正在开发中");
- }];
- [action3 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
- [alertvc addAction:action3];
- UIAlertAction *action4 = [UIAlertAction actionWithTitle:@"从笔记选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- SHOWERROR(@"暂不支持,正在开发中");
- }];
- [action4 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
- [alertvc addAction:action4];
- UIAlertAction *action5 = [UIAlertAction actionWithTitle:@"本地文件" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- [[FWZFileGetTool sharedTool] openFileWithCrop:YES showImgBlock:^(NSString * _Nonnull fileUrlStr) {
-
- } choosFileBlock:^(NSData * _Nonnull fileData, NSString * _Nonnull fileName) {
- NSLog(@"%@",fileName);
- SHOWLOADING
- [[HttpManager sharedHttpManager] HeaderUploadFileUrl:Host(Modify_UserImages_Post) parameters:@{} fileData:fileData fileKey:@"file" fileName:fileName mimeType:@"multipart/form-data" success:^(id _Nonnull responseObject) {
-
- NSLog(@"上传成功的文件%@",responseObject);
-
- NSArray *dic = responseObject;
-
- SelectImageModel *model = [[SelectImageModel alloc] initWithDictionary:dic[0] error:nil];
- if (self->_isTest) {
- success(model);
- }
- } failure:^(NSError * _Nonnull error) {
- failure(error);
- }];
-
- }];
- }];
- [action5 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
- [alertvc addAction:action5];
- UIAlertAction *action6 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [action6 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
- [alertvc addAction:action6];
-
- [self presentViewController:alertvc animated:YES completion:^{}];
-
-
- }
- #pragma mark - 提交
- - (void)commitGonwen:(TDButton *)sender{
- if (self.isTest == 1) {
- }else{
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
- for (FormFieldsModel *model in self.viewDataArray2) {
-
- if ([model.Type isEqualToString:@"TextArea"]) {
- if ([model.paramString isEqualToString:@"请输入"]) {
- NSString *errorString = [NSString stringWithFormat:@"%@%@",model.Placeholder,model.Label];
- SHOWERROR(errorString);
- return;
- }
- }
-
- if (ISEmptyString(model.paramString)) {
- if (model.Required){
- NSString *errorString = [NSString stringWithFormat:@"%@%@",model.Placeholder,model.Label];
- NSLog(@"%@",model);
- SHOWERROR(errorString);
- return;
- }
- }else{
- if ([model.Type isEqualToString:@"TextArea"]) {
- [dic setValue:model.paramString forKey:@"Reasons"];
- }
- if ([model.Type isEqualToString:@"Radio"]) {
- [dic setValue:model.paramString forKey:@"Destination"];
- }
- if ([[dic objectForKey:@"StartDate"] length] > 0) {
- if ([model.Type isEqualToString:@"DateTime"]) {
- [dic setValue:model.paramString forKey:@"EndDate"];
- }
- }else{
- if ([model.Type isEqualToString:@"DateTime"]) {
- [dic setValue:model.paramString forKey:@"StartDate"];
- }
- }
- if ([model.Type isEqualToString:@"Text"]) {
- [dic setValue:@([model.paramString integerValue]) forKey:@"Hour"];
- }
- }
- }
- [dic setValue:@(self.carTypeId) forKey:@"TypeId"];
- NSLog(@"成功成功成功成功%@",dic);
- SHOWLOADING
- WS(weakSelf);
- [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,WorkFlowApp_Car_Actions_Order] parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
- REMOVESHOW
- SHOWSUCCESS(@"申请成功");
- [weakSelf.navigationController popViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- }
- -(void)gotoAddPeople{
- SendInfoGroupVC *sendinfoVc = [[SendInfoGroupVC alloc] init];
- [self.navigationController pushViewController:sendinfoVc animated:YES];
- }
- - (BOOL)textFieldShouldReturn:(UITextField *)textField{
- if (_isTest == 2) {
- self.viewDataArray2[textField.tag].paramString = textField.text;
- }
- [textField resignFirstResponder];
- return YES;
- }
- - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
- return YES;
- }
- - (void)textViewDidChange:(UITextView *)textView{
- if (_isTest == 2) {
- self.viewDataArray2[textView.tag].paramString = textView.text;
- }
- }
- - (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange interaction:(UITextItemInteraction)interaction{
- if (_isTest == 2) {
- self.viewDataArray2[textView.tag].paramString = textView.text;
- }
- return YES;
- }
- - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
- if ([string isEqualToString:@""] || [string isEqualToString:@"\n"]) {
- return YES;
- }
- if(self.isTest == 2) {
- self.viewDataArray2[textField.tag].paramString = textField.text;
- }
- return YES;
- }
- #pragma mark - AddPictureCellDelegate
- - (void)addPictureWith:(NSIndexPath *)index WithSuccess:(void (^)(id _Nullable))success failure:(void (^)(NSError * _Nonnull))failure{
- WEAKSELF
- [self addFile:index Sucuss:^(id _Nullable responseObject) {
- STRONGSELF
- AddPictureCell *cell = [strongSelf.myTableView cellForRowAtIndexPath:index];
- [cell.mycollectionView reloadData];
- [strongSelf.viewDataArray2[index.section].paraImage addObject:responseObject];
- strongSelf.viewDataArray2[index.section].paramString = @"ssas";
- NSLog(@"%@",strongSelf.viewDataArray2[index.section]);
-
- REMOVESHOW;
-
- } failure:^(NSError * _Nonnull error ) {
- REMOVESHOW;
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- - (void)deletePictureWithCell:(NSIndexPath *)index SuperViewCellIndexPath:(NSIndexPath *)superIndex WithSuccess:(void (^)(id _Nullable))success failure:(void (^)(NSError * _Nonnull))failure{
- [self.viewDataArray2[superIndex.section].paraImage removeObjectAtIndex:index.item];
- }
- #pragma mark - AddPeopleToGongWenCellDelegate,MyWorkAppApprovalCellDelegate
- - (void)addLookUpPeopleSuccess:(void (^)(id _Nullable))success failure:(void (^)(NSError * _Nonnull))failure{
- NSLog(@"点击添加抄送人");
- self.isShenPinRen = NO;
- Department *defaltGroupSetion = [[Department alloc]init];
- defaltGroupSetion.Name = @"单位通讯录";
- defaltGroupSetion.Id = 0;
-
- Department *myGroupSetion = [[Department alloc]init];
- myGroupSetion.Name = @"自建通讯录";
- defaltGroupSetion.Id = 0;
-
- AddLookUpUserSecondVC *vc = [[AddLookUpUserSecondVC alloc] init];
- vc.departSourceDataArray = @[defaltGroupSetion,myGroupSetion].mutableCopy;
- vc.isDefalutPage = 1;
- vc.delegate = self;
- [self.navigationController pushViewController:vc animated:YES];
- }
- - (void)addApprovalPeopleSuccess:(void (^)(id _Nullable))success failure:(void (^)(NSError * _Nonnull))failure{
- NSLog(@"点击添加抄送人");
- self.isShenPinRen = YES;
- Department *defaltGroupSetion = [[Department alloc]init];
- defaltGroupSetion.Name = @"单位通讯录";
- defaltGroupSetion.Id = 0;
-
- Department *myGroupSetion = [[Department alloc]init];
- myGroupSetion.Name = @"自建通讯录";
- defaltGroupSetion.Id = 0;
-
- AddLookUpUserSecondVC *vc = [[AddLookUpUserSecondVC alloc] init];
- vc.departSourceDataArray = @[defaltGroupSetion,myGroupSetion].mutableCopy;
- vc.isDefalutPage = 1;
- vc.delegate = self;
- [self.navigationController pushViewController:vc animated:YES];
- }
- #pragma mark - 注册通知 接受抄送人和审批人数据
- - (void)registerNotification{
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recviveChaoSongRen:) name:NOTIFI_ChaoSongRen object:nil];
- // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recviveApprovalRen:) name:NOTIFI_ApprovalRen object:nil];
- }
- - (void)recviveApprovalRen:(NSNotification *)notification{
- NSLog(@"审批人1%@",notification.userInfo);
- // SelectModel *model = [[SelectModel alloc]initWithDictionary:notification.userInfo error:nil];
- SelectModel * model = [[SelectModel alloc] initDict:notification.userInfo];
- [self.shenPiRenArr addObject:model];
- NSLog(@"审批人2%@",self.shenPiRenArr);
- [self.myTableView reloadSection:self.viewDataArray2.count withRowAnimation:UITableViewRowAnimationAutomatic];
- }
- - (void)recviveChaoSongRen:(NSNotification *)notification{
- if (self.isShenPinRen) {
- NSMutableArray <SelectModel *>* array = notification.userInfo[@"selectPeople"];
-
- NSMutableArray <SelectModel *>* array0 = self.shenPiRenArr;
- NSMutableArray <SelectModel *>* array1 = notification.userInfo[@"selectPeople"];
- if (array0.count == 0) {
- [self.shenPiRenArr addObjectsFromArray:array];
- }else{
- for (NSInteger x = 0; x < array.count; x++) {
- for (NSInteger y = 0 ; y<array0.count; y++) {
- if (array[x].UserId == array0[y].UserId) {
- [array1 removeObjectAtIndex:x];
- }
- }
- }
- NSLog(@"结果数据组%@",array1);
- [self.shenPiRenArr addObjectsFromArray:array1];
- }
- }else{
- NSMutableArray <SelectModel *>* array = notification.userInfo[@"selectPeople"];
-
- NSMutableArray <SelectModel *>* array0 = self.chaoSongRenArr;
- NSMutableArray <SelectModel *>* array1 = notification.userInfo[@"selectPeople"];
- if (array0.count == 0) {
- [self.chaoSongRenArr addObjectsFromArray:array];
- }else{
- for (NSInteger x = 0; x < array.count; x++) {
- for (NSInteger y = 0 ; y<array0.count; y++) {
- if (array[x].UserId == array0[y].UserId) {
- [array1 removeObjectAtIndex:x];
- }
- }
- }
- NSLog(@"结果数据组%@",array1);
- [self.chaoSongRenArr addObjectsFromArray:array1];
- }
- }
- [self.myTableView reloadData];
- }
- #pragma mark - setter
- - (NSMutableArray *)chaoSongRenArr{
- if (!_chaoSongRenArr) {
- _chaoSongRenArr = [NSMutableArray array];
- }
- return _chaoSongRenArr;
- }
- - (NSMutableArray *)shenPiRenArr{
- if (!_shenPiRenArr) {
- _shenPiRenArr = [NSMutableArray array];
- }
- return _shenPiRenArr;
- }
- - (void)dealloc
- {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- }
- @end
|