| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522 |
- //
- // NewInstallDetailListsCell.m
- // IBOSS
- //
- // Created by apple on 16/1/12.
- // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved.
- //
- // 功能描述:新增安装明细单元格
- #import "NewInstallDetailListsCell.h"
- #import "StatusInfoTextVC.h"
- #import "ArgumentSetting.h"
- #import "OrderQuantity.h"
- #define kTextFont [UIFont systemFontOfSize:LabelAndTextFontOfSize]
- @implementation NewInstallDetailListsCell
- #pragma mark - 公有函数
- /**
- cell点击函数
- @param selected <#selected description#>
- @param animated <#animated description#>
- */
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
-
- }
- /**
- 初始化 cell style
- @param style <#style description#>
- @param reuseIdentifier <#reuseIdentifier description#>
- @return <#return value description#>
- */
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
- {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- CGFloat w=((Screen_Width-100-22));;
-
-
- UILabel *lblTitleOnlyCode = [[UILabel alloc] initWithFrame:CGRectMake(20,5,80,31)];
- lblTitleOnlyCode.textColor = [UIColor blackColor];
- lblTitleOnlyCode.text = @"唯一编码:";
- lblTitleOnlyCode.font=kTextFont;
- lblTitleOnlyCode.textAlignment = NSTextAlignmentLeft;
- [self.contentView addSubview:lblTitleOnlyCode];
- self.lblOnlyCode = [[UILabel alloc] initWithFrame:CGRectMake(95,5,w,31)];
- self.lblOnlyCode.backgroundColor = [UIColor clearColor];
- self.lblOnlyCode.textColor = [UIColor blackColor];
- self.lblOnlyCode.font=kTextFont;
- self.lblOnlyCode.textAlignment = NSTextAlignmentLeft;
- [self.contentView addSubview: self.lblOnlyCode];
-
- UILabel *lblTitleCode = [[UILabel alloc] initWithFrame:CGRectMake(20,5+CGRectGetMaxY(lblTitleOnlyCode.frame),80,31)];
- lblTitleCode.textColor = [UIColor blackColor];
- lblTitleCode.text = @"商品编码:";
- lblTitleCode.font=kTextFont;
- lblTitleCode.textAlignment = NSTextAlignmentLeft;
- [self.contentView addSubview:lblTitleCode];
- self.code = [[UILabel alloc] initWithFrame:CGRectMake(95,CGRectGetMaxY(lblTitleOnlyCode.frame)+5,w,31)];
- self.code.backgroundColor = [UIColor clearColor];
- self.code.textColor = [UIColor blackColor];
- self.code.font=kTextFont;
- self.code.textAlignment = NSTextAlignmentLeft;
- [self.contentView addSubview: self.code];
-
- ////////////////////////商品名称
- UILabel *lblgoodsname = [[UILabel alloc] initWithFrame:CGRectMake(20,5+CGRectGetMaxY(lblTitleCode.frame),80,31)];
- lblgoodsname.backgroundColor = [UIColor clearColor];
- lblgoodsname.textColor = [UIColor blackColor];
- lblgoodsname.text = @"商品名称:";
- lblgoodsname.font=kTextFont;
- lblgoodsname.textAlignment = NSTextAlignmentLeft;
- [self.contentView addSubview:lblgoodsname];
- self.goodsName = [[UILabel alloc] initWithFrame:CGRectMake(95,5+CGRectGetMaxY(lblTitleCode.frame),w,31)];
- self.goodsName.backgroundColor = [UIColor clearColor];
- self.goodsName.textColor = [UIColor blackColor];
- self.goodsName.font=kTextFont;
- self.goodsName.textAlignment = NSTextAlignmentLeft;
- [self.contentView addSubview: self.goodsName];
-
-
- ////////////////////////计量单位
- UILabel *lblunit = [[UILabel alloc] initWithFrame:CGRectMake(Screen_Width/2,5+CGRectGetMaxY(lblTitleCode.frame),70,31)];
- lblunit.backgroundColor = [UIColor clearColor];
- lblunit.textColor = [UIColor blackColor];
- lblunit.text = @"计量单位:";
- lblunit.font=kTextFont;
- lblunit.textAlignment = NSTextAlignmentLeft;
- [self.contentView addSubview:lblunit];
- self.unit = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(lblunit.frame),5+CGRectGetMaxY(lblTitleCode.frame),w,31)];
- self.unit.backgroundColor = [UIColor clearColor];
- self.unit.textColor = [UIColor blackColor];
- self.unit.font=kTextFont;
- self.unit.textAlignment = NSTextAlignmentLeft;
- [self.contentView addSubview: self.unit];
-
- ////////////////////////安装数量
- UILabel *lblinstallquality = [[UILabel alloc] initWithFrame:CGRectMake(20,5+CGRectGetMaxY(lblgoodsname.frame),80,31)];
- lblinstallquality.backgroundColor = [UIColor clearColor];
- lblinstallquality.textColor = [UIColor blackColor];
- lblinstallquality.text = @"安装数量:";
- lblinstallquality.font=kTextFont;
- lblinstallquality.textAlignment = NSTextAlignmentLeft;
- [self.contentView addSubview:lblinstallquality];
- self.installQuantity = [[UILabel alloc] initWithFrame:CGRectMake(95,5+CGRectGetMaxY(lblgoodsname.frame),w,31)];
- self.installQuantity.backgroundColor = [UIColor clearColor];
- self.installQuantity.textColor = [UIColor blackColor];
- self.installQuantity.font=kTextFont;
- self.installQuantity.textAlignment = NSTextAlignmentLeft;
- [self.contentView addSubview: self.installQuantity];
-
- ////////////////////////完成数量
- UILabel *lblcompletedquality = [[UILabel alloc] initWithFrame:CGRectMake(Screen_Width/2,5+CGRectGetMaxY(lblgoodsname.frame),70,31)];
- lblcompletedquality.backgroundColor = [UIColor clearColor];
- lblcompletedquality.textColor = [UIColor blackColor];
- lblcompletedquality.text = @"完成数量:";
- lblcompletedquality.font=kTextFont;
- lblcompletedquality.textAlignment = NSTextAlignmentLeft;
- [self.contentView addSubview:lblcompletedquality];
- self.completedQuantity = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(lblcompletedquality.frame),5+CGRectGetMaxY(lblgoodsname.frame),w,31)];
- self.completedQuantity.backgroundColor = [UIColor clearColor];
- self.completedQuantity.textColor = [UIColor blackColor];
- self.completedQuantity.font=kTextFont;
- self.completedQuantity.textAlignment = NSTextAlignmentLeft;
- [self.contentView addSubview: self.completedQuantity];
-
- ////////////////////////回执数量
- UILabel *lblreceiptquality = [[UILabel alloc] initWithFrame:CGRectMake(20,5+CGRectGetMaxY(_completedQuantity.frame),80,31)];
- lblreceiptquality.backgroundColor = [UIColor clearColor];
- lblreceiptquality.textColor = [UIColor blackColor];
- lblreceiptquality.font=kTextFont;
- lblreceiptquality.text = @"回执数量:";
-
- lblreceiptquality.textAlignment = NSTextAlignmentLeft;
- [self.contentView addSubview:lblreceiptquality];
- self.receiptQuantity = [[UITextField alloc] initWithFrame:CGRectMake(95,5+CGRectGetMaxY(_completedQuantity.frame),w,31)];
- self.receiptQuantity.backgroundColor = [UIColor clearColor];
- self.receiptQuantity.textColor = [UIColor blackColor];
- self.receiptQuantity.textAlignment = NSTextAlignmentLeft;
- self.receiptQuantity.tag=1110;
- self.receiptQuantity.font=kTextFont;
- self.receiptQuantity.placeholder = @"请输入回执数量";
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onFocusPeopleEditingChanged:) name:@"UITextFieldTextDidChangeNotification" object: self.receiptQuantity];
- self.receiptQuantity.keyboardType=UIKeyboardTypeDecimalPad;
- [self.contentView addSubview: self.receiptQuantity];
- ////////////////////////出库数量
- UILabel *lblOutqualityTitle = [[UILabel alloc] initWithFrame:CGRectMake(Screen_Width/2,5+CGRectGetMaxY(_completedQuantity.frame),70,31)];
- lblOutqualityTitle.backgroundColor = [UIColor clearColor];
- lblOutqualityTitle.textColor = [UIColor blackColor];
- lblOutqualityTitle.font=kTextFont;
- lblOutqualityTitle.text = @"出库数量:";
-
- lblOutqualityTitle.textAlignment = NSTextAlignmentLeft;
- [self.contentView addSubview:lblOutqualityTitle];
- self.lblOutquality = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(lblOutqualityTitle.frame),5+CGRectGetMaxY(_completedQuantity.frame),80,31)];
- _lblOutquality.backgroundColor = [UIColor clearColor];
- _lblOutquality.textColor = [UIColor blackColor];
- _lblOutquality.font=kTextFont;
-
- _lblOutquality.textAlignment = NSTextAlignmentLeft;
- [self.contentView addSubview:_lblOutquality];
-
- ////////////////////////回执类型
- UILabel *lblreceipttype = [[UILabel alloc] initWithFrame:CGRectMake(20,5+CGRectGetMaxY(lblreceiptquality.frame),80,31)];
- lblreceipttype.backgroundColor = [UIColor clearColor];
- lblreceipttype.textColor = [UIColor blackColor];
- lblreceipttype.text = @"回执类型:";
- lblreceipttype.font=kTextFont;
- lblreceipttype.textAlignment = NSTextAlignmentLeft;
- [self.contentView addSubview:lblreceipttype];
- self.btnReceiptType = [[UIButton alloc] initWithFrame:CGRectMake(95,5+CGRectGetMaxY(lblreceiptquality.frame),w-20,31)];
- [self.btnReceiptType setTitle:@"请选择回执类型" forState:UIControlStateNormal];
- self.btnReceiptType.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
- self.btnReceiptType.titleLabel.font=kTextFont;
- [self.btnReceiptType setTitleColor:[UIColor colorWithWhite:0 alpha:1] forState:UIControlStateNormal];
- self.btnReceiptType.tag=1000;
- [self.contentView addSubview: self.btnReceiptType];
- ////////////////////////回执备注
- UILabel *lblremark = [[UILabel alloc] initWithFrame:CGRectMake(20,5+CGRectGetMaxY(lblreceipttype.frame),80,31)];
- lblremark.backgroundColor = [UIColor clearColor];
- lblremark.textColor = [UIColor blackColor];
- lblremark.text = @"回执备注:";
- lblremark.font=kTextFont;
- lblremark.textAlignment = NSTextAlignmentLeft;
- [self.contentView addSubview:lblremark];
- self.remark = [[UITextField alloc] initWithFrame:CGRectMake(95,5+CGRectGetMaxY(lblreceipttype.frame),w,31)];
- self.remark.backgroundColor = [UIColor clearColor];
- self.remark.tag=1111;
- self.remark.textColor = [UIColor blackColor];
- self.remark.textAlignment = NSTextAlignmentLeft;
- self.remark.font=kTextFont;
- self.remark.placeholder = @"请输入回执备注";
- [self.contentView addSubview: self.remark];
-
- UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, 5+CGRectGetMaxY(self.remark.frame), SCREENWIDTH, 5)];
- line.backgroundColor = [UIColor colorWithRed:234.0/255 green:235.0/255 blue:236.0/255 alpha:1];
- [self.contentView addSubview: line];
- self.cellHeight=CGRectGetMaxY(line.frame);
-
- [self.receiptQuantity addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
- [self.remark addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
-
- self.receiptQuantity.delegate=self;
- self.remark.delegate=self;
-
- }
- return self;
- }
- #pragma mark - 委托函数
- /**
- textfield回调函数
- @param textField <#textField description#>
- */
- - (void)textFieldDidBeginEditing:(UITextField *)textField{
- if([textField isEqual:self.remark] ){
- if([self.installDelegate respondsToSelector:@selector(keyboardWillShow:)])
- {
- [self.installDelegate keyboardWillShow:self];
- }
- }
- }
- /**
- textfield回调函数
- @param textField <#textField description#>
- */
- - (void)textFieldDidEndEditing:(UITextField *)textField{
- NSLog(@"textFieldDidEndEditing");
- if([textField isEqual:self.remark]){
- if([self.installDelegate respondsToSelector:@selector(keyboardWillHide:)])
- {
- [self.installDelegate keyboardWillHide:self];
- }
- return ;
- }else{
- OrderQuantity *quantity = [OrderQuantity new];
- NSInteger decimalPlaces= [_model.decimalPlaces integerValue];
- NSString *receiptQuantity = [quantity calculateReceiptQuantity:[self.model.circulateType integerValue] decimalPlaces:[NSString stringWithFormat:@"%ld",(long)decimalPlaces] quantity:self.receiptQuantity.text acreage:[self.model.acreage doubleValue]];
- self.receiptQuantity.text = receiptQuantity;
- self.model.receiptQuantity = receiptQuantity;
- }
- if([self.installDelegate respondsToSelector:@selector(endEdit:)])
- {
- [self.installDelegate endEdit:self];
- }
- }
- /**
- textfield回调函数
- @param textField <#textField description#>
- @param range <#range description#>
- @param string <#string description#>
- @return <#return value description#>
- */
- - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
-
- if([textField isEqual:self.remark]){
- if (range.location >= 100){
- return NO;
- }
- }
-
- if(textField == self.receiptQuantity)
- {
- if (range.location >= 17){
- return NO;
- } // return NO to not change text
-
- if ([textField.text rangeOfString:@"."].location == NSNotFound) {
- self.isHaveDian = NO;
- }else{
- self.isHaveDian=YES;
- }
- if ([string length] > 0) {
-
- unichar single = [string characterAtIndex:0];//当前输入的字符
- if ((single >= '0' && single <= '9') || single == '.') {//数据格式正确
-
- //首字母不能为0和小数点
- if([textField.text length] == 0){
- if(single == '.') {
- [self showAlertViewText:@"第一个数字不能为小数点"];
- [textField.text stringByReplacingCharactersInRange:range withString:@""];
- return NO;
- }
-
- }
- if([textField.text length] == 1 && [[textField.text substringToIndex:1] isEqualToString: @"0"]){
- if(!(single == '.')) {
- [textField.text stringByReplacingCharactersInRange:range withString:@""];
- return NO;
- }
-
- }
-
- //输入的字符是否是小数点
- if (single == '.') {
- if(!self.isHaveDian)//text中还没有小数点
- {
- self.isHaveDian = YES;
- return YES;
-
- }else{
- [self showAlertViewText:@"您已经输入过小数点了"];
- [textField.text stringByReplacingCharactersInRange:range withString:@""];
- return NO;
- }
- }else{
- if (self.isHaveDian) {//存在小数点
-
- //判断小数点的位数
- NSRange ran = [textField.text rangeOfString:@"."];
- if (range.location - ran.location <= 6) {
- return YES;
- }else{
- //[self showAlertViewText:@"亲,您最多输入两位小数"];
- return NO;
- }
- }else{
- return YES;
- }
- }
- }else{//输入的数据格式不正确
- [self showAlertViewText:@"您输入的格式不正确"];
- [textField.text stringByReplacingCharactersInRange:range withString:@""];
- return NO;
- }
- }
- else
- {
- return YES;
- }
- }
-
- return YES;
- }
- #pragma mark - 私有函数
- /**
- 设置cell数据
- @param model <#model description#>
- */
- - (void)parseInfoModel:(NewInstallIItemModel*)model type:(NSString *) type{
- if(model != nil){
- _model =model;
- self.installId=model.installationId;
- self.detailId=model.detailId;
- self.salesDetailId=model.salesDetailId;
- self.code.text=model.code;
- self.lblOnlyCode.text=model.onlyCode;
- self.installQuantity.text=model.installQuantity;
- self.completedQuantity.text=model.completeQuantity;
- self.unit.text=model.unitName;
- if(model.payStyle == nil|| model.payStyle.length == 0)
- {
- self.payStyle = @"";
- [self.btnPayStyle setTitle:@"请选择铺贴方式" forState:UIControlStateNormal];
- }
- else{
- self.payStyle=model.payStyle;
- [self.btnPayStyle setTitle:model.payStyleValue forState:UIControlStateNormal];
- }
- _lblOutquality.text = model.outQuantity;
- self.receiptQuantity.text=model.receiptQuantity;
- self.receiptBox.text=model.box;
- self.receiptPiece.text=model.piece;
- self.mm.text=model.mm;
- self.package.text=model.package;
- self.remark.text=model.remarks;
- self.receiptType=model.receiptType;
- self.goodsName.text = model.goodsName;
- self.receiptQuantity.enabled=model.isDelay;
- self.remark.enabled=model.isDelay;
- if ([model.receiptType isEqualToString:@"5"]) {
- [self.btnReceiptType setTitle:@"再安装" forState:UIControlStateNormal];
- self.receiptQuantity.enabled= YES;
- self.receiptQuantity.text = model.receiptQuantity;
- }
- if([model.receiptType isEqualToString:@"1"]){
- if([type intValue] == 3){
- [self.btnReceiptType setTitle:@"完成" forState:UIControlStateNormal];
- self.receiptQuantity.enabled= NO;
- self.receiptQuantity.text = model.receiptQuantity;
- model.receiptQuantity = model.receiptQuantity;
- }else{
- [self.btnReceiptType setTitle:@"完成" forState:UIControlStateNormal];
- self.receiptQuantity.enabled= NO;
- self.receiptQuantity.text = model.maxReceiptQuantity;
- model.receiptQuantity = model.maxReceiptQuantity;
- }
-
- }
- [self.btnReceiptType addTarget:self action:@selector(btnCilck:) forControlEvents:UIControlEventTouchUpInside];
-
- }
- }
- /**
- 文本字段变化函数
- @param sender <#sender description#>
- */
- - (void)textFieldDidChange:(UITextField*) sender{
- UITextField* txt=sender;
- switch (txt.tag) {
- case 1110:
- {
-
- }
- break;
- case 1111:
- {
-
- }
- break;
-
- default:
- break;
- }
-
- if([self.installDelegate respondsToSelector:@selector(textValueChange:txtField:qualityField:remarkField:)])
- {
- [self.installDelegate textValueChange:self txtField:txt qualityField:self.receiptQuantity remarkField:self.remark];
-
- }
- }
- /**
- 按钮点击函数
- @param sender <#sender description#>
- */
- - (void)btnCilck:(UIButton*)sender{
- UIButton *btn=sender;
- [self endEditing:YES];
-
- switch (btn.tag) {
- case 1000:
- {
- if([self.installDelegate respondsToSelector:@selector(btnGoReceiptType:)])
- {
- [self.installDelegate btnGoReceiptType:self];
- }
- }
- break;
- case 1001:
- {
- if([self.installDelegate respondsToSelector:@selector(btnGoPayStyle:)])
- {
- [self.installDelegate btnGoPayStyle:self];
- }
- }
- break;
- default:
- break;
- }
-
- }
- /**
- 文本框的长度限制 实现监听方法
- @param sender <#sender description#>
- */
- - (void)onFocusPeopleEditingChanged:(NSNotification *)sender
- {
-
- UITextField *textField = (UITextField *)sender.object;
- NSString *toBeString = textField.text;
-
- NSString *lang = [[UITextInputMode currentInputMode] primaryLanguage];
- int kMaxLength=0;
- if([textField isEqual:self.receiptQuantity]){
- kMaxLength=17;
-
- if (toBeString!= nil && toBeString.length>0 && [toBeString floatValue]-9999999999.999999f>0.0000000001f) {
- textField.text = @"9999999999.999999";
- toBeString = @"9999999999.999999";
- }
-
- }
- if ([lang isEqualToString:@"zh-Hans"]) {
- UITextRange *selectedRange = [textField markedTextRange];
- UITextPosition *position = [textField positionFromPosition:selectedRange.start offset:0];
-
- if (!position) {
- if (toBeString.length > kMaxLength) {
- textField.text = [toBeString substringToIndex:kMaxLength];
- }
- }
- }else{
- if (toBeString.length > kMaxLength) {
- textField.text = [toBeString substringToIndex:kMaxLength];
- }
- }
- }
- /**
- 警告对话框
- @param text <#text description#>
- */
- - (void)showAlertViewText:(NSString *)text
- {
- UIAlertView*alert = [[UIAlertView alloc]initWithTitle:@"提示"
- message:text
- delegate:nil
- cancelButtonTitle:@"确定"
- otherButtonTitles:nil];
- [alert show];
-
-
- }
- @end
|