NewOrderVC.m 108 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620
  1. //
  2. // OrderVC.m
  3. // IBOSSmini
  4. //
  5. // Created by guan hong hou on 2018/1/24.
  6. // Copyright © 2018年 elongtian. All rights reserved.
  7. //
  8. #import "NewOrderVC.h"
  9. #import "DragItemInfo.h"
  10. #import "EditSortVC.h"
  11. #import "BRDatePickerView.h"
  12. @interface NewOrderVC (){
  13. UIScrollView *_scrollView;
  14. Boolean isExpand;
  15. }
  16. @property(strong)BRDatePickerView *brDatePicker;
  17. @end
  18. @implementation NewOrderVC
  19. - (void)viewDidLoad {
  20. [super viewDidLoad];
  21. _departmentDataList=[[NSMutableArray alloc]init];
  22. _salesmanDataList=[[NSMutableArray alloc]init];
  23. _intermediateCustomerList=[[NSMutableArray alloc]init];
  24. _earnestAmountList=[[NSMutableArray alloc]init];
  25. _feesAmountList=[[NSMutableArray alloc]init];
  26. [self initData];
  27. [self initUI];
  28. [self initDynamicLayout:_topDataList dynamicView:_vTop topFlag:YES];
  29. [self initDynamicLayout:_bottomDataList dynamicView:_vBottom topFlag:NO];
  30. if(!_editFLag){
  31. _installDate=[DateFormat getCurrentDate];
  32. _deliveryDate=[DateFormat getCurrentDate];
  33. _lblInstallDate.text=_installDate;
  34. _lblDeliveryDate.text=_deliveryDate;
  35. // _channelId=kkChannelId;
  36. // _channelName=kkChannelName;
  37. // _staffId=kkStaffId;
  38. // _staffName=kkStaffName;
  39. _mainDepartmentCommission=@"100";
  40. _mainSalesManCommission=@"100";
  41. // _customerAreaId=kkCustomerAreaId;
  42. // _customerAreaName=kkCustomerAreaName;
  43. // if(_organizationName!=nil){
  44. // _lblOrganizationName.text=_organizationName;
  45. // }
  46. // if(_customerAreaName!=nil){
  47. // _lblCustomerArea.text=_customerAreaName;
  48. // }
  49. // if(_channelName!=nil){
  50. // _lblChannel.text=kkChannelName;
  51. // }
  52. // if(_staffName!=nil){
  53. // _lblStaff.text=_staffName;
  54. // }
  55. }
  56. _vBottom.hidden=YES;
  57. _vBottom.frame=CGRectMake(0, CGRectGetMaxY(_separator2.frame),Screen_Width, 0);
  58. _vBody.frame=CGRectMake(0,0,Screen_Width, CGRectGetMaxY(_vBottom.frame));
  59. [self updateScrollView];
  60. }
  61. /**
  62. 修改:2017-9-25
  63. 适配机型
  64. 安全区视图发生变化
  65. */
  66. -(void)viewSafeAreaInsetsDidChange{
  67. _scrollView.frame = CGRectMake(0, 0, Screen_Width, self.view.superview.frame.size.height );
  68. [super viewSafeAreaInsetsDidChange];
  69. }
  70. -(void)loadEarnestDataSource{
  71. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  72. [dict setObject:@"GetEarnestAmountDataAndroid" forKey:@"Action"];
  73. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  74. [dict setObject:kkUserCode forKey:@"UserCode"];
  75. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  76. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  77. _downManager = [[ASIDownManager alloc] init];
  78. [self startLoading];
  79. _downManager.delegate = self;
  80. _downManager.onRequestSuccess = @selector(onEarnestLoadFinish:);
  81. _downManager.onRequestFail = @selector(onEarnestLoadFail:);
  82. [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
  83. }
  84. -(void)loadFeeAmountDataSource{
  85. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  86. [dict setObject:@"GetFeeItemInfo" forKey:@"Action"];
  87. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  88. [dict setObject:kkUserCode forKey:@"UserCode"];
  89. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  90. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  91. _downManager = [[ASIDownManager alloc] init];
  92. [self startLoading];
  93. _downManager.delegate = self;
  94. _downManager.onRequestSuccess = @selector(onFeesAmountLoadFinish:);
  95. _downManager.onRequestFail = @selector(onFeesAmountLoadFail:);
  96. [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
  97. }
  98. -(void) loadIntermediateCustomer{
  99. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  100. [dict setObject:@"GetDataSource" forKey:@"Action"];
  101. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  102. [dict setObject:kkUserCode forKey:@"UserCode"];
  103. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  104. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  105. [dict setObject:@"IntCustomerStaff"forKey:@"DataSourceCode"];
  106. [dict setObject:@""forKey:@"FatherCustomerID"];
  107. _downManager = [[ASIDownManager alloc] init];
  108. [self startLoading];
  109. _downManager.delegate = self;
  110. _downManager.onRequestSuccess = @selector(onIntermediateCustomerLoadFinish:);
  111. _downManager.onRequestFail = @selector(onIntermediateCustomerLoadFail:);
  112. [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
  113. }
  114. -(void)loadSalesManData{
  115. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  116. [dict setObject:@"GetStaffDataSource" forKey:@"Action"];
  117. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  118. [dict setObject:kkUserCode forKey:@"UserCode"];
  119. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  120. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  121. [dict setObject:@""forKey:@"StaffCode"];
  122. [dict setObject:@""forKey:@"StaffName"];
  123. _downManager = [[ASIDownManager alloc] init];
  124. [self startLoading];
  125. _downManager.delegate = self;
  126. _downManager.onRequestSuccess = @selector(onSalesmanLoadFinish:);
  127. _downManager.onRequestFail = @selector(onSalesmanLoadFail:);
  128. [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
  129. }
  130. -(void)loadBusinessDepartmentData{
  131. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  132. [dict setObject:@"GetOrganizationDataSource" forKey:@"Action"];
  133. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  134. [dict setObject:kkUserCode forKey:@"UserCode"];
  135. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  136. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  137. [dict setObject:@""forKey:@"OrganizationName"];
  138. [dict setObject:@""forKey:@"OrganizationCode"];
  139. [dict setObject:@"true"forKey:@"IsOnlyDisplayEnd"];
  140. _downManager = [[ASIDownManager alloc] init];
  141. [self startLoading];
  142. _downManager.delegate = self;
  143. _downManager.onRequestSuccess = @selector(onDepartmentLoadFinish:);
  144. _downManager.onRequestFail = @selector(onDepartmentLoadFail:);
  145. [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
  146. }
  147. /**
  148. 日期
  149. */
  150. - (void)showDeliveryDate:(UITapGestureRecognizer *)gesture{
  151. __weak typeof(self) weakself=self;
  152. [weakself.view endEditing:YES];
  153. _brDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  154. [_brDatePicker configureSelectionBlock:^(NSString *date){
  155. _deliveryDate=date;
  156. } andCompletionBlock:^(void){
  157. _lblDeliveryDate.text=_deliveryDate;
  158. } andCancelBlock:^(void){
  159. if([_lblDeliveryDate.text isEqualToString:@"请选择配送日期"]){
  160. self->_deliveryDate=@"";
  161. }
  162. }];
  163. [_brDatePicker show];
  164. }
  165. - (void)showInstallDate:(UITapGestureRecognizer *)gesture{
  166. __weak typeof(self) weakself=self;
  167. [weakself.view endEditing:YES];
  168. _brDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  169. [_brDatePicker configureSelectionBlock:^(NSString *date){
  170. _installDate=date;
  171. } andCompletionBlock:^(void){
  172. _lblInstallDate.text= _installDate;
  173. } andCancelBlock:^(void){
  174. if([_lblDeliveryDate.text isEqualToString:@"请选择安装日期"]){
  175. _deliveryDate=@"";
  176. }
  177. }];
  178. [_brDatePicker show];
  179. }
  180. // scrollView 开始拖动
  181. - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
  182. {
  183. [self.homeVC.view endEditing:YES];
  184. }
  185. -(void)onEarnestLoadFinish:(ASIDownManager *)sender{
  186. NSDictionary *dic = [sender.mWebStr JSONValue];
  187. [self cancel];
  188. // 服务器返回数据是否正确
  189. if (dic && [dic isKindOfClass:[NSDictionary class]]) {
  190. // 服务器返回数据状态值
  191. int iStatus = [[dic objectForKey:@"Status"] intValue];
  192. // 服务器返回数据消息
  193. NSString *message=[dic objectForKey:@"Message"];
  194. // 服务器返回数据状态值正确
  195. if (iStatus == 0) {
  196. NSArray * infoArr=[dic objectForKey:@"Result"];
  197. if(infoArr!=nil&& infoArr.count>0)
  198. {
  199. for (int i = 0; i < infoArr.count; i++) {
  200. NSDictionary *dic=infoArr[i];
  201. EarnestModel *earnestModel=[EarnestModel new];
  202. [earnestModel parseDic:dic ];
  203. [_earnestAmountList addObject:earnestModel];
  204. }
  205. }
  206. }
  207. else if(iStatus == ActionResultStatusAuthError
  208. ||iStatus == ActionResultStatusNoLogin
  209. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
  210. [self showReLoginDialog:message];
  211. }
  212. else{
  213. [self showAlertViewText:message];
  214. }
  215. [self loadFeeAmountDataSource];
  216. }
  217. }
  218. -(void)onEarnestLoadFail:(ASIDownManager *)sender{
  219. [self cancel];
  220. [self showAlertViewText:@"加载失败"];
  221. }
  222. -(void)onFeesAmountLoadFinish:(ASIDownManager *)sender{
  223. NSDictionary *dic = [sender.mWebStr JSONValue];
  224. [self cancel];
  225. // 服务器返回数据是否正确
  226. if (dic && [dic isKindOfClass:[NSDictionary class]]) {
  227. // 服务器返回数据状态值
  228. int iStatus = [[dic objectForKey:@"Status"] intValue];
  229. // 服务器返回数据消息
  230. NSString *message=[dic objectForKey:@"Message"];
  231. // 服务器返回数据状态值正确
  232. if (iStatus == 0) {
  233. NSArray * infoArr=[dic objectForKey:@"Result"];
  234. if(infoArr!=nil&& infoArr.count>0)
  235. {
  236. for (int i = 0; i < infoArr.count; i++) {
  237. NSDictionary *dic=infoArr[i];
  238. FeeAmountModel *feeModel=[FeeAmountModel new];
  239. int feeItemIdValue= [[dic objectForKey:@"FeeItemID"]intValue];
  240. NSString *feeItemId= [NSString stringWithFormat:@"%d",feeItemIdValue] ;
  241. NSString *feeItemName=[dic objectForKey:@"FeeItemName"];
  242. [feeModel setFeeItemId:feeItemId];
  243. [feeModel setFeeItemName:feeItemName];
  244. [feeModel setFeeItemSum:@"0"];
  245. [_feesAmountList addObject:feeModel];
  246. }
  247. }
  248. }
  249. else if(iStatus == ActionResultStatusAuthError
  250. ||iStatus == ActionResultStatusNoLogin
  251. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
  252. [self showReLoginDialog:message];
  253. }
  254. else{
  255. [self showAlertViewText:message];
  256. }
  257. }
  258. }
  259. -(void)onFeesAmountLoadFail:(ASIDownManager *)sender{
  260. [self cancel];
  261. [self showAlertViewText:@"加载失败"];
  262. }
  263. -(void)onIntermediateCustomerLoadFinish:(ASIDownManager *)sender{
  264. NSDictionary *dic = [sender.mWebStr JSONValue];
  265. [self cancel];
  266. // 服务器返回数据是否正确
  267. if (dic && [dic isKindOfClass:[NSDictionary class]]) {
  268. // 服务器返回数据状态值
  269. int iStatus = [[dic objectForKey:@"Status"] intValue];
  270. // 服务器返回数据消息
  271. NSString *message=[dic objectForKey:@"Message"];
  272. // 服务器返回数据状态值正确
  273. if (iStatus == 0) {
  274. NSArray * infoArr=[dic objectForKey:@"Result"];
  275. if(infoArr!=nil&& infoArr.count>0)
  276. {
  277. for (int i = 0; i < infoArr.count; i++) {
  278. NSDictionary * dic=infoArr[i];
  279. IntermediateCustomerModel *model=[IntermediateCustomerModel new];
  280. [model parseDic:dic];
  281. IntermediateCustomerFrame *intermediateCustomerFrame=[IntermediateCustomerFrame new];
  282. [intermediateCustomerFrame setIntermediateCustomerFrame:model];
  283. [_intermediateCustomerList addObject:intermediateCustomerFrame];
  284. }
  285. if(_editFLag){
  286. for (IntermediateCustomerFrame *intermediateCustomerFrame in _intermediateCustomerList){
  287. IntermediateCustomerModel *intermediateCustomerModel= intermediateCustomerFrame.intermediateCustomerModel;
  288. if(_originalIntermediateCustomerList!=nil&&_originalIntermediateCustomerList.count>0){
  289. for(IntermediateCustomerFrame *originalIntermediateCustomerFrame in _originalIntermediateCustomerList){
  290. IntermediateCustomerModel *originalCustomerModel=originalIntermediateCustomerFrame.intermediateCustomerModel;
  291. if(intermediateCustomerModel.intermediateCustomerStaffId==originalCustomerModel.intermediateCustomerStaffId){
  292. intermediateCustomerModel.commission=originalCustomerModel.commission;
  293. intermediateCustomerModel.isCheckedStatus=YES;
  294. }
  295. }
  296. }
  297. }
  298. }
  299. }
  300. }
  301. // 服务器返回数据状态值异常
  302. else if(iStatus == ActionResultStatusAuthError
  303. ||iStatus == ActionResultStatusNoLogin
  304. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
  305. [self showReLoginDialog:message];
  306. }
  307. else{
  308. [self showAlertViewText:message];
  309. }
  310. [self loadEarnestDataSource];
  311. }
  312. }
  313. /**
  314. 加载总数数据失败回调
  315. @param sender <#sender description#>
  316. */
  317. - (void)onIntermediateCustomerLoadFail:(ASIDownManager *)sender {
  318. [self cancel];
  319. [self showAlertViewText:@"加载失败"];
  320. }
  321. - (void)onDepartmentLoadFinish:(ASIDownManager *)sender {
  322. NSDictionary *dic = [sender.mWebStr JSONValue];
  323. [self cancel];
  324. // 服务器返回数据是否正确
  325. if (dic && [dic isKindOfClass:[NSDictionary class]]) {
  326. // 服务器返回数据状态值
  327. int iStatus = [[dic objectForKey:@"Status"] intValue];
  328. // 服务器返回数据消息
  329. NSString *message=[dic objectForKey:@"Message"];
  330. // 服务器返回数据状态值正确
  331. if (iStatus == 0) {
  332. NSArray * infoArr=[dic objectForKey:@"Result"];
  333. // 返回结果
  334. if(infoArr!=nil&& infoArr.count>0)
  335. {
  336. for (int i = 0; i < infoArr.count; i++) {
  337. NSDictionary * dic=infoArr[i];
  338. BusinessDepartmentModel *departmentModel=[[BusinessDepartmentModel alloc]init];
  339. [departmentModel parseDic:dic];
  340. DepartmentFrame *frame=[DepartmentFrame new];
  341. [frame setBusinessDepartmentFrame:departmentModel];
  342. [_departmentDataList addObject:frame];
  343. }
  344. if(_editFLag){
  345. for(DepartmentFrame *frame in _departmentDataList){
  346. BusinessDepartmentModel *departmentModel=frame.departmentModel;
  347. if(_originalMainDepartmentModel!=nil){
  348. if(departmentModel.organizationId==_originalMainDepartmentModel.organizationId){
  349. departmentModel.commission=_originalMainDepartmentModel.commission;
  350. departmentModel.isMainDepartmentStatus=YES;
  351. departmentModel.isCheckedStatus=YES;
  352. }
  353. }
  354. if(_originalSecondaryDepartmentList!=nil&&_originalSecondaryDepartmentList.count>0){
  355. for(DepartmentFrame *originalFrame in _originalSecondaryDepartmentList ){
  356. BusinessDepartmentModel *originalDepartmentModel= originalFrame.departmentModel;
  357. if(departmentModel.organizationId==originalDepartmentModel.organizationId){
  358. departmentModel.commission=originalDepartmentModel.commission;
  359. departmentModel.isMainDepartmentStatus=NO;
  360. departmentModel.isCheckedStatus=YES;
  361. }
  362. }
  363. }
  364. }
  365. }
  366. else{
  367. if(_organizationId!=nil&&_organizationCode!=nil&&_organizationName!=nil){
  368. _mainDepartmentModel=[BusinessDepartmentModel new];
  369. _mainDepartmentModel.organizationId=[_organizationId integerValue] ;
  370. _mainDepartmentModel.organizationCode=_organizationCode;
  371. _mainDepartmentModel.organizationName=_organizationName;
  372. _mainDepartmentModel.commission=@"100";
  373. _mainDepartmentModel.isCheckedStatus=YES;
  374. _mainDepartmentModel.isMainDepartmentStatus=YES;
  375. for(DepartmentFrame *frame in _departmentDataList){
  376. BusinessDepartmentModel *departmentModel=frame.departmentModel;
  377. if(_mainDepartmentModel.organizationId==departmentModel.organizationId){
  378. departmentModel.commission=@"100";
  379. departmentModel.isCheckedStatus=YES;
  380. departmentModel.isMainDepartmentStatus=YES;
  381. }
  382. }
  383. }
  384. }
  385. }
  386. }
  387. // 服务器返回数据状态值异常
  388. else if(iStatus == ActionResultStatusAuthError
  389. ||iStatus == ActionResultStatusNoLogin
  390. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
  391. [self showReLoginDialog:message];
  392. }
  393. else{
  394. [self showAlertViewText:message];
  395. }
  396. [self loadSalesManData];
  397. }
  398. }
  399. /**
  400. 加载总数数据失败回调
  401. @param sender <#sender description#>
  402. */
  403. - (void)onDepartmentLoadFail:(ASIDownManager *)sender
  404. {
  405. [self cancel];
  406. [self showAlertViewText:@"加载失败"];
  407. }
  408. - (void)onSalesmanLoadFinish:(ASIDownManager *)sender
  409. {
  410. NSDictionary *dic = [sender.mWebStr JSONValue];
  411. [self cancel];
  412. // 服务器返回数据是否正确
  413. if (dic && [dic isKindOfClass:[NSDictionary class]]) {
  414. // 服务器返回数据状态值
  415. int iStatus = [[dic objectForKey:@"Status"] intValue];
  416. // 服务器返回数据消息
  417. NSString *message=[dic objectForKey:@"Message"];
  418. // 服务器返回数据状态值正确
  419. if (iStatus == 0)
  420. {
  421. NSArray * infoArr=[dic objectForKey:@"Result"];
  422. // 返回结果
  423. if(infoArr!=nil&& infoArr.count>0)
  424. {
  425. for (int i = 0; i < infoArr.count; i++) {
  426. NSDictionary * dic=infoArr[i];
  427. SalesManModel *salesmanModel=[[SalesManModel alloc]init];
  428. [salesmanModel parseDic:dic];
  429. SalesManFrame *frame=[SalesManFrame new];
  430. [frame setSalesManFrame:salesmanModel];
  431. [_salesmanDataList addObject:frame];
  432. }
  433. if(_editFLag)
  434. {
  435. for(SalesManFrame *salesmanFrame in _salesmanDataList){
  436. SalesManModel *salesmanModel=salesmanFrame.salesmanModel;
  437. if(_originalMainSalesMan!=nil){
  438. if(salesmanModel.staffId==_originalMainSalesMan.staffId){
  439. salesmanModel.commission=_originalMainSalesMan.commission;
  440. salesmanModel.isMainSalesManStatus=YES;
  441. salesmanModel.isCheckedStatus=YES;
  442. }
  443. }
  444. if(_originalSecondaryStaffList!=nil&&_originalSecondaryStaffList.count>0){
  445. for(SalesManFrame *originalSalesmanFrame in _originalSecondaryStaffList){
  446. SalesManModel *originalSalesmanModel= originalSalesmanFrame.salesmanModel;
  447. if(salesmanModel.staffId==originalSalesmanModel.staffId){
  448. salesmanModel.commission=@"100";
  449. salesmanModel.isMainSalesManStatus=YES;
  450. salesmanModel.isCheckedStatus=YES;
  451. }
  452. }
  453. }
  454. }
  455. }
  456. else{
  457. if(_staffId!=nil&&_staffName!=nil){
  458. _mainSalesMan=[SalesManModel new];
  459. _mainSalesMan.staffId=[_staffId integerValue];
  460. _mainSalesMan.staffName=_staffName;
  461. for(SalesManFrame *salesmanFrame in _salesmanDataList ){
  462. SalesManModel *salesmanModel= salesmanFrame.salesmanModel;
  463. if(_mainSalesMan.staffId==salesmanModel.staffId){
  464. salesmanModel.commission=@"100";
  465. salesmanModel.isMainSalesManStatus=YES;
  466. salesmanModel.isCheckedStatus=YES;
  467. }
  468. }
  469. }
  470. }
  471. }
  472. }
  473. // 服务器返回数据状态值异常
  474. else if(iStatus == ActionResultStatusAuthError
  475. ||iStatus == ActionResultStatusNoLogin
  476. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
  477. [self showReLoginDialog:message];
  478. }
  479. else{
  480. [self showAlertViewText:message];
  481. }
  482. [self loadIntermediateCustomer];
  483. }
  484. }
  485. /**
  486. 加载总数数据失败回调
  487. @param sender <#sender description#>
  488. */
  489. - (void)onSalesmanLoadFail:(ASIDownManager *)sender {
  490. [self cancel];
  491. [self showAlertViewText:@"加载失败"];
  492. }
  493. -(void)allListeners{
  494. UITapGestureRecognizer *tapRecognizerPerformanceAccountingCategory=[[UITapGestureRecognizer alloc] initWithTarget:self
  495. action:@selector(goPerformanceAccountingCategory)];
  496. [_lblPerformanceAccountingCategory addGestureRecognizer:tapRecognizerPerformanceAccountingCategory];
  497. UITapGestureRecognizer *tapRecognizerIntermediateCustomer=[[UITapGestureRecognizer alloc] initWithTarget:self
  498. action:@selector(goIntermediateCustomer:)];
  499. [_lblIntermediateCustomer addGestureRecognizer:tapRecognizerIntermediateCustomer];
  500. UITapGestureRecognizer *tapRecognizerPayment=[[UITapGestureRecognizer alloc] initWithTarget:self
  501. action:@selector(goPayment:)];
  502. [_lblPayment addGestureRecognizer:tapRecognizerPayment];
  503. UITapGestureRecognizer *tapRecognizerDecorationProgress=[[UITapGestureRecognizer alloc] initWithTarget:self
  504. action:@selector(goDecorationProgress:)];
  505. [_lblDecorationProgress addGestureRecognizer:tapRecognizerDecorationProgress];
  506. UITapGestureRecognizer *tapRecognizerFloors=[[UITapGestureRecognizer alloc] initWithTarget:self
  507. action:@selector(goFloors:)];
  508. [_lblFloor addGestureRecognizer:tapRecognizerFloors];
  509. UITapGestureRecognizer *tapRecognizerDeliveryDate=[[UITapGestureRecognizer alloc] initWithTarget:self
  510. action:@selector(showDeliveryDate:)];
  511. [_lblDeliveryDate addGestureRecognizer:tapRecognizerDeliveryDate];
  512. UITapGestureRecognizer *tapRecognizerInstallDate=[[UITapGestureRecognizer alloc] initWithTarget:self
  513. action:@selector(showInstallDate:)];
  514. [_lblInstallDate addGestureRecognizer:tapRecognizerInstallDate];
  515. UITapGestureRecognizer *tapRecognizerFeesAmount=[[UITapGestureRecognizer alloc] initWithTarget:self
  516. action:@selector(showFeesAmount:)];
  517. [_lblFeesAmount addGestureRecognizer:tapRecognizerFeesAmount];
  518. }
  519. -(void)initData{
  520. NSData *encodeTopObject = [[NSUserDefaults standardUserDefaults] objectForKey:@"topList"];
  521. _topDataList = [NSKeyedUnarchiver unarchiveObjectWithData:encodeTopObject];
  522. NSData *encodeBottomObject = [[NSUserDefaults standardUserDefaults] objectForKey:@"bottomList"];
  523. _bottomDataList = [NSKeyedUnarchiver unarchiveObjectWithData:encodeBottomObject];
  524. if((_topDataList==nil||_topDataList.count==0)&&(_bottomDataList==nil||_bottomDataList.count==0)){
  525. _topDataList=[[NSMutableArray alloc]init];
  526. _bottomDataList=[[NSMutableArray alloc]init];
  527. DragItemInfo *topInfo;
  528. topInfo =[DragItemInfo new];
  529. [topInfo setComponentId:1000];
  530. [topInfo setComponentName:@"客户地址"];
  531. [_topDataList addObject:topInfo];
  532. topInfo =[DragItemInfo new];
  533. [topInfo setComponentId:1001];
  534. [topInfo setComponentName:@"备 注"];
  535. [_topDataList addObject:topInfo];
  536. DragItemInfo *bottomItemInfo;
  537. bottomItemInfo = [DragItemInfo new];
  538. bottomItemInfo.componentId = 1002;
  539. bottomItemInfo.componentName = @"业绩核算类别";
  540. [_bottomDataList addObject:bottomItemInfo];
  541. bottomItemInfo = [DragItemInfo new];
  542. bottomItemInfo.componentId = 1003;
  543. bottomItemInfo.componentName = @"定金金额";
  544. [_bottomDataList addObject:bottomItemInfo];
  545. bottomItemInfo = [DragItemInfo new];
  546. bottomItemInfo.componentId = 1004;
  547. bottomItemInfo.componentName = @"中间客户";
  548. [_bottomDataList addObject:bottomItemInfo];
  549. bottomItemInfo = [DragItemInfo new];
  550. bottomItemInfo.componentId = 1005;
  551. bottomItemInfo.componentName = @"货物总额";
  552. [_bottomDataList addObject:bottomItemInfo];
  553. bottomItemInfo = [DragItemInfo new];
  554. bottomItemInfo.componentId = 1006;
  555. bottomItemInfo.componentName = @"合计总额";
  556. [_bottomDataList addObject:bottomItemInfo];
  557. bottomItemInfo = [DragItemInfo new];
  558. bottomItemInfo.componentId = 1007;
  559. bottomItemInfo.componentName = @"合同号";
  560. [_bottomDataList addObject:bottomItemInfo];
  561. bottomItemInfo = [DragItemInfo new];
  562. bottomItemInfo.componentId = 1008;
  563. bottomItemInfo.componentName = @"联系人";
  564. [_bottomDataList addObject:bottomItemInfo];
  565. bottomItemInfo = [DragItemInfo new];
  566. bottomItemInfo.componentId = 1009;
  567. bottomItemInfo.componentName = @"联系方式";
  568. [_bottomDataList addObject:bottomItemInfo];
  569. bottomItemInfo = [DragItemInfo new];
  570. bottomItemInfo.componentId = 1010;
  571. bottomItemInfo.componentName = @"整单折扣";
  572. [_bottomDataList addObject:bottomItemInfo];
  573. bottomItemInfo = [DragItemInfo new];
  574. bottomItemInfo.componentId = 1011;
  575. bottomItemInfo.componentName = @"转销售金额";
  576. [_bottomDataList addObject:bottomItemInfo];
  577. bottomItemInfo = [DragItemInfo new];
  578. bottomItemInfo.componentId = 1012;
  579. bottomItemInfo.componentName = @"安装日期";
  580. [_bottomDataList addObject:bottomItemInfo];
  581. bottomItemInfo = [DragItemInfo new];
  582. bottomItemInfo.componentId = 1013;
  583. bottomItemInfo.componentName = @"配送日期";
  584. [_bottomDataList addObject:bottomItemInfo];
  585. bottomItemInfo = [DragItemInfo new];
  586. bottomItemInfo.componentId = 1014;
  587. bottomItemInfo.componentName = @"楼层";
  588. [_bottomDataList addObject:bottomItemInfo];
  589. bottomItemInfo = [DragItemInfo new];
  590. bottomItemInfo.componentId = 1015;
  591. bottomItemInfo.componentName = @"装修进度";
  592. [_bottomDataList addObject:bottomItemInfo];
  593. bottomItemInfo = [DragItemInfo new];
  594. bottomItemInfo.componentId = 1016;
  595. bottomItemInfo.componentName = @"重量";
  596. [_bottomDataList addObject:bottomItemInfo];
  597. bottomItemInfo = [DragItemInfo new];
  598. bottomItemInfo.componentId = 1017;
  599. bottomItemInfo.componentName = @"总体积";
  600. [_bottomDataList addObject:bottomItemInfo];
  601. bottomItemInfo = [DragItemInfo new];
  602. bottomItemInfo.componentId = 1018;
  603. bottomItemInfo.componentName = @"定金比率";
  604. [_bottomDataList addObject:bottomItemInfo];
  605. bottomItemInfo = [DragItemInfo new];
  606. bottomItemInfo.componentId = 1019;
  607. bottomItemInfo.componentName = @"标价总额";
  608. [_bottomDataList addObject:bottomItemInfo];
  609. bottomItemInfo = [DragItemInfo new];
  610. bottomItemInfo.componentId = 1020;
  611. bottomItemInfo.componentName = @"订单单号";
  612. [_bottomDataList addObject:bottomItemInfo];
  613. bottomItemInfo = [DragItemInfo new];
  614. bottomItemInfo.componentId = 1021;
  615. bottomItemInfo.componentName = @"费用金额";
  616. [_bottomDataList addObject:bottomItemInfo];
  617. bottomItemInfo = [DragItemInfo new];
  618. bottomItemInfo.componentId = 1022;
  619. bottomItemInfo.componentName = @"总平米";
  620. [_bottomDataList addObject:bottomItemInfo];
  621. }
  622. }
  623. -(void)setTextEnabled:(Boolean)enabled{
  624. _vChannel.userInteractionEnabled=enabled;
  625. _vCustomerType.userInteractionEnabled=enabled;
  626. _txtCustomerName.enabled=enabled;
  627. }
  628. /**
  629. 隐藏键盘
  630. */
  631. - (void)hideKey{
  632. [self.view endEditing:YES];
  633. }
  634. - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
  635. //CGFloat contentOffset = scrollView.contentOffset.y;
  636. if(!isExpand){
  637. _vBottom.hidden=NO;
  638. isExpand=YES;
  639. [self performSelector:@selector(delayMethod) withObject:nil afterDelay:0.1];
  640. }
  641. }
  642. -(void)delayMethod{
  643. [self initDynamicLayout:_bottomDataList dynamicView:_vBottom topFlag:NO];
  644. }
  645. -(void)initUI{
  646. [self.view setBackgroundColor:[UIColor whiteColor]];
  647. _scrollView=[UIScrollView new];
  648. _scrollView.frame=CGRectMake(0, 0, CGRectGetWidth(self.view.frame), SCREENHEIGHT-rectNavHeight-rectStatusHeight-80-55);
  649. [self.view addSubview:_scrollView];
  650. _vBody=[UIView new];
  651. _vBody.frame=CGRectZero;
  652. [_scrollView addSubview:_vBody];
  653. _scrollView.delegate=self;
  654. UITapGestureRecognizer* gesture=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKey)];
  655. [self.view addGestureRecognizer:gesture];
  656. UIView *topSeparatorView = [UIView new];
  657. topSeparatorView.frame=CGRectMake(0,3, Screen_Width, 10);
  658. topSeparatorView.backgroundColor = LineBackgroundColor;
  659. [_vBody addSubview:topSeparatorView];
  660. if(_vCustomerCode==nil){
  661. _vCustomerCode = [UIView new];
  662. }
  663. _vCustomerCode.frame=CGRectMake(0,CGRectGetMaxY(topSeparatorView.frame),Screen_Width, 51);
  664. [_vBody addSubview:_vCustomerCode];
  665. UILabel *lblCustomerCode = [UILabel new];
  666. lblCustomerCode.frame=CGRectMake(15,16, 100, 25);
  667. lblCustomerCode.text = @"客户编码";
  668. lblCustomerCode.textColor=[UIColor redColor];
  669. lblCustomerCode.font= [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  670. [_vCustomerCode addSubview:lblCustomerCode];
  671. _txtCustomerCode = [UITextField new];
  672. _txtCustomerCode.frame=CGRectMake(CGRectGetMaxX(lblCustomerCode.frame)+10,16, 150, 25);
  673. _txtCustomerCode.font=[UIFont systemFontOfSize: LabelAndTextFontOfSize];
  674. _txtCustomerCode.placeholder = @"请输入客户编码";
  675. _txtCustomerCode.delegate=self;
  676. [_txtCustomerCode addTarget:self action:@selector(searchOnlyByCustomerCode) forControlEvents:UIControlEventEditingDidEnd];
  677. _txtCustomerCode.tag=1301;
  678. [_vCustomerCode addSubview:_txtCustomerCode];
  679. _btnCustomerCode = [UIButton buttonWithType:UIButtonTypeCustom];
  680. _btnCustomerCode.frame=CGRectMake(Screen_Width-50,10,32,30);
  681. UIImageView *customerCodeImg = [[UIImageView alloc]initWithFrame:CGRectMake(25,9,7, 12)];
  682. [customerCodeImg setImage:[UIImage imageNamed:@"rightarrow"]];
  683. customerCodeImg.userInteractionEnabled=NO;
  684. [ _btnCustomerCode addSubview:customerCodeImg];
  685. [_btnCustomerCode addTarget:self action:@selector(searchCustomerCode) forControlEvents:UIControlEventTouchUpInside];
  686. [_vCustomerCode addSubview:_btnCustomerCode];
  687. [_btnCustomerCode addTarget:self action:@selector(loadMoreInfo) forControlEvents:UIControlEventTouchUpInside];
  688. UIView *separator = [UIView new];
  689. separator.backgroundColor=LineBackgroundColor;
  690. separator.frame=CGRectMake(CGRectGetMaxX(lblCustomerCode.frame)+10,CGRectGetMaxY(_txtCustomerCode.frame)+10,Screen_Width-CGRectGetMaxX(lblCustomerCode.frame)+10, 1);
  691. [_vCustomerCode addSubview:separator];
  692. if(_vCustomerName==nil){
  693. _vCustomerName = [UIView new];
  694. }
  695. _vCustomerName.frame=CGRectMake(0,CGRectGetMaxY(_vCustomerCode.frame),Screen_Width, 51);
  696. [_vBody addSubview:_vCustomerName];
  697. _txtCustomerName= [self getTextField:_vCustomerName labelText:@"客户名称" hintText:@"请输入客户名称" labelColor:[UIColor redColor] tag:901];
  698. _txtCustomerName.delegate=self;
  699. if(_vTelephone==nil){
  700. _vTelephone = [UIView new];
  701. }
  702. _vTelephone.frame=CGRectMake(0,CGRectGetMaxY(_vCustomerName.frame),Screen_Width, 51);
  703. [_vBody addSubview:_vTelephone];
  704. _txtTelephone= [self getTextField:_vTelephone labelText:@"联系电话" hintText:@"请输入联系电话" labelColor:[UIColor redColor] tag:902];
  705. _txtTelephone.delegate=self;
  706. if(_vDepartment==nil){
  707. _vDepartment = [UIView new];
  708. }
  709. _vDepartment.frame=CGRectMake(0,CGRectGetMaxY(_vTelephone.frame),Screen_Width, 51);
  710. [_vBody addSubview:_vDepartment];
  711. if(_lblOrganizationName==nil){
  712. _lblOrganizationName= [self getUILabel:_vDepartment labelText:@"业务部门" hintText:@"请选择业务部门" labelColor:[UIColor redColor] isHaveRightArrow:YES tag:903];
  713. }
  714. UITapGestureRecognizer *tapGesture=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(goDepartment:)];
  715. [_lblOrganizationName addGestureRecognizer:tapGesture];
  716. [tapGesture setNumberOfTapsRequired:1];
  717. // if(!_editFLag){
  718. // _lblOrganizationName.text=_organizationName;
  719. // }
  720. if(_vStaff==nil){
  721. _vStaff = [UIView new];
  722. }
  723. _vStaff.frame=CGRectMake(0,CGRectGetMaxY(_vDepartment.frame),Screen_Width, 51);
  724. [_vBody addSubview:_vStaff];
  725. if(_lblStaff==nil){
  726. _lblStaff = [self getUILabel:_vStaff labelText:@"业 务 员" hintText:@"请选择业务员" labelColor:[UIColor redColor] isHaveRightArrow:YES tag:904];
  727. }
  728. UITapGestureRecognizer *tapRecognizerStaff=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goStaff:)];
  729. _lblStaff.userInteractionEnabled=YES;
  730. [_lblStaff addGestureRecognizer:tapRecognizerStaff];
  731. _vChannel = [UIView new];
  732. _vChannel.frame=CGRectMake(0,CGRectGetMaxY(_vStaff.frame),Screen_Width, 51);
  733. [_vBody addSubview:_vChannel];
  734. if(_lblChannel==nil){
  735. _lblChannel=[self getUILabel:_vChannel labelText:@"渠 道" hintText:@"请选择渠道" labelColor:[UIColor redColor] isHaveRightArrow:YES tag:905];
  736. }
  737. UITapGestureRecognizer *tapRecognizerChannel=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goChannel:)];
  738. [_lblChannel addGestureRecognizer:tapRecognizerChannel];
  739. _vCustomerArea = [UIView new];
  740. _vCustomerArea.frame=CGRectMake(0,CGRectGetMaxY(_vChannel.frame),Screen_Width, 51);
  741. [_vBody addSubview:_vCustomerArea];
  742. if(_lblCustomerArea==nil){
  743. _lblCustomerArea= [self getUILabel:_vCustomerArea labelText:@"客户区域" hintText:@"请选择客户区域" labelColor:[UIColor redColor] isHaveRightArrow:YES tag:906];
  744. }
  745. UITapGestureRecognizer *tapRecognizerCustomerArea=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goCustomerArea:)];
  746. _lblCustomerArea.userInteractionEnabled=YES;
  747. [_lblCustomerArea addGestureRecognizer:tapRecognizerCustomerArea];
  748. _vCustomerType = [UIView new];
  749. _vCustomerType.frame=CGRectMake(0,CGRectGetMaxY(_vCustomerArea.frame),Screen_Width, 51);
  750. [_vBody addSubview:_vCustomerType];
  751. if(_lblCustomerType==nil){
  752. _lblCustomerType= [self getUILabel:_vCustomerType labelText:@"客户性质" hintText:@"请选择客户性质" labelColor:[UIColor redColor] isHaveRightArrow:YES tag:907];
  753. }
  754. UITapGestureRecognizer *tapRecognizerCustomerType=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goCustomerType:)];
  755. _lblCustomerType.userInteractionEnabled=YES;
  756. [_lblCustomerType addGestureRecognizer:tapRecognizerCustomerType];
  757. _vTop=[UIView new];
  758. _vTop.frame=CGRectMake(0,CGRectGetMaxY(_vCustomerType.frame),Screen_Width,0);
  759. [_vBody addSubview:_vTop];
  760. _vTop.frame=CGRectMake(0, CGRectGetMaxY(_vCustomerType.frame), Screen_Width, CGRectGetMaxY(_vCustomerType.frame));
  761. _separator1 = [UIView new];
  762. _separator1.backgroundColor=LineBackgroundColor;
  763. _separator1.frame=CGRectMake(0,CGRectGetMaxY(_vTop.frame)+10,Screen_Width, 10);
  764. [_vBody addSubview:_separator1];
  765. _vOperation = [UIView new];
  766. _vOperation.frame=CGRectMake(0,CGRectGetMaxY(_separator1.frame),Screen_Width, 51);
  767. [_vBody addSubview:_vOperation];
  768. _vOperation.userInteractionEnabled=YES;
  769. UIButton *moreInfoBtn=[UIButton buttonWithType:UIButtonTypeCustom];
  770. moreInfoBtn.frame=CGRectMake(Screen_Width-80, 16, 70, 25);
  771. [moreInfoBtn setTitle:@"更多信息" forState:UIControlStateNormal];
  772. [moreInfoBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
  773. moreInfoBtn.titleLabel.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  774. [_vOperation addSubview:moreInfoBtn];
  775. [moreInfoBtn addTarget:self action:@selector(loadMoreInfo) forControlEvents:UIControlEventTouchUpInside];
  776. UIButton *editSortBtn=[UIButton buttonWithType:UIButtonTypeCustom];
  777. editSortBtn.frame=CGRectMake(Screen_Width-160, 16, 70, 25);
  778. [editSortBtn setTitle:@"编辑排序" forState:UIControlStateNormal];
  779. [editSortBtn addTarget:self action:@selector(editSort) forControlEvents:UIControlEventTouchUpInside];
  780. [editSortBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
  781. editSortBtn.titleLabel.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  782. [_vOperation addSubview:editSortBtn];
  783. _separator2 = [UIView new];
  784. _separator2.backgroundColor=LineBackgroundColor;
  785. _separator2.frame=CGRectMake(0,CGRectGetMaxY(_vOperation.frame),Screen_Width, 10);
  786. [_vBody addSubview:_separator2];
  787. _vBottom=[UIView new];
  788. _vBottom.frame=CGRectMake(0, CGRectGetMaxY(_separator2.frame),Screen_Width, 0);
  789. [_vBody addSubview:_vBottom];
  790. _vBody.frame=CGRectMake(0,0,Screen_Width, CGRectGetMaxY(_vBottom.frame));
  791. [self updateScrollView];
  792. }
  793. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
  794. {
  795. NSInteger existedLength = textField.text.length;
  796. NSInteger selectedLength = range.length;
  797. NSInteger replaceLength = string.length;
  798. if (textField == self.txtCustomerCode) {
  799. if (string.length == 0){
  800. return YES;
  801. }
  802. if (existedLength - selectedLength + replaceLength > 100) {
  803. return NO;
  804. }
  805. }
  806. if(textField==self.txtCustomerName){
  807. if (string.length == 0){
  808. return YES;
  809. }
  810. if (existedLength - selectedLength + replaceLength > 50) {
  811. return NO;
  812. }
  813. }
  814. if(textField==self.txtTelephone){
  815. if (string.length == 0){
  816. return YES;
  817. }
  818. if (existedLength - selectedLength + replaceLength >12) {
  819. return NO;
  820. }
  821. }
  822. if(textField==self.txtContactPerson){
  823. if (string.length == 0){
  824. return YES;
  825. }
  826. if (existedLength - selectedLength + replaceLength >50) {
  827. return NO;
  828. }
  829. }
  830. if(textField==self.txtContactWay){
  831. if (string.length == 0){
  832. return YES;
  833. }
  834. if (existedLength - selectedLength + replaceLength >100) {
  835. return NO;
  836. }
  837. }
  838. if(textField==self.txtContractNo){
  839. if (string.length == 0){
  840. return YES;
  841. }
  842. if (existedLength - selectedLength + replaceLength >50) {
  843. return NO;
  844. }
  845. }
  846. if(textField==self.txtCustomerAddress){
  847. if (string.length == 0){
  848. return YES;
  849. }
  850. if (existedLength - selectedLength + replaceLength >500) {
  851. return NO;
  852. }
  853. }
  854. if(textField==self.txtContractNo){
  855. if (string.length == 0){
  856. return YES;
  857. }
  858. if (existedLength - selectedLength + replaceLength >50) {
  859. return NO;
  860. }
  861. }
  862. if(textField==self.txtRemarks){
  863. if (string.length == 0){
  864. return YES;
  865. }
  866. if (existedLength - selectedLength + replaceLength >200) {
  867. return NO;
  868. }
  869. }
  870. return YES;
  871. }
  872. -(void)goDecorationProgress:(UITapGestureRecognizer *)gesture{
  873. self.hidesBottomBarWhenPushed=YES;
  874. CustomerReportTextVC *tc=[[CustomerReportTextVC alloc] init];
  875. tc.delegate = self;
  876. tc.dataSourceCode=@"DecorationProcess";
  877. tc.showDialogViewTag=ReportCumstomerDecorationProgress;
  878. [self.orderNav pushViewController:tc animated:YES];
  879. }
  880. - (void)goDepartment:(UITapGestureRecognizer *)gesture {
  881. self.hidesBottomBarWhenPushed = YES;
  882. SalesOrderBusinessDepartmentVC *departmentVC=[[ SalesOrderBusinessDepartmentVC alloc] init];
  883. _businessDepartmentTempList=[[NSMutableArray alloc] initWithArray:_departmentDataList copyItems:YES];
  884. departmentVC.departmentDelegate=self;
  885. if(_departmentDataList!=nil&&_departmentDataList.count>0){
  886. departmentVC.departmentList=_departmentDataList;
  887. }
  888. [self.orderNav pushViewController:departmentVC animated:YES];
  889. }
  890. -(void)goChannel:(UITapGestureRecognizer *)gesture{
  891. self.hidesBottomBarWhenPushed = YES;
  892. CustomerReportTextVC *tc=[[CustomerReportTextVC alloc] init];
  893. tc.delegate=self;
  894. tc.dataSourceCode=@"T_MST_Channel";
  895. tc.showDialogViewTag=ReportCumstomerChannel;
  896. [self.orderNav pushViewController:tc animated:YES];
  897. }
  898. -(void)goStaff:(UITapGestureRecognizer *)gesture{
  899. if(_salesmanDataList!=nil&&_salesmanDataList.count>0){
  900. self.hidesBottomBarWhenPushed = YES;
  901. _salesmanTempList=[[NSMutableArray alloc] initWithArray:_salesmanDataList copyItems:YES];
  902. SalesManVC *salesmanVc=[[SalesManVC alloc]init];
  903. salesmanVc.salesmanDelegate=self;
  904. salesmanVc.editFlag=_editFLag;
  905. salesmanVc.originalSecondarySalesmanList=_originalSecondaryStaffList;
  906. salesmanVc.originalMainSalesManModel=_originalMainSalesMan;
  907. salesmanVc.salesmanList=_salesmanDataList;
  908. [self.orderNav pushViewController:salesmanVc animated:YES];
  909. }
  910. }
  911. -(void)goCustomerArea:(UITapGestureRecognizer *)gesture{
  912. self.hidesBottomBarWhenPushed = YES;
  913. CustomerReportTextVC *tc=[[CustomerReportTextVC alloc] init];
  914. tc.delegate=self;
  915. tc.dataSourceCode=@"T_MST_District";
  916. tc.showDialogViewTag=ReportCustomerAero;
  917. [self.orderNav pushViewController:tc animated:YES];
  918. }
  919. -(void)goFloors:(UITapGestureRecognizer *)gesture{
  920. self.hidesBottomBarWhenPushed = YES;
  921. CustomerReportTextVC *tc=[[CustomerReportTextVC alloc] init];
  922. tc.delegate=self;
  923. tc.showDialogViewTag=ReportFloors;
  924. [self.orderNav pushViewController:tc animated:YES];
  925. }
  926. -(void)goIntermediateCustomer:(UITapGestureRecognizer *)gesture{
  927. self.hidesBottomBarWhenPushed = YES;
  928. IntermediateCustomerVC *customerVc=[[IntermediateCustomerVC alloc]init];
  929. _intermediateCustomerTempList= [[NSMutableArray alloc] initWithArray:_intermediateCustomerList copyItems:YES];
  930. customerVc.intermediateCustomerDelegate=self;
  931. customerVc.intermediateCustomerList=_intermediateCustomerList;
  932. [self.orderNav pushViewController:customerVc animated:YES];
  933. }
  934. -(void)recoveryData{
  935. if(_businessDepartmentTempList!=nil&&_businessDepartmentTempList.count>0){
  936. _departmentDataList=[[NSMutableArray alloc] initWithArray:_businessDepartmentTempList copyItems:YES];
  937. }
  938. if(_salesmanTempList!=nil&&_salesmanTempList.count>0){
  939. _salesmanDataList=[[NSMutableArray alloc] initWithArray:_salesmanTempList copyItems:YES];
  940. }
  941. if(_intermediateCustomerTempList!=nil&&_intermediateCustomerTempList.count>0){
  942. _intermediateCustomerList= [[NSMutableArray alloc] initWithArray:_intermediateCustomerTempList copyItems:YES];;
  943. }
  944. }
  945. /**
  946. 客户性质
  947. */
  948. - (void)goCustomerType:(UITapGestureRecognizer *)gesture{
  949. self.hidesBottomBarWhenPushed = YES;
  950. CustomerReportTextVC *tc=[[CustomerReportTextVC alloc] init];
  951. tc.delegate=self;
  952. tc.dataSourceCode=@"CustomerType";
  953. tc.showDialogViewTag=ReportOrderCumstomerType;
  954. [self.orderNav pushViewController:tc animated:YES];
  955. }
  956. -(void)goPerformanceAccountingCategory
  957. {
  958. self.hidesBottomBarWhenPushed = YES;
  959. CustomerReportTextVC *tc=[[CustomerReportTextVC alloc] init];
  960. tc.delegate=self;
  961. tc.showDialogViewTag=ReportPerformanceAccountingCategory;
  962. [self.orderNav pushViewController:tc animated:YES];
  963. }
  964. -(void)goPayment:(UITapGestureRecognizer *)gesture{
  965. self.hidesBottomBarWhenPushed = YES;
  966. EarnestAmountVC *earnestVc=[[EarnestAmountVC alloc]init];
  967. earnestVc.paymentDelegate=self;
  968. earnestVc.earnestList=_earnestAmountList;
  969. [self.orderNav pushViewController:earnestVc animated:YES];
  970. }
  971. -(void)showFeesAmount:(UITapGestureRecognizer *)gesture{
  972. self.hidesBottomBarWhenPushed = YES;
  973. FeeAmountVC *feeVc=[[FeeAmountVC alloc]init];
  974. feeVc.feeAmountDelegate=self;
  975. feeVc.feeList=_feesAmountList;
  976. [self.orderNav pushViewController:feeVc animated:YES];
  977. }
  978. /**
  979. 渠道,区域,客户性质,级别等返回回调
  980. @param model <#model description#>
  981. @param cr <#cr description#>
  982. */
  983. - (void)customerReportTextDoneDatas:(CustomerReportTextInfoModel *)model CustomerReport:(CustomerReport)cr
  984. {
  985. if (model==nil) {
  986. return;
  987. }
  988. //渠道返回值
  989. if(cr==ReportCumstomerChannel){
  990. _channelId=model.idCode;
  991. _channelName=model.name;
  992. _lblChannel.text=self.channelName;
  993. }
  994. //客户性质返回值
  995. if(cr==ReportOrderCumstomerType){
  996. _customerTypeId=model.idCode;
  997. _customerTypeName=model.name;
  998. _lblCustomerType.text=@"";
  999. _lblCustomerType.text=_customerTypeName;
  1000. }
  1001. //客户区域返回值
  1002. if(cr==ReportCustomerAero){
  1003. _customerAreaId=model.idCode;
  1004. _customerAreaName=model.name;
  1005. _lblCustomerArea.text=_customerAreaName;
  1006. }
  1007. if(cr==ReportCumstomerDecorationProgress){
  1008. _decorationProgressId=model.idCode;
  1009. _decorationProgressName=model.name;
  1010. _lblDecorationProgress.text=_decorationProgressName;
  1011. }
  1012. if(cr==ReportFloors){
  1013. _floorsId=model.idCode;
  1014. _floorsName=model.name;
  1015. _lblFloor.text=_floorsName;
  1016. }
  1017. if(cr==ReportPerformanceAccountingCategory)
  1018. {
  1019. _performanceAccountingId=model.idCode;
  1020. _performanceAccountingName=model.name;
  1021. _lblPerformanceAccountingCategory.text=_performanceAccountingName;
  1022. }
  1023. if(cr==ReportFloors)
  1024. {
  1025. _floorsId=model.idCode;
  1026. _floorsName=model.name;
  1027. _lblFloor.text=_floorsName;
  1028. }
  1029. }
  1030. -(void)showDepartmentInfo:(NSMutableArray*)departmentList
  1031. {
  1032. _departmentCheckedList=departmentList;
  1033. _mainDepartmentModel=[self getMainBusinessDepartment:_departmentCheckedList];
  1034. _secondaryDepartmentList=[self getSecondaryDepartmentList:_departmentCheckedList];
  1035. if(_editFLag){
  1036. if(_mainDepartmentModel.organizationId==_originalMainDepartmentModel.organizationId){
  1037. _mainDepartmentModel.commission=_originalMainDepartmentModel.commission;
  1038. }
  1039. else{
  1040. _mainDepartmentModel.commission=@"100";
  1041. }
  1042. for(DepartmentFrame *departmentFrame in _secondaryDepartmentList){
  1043. BusinessDepartmentModel *departmentModel= departmentFrame.departmentModel;
  1044. if(_originalSecondaryDepartmentList!=nil&&_originalSecondaryDepartmentList.count>0){
  1045. for(DepartmentFrame *originalDepartmentFrame in _originalSecondaryDepartmentList){
  1046. BusinessDepartmentModel *originalDepartmentModel=originalDepartmentFrame.departmentModel;
  1047. if(departmentModel.organizationId==originalDepartmentModel.organizationId){
  1048. departmentModel.commission=originalDepartmentModel.commission;
  1049. }
  1050. }
  1051. Boolean existsFlag=[self isExistsBusinessDepartment:departmentModel departmentList:_originalSecondaryDepartmentList];
  1052. if(!existsFlag){
  1053. departmentModel.commission=@"100";
  1054. }
  1055. }
  1056. else{
  1057. departmentModel.commission=@"100";
  1058. }
  1059. }
  1060. }
  1061. _mainDepartmentCommission=_mainDepartmentModel.commission;
  1062. NSString *departmentStr=@"";
  1063. departmentStr=[NSString stringWithFormat:@"%@%@",_mainDepartmentModel.organizationName,@","];
  1064. for(DepartmentFrame *frame in _secondaryDepartmentList){
  1065. BusinessDepartmentModel *model=frame.departmentModel;
  1066. departmentStr= [NSString stringWithFormat:@"%@%@%@",departmentStr,model.organizationName,@","];
  1067. }
  1068. _organizationId=[NSString stringWithFormat:@"%ld", _mainDepartmentModel.organizationId];
  1069. _organizationCode=_mainDepartmentModel.organizationCode;
  1070. departmentStr=[departmentStr substringToIndex:departmentStr.length-1];
  1071. _lblOrganizationName.text=departmentStr;
  1072. }
  1073. -(Boolean)isExistsBusinessDepartment:(BusinessDepartmentModel*)departmentModel departmentList:(NSMutableArray*)departmentList{
  1074. Boolean flag=NO;
  1075. for(DepartmentFrame *departmentFrame in departmentList){
  1076. if(departmentModel.organizationId==departmentFrame.departmentModel.organizationId){
  1077. flag=YES;
  1078. break;
  1079. }
  1080. }
  1081. return flag;
  1082. }
  1083. -(void)showEarnestInfo:(NSMutableArray*)earnestList{
  1084. double sum = 0;
  1085. _earnestCheckedList=[[NSMutableArray alloc]init];
  1086. for(EarnestModel *model in earnestList){
  1087. NSString *earnestSum=model.earnestSum;
  1088. double earnestSumValue=[earnestSum doubleValue];
  1089. if(earnestSumValue>0){
  1090. sum+=earnestSumValue;
  1091. [_earnestCheckedList addObject:model];
  1092. }
  1093. }
  1094. NSString *sumStr=[NSString stringWithFormat:@"%.4f",sum];
  1095. _paymentAmount=sumStr;
  1096. _lblPayment.text=sumStr;
  1097. [self.homeVC calculate:@"orderDetail"];
  1098. }
  1099. -(void)showIntermediateCustomerInfo:(NSMutableArray*)intermediateCustomerList{
  1100. if(intermediateCustomerList.count == 0){
  1101. return;
  1102. }
  1103. _intermediateCustomerCheckedList=intermediateCustomerList;
  1104. if(_editFLag){
  1105. if(_intermediateCustomerCheckedList!=nil&&_intermediateCustomerCheckedList.count>0){
  1106. for(IntermediateCustomerFrame *intemediateCustomerFrame in _intermediateCustomerCheckedList){
  1107. IntermediateCustomerModel *intermediateCustomerModel= intemediateCustomerFrame.intermediateCustomerModel;
  1108. if(_originalIntermediateCustomerList!=nil&&_originalIntermediateCustomerList.count>0){
  1109. for(IntermediateCustomerFrame *originalIntermediateCustomerFrame in _originalIntermediateCustomerList){
  1110. if(intermediateCustomerModel.intermediateCustomerStaffId==originalIntermediateCustomerFrame.intermediateCustomerModel.intermediateCustomerStaffId){
  1111. intermediateCustomerModel.commission=originalIntermediateCustomerFrame.intermediateCustomerModel.commission;
  1112. }
  1113. }
  1114. Boolean existsFlag=[self isExistsIntermediateCustomer:intermediateCustomerModel intermediateCustomerList:_originalIntermediateCustomerList];
  1115. if(!existsFlag){
  1116. intermediateCustomerModel.commission=@"100";
  1117. }
  1118. }
  1119. else{
  1120. intermediateCustomerModel.commission=@"100";
  1121. }
  1122. }
  1123. }
  1124. }
  1125. NSString *intermediateCustomerStr=@"";
  1126. for(IntermediateCustomerFrame *frame in _intermediateCustomerCheckedList){
  1127. IntermediateCustomerModel *model=frame.intermediateCustomerModel;
  1128. intermediateCustomerStr= [NSString stringWithFormat:@"%@%@%@",intermediateCustomerStr,model.intermediateCustomerStaffName,@","];
  1129. }
  1130. intermediateCustomerStr=[intermediateCustomerStr substringToIndex:intermediateCustomerStr.length-1];
  1131. _lblIntermediateCustomer.text=intermediateCustomerStr;
  1132. }
  1133. -(Boolean)isExistsIntermediateCustomer:(IntermediateCustomerModel*)customerModel intermediateCustomerList:(NSMutableArray*)intermediateCustomerList{
  1134. Boolean flag=NO;
  1135. for(IntermediateCustomerFrame *intermediateCustomerFrame in intermediateCustomerList )
  1136. {
  1137. if(customerModel.intermediateCustomerStaffId==intermediateCustomerFrame.intermediateCustomerModel.intermediateCustomerStaffId){
  1138. flag=YES;
  1139. break;
  1140. }
  1141. }
  1142. return flag;
  1143. }
  1144. -(BusinessDepartmentModel*)getMainBusinessDepartment:(NSMutableArray*)departmentList{
  1145. BusinessDepartmentModel *mainDepartmentModel;
  1146. for(DepartmentFrame *frame in departmentList){
  1147. if(frame.departmentModel.isMainDepartmentStatus){
  1148. mainDepartmentModel=frame.departmentModel;
  1149. break;
  1150. }
  1151. }
  1152. return mainDepartmentModel;
  1153. }
  1154. -(NSMutableArray*)getSecondaryDepartmentList:(NSMutableArray*)departmentList{
  1155. NSMutableArray *secondaryDepartmentList=[[NSMutableArray alloc]init];
  1156. for(DepartmentFrame *frame in departmentList){
  1157. if(!frame.departmentModel.isMainDepartmentStatus){
  1158. [secondaryDepartmentList addObject:frame];
  1159. }
  1160. }
  1161. return secondaryDepartmentList;
  1162. }
  1163. //文本回调
  1164. - (void)textEnd:(id)sender customerCode:(NSString*)code
  1165. customerId:(NSString*)customerId customerName:(NSString*)customerName
  1166. {
  1167. UIButton *btn=(UIButton *)sender;
  1168. if(code!=nil){
  1169. _txtCustomerCode.text=code;
  1170. }
  1171. if(btn.tag==1301) //客户编码
  1172. {
  1173. if(_txtCustomerCode.text.length==0){
  1174. return;
  1175. }
  1176. [self setTextEnable:YES];
  1177. [self searchCustomerInfo:_txtCustomerCode.text];
  1178. }
  1179. }
  1180. -(void)searchOnlyByCustomerCode
  1181. {
  1182. if(_txtCustomerCode.text.length==0)
  1183. {
  1184. return;
  1185. }
  1186. [self setTextEnable:YES];
  1187. [self searchCustomerInfo:_txtCustomerCode.text];
  1188. }
  1189. -(void)showSaleManInfo:(SalesManModel*)mainSalesMan secondarySalesMan:(NSMutableArray*)secondarySalesManList salesmanSelectedList:(NSMutableArray*)salesmanSelectedList{
  1190. _mainSalesMan=mainSalesMan;
  1191. _secondarySalesManList=secondarySalesManList;
  1192. _salesManCheckedList=salesmanSelectedList;
  1193. _mainSalesManCommission=_mainSalesMan.commission;
  1194. NSString *salesmanStr=@"";
  1195. salesmanStr=[NSString stringWithFormat:@"%@%@",_mainSalesMan.staffName,@","];
  1196. for(SalesManFrame *frame in _secondarySalesManList){
  1197. SalesManModel *model=frame.salesmanModel;
  1198. salesmanStr= [NSString stringWithFormat:@"%@%@%@",salesmanStr,model.staffName,@","];
  1199. }
  1200. salesmanStr=[salesmanStr substringToIndex:salesmanStr.length-1];
  1201. _lblStaff.text=salesmanStr;
  1202. _staffName=_mainSalesMan.staffName;
  1203. _staffId=[NSString stringWithFormat:@"%d",_mainSalesMan.staffId];
  1204. }
  1205. -(Boolean) isExistsSalsman:(SalesManModel*)salesmanModel salesmanList:(NSMutableArray*)salesmanList{
  1206. Boolean flag=NO;
  1207. for(SalesManFrame *salesmanFrame in salesmanList){
  1208. if(salesmanModel.staffId==salesmanFrame.salesmanModel.staffId){
  1209. flag=YES;
  1210. break;
  1211. }
  1212. }
  1213. return flag;
  1214. }
  1215. -(void)searchCustomerInfo:(NSString *)code
  1216. {
  1217. NSString *urlStr = ServerURL;
  1218. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  1219. [dict setObject:@"SearchCustomerAndroid" forKey:@"Action"];
  1220. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  1221. [dict setObject:kkUserCode forKey:@"UserCode"];
  1222. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  1223. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  1224. [dict setObject:code forKey:@"CustomerCode"];
  1225. self.mDownManager = [[ASIDownManager alloc] init];
  1226. _mDownManager.delegate = self;
  1227. _mDownManager.onRequestSuccess = @selector(onCustomerCodeLoadFinish:);
  1228. _mDownManager.onRequestFail = @selector(onCustomerCodeLoadFail:);
  1229. [_mDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  1230. }
  1231. //进度条取消函数
  1232. - (void)cancel {
  1233. [self stopLoading];
  1234. }
  1235. //客户编码查询成功接口
  1236. - (void)onCustomerCodeLoadFinish:(ASIDownManager *)sender {
  1237. NSDictionary *dic = [sender.mWebStr JSONValue];
  1238. [self cancel];
  1239. if (dic && [dic isKindOfClass:[NSDictionary class]]) {
  1240. int iStatus = [[dic objectForKey:@"Status"] intValue];
  1241. NSString *message=[dic objectForKey:@"Message"];
  1242. if (iStatus == 0) {
  1243. NSArray * approvArr=[dic objectForKey:@"Result"];
  1244. if(approvArr!=nil&&approvArr.count>0)
  1245. {
  1246. _orderSearchList=[[NSMutableArray alloc]init];
  1247. for(int i=0;i<approvArr.count;i++){
  1248. NSDictionary *dic=approvArr[0];
  1249. NSInteger fillingId=[[dic objectForKey:@"FilingID"]integerValue];
  1250. NSInteger customerId=[[dic objectForKey:@"CustomerID"]integerValue];
  1251. NSString *customerCode=[dic objectForKey:@"CustomerCode"];
  1252. NSString *customerName=[dic objectForKey:@"CustomerName"];
  1253. NSString *channelName=[dic objectForKey:@"ChannelName"];
  1254. NSInteger channelId=[[dic objectForKey:@"ChannelID"]integerValue];
  1255. NSString *telephone=[dic objectForKey:@"Telephone"];
  1256. NSString *address=[dic objectForKey:@"Address"];
  1257. NSString *staffName=[dic objectForKey:@"StaffName"];
  1258. NSInteger staffId=[[dic objectForKey:@"StaffID"]integerValue];
  1259. NSInteger customerTypeId=[[dic objectForKey:@"CustomerType"]integerValue];
  1260. NSString *customerTypeName=[dic objectForKey:@"CustomerTypeName"];
  1261. NSInteger organizationId=[[dic objectForKey:@"OrganizationID"]integerValue];
  1262. NSString *organizationName=[dic objectForKey:@"OrganizationName"];
  1263. NSString *organizationCode=[dic objectForKey:@"OrganizationCode"];
  1264. NSInteger purviewFlag=[[dic objectForKey:@"PurviewFlag"]integerValue];
  1265. NSInteger districtId=[[dic objectForKey:@"DistrictID"]integerValue];
  1266. NSString* districtCode=[dic objectForKey:@"DistrictCode"];
  1267. NSString *districtName=[dic objectForKey:@"DistrictName"];
  1268. CustomerCodeSearchModel *searchModel=[CustomerCodeSearchModel new];
  1269. searchModel.filingId=fillingId;
  1270. searchModel.customerId=customerId;
  1271. searchModel.customerCode=customerCode;
  1272. searchModel.customerName=customerName;
  1273. searchModel.channelId=channelId;
  1274. searchModel.channelName=channelName;
  1275. searchModel.telephone=telephone;
  1276. searchModel.address=address;
  1277. searchModel.staffId=staffId;
  1278. searchModel.staffName=staffName;
  1279. searchModel.districtId=districtId;
  1280. searchModel.districtCode=districtCode;
  1281. searchModel.districtName=districtName;
  1282. searchModel.customerTypeId=customerTypeId;
  1283. searchModel.customerTypeName=customerTypeName;
  1284. searchModel.organizationId=organizationId;
  1285. searchModel.organizationCode=organizationCode;
  1286. searchModel.organizationName=organizationName;
  1287. searchModel.purviewFlag=purviewFlag;
  1288. [_orderSearchList addObject:searchModel];
  1289. }
  1290. int totalCount = 0;
  1291. for(int i=0;i<_orderSearchList.count;i++){
  1292. CustomerCodeSearchModel *searchModel1= [_orderSearchList objectAtIndex:i];
  1293. NSInteger purviewFlag=searchModel1.purviewFlag;
  1294. if(purviewFlag==0){
  1295. ++totalCount;
  1296. }
  1297. }
  1298. if(totalCount==_orderSearchList.count){
  1299. [self showAlertViewText:@"此客户编码无访问权限"];
  1300. return;
  1301. }
  1302. CustomerCodeSearchModel *customerCodeSearchModel=[self getSearchInfoModel:_orderSearchList];
  1303. if(customerCodeSearchModel!=nil){
  1304. [self showData:customerCodeSearchModel];
  1305. [self setTextEnabled:NO];
  1306. }
  1307. }
  1308. }
  1309. else if(iStatus == ActionResultStatusAuthError
  1310. ||iStatus == ActionResultStatusNoLogin
  1311. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue)
  1312. {
  1313. [self showReLoginDialog:message];
  1314. [self setTextEnabled:YES];
  1315. return;
  1316. }
  1317. else {
  1318. // [self showAlertViewText:message];
  1319. [self setTextEnabled:YES];
  1320. }
  1321. }
  1322. }
  1323. //客户编码查询失败接口
  1324. - (void)onCustomerCodeLoadFail:(ASIDownManager *)sender {
  1325. [self cancel];
  1326. [self setTextEnabled:YES];
  1327. [self showAlertViewText:@"加载失败"];
  1328. }
  1329. //客户编码列表查询
  1330. -(void)searchCustomerCode{
  1331. self.hidesBottomBarWhenPushed = YES;
  1332. CustomerCodeSearchVC *customerCodeVC=[[ CustomerCodeSearchVC alloc] init];
  1333. customerCodeVC.orderDelegate=self;
  1334. customerCodeVC.subview=YES;
  1335. customerCodeVC.flag=@"salesOrder";
  1336. [self.orderNav pushViewController:customerCodeVC animated:YES];
  1337. }
  1338. -(void)refreshEditStatus{
  1339. if(_editStatus==5||_editStatus==4){
  1340. _txtCustomerName.enabled=NO;
  1341. _txtCustomerCode.enabled=NO;
  1342. _btnCustomerCode.enabled=NO;
  1343. _txtTelephone.enabled=NO;
  1344. _lblOrganizationName.userInteractionEnabled=NO;
  1345. _lblStaff.userInteractionEnabled=NO;
  1346. _lblChannel.userInteractionEnabled=NO;
  1347. _lblPayment.userInteractionEnabled=NO;
  1348. _lblIntermediateCustomer.userInteractionEnabled=NO;
  1349. _txtContractNo.enabled=NO;
  1350. }
  1351. else if(_editStatus==7){
  1352. _btnCustomerCode.enabled=NO;
  1353. _txtCustomerName.enabled=NO;
  1354. _txtCustomerCode.enabled=NO;
  1355. _txtTelephone.enabled=NO;
  1356. _lblOrganizationName.userInteractionEnabled=NO;
  1357. _lblStaff.userInteractionEnabled=NO;
  1358. _lblChannel.userInteractionEnabled=NO;
  1359. _lblCustomerArea.userInteractionEnabled=NO;
  1360. _txtCustomerAddress.enabled=NO;
  1361. // _orderGoodsDetailVC.btnSearch.enabled=NO;
  1362. _lblCustomerType.userInteractionEnabled=NO;
  1363. _lblPayment.userInteractionEnabled=NO;
  1364. _lblIntermediateCustomer.userInteractionEnabled=NO;
  1365. _txtContractNo.enabled=NO;
  1366. _txtContactPerson.enabled=NO;
  1367. _txtContactWay.enabled=NO;
  1368. _lblInstallDate.userInteractionEnabled=NO;
  1369. _lblDeliveryDate.userInteractionEnabled=NO;
  1370. _lblFloor.userInteractionEnabled=NO;
  1371. _lblDecorationProgress.userInteractionEnabled=NO;
  1372. }
  1373. else if(_editStatus==10){
  1374. _txtCustomerName.enabled=NO;
  1375. _txtCustomerCode.enabled=NO;
  1376. _btnCustomerCode.enabled=NO;
  1377. _txtTelephone.enabled=NO;
  1378. _lblOrganizationName.userInteractionEnabled=NO;
  1379. _lblStaff.userInteractionEnabled=NO;
  1380. _lblChannel.userInteractionEnabled=NO;
  1381. _lblCustomerArea.userInteractionEnabled=NO;
  1382. _txtCustomerAddress.enabled=NO;
  1383. _txtRemarks.enabled=NO;
  1384. _lblCustomerType.userInteractionEnabled=NO;
  1385. _lblPayment.userInteractionEnabled=NO;
  1386. _lblIntermediateCustomer.userInteractionEnabled=NO;
  1387. _txtContractNo.enabled=NO;
  1388. _txtContactPerson.enabled=NO;
  1389. _txtContactWay.enabled=NO;
  1390. // _orderGoodsDetailVC.btnSearch.enabled=NO;
  1391. _lblInstallDate.userInteractionEnabled=NO;
  1392. _lblDeliveryDate.userInteractionEnabled=NO;
  1393. _lblFloor.userInteractionEnabled=NO;
  1394. _lblDecorationProgress.userInteractionEnabled=NO;
  1395. }
  1396. }
  1397. -(void)setTextEnable:(Boolean) enabled{
  1398. _lblChannel.userInteractionEnabled=enabled;
  1399. _lblCustomerType.userInteractionEnabled=enabled;
  1400. _txtCustomerName.enabled=enabled;
  1401. }
  1402. -(void)getCustomerOrder:(CustomerCodeSearchModel*)searchModel{
  1403. [self showData:searchModel];
  1404. [self setTextEnabled:NO];
  1405. }
  1406. -(void)showData:(CustomerCodeSearchModel*)searchModel{
  1407. _channelId=[NSString stringWithFormat:@"%ld",(long)searchModel.channelId];
  1408. _channelName=searchModel.channelName;
  1409. _lblChannel.text=_channelName;
  1410. NSInteger organizationIdValue= searchModel.organizationId;
  1411. _organizationId =[NSString stringWithFormat:@"%d",organizationIdValue] ;
  1412. _organizationCode = [searchModel organizationCode];
  1413. _organizationName = [searchModel organizationName];
  1414. _customerCode=searchModel.customerCode;
  1415. _telephone=searchModel.telephone;
  1416. _txtTelephone.text=_telephone;
  1417. _filingId=[NSString stringWithFormat:@"%ld",(long)searchModel.filingId];
  1418. if (_customerCode==nil||[_customerCode isEqualToString:@""]) {
  1419. _txtCustomerCode.text=_telephone;
  1420. } else {
  1421. _txtCustomerCode.text=_customerCode;
  1422. }
  1423. _customerName=searchModel.customerName;
  1424. _txtCustomerName.text=_customerName;
  1425. _address=searchModel.address;
  1426. _txtCustomerAddress.text=_address;
  1427. _customerTypeId=[NSString stringWithFormat:@"%ld",(long)searchModel.customerTypeId];
  1428. _customerId=[NSString stringWithFormat:@"%ld",(long)searchModel.customerId];
  1429. _customerAreaId=[NSString stringWithFormat:@"%ld",(long)searchModel.districtId];
  1430. _customerAreaName=searchModel.districtName;
  1431. _lblCustomerArea.text=_customerAreaName;
  1432. _customerTypeName=searchModel.customerTypeName;
  1433. _lblCustomerType.text=_customerTypeName;
  1434. _staffId=[NSString stringWithFormat:@"%ld",(long)searchModel.staffId];
  1435. _staffName=searchModel.staffName;
  1436. _mainDepartmentModel=[BusinessDepartmentModel new];
  1437. _mainDepartmentModel.organizationId=[_organizationId integerValue];
  1438. _mainDepartmentModel.organizationCode=_organizationCode;
  1439. _mainDepartmentModel.organizationName=_organizationName;
  1440. _mainDepartmentModel.commission=@"100";
  1441. _mainDepartmentModel.isCheckedStatus=YES;
  1442. _mainDepartmentModel.isMainDepartmentStatus=YES;
  1443. if(!_editFLag){
  1444. if(_departmentDataList!=nil&&_departmentDataList.count>0){
  1445. for(DepartmentFrame *departmentFrame in _departmentDataList){
  1446. if(_mainDepartmentModel.organizationId==departmentFrame.departmentModel.organizationId){
  1447. departmentFrame.departmentModel.isCheckedStatus=YES;
  1448. departmentFrame.departmentModel.isMainDepartmentStatus=YES;
  1449. departmentFrame.departmentModel.commission=@"100";
  1450. }
  1451. else{
  1452. departmentFrame.departmentModel.isCheckedStatus=NO;
  1453. departmentFrame.departmentModel.isMainDepartmentStatus=NO;
  1454. departmentFrame.departmentModel.commission=@"100";
  1455. }
  1456. }
  1457. }
  1458. }
  1459. else{
  1460. if(_mainDepartmentModel.organizationId==_originalMainDepartmentModel.organizationId){
  1461. _mainDepartmentModel.commission=_originalMainDepartmentModel.commission;
  1462. }
  1463. else{
  1464. _mainDepartmentModel.commission=@"100";
  1465. }
  1466. for(DepartmentFrame *departmentFrame in _departmentDataList){
  1467. if(_mainDepartmentModel.organizationId==departmentFrame.departmentModel.organizationId){
  1468. departmentFrame.departmentModel.isCheckedStatus=YES;
  1469. departmentFrame.departmentModel.isMainDepartmentStatus=YES;
  1470. departmentFrame.departmentModel.commission=_mainDepartmentModel.commission;
  1471. }
  1472. else{
  1473. departmentFrame.departmentModel.isCheckedStatus=NO;
  1474. departmentFrame.departmentModel.isMainDepartmentStatus=NO;
  1475. }
  1476. }
  1477. }
  1478. _lblOrganizationName.text=_organizationName;
  1479. _mainDepartmentCommission=_mainDepartmentModel.commission;
  1480. _mainSalesMan=[SalesManModel new];
  1481. _mainSalesMan.staffId=[_staffId integerValue];
  1482. _mainSalesMan.staffName=_staffName;
  1483. if(!_editFLag){
  1484. if(_salesmanDataList!=nil&&_salesmanDataList.count>0){
  1485. for(SalesManFrame *salesmanFrame in _salesmanDataList){
  1486. if(_mainSalesMan.staffId==salesmanFrame.salesmanModel.staffId){
  1487. salesmanFrame.salesmanModel.isMainSalesManStatus=YES;
  1488. salesmanFrame.salesmanModel.commission=@"100";
  1489. salesmanFrame.salesmanModel.isCheckedStatus=YES;
  1490. }
  1491. else{
  1492. salesmanFrame.salesmanModel.isMainSalesManStatus=NO;
  1493. salesmanFrame.salesmanModel.commission=@"100";
  1494. salesmanFrame.salesmanModel.isCheckedStatus=NO;
  1495. }
  1496. }
  1497. }
  1498. }
  1499. else{
  1500. if(_mainSalesMan.staffId==_originalMainSalesMan.staffId){
  1501. _mainSalesMan.commission=_originalMainSalesMan.commission;
  1502. }
  1503. else{
  1504. _mainSalesMan.commission=@"100";
  1505. }
  1506. if(_salesmanDataList!=nil&&_salesmanDataList.count>0){
  1507. for(SalesManFrame *salesmanFrame in _salesmanDataList){
  1508. if(_mainSalesMan.staffId==salesmanFrame.salesmanModel.staffId){
  1509. salesmanFrame.salesmanModel.isMainSalesManStatus=YES;
  1510. salesmanFrame.salesmanModel.commission=_mainSalesMan.commission;
  1511. salesmanFrame.salesmanModel.isCheckedStatus=YES;
  1512. }
  1513. else{
  1514. salesmanFrame.salesmanModel.isMainSalesManStatus=NO;
  1515. salesmanFrame.salesmanModel.isCheckedStatus=NO;
  1516. }
  1517. }
  1518. }
  1519. }
  1520. _lblStaff.text=_staffName;
  1521. _mainSalesManCommission=_mainSalesMan.commission;
  1522. if(_secondaryDepartmentList!=nil&&_secondaryDepartmentList.count>0){
  1523. [_secondaryDepartmentList removeAllObjects];
  1524. }
  1525. if(_secondarySalesManList!=nil &&_secondarySalesManList.count>0){
  1526. [_secondarySalesManList removeAllObjects];
  1527. }
  1528. if((_orderGoodsDetailVC.inventoryGoodsDetailList!=nil&&_orderGoodsDetailVC.inventoryGoodsDetailList.count==0)||_orderGoodsDetailVC.inventoryGoodsDetailList==nil){
  1529. return;
  1530. }
  1531. [self setTextEnable:NO];
  1532. [self updateMarkedPrice];
  1533. }
  1534. /**
  1535. 更新商品售价
  1536. */
  1537. - (void)updateGoodsSalePrice
  1538. {
  1539. // [self startLoading];
  1540. NSString *urlStr = ServerURL;
  1541. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  1542. [dict setObject:@"GetOrderPriceIphone" forKey:@"Action"];
  1543. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  1544. [dict setObject:kkUserCode forKey:@"UserCode"];
  1545. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  1546. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  1547. [dict setObject:_organizationId forKey:@"OrganizationID"];
  1548. [dict setObject:_organizationCode forKey:@"OrganizationCode"];
  1549. [dict setObject:_organizationCode forKey:@"OrganizationCode"];
  1550. [dict setObject:(_channelId==nil?@"":_channelId) forKey:@"ChannelID"];
  1551. NSString * orderDetail=[self checkedSalePriceJSON];
  1552. [dict setObject:orderDetail forKey:@"OrderDetail"];
  1553. self.mDownManager = [[ASIDownManager alloc] init];
  1554. _mDownManager.delegate = self;
  1555. _mDownManager.onRequestSuccess = @selector(onSalesPriceLoadFinish:);
  1556. _mDownManager.onRequestFail = @selector(onSalesPriceLoadFail:);
  1557. [_mDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  1558. }
  1559. - (void)onSalesPriceLoadFinish:(ASIDownManager *)sender {
  1560. [self cancel];
  1561. // 服务器返回数据
  1562. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  1563. // 服务器返回数据状态值
  1564. int iStatus = resultModel.status;
  1565. // 服务器返回数据消息
  1566. NSString *message = resultModel.message;
  1567. // 服务器返回数据状态值正确
  1568. if (iStatus == 0) {
  1569. // 服务器返回数据结果
  1570. NSArray * approvArr = (NSArray *)resultModel.result;
  1571. if(approvArr != nil && approvArr.count > 0)
  1572. {
  1573. NSMutableArray *orderPriceList=[[NSMutableArray alloc]init];
  1574. for(int i=0;i<approvArr.count;i++)
  1575. {
  1576. NSDictionary *orderDic=[approvArr objectAtIndex:i];
  1577. int codeId=[[orderDic objectForKey:@"CodeID"]intValue];
  1578. int gradeId=[[orderDic objectForKey:@"GradeID"]intValue];
  1579. double orderPrice;
  1580. if([[orderDic allKeys]containsObject:@"OrderPrice"])
  1581. {
  1582. orderPrice=[[orderDic objectForKey:@"OrderPrice"]doubleValue];
  1583. }
  1584. else{
  1585. orderPrice=0;
  1586. }
  1587. InventoryListModel *goodsModel=[InventoryListModel new];
  1588. [goodsModel setCodeId:codeId];
  1589. [goodsModel setGradeId:gradeId];
  1590. [goodsModel setSalesPrice:[NSString stringWithFormat:@"%.lf",orderPrice]];
  1591. [orderPriceList addObject:goodsModel];
  1592. }
  1593. for(int i=0;i<orderPriceList.count;i++)
  1594. {
  1595. InventoryListModel *inventoryModel=[orderPriceList objectAtIndex:i];
  1596. if(_orderGoodsDetailVC.inventoryGoodsDetailList!=nil&&_orderGoodsDetailVC.inventoryGoodsDetailList.count>0)
  1597. {
  1598. for(int i=0;i<_orderGoodsDetailVC.inventoryGoodsDetailList.count;i++)
  1599. {
  1600. InventoryListModel *goodsModel=[_orderGoodsDetailVC.inventoryGoodsDetailList objectAtIndex:i];
  1601. if(goodsModel.circulateType==1&&goodsModel.acreageFlag)
  1602. {
  1603. double orderPrice=[goodsModel.acreagePrice doubleValue]*goodsModel.acreage;
  1604. [goodsModel setSalesPrice:[NSString stringWithFormat:@"%.6f",orderPrice]];
  1605. }
  1606. else
  1607. {
  1608. if(goodsModel.promotionDetailId==nil||[goodsModel.promotionDetailId isEqualToString:@""])
  1609. {
  1610. if((inventoryModel.codeId==goodsModel.codeId)&&(inventoryModel.gradeId==goodsModel.gradeId))
  1611. {
  1612. [goodsModel setSalesPrice:inventoryModel.salesPrice];
  1613. }
  1614. }
  1615. }
  1616. }
  1617. }
  1618. }
  1619. [self updateMarkedPrice];
  1620. }
  1621. }
  1622. else if(iStatus == ActionResultStatusAuthError
  1623. ||iStatus == ActionResultStatusNoLogin
  1624. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
  1625. [self showReLoginDialog:message];
  1626. return;
  1627. }else {
  1628. [self showAlertViewText:message];
  1629. }
  1630. }
  1631. /**
  1632. 产品价格加载失败接口
  1633. @param sender
  1634. */
  1635. - (void)onSalesPriceLoadFail:(ASIDownManager *)sender {
  1636. [self cancel];
  1637. [self showAlertViewText:@"网络异常"];
  1638. }
  1639. -(void)updateMarkedPrice{
  1640. // [self startLoading];
  1641. NSString *urlStr = ServerURL;
  1642. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  1643. [dict setObject:@"GetMarkedPriceIphone" forKey:@"Action"];
  1644. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  1645. [dict setObject:kkUserCode forKey:@"UserCode"];
  1646. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  1647. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  1648. [dict setObject: _organizationCode forKey:@"OrganizationCode"];
  1649. [dict setObject:(_channelId==nil?@"":_channelId) forKey:@"ChannelID"];
  1650. NSString * orderDetail=[self checkedSalePriceJSON];
  1651. [dict setObject:orderDetail forKey:@"OrderDetail"];
  1652. SBJsonWriter *write = [[SBJsonWriter alloc] init];
  1653. NSString *value = [write stringWithObject:dict];
  1654. self.mDownManager = [[ASIDownManager alloc] init];
  1655. _mDownManager.delegate = self;
  1656. _mDownManager.onRequestSuccess = @selector(onMarkedPriceLoadFinish:);
  1657. _mDownManager.onRequestFail = @selector(onMarkedPriceLoadFail:);
  1658. [_mDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  1659. }
  1660. //获得选中的商品的JSON数据,用于获取商品售价
  1661. -(NSString *)checkedSalePriceJSON
  1662. {
  1663. NSMutableArray *finalArr=[NSMutableArray new];
  1664. if(_orderGoodsDetailVC.inventoryGoodsDetailList!=nil&&_orderGoodsDetailVC.inventoryGoodsDetailList.count>0){
  1665. for(InventoryListModel *inventoryModel in _orderGoodsDetailVC.inventoryGoodsDetailList){
  1666. NSInteger codeIdValue= inventoryModel.codeId;
  1667. NSInteger gradeIdValue=inventoryModel.gradeId;
  1668. NSString *gradeID=[NSString stringWithFormat:@"%ld",gradeIdValue];
  1669. NSString *codeId=[NSString stringWithFormat:@"%ld",codeIdValue];
  1670. if(codeId!=nil&&gradeID!=nil){
  1671. [finalArr addObject:@{@"CodeID": codeId,@"GradeID":gradeID}];
  1672. }
  1673. }
  1674. }
  1675. if(_orderGiftDetailVC.inventoryGiftDetailList!=nil&&_orderGiftDetailVC.inventoryGiftDetailList.count>0)
  1676. {
  1677. for(InventoryListModel *inventoryModel in _orderGiftDetailVC.inventoryGiftDetailList){
  1678. NSInteger codeIdValue= inventoryModel.codeId;
  1679. NSString *codeId=[NSString stringWithFormat:@"%ld",codeIdValue];
  1680. NSInteger gradeIdValue=inventoryModel.gradeId;
  1681. NSString *gradeID=[NSString stringWithFormat:@"%ld",gradeIdValue];
  1682. if(codeId!=nil&&gradeID!=nil){
  1683. [finalArr addObject:@{@"CodeID": codeId,@"GradeID":gradeID}];
  1684. }
  1685. }
  1686. }
  1687. SBJsonWriter *write = [[SBJsonWriter alloc] init];
  1688. NSString *value = [write stringWithObject:finalArr];
  1689. return value;
  1690. }
  1691. //客户编码查询成功接口
  1692. - (void)onMarkedPriceLoadFinish:(ASIDownManager *)sender {
  1693. NSDictionary *dic = [sender.mWebStr JSONValue];
  1694. [self cancel];
  1695. if (dic && [dic isKindOfClass:[NSDictionary class]]) {
  1696. int iStatus = [[dic objectForKey:@"Status"] intValue];
  1697. NSString *message=[dic objectForKey:@"Message"];
  1698. if (iStatus == 0) {
  1699. NSArray * approvArr=[dic objectForKey:@"Result"];
  1700. if(approvArr!=nil&&approvArr.count>0){
  1701. [self updateGoodsMarkedPrice:approvArr];
  1702. }
  1703. }
  1704. else if(iStatus == ActionResultStatusAuthError
  1705. ||iStatus == ActionResultStatusNoLogin
  1706. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue)
  1707. {
  1708. [self showReLoginDialog:message];
  1709. return;
  1710. }
  1711. else {
  1712. [self showAlertViewText:message];
  1713. }
  1714. }
  1715. }
  1716. //客户编码查询失败接口
  1717. - (void)onMarkedPriceLoadFail:(ASIDownManager *)sender {
  1718. [self cancel];
  1719. [self showAlertViewText:@"加载失败"];
  1720. }
  1721. //更新商品标价
  1722. -(void)updateGoodsMarkedPrice :(NSArray *)priceArr;
  1723. {
  1724. for(NSDictionary *dic in priceArr){
  1725. //渠道价格
  1726. NSString * channelPrice = [dic objectForKey:@"ChannelPrice"];
  1727. //策略价格
  1728. NSString * basePrice = [dic objectForKey:@"BasePrice"];
  1729. //基础标价
  1730. NSString * standardPrice = [dic objectForKey:@"StandardPrice"];
  1731. NSString *codeId = [NSString stringWithFormat:@"%@",[dic objectForKey:@"CodeID"]];
  1732. NSString *gradeId = [NSString stringWithFormat:@"%@",[dic objectForKey:@"GradeID"]];
  1733. for( InventoryListModel *inventoryModel in _orderGoodsDetailVC.inventoryGoodsDetailList){
  1734. if([[NSString stringWithFormat:@"%ld",inventoryModel.codeId] isEqualToString:codeId]&&[[NSString stringWithFormat:@"%ld",inventoryModel.gradeId] isEqualToString:gradeId]){
  1735. //标价取值顺序: 渠道价格->策略价格->基础标价->0
  1736. if(channelPrice != nil)
  1737. {
  1738. inventoryModel.markedPrice=[NSString stringWithFormat:@"%lf",[channelPrice doubleValue]];
  1739. }
  1740. else if(basePrice != nil){
  1741. inventoryModel.markedPrice=[NSString stringWithFormat:@"%lf",[basePrice doubleValue]];
  1742. }
  1743. else if(standardPrice != nil){
  1744. inventoryModel.markedPrice=[NSString stringWithFormat:@"%lf",[standardPrice doubleValue]];
  1745. }
  1746. else{
  1747. inventoryModel.markedPrice=@"0.00";
  1748. }
  1749. // 2017-7-26 关宏厚 end
  1750. if(inventoryModel.salesPrice == nil||[inventoryModel.salesPrice isEqualToString:@"0"]||[inventoryModel.salesPrice isEqualToString:@"(null)"]){
  1751. inventoryModel.salesPrice = [inventoryModel.markedPrice copy];
  1752. }
  1753. double markedPrice=[inventoryModel.markedPrice doubleValue];
  1754. if(inventoryModel.circulateType==1&&inventoryModel.acreageFlag)
  1755. {
  1756. if(markedPrice>0)
  1757. {
  1758. double discount=[inventoryModel.acreagePrice doubleValue]*100/markedPrice;
  1759. [inventoryModel setDiscount:[NSString stringWithFormat:@"%.2f",discount]];
  1760. }
  1761. else
  1762. {
  1763. [inventoryModel setDiscount:@"100"];
  1764. }
  1765. }
  1766. else
  1767. {
  1768. if(markedPrice>0)
  1769. {
  1770. double orderPrice=[inventoryModel.salesPrice doubleValue];
  1771. double discount=orderPrice*100/markedPrice;
  1772. [inventoryModel setDiscount:[NSString stringWithFormat:@"%.2f",discount]];
  1773. }
  1774. else
  1775. {
  1776. [inventoryModel setDiscount:@"100"];
  1777. }
  1778. }
  1779. }
  1780. }
  1781. for(InventoryListModel *inventoryModel in _orderGiftDetailVC.inventoryGiftDetailList)
  1782. {
  1783. if([[NSString stringWithFormat:@"%ld",inventoryModel.codeId] isEqualToString:codeId]&&[[NSString stringWithFormat:@"%ld",inventoryModel.gradeId] isEqualToString:gradeId]){
  1784. //标价取值顺序: 渠道价格->策略价格->基础标价->0
  1785. if(channelPrice != nil)
  1786. {
  1787. inventoryModel.markedPrice=[NSString stringWithFormat:@"%lf",[channelPrice doubleValue]];
  1788. }
  1789. else if(basePrice != nil){
  1790. inventoryModel.markedPrice=[NSString stringWithFormat:@"%lf",[basePrice doubleValue]];
  1791. }
  1792. else if(standardPrice != nil){
  1793. inventoryModel.markedPrice=[NSString stringWithFormat:@"%lf",[standardPrice doubleValue]];
  1794. }
  1795. else{
  1796. inventoryModel.markedPrice=@"0.00";
  1797. }
  1798. }
  1799. }
  1800. }
  1801. [_homeVC calculate:@"orderDetail"];
  1802. [_orderGoodsDetailVC.vDetailTableView reloadData];
  1803. [_orderGiftDetailVC.vDetailTableView reloadData];
  1804. }
  1805. -(CustomerCodeSearchModel*)getSearchInfoModel:(NSMutableArray*)searchInfoList{
  1806. CustomerCodeSearchModel *searchModel=nil;
  1807. for(CustomerCodeSearchModel *search in searchInfoList){
  1808. if(search.purviewFlag==1){
  1809. searchModel=search;
  1810. break;
  1811. }
  1812. }
  1813. return searchModel;
  1814. }
  1815. -(void)editSort{
  1816. self.hidesBottomBarWhenPushed = YES;
  1817. EditSortVC *sortVc = [[EditSortVC alloc] init];
  1818. sortVc.topDataList=_topDataList;
  1819. sortVc.bottomDataList=_bottomDataList;
  1820. sortVc.refreshDelegate=self;
  1821. sortVc.orderNav=self.orderNav;
  1822. [self.orderNav pushViewController:sortVc animated:YES];
  1823. }
  1824. -(void)loadMoreInfo{
  1825. _vBottom.hidden=NO;
  1826. if(!isExpand){
  1827. isExpand=YES;
  1828. [self initDynamicLayout:_bottomDataList dynamicView:_vBottom topFlag:NO];
  1829. }
  1830. else{
  1831. isExpand=NO;
  1832. [_vBottom removeFromSuperview];
  1833. _vBottom=[UIView new];
  1834. _vBottom.frame=CGRectMake(0, CGRectGetMaxY(_separator2.frame),Screen_Width, 0);
  1835. [_vBody addSubview:_vBottom];
  1836. _vBottom.frame=CGRectMake(0, CGRectGetMaxY(_separator2.frame),Screen_Width, 0);
  1837. _vBody.frame=CGRectMake(0,0,Screen_Width, CGRectGetMaxY(_vBottom.frame));
  1838. [self updateScrollView];
  1839. }
  1840. }
  1841. -(void)initDynamicLayout:(NSMutableArray *)dataList dynamicView:(UIView*)dynamicView topFlag:(Boolean) topFlag{
  1842. if(dataList!=nil&&dataList.count>0){
  1843. for(int i=0;i<dataList.count;i++){
  1844. DragItemInfo *info= dataList[i];
  1845. NSInteger componentId=info.componentId;
  1846. switch (componentId) {
  1847. case 1000:
  1848. if(_vCustomerAddress==nil){
  1849. _vCustomerAddress=[UIView new];
  1850. }
  1851. [dynamicView addSubview:_vCustomerAddress];
  1852. _vCustomerAddress.frame=CGRectMake(0,51*i,Screen_Width, 51);
  1853. if(_txtCustomerAddress==nil){
  1854. _txtCustomerAddress= [self getTextField:_vCustomerAddress labelText:@"客户地址" hintText:@"请输入客户地址" labelColor:[UIColor blackColor] tag:1000];
  1855. _txtCustomerAddress.delegate=self;
  1856. }
  1857. [self updateScrollView:topFlag dynamicView:dynamicView count:i];
  1858. break;
  1859. case 1001:
  1860. if(_vRemarks==nil){
  1861. _vRemarks=[UIView new];
  1862. }
  1863. [dynamicView addSubview:_vRemarks];
  1864. _vRemarks.frame=CGRectMake(0,51*i,Screen_Width, 51);
  1865. if(_txtRemarks==nil){
  1866. _txtRemarks= [self getTextField:_vRemarks labelText:@"备注" hintText:@"请输入备注" labelColor:[UIColor blackColor] tag:1001];
  1867. _txtRemarks.delegate=self;
  1868. }
  1869. [self updateScrollView:topFlag dynamicView:dynamicView count:i];
  1870. break;
  1871. case 1002:
  1872. if(_vPerformanceAccountingCategory==nil){
  1873. _vPerformanceAccountingCategory=[UIView new];
  1874. }
  1875. [dynamicView addSubview:_vPerformanceAccountingCategory];
  1876. _vPerformanceAccountingCategory.frame=CGRectMake(0,51*i,Screen_Width, 51);
  1877. if(_lblPerformanceAccountingCategory==nil){
  1878. _lblPerformanceAccountingCategory=[self getUILabel:_vPerformanceAccountingCategory labelText:@"业绩核算类别" hintText:@"请选择业绩核算类别" labelColor:[UIColor blackColor] isHaveRightArrow:YES tag:1002];
  1879. }
  1880. [self updateScrollView:topFlag dynamicView:dynamicView count:i];
  1881. [self allListeners];
  1882. break;
  1883. case 1003:
  1884. if(_vPayment==nil){
  1885. _vPayment=[UIView new];
  1886. }
  1887. [dynamicView addSubview:_vPayment];
  1888. _vPayment.frame=CGRectMake(0,51*i,Screen_Width, 51);
  1889. if(_lblPayment==nil){
  1890. _lblPayment=[self getUILabel:_vPayment labelText:@"定金金额" hintText:@"请选择定金金额" labelColor:[UIColor blackColor] isHaveRightArrow:YES tag:1003];
  1891. }
  1892. [self updateScrollView:topFlag dynamicView:dynamicView count:i];
  1893. [self allListeners];
  1894. break;
  1895. case 1004:
  1896. if(_vIntermediateCustomer==nil){
  1897. _vIntermediateCustomer=[UIView new];
  1898. }
  1899. [dynamicView addSubview:_vIntermediateCustomer];
  1900. _vIntermediateCustomer.frame=CGRectMake(0,51*i,Screen_Width, 51);
  1901. if(_lblIntermediateCustomer==nil){
  1902. _lblIntermediateCustomer=[self getUILabel:_vIntermediateCustomer labelText:@"中间客户" hintText:@"请选择中间客户" labelColor:[UIColor blackColor] isHaveRightArrow:YES tag:1004];
  1903. }
  1904. [self updateScrollView:topFlag dynamicView:dynamicView count:i];
  1905. [self allListeners];
  1906. break;
  1907. case 1005:
  1908. if(_vGoodsAmount==nil){
  1909. _vGoodsAmount=[UIView new];
  1910. }
  1911. [dynamicView addSubview:_vGoodsAmount];
  1912. _vGoodsAmount.frame=CGRectMake(0,51*i,Screen_Width, 51);
  1913. if(_lblGoodsAmount==nil){
  1914. _lblGoodsAmount=[self getUILabel:_vGoodsAmount labelText:@"货物总额" hintText:@"" labelColor:[UIColor blackColor] isHaveRightArrow:NO tag:1005];
  1915. }
  1916. [self updateScrollView:topFlag dynamicView:dynamicView count:i];
  1917. break;
  1918. case 1006:
  1919. if(_vTotalAmount==nil){
  1920. _vTotalAmount=[UIView new];
  1921. }
  1922. [dynamicView addSubview:_vTotalAmount];
  1923. _vTotalAmount.frame=CGRectMake(0,51*i,Screen_Width, 51);
  1924. if(_lblTotalAmount==nil){
  1925. _lblTotalAmount=[self getUILabel:_vTotalAmount labelText:@"合计总额" hintText:@"" labelColor:[UIColor blackColor] isHaveRightArrow:NO tag:1006];
  1926. }
  1927. [self updateScrollView:topFlag dynamicView:dynamicView count:i];
  1928. break;
  1929. case 1007:
  1930. if(_vContractNo==nil){
  1931. _vContractNo=[UIView new];
  1932. }
  1933. [dynamicView addSubview:_vContractNo];
  1934. _vContractNo.frame=CGRectMake(0,51*i,Screen_Width, 51);
  1935. if(_txtContractNo==nil){
  1936. _txtContractNo=[self getTextField:_vContractNo labelText:@"合同号" hintText:@"请输入合同号" labelColor:[UIColor blackColor] tag:1007];
  1937. _txtContractNo.delegate=self;
  1938. }
  1939. [self updateScrollView:topFlag dynamicView:dynamicView count:i];
  1940. break;
  1941. case 1008:
  1942. if(_vContactPerson==nil){
  1943. _vContactPerson=[UIView new];
  1944. }
  1945. [dynamicView addSubview:_vContactPerson];
  1946. _vContactPerson.frame=CGRectMake(0,51*i,Screen_Width, 51);
  1947. if(_txtContactPerson==nil){
  1948. _txtContactPerson=[self getTextField:_vContactPerson labelText:@"联系人" hintText:@"请输入联系人" labelColor:[UIColor blackColor] tag:1008];
  1949. _txtContactPerson.delegate=self;
  1950. }
  1951. [self updateScrollView:topFlag dynamicView:dynamicView count:i];
  1952. break;
  1953. case 1009:
  1954. if(_vContactWay==nil){
  1955. _vContactWay=[UIView new];
  1956. }
  1957. [dynamicView addSubview:_vContactWay];
  1958. _vContactWay.frame=CGRectMake(0,51*i,Screen_Width, 51);
  1959. if(_txtContactWay==nil){
  1960. _txtContactWay=[self getTextField:_vContactWay labelText:@"联系方式" hintText:@"请输入联系方式" labelColor:[UIColor blackColor] tag:1009];
  1961. _txtContactWay.delegate=self;
  1962. }
  1963. [self updateScrollView:topFlag dynamicView:dynamicView count:i];
  1964. break;
  1965. case 1010:
  1966. if(_vFullDiscount==nil){
  1967. _vFullDiscount=[UIView new];
  1968. }
  1969. [dynamicView addSubview:_vFullDiscount];
  1970. _vFullDiscount.frame=CGRectMake(0,51*i,Screen_Width, 51);
  1971. if(_lblFullDiscount==nil){
  1972. _lblFullDiscount=[self getUILabel:_vFullDiscount labelText:@"整单折扣" hintText:@"" labelColor:[UIColor blackColor] isHaveRightArrow:NO tag:1010];
  1973. }
  1974. [self updateScrollView:topFlag dynamicView:dynamicView count:i];
  1975. break;
  1976. case 1011:
  1977. if(_vToSalesAmount==nil){
  1978. _vToSalesAmount=[UIView new];
  1979. }
  1980. [dynamicView addSubview:_vToSalesAmount];
  1981. _vToSalesAmount.frame=CGRectMake(0,51*i,Screen_Width, 51);
  1982. if(_lblToSalesAmount==nil){
  1983. _lblToSalesAmount=[self getUILabel:_vToSalesAmount labelText:@"转销售金额" hintText:@"" labelColor:[UIColor blackColor] isHaveRightArrow:NO tag:1011];
  1984. }
  1985. [self updateScrollView:topFlag dynamicView:dynamicView count:i];
  1986. break;
  1987. case 1012:
  1988. if(_vInstallDate==nil){
  1989. _vInstallDate=[UIView new];
  1990. }
  1991. [dynamicView addSubview:_vInstallDate];
  1992. _vInstallDate.frame=CGRectMake(0,51*i,Screen_Width, 51);
  1993. if(_lblInstallDate==nil){
  1994. _lblInstallDate=[self getUILabel:_vInstallDate labelText:@"安装日期" hintText:@"请选择安装日期" labelColor:[UIColor blackColor] isHaveRightArrow:YES tag:1012];
  1995. }
  1996. [self updateScrollView:topFlag dynamicView:dynamicView count:i];
  1997. [self allListeners];
  1998. break;
  1999. case 1013:
  2000. if(_vDeliveryDate==nil){
  2001. _vDeliveryDate=[UIView new];
  2002. }
  2003. [dynamicView addSubview:_vDeliveryDate];
  2004. _vDeliveryDate.frame=CGRectMake(0,51*i,Screen_Width, 51);
  2005. if(_lblDeliveryDate==nil){
  2006. _lblDeliveryDate=[self getUILabel:_vDeliveryDate labelText:@"配送日期" hintText:@"请选择配送日期" labelColor:[UIColor blackColor] isHaveRightArrow:YES tag:1013];
  2007. }
  2008. [self updateScrollView:topFlag dynamicView:dynamicView count:i];
  2009. [self allListeners];
  2010. break;
  2011. case 1014:
  2012. if(_vFloor==nil){
  2013. _vFloor=[UIView new];
  2014. }
  2015. [dynamicView addSubview:_vFloor];
  2016. _vFloor.frame=CGRectMake(0,51*i,Screen_Width, 51);
  2017. if(_lblFloor==nil){
  2018. _lblFloor=[self getUILabel:_vFloor labelText:@"楼层" hintText:@"请选择楼层" labelColor:[UIColor blackColor] isHaveRightArrow:YES tag:1014];
  2019. }
  2020. [self updateScrollView:topFlag dynamicView:dynamicView count:i];
  2021. [self allListeners];
  2022. break;
  2023. case 1015:
  2024. if(_vDecorationProgress==nil){
  2025. _vDecorationProgress=[UIView new];
  2026. }
  2027. [dynamicView addSubview:_vDecorationProgress];
  2028. _vDecorationProgress.frame=CGRectMake(0,51*i,Screen_Width, 51);
  2029. if(_lblDecorationProgress==nil){
  2030. _lblDecorationProgress=[self getUILabel:_vDecorationProgress labelText:@"装修进度" hintText:@"请选择装修进度" labelColor:[UIColor blackColor] isHaveRightArrow:YES tag:1015];
  2031. }
  2032. [self updateScrollView:topFlag dynamicView:dynamicView count:i];
  2033. [self allListeners];
  2034. break;
  2035. case 1016:
  2036. if(_vWeight==nil){
  2037. _vWeight=[UIView new];
  2038. }
  2039. [dynamicView addSubview:_vWeight];
  2040. _vWeight.frame=CGRectMake(0,51*i,Screen_Width, 51);
  2041. if(_lblWeight==nil){
  2042. _lblWeight=[self getUILabel:_vWeight labelText:@"重量" hintText:@"" labelColor:[UIColor blackColor] isHaveRightArrow:NO tag:1016];
  2043. }
  2044. [self updateScrollView:topFlag dynamicView:dynamicView count:i];
  2045. break;
  2046. case 1017:
  2047. if(_vVolume==nil){
  2048. _vVolume=[UIView new];
  2049. }
  2050. [dynamicView addSubview:_vVolume];
  2051. _vVolume.frame=CGRectMake(0,51*i,Screen_Width, 51);
  2052. if(_lblVolume==nil){
  2053. _lblVolume=[self getUILabel:_vVolume labelText:@"总体积" hintText:@"" labelColor:[UIColor blackColor] isHaveRightArrow:NO tag:1017];
  2054. }
  2055. [self updateScrollView:topFlag dynamicView:dynamicView count:i];
  2056. break;
  2057. case 1018:
  2058. if(_vPaymentRate==nil){
  2059. _vPaymentRate=[UIView new];
  2060. }
  2061. [dynamicView addSubview:_vPaymentRate];
  2062. _vPaymentRate.frame=CGRectMake(0,51*i,Screen_Width, 51);
  2063. if(_lblPaymentRate==nil){
  2064. _lblPaymentRate=[self getUILabel:_vPaymentRate labelText:@"定金比率" hintText:@"" labelColor:[UIColor blackColor] isHaveRightArrow:NO tag:1017];
  2065. }
  2066. [self updateScrollView:topFlag dynamicView:dynamicView count:i];
  2067. break;
  2068. case 1019:
  2069. if(_vMarkPriceAmount==nil){
  2070. _vMarkPriceAmount=[UIView new];
  2071. }
  2072. [dynamicView addSubview:_vMarkPriceAmount];
  2073. _vMarkPriceAmount.frame=CGRectMake(0,51*i,Screen_Width, 51);
  2074. if(_lblMarkPriceAmount==nil){
  2075. _lblMarkPriceAmount=[self getUILabel:_vMarkPriceAmount labelText:@"标价总额" hintText:@"" labelColor:[UIColor blackColor] isHaveRightArrow:NO tag:1017];
  2076. }
  2077. [self updateScrollView:topFlag dynamicView:dynamicView count:i];
  2078. break;
  2079. case 1020:
  2080. if(_vOrderNo==nil){
  2081. _vOrderNo=[UIView new];
  2082. }
  2083. [dynamicView addSubview:_vOrderNo];
  2084. _vOrderNo.frame=CGRectMake(0,51*i,Screen_Width, 51);
  2085. if(_lblOrderNo==nil){
  2086. _lblOrderNo=[self getUILabel:_vOrderNo labelText:@"订单单号" hintText:@"" labelColor:[UIColor blackColor] isHaveRightArrow:NO tag:1017];
  2087. }
  2088. [self updateScrollView:topFlag dynamicView:dynamicView count:i];
  2089. break;
  2090. case 1021:
  2091. if(_vFeesAmount==nil){
  2092. _vFeesAmount=[UIView new];
  2093. }
  2094. [dynamicView addSubview:_vFeesAmount];
  2095. _vFeesAmount.frame=CGRectMake(0,51*i,Screen_Width, 51);
  2096. if(_lblFeesAmount==nil){
  2097. _lblFeesAmount=[self getUILabel:_vFeesAmount labelText:@"费用金额" hintText:@"请选择费用金额" labelColor:[UIColor blackColor] isHaveRightArrow:YES tag:1021];
  2098. }
  2099. [self updateScrollView:topFlag dynamicView:dynamicView count:i];
  2100. [self allListeners];
  2101. break;
  2102. case 1022:
  2103. if(_vTotalM2==nil){
  2104. _vTotalM2=[UIView new];
  2105. }
  2106. [dynamicView addSubview:_vTotalM2];
  2107. _vTotalM2.frame=CGRectMake(0,51*i,Screen_Width, 51);
  2108. if(_lblTotalM2==nil){
  2109. _lblTotalM2=[self getUILabel:_vTotalM2 labelText:@"总平米" hintText:@"" labelColor:[UIColor blackColor] isHaveRightArrow:NO tag:1022];
  2110. }
  2111. [self updateScrollView:topFlag dynamicView:dynamicView count:i];
  2112. break;
  2113. default:
  2114. break;
  2115. }
  2116. }
  2117. }
  2118. }
  2119. -(void)updateScrollView:(Boolean)topFlag dynamicView:(UIView*)dynamicView count:(NSInteger) count{
  2120. if(topFlag){
  2121. dynamicView.frame=CGRectMake(0,CGRectGetMaxY(_vCustomerType.frame),Screen_Width,51*(count+1));
  2122. _separator1.frame=CGRectMake(0,CGRectGetMaxY(dynamicView.frame)+10,Screen_Width, 10);
  2123. _vOperation.frame=CGRectMake(0,CGRectGetMaxY(_separator1.frame),Screen_Width, 51);
  2124. _separator2.frame=CGRectMake(0,CGRectGetMaxY(_vOperation.frame),Screen_Width, 10);
  2125. _vBody.frame=CGRectMake(0,0,Screen_Width, CGRectGetMaxY(_separator2.frame));
  2126. [self updateScrollView];
  2127. }
  2128. else{
  2129. dynamicView.frame=CGRectMake(0, CGRectGetMaxY(_separator2.frame),Screen_Width, 51*(count+1));
  2130. _vBody.frame=CGRectMake(0,0,Screen_Width, CGRectGetMaxY(dynamicView.frame));
  2131. [self updateScrollView];
  2132. }
  2133. }
  2134. -(UITextField *)getTextField:(UIView*)v labelText:(NSString*)labelTitle hintText:(NSString*)hint labelColor:(UIColor*) color tag:(NSInteger) tag {
  2135. UILabel *lblCustomer = [UILabel new];
  2136. lblCustomer.frame=CGRectMake(15,16, 100, 25);
  2137. lblCustomer.text = labelTitle;
  2138. lblCustomer.textColor=color;
  2139. lblCustomer.font= [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  2140. [v addSubview:lblCustomer];
  2141. UITextField *txtCustomer = [UITextField new];
  2142. txtCustomer.frame=CGRectMake(CGRectGetMaxX(lblCustomer.frame)+10,16, 200, 25);
  2143. txtCustomer.tag=tag;
  2144. txtCustomer.font=[UIFont systemFontOfSize: LabelAndTextFontOfSize];
  2145. txtCustomer.placeholder = hint;
  2146. [v addSubview:txtCustomer];
  2147. UIView *separator = [UIView new];
  2148. separator.backgroundColor=LineBackgroundColor;
  2149. separator.frame=CGRectMake(CGRectGetMaxX(lblCustomer.frame)+10,CGRectGetMaxY(txtCustomer.frame)+10,Screen_Width-CGRectGetMaxX(lblCustomer.frame)+10, 1);
  2150. [v addSubview:separator];
  2151. return txtCustomer;
  2152. }
  2153. -(UILabel *)getUILabel:(UIView*)v labelText:(NSString*)labelTitle hintText:(NSString*)hint labelColor:(UIColor*) color isHaveRightArrow:(Boolean)rightArrowFlag tag:(NSInteger) tag{
  2154. UILabel *lblTitleCustomer = [UILabel new];
  2155. lblTitleCustomer.frame=CGRectMake(15,16, 100, 25);
  2156. lblTitleCustomer.text = labelTitle;
  2157. lblTitleCustomer.textColor=color;
  2158. lblTitleCustomer.font= [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  2159. [v addSubview:lblTitleCustomer];
  2160. UILabel *lblCustomer = [UILabel new];
  2161. lblCustomer.frame=CGRectMake(CGRectGetMaxX(lblTitleCustomer.frame)+10,16, 200, 25);
  2162. lblCustomer.font=[UIFont systemFontOfSize: LabelAndTextFontOfSize];
  2163. lblCustomer.userInteractionEnabled=YES;
  2164. lblCustomer.text=hint;
  2165. lblCustomer.tag=tag;
  2166. [v addSubview:lblCustomer];
  2167. UIView *separator = [UIView new];
  2168. separator.backgroundColor=LineBackgroundColor;
  2169. separator.frame=CGRectMake(CGRectGetMaxX(lblTitleCustomer.frame)+10,CGRectGetMaxY(lblCustomer.frame)+10,Screen_Width-CGRectGetMaxX(lblTitleCustomer.frame)+10, 1);
  2170. [v addSubview:separator];
  2171. if(rightArrowFlag){
  2172. UIButton *btnRightArrow = [UIButton buttonWithType:UIButtonTypeCustom];
  2173. btnRightArrow.frame=CGRectMake(Screen_Width-50,10,32,30);
  2174. UIImageView *rightArrowImg = [[UIImageView alloc]initWithFrame:CGRectMake(25,9,7, 12)];
  2175. [rightArrowImg setImage:[UIImage imageNamed:@"rightarrow"]];
  2176. [ btnRightArrow addSubview:rightArrowImg];
  2177. rightArrowImg.userInteractionEnabled=NO;
  2178. [v addSubview:btnRightArrow];
  2179. }
  2180. return lblCustomer;
  2181. }
  2182. -(void)refreshData:(NSMutableArray*)topDataList bottomDataList:(NSMutableArray*)bottomData{
  2183. _vBottom.hidden=NO;
  2184. _topDataList=topDataList;
  2185. _bottomDataList=bottomData;
  2186. [_vTop removeFromSuperview];
  2187. _vTop=[UIView new];
  2188. _vTop.frame=CGRectMake(0,CGRectGetMaxY(_vCustomerType.frame),Screen_Width,0);
  2189. [_vBody addSubview:_vTop];
  2190. _separator1.frame=CGRectMake(0,CGRectGetMaxY(_vTop.frame)+10,Screen_Width, 10);
  2191. _vOperation.frame=CGRectMake(0,CGRectGetMaxY(_separator1.frame),Screen_Width, 51);
  2192. _separator2.frame=CGRectMake(0,CGRectGetMaxY(_vOperation.frame),Screen_Width, 10);
  2193. [_vBottom removeFromSuperview];
  2194. _vBottom=[UIView new];
  2195. _vBottom.frame=CGRectMake(0, CGRectGetMaxY(_separator2.frame),Screen_Width, 0);
  2196. [_vBody addSubview:_vBottom];
  2197. _vBody.frame=CGRectMake(0,0,Screen_Width, CGRectGetMaxY(_vBottom.frame));
  2198. [self updateScrollView];
  2199. [self initDynamicLayout:_topDataList dynamicView:_vTop topFlag:YES];
  2200. [self initDynamicLayout:_bottomDataList dynamicView:_vBottom topFlag:NO];
  2201. }
  2202. -(void)callbackDepositAmount:(NSMutableArray *) arry
  2203. {
  2204. _feesAmountCheckedList=[[NSMutableArray alloc]init];
  2205. double sum=0;
  2206. for(int i=0;i<arry.count;i++)
  2207. {
  2208. FeeAmountModel *depositModel= [arry objectAtIndex:i];
  2209. NSString *feeItemSum= depositModel.feeItemSum;
  2210. if(feeItemSum!=nil&&![feeItemSum isEqualToString:@""])
  2211. {
  2212. double feeItemSumValue=[feeItemSum doubleValue];
  2213. if(feeItemSumValue>0)
  2214. {
  2215. sum+=feeItemSumValue;
  2216. [_feesAmountCheckedList addObject:depositModel];
  2217. }
  2218. }
  2219. }
  2220. _feeAmount =[NSString stringWithFormat:@"%.4f",sum];
  2221. _lblFeesAmount.text=_feeAmount;
  2222. }
  2223. /**
  2224. 更新ScrollView
  2225. */
  2226. -(void)updateScrollView{
  2227. _scrollView.contentSize = CGSizeMake(self.view.frame.size.width, CGRectGetMaxY(_vBody.frame)+rectStatusHeight+rectNavHeight+40);
  2228. }
  2229. - (void)didReceiveMemoryWarning {
  2230. [super didReceiveMemoryWarning];
  2231. }
  2232. @end