JONewMeetingTableViewController.m 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517
  1. //
  2. // JONewMeetingTableViewController.m
  3. // shiku_im
  4. //
  5. // Created by 周兵 on 16/6/29.
  6. // Copyright © 2016年 Reese. All rights reserved.
  7. //
  8. #import "JONewMeetingTableViewController.h"
  9. #import "ZQDayPickerViewController.h"
  10. #import "JOGETNameTableViewController.h"
  11. #import "JONavigationController.h"
  12. #import "JOGETAddressTableViewController.h"
  13. #import "JOGETLabelTableViewController.h"
  14. #import "JOShowMessageFromNavi.h"
  15. #import "JOHYTableViewController.h"
  16. #import "iflyMSC/IFlyMSC.h"
  17. #import "ISRDataHelper.h"
  18. #import "IATConfig.h"
  19. #import "YPCalendarVC.h"
  20. #define balckColor [UIColor blackColor]
  21. #define UNblack Color(71,71,71,1.0)
  22. #define beijingyanse Color(160,160,160,0.5)
  23. #pragma mark -- 自定义的cell
  24. @interface HYcell : UITableViewCell
  25. {
  26. /**cell标题名字*/
  27. UILabel * _labelName;
  28. }
  29. /**数据接口*/
  30. @property (nonatomic , strong) NSMutableAttributedString * nameString;
  31. /** 会议编号*/
  32. /**
  33. 设置模型
  34. */
  35. -(void)setModel;
  36. @end
  37. @implementation HYcell
  38. -(void)setModel
  39. {
  40. _labelName=[[UILabel alloc]init];
  41. _labelName.font=FONT_SIZE(14);
  42. _labelName.textColor=UNblack;
  43. _labelName.frame=CGRectMake(10,10,90,20);
  44. _labelName.attributedText=_nameString;
  45. [self.contentView addSubview:_labelName];
  46. }
  47. @end
  48. @interface JONewMeetingTableViewController ()<ZQDayPickerViewControllerDelegate,UITextFieldDelegate,UITableViewDelegate,UITableViewDataSource,IFlySpeechRecognizerDelegate>
  49. {
  50. NSArray * numOfSection;
  51. /**会议名称*/
  52. UITextField * _huiyiName;
  53. /**开始时间*/
  54. UILabel * _beginTime;
  55. /**结束时间*/
  56. UILabel * _closeTime;
  57. /**会议地址*/
  58. UITextField * _huiyiAddress;
  59. /**参会人员*/
  60. UILabel * _canhui;
  61. /**参会人员IMID*/
  62. NSString * _canhuiImId;
  63. /**管理人员*/
  64. UILabel * _guanli;
  65. /**会议标签*/
  66. UITextField * _huiyiLabel;
  67. /**会议介绍*/
  68. UITextField * _huiyijiesao;
  69. /**会议日程*/
  70. UISwitch * _rcSwitch;
  71. UITableView * _tableView;
  72. int yaobuyaoricheng;
  73. ZQDayPickerViewController * _dayPickerViewController01;
  74. ZQDayPickerViewController * _dayPickerViewController02;
  75. MBProgressHUD * HUD;
  76. UIButton * _uploadBtn;//上传按钮.
  77. }
  78. @property (nonatomic, copy) NSString *Str;
  79. @property(nonatomic,strong)UIView * uv;
  80. @property(nonatomic,strong) IFlySpeechRecognizer * iFlySpeechRecognizer;//带视图的语音识别器
  81. @property(nonatomic,strong)UIImageView * imageV;
  82. @property(nonatomic,strong)UIView * MyView;
  83. @end
  84. @implementation JONewMeetingTableViewController
  85. - (void)viewDidLoad {
  86. [super viewDidLoad];
  87. self.view.backgroundColor=[UIColor whiteColor];
  88. _tableView=[[UITableView alloc]initWithFrame:CGRectMake(0,0,self_width, self_height) style:UITableViewStylePlain];
  89. _tableView.backgroundColor= BGB_COLOR;
  90. _tableView.delegate=self;
  91. _tableView.dataSource=self;
  92. [self.view addSubview:_tableView];
  93. [self setNavi];
  94. //去掉多余分割线
  95. [self setExtraCellLineHidden:_tableView];
  96. [self initRecognizer1];
  97. [self initCYBL];
  98. //判断从那个页面返回
  99. // self.block(@"创建会议");
  100. }
  101. /**
  102. 设置导航栏
  103. */
  104. - (void)setNavi
  105. {
  106. //1,设置title
  107. UILabel * titleLabel=[[UILabel alloc]initWithFrame:CGRectMake(0,0,80,30)];
  108. titleLabel.font=FONT_SIZE(18);
  109. titleLabel.text=Localized(@"UU_work_OA_ManagementOfMeetings_CreateMeeting");
  110. titleLabel.textColor=[UIColor whiteColor];
  111. self.navigationItem.titleView=titleLabel;
  112. //2,保存按钮
  113. UIButton *rigntBtn = [UIButton buttonWithType:UIButtonTypeSystem];
  114. rigntBtn.frame = CGRectMake(0, 0, 20, 20);
  115. rigntBtn.tintColor = [UIColor whiteColor];
  116. [rigntBtn setImage:[UIImage imageNamed:@"1xlist"] forState:UIControlStateNormal];
  117. [rigntBtn addTarget:self action:@selector(createHYB) forControlEvents:UIControlEventTouchUpInside];
  118. UIBarButtonItem *creatBtn = [[UIBarButtonItem alloc]initWithCustomView:rigntBtn];
  119. [self.navigationItem setRightBarButtonItem:creatBtn];
  120. UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeSystem];
  121. btn2.frame = CGRectMake(0, 5, 22, 22);
  122. UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(0, iOS11?5:0, 22, 22)];
  123. image.image = [UIImage imageNamed:@"icon_back_nor3"];
  124. btn2.tintColor = [UIColor whiteColor];
  125. [btn2 addSubview:image];
  126. [btn2 addTarget:self action:@selector(cancel) forControlEvents:UIControlEventTouchUpInside];
  127. UIBarButtonItem *bbi2 = [[UIBarButtonItem alloc]initWithCustomView:btn2];
  128. self.navigationItem.leftBarButtonItems = @[bbi2];
  129. }
  130. /**
  131. 创建会议
  132. */
  133. - (void)createHYB
  134. {
  135. // JONewMeetingTableViewController * newMeeting=[[JONewMeetingTableViewController alloc]init];
  136. //
  137. // [newMeeting setBlock:^(NSString *str) {
  138. //
  139. // _CJStr = str;
  140. //
  141. // }];
  142. // [self.navigationController pushViewController:newMeeting animated:YES];
  143. JOHYTableViewController * vc=[[JOHYTableViewController alloc]init];
  144. [self.navigationController pushViewController:vc animated:YES];
  145. }
  146. /**
  147. 初始化成员变量
  148. */
  149. - (void)initCYBL
  150. {
  151. NSString * qingshuru=Localized(@"UU_custom_pleaseInput");
  152. NSString * qingxuanze=Localized(@"UU_custom_pleaseSelect");
  153. CGFloat wigth=100;
  154. numOfSection=@[@[Localized(@"UU_work_OA_MM_CreateMeeting_ConferenceName"),Localized(@"UU_work_OA_MM_CreateMeeting_StartTime"),Localized(@"UU_work_OA_MM_CreateMeeting_EndTime"),Localized(@"UU_work_OA_ManagementOfMeetings_Meetingplace")],@[Localized(@"UU_work_OA_MM_CreateMeeting_Participants"),Localized(@"UU_work_OA_MM_CreateMeeting_Administrators")],@[Localized(@"UU_work_OA_MM_MeetingDetail_ConferenceTab"),Localized(@"UU_work_OA_MM_MeetingDetail_ConferencePresentation")],@[Localized(@"UU_work_OA_MM_CreateMeeting_CreateSchedulesForAttendees")]];
  155. /**1,初始化会议标题*/
  156. _huiyiName = [[UITextField alloc] initWithFrame:CGRectMake(wigth,5,SCREEN_WIDTH-135,30)];
  157. [_huiyiName setBorderStyle:UITextBorderStyleNone]; //外框类型
  158. _huiyiName.placeholder =qingshuru; //默认显示的字
  159. _huiyiName.textColor=balckColor;
  160. _huiyiName.autocorrectionType = UITextAutocorrectionTypeNo;
  161. _huiyiName.autocapitalizationType = UITextAutocapitalizationTypeNone;
  162. _huiyiName.returnKeyType = UIReturnKeyDone;
  163. _huiyiName.font =FONT_SIZE(13);
  164. _huiyiName.delegate=self;
  165. _huiyiName.textAlignment = NSTextAlignmentRight;
  166. /**
  167. 会议开始和结束时间默认当前时间和之后两小时
  168. */
  169. NSDateFormatter * formatter=[[NSDateFormatter alloc]init];
  170. [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
  171. NSDate * date=[NSDate date];
  172. NSString * strNow=[formatter stringFromDate:date];
  173. /**2,会议开始时间*/
  174. _beginTime =[[UILabel alloc]initWithFrame:CGRectMake(wigth,5,SCREEN_WIDTH-135,30)];
  175. _beginTime.textColor=balckColor;
  176. _beginTime.font =FONT_SIZE(14);
  177. _beginTime.text=strNow;
  178. _beginTime.textAlignment = NSTextAlignmentRight;
  179. NSDate * dates=[NSDate dateWithTimeIntervalSinceNow:7200];
  180. NSString * strgan=[formatter stringFromDate:dates];
  181. /**3,会议结束时间*/
  182. _closeTime =[[UILabel alloc]initWithFrame:CGRectMake(wigth,5,SCREEN_WIDTH-135,30)];
  183. _closeTime.font =FONT_SIZE(14);
  184. _closeTime.textColor=balckColor;
  185. _closeTime.text=strgan;
  186. _closeTime.textAlignment = NSTextAlignmentRight;
  187. /**4,会议地址*/
  188. _huiyiAddress = [[UITextField alloc] initWithFrame:CGRectMake(wigth,5,SCREEN_WIDTH-135,30)];
  189. [_huiyiAddress setBorderStyle:UITextBorderStyleNone]; //外框类型
  190. _huiyiAddress.placeholder = qingxuanze; //默认显示的字
  191. _huiyiAddress.autocorrectionType = UITextAutocorrectionTypeNo;
  192. _huiyiAddress.autocapitalizationType = UITextAutocapitalizationTypeNone;
  193. _huiyiAddress.font =FONT_SIZE(14);
  194. _huiyiAddress.returnKeyType = UIReturnKeyDone;
  195. _huiyiAddress.userInteractionEnabled=NO;
  196. _huiyiAddress.delegate=self;
  197. _huiyiAddress.textAlignment = NSTextAlignmentRight;
  198. /**5,参会人员*/
  199. _canhui=[[UILabel alloc]initWithFrame:CGRectMake(wigth,5,SCREEN_WIDTH-135,30)];
  200. _canhui.textColor=beijingyanse;
  201. _canhui.font =FONT_SIZE(14);
  202. _canhui.text=qingxuanze;
  203. _canhui.textAlignment = NSTextAlignmentRight;
  204. /**6,管理人员*/
  205. /**7,会议标签*/
  206. _huiyiLabel=[[UITextField alloc] initWithFrame:CGRectMake(wigth,5, SCREEN_WIDTH-135, 30)];
  207. [_huiyiLabel setBorderStyle:UITextBorderStyleNone]; //外框类型
  208. _huiyiLabel.placeholder =qingxuanze ; //默认显示的字
  209. _huiyiLabel.autocorrectionType = UITextAutocorrectionTypeNo;
  210. _huiyiLabel.autocapitalizationType = UITextAutocapitalizationTypeNone;
  211. _huiyiLabel.returnKeyType = UIReturnKeyDone;
  212. _huiyiLabel.delegate=self;
  213. _huiyiLabel.font =FONT_SIZE(14);
  214. _huiyiLabel.userInteractionEnabled=NO;
  215. _huiyiLabel.textAlignment = NSTextAlignmentRight;
  216. /**8,会议介绍*/
  217. _huiyijiesao = [[UITextField alloc] initWithFrame:CGRectMake(wigth,5,SCREEN_WIDTH-135,30)];
  218. [_huiyijiesao setBorderStyle:UITextBorderStyleNone]; //外框类型
  219. _huiyijiesao.placeholder = qingshuru; //默认显示的字
  220. _huiyijiesao.autocorrectionType = UITextAutocorrectionTypeNo;
  221. _huiyijiesao.autocapitalizationType = UITextAutocapitalizationTypeNone;
  222. _huiyijiesao.returnKeyType = UIReturnKeyDone;
  223. _huiyijiesao.font =FONT_SIZE(14);
  224. _huiyijiesao.delegate=self;
  225. _huiyijiesao.textAlignment = NSTextAlignmentRight;
  226. [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(textFiledEditChanged:)name:@"UITextFieldTextDidChangeNotification"
  227. object:nil];
  228. }
  229. -(void)initMyButton:(UITableViewCell * )Mycell andIndexPath:(NSIndexPath *)indexPath{
  230. UIButton * btn = [[UIButton alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-21, 12, 16,16 )];
  231. [btn setImage:[UIImage imageNamed:@"icon-searcher-custom"] forState:UIControlStateNormal];
  232. [btn addTarget:self action:@selector(clickVoiceSearch:) forControlEvents:UIControlEventTouchUpInside];
  233. btn.tag = indexPath.row + indexPath.section;
  234. [Mycell.contentView addSubview:btn];
  235. }
  236. -(void)clickVoiceSearch:(id)sender{
  237. [self.view endEditing:YES];
  238. UIView * view = (UIView * )sender;
  239. UIView * MyView =[[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds];
  240. MyView.backgroundColor =[UIColor colorWithRed:1 green:1 blue:1 alpha:0.5];
  241. self.MyView = MyView;
  242. self.MyView.tag = view.tag;
  243. [self.view addSubview:MyView];
  244. UIImageView * imageV =[[UIImageView alloc]initWithFrame:CGRectMake((SCREEN_WIDTH-60)/2, 200, 60, 60)];
  245. imageV.image = [UIImage imageNamed:@"uu_voice_search1"];
  246. imageV.userInteractionEnabled = YES;
  247. self.imageV = imageV;
  248. [MyView addSubview:imageV];
  249. [_iFlySpeechRecognizer startListening];
  250. }
  251. -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
  252. [super touchesBegan:touches withEvent:event];
  253. [self.MyView removeFromSuperview];
  254. [_iFlySpeechRecognizer cancel];
  255. }
  256. -(void)initRecognizer1
  257. {
  258. DLog(@"%s",__func__);
  259. //单例模式,无UI的实例
  260. if (_iFlySpeechRecognizer == nil) {
  261. _iFlySpeechRecognizer = [IFlySpeechRecognizer sharedInstance];
  262. [_iFlySpeechRecognizer setParameter:@"" forKey:[IFlySpeechConstant PARAMS]];
  263. //设置听写模式
  264. [_iFlySpeechRecognizer setParameter:@"iat" forKey:[IFlySpeechConstant IFLY_DOMAIN]];
  265. }
  266. _iFlySpeechRecognizer.delegate = self;
  267. if (_iFlySpeechRecognizer != nil) {
  268. IATConfig *instance = [IATConfig sharedInstance];
  269. //设置最长录音时间
  270. [_iFlySpeechRecognizer setParameter:instance.speechTimeout forKey:[IFlySpeechConstant SPEECH_TIMEOUT]];
  271. //设置后端点
  272. [_iFlySpeechRecognizer setParameter:instance.vadEos forKey:[IFlySpeechConstant VAD_EOS]];
  273. //设置前端点
  274. [_iFlySpeechRecognizer setParameter:instance.vadBos forKey:[IFlySpeechConstant VAD_BOS]];
  275. //网络等待时间
  276. [_iFlySpeechRecognizer setParameter:@"20000" forKey:[IFlySpeechConstant NET_TIMEOUT]];
  277. //设置采样率,推荐使用16K
  278. [_iFlySpeechRecognizer setParameter:instance.sampleRate forKey:[IFlySpeechConstant SAMPLE_RATE]];
  279. if ([instance.language isEqualToString:[IATConfig chinese]]) {
  280. //设置语言
  281. [_iFlySpeechRecognizer setParameter:instance.language forKey:[IFlySpeechConstant LANGUAGE]];
  282. //设置方言
  283. [_iFlySpeechRecognizer setParameter:instance.accent forKey:[IFlySpeechConstant ACCENT]];
  284. }else if ([instance.language isEqualToString:[IATConfig english]]) {
  285. [_iFlySpeechRecognizer setParameter:instance.language forKey:[IFlySpeechConstant LANGUAGE]];
  286. }
  287. //设置是否返回标点符号
  288. [_iFlySpeechRecognizer setParameter:instance.dot forKey:[IFlySpeechConstant ASR_PTT]];
  289. }
  290. }
  291. #pragma mark 下面是语音识别的回调函数
  292. - (void) onError:(IFlySpeechError *) error
  293. {
  294. if (error.errorCode == 20001) {
  295. [KPromptBox showKPromptBoxWithMassage:@"请检查网络连接"];
  296. }else if(error.errorCode == 20006){
  297. [KPromptBox showKPromptBoxWithMassage:@"请检查麦克风权限是否开启"];
  298. }
  299. [self.MyView removeFromSuperview];
  300. }
  301. - (void) onVolumeChanged: (int)volume{
  302. int ff = volume;
  303. if (ff>=0&&ff<3) {
  304. [self.imageV setImage:GetImage(@"uu_voice_search1")];
  305. } else if (ff>=3 && ff<6) {
  306. [self.imageV setImage:GetImage(@"uu_voice_search2")];
  307. } else if (ff >=6 &&ff<9) {
  308. [self.imageV setImage:GetImage(@"uu_voice_search3")];
  309. } else if (ff >=9 &&ff<12) {
  310. [self.imageV setImage:GetImage(@"uu_voice_search4")];
  311. } else if (ff >=12 &&ff<15) {
  312. [self.imageV setImage:GetImage(@"uu_voice_search5")];
  313. } else if (ff >= 15 && ff < 18) {
  314. [self.imageV setImage:GetImage(@"uu_voice_search6")];
  315. } else if (ff >= 18 && ff < 21) {
  316. [self.imageV setImage:GetImage(@"uu_voice_search7")];
  317. } else if(ff>=21){
  318. [self.imageV setImage:GetImage(@"uu_voice_search8")];
  319. }
  320. }
  321. //听写结果回调
  322. // resultArray:听写结果
  323. // isLast:表示最后一次
  324. - (void) onResults:(NSArray *) results isLast:(BOOL)isLast
  325. {
  326. NSMutableString *result = [[NSMutableString alloc] init];
  327. NSDictionary *dic = [results objectAtIndex:0];
  328. for (NSString *key in dic) {
  329. [result appendFormat:@"%@",key];
  330. }
  331. NSString * resultFromJson = [ISRDataHelper stringFromJson:result];
  332. NSString * searchText = [NSString stringWithFormat:@"%@",resultFromJson];
  333. if (self.MyView.tag == 0) {
  334. _huiyiName.text = searchText;
  335. }
  336. else{
  337. _huiyijiesao.text = searchText;
  338. }
  339. [_iFlySpeechRecognizer cancel];
  340. }
  341. - (BOOL)textFieldShouldReturn:(UITextField *)textField
  342. {
  343. [_huiyiName resignFirstResponder];
  344. [_huiyiAddress resignFirstResponder];
  345. [_huiyijiesao resignFirstResponder];
  346. [_huiyiLabel resignFirstResponder];
  347. return YES;
  348. }
  349. #pragma mark -- 点击事件
  350. /**取消返回*/
  351. - (void)cancel
  352. {
  353. [self.navigationController popViewControllerAnimated:YES];
  354. }
  355. /**
  356. 保存发布
  357. 先获取code
  358. */
  359. - (void)preserve:(UIButton *)btn
  360. {
  361. if ([_huiyiName.text isEqualToString:@""])
  362. {
  363. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_work_OA_MM_CreateMeeting_FillMeetingName") ToNavi:self.navigationController withColor:nil];
  364. return;
  365. }else if ([_huiyiAddress.text isEqualToString:@""])
  366. {
  367. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_work_OA_MM_CreateMeeting_FillMeetingAddress") ToNavi:self.navigationController withColor:nil];
  368. return;
  369. }else if ([_beginTime.text isEqualToString:Localized(@"UU_custom_pleaseSelect")]||[_closeTime.text isEqualToString:Localized(@"UU_custom_pleaseSelect")])
  370. {
  371. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_work_OA_MM_CreateMeeting_FillMeetingTime") ToNavi:self.navigationController withColor:nil];
  372. return;
  373. }else if ([_canhui.text isEqualToString:Localized(@"UU_custom_pleaseSelect")])
  374. {
  375. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_work_OA_MM_CreateMeeting_ParticipantsCanNoteEmpty") ToNavi:self.navigationController withColor:nil];
  376. return;
  377. }else{
  378. [self sethuiyiMrCode];
  379. //btn.userInteractionEnabled=NO;
  380. DLog(@"要不要日程啊%d",yaobuyaoricheng);
  381. HUD = [[MBProgressHUD alloc] initWithView:self.view];
  382. [self.view addSubview:HUD];
  383. HUD.labelText = @"";
  384. HUD.mode = MBProgressHUDModeIndeterminate;
  385. if (_uploadBtn.selected) {
  386. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_work_OA_MM_CreateMeeting_Creating") ToNavi:self.navigationController withColor:nil];
  387. return;
  388. }
  389. _uploadBtn.selected = YES;
  390. [HUD showAnimated:YES whileExecutingBlock:^{
  391. for (int i=0; i<yaobuyaoricheng; i++)
  392. {
  393. //1,创建一个网络请求管理对象
  394. UASNetworkManager *manager1=[UASNetworkManager shareManager];
  395. manager1.responseSerializer=[AFHTTPResponseSerializer serializer];
  396. //2,取出sessionID和IP
  397. NSUserDefaults *userDefault=[NSUserDefaults standardUserDefaults];
  398. NSString *sessionId=[userDefault stringForKey:@"sessionId"];
  399. NSString * ips=[UASUserInfo shareManager].urlIp;
  400. NSString * userID=[[NSUserDefaults standardUserDefaults] objectForKey:@"erpaccount"];
  401. NSString *master=[[[NSUserDefaults standardUserDefaults] objectForKey:@"masterDic"]objectForKey:@"ma_user"];
  402. //3.拼接sessionID
  403. NSString *paramSessionId=[@"" stringByAppendingFormat:@"JSESSIONID=%@",sessionId];
  404. //4.设置cookie
  405. [manager1.requestSerializer setValue:paramSessionId forHTTPHeaderField:@"Cookie"];
  406. //5,接口
  407. NSString * urlAddress1=@"common/getCodeString.action";
  408. //6,Caller
  409. NSString * caller1=@"Meetingroomapply";
  410. //url
  411. NSString * url2=[@"" stringByAppendingFormat:@"%@%@?type=2&caller=%@&master=%@&sessionUser=%@",ips,urlAddress1,caller1,master,userID];
  412. [manager1 request:url2 method:GET parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
  413. NSData *data=responseObject;
  414. id rootDic =[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
  415. DLog(@"请求成功");
  416. DLog(@"返回的是什么鬼:%@",rootDic);
  417. NSString * code=[rootDic objectForKey:@"code"];
  418. if (i==0)
  419. {
  420. [self getMa_idFromServer:code];
  421. }else{
  422. [self confirmAction:code];
  423. }
  424. } failure:^(NSURLSessionDataTask *task, NSError *error) {
  425. ErrorInfomation
  426. // [self dismissViewControllerAnimated:YES completion:nil];
  427. }];
  428. }
  429. } completionBlock:^{
  430. // HUD.mode=MBProgressHUDModeIndeterminate;
  431. // HUD.labelText=Localized(@"UU_custom_netWorking");
  432. // [HUD show:YES];
  433. }];
  434. }
  435. }
  436. /**
  437. 获取ma_id接口
  438. */
  439. - (void)getMa_idFromServer:(NSString *)code
  440. {
  441. //2,取出sessionID和IP
  442. NSUserDefaults *userDefault=[NSUserDefaults standardUserDefaults];
  443. NSString *sessionId=[userDefault stringForKey:@"sessionId"];
  444. NSString * ips=[UASUserInfo shareManager].urlIp;
  445. NSString * userID=[[NSUserDefaults standardUserDefaults] objectForKey:@"erpaccount"];
  446. NSString *master=[[[NSUserDefaults standardUserDefaults] objectForKey:@"masterDic"]objectForKey:@"ma_user"];
  447. //3.拼接sessionID
  448. NSString *paramSessionId=[@"" stringByAppendingFormat:@"JSESSIONID=%@",sessionId];
  449. //5,接口
  450. NSString * urlAddress1=@"common/getId.action";
  451. //6,Caller
  452. NSString * seq=@"Meetingroomapply_SEQ";
  453. //url
  454. NSString * url2=[@"" stringByAppendingFormat:@"%@%@?&seq=%@&master=%@&sessionUser=%@",ips,urlAddress1,seq,master,userID];
  455. DLog(@"url2=%@",url2);
  456. url2 = [url2 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  457. [[UASNetworkManager shareManager] request:url2 method:GET parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
  458. // NSData *data=responseObject;
  459. // id rootDic =[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
  460. NSDictionary *rootDic = responseObject;
  461. DLog(@"返回的是什么鬼:%@",rootDic);
  462. if (rootDic.count != 0) {
  463. [self postDataToServerWith:code andWithMa_id:[rootDic objectForKey:@"id"]];
  464. }else{
  465. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_work_OA_MM_CreateMeeting_NewCreateFailed") ToNavi:self.navigationController withColor:nil];
  466. [self dismissViewControllerAnimated:YES completion:nil];
  467. }
  468. } failure:^(NSURLSessionDataTask *task, NSError *error) {
  469. ErrorInfomation
  470. }];
  471. }
  472. //创建日程
  473. - (void)confirmAction:(NSString *)code
  474. {
  475. NSString *sessionId=[[NSUserDefaults standardUserDefaults] stringForKey:@"sessionId"];
  476. NSString *ip=[UASUserInfo shareManager].urlIp;
  477. NSString * userID=[[NSUserDefaults standardUserDefaults] objectForKey:@"erpaccount"];
  478. NSString *master=[[[NSUserDefaults standardUserDefaults] objectForKey:@"masterDic"]objectForKey:@"ma_user"];
  479. NSDictionary * params;
  480. params = @{
  481. @"name":_huiyiName.text,
  482. @"resourcename":_canhui.text,
  483. @"enddate":_closeTime.text,
  484. @"tasklevel":@"紧急",
  485. @"taskorschedule":@"Schedule",
  486. @"custname":@"",
  487. @"timealert":@"",
  488. @"description":_huiyiLabel.text,
  489. @"SOURCECODE":@"",
  490. @"taskcode":code,
  491. @"startdate":_beginTime.text
  492. // @"handstatus":@"未完成",
  493. // @"handstatuscode":@"UNFINISHED"
  494. };
  495. DLog(@"里面时什么啊,怎么会崩%@",params);
  496. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:params options:NSJSONWritingPrettyPrinted error:nil];
  497. NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  498. NSDictionary * dic11 = @{
  499. @"formStore":str,
  500. @"sessionId":sessionId,
  501. @"master":master,
  502. @"sessionUser":userID,
  503. };
  504. NSString *url = [NSString stringWithFormat:@"%@plm/task/addbilltask.action",ip];
  505. url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  506. [[UASNetworkManager shareManager]request:url method:POST parameters:dic11 progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
  507. DLog(@"chenggong---:%@",responseObject);
  508. } failure:^(NSURLSessionDataTask *task, NSError *error) {
  509. ErrorInfomation
  510. }];
  511. }
  512. #pragma mark 获取会议编号
  513. - (void)sethuiyiMrCode
  514. {
  515. NSString *sessionId=[[NSUserDefaults standardUserDefaults] stringForKey:@"sessionId"];
  516. NSString *ip=[UASUserInfo shareManager].urlIp;
  517. NSString *emcode = [[NSUserDefaults standardUserDefaults] objectForKey:@"erpaccount"];
  518. int pageSize = 30;
  519. int page = 1;
  520. NSString *url = [NSString stringWithFormat:@"%@/mobile/common/list.action?master=%@&sessionUser=%@&emcode=%@&pageSize=%d&condition=mr_statuscode='AUDITED'&caller=MeetingRoom&page=%d&currentMaster=%@&sessionId=%@",ip,g_master,g_sessionUser,emcode,pageSize,page,g_master,sessionId];
  521. DLog(@"aaaaaaaa==:%@",url);
  522. url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  523. UASNetworkManager *manager = [UASNetworkManager shareManager];
  524. manager.responseSerializer = [AFJSONResponseSerializer serializer];
  525. //拼接sessionID
  526. NSString *paramSessionId=[@"" stringByAppendingFormat:@"JSESSIONID=%@",sessionId];
  527. //设置cookie
  528. [manager.requestSerializer setValue:paramSessionId forHTTPHeaderField:@"Cookie"];
  529. [manager.requestSerializer setValue:[NSString stringWithFormat:@"%@",g_sessionUser] forHTTPHeaderField:@"sessionUser"];
  530. [manager request:url method:POST parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
  531. NSString * sessionId = [NSString stringWithFormat:@"%@",responseObject[@"sessionId"]];
  532. if (![sessionId isEqualToString:@"(null)"]) {
  533. [[NSUserDefaults standardUserDefaults] setObject:sessionId forKey:@"sessionId"];
  534. }
  535. SLog(@"=====%@",responseObject[@"listdata"]);
  536. NSArray *arr = responseObject[@"listdata"];
  537. for (NSDictionary *dic in arr) {
  538. if ([dic[@"mr_name"] isEqualToString:_huiyiAddress.text]) {
  539. _Str = [NSString stringWithFormat:@"%@",dic[@"mr_code"]];
  540. SLog(@"======%@",_Str);
  541. }
  542. }
  543. } failure:^(NSURLSessionDataTask *task, NSError *error) {
  544. [((AppDelegate*)[[UIApplication sharedApplication] delegate]) showAlert:Localized(@"UU_work_OA_MM_CreateMeeting_title5")];
  545. SLog(@"请求失败:%@",error);
  546. }];
  547. }
  548. #pragma mark 上传会议 数据
  549. //上传会议
  550. - (void)postDataToServerWith:(NSString *)code andWithMa_id:(NSString *)maid
  551. {
  552. //1,创建一个网络请求管理对象
  553. UASNetworkManager *manager = [UASNetworkManager shareManager];
  554. manager.responseSerializer = [AFJSONResponseSerializer serializer];
  555. //2,取出sessionID和IP
  556. NSUserDefaults *userDefault=[NSUserDefaults standardUserDefaults];
  557. NSString *sessionId=[userDefault stringForKey:@"sessionId"];
  558. NSString * ips=[UASUserInfo shareManager].urlIp;
  559. NSString * userID = [userDefault objectForKey:@"erpaccount"];
  560. DLog(@"%@",_Str);
  561. NSString *master=[[[NSUserDefaults standardUserDefaults] objectForKey:@"masterDic"]objectForKey:@"ma_user"];
  562. //3.拼接sessionID
  563. NSString *paramSessionId=[@"" stringByAppendingFormat:@"JSESSIONID=%@",sessionId];
  564. //4.设置cookie
  565. [manager.requestSerializer setValue:paramSessionId forHTTPHeaderField:@"Cookie"];
  566. //5,接口
  567. NSString * urlAddress=@"oa/meeting/saveMeetingroomapply.action";
  568. //6,Caller
  569. NSString * caller=@"Meetingroomapply";//MeetingroomapplyDetail //Meetingroomapply
  570. //当前时间
  571. NSDateFormatter * formatter=[[NSDateFormatter alloc]init];
  572. [formatter setDateFormat:@"yyyy-MM-dd hh:mm:ss"];
  573. NSDate * date=[NSDate date];
  574. NSString * currentTime=[formatter stringFromDate:date];
  575. DLog(@"当前时间是%@",currentTime);
  576. /**
  577. 会议开始和结束时间处理
  578. */
  579. DLog(@"开始时间%@ 结束时间%@",_beginTime.text,_closeTime.text);
  580. //7,字段组合
  581. NSDictionary *formStore = @{
  582. @"ma_code":FORMAT(@"%@",code),
  583. @"ma_mrcode":FORMAT(@"%@",_Str),
  584. @"ma_mrname":FORMAT(@"%@",_huiyiAddress.text),
  585. @"ma_theme":FORMAT(@"%@",_huiyiName.text),
  586. @"ma_status":FORMAT(@"%@",@"已提交"),
  587. @"ma_recorder":FORMAT(@"%@",[[NSUserDefaults standardUserDefaults] stringForKey:@"personName"]),
  588. @"ma_recorddate":FORMAT(@"%@",currentTime),
  589. @"ma_starttime":FORMAT(@"%@",_beginTime.text),
  590. @"ma_isturndoc":FORMAT(@"%@",@"否"),
  591. @"ma_tag":FORMAT(@"%@",_huiyiLabel.text),
  592. @"ma_remark":FORMAT(@"%@",_huiyijiesao.text),
  593. @"ma_group":FORMAT(@"%@",_canhui.text),
  594. @"ma_groupid":FORMAT(@"%@",_canhuiImId),
  595. @"ma_endtime":FORMAT(@"%@",_closeTime.text),
  596. @"ma_statuscode":FORMAT(@"%@",@"ENTERING"),
  597. @"ma_id":FORMAT(@"%@",maid),
  598. };
  599. DLog(@" ==%@",formStore);
  600. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:formStore options:NSJSONWritingPrettyPrinted error:nil];
  601. NSString *dataStr=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  602. NSDictionary * dic11 = @{
  603. @"caller":caller,
  604. @"sessionId":sessionId,
  605. @"master":master,
  606. @"sessionUser":userID,
  607. @"param":@"[]",
  608. @"formStore":dataStr,
  609. };
  610. DLog(@"%@",dic11);
  611. NSString *url=[@"" stringByAppendingFormat:@"%@%@",ips,urlAddress];
  612. DLog(@"新建会议URL=%@",url);
  613. NSString * urlStringUTF8 = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  614. //发送请求
  615. [manager request:urlStringUTF8 method:POST parameters:dic11 progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
  616. NSDictionary *rootDic = responseObject;
  617. DLog(@"请求参会人员成功:%@",rootDic);
  618. if ([[rootDic allKeys] containsObject:@"sessionId"]==YES)
  619. {
  620. NSString * sessionId=[NSString stringWithFormat:@"%@",[rootDic objectForKey:@"sessionId"]];
  621. [[NSUserDefaults standardUserDefaults] setObject:sessionId forKey:@"sessionId"];
  622. }
  623. [self applyHuiyishi:maid];
  624. [MBProgressHUD showSuccess:Localized(@"UU_work_OA_MM_CreateMeeting_CreateSuccess")];
  625. // [self.navigationController popViewControllerAnimated:YES];
  626. _uploadBtn.selected = NO;
  627. JOHYTableViewController * vc=[[JOHYTableViewController alloc]init];
  628. vc.popStr = @"Commit";//提交后跳转
  629. [self.navigationController pushViewController:vc animated:YES];
  630. } failure:^(NSURLSessionDataTask *task, NSError *error) {
  631. _uploadBtn.selected = NO;
  632. DLog(@"失败%@",error);
  633. ErrorInfomation
  634. // [self.navigationController popViewControllerAnimated:YES];
  635. }];
  636. }
  637. - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  638. {
  639. if (buttonIndex==1)
  640. {
  641. [MBProgressHUD showSuccess:Localized(@"UU_work_OA_MM_CreateMeeting_CreateSuccess")];
  642. [self dismissViewControllerAnimated:YES completion:nil];
  643. }else{
  644. [MBProgressHUD showSuccess:Localized(@"UU_work_OA_MM_CreateMeeting_CreateSuccess")];
  645. [self dismissViewControllerAnimated:YES completion:nil];
  646. }
  647. }
  648. - (void)swicthOn:(id)sender
  649. {
  650. UISwitch *switchButton = (UISwitch*)sender;
  651. if (switchButton.isOn==YES)
  652. {
  653. yaobuyaoricheng=2;
  654. }else
  655. {
  656. yaobuyaoricheng=1;
  657. }
  658. }
  659. #pragma mark - Table view data source
  660. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  661. return numOfSection.count;
  662. }
  663. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  664. NSArray *subArr = numOfSection[section];
  665. return subArr.count;
  666. }
  667. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  668. {
  669. return 40;
  670. }
  671. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  672. {
  673. if (section==0)
  674. {
  675. return 0;
  676. }else{
  677. return 10;
  678. }
  679. }
  680. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  681. return section == numOfSection.count-1? 120:0;
  682. }
  683. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  684. //1.cell初始化
  685. static NSString *identifier = @"cell";
  686. HYcell * cell=[[HYcell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  687. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  688. cell.backgroundColor=[UIColor whiteColor];
  689. if (indexPath.section==3)
  690. {
  691. UILabel * label=[[UILabel alloc]init];
  692. label.textColor=UNblack;
  693. label.text=numOfSection[indexPath.section][indexPath.row];
  694. label.frame=CGRectMake(10,5,200,30);
  695. label.textAlignment=0;
  696. label.font=FONT_SIZE(14);
  697. [cell addSubview:label];
  698. _rcSwitch=[[UISwitch alloc]init];
  699. _rcSwitch.frame=CGRectMake(self_width-70,5,60,30);
  700. _rcSwitch.on=YES;
  701. _rcSwitch.onTintColor= Color(76,217,100,1.0);
  702. [_rcSwitch addTarget:self action:@selector(swicthOn:) forControlEvents:UIControlEventValueChanged];
  703. [cell addSubview:_rcSwitch];
  704. yaobuyaoricheng=2;//默认为2
  705. }
  706. else
  707. {
  708. NSString *titleName = FORMAT(@"%@",numOfSection[indexPath.section][indexPath.row]);
  709. NSMutableAttributedString *AttributedStr ;
  710. if (indexPath.section==0||(indexPath.section==1&&indexPath.row==0)) {
  711. AttributedStr = [[NSMutableAttributedString alloc]initWithString:FORMAT(@"%@*",titleName)];
  712. [AttributedStr addAttribute:NSForegroundColorAttributeName
  713. value:[UIColor redColor]
  714. range:NSMakeRange(titleName.length, 1)];
  715. }else{
  716. AttributedStr = [[NSMutableAttributedString alloc]initWithString:FORMAT(@"%@",titleName)];
  717. }
  718. cell.nameString=AttributedStr ;
  719. [cell setModel];
  720. }
  721. #pragma mark----------------------------
  722. if (indexPath.section==0&&indexPath.row==0)
  723. {
  724. [cell.contentView addSubview:_huiyiName];
  725. [self initMyButton:cell andIndexPath:indexPath];
  726. }
  727. else if (indexPath.section==0&&indexPath.row==1)
  728. {
  729. UIButton * beginBtn=[UIButton buttonWithType:UIButtonTypeCustom];
  730. beginBtn.frame=CGRectMake(0, 0,self_width,40);
  731. beginBtn.tag = 10000;
  732. [beginBtn addTarget:self action:@selector(beginBtn:) forControlEvents:UIControlEventTouchUpInside];
  733. [cell.contentView addSubview:beginBtn];
  734. [cell.contentView addSubview:_beginTime];
  735. }
  736. else if (indexPath.section==0&&indexPath.row==2)
  737. {
  738. UIButton * closeBtn=[UIButton buttonWithType:UIButtonTypeCustom];
  739. closeBtn.frame=CGRectMake(0, 0,self_width,40);
  740. closeBtn.tag = 10001;
  741. [closeBtn addTarget:self action:@selector(closeBtn:) forControlEvents:UIControlEventTouchUpInside];
  742. [cell.contentView addSubview:closeBtn];
  743. [cell.contentView addSubview:_closeTime];
  744. }
  745. else if (indexPath.section==0&&indexPath.row==3)
  746. {
  747. [cell.contentView addSubview:_huiyiAddress];
  748. UIButton * addressBtn=[UIButton buttonWithType:UIButtonTypeCustom];
  749. addressBtn.frame=CGRectMake(0,0,self_width,30);
  750. [addressBtn setTitle:@"" forState:UIControlStateNormal];
  751. [addressBtn addTarget:self action:@selector(gotoGETAddress) forControlEvents:UIControlEventTouchUpInside];
  752. [cell.contentView addSubview:addressBtn];
  753. }else if (indexPath.section==2&&indexPath.row==1)
  754. {
  755. [cell.contentView addSubview:_huiyijiesao];
  756. [self initMyButton:cell andIndexPath:indexPath];
  757. }else if (indexPath.section==1&&indexPath.row==0)
  758. {
  759. UIButton * closeBtn=[UIButton buttonWithType:UIButtonTypeCustom];
  760. closeBtn.frame=CGRectMake(0, 0,self_width,40);
  761. [closeBtn addTarget:self action:@selector(chooesName) forControlEvents:UIControlEventTouchUpInside];
  762. [cell.contentView addSubview:closeBtn];
  763. [cell.contentView addSubview:_canhui];
  764. }
  765. else if (indexPath.section==1&&indexPath.row==1)//会议管理员
  766. {
  767. UILabel * label=[[UILabel alloc]init];
  768. label.frame=CGRectMake(100,5,SCREEN_WIDTH-135,30);
  769. label.text=[[NSUserDefaults standardUserDefaults] stringForKey:@"personName"];
  770. label.textAlignment = NSTextAlignmentRight;
  771. label.font=FONT_SIZE(14);
  772. [cell.contentView addSubview:label];
  773. }else if (indexPath.section==2&&indexPath.row==0)
  774. {
  775. // UIButton * closeBtn=[UIButton buttonWithType:UIButtonTypeCustom];
  776. // closeBtn.frame=CGRectMake(0, 0,self_width,40);
  777. // [closeBtn addTarget:self action:@selector(huiyibiaoqian:) forControlEvents:UIControlEventTouchUpInside];
  778. // closeBtn.tag=11111;
  779. [cell.contentView addSubview:_huiyiLabel];
  780. // [cell.contentView addSubview:closeBtn];
  781. UIButton * LabelBtn=[UIButton buttonWithType:UIButtonTypeCustom];
  782. LabelBtn.frame = CGRectMake(0,0,self_width,30);
  783. [LabelBtn setTitle:@"" forState:UIControlStateNormal];
  784. [LabelBtn addTarget:self action:@selector(gotoGETLabel) forControlEvents:UIControlEventTouchUpInside];
  785. [cell.contentView addSubview:LabelBtn];
  786. }
  787. return cell;
  788. }
  789. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  790. {
  791. UIView * view=[[UIView alloc]init];
  792. if (section==0)
  793. {
  794. }else{
  795. view.frame=CGRectMake(0,0,self_width,10);
  796. view.backgroundColor=[UIColor clearColor];
  797. }
  798. return view;
  799. }
  800. -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
  801. UIView *footerView = [[UIView alloc] init];
  802. footerView.userInteractionEnabled = YES;
  803. footerView.backgroundColor = [UIColor clearColor];
  804. _uploadBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  805. _uploadBtn.frame = CGRectMake(20,40, self_width-40, 40);
  806. _uploadBtn.layer.cornerRadius = 5;
  807. _uploadBtn.layer.masksToBounds = YES;
  808. [_uploadBtn addTarget:self action:@selector(preserve:) forControlEvents:UIControlEventTouchUpInside];
  809. [_uploadBtn setBackgroundColor:HexColor(@"#33A2EE") forState:UIControlStateNormal];
  810. [_uploadBtn setBackgroundColor:HexColor(@"#2D84C0") forState:UIControlStateHighlighted];
  811. [_uploadBtn setTitleColor:HexColor(@"#FFFFFF") forState:UIControlStateNormal];
  812. [_uploadBtn setTitle:@"提交" forState:UIControlStateNormal];
  813. _uploadBtn.titleLabel.font = FONT_SIZE(18);
  814. [footerView addSubview:_uploadBtn];
  815. return section==(numOfSection.count-1)? footerView:nil;
  816. }
  817. //会议标签选择
  818. - (void)huiyibiaoqian:(UIButton *)btn
  819. {
  820. if ([[[UIDevice currentDevice] systemVersion] floatValue]<8.0)
  821. {
  822. [((AppDelegate*)[[UIApplication sharedApplication] delegate]) showAlertController:self withMessage:Localized(@"UU_custom_iphoneLow")];
  823. btn.userInteractionEnabled=NO;
  824. _huiyiLabel.userInteractionEnabled=YES;
  825. return;
  826. }
  827. UIAlertController * alertController = [UIAlertController alertControllerWithTitle: nil message: nil preferredStyle:UIAlertControllerStyleActionSheet];
  828. UIButton * Btn=[self.view viewWithTag:btn.tag];
  829. //添加Button
  830. [alertController addAction: [UIAlertAction actionWithTitle: Localized(@"UU_work_OA_MM_CreateMeeting_TrainMeeting") style: UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  831. _huiyiLabel.text=Localized(@"UU_work_OA_MM_CreateMeeting_TrainMeeting");
  832. }]];
  833. [alertController addAction: [UIAlertAction actionWithTitle: Localized(@"UU_work_OA_MM_CreateMeeting_departmentMeeting") style: UIAlertActionStyleDefault handler:^(UIAlertAction *action){
  834. _huiyiLabel.text=Localized(@"UU_work_OA_MM_CreateMeeting_departmentMeeting");
  835. }]];
  836. [alertController addAction: [UIAlertAction actionWithTitle: Localized(@"UU_work_OA_MM_CreateMeeting_monthMeeting") style: UIAlertActionStyleDefault handler:^(UIAlertAction *action){
  837. _huiyiLabel.text=Localized(@"UU_work_OA_MM_CreateMeeting_monthMeeting");
  838. }]];
  839. [alertController addAction: [UIAlertAction actionWithTitle: Localized(@"UU_work_OA_MM_CreateMeeting_weekMeeting") style: UIAlertActionStyleDefault handler:^(UIAlertAction *action){
  840. _huiyiLabel.text=Localized(@"UU_work_OA_MM_CreateMeeting_weekMeeting");
  841. }]];
  842. [alertController addAction: [UIAlertAction actionWithTitle: Localized(@"UU_work_OA_MM_CreateMeeting_custom") style: UIAlertActionStyleDefault handler:^(UIAlertAction *action){
  843. _huiyiLabel.userInteractionEnabled=YES;
  844. if (btn.tag==11111)
  845. {
  846. Btn.userInteractionEnabled=NO;
  847. _huiyiLabel.placeholder=Localized(@"UU_custom_pleaseInput");
  848. _huiyiLabel.text=@"";
  849. }
  850. }]];
  851. [alertController addAction: [UIAlertAction actionWithTitle: Localized(@"UU_custom_cancle") style: UIAlertActionStyleCancel handler:nil]];
  852. [self presentViewController: alertController animated: YES completion: nil];
  853. }
  854. - (void)gotoGETLabel
  855. {
  856. JOGETLabelTableViewController * vc=[[JOGETLabelTableViewController alloc]init];
  857. // vc.naviColor= Color(215,145,71,1.0);
  858. JONavigationController * navi = [[JONavigationController alloc]initWithRootViewController:vc];
  859. [self presentViewController:navi animated:YES completion:^{
  860. [vc backLabelName:^(NSString *lableName) {
  861. _huiyiLabel.text=lableName;
  862. }];
  863. }];
  864. }
  865. - (void)gotoGETAddress
  866. {
  867. JOGETAddressTableViewController * vc=[[JOGETAddressTableViewController alloc]init];
  868. vc.naviColor= Color(215,145,71,1.0);
  869. UASBasNavController * navi=[[UASBasNavController alloc]initWithRootViewController:vc];
  870. [self presentViewController:navi animated:YES completion:^{
  871. [vc backAddressName:^(NSString *addressName,NSString * addressId){
  872. DLog(@"会议室:%@ 会议室ID:%@",addressName,addressId);
  873. _huiyiAddress.text=addressName;
  874. }];
  875. }];
  876. }
  877. #pragma mark -- 会议室
  878. - (void)applyHuiyishi:(NSString *)addressId
  879. {
  880. //1,创建一个网络请求管理对象
  881. UASNetworkManager *manager1=[UASNetworkManager shareManager];
  882. manager1.responseSerializer=[AFHTTPResponseSerializer serializer];
  883. //2,取出sessionID和IP
  884. NSUserDefaults *userDefault=[NSUserDefaults standardUserDefaults];
  885. NSString *sessionId=[userDefault stringForKey:@"sessionId"];
  886. NSString * ips=[UASUserInfo shareManager].urlIp;
  887. NSString * userID=[[NSUserDefaults standardUserDefaults] objectForKey:@"erpaccount"];
  888. NSString *master=[[[NSUserDefaults standardUserDefaults] objectForKey:@"masterDic"]objectForKey:@"ma_user"];
  889. /*
  890. 会议室申请,保存后触犯审批流接口
  891. 地址:/oa/meeting/submitMeetingroomapply.action
  892. 参数:caller,id
  893. */
  894. //3.拼接sessionID
  895. NSString *paramSessionId=[@"" stringByAppendingFormat:@"JSESSIONID=%@",sessionId];
  896. //4.设置cookie
  897. [manager1.requestSerializer setValue:paramSessionId forHTTPHeaderField:@"Cookie"];
  898. //5,接口
  899. NSString * urlAddress1 = @"oa/meeting/submitMeetingroomapply.action";
  900. //6,Caller
  901. NSString * caller1 = @"Meetingroomapply";
  902. //url
  903. NSString * url2 = [@"" stringByAppendingFormat:@"%@%@?id=%@&caller=%@&master=%@&sessionUser=%@",ips,urlAddress1,addressId,caller1,master,userID];
  904. DLog(@"url==%@",url2);
  905. [manager1 request:url2 method:GET parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
  906. NSData *data=responseObject;
  907. id rootDic =[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
  908. //DLog(@"请求成功");
  909. // DLog(@"返回的是什么鬼:%@",rootDic);
  910. DLog(@"申请成功啦:%@",rootDic);
  911. } failure:^(NSURLSessionDataTask *task, NSError *error) {
  912. [((AppDelegate*)[[UIApplication sharedApplication] delegate]) showAlert:@"会议室审批申请失败"];
  913. NSData *returnData = [[error userInfo] objectForKey:@"com.alamofire.serialization.response.error.data"];
  914. if (returnData) {
  915. NSDictionary *content = [NSJSONSerialization JSONObjectWithData:returnData options:NSJSONReadingMutableContainers error:nil];//转换数据格式
  916. NSString *errorStr = [NSString stringWithFormat:@"%@",[content objectForKey:@"exceptionInfo"]];
  917. DLog(@"错误信息是:%@",errorStr);
  918. }
  919. [self dismissViewControllerAnimated:YES completion:nil];
  920. }];
  921. }
  922. //获取返回的参会成员
  923. - (void)chooesName
  924. {
  925. JOGETNameTableViewController * vc=[[JOGETNameTableViewController alloc]init];
  926. vc.naviColor= Color(215,145,71,1.0);
  927. vc.naviTitle=Localized(@"UU_work_OA_MM_CreateMeeting_PleaseSelectParticipants");
  928. JONavigationController * navi=[[JONavigationController alloc]initWithRootViewController:vc];
  929. [self presentViewController:navi animated:YES completion:^{
  930. [vc backname:^(NSMutableArray *arr,NSMutableArray * brr) {
  931. DLog(@"拿回来的是人名嘛%@",arr);
  932. DLog(@"拉回来的事ID吗%@",brr);
  933. if (arr.count>=1)
  934. {
  935. NSString * str=@"";
  936. NSString * str2=@"";
  937. for (int i=0; i<arr.count; i++)
  938. {
  939. str=[[str stringByAppendingString:@","] stringByAppendingString:arr[i]];
  940. str2=[[str2 stringByAppendingString:@";employee#"] stringByAppendingString:brr[i]];
  941. }
  942. str=[str substringFromIndex:1];
  943. str2=[str2 substringFromIndex:1];
  944. _canhui.text=str;
  945. _canhui.textColor=balckColor;
  946. _canhuiImId=str2;
  947. DLog(@"处理过后呢%@",_canhuiImId);
  948. }else if (arr.count==1){
  949. _canhui.text=arr[0];
  950. _canhui.textColor=balckColor;
  951. _canhuiImId=brr[0];
  952. }
  953. }];
  954. }];
  955. }
  956. - (void)beginBtn:(UIButton *)btn
  957. {
  958. /*_dayPickerViewController01 = [[ZQDayPickerViewController alloc] initWithNibName:NSStringFromClass([ZQDayPickerViewController class]) bundle:nil];
  959. _dayPickerViewController01.selectedColor = [UIColor blackColor];
  960. _dayPickerViewController01.hintTitle = Localized(@"UU_custom_pleaseSelect");
  961. _dayPickerViewController01.delegate = self;
  962. [self presentViewController:_dayPickerViewController01 animated:YES completion:nil];*/
  963. YPCalendarVC *ypVC = [[YPCalendarVC alloc]init];
  964. ypVC.caller = @"NewMeeting";
  965. ypVC.kaishiTime = _beginTime.text;
  966. ypVC.jieshuTime = _closeTime.text;
  967. ypVC.block = ^(NSString *start,NSString *end) {
  968. DLog(@"返回什么东西:%@--%@",start,end);
  969. _beginTime.text = start;
  970. _closeTime.text = end;
  971. };
  972. [self.navigationController pushViewController:ypVC animated:YES];
  973. }
  974. - (void)closeBtn:(UIButton * )btn
  975. {
  976. // if ([_beginTime.text isEqualToString:@"请选择"])
  977. // {
  978. // [((AppDelegate*)[[UIApplication sharedApplication] delegate]) showAlertController:self withMessage:@"请先选择开始时间"];
  979. // return ;
  980. // }
  981. /*_dayPickerViewController02 = [[ZQDayPickerViewController alloc] initWithNibName:NSStringFromClass([ZQDayPickerViewController class]) bundle:nil];
  982. _dayPickerViewController02.selectedColor = [UIColor blackColor];
  983. _dayPickerViewController02.hintTitle = Localized(@"UU_custom_pleaseSelect");
  984. _dayPickerViewController02.delegate = self;
  985. [self presentViewController:_dayPickerViewController02 animated:YES completion:nil];*/
  986. YPCalendarVC *ypVC = [[YPCalendarVC alloc]init];
  987. ypVC.caller = @"NewMeeting";
  988. ypVC.kaishiTime = _beginTime.text;
  989. ypVC.jieshuTime = _closeTime.text;
  990. ypVC.selectDay = @"end";
  991. ypVC.block = ^(NSString *start,NSString *end) {
  992. DLog(@"返回什么东西:%@--%@",start,end);
  993. _beginTime.text = start;
  994. _closeTime.text = end;
  995. };
  996. [self.navigationController pushViewController:ypVC animated:YES];
  997. }
  998. //获取时间
  999. - (void)dayPickerViewControllerChoosedDate:(ZQDayPickerViewController *)dayPickerViewController
  1000. {
  1001. NSString * str = [self dateStringFromDate:dayPickerViewController.date];
  1002. if (dayPickerViewController==_dayPickerViewController01)
  1003. {
  1004. if ([self compareDate:_closeTime.text withDate:str]==1||[self compareDate:_closeTime.text withDate:str]==0)
  1005. {
  1006. [((AppDelegate*)[[UIApplication sharedApplication] delegate]) showAlert:Localized(@"UU_work_OA_MM_CreateMeeting_PleaseSelectStartTimeLessThanEndTime")];
  1007. return;
  1008. }
  1009. _beginTime.text=str;
  1010. //_beginTime.textColor=balckColor;
  1011. }
  1012. else if (dayPickerViewController==_dayPickerViewController02)
  1013. {
  1014. if ([self compareDate:_beginTime.text withDate:str]==-1||[self compareDate:_beginTime.text withDate:str]==0)
  1015. {
  1016. [((AppDelegate*)[[UIApplication sharedApplication] delegate]) showAlert:Localized(@"UU_work_OA_MM_CreateMeeting_PleaseSelectEndTimeGreaterThanStartTime")];
  1017. return;
  1018. }
  1019. _closeTime.text=str;
  1020. // _closeTime.textColor=balckColor;
  1021. }
  1022. }
  1023. - (int)compareDate:(NSString*)date01 withDate:(NSString*)date02
  1024. {
  1025. int ci;
  1026. NSDateFormatter *df = [[NSDateFormatter alloc] init];
  1027. [df setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
  1028. NSDate *dt1 = [[NSDate alloc] init];
  1029. NSDate *dt2 = [[NSDate alloc] init];
  1030. dt1 = [df dateFromString:date01];
  1031. dt2 = [df dateFromString:date02];
  1032. NSComparisonResult result = [dt1 compare:dt2];
  1033. switch (result)
  1034. {
  1035. //date02比date01大
  1036. case NSOrderedAscending: ci=1; break;
  1037. //date02比date01小
  1038. case NSOrderedDescending: ci=-1; break;
  1039. //date02=date01
  1040. case NSOrderedSame: ci=0; break;
  1041. default: DLog(@"erorr dates %@, %@", dt2, dt1); break;
  1042. }
  1043. return ci;
  1044. }
  1045. //设置返回时间的格式
  1046. - (NSString *)dateStringFromDate:(NSDate *)date
  1047. {
  1048. NSDateFormatter *formatter = [NSDateFormatter new];
  1049. formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss";
  1050. return [formatter stringFromDate:date];
  1051. }
  1052. /**去掉分割线*/
  1053. - (void)setExtraCellLineHidden: (UITableView *)tableView
  1054. {
  1055. UIView *view = [UIView new];
  1056. view.backgroundColor = [UIColor clearColor];
  1057. [tableView setTableFooterView:view];
  1058. }
  1059. - (void)textFieldDidEndEditing:(UITextField *)textField
  1060. {
  1061. if (textField==_huiyiLabel||textField==_huiyijiesao)
  1062. {
  1063. _tableView.y=0;
  1064. }
  1065. }
  1066. - (void)textFieldDidBeginEditing:(UITextField *)textField
  1067. {
  1068. if (textField==_huiyiLabel||textField==_huiyijiesao)
  1069. {
  1070. _tableView.y=-130;
  1071. }
  1072. }
  1073. - (void)textFiledEditChanged:(NSNotification *)obj
  1074. {
  1075. UITextField *textField = (UITextField *)obj.object;
  1076. DLog(@"%@",textField.text);
  1077. NSString *toBeString = textField.text;
  1078. if (textField==_huiyiName)
  1079. {
  1080. if (toBeString.length > 17)
  1081. {
  1082. textField.text = [toBeString substringToIndex:17];
  1083. [self.view endEditing: YES];
  1084. [KPromptBox showKPromptBoxWithMassage:Localized(@"UU_work_OA_MM_CreateMeeting_title6")];
  1085. }
  1086. }
  1087. else if (textField==_huiyiAddress )
  1088. {
  1089. if (toBeString.length > 17)
  1090. {
  1091. textField.text = [toBeString substringToIndex:17];
  1092. [self.view endEditing: YES];
  1093. [KPromptBox showKPromptBoxWithMassage:Localized(@"UU_work_OA_MM_CreateMeeting_title6")];
  1094. }
  1095. }
  1096. else if (textField==_huiyiLabel)
  1097. {
  1098. if (toBeString.length > 17)
  1099. {
  1100. textField.text = [toBeString substringToIndex:17];
  1101. [self.view endEditing: YES];
  1102. [KPromptBox showKPromptBoxWithMassage:Localized(@"UU_work_OA_MM_CreateMeeting_title6")];
  1103. }
  1104. }
  1105. else if (textField==_huiyijiesao)
  1106. {
  1107. if (toBeString.length > 17)
  1108. {
  1109. textField.text = [toBeString substringToIndex:17];
  1110. [self.view endEditing: YES];
  1111. [KPromptBox showKPromptBoxWithMassage:Localized(@"UU_work_OA_MM_CreateMeeting_title6")];
  1112. }
  1113. }
  1114. }
  1115. -(void)viewWillAppear:(BOOL)animated{
  1116. [[NSNotificationCenter defaultCenter] postNotificationName:@"hiddenTabBar"object:nil];
  1117. }
  1118. @end