Commit eaf34b6609e78603ceed88acdf1c8a69d1418802
1 parent
a8fe2388
Exists in
parentassistant
考勤添加时间选择
Showing
10 changed files
with
250 additions
and
33 deletions
 
Show diff stats
ParentAssistant/ParentAssistant.xcodeproj/project.pbxproj
| @@ -61,6 +61,7 @@ | @@ -61,6 +61,7 @@ | ||
| 61 | AD5681CF2080449A0034A948 /* GrowCheckDownTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = AD5681CD2080449A0034A948 /* GrowCheckDownTableViewCell.xib */; }; | 61 | AD5681CF2080449A0034A948 /* GrowCheckDownTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = AD5681CD2080449A0034A948 /* GrowCheckDownTableViewCell.xib */; }; | 
| 62 | AD639F0520897CBC0028BE73 /* AlertShowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD639F0420897CBC0028BE73 /* AlertShowView.swift */; }; | 62 | AD639F0520897CBC0028BE73 /* AlertShowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD639F0420897CBC0028BE73 /* AlertShowView.swift */; }; | 
| 63 | AD639F072089C3950028BE73 /* LocationManger.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD639F062089C3950028BE73 /* LocationManger.swift */; }; | 63 | AD639F072089C3950028BE73 /* LocationManger.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD639F062089C3950028BE73 /* LocationManger.swift */; }; | 
| 64 | + AD639F092089D8670028BE73 /* PickSelectView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD639F082089D8670028BE73 /* PickSelectView.swift */; }; | ||
| 64 | AD64A2C0207F289400B25E80 /* ProgramVacateTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD64A2BE207F289400B25E80 /* ProgramVacateTableViewCell.swift */; }; | 65 | AD64A2C0207F289400B25E80 /* ProgramVacateTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD64A2BE207F289400B25E80 /* ProgramVacateTableViewCell.swift */; }; | 
| 65 | AD64A2C1207F289400B25E80 /* ProgramVacateTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = AD64A2BF207F289400B25E80 /* ProgramVacateTableViewCell.xib */; }; | 66 | AD64A2C1207F289400B25E80 /* ProgramVacateTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = AD64A2BF207F289400B25E80 /* ProgramVacateTableViewCell.xib */; }; | 
| 66 | AD64A2C3207F28CF00B25E80 /* ProgramVacateBodyTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD64A2C2207F28CF00B25E80 /* ProgramVacateBodyTableViewCell.swift */; }; | 67 | AD64A2C3207F28CF00B25E80 /* ProgramVacateBodyTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD64A2C2207F28CF00B25E80 /* ProgramVacateBodyTableViewCell.swift */; }; | 
| @@ -241,6 +242,7 @@ | @@ -241,6 +242,7 @@ | ||
| 241 | AD5681CD2080449A0034A948 /* GrowCheckDownTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = GrowCheckDownTableViewCell.xib; sourceTree = "<group>"; }; | 242 | AD5681CD2080449A0034A948 /* GrowCheckDownTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = GrowCheckDownTableViewCell.xib; sourceTree = "<group>"; }; | 
| 242 | AD639F0420897CBC0028BE73 /* AlertShowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertShowView.swift; sourceTree = "<group>"; }; | 243 | AD639F0420897CBC0028BE73 /* AlertShowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertShowView.swift; sourceTree = "<group>"; }; | 
| 243 | AD639F062089C3950028BE73 /* LocationManger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationManger.swift; sourceTree = "<group>"; }; | 244 | AD639F062089C3950028BE73 /* LocationManger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationManger.swift; sourceTree = "<group>"; }; | 
| 245 | + AD639F082089D8670028BE73 /* PickSelectView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PickSelectView.swift; sourceTree = "<group>"; }; | ||
| 244 | AD64A2BE207F289400B25E80 /* ProgramVacateTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgramVacateTableViewCell.swift; sourceTree = "<group>"; }; | 246 | AD64A2BE207F289400B25E80 /* ProgramVacateTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgramVacateTableViewCell.swift; sourceTree = "<group>"; }; | 
| 245 | AD64A2BF207F289400B25E80 /* ProgramVacateTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ProgramVacateTableViewCell.xib; sourceTree = "<group>"; }; | 247 | AD64A2BF207F289400B25E80 /* ProgramVacateTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ProgramVacateTableViewCell.xib; sourceTree = "<group>"; }; | 
| 246 | AD64A2C2207F28CF00B25E80 /* ProgramVacateBodyTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgramVacateBodyTableViewCell.swift; sourceTree = "<group>"; }; | 248 | AD64A2C2207F28CF00B25E80 /* ProgramVacateBodyTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgramVacateBodyTableViewCell.swift; sourceTree = "<group>"; }; | 
| @@ -889,6 +891,7 @@ | @@ -889,6 +891,7 @@ | ||
| 889 | BFF9B7F12057A28900F39B3E /* TableEmptyView.swift */, | 891 | BFF9B7F12057A28900F39B3E /* TableEmptyView.swift */, | 
| 890 | BFF9B7F32057A29D00F39B3E /* TableEmptyView.xib */, | 892 | BFF9B7F32057A29D00F39B3E /* TableEmptyView.xib */, | 
| 891 | AD639F0420897CBC0028BE73 /* AlertShowView.swift */, | 893 | AD639F0420897CBC0028BE73 /* AlertShowView.swift */, | 
| 894 | + AD639F082089D8670028BE73 /* PickSelectView.swift */, | ||
| 892 | ); | 895 | ); | 
| 893 | path = view; | 896 | path = view; | 
| 894 | sourceTree = "<group>"; | 897 | sourceTree = "<group>"; | 
| @@ -1196,6 +1199,7 @@ | @@ -1196,6 +1199,7 @@ | ||
| 1196 | BFF9B7F62057A4C900F39B3E /* ChildrenDetailViewController.swift in Sources */, | 1199 | BFF9B7F62057A4C900F39B3E /* ChildrenDetailViewController.swift in Sources */, | 
| 1197 | 599364FF204E945600C8B371 /* BindingViewController.swift in Sources */, | 1200 | 599364FF204E945600C8B371 /* BindingViewController.swift in Sources */, | 
| 1198 | 590944E020579CFA004478B5 /* InvitationCodeVerificationViewController.swift in Sources */, | 1201 | 590944E020579CFA004478B5 /* InvitationCodeVerificationViewController.swift in Sources */, | 
| 1202 | + AD639F092089D8670028BE73 /* PickSelectView.swift in Sources */, | ||
| 1199 | AD122AC120843FAF00C7D0AD /* ProgramVacateTextFieldCell.swift in Sources */, | 1203 | AD122AC120843FAF00C7D0AD /* ProgramVacateTextFieldCell.swift in Sources */, | 
| 1200 | ADC9AB77207C65FC00348EF1 /* GrowSubjectCell.swift in Sources */, | 1204 | ADC9AB77207C65FC00348EF1 /* GrowSubjectCell.swift in Sources */, | 
| 1201 | AD122AC5208442BC00C7D0AD /* ProgramVacateImageCell.swift in Sources */, | 1205 | AD122AC5208442BC00C7D0AD /* ProgramVacateImageCell.swift in Sources */, | 
ParentAssistant/ParentAssistant.xcworkspace/xcuserdata/caoyang.xcuserdatad/UserInterfaceState.xcuserstate
No preview for this file type
ParentAssistant/ParentAssistant.xcworkspace/xcuserdata/caoyang.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
| @@ -13,5 +13,21 @@ | @@ -13,5 +13,21 @@ | ||
| 13 | stopOnStyle = "0"> | 13 | stopOnStyle = "0"> | 
| 14 | </BreakpointContent> | 14 | </BreakpointContent> | 
| 15 | </BreakpointProxy> | 15 | </BreakpointProxy> | 
| 16 | + <BreakpointProxy | ||
| 17 | + BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> | ||
| 18 | + <BreakpointContent | ||
| 19 | + shouldBeEnabled = "Yes" | ||
| 20 | + ignoreCount = "0" | ||
| 21 | + continueAfterRunningActions = "No" | ||
| 22 | + filePath = "ParentAssistant/Classes/controllers/Grow/GrowViewController.swift" | ||
| 23 | + timestampString = "545907653.422401" | ||
| 24 | + startingColumnNumber = "9223372036854775807" | ||
| 25 | + endingColumnNumber = "9223372036854775807" | ||
| 26 | + startingLineNumber = "161" | ||
| 27 | + endingLineNumber = "161" | ||
| 28 | + landmarkName = "switchChildrenAction()" | ||
| 29 | + landmarkType = "7"> | ||
| 30 | + </BreakpointContent> | ||
| 31 | + </BreakpointProxy> | ||
| 16 | </Breakpoints> | 32 | </Breakpoints> | 
| 17 | </Bucket> | 33 | </Bucket> | 
ParentAssistant/ParentAssistant/Classes/controllers/Grow/GrowViewController.swift
| @@ -54,6 +54,8 @@ class GrowViewController: UIViewController,UIScrollViewDelegate { | @@ -54,6 +54,8 @@ class GrowViewController: UIViewController,UIScrollViewDelegate { | ||
| 54 | 54 | ||
| 55 | var titleLeftLab = UILabel() | 55 | var titleLeftLab = UILabel() | 
| 56 | 56 | ||
| 57 | + var childDataModel = StudentClassInfoModel() | ||
| 58 | + | ||
| 57 | //是否显示右侧按钮 | 59 | //是否显示右侧按钮 | 
| 58 | var rightBtn = UIBarButtonItem() | 60 | var rightBtn = UIBarButtonItem() | 
| 59 | 61 | ||
| @@ -71,8 +73,7 @@ class GrowViewController: UIViewController,UIScrollViewDelegate { | @@ -71,8 +73,7 @@ class GrowViewController: UIViewController,UIScrollViewDelegate { | ||
| 71 | setUpTitle() | 73 | setUpTitle() | 
| 72 | //顶部左右按钮 | 74 | //顶部左右按钮 | 
| 73 | drawHeadView() | 75 | drawHeadView() | 
| 74 | - //子控制器 | ||
| 75 | - setChildViewContent() | 76 | + | 
| 76 | //设置导航栏样式 | 77 | //设置导航栏样式 | 
| 77 | self.configTheme() | 78 | self.configTheme() | 
| 78 | } | 79 | } | 
| @@ -95,6 +96,9 @@ class GrowViewController: UIViewController,UIScrollViewDelegate { | @@ -95,6 +96,9 @@ class GrowViewController: UIViewController,UIScrollViewDelegate { | ||
| 95 | title = "未绑定" | 96 | title = "未绑定" | 
| 96 | }else{ | 97 | }else{ | 
| 97 | title = array[0].studentName | 98 | title = array[0].studentName | 
| 99 | + self.childDataModel = array[0] | ||
| 100 | + //子控制器 | ||
| 101 | + setChildViewContent() | ||
| 98 | } | 102 | } | 
| 99 | }else{ | 103 | }else{ | 
| 100 | title = "未登录" | 104 | title = "未登录" | 
| @@ -156,6 +160,7 @@ class GrowViewController: UIViewController,UIScrollViewDelegate { | @@ -156,6 +160,7 @@ class GrowViewController: UIViewController,UIScrollViewDelegate { | ||
| 156 | if object is StudentClassInfoModel { | 160 | if object is StudentClassInfoModel { | 
| 157 | let model = object as! StudentClassInfoModel | 161 | let model = object as! StudentClassInfoModel | 
| 158 | self.titleLeftLab.text = model.studentName | 162 | self.titleLeftLab.text = model.studentName | 
| 163 | + self.childDataModel = model | ||
| 159 | } | 164 | } | 
| 160 | } | 165 | } | 
| 161 | }else{ | 166 | }else{ | 
| @@ -189,10 +194,12 @@ class GrowViewController: UIViewController,UIScrollViewDelegate { | @@ -189,10 +194,12 @@ class GrowViewController: UIViewController,UIScrollViewDelegate { | ||
| 189 | for i in 0..<titleArr.count { | 194 | for i in 0..<titleArr.count { | 
| 190 | if i == 0 { | 195 | if i == 0 { | 
| 191 | let vc = ProgramViewController() | 196 | let vc = ProgramViewController() | 
| 197 | + vc.studentModel = self.childDataModel | ||
| 192 | self.addChildViewController(vc) | 198 | self.addChildViewController(vc) | 
| 193 | } | 199 | } | 
| 194 | if i == 1 { | 200 | if i == 1 { | 
| 195 | let vc = ReportViewController() | 201 | let vc = ReportViewController() | 
| 202 | + | ||
| 196 | self.addChildViewController(vc) | 203 | self.addChildViewController(vc) | 
| 197 | } | 204 | } | 
| 198 | } | 205 | } | 
ParentAssistant/ParentAssistant/Classes/controllers/Grow/Program/ProgramCardViewController.swift
| @@ -12,6 +12,9 @@ class ProgramCardViewController: UIViewController,UITextFieldDelegate { | @@ -12,6 +12,9 @@ class ProgramCardViewController: UIViewController,UITextFieldDelegate { | ||
| 12 | 12 | ||
| 13 | var cardInputTextField = UITextField() | 13 | var cardInputTextField = UITextField() | 
| 14 | 14 | ||
| 15 | + //孩子数据 | ||
| 16 | + var studentData = StudentClassInfoModel() | ||
| 17 | + | ||
| 15 | lazy var cardView = { ()-> UIView in | 18 | lazy var cardView = { ()-> UIView in | 
| 16 | 19 | ||
| 17 | let view = UIView.init(frame: CGRect.init(x: 10, y: 10, width: screenWidth-20, height: 100)) | 20 | let view = UIView.init(frame: CGRect.init(x: 10, y: 10, width: screenWidth-20, height: 100)) | 
| @@ -50,10 +53,10 @@ class ProgramCardViewController: UIViewController,UITextFieldDelegate { | @@ -50,10 +53,10 @@ class ProgramCardViewController: UIViewController,UITextFieldDelegate { | ||
| 50 | super.viewDidLoad() | 53 | super.viewDidLoad() | 
| 51 | 54 | ||
| 52 | self.view.addSubview(self.rootView) | 55 | self.view.addSubview(self.rootView) | 
| 53 | - | ||
| 54 | self.rootView.addSubview(self.cardView) | 56 | self.rootView.addSubview(self.cardView) | 
| 55 | self.rootView.addSubview(self.bottomBtn) | 57 | self.rootView.addSubview(self.bottomBtn) | 
| 56 | self.rootView.contentSize = CGSize.init(width: 0, height: screenHeight+1) | 58 | self.rootView.contentSize = CGSize.init(width: 0, height: screenHeight+1) | 
| 59 | + | ||
| 57 | setUpContentView() | 60 | setUpContentView() | 
| 58 | // Do any additional setup after loading the view. | 61 | // Do any additional setup after loading the view. | 
| 59 | 62 | ||
| @@ -76,13 +79,18 @@ class ProgramCardViewController: UIViewController,UITextFieldDelegate { | @@ -76,13 +79,18 @@ class ProgramCardViewController: UIViewController,UITextFieldDelegate { | ||
| 76 | cardLable.text = "补卡人:" | 79 | cardLable.text = "补卡人:" | 
| 77 | 80 | ||
| 78 | let cardName = UILabel.init(frame: CGRect.init(x: 110, y: 10, width: 100, height: 30)) | 81 | let cardName = UILabel.init(frame: CGRect.init(x: 110, y: 10, width: 100, height: 30)) | 
| 79 | - cardName.text = "张三" | 82 | + cardName.text = self.studentData.studentName | 
| 80 | 83 | ||
| 81 | let cardNumberLab = UILabel.init(frame: CGRect.init(x: 10, y: 50, width: 100, height: 30)) | 84 | let cardNumberLab = UILabel.init(frame: CGRect.init(x: 10, y: 50, width: 100, height: 30)) | 
| 82 | cardNumberLab.text = "卡号:" | 85 | cardNumberLab.text = "卡号:" | 
| 83 | 86 | ||
| 84 | let cardNumberInput = UITextField.init(frame: CGRect.init(x: 110, y: 50, width: screenWidth-120, height: 30)) | 87 | let cardNumberInput = UITextField.init(frame: CGRect.init(x: 110, y: 50, width: screenWidth-120, height: 30)) | 
| 85 | cardNumberInput.placeholder = "请输入卡号" | 88 | cardNumberInput.placeholder = "请输入卡号" | 
| 89 | + let card = self.studentData.cardNumber | ||
| 90 | + if card.count>0 { | ||
| 91 | + cardNumberInput.text = card | ||
| 92 | + } | ||
| 93 | + | ||
| 86 | cardNumberInput.keyboardType = .numbersAndPunctuation | 94 | cardNumberInput.keyboardType = .numbersAndPunctuation | 
| 87 | cardNumberInput.delegate = self | 95 | cardNumberInput.delegate = self | 
| 88 | self.cardInputTextField = cardNumberInput | 96 | self.cardInputTextField = cardNumberInput | 
ParentAssistant/ParentAssistant/Classes/controllers/Grow/Program/ProgramCheckViewController.swift
| @@ -22,30 +22,36 @@ class ProgramCheckViewController: UIViewController,UITableViewDelegate,UITableVi | @@ -22,30 +22,36 @@ class ProgramCheckViewController: UIViewController,UITableViewDelegate,UITableVi | ||
| 22 | return table | 22 | return table | 
| 23 | }() | 23 | }() | 
| 24 | 24 | ||
| 25 | - var studentName:String? | ||
| 26 | lazy var formatter = {()->DateFormatter in | 25 | lazy var formatter = {()->DateFormatter in | 
| 27 | let matter = DateFormatter.init() | 26 | let matter = DateFormatter.init() | 
| 28 | matter.dateFormat = "yyyy-MM-dd" | 27 | matter.dateFormat = "yyyy-MM-dd" | 
| 29 | return matter | 28 | return matter | 
| 30 | }() | 29 | }() | 
| 30 | + //考勤数据 | ||
| 31 | var viewData = Array<StudentCardModel>() | 31 | var viewData = Array<StudentCardModel>() | 
| 32 | - | 32 | + //孩子数据模型 | 
| 33 | + var studentModel = StudentClassInfoModel() | ||
| 34 | + //时间选择器 | ||
| 35 | + var addAlertView = PickSelectView() | ||
| 36 | + //选择的时间 | ||
| 37 | + var timeSelectString = String() | ||
| 33 | 38 | ||
| 34 | override func viewDidLoad() { | 39 | override func viewDidLoad() { | 
| 35 | super.viewDidLoad() | 40 | super.viewDidLoad() | 
| 36 | 41 | ||
| 37 | - self.studentName = AccountManager.shared.rawUserInfo?.contentData()["studentClass"][0]["studentName"].string | ||
| 38 | - | ||
| 39 | - self.view.addSubview(self.tableView) | 42 | + timeSelectString = self.formatter.string(from:Date()) | 
| 40 | 43 | ||
| 44 | + self.addAlertView = PickSelectView.init(frame: CGRect.init(x: 0, y: screenHeight-200, width: screenWidth, height: 200)) | ||
| 45 | + self.view.addSubview(self.tableView) | ||
| 46 | + | ||
| 41 | // Do any additional setup after loading the view. | 47 | // Do any additional setup after loading the view. | 
| 42 | - downLoadDataFromNet() | 48 | + downLoadDataFromNet(time: self.formatter.string(from: Date())) | 
| 43 | } | 49 | } | 
| 44 | 50 | ||
| 45 | /// 获取数据 | 51 | /// 获取数据 | 
| 46 | - private func downLoadDataFromNet(){ | 52 | + private func downLoadDataFromNet(time:String){ | 
| 47 | SVProgressHUD.show() | 53 | SVProgressHUD.show() | 
| 48 | - let params = ["studentid":185,"schoolid":1,"starttime":"2017-07-19"] as [String : Any] | 54 | + let params = ["studentid":studentModel.studentId,"schoolid":studentModel.schollId,"starttime":time] as [String : Any] | 
| 49 | HTTPServer.shared.getStudentCheckList(parameters: params as [String : AnyObject]) { (backData, error) in | 55 | HTTPServer.shared.getStudentCheckList(parameters: params as [String : AnyObject]) { (backData, error) in | 
| 50 | SVProgressHUD.dismiss() | 56 | SVProgressHUD.dismiss() | 
| 51 | if error == nil && JSON.fromString(backData)!["status"].intValue == 1 { | 57 | if error == nil && JSON.fromString(backData)!["status"].intValue == 1 { | 
| @@ -61,7 +67,7 @@ class ProgramCheckViewController: UIViewController,UITableViewDelegate,UITableVi | @@ -61,7 +67,7 @@ class ProgramCheckViewController: UIViewController,UITableViewDelegate,UITableVi | ||
| 61 | } | 67 | } | 
| 62 | } | 68 | } | 
| 63 | } | 69 | } | 
| 64 | - | 70 | + | 
| 65 | 71 | ||
| 66 | //MARK: - TableView Delegate && DataSource | 72 | //MARK: - TableView Delegate && DataSource | 
| 67 | func numberOfSections(in tableView: UITableView) -> Int { | 73 | func numberOfSections(in tableView: UITableView) -> Int { | 
| @@ -82,18 +88,33 @@ class ProgramCheckViewController: UIViewController,UITableViewDelegate,UITableVi | @@ -82,18 +88,33 @@ class ProgramCheckViewController: UIViewController,UITableViewDelegate,UITableVi | ||
| 82 | if indexPath.row == 0 { | 88 | if indexPath.row == 0 { | 
| 83 | let cell = tableView.dequeueReusableCell(withIdentifier: "GrowCheckUpTableViewCell", for: indexPath) as! GrowCheckUpTableViewCell | 89 | let cell = tableView.dequeueReusableCell(withIdentifier: "GrowCheckUpTableViewCell", for: indexPath) as! GrowCheckUpTableViewCell | 
| 84 | cell.checkCount.text = "\(self.viewData.count)" | 90 | cell.checkCount.text = "\(self.viewData.count)" | 
| 85 | - cell.checkDate.text = self.formatter.string(from: Date()) | ||
| 86 | - cell.checkName.text = studentName | 91 | + cell.timeSelectBtn.setTitle(timeSelectString, for: UIControlState.normal) | 
| 92 | + cell.checkName.text = studentModel.studentName | ||
| 93 | + cell.backBlock = { | ||
| 94 | + print("选择日期") | ||
| 95 | + self.selectTimeAction() | ||
| 96 | + } | ||
| 87 | return cell | 97 | return cell | 
| 88 | }else{ | 98 | }else{ | 
| 89 | let cell = tableView.dequeueReusableCell(withIdentifier: "GrowCheckDownTableViewCell", for: indexPath) as! GrowCheckDownTableViewCell | 99 | let cell = tableView.dequeueReusableCell(withIdentifier: "GrowCheckDownTableViewCell", for: indexPath) as! GrowCheckDownTableViewCell | 
| 90 | let model = self.viewData[indexPath.row-1] | 100 | let model = self.viewData[indexPath.row-1] | 
| 91 | - cell.studentParents.text = "尊敬的\(studentName!)家长" | 101 | + cell.studentParents.text = "尊敬的\(studentModel.studentName)家长" | 
| 92 | cell.setCellData(model: model) | 102 | cell.setCellData(model: model) | 
| 93 | return cell | 103 | return cell | 
| 94 | } | 104 | } | 
| 95 | } | 105 | } | 
| 96 | 106 | ||
| 107 | + /// 展示时间选择器 | ||
| 108 | + func selectTimeAction() { | ||
| 109 | + self.addAlertView.setRowAndTitle(title: [], type: PickSelectView.AlertType.TimeDateType) | ||
| 110 | + self.addAlertView.showView() | ||
| 111 | + self.addAlertView.alertTimeBlock = {str in | ||
| 112 | + print("backdata= \(str)") | ||
| 113 | + self.timeSelectString = str | ||
| 114 | + self.downLoadDataFromNet(time: str) | ||
| 115 | + } | ||
| 116 | + } | ||
| 117 | + | ||
| 97 | override func didReceiveMemoryWarning() { | 118 | override func didReceiveMemoryWarning() { | 
| 98 | super.didReceiveMemoryWarning() | 119 | super.didReceiveMemoryWarning() | 
| 99 | // Dispose of any resources that can be recreated. | 120 | // Dispose of any resources that can be recreated. | 
ParentAssistant/ParentAssistant/Classes/controllers/Grow/Program/ProgramViewController.swift
| @@ -50,8 +50,10 @@ class ProgramViewController: UIViewController,UITableViewDelegate,UITableViewDat | @@ -50,8 +50,10 @@ class ProgramViewController: UIViewController,UITableViewDelegate,UITableViewDat | ||
| 50 | 50 | ||
| 51 | //Data | 51 | //Data | 
| 52 | var tableData = Array<String>() | 52 | var tableData = Array<String>() | 
| 53 | - var titleImage = Array<String>() | 53 | + //孩子数据 | 
| 54 | + var studentModel = StudentClassInfoModel() | ||
| 54 | 55 | ||
| 56 | + var titleImage = Array<String>() | ||
| 55 | 57 | ||
| 56 | override func viewWillAppear(_ animated: Bool) { | 58 | override func viewWillAppear(_ animated: Bool) { | 
| 57 | 59 | ||
| @@ -69,7 +71,6 @@ class ProgramViewController: UIViewController,UITableViewDelegate,UITableViewDat | @@ -69,7 +71,6 @@ class ProgramViewController: UIViewController,UITableViewDelegate,UITableViewDat | ||
| 69 | override func viewDidLoad() { | 71 | override func viewDidLoad() { | 
| 70 | super.viewDidLoad() | 72 | super.viewDidLoad() | 
| 71 | self.view.backgroundColor = backGroundColor | 73 | self.view.backgroundColor = backGroundColor | 
| 72 | - | ||
| 73 | self.view.addSubview(self.tableView) | 74 | self.view.addSubview(self.tableView) | 
| 74 | 75 | ||
| 75 | self.tableData = ["考勤","补卡","请假"] | 76 | self.tableData = ["考勤","补卡","请假"] | 
| @@ -118,10 +119,12 @@ class ProgramViewController: UIViewController,UITableViewDelegate,UITableViewDat | @@ -118,10 +119,12 @@ class ProgramViewController: UIViewController,UITableViewDelegate,UITableViewDat | ||
| 118 | case 0: | 119 | case 0: | 
| 119 | let vc = ProgramCheckViewController() | 120 | let vc = ProgramCheckViewController() | 
| 120 | vc.title = "考勤" | 121 | vc.title = "考勤" | 
| 122 | + vc.studentModel = self.studentModel | ||
| 121 | self.navigationController?.pushViewController(vc, animated: true) | 123 | self.navigationController?.pushViewController(vc, animated: true) | 
| 122 | case 1: | 124 | case 1: | 
| 123 | let vc = ProgramCardViewController() | 125 | let vc = ProgramCardViewController() | 
| 124 | vc.title = "补卡" | 126 | vc.title = "补卡" | 
| 127 | + vc.studentData = self.studentModel | ||
| 125 | self.navigationController?.pushViewController(vc, animated: true) | 128 | self.navigationController?.pushViewController(vc, animated: true) | 
| 126 | case 2: | 129 | case 2: | 
| 127 | let vc = ProgramVacateViewController() | 130 | let vc = ProgramVacateViewController() | 
ParentAssistant/ParentAssistant/Classes/controllers/Grow/View/ProgramView/GrowCheckUpTableViewCell.swift
| @@ -8,11 +8,14 @@ | @@ -8,11 +8,14 @@ | ||
| 8 | 8 | ||
| 9 | import UIKit | 9 | import UIKit | 
| 10 | 10 | ||
| 11 | +public typealias cellBackBlock = ()->Void | ||
| 12 | + | ||
| 11 | class GrowCheckUpTableViewCell: UITableViewCell { | 13 | class GrowCheckUpTableViewCell: UITableViewCell { | 
| 12 | 14 | ||
| 13 | @IBOutlet weak var checkName: UILabel! | 15 | @IBOutlet weak var checkName: UILabel! | 
| 14 | - @IBOutlet weak var checkDate: UILabel! | 16 | + @IBOutlet weak var timeSelectBtn: UIButton! | 
| 15 | @IBOutlet weak var checkCount: UILabel! | 17 | @IBOutlet weak var checkCount: UILabel! | 
| 18 | + var backBlock : cellBackBlock? | ||
| 16 | override func awakeFromNib() { | 19 | override func awakeFromNib() { | 
| 17 | super.awakeFromNib() | 20 | super.awakeFromNib() | 
| 18 | self.backgroundColor = backGroundColor | 21 | self.backgroundColor = backGroundColor | 
| @@ -20,6 +23,9 @@ class GrowCheckUpTableViewCell: UITableViewCell { | @@ -20,6 +23,9 @@ class GrowCheckUpTableViewCell: UITableViewCell { | ||
| 20 | // Initialization code | 23 | // Initialization code | 
| 21 | } | 24 | } | 
| 22 | 25 | ||
| 26 | + @IBAction func SelectAction(_ sender: Any) { | ||
| 27 | + self.backBlock!() | ||
| 28 | + } | ||
| 23 | override func setSelected(_ selected: Bool, animated: Bool) { | 29 | override func setSelected(_ selected: Bool, animated: Bool) { | 
| 24 | super.setSelected(selected, animated: animated) | 30 | super.setSelected(selected, animated: animated) | 
| 25 | 31 | 
ParentAssistant/ParentAssistant/Classes/controllers/Grow/View/ProgramView/GrowCheckUpTableViewCell.xib
| @@ -20,7 +20,7 @@ | @@ -20,7 +20,7 @@ | ||
| 20 | <autoresizingMask key="autoresizingMask"/> | 20 | <autoresizingMask key="autoresizingMask"/> | 
| 21 | <subviews> | 21 | <subviews> | 
| 22 | <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="4bl-Ug-Jkf"> | 22 | <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="4bl-Ug-Jkf"> | 
| 23 | - <rect key="frame" x="10" y="10" width="300" height="109.5"/> | 23 | + <rect key="frame" x="10" y="10" width="300" height="110"/> | 
| 24 | <subviews> | 24 | <subviews> | 
| 25 | <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="考勤对象:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ExJ-Vr-Gtw"> | 25 | <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="考勤对象:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ExJ-Vr-Gtw"> | 
| 26 | <rect key="frame" x="10" y="10" width="74" height="21"/> | 26 | <rect key="frame" x="10" y="10" width="74" height="21"/> | 
| @@ -29,7 +29,7 @@ | @@ -29,7 +29,7 @@ | ||
| 29 | <nil key="highlightedColor"/> | 29 | <nil key="highlightedColor"/> | 
| 30 | </label> | 30 | </label> | 
| 31 | <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="张三" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="OoZ-Pq-CLb"> | 31 | <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="张三" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="OoZ-Pq-CLb"> | 
| 32 | - <rect key="frame" x="94" y="10" width="35" height="21"/> | 32 | + <rect key="frame" x="132.5" y="10" width="35" height="21"/> | 
| 33 | <fontDescription key="fontDescription" type="system" pointSize="17"/> | 33 | <fontDescription key="fontDescription" type="system" pointSize="17"/> | 
| 34 | <nil key="textColor"/> | 34 | <nil key="textColor"/> | 
| 35 | <nil key="highlightedColor"/> | 35 | <nil key="highlightedColor"/> | 
| @@ -40,12 +40,6 @@ | @@ -40,12 +40,6 @@ | ||
| 40 | <nil key="textColor"/> | 40 | <nil key="textColor"/> | 
| 41 | <nil key="highlightedColor"/> | 41 | <nil key="highlightedColor"/> | 
| 42 | </label> | 42 | </label> | 
| 43 | - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="2018-04-02" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="PQL-0B-hTy"> | ||
| 44 | - <rect key="frame" x="94" y="41" width="95" height="21"/> | ||
| 45 | - <fontDescription key="fontDescription" type="system" pointSize="17"/> | ||
| 46 | - <nil key="textColor"/> | ||
| 47 | - <nil key="highlightedColor"/> | ||
| 48 | - </label> | ||
| 49 | <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="考勤次数:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SdL-gq-fnS"> | 43 | <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="考勤次数:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SdL-gq-fnS"> | 
| 50 | <rect key="frame" x="10" y="72" width="74" height="21"/> | 44 | <rect key="frame" x="10" y="72" width="74" height="21"/> | 
| 51 | <fontDescription key="fontDescription" type="system" pointSize="17"/> | 45 | <fontDescription key="fontDescription" type="system" pointSize="17"/> | 
| @@ -53,19 +47,31 @@ | @@ -53,19 +47,31 @@ | ||
| 53 | <nil key="highlightedColor"/> | 47 | <nil key="highlightedColor"/> | 
| 54 | </label> | 48 | </label> | 
| 55 | <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="2次" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ix0-QT-dOr"> | 49 | <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="2次" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ix0-QT-dOr"> | 
| 56 | - <rect key="frame" x="94" y="72" width="28" height="21"/> | 50 | + <rect key="frame" x="136" y="72" width="28" height="21"/> | 
| 57 | <fontDescription key="fontDescription" type="system" pointSize="17"/> | 51 | <fontDescription key="fontDescription" type="system" pointSize="17"/> | 
| 58 | <nil key="textColor"/> | 52 | <nil key="textColor"/> | 
| 59 | <nil key="highlightedColor"/> | 53 | <nil key="highlightedColor"/> | 
| 60 | </label> | 54 | </label> | 
| 55 | + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="SNs-cj-fGX"> | ||
| 56 | + <rect key="frame" x="75" y="36.5" width="150" height="30"/> | ||
| 57 | + <constraints> | ||
| 58 | + <constraint firstAttribute="width" constant="150" id="4lv-05-kSf"/> | ||
| 59 | + <constraint firstAttribute="height" constant="30" id="oDo-0P-h4l"/> | ||
| 60 | + </constraints> | ||
| 61 | + <state key="normal" title="2018-04-20"> | ||
| 62 | + <color key="titleColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> | ||
| 63 | + </state> | ||
| 64 | + <connections> | ||
| 65 | + <action selector="SelectAction:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="Yvc-N7-yzq"/> | ||
| 66 | + </connections> | ||
| 67 | + </button> | ||
| 61 | </subviews> | 68 | </subviews> | 
| 62 | <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> | 69 | <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> | 
| 63 | <constraints> | 70 | <constraints> | 
| 64 | <constraint firstItem="tmY-YA-dJD" firstAttribute="leading" secondItem="ExJ-Vr-Gtw" secondAttribute="leading" id="3Pa-wB-2lr"/> | 71 | <constraint firstItem="tmY-YA-dJD" firstAttribute="leading" secondItem="ExJ-Vr-Gtw" secondAttribute="leading" id="3Pa-wB-2lr"/> | 
| 65 | - <constraint firstItem="PQL-0B-hTy" firstAttribute="centerY" secondItem="tmY-YA-dJD" secondAttribute="centerY" id="BEz-Ng-xFW"/> | ||
| 66 | - <constraint firstItem="PQL-0B-hTy" firstAttribute="leading" secondItem="tmY-YA-dJD" secondAttribute="trailing" constant="10" id="C6P-sS-Ti3"/> | ||
| 67 | - <constraint firstItem="ix0-QT-dOr" firstAttribute="leading" secondItem="SdL-gq-fnS" secondAttribute="trailing" constant="10" id="C7D-Xp-8fA"/> | ||
| 68 | - <constraint firstItem="OoZ-Pq-CLb" firstAttribute="leading" secondItem="ExJ-Vr-Gtw" secondAttribute="trailing" constant="10" id="CV2-qX-bM9"/> | 72 | + <constraint firstItem="SNs-cj-fGX" firstAttribute="centerY" secondItem="tmY-YA-dJD" secondAttribute="centerY" id="424-d4-Q7g"/> | 
| 73 | + <constraint firstItem="ix0-QT-dOr" firstAttribute="centerX" secondItem="4bl-Ug-Jkf" secondAttribute="centerX" id="C7D-Xp-8fA"/> | ||
| 74 | + <constraint firstItem="OoZ-Pq-CLb" firstAttribute="centerX" secondItem="4bl-Ug-Jkf" secondAttribute="centerX" id="CV2-qX-bM9"/> | ||
| 69 | <constraint firstItem="ix0-QT-dOr" firstAttribute="centerY" secondItem="SdL-gq-fnS" secondAttribute="centerY" id="DbP-xw-6R6"/> | 75 | <constraint firstItem="ix0-QT-dOr" firstAttribute="centerY" secondItem="SdL-gq-fnS" secondAttribute="centerY" id="DbP-xw-6R6"/> | 
| 70 | <constraint firstItem="tmY-YA-dJD" firstAttribute="top" secondItem="ExJ-Vr-Gtw" secondAttribute="bottom" constant="10" id="Feh-ug-yAO"/> | 76 | <constraint firstItem="tmY-YA-dJD" firstAttribute="top" secondItem="ExJ-Vr-Gtw" secondAttribute="bottom" constant="10" id="Feh-ug-yAO"/> | 
| 71 | <constraint firstItem="OoZ-Pq-CLb" firstAttribute="centerY" secondItem="ExJ-Vr-Gtw" secondAttribute="centerY" id="GSd-kH-4nO"/> | 77 | <constraint firstItem="OoZ-Pq-CLb" firstAttribute="centerY" secondItem="ExJ-Vr-Gtw" secondAttribute="centerY" id="GSd-kH-4nO"/> | 
| @@ -73,6 +79,7 @@ | @@ -73,6 +79,7 @@ | ||
| 73 | <constraint firstItem="SdL-gq-fnS" firstAttribute="leading" secondItem="tmY-YA-dJD" secondAttribute="leading" id="Ig0-4D-3dH"/> | 79 | <constraint firstItem="SdL-gq-fnS" firstAttribute="leading" secondItem="tmY-YA-dJD" secondAttribute="leading" id="Ig0-4D-3dH"/> | 
| 74 | <constraint firstItem="SdL-gq-fnS" firstAttribute="top" secondItem="tmY-YA-dJD" secondAttribute="bottom" constant="10" id="XIM-uQ-5fp"/> | 80 | <constraint firstItem="SdL-gq-fnS" firstAttribute="top" secondItem="tmY-YA-dJD" secondAttribute="bottom" constant="10" id="XIM-uQ-5fp"/> | 
| 75 | <constraint firstItem="ExJ-Vr-Gtw" firstAttribute="top" secondItem="4bl-Ug-Jkf" secondAttribute="top" constant="10" id="dYP-XR-ZhS"/> | 81 | <constraint firstItem="ExJ-Vr-Gtw" firstAttribute="top" secondItem="4bl-Ug-Jkf" secondAttribute="top" constant="10" id="dYP-XR-ZhS"/> | 
| 82 | + <constraint firstItem="SNs-cj-fGX" firstAttribute="centerX" secondItem="4bl-Ug-Jkf" secondAttribute="centerX" id="nX3-sb-mWe"/> | ||
| 76 | </constraints> | 83 | </constraints> | 
| 77 | </view> | 84 | </view> | 
| 78 | </subviews> | 85 | </subviews> | 
| @@ -86,8 +93,8 @@ | @@ -86,8 +93,8 @@ | ||
| 86 | <viewLayoutGuide key="safeArea" id="njF-e1-oar"/> | 93 | <viewLayoutGuide key="safeArea" id="njF-e1-oar"/> | 
| 87 | <connections> | 94 | <connections> | 
| 88 | <outlet property="checkCount" destination="ix0-QT-dOr" id="S2d-me-Lfu"/> | 95 | <outlet property="checkCount" destination="ix0-QT-dOr" id="S2d-me-Lfu"/> | 
| 89 | - <outlet property="checkDate" destination="PQL-0B-hTy" id="oje-oo-bif"/> | ||
| 90 | <outlet property="checkName" destination="OoZ-Pq-CLb" id="47o-Bv-QW8"/> | 96 | <outlet property="checkName" destination="OoZ-Pq-CLb" id="47o-Bv-QW8"/> | 
| 97 | + <outlet property="timeSelectBtn" destination="SNs-cj-fGX" id="dpG-p6-Ldf"/> | ||
| 91 | </connections> | 98 | </connections> | 
| 92 | <point key="canvasLocation" x="-30" y="-35.5"/> | 99 | <point key="canvasLocation" x="-30" y="-35.5"/> | 
| 93 | </tableViewCell> | 100 | </tableViewCell> | 
ParentAssistant/ParentAssistant/Classes/util/view/PickSelectView.swift
0 → 100644
| @@ -0,0 +1,145 @@ | @@ -0,0 +1,145 @@ | ||
| 1 | +// | ||
| 2 | +// PickSelectView.swift | ||
| 3 | +// ParentAssistant | ||
| 4 | +// | ||
| 5 | +// Created by Cao yang on 2018/4/20. | ||
| 6 | +// Copyright © 2018年 HANGZHOUTEAM. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +import UIKit | ||
| 10 | + | ||
| 11 | + | ||
| 12 | + | ||
| 13 | +/// 返回数据block | ||
| 14 | +typealias AlertViewBackData = (Dictionary<String, JSON>)->() | ||
| 15 | +/// 返回时间block | ||
| 16 | +typealias AlertTimeBlock = (String)->() | ||
| 17 | +/// 选择器 | ||
| 18 | +class PickSelectView:UIView,UIPickerViewDelegate,UIPickerViewDataSource { | ||
| 19 | + | ||
| 20 | + enum AlertType { | ||
| 21 | + case NormalType | ||
| 22 | + case TimeDateType | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + var keyWindow = UIWindow() | ||
| 26 | + var backBtn = UIButton() | ||
| 27 | + var leftBtn = UIButton() | ||
| 28 | + | ||
| 29 | + var datePicker = UIDatePicker() | ||
| 30 | + var alertView = UIPickerView() | ||
| 31 | + var alertBlock : AlertViewBackData? | ||
| 32 | + var alertTimeBlock : AlertTimeBlock? | ||
| 33 | + var selfType = AlertType.NormalType | ||
| 34 | + | ||
| 35 | + //data | ||
| 36 | + //一般类型数据 | ||
| 37 | + var titleArr = Array<JSON>() | ||
| 38 | + var Components = Int() | ||
| 39 | + var Rows = Int() | ||
| 40 | + var selectStr = String() //normal | ||
| 41 | + //日期类型数据 | ||
| 42 | + var selectDate = String() //date | ||
| 43 | + //日期格式 | ||
| 44 | + lazy var formatter = {()-> DateFormatter in | ||
| 45 | + let forma = DateFormatter() | ||
| 46 | + forma.dateFormat = "yyyy-MM-dd" | ||
| 47 | + return forma | ||
| 48 | + }() | ||
| 49 | + | ||
| 50 | + override init(frame: CGRect) { | ||
| 51 | + super.init(frame: frame) | ||
| 52 | + self.backgroundColor = UIColor.white | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + func setRowAndTitle(title:Array<JSON>,type:AlertType){ | ||
| 56 | + | ||
| 57 | + self.selfType = type | ||
| 58 | + | ||
| 59 | + switch type { | ||
| 60 | + case .NormalType: | ||
| 61 | + self.alertView = UIPickerView.init(frame: self.bounds) | ||
| 62 | + self.Components = 1 | ||
| 63 | + self.Rows = title.count | ||
| 64 | + self.titleArr = title | ||
| 65 | + self.alertView.delegate = self | ||
| 66 | + self.alertView.dataSource = self | ||
| 67 | + self.addSubview(self.alertView) | ||
| 68 | + | ||
| 69 | + case .TimeDateType: | ||
| 70 | + self.datePicker = UIDatePicker.init(frame: self.bounds) | ||
| 71 | + self.datePicker.locale = Locale.init(identifier: "zh_CN") | ||
| 72 | + self.datePicker.datePickerMode = .date | ||
| 73 | + self.datePicker.addTarget(self, action: #selector(dateChanged), for: UIControlEvents.valueChanged) | ||
| 74 | + self.addSubview(self.datePicker) | ||
| 75 | + self.selectDate = self.formatter.string(from: Date()) | ||
| 76 | + self.alertTimeBlock?(self.selectDate) | ||
| 77 | + } | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + @objc func dateChanged(datePicker:UIDatePicker) { | ||
| 81 | + | ||
| 82 | + self.selectDate = self.formatter.string(from: datePicker.date) | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + @objc func showView(){ | ||
| 86 | + | ||
| 87 | + keyWindow = UIApplication.shared.keyWindow! | ||
| 88 | + backBtn = UIButton.init(frame: CGRect.init(x: 0,y: 0, width: screenWidth, height: screenHeight-200)) | ||
| 89 | + backBtn.backgroundColor = UIColor.black | ||
| 90 | + backBtn.alpha = 0.4 | ||
| 91 | + | ||
| 92 | + backBtn.addTarget(self, action: #selector(closeView), for: UIControlEvents.allEvents) | ||
| 93 | + | ||
| 94 | + | ||
| 95 | + leftBtn = UIButton.init(frame: CGRect.init(x: 0, y: screenHeight-200, width: 80, height: 40)) | ||
| 96 | + leftBtn.setTitle("确定", for: UIControlState.normal) | ||
| 97 | + leftBtn.titleLabel?.textAlignment = .center | ||
| 98 | + leftBtn.setTitleColor(UIColor.black, for: UIControlState.normal) | ||
| 99 | + leftBtn.tag = 1 | ||
| 100 | + leftBtn.addTarget(self, action: #selector(closeView), for: UIControlEvents.touchUpInside) | ||
| 101 | + | ||
| 102 | + keyWindow.addSubview(backBtn) | ||
| 103 | + keyWindow.addSubview(self) | ||
| 104 | + keyWindow.addSubview(leftBtn) | ||
| 105 | + self.isHidden = false | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + @objc func closeView() { | ||
| 109 | + | ||
| 110 | + switch self.selfType { | ||
| 111 | + case .TimeDateType: | ||
| 112 | + self.alertTimeBlock?(self.selectDate) | ||
| 113 | + default: | ||
| 114 | + break | ||
| 115 | + } | ||
| 116 | + UIView.animate(withDuration: 0.3) { | ||
| 117 | + self.backBtn.removeFromSuperview() | ||
| 118 | + self.leftBtn.removeFromSuperview() | ||
| 119 | + self.alertView.removeFromSuperview() | ||
| 120 | + self.datePicker.removeFromSuperview() | ||
| 121 | + self.isHidden = true | ||
| 122 | + } | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + required init?(coder aDecoder: NSCoder) { | ||
| 126 | + fatalError("init(coder:) has not been implemented") | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + func numberOfComponents(in pickerView: UIPickerView) -> Int { | ||
| 130 | + return Components | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { | ||
| 134 | + return Rows | ||
| 135 | + } | ||
| 136 | + func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { | ||
| 137 | + let dic = titleArr[row].dictionaryValue | ||
| 138 | + return dic["dimensionName"]?.stringValue | ||
| 139 | + } | ||
| 140 | + func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { | ||
| 141 | + let dic = titleArr[row].dictionaryValue | ||
| 142 | + self.alertBlock?(dic) | ||
| 143 | + } | ||
| 144 | +} | ||
| 145 | + |