NewReceiptViewController.m 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305
  1. // NewReceiptViewController.m
  2. // IOBSS 2.0
  3. //
  4. // Created by 刘瀚璘 on 2017.7.14
  5. // Copyright 2017 沈阳东科云信软件有限公司. All rights reserved.
  6. //
  7. // 系统名称:
  8. // 功能描述:新增定制品回执页面
  9. #import "NewReceiptViewController.h"
  10. #import "CustomButton.h"
  11. #import "DKPhotoAssets.h"
  12. #import "DKUICollectionViewCell.h"
  13. #import "DKPhotoPickerBrowserViewController.h"
  14. #import "DKPhotoPickerViewController.h"
  15. #import "ReceiptDetailViewController.h"
  16. #import "NewCustomReceiptCell.h"
  17. #import "NewCustomerModel.h"
  18. //#import "MapViewController.h"
  19. #import "StatusInfo.h"
  20. #import "StatusInfoTextVC.h"
  21. #import "SettlementTypeVC.h"
  22. #import "LeslieAsyncImageDownloader.h"
  23. @interface NewReceiptViewController () <UITextFieldDelegate,DKPhotoPickerBrowserViewControllerDelegate,DKPhotoPickerBrowserViewControllerDataSource,DKPhotoPickerViewControllerDelegate,UITableViewDelegate,StatusInfoTextDelegate,SettlementTypeProtocol,NewCustomReceiptCellDelegate,UITableViewDataSource,UICollectionViewDelegate,UICollectionViewDataSource,UIScrollViewDelegate> {
  24. /**
  25. UIScrollView
  26. */
  27. UIScrollView *_scrollView;
  28. /**
  29. UITableView
  30. */
  31. UITableView *_tableView;
  32. /**
  33. 回执金额
  34. */
  35. UITextField *_fieldReceiptAmount;
  36. /**
  37. 已回执金额
  38. */
  39. UILabel *_lblReceivedAmount;
  40. /**
  41. 客户名称
  42. */
  43. UILabel *_lblCustomerName;
  44. /**
  45. 电话
  46. */
  47. UILabel *_lblTelePhone;
  48. /**
  49. 收费金额
  50. */
  51. UILabel *_lblTollAmount;
  52. /**
  53. 位置
  54. */
  55. UILabel *_lblPosition;
  56. /**
  57. 拍照,相册,位置
  58. */
  59. UIView *_center;
  60. /**
  61. 线
  62. */
  63. UIView *_line;
  64. /**
  65. 位置
  66. */
  67. UIView *_positionImage;
  68. /**
  69. 结算方式
  70. */
  71. UIButton *_btnSettlement;
  72. /**
  73. 回执状态
  74. */
  75. UIButton *_btnReceiptStatus;
  76. /**
  77. 客户名称
  78. */
  79. NSString *_strCustomerName;
  80. /**
  81. 收费金额
  82. */
  83. NSString *_strTollAmount;
  84. /**
  85. 回执金额
  86. */
  87. NSString *_strReceiptedAmount;
  88. /**
  89. 已回执金额
  90. */
  91. NSString *_strReceivedAmount;
  92. /**
  93. 联系电话
  94. */
  95. NSString *_strTelephone;
  96. /**
  97. 回执状态ID
  98. */
  99. NSString *_statusID;
  100. /**
  101. 售前ID
  102. */
  103. NSString *_fixedID;
  104. /**
  105. 安排单号ID
  106. */
  107. NSString *_arrangementID;
  108. /**
  109. 结算方式ID
  110. */
  111. NSString *_settlementType;
  112. /**
  113. 用户ID
  114. */
  115. NSString *_strCustomerID;
  116. /**
  117. 上传参数
  118. */
  119. NSString *_strBusinessOrganization;
  120. /**
  121. 备注
  122. */
  123. NSString *_strRemarks;
  124. /**
  125. 业务员
  126. */
  127. NSString *_strSalesMan;
  128. /**
  129. 结算方式回调的备注
  130. */
  131. NSString *_listRemarks;
  132. /**
  133. 结算方式回调的参数
  134. */
  135. NSString *_strEarnestFee;
  136. /**
  137. 上传的图片
  138. */
  139. NSMutableArray *_arrImagePaths;
  140. /**
  141. 当前图片数
  142. */
  143. NSMutableArray *_assets;
  144. /**
  145. 回执状态
  146. */
  147. NSMutableArray *_arrayDStatus;
  148. /**
  149. 键盘弹起标识
  150. */
  151. BOOL _keyboardShow;
  152. /**
  153. 键盘弹起View是否执行动画
  154. */
  155. BOOL isCancelAnimation;
  156. }
  157. @end
  158. @implementation NewReceiptViewController
  159. #pragma mark - 公共函数
  160. - (void)viewDidLoad {
  161. [super viewDidLoad];
  162. [[NSNotificationCenter defaultCenter] addObserver:self
  163. selector:@selector(keyboardWillShow)
  164. name:UIKeyboardWillShowNotification
  165. object:nil];
  166. [[NSNotificationCenter defaultCenter] addObserver:self
  167. selector:@selector(keyboardWillHide)
  168. name:UIKeyboardWillHideNotification
  169. object:nil];
  170. [self initUI];
  171. [self loadUI];
  172. [self reloadData];
  173. }
  174. /**
  175. 安全区视图发生变化
  176. */
  177. -(void)viewSafeAreaInsetsDidChange{
  178. _scrollView.frame = CGRectMake(0, 0, SCREENWIDTH,self.view.safeAreaLayoutGuide.layoutFrame.size.height-44);
  179. _btnSave.frame=CGRectMake(20,self.view.safeAreaLayoutGuide.layoutFrame.size.height-44-15, Screen_Width-40,44) ;
  180. [super viewSafeAreaInsetsDidChange];
  181. }
  182. /**
  183. 销毁
  184. */
  185. - (void)dealloc {
  186. [[NSNotificationCenter defaultCenter] removeObserver:UIKeyboardWillShowNotification];
  187. [[NSNotificationCenter defaultCenter] removeObserver:UIKeyboardWillHideNotification];
  188. }
  189. /**
  190. 请求数据
  191. */
  192. - (void)reloadData{
  193. _dataArray = [[NSMutableArray alloc] init];
  194. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  195. [dict setObject:@"GetFixedForNewReceiptIphone" forKey:@"Action"];
  196. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  197. [dict setObject:kkUserCode forKey:@"UserCode"];
  198. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  199. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  200. [dict setObject:_fixedNo forKey:@"FixedNo"];
  201. _downManager = [[ASIDownManager alloc] init];
  202. _downManager.delegate = self;
  203. _downManager.onRequestSuccess = @selector(onLoadFinish:);
  204. _downManager.onRequestFail = @selector(onLoadFail:);
  205. [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
  206. }
  207. #pragma mark - 数据解析
  208. /**
  209. 请求成功
  210. @param sender <#sender description#>
  211. */
  212. - (void)onLoadFinish:(ASIDownManager *) sender{
  213. // 服务器返回数据
  214. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  215. // 服务器返回数据状态值
  216. int iStatus = resultModel.status;
  217. // 服务器返回数据消息
  218. NSString *message = resultModel.message;
  219. // 服务器返回数据状态值正确
  220. if (iStatus == 0) {
  221. // 服务器返回数据结果
  222. NSDictionary * dictionary = (NSDictionary *)resultModel.result;
  223. NSArray *table = [dictionary objectForKey:@"Table"];
  224. NSArray *table1 = [dictionary objectForKey:@"Table1"];
  225. if(table == nil ||table.count == 0){
  226. [self showAlertViewText:@"加载数据失败"];
  227. return;
  228. }
  229. BOOL receiptFlag = NO;
  230. for (int i = 0; i < table.count; i++) {
  231. NSDictionary *dic = table[i];
  232. receiptFlag = [[dic objectForKey:@"ReceiptFlag"] boolValue];
  233. if (receiptFlag) {
  234. break;
  235. }
  236. _strCustomerName = [dic objectForKey:@"CustomerName"];
  237. _strTollAmount = [NSString stringWithFormat:@"%.2f",[[dic objectForKey:@"Receivables"] doubleValue]] ;
  238. _strReceivedAmount = [NSString stringWithFormat:@"%.2f",[[dic objectForKey:@"ReceiptedAmount"] doubleValue]] ;
  239. _strReceiptedAmount = [NSString stringWithFormat:@"%.2f",[[dic objectForKey:@"ReceiptSum"] doubleValue]] ;
  240. _strTelephone = [dic objectForKey:@"Telephone"];
  241. _strSalesMan = [dic objectForKey:@"SalesMan"];
  242. _fieldReceiptAmount.text = _strReceiptedAmount;
  243. if(_strTelephone == nil){
  244. _strTelephone = @"";
  245. }
  246. _lblTelePhone.text = [NSString stringWithFormat:@"联系电话:%@",_strTelephone];
  247. _lblTollAmount.text = [NSString stringWithFormat:@"收费金额:%@",_strTollAmount];
  248. _lblReceivedAmount.text = [NSString stringWithFormat:@"已回执金额:%@",_strReceivedAmount];
  249. _lblCustomerName.text = [NSString stringWithFormat:@"客户名称:%@",_strCustomerName];
  250. _fixedID = [dic objectForKey:@"FixedID"];
  251. _arrangementID = [dic objectForKey:@"ArrangementID"];
  252. _strCustomerID = [dic objectForKey:@"CustomerID"];
  253. _strBusinessOrganization = [dic objectForKey:@"BusinessOrganization"];
  254. _strRemarks = [dic objectForKey:@"Remarks"];
  255. }
  256. if(receiptFlag){
  257. receiptFlag = NO;
  258. }
  259. if([_strTollAmount doubleValue]>0){
  260. _fieldReceiptAmount.enabled = YES;
  261. }else{
  262. _fieldReceiptAmount.enabled = NO;
  263. }
  264. for (int i = 0; i < table1.count; i++) {
  265. NSDictionary *dic = table1[i];
  266. NewCustomerModel *model = [NewCustomerModel dk_modelWithDictionary:dic];
  267. [_dataArray addObject:model] ;
  268. }
  269. [self reloadTableViewHeight:_dataArray];
  270. [_tableView reloadData];
  271. }else if(iStatus == ActionResultStatusAuthError
  272. ||iStatus == ActionResultStatusNoLogin
  273. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
  274. [self showReLoginDialog:message];
  275. return;
  276. }else {
  277. // [[UserInfoManager Share] ClearUserData];
  278. [self showAlertViewText:message];
  279. return;
  280. }
  281. }
  282. /**
  283. 请求失败
  284. @param sender
  285. */
  286. - (void)onLoadFail:(ASIDownManager *) sender{
  287. [self stopLoading];
  288. }
  289. /**
  290. 保存成功
  291. @param sender
  292. */
  293. - (void)onSaveFinish: (ASIDownManager *)sender {
  294. [self stopLoading];
  295. // 服务器返回数据
  296. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  297. // 服务器返回数据状态值
  298. int status = resultModel.status;
  299. // 服务器返回数据消息
  300. NSString *message = resultModel.message;
  301. // 服务器返回数据状态值正确
  302. if(status == 0){
  303. [self showAlertViewText:@"保存成功"];
  304. }else if(status == ActionResultStatusAuthError
  305. ||status == ActionResultStatusNoLogin
  306. ||status == ActionResultStatusLogined||status==ActionResultSessionOverdue){
  307. [self showReLoginDialog:message];
  308. return;
  309. }
  310. else {
  311. [self showAlertViewText:message];
  312. return;
  313. }
  314. }
  315. /**
  316. 保存失败
  317. @param sender
  318. */
  319. - (void)onSaveFail: (ASIDownManager *)sender{
  320. [self stopLoading];
  321. }
  322. /**
  323. 保存退出
  324. @param text
  325. */
  326. - (void) showAlertViewText:(NSString *)text{
  327. UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:text preferredStyle:UIAlertControllerStyleAlert ];
  328. [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
  329. if([text isEqualToString:@"保存成功"]){
  330. [_noReceiptVC popViewReLoadData];
  331. }
  332. [self.navigationController popViewControllerAnimated:true];
  333. }]];
  334. [self presentViewController:alert animated:YES completion:nil];
  335. }
  336. #pragma mark - 事件
  337. /**
  338. 回执类型
  339. @param btn
  340. */
  341. - (void)showReceiptType:(UIButton *)btn{
  342. self.hidesBottomBarWhenPushed=YES;
  343. [self initStatus];
  344. StatusInfoTextVC *tc = [[StatusInfoTextVC alloc] init];
  345. tc.sdelegate = self;
  346. [tc.arrFilter addObjectsFromArray: _arrayDStatus];
  347. [self.navigationController pushViewController:tc animated:YES];
  348. self.hidesBottomBarWhenPushed=NO;
  349. }
  350. /**
  351. 结算方式
  352. @param btn
  353. */
  354. - (void)showSettlement:(UIButton *) btn{
  355. if ([_strTollAmount isEqualToString:@""]
  356. || [_strTollAmount doubleValue]== 0) {
  357. return;
  358. }
  359. [self.view endEditing:YES];
  360. self.hidesBottomBarWhenPushed = YES;
  361. SettlementTypeVC *tc = [[SettlementTypeVC alloc] init];
  362. tc.sDelegate = self;
  363. [self.navigationController pushViewController:tc animated:YES];
  364. self.hidesBottomBarWhenPushed = NO;
  365. }
  366. /**
  367. 跳转到相机
  368. */
  369. - (void)pushPhotograph{
  370. DKCameraViewController *cameraVc = [[DKCameraViewController alloc] init];
  371. __weak typeof(self) weakSelf = self;
  372. // 多选相册+相机多拍 回调
  373. [cameraVc startCameraOrPhotoFileWithViewController:self
  374. complate:^(NSArray *object){
  375. // 选择完照片、拍照完回调
  376. [object enumerateObjectsUsingBlock:^(id asset, NSUInteger idx, BOOL *stop){
  377. if(weakSelf.assets.count < 9)
  378. {
  379. if ([asset isKindOfClass:[DKCamera class]]) {
  380. [weakSelf.assets addObject:asset];
  381. }else{
  382. [weakSelf.assets addObject:asset];
  383. }
  384. }else{
  385. [self showAlertViewText:@"最多只能选择9张图片"];
  386. }
  387. }];
  388. [weakSelf.collectionView reloadData];
  389. }];
  390. weakSelf.cameraVc = cameraVc;
  391. }
  392. /**
  393. 跳转到相机
  394. */
  395. - (void)pushAlbum{
  396. // 创建控制器
  397. DKPhotoPickerViewController *pickerVc = [[DKPhotoPickerViewController alloc] init];
  398. // 默认显示相册里面的内容SavePhotos
  399. pickerVc.status = PickerViewShowStatusCameraRoll;
  400. pickerVc.selectPickers = self.assets;
  401. // 最多能选9张图片
  402. pickerVc.minCount = 9;
  403. pickerVc.cameraCount = [self cameraCount];
  404. pickerVc.delegate = self;
  405. [pickerVc show];
  406. /**
  407. *
  408. 传值可以用代理,或者用block来接收,以下是block的传值
  409. __weak typeof(self) weakSelf = self;
  410. pickerVc.callBack = ^(NSArray *assets){
  411. weakSelf.assets = assets;
  412. [weakSelf.tableView reloadData];
  413. };
  414. */
  415. }
  416. /**
  417. 跳转到地图
  418. 关宏厚删除高德地图
  419. 2018-11-14
  420. */
  421. - (void)pushMap{
  422. self.hidesBottomBarWhenPushed=YES;
  423. // MapViewController *mc = [MapViewController new];
  424. // mc.pDelegate=self;
  425. // [self.navigationController pushViewController:mc animated:YES];
  426. //self.hidesBottomBarWhenPushed=NO;
  427. }
  428. /**
  429. 保存按钮
  430. */
  431. - (void)dataSave{
  432. for (int i = 0; i<_dataArray.count; i++) {
  433. NewCustomerModel *model = [_dataArray objectAtIndex:i];
  434. if(model.receiptSpecification == NULL || [model.receiptSpecification isEqualToString:@""]){
  435. [super showAlertViewText:@"回执规格不能为空!"];
  436. return;
  437. }
  438. }
  439. [self startLoading];
  440. dispatch_async(dispatch_get_global_queue(0, 0), ^{
  441. if ([self savePicsManager]) {
  442. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  443. [dict setObject:@"SaveFixedReceiptIphone" forKey:@"Action"];
  444. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  445. [dict setObject:kkUserCode forKey:@"UserCode"];
  446. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  447. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  448. [dict setObject:_fixedID forKey:@"FixedID"];
  449. [dict setObject:_arrangementID forKey:@"ArrangementID"];
  450. if(_lblPosition.text == nil){
  451. [dict setObject:@"" forKey:@"Position"];
  452. }else{
  453. [dict setObject:_lblPosition.text forKey:@"Position"];
  454. }
  455. [dict setObject:kkLicenseCode forKey:@"LicenseCode"];
  456. NSMutableDictionary *dicHead = [[NSMutableDictionary alloc] init];
  457. NSMutableArray *arrHead = [[NSMutableArray alloc]init];
  458. [dicHead setObject:_strCustomerID forKeyedSubscript:@"CustomerID"];
  459. [dicHead setObject:_strBusinessOrganization forKeyedSubscript:@"BusinessOrganization"];
  460. [dicHead setObject:_statusID forKeyedSubscript:@"ReceiptStatus"];
  461. [dicHead setObject:_strRemarks forKeyedSubscript:@"Remarks"];
  462. [dicHead setObject:_strSalesMan forKeyedSubscript:@"SalesMan"];
  463. [dicHead setObject:_fieldReceiptAmount.text forKeyedSubscript:@"ReceivableSum"];
  464. if(_settlementType == NULL){
  465. _settlementType = @"";
  466. }
  467. [dicHead setObject:_settlementType forKeyedSubscript:@"SettlementType"];
  468. [arrHead addObject:dicHead];
  469. [dict setObject:[Util objectToJson:arrHead] forKey:@"ReceiptData"];
  470. NSMutableArray *arrList = [[NSMutableArray alloc]init];
  471. for(int i = 0; i < _dataArray.count; i++){
  472. NewCustomerModel *model = [_dataArray objectAtIndex:i];
  473. NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
  474. [dic setObject:model.detailID forKeyedSubscript:@"FixedDetailID"];
  475. if(model.receiptRemarks == NULL){
  476. [dic setObject: @"" forKeyedSubscript:@"ReceiptRemarks"];
  477. }else{
  478. [dic setObject:model.receiptRemarks forKeyedSubscript:@"ReceiptRemarks"];
  479. }
  480. if(model.receiptSpecification == nil){
  481. [dic setObject:@"" forKeyedSubscript:@"ReceiptSpecification"];
  482. }
  483. else{
  484. [dic setObject:model.receiptSpecification forKeyedSubscript:@"ReceiptSpecification"];
  485. }
  486. [dic setObject:_settlementType forKeyedSubscript:@"SettlementType"];
  487. [arrList addObject:dic];
  488. }
  489. [dict setObject:[Util objectToJson:arrList] forKey:@"ReceiptDetailData"];
  490. if(_settlementType == NULL || _settlementType.length == 0){
  491. [dict setObject:@"" forKey:@"ReceiptEarnestData"];
  492. }else{
  493. NSMutableArray *arrList = [[NSMutableArray alloc]init];
  494. NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
  495. [dic setObject:_strTollAmount forKeyedSubscript:@"ReceivableSum"];
  496. if(_strEarnestFee == nil){
  497. [dic setObject:@"0" forKeyedSubscript:@"EarnestFee"];
  498. }else{
  499. [dic setObject:_strEarnestFee forKeyedSubscript:@"EarnestFee"];
  500. }
  501. [dic setObject:_listRemarks forKeyedSubscript:@"Remarks"];
  502. [dic setObject:_settlementType forKeyedSubscript:@"SettlementType"];
  503. [arrList addObject:dic];
  504. [dict setObject:[Util objectToJson:arrList] forKey:@"ReceiptEarnestData"];
  505. }
  506. if (_assets && self.arrImagePaths.count > 0) {
  507. [dict setObject:[self.arrImagePaths componentsJoinedByString:@"," ] forKey:@"ImagePath"];
  508. }
  509. _downManager = [[ASIDownManager alloc] init];
  510. _downManager.delegate = self;
  511. _downManager.onRequestSuccess = @selector(onSaveFinish:);
  512. _downManager.onRequestFail = @selector(onSaveFail:);
  513. [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
  514. }
  515. });
  516. }
  517. #pragma mark - 回调
  518. /**
  519. 键盘弹起
  520. */
  521. - (void) keyboardWillShow{
  522. if(!_keyboardShow){
  523. if(isCancelAnimation){
  524. [UIView animateWithDuration:0.3f animations:^ {
  525. self.view.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y-210, self.view.frame.size.width, self.view.frame.size.height);
  526. }];}
  527. }
  528. _keyboardShow=YES;
  529. }
  530. /**
  531. 键盘收起
  532. */
  533. - (void) keyboardWillHide{
  534. if(_keyboardShow){
  535. if(isCancelAnimation){
  536. [UIView animateWithDuration:0.1f animations:^ {
  537. self.view.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y+210, self.view.frame.size.width, self.view.frame.size.height);
  538. }];}
  539. }
  540. _keyboardShow=NO;
  541. }
  542. /**
  543. 地理位置
  544. @param name
  545. */
  546. - (void)relocationData:(NSString *)name{
  547. _lblPosition.text= name;
  548. _positionImage.hidden = NO;
  549. _lblPosition.hidden = NO;
  550. [self refreshView];
  551. }
  552. /**
  553. 回执状态回调
  554. @param s
  555. */
  556. - (void)showStatusValue:(StatusInfo*)s{
  557. [_btnReceiptStatus setTitle:s.name forState:UIControlStateNormal];
  558. _statusID= s.statusId;
  559. [_btnReceiptStatus setTintColor:[UIColor blackColor]];
  560. }
  561. /**
  562. 结算方式回调
  563. @param model
  564. */
  565. - (void)showProtocolValue:(SettlementTypeModel *)model{
  566. _settlementType=model.settlementId;
  567. _listRemarks=model.remark;
  568. _strEarnestFee = model.receivables;
  569. [_btnSettlement setTitle:model.settlementName forState:UIControlStateNormal];
  570. [_btnSettlement setTintColor:[UIColor blackColor]];
  571. }
  572. #pragma mark - 懒加载
  573. - (NSMutableArray *)assets{
  574. if (!_assets) {
  575. _assets = [NSMutableArray array];
  576. }
  577. return _assets;
  578. }
  579. - (NSMutableArray *)arrImagePaths{
  580. if (!_arrImagePaths) {
  581. _arrImagePaths = [NSMutableArray array];
  582. }
  583. return _arrImagePaths;
  584. }
  585. #pragma mark - 网格状图片列表
  586. /**
  587. 组数
  588. @param collectionView <#collectionView description#>
  589. @return <#return value description#>
  590. */
  591. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
  592. return 1;
  593. }
  594. /**
  595. 每组几个
  596. @param collectionView <#collectionView description#>
  597. @param section <#section description#>
  598. @return <#return value description#>
  599. */
  600. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
  601. CGFloat collectionheight = [Util getPhotoCollectionViewHeightWithPhotos:self.assets];
  602. self.collectionView.frame=CGRectMake(0, CGRectGetMaxY(_tableView.frame)+10, Screen_Width, collectionheight);
  603. [self refreshView];
  604. return [self.assets count];
  605. }
  606. /**
  607. 刷新布局
  608. */
  609. - (void)refreshView{
  610. if(_positionImage.isHidden){
  611. _positionImage.frame = CGRectMake(0, CGRectGetMaxY(_collectionView.frame), Screen_Width, 0);
  612. }else{
  613. _positionImage.frame = CGRectMake(0, CGRectGetMaxY(_collectionView.frame)+8, Screen_Width, 30);
  614. }
  615. _center.frame = CGRectMake(0, CGRectGetMaxY(_positionImage.frame), Screen_Width, 30);
  616. self.collectionView.backgroundColor = [UIColor whiteColor];
  617. _scrollView.contentSize = CGSizeMake(SCREENWIDTH, CGRectGetMaxY(_center.frame)+30);
  618. }
  619. /**
  620. cell返回
  621. @param collectionView <#collectionView description#>
  622. @param indexPath <#indexPath description#>
  623. @return <#return value description#>
  624. */
  625. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  626. DKUICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"DKUICollectionViewCell" forIndexPath:indexPath];
  627. // 判断类型来获取Image
  628. DKPhotoAssets *asset = self.assets[indexPath.item];
  629. if ([asset isKindOfClass:[DKPhotoAssets class]]) {
  630. cell.imageView.image = asset.originImage;
  631. }else if ([asset isKindOfClass:[NSString class]]){
  632. [cell.imageView sd_setImageWithURL:[NSURL URLWithString:(NSString *)asset] placeholderImage:[UIImage imageNamed:@"wallpaper_placeholder"]];
  633. }else if([asset isKindOfClass:[UIImage class]]){
  634. cell.imageView.image = (UIImage *)asset;
  635. }else if ([asset isKindOfClass:[DKCamera class]]){
  636. cell.imageView.image = [(DKCamera*)asset thumbImage];
  637. }
  638. return cell;
  639. }
  640. /**
  641. 网格状点击事件
  642. @param collectionView <#collectionView description#>
  643. @param indexPath <#indexPath description#>
  644. */
  645. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
  646. DKUICollectionViewCell *cell = (DKUICollectionViewCell *)[self.collectionView cellForItemAtIndexPath:indexPath];
  647. // 图片游览器
  648. DKPhotoPickerBrowserViewController *pickerBrowser = [[DKPhotoPickerBrowserViewController alloc] init];
  649. // 传入点击图片View的话,会有微信朋友圈照片的风格
  650. pickerBrowser.toView = cell.imageView;
  651. // 数据源/delegate
  652. pickerBrowser.delegate = self;
  653. pickerBrowser.dataSource = self;
  654. // 是否可以删除照片
  655. pickerBrowser.editing = YES;
  656. // 当前选中的值
  657. pickerBrowser.currentIndexPath = [NSIndexPath indexPathForItem:indexPath.row inSection:0];
  658. // 展示控制器
  659. [pickerBrowser show];
  660. }
  661. #pragma mark - 拍照回调
  662. - (NSInteger)numberOfSectionInPhotosInPickerBrowser:(DKPhotoPickerBrowserViewController *)pickerBrowser{
  663. return 1;
  664. }
  665. - (NSInteger)photoBrowser:(DKPhotoPickerBrowserViewController *)photoBrowser numberOfItemsInSection:(NSUInteger)section{
  666. return [self.assets count];
  667. }
  668. - (DKPhotoPickerBrowserPhoto *)photoBrowser:(DKPhotoPickerBrowserViewController *)pickerBrowser photoAtIndexPath:(NSIndexPath *)indexPath{
  669. id imageObj = [self.assets objectAtIndex:indexPath.item];
  670. DKPhotoPickerBrowserPhoto *photo = [DKPhotoPickerBrowserPhoto photoAnyImageObjWith:imageObj];
  671. // 包装下imageObj 成 DKPhotoPickerBrowserPhoto 传给数据源
  672. DKUICollectionViewCell *cell = (DKUICollectionViewCell *)[self.collectionView cellForItemAtIndexPath:indexPath];
  673. // 缩略图
  674. photo.thumbImage = cell.imageView.image;
  675. return photo;
  676. }
  677. #pragma mark - <DKPhotoPickerBrowserViewControllerDelegate>
  678. - (void)photoBrowser:(DKPhotoPickerBrowserViewController *)photoBrowser removePhotoAtIndexPath:(NSIndexPath *)indexPath{
  679. if (indexPath.row > [self.assets count]) return;
  680. [self.assets removeObjectAtIndex:indexPath.row];
  681. [self.collectionView reloadData];
  682. }
  683. /**
  684. 图片的个数
  685. @return <#return value description#>
  686. */
  687. - (NSInteger)cameraCount{
  688. NSInteger count=0;
  689. for (int i=0; i<self.assets.count; i++) {
  690. id asset=self.assets[i];
  691. if ([asset isKindOfClass:[DKCamera class]]) {
  692. count++;
  693. }
  694. }
  695. return count;
  696. }
  697. /**
  698. 图片返回
  699. @param assets <#assets description#>
  700. */
  701. - (void)pickerViewControllerDoneAsstes:(NSArray *)assets{
  702. for (int i=(int)self.assets.count-1;i>=0;i-- ) {
  703. if ([self.assets[i] isKindOfClass:[DKPhotoAssets class]]) {
  704. [self.assets removeObject:self.assets[i]];
  705. }
  706. }
  707. for (DKPhotoAssets* asset in assets ) {
  708. if ([asset isKindOfClass:[DKPhotoAssets class]]) {
  709. [self.assets addObject:asset];
  710. }
  711. }
  712. [self.collectionView reloadData];
  713. }
  714. #pragma mark - tableView实现的方法
  715. /**
  716. 组数
  717. @param tableView
  718. @return
  719. */
  720. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  721. return 1;
  722. }
  723. /**
  724. 返回cell
  725. @param tableView
  726. @param indexPath
  727. @return
  728. */
  729. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  730. static NSString *str = @"NewCustomReceiptCell";
  731. NewCustomReceiptCell *cell = [tableView dequeueReusableCellWithIdentifier:str];
  732. if(cell == nil){
  733. cell = [[NewCustomReceiptCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:str];
  734. }
  735. NewCustomerModel *model = [_dataArray objectAtIndex:indexPath.row];
  736. cell.model = model;
  737. cell.delegate = self;
  738. [cell loadCell];
  739. return cell;
  740. }
  741. /**
  742. cell的高度
  743. @param tableView
  744. @param indexPath
  745. @return
  746. */
  747. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  748. return 197;
  749. }
  750. /**
  751. 每组多少行
  752. @param tableView
  753. @param section
  754. @return
  755. */
  756. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  757. return _dataArray.count;
  758. }
  759. /**
  760. 计算tableView的高度
  761. @param array
  762. */
  763. - (void)reloadTableViewHeight:(NSArray *)array{
  764. // 上下间隔已经在frame上做了
  765. NSInteger row = array.count;
  766. _tableView.frame = CGRectMake(0,CGRectGetMaxY(_line.frame), SCREENWIDTH,202 * array.count);
  767. _collectionView.frame = CGRectMake(0, CGRectGetMaxY(_tableView.frame)
  768. , SCREENWIDTH, 0);
  769. _center.frame = CGRectMake(0,CGRectGetMaxY(_collectionView.frame), SCREENWIDTH, 30);
  770. _scrollView.contentSize = CGSizeMake(SCREENWIDTH, CGRectGetMaxY(_center.frame)+30);
  771. }
  772. #pragma mark - 键盘
  773. - (void)scrollViewDidScroll:(UIScrollView *)scrollView
  774. {
  775. [self.view endEditing:YES];
  776. }
  777. /**
  778. 键盘收起
  779. @param textField
  780. @return
  781. */
  782. - (BOOL)textFieldShouldReturn:(UITextField *)textField {
  783. // 回收键盘
  784. [textField resignFirstResponder];
  785. return YES;
  786. }
  787. /**
  788. cell回调保存输入框里面的值
  789. @param textField <#textField description#>
  790. */
  791. - (void)cellTextFieldDidEndEditing:(UITextField *)textField {
  792. UITableViewCell *cell = (UITableViewCell *)[[textField superview] superview];
  793. NSIndexPath *indexPath = [_tableView indexPathForCell:cell];
  794. NewCustomerModel *model = [_dataArray objectAtIndex:indexPath.row];
  795. if(textField.tag == 10){
  796. model.receiptSpecification = textField.text;
  797. }
  798. if(textField.tag == 20){
  799. model.receiptRemarks = textField.text;
  800. }
  801. }
  802. /**
  803. 结束编辑回调
  804. @param textField <#textField description#>
  805. */
  806. -(void)textFieldDidBeginEditing:(UITextField *)textField{
  807. if(textField.tag == 101){
  808. isCancelAnimation = NO;
  809. }
  810. }
  811. /**
  812. 开始编辑回调
  813. @param textField <#textField description#>
  814. */
  815. - (void)cellTextFieldDidBeginEditing:(UITextField *)textField{
  816. isCancelAnimation = YES;
  817. }
  818. /**
  819. 回执金额输入监听
  820. @param textField
  821. */
  822. - (void)textFieldDidChange :(UITextField *) textField{
  823. if([textField.text isEqualToString:@""]){
  824. return;
  825. }
  826. if([textField.text rangeOfString:@"."].location != NSNotFound){
  827. if(textField.text.length -1 - [textField.text rangeOfString:@"."].location > 6){
  828. NSString *str = [textField.text substringFromIndex:[textField.text rangeOfString:@"."].location+7];
  829. textField.text = str;
  830. }
  831. }
  832. if ([[textField.text substringFromIndex:0] isEqualToString:@"."]){
  833. textField.text = [NSString stringWithFormat:@"%@%@", @"0",textField.text];
  834. }
  835. NSString *str = _strTollAmount;
  836. if([str isEqualToString:@""]){
  837. str = @"0";
  838. }
  839. if([textField.text doubleValue]>[str doubleValue]){
  840. textField.text = str;
  841. [super showAlertViewText:[NSString stringWithFormat:@"%@%@%@",@"输入的最大值不能大于收费金额(",str,@")"]];
  842. }
  843. }
  844. #pragma mark - 图片上传
  845. /**
  846. 上传图片
  847. @return
  848. */
  849. - (BOOL)savePicsManager{
  850. _downManager = [[ASIDownManager alloc] init];
  851. _downManager.delegate = self;
  852. //////////////上传图片
  853. NSString *urlStr = ServerURL;
  854. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  855. [dict setObject:@"SaveImg" forKey:@"Action"];
  856. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  857. [dict setObject:kkUserCode forKey:@"UserCode"];
  858. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  859. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  860. [self.arrImagePaths removeAllObjects];
  861. for (int i=0; i<self.assets.count; i++) {
  862. ////////////////////
  863. //图片转化成document的路径。。。。。。。。
  864. // 判断类型来获取Image
  865. DKPhotoAssets *asset = self.assets[i];
  866. DKCamera * c;
  867. if ([asset isKindOfClass:[DKPhotoAssets class]]) {
  868. c = [self saveImage:asset.originImage withName:nil];
  869. }else if ([asset isKindOfClass:[NSString class]]){
  870. }else if([asset isKindOfClass:[UIImage class]]){
  871. }else if ([asset isKindOfClass:[DKCamera class]]){
  872. c=(DKCamera *)asset;
  873. c= [self saveImage:c.thumbImage withName:nil];
  874. }
  875. //延时
  876. [NSThread sleepForTimeInterval:0.5];
  877. NSString* retValue= [_downManager syncPostHttpRequestUrl:urlStr dic:dict path:c.imagePath filename:nil fileType:@"image/jpeg"];
  878. if (retValue == nil || retValue.length == 0){
  879. [super showAlertViewText:@"上传图片失败"];
  880. self.navigationItem.rightBarButtonItem.enabled=YES;
  881. return NO;
  882. }
  883. NSDictionary *dicRetValue = [retValue JSONValue];
  884. if (dicRetValue && [dicRetValue isKindOfClass:[NSDictionary class]]) {
  885. int iStatus = [[dicRetValue objectForKey:@"Status"] intValue];
  886. if (iStatus == 0) {
  887. NSString * imgPath = [dicRetValue objectForKey:@"Result"];
  888. [self.arrImagePaths addObject:imgPath];
  889. }
  890. else{
  891. return NO;
  892. }
  893. }
  894. }
  895. return YES;
  896. }
  897. /**
  898. 保存图片至沙盒
  899. @param currentImage
  900. @param imageName
  901. @return
  902. */
  903. - (DKCamera *)saveImage:(UIImage *)currentImage withName:(NSString *)imageName {
  904. if (!currentImage) {
  905. return nil;
  906. }
  907. NSDateFormatter *formater = [[NSDateFormatter alloc] init];
  908. formater.dateFormat = @"yyyyMMddHHmmss";
  909. NSString *currentTimeStr = [[formater stringFromDate:[NSDate date]] stringByAppendingFormat:@"_%d_.jpg" ,arc4random_uniform(10000)];
  910. NSData *imageData = [LeslieAsyncImageDownloader resetSizeOfImageData:currentImage maxSize:500];
  911. // 获取沙盒目录
  912. NSString *fullPath ;
  913. if([imageName isEqualToString:@""] || imageName == nil){
  914. fullPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:currentTimeStr];
  915. }
  916. else{
  917. fullPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:imageName];
  918. }
  919. // 将图片写入文件
  920. [imageData writeToFile:fullPath atomically:NO];
  921. UIImage *savedImage = [[UIImage alloc] initWithContentsOfFile:fullPath];
  922. //NSData *data = UIImageJPEGRepresentation(savedImage, 0.3);
  923. DKCamera *camera = [[DKCamera alloc] init];
  924. camera.imagePath = fullPath;
  925. camera.thumbImage =savedImage;// [UIImage imageWithData:data];
  926. return camera;
  927. }
  928. #pragma mark - 初始化
  929. /**
  930. 初始化布局
  931. */
  932. - (void)initUI{
  933. _strCustomerName = @"";
  934. _strTelephone = @"";
  935. _strTollAmount = @"";
  936. _strReceivedAmount = @"";
  937. _strReceiptedAmount = @"";
  938. self.view.backgroundColor = [UIColor whiteColor];
  939. self.navigationItem.title = @"定制品售前回执";
  940. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  941. [button setImage:[UIImage imageNamed:@"icon_back.png"] forState:UIControlStateNormal];
  942. [button addTarget:self action:@selector(goBack)
  943. forControlEvents:UIControlEventTouchUpInside];
  944. button.frame = CGRectMake(0, 0,45,22);
  945. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  946. self.navigationItem.leftBarButtonItem = menuButton;
  947. }
  948. /**
  949. 界面展示
  950. */
  951. - (void)loadUI{
  952. self.view.frame = CGRectMake(0, 0, SCREENWIDTH, Screen_Height-rectNavHeight-rectStatusHeight);
  953. _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, SCREENWIDTH, Screen_Height-rectNavHeight-rectStatusHeight-50)];
  954. _scrollView.delegate = self;
  955. [self.view addSubview:_scrollView];
  956. CGFloat lineHeight = 5;
  957. CGFloat fixedNoHeight = 14;
  958. CGFloat spacing = 13;
  959. CGFloat leftSpacing = 15;
  960. CGFloat CustomerNameHeight = 13;
  961. UIColor *textColor = [UIColor colorWithRed:180.0/255 green:180.0/255 blue:180.0/255 alpha:1];
  962. UIColor *lineColor = [UIColor colorWithRed:234.0/255 green:235.0/255 blue:236.0/255 alpha:1];
  963. UIView *lineTop = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREENWIDTH, lineHeight)];
  964. lineTop.backgroundColor = lineColor;
  965. [_scrollView addSubview: lineTop];
  966. UILabel *fixedNo = [[UILabel alloc]initWithFrame:CGRectMake(leftSpacing, lineHeight+spacing , SCREENWIDTH-30,fixedNoHeight)];
  967. fixedNo.text = [NSString stringWithFormat:@"售前回执:%@",_fixedNo];
  968. fixedNo.font = [UIFont systemFontOfSize:fixedNoHeight];
  969. [_scrollView addSubview: fixedNo];
  970. UIView *lineBottom = [[UIView alloc]initWithFrame:CGRectMake(0,lineHeight+fixedNoHeight+spacing*2, SCREENWIDTH, lineHeight)];
  971. lineBottom.backgroundColor = lineColor;
  972. [_scrollView addSubview: lineBottom];
  973. _lblCustomerName = [[UILabel alloc]initWithFrame:CGRectMake(leftSpacing, lineHeight*2+spacing*3+fixedNoHeight, SCREENWIDTH-30,CustomerNameHeight)];
  974. _lblCustomerName.text = [NSString stringWithFormat:@"客户名称:%@",_strCustomerName];
  975. _lblCustomerName.font = [UIFont systemFontOfSize:fixedNoHeight-1];
  976. [_scrollView addSubview: _lblCustomerName];
  977. _lblTollAmount = [[UILabel alloc]initWithFrame:CGRectMake(leftSpacing, lineHeight*2+spacing*5+fixedNoHeight+CustomerNameHeight, SCREENWIDTH-30,CustomerNameHeight)];
  978. _lblTollAmount.text = [NSString stringWithFormat:@"收费金额:%@",_strTollAmount];
  979. _lblTollAmount.font = [UIFont systemFontOfSize:CustomerNameHeight];
  980. [_scrollView addSubview: _lblTollAmount];
  981. _lblReceivedAmount = [[UILabel alloc]initWithFrame:CGRectMake(leftSpacing, lineHeight*2+spacing*7+fixedNoHeight+CustomerNameHeight*2, SCREENWIDTH-30,CustomerNameHeight)];
  982. _lblReceivedAmount.text = [NSString stringWithFormat:@"已回执金额:%@",_strReceivedAmount];
  983. _lblReceivedAmount.font = [UIFont systemFontOfSize:CustomerNameHeight];
  984. [_scrollView addSubview: _lblReceivedAmount];
  985. UILabel *receiptAmount = [[UILabel alloc]initWithFrame:CGRectMake(leftSpacing, lineHeight*2+spacing*9+fixedNoHeight+CustomerNameHeight*3, 70,CustomerNameHeight)];
  986. receiptAmount.text = @"回执金额:";
  987. receiptAmount.font = [UIFont systemFontOfSize:CustomerNameHeight];
  988. [_scrollView addSubview: receiptAmount];
  989. _fieldReceiptAmount = [[UITextField alloc]initWithFrame:CGRectMake(70+leftSpacing, lineHeight*2+spacing*9+fixedNoHeight+CustomerNameHeight*3, SCREENWIDTH-85,CustomerNameHeight)];
  990. _fieldReceiptAmount.delegate = self;
  991. NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:@"请输入回执金额" attributes:
  992. @{NSForegroundColorAttributeName: textColor,
  993. NSFontAttributeName:_fieldReceiptAmount.font
  994. }];
  995. [_fieldReceiptAmount addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  996. _fieldReceiptAmount.tag = 101;
  997. _fieldReceiptAmount.delegate = self;
  998. _fieldReceiptAmount.attributedPlaceholder = attrString;
  999. _fieldReceiptAmount.font = [UIFont systemFontOfSize:CustomerNameHeight];
  1000. [_scrollView addSubview: _fieldReceiptAmount];
  1001. UILabel *settlement = [[UILabel alloc]initWithFrame:CGRectMake(leftSpacing, lineHeight*2+spacing*11+fixedNoHeight+CustomerNameHeight*4, 70,CustomerNameHeight)];
  1002. settlement.text = @"结算方式:";
  1003. settlement.font = [UIFont systemFontOfSize:CustomerNameHeight];
  1004. [_scrollView addSubview: settlement];
  1005. _btnSettlement = [UIButton buttonWithType:UIButtonTypeSystem];
  1006. _btnSettlement.frame = CGRectMake(85, lineHeight*2+spacing*11+fixedNoHeight+CustomerNameHeight*4, SCREENWIDTH-85,CustomerNameHeight);
  1007. [_btnSettlement setTitle:@"请选择结算方式" forState:UIControlStateNormal];
  1008. [_btnSettlement addTarget:self action:@selector(showSettlement:) forControlEvents:(UIControlEventTouchUpInside)];
  1009. [_btnSettlement setTintColor:textColor];
  1010. _btnSettlement.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  1011. _btnSettlement.font = [UIFont systemFontOfSize:CustomerNameHeight];
  1012. [_scrollView addSubview: _btnSettlement];
  1013. UILabel *receiptStatus = [[UILabel alloc]initWithFrame:CGRectMake(leftSpacing, lineHeight*2+spacing*13+fixedNoHeight+CustomerNameHeight*5, 70,CustomerNameHeight)];
  1014. receiptStatus.text = @"回执状态:";
  1015. receiptStatus.font = [UIFont systemFontOfSize:CustomerNameHeight];
  1016. [_scrollView addSubview: receiptStatus];
  1017. _btnReceiptStatus = [UIButton buttonWithType:UIButtonTypeSystem];
  1018. _btnReceiptStatus.frame = CGRectMake(85, lineHeight*2+spacing*13+fixedNoHeight+CustomerNameHeight*5, SCREENWIDTH-85,CustomerNameHeight);
  1019. [_btnReceiptStatus setTitle:@"完成" forState:UIControlStateNormal];
  1020. _statusID= @"2";
  1021. [_btnReceiptStatus setTintColor:[UIColor blackColor]];
  1022. [_btnReceiptStatus addTarget:self action:@selector(showReceiptType:) forControlEvents:(UIControlEventTouchUpInside)];
  1023. _btnReceiptStatus.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  1024. _btnReceiptStatus.font = [UIFont systemFontOfSize:CustomerNameHeight];
  1025. [_scrollView addSubview: _btnReceiptStatus];
  1026. _lblTelePhone = [[UILabel alloc]initWithFrame:CGRectMake(leftSpacing, lineHeight*2+spacing*15+fixedNoHeight+CustomerNameHeight*6, SCREENWIDTH-30,CustomerNameHeight)];
  1027. _lblTelePhone.text = [NSString stringWithFormat:@"联系电话:%@",_strTelephone];
  1028. _lblTelePhone.font = [UIFont systemFontOfSize:CustomerNameHeight];
  1029. [_scrollView addSubview: _lblTelePhone];
  1030. _line = [[UIView alloc] initWithFrame:CGRectMake(0,CGRectGetMaxY(_lblTelePhone.frame)+10,SCREENWIDTH, 5)];
  1031. _line.backgroundColor = [UIColor colorWithRed:234.0/255 green:235.0/255 blue:236.0/255 alpha:1];
  1032. [_scrollView addSubview:_line];
  1033. //TableView
  1034. _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_line.frame), SCREENWIDTH, 200) style:UITableViewStylePlain];
  1035. _tableView.scrollEnabled=NO;
  1036. _tableView.delegate = self;
  1037. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  1038. _tableView.dataSource = self;
  1039. [_scrollView addSubview:_tableView];
  1040. UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
  1041. flowLayout.itemSize = CGSizeMake(85, 85);
  1042. flowLayout.minimumInteritemSpacing = 5;
  1043. flowLayout.minimumLineSpacing = 10;
  1044. flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
  1045. flowLayout.sectionInset = UIEdgeInsetsMake(7, 20, 0, 20);
  1046. _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_tableView.frame)+10
  1047. , SCREENWIDTH, 0) collectionViewLayout:flowLayout];
  1048. [self.collectionView registerNib:[UINib nibWithNibName:@"DKUICollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"DKUICollectionViewCell"];
  1049. _collectionView.dataSource = self;
  1050. _collectionView.scrollEnabled = NO;
  1051. _collectionView.delegate = self;
  1052. [_scrollView addSubview:_collectionView];
  1053. //位置view
  1054. _positionImage = [[UIView alloc]init];
  1055. _positionImage.frame = CGRectMake(0, CGRectGetMaxY(_collectionView.frame), Screen_Width, 0);
  1056. _positionImage.hidden = YES;
  1057. [_scrollView addSubview:_positionImage];
  1058. //星号
  1059. UIImageView *ivposition = [UIImageView new];
  1060. ivposition.image = [UIImage imageNamed:@"log_position"];
  1061. ivposition.frame = CGRectMake(10,2,13,16);
  1062. [_positionImage addSubview:ivposition];
  1063. _lblPosition = [UILabel new];
  1064. _lblPosition.font = [UIFont systemFontOfSize:14];
  1065. _lblPosition.frame = CGRectMake(30, 0, Screen_Width-32, 20);
  1066. [_positionImage addSubview:_lblPosition];
  1067. _positionImage.hidden = YES;
  1068. _center = [[UIView alloc]initWithFrame:CGRectMake(0,CGRectGetMaxY(_positionImage.frame), SCREENWIDTH, 30)];
  1069. _center.backgroundColor = [UIColor whiteColor];
  1070. [_scrollView addSubview: _center];
  1071. CGFloat width = (SCREENWIDTH-70)/2;
  1072. CustomButton *btnPhoto = [[CustomButton alloc]initWithFrame:CGRectMake(width-90, 10, 70, 20) andImage:[UIImage imageNamed:@"icon_takephoto"] addText:@"照相" addImageWidth:15 addImageHeight:12];
  1073. [btnPhoto addTarget:self action:@selector(pushPhotograph) forControlEvents:(UIControlEventTouchUpInside)];
  1074. [_center addSubview:btnPhoto];
  1075. CustomButton *btn = [[CustomButton alloc]initWithFrame:CGRectMake(width, 10,70 , 20) andImage:[UIImage imageNamed:@"icon_photo"] addText:@"相册" addImageWidth:14 addImageHeight:15];
  1076. [btn addTarget:self action:@selector(pushAlbum) forControlEvents:(UIControlEventTouchUpInside)];
  1077. [_center addSubview:btn];
  1078. CustomButton *btnLoaction = [[CustomButton alloc]initWithFrame:CGRectMake(width+85, 10,100 , 20) andImage:[UIImage imageNamed:@"icon_position"] addText:@"所在位置" addImageWidth:13 addImageHeight:16];
  1079. [btnLoaction addTarget:self action:@selector(pushMap) forControlEvents:(UIControlEventTouchUpInside)];
  1080. [_center addSubview:btnLoaction];
  1081. //保存
  1082. _btnSave = [UIButton buttonWithType:UIButtonTypeCustom];
  1083. _btnSave.frame=CGRectMake(20, self.view.frame.size.height-59, Screen_Width-40,44) ;
  1084. [_btnSave setBackgroundImage:[UIImage imageNamed:@"bt_datasave"] forState:UIControlStateNormal];
  1085. [_btnSave addTarget:self action:@selector(dataSave) forControlEvents:UIControlEventTouchUpInside];
  1086. [self.view addSubview:_btnSave];
  1087. }
  1088. /**
  1089. 状态初始化
  1090. */
  1091. - (void)initStatus{
  1092. _arrayDStatus = [[NSMutableArray alloc] init];
  1093. StatusInfo* s = [[StatusInfo alloc]init];
  1094. s.tagName = @"status";
  1095. s.statusId = @"1";
  1096. s.name = @"再次安排";
  1097. [_arrayDStatus addObject:s];
  1098. s = [[StatusInfo alloc]init];
  1099. s.tagName = @"status";
  1100. s.statusId = @"2";
  1101. s.name = @"完成";
  1102. [_arrayDStatus addObject:s];
  1103. }
  1104. @end