123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344 |
- //
- // AddRecordVC.m
- // jiaPeiC
- //
- // Created by apple on 16/3/10.
- // Copyright © 2016年 JCZ. All rights reserved.
- //
- #import "AddRecordVC.h"
- #import "DateView.h"
- #import "PickTimeV.h"
- #import "AppDelegate.h"
- @interface AddRecordVC ()<UITextViewDelegate>
- {
- UIButton *styleBtn,*dateBtn,*addBtn;
- UITextView *markTV;
- UILabel *placeHolderLabel;
- DateView *dateV;
- PickTimeV *pickV;
-
- NSString *dateString;
- NSString *recordStyle;
- }
- @end
- @implementation AddRecordVC
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.title = @"日志添加";
-
- float bd,x,y,w,h;
-
- x = bd = 10;
- y = kNavOffSet + 10;
- w = kSize.width - 20;
- h = 50;
-
- UIView *bgView;
- UILabel *label;
- UIButton *button;
-
- bgView = [[UIView alloc] initWithFrame:CGRectMake(x, y , w, h)];
- [bgView boardWid:2 Color:lineColor];
- [bgView corner:5];
- [self addV:bgView];
-
- label = [[UILabel alloc] initWithFrame:CGRectMake(x + bd, y , w - bd, h)];
- [label setText:[NSString stringWithFormat:@"学员姓名: %@",_stuDic[@"STU_NAME"]] Font:18 TextColor:titleColor Alignment:NSTextAlignmentLeft];
- [self addV:label];
-
- if ([_stuDic[@"SUBJECT"] integerValue] == 2 || [_stuDic[@"SUBJECT"] integerValue] == 3) {
- y += h + bd;
- bgView = [[UIView alloc] initWithFrame:CGRectMake(x, y , w, h)];
- [bgView boardWid:2 Color:lineColor];
- [bgView corner:5];
- [self addV:bgView];
-
- label = [[UILabel alloc] initWithFrame:CGRectMake(x + bd, y , w - bd, h)];
- [label setText:[NSString stringWithFormat:@"日志类型:"] Font:18 TextColor:titleColor Alignment:NSTextAlignmentLeft];
- [self addV:label];
-
- button = [[UIButton alloc] initWithFrame:CGRectMake(x, y , w, h)];
- [button setTitle:@"请选择日志类型" textColor:defGreen font:17 fotState:UIControlStateNormal];
- [button target:self Tag:1];
- [self addV:button];
- styleBtn = button;
- }
-
- y += h + bd;
- bgView = [[UIView alloc] initWithFrame:CGRectMake(x, y , w, h)];
- [bgView boardWid:2 Color:lineColor];
- [bgView corner:5];
- [self addV:bgView];
-
- label = [[UILabel alloc] initWithFrame:CGRectMake(x + bd, y , w - bd, h)];
- [label setText:[NSString stringWithFormat:@"添加时间:"] Font:18 TextColor:titleColor Alignment:NSTextAlignmentLeft];
- [self addV:label];
-
- //默认是当天时间
- NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
- [formatter setDateFormat:@"yyyy-MM-dd"];
- dateString = [formatter stringFromDate:[NSDate date]];
-
- button = [[UIButton alloc] initWithFrame:CGRectMake(x, y , w, h)];
- [button setTitle:dateString textColor:defGreen font:17 fotState:UIControlStateNormal];
- [button target:self Tag:2];
- [self addV:button];
- dateBtn = button;
-
- y += h + bd;
- h = 180;
- if (kSize.height < 500.0) {
- h = 140;
- }
- bgView = [[UIView alloc] initWithFrame:CGRectMake(x, y , w, h)];
- [bgView boardWid:2 Color:lineColor];
- [bgView corner:5];
- [self addV:bgView];
-
- markTV = [[UITextView alloc] initWithFrame:CGRectMake(x + bd, y + 5, w - 2*bd, h - 10)];
- markTV.delegate = self;
- markTV.backgroundColor = backGroundColor;
- markTV.textColor = contentTextColor;
- [markTV setFont:[UIFont scaleSize:17]];
- markTV.returnKeyType = UIReturnKeyDone;
- [self addV:markTV];
-
- label = [[UILabel alloc] initWithFrame:CGRectMake(x + bd, y + 5, w - 2*bd, 30)];
- label.text = @"备注:请输入备注信息(60字以内)";
- label.textColor = contentTextColor;
- [label setFont:[UIFont scaleSize:17]];
- [label setTextAlignment:NSTextAlignmentLeft];
- [self addV:label];
- placeHolderLabel = label;
-
-
- y += h + 25;
- if (kSize.height > 600.0) {
- y += 100;
- }
- h = 50;
- button = [[UIButton alloc] initWithFrame:CGRectMake(x + 2*bd, y, w - 4*bd, h)];
- [button setTitle:@"确认添加" textColor:[UIColor whiteColor] font:20 fotState:UIControlStateNormal];
- button.backgroundColor = defGreen;
- [button.layer setMasksToBounds:YES];
- [button.layer setCornerRadius:10];
- [button target:self Tag:3];
- [self addV:button];
- addBtn = button;
-
-
- //修改日志
- if (_recordDic) {
-
- // NSLog(@"修改的日志---->%@",_recordDic);
- self.title = @"日志修改";
- recordStyle = _recordDic[@"TL_TEACH_ID"];
- if (_teachType.count > [recordStyle integerValue] - 1) {
-
- [styleBtn setTitle:_teachType[[recordStyle integerValue] - 1] forState:UIControlStateNormal];
- }
-
- [dateBtn setTitle:_recordDic[@"TL_CRDATE"] forState:UIControlStateNormal];
- [dateBtn setUserInteractionEnabled:NO];
- markTV.text = _recordDic[@"TL_REMARK"];
- if (markTV.text && markTV.text.length > 0) {
- [placeHolderLabel setHidden:YES];
- }
-
- [addBtn setTitle:@"确认修改" forState:UIControlStateNormal];
- addBtn.tag = 4;
- }
- }
- -(void)btnClick:(UIButton *)sender
- {
- [self.view endEditing:YES];
- if (sender.tag == 1) {
- //选择日志类型
- pickV = [[PickTimeV alloc] init];
- if ([_stuDic objectForKey:@"SUBJECT"]) {
- pickV.KM = _stuDic[@"SUBJECT"];
- }
- [pickV setWhichVC:@"AddRecordVC"];
- [pickV complete:^(NSDictionary* obj) {
-
- [styleBtn setTitle:obj[@"TC_TEACH_TYPE"] forState:UIControlStateNormal];
- recordStyle = obj[@"TC_ID"];
- }];
- [pickV show];
- }
- if (sender.tag == 2) {
- //选择日志时间
- dateV = [[DateView alloc] init];
- [dateV setStyle:0];
- [dateV showWithComplete:^(NSString * result) {
-
- //NSLog(@"%@",result); eg:2016-03-11
- dateString = result;
- [dateBtn setTitle:dateString forState:UIControlStateNormal];
- }];
- }
- if (sender.tag == 3) {
- //确认添加
- if (!recordStyle || recordStyle.length == 0) {
- if ([_stuDic[@"SUBJECT"] integerValue] == 2 || [_stuDic[@"SUBJECT"] integerValue] == 3) {
- ShowMsg(@"请选择日志类型");
- return;
- }
- }
- if (markTV.text.length > 60) {
-
- ShowMsg(@"备注已超过60字符");
- return;
- }
-
- [self uploadTeachLogs];
- }
- if (sender.tag == 4) {
- //确认修改
- if (markTV.text.length > 60) {
-
- ShowMsg(@"备注已超过60字符");
- return;
- }
-
- [self modifyTeachLogs];
- }
- }
- #pragma mark 添加日志
- - (void)uploadTeachLogs
- {
- [LoadingView showHUD];
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"name" Value:_stuDic[@"STU_NAME"]];
- [arr addPro:@"userOutId" Value:_stuDic[@"TSO_ID"]];
- [arr addPro:@"coaSfzhm" Value:defUser.userDict[@"idcard"]];
- [arr addPro:@"crDate" Value:dateString];
- [arr addPro:@"teachId" Value:recordStyle];
- [arr addPro:@"subject" Value:_stuDic[@"SUBJECT"]];
- [arr addPro:@"jxbh" Value:defUser.userDict[@"jxbh"]];
- [arr addPro:@"remark" Value:markTV.text];
- NSString* method = @"uploadTeachLogs";
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- RemoveHUD();
- //NSLog(@"添加日志---->%@----->%@",arr,root);
-
- if (!root) {
- ShowMsg(@"上传失败!");
- return ;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
- ShowMsg(root[@"body"]);
- return;
- }
-
- ShowMsg(@"上传成功!");
- if (self.refreshTeachlogs) {
- self.refreshTeachlogs();
- }
- [self.navigationController popViewControllerAnimated:YES];
- }];
- }
- #pragma mark 修改日志
- - (void)modifyTeachLogs
- {
- [LoadingView showHUD];
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"id" Value:_recordDic[@"TL_ID"]];
- [arr addPro:@"teachId" Value:recordStyle];
- [arr addPro:@"subject" Value:_stuDic[@"SUBJECT"]];
- [arr addPro:@"remark" Value:markTV.text];
- NSString* method = @"modifyMyTeachLog";
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- RemoveHUD();
- //NSLog(@"修改日志---->%@----->%@",arr,root);
-
- if (!root) {
- ShowMsg(@"修改失败!");
- return ;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
- ShowMsg(root[@"body"]);
- return;
- }
-
- ShowMsg(@"修改成功!");
- if (self.refreshTeachlogs) {
- self.refreshTeachlogs();
- }
- [self.navigationController popViewControllerAnimated:YES];
- }];
- }
- #pragma mark tv代理
- -(void)textViewDidBeginEditing:(UITextView *)textView
- {
- [placeHolderLabel setTextColor:[UIColor colorWithWhite:.3 alpha:.5]];
- }
- -(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
- {
- NSMutableString * changedString=[[NSMutableString alloc]initWithString:textView.text];
- [changedString replaceCharactersInRange:range withString:text];
-
- if (changedString.length > 0) {
- [placeHolderLabel setHidden:YES];
- }else{
- [placeHolderLabel setHidden:NO];
- }
-
- if ([@"\n" isEqualToString:text] == YES) {
-
- //如果是换行键 就隐藏键盘
- [self.view endEditing:YES];
- return NO;
- }
-
- return YES;
- }
- -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
- {
- [self.view endEditing:YES];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|