| | |
| | | private var itemType:ItemType! |
| | | private var selectStudents = [Any]() |
| | | private var disposeBag = DisposeBag() |
| | | |
| | | private var authGender:Int? |
| | | private var authAgeRange:(min:Int,max:Int)? |
| | | |
| | | |
| | | private lazy var stuViewModel:StudentViewModel = { |
| | | return StudentViewModel() |
| | |
| | | setRx() |
| | | } |
| | | |
| | | static func show(itemType:ItemType,defaultStu:[Any]? = nil,isAuth:Int? = nil,clickClouse:@escaping ([Any])->Void,needAddClouse:@escaping ()->Void){ |
| | | static func show(itemType:ItemType,defaultStu:[Any]? = nil,isAuth:Int? = nil,authGender:Int? = nil,authAgeRange:(min:Int,max:Int)? = nil,clickClouse:@escaping ([Any])->Void,needAddClouse:@escaping ()->Void){ |
| | | let studentChooseView = StudentChooseView.jq_loadNibView() |
| | | if defaultStu != nil{ |
| | | studentChooseView.selectStudents = defaultStu! |
| | |
| | | if itemType == .course{ |
| | | studentChooseView.tableView.register(UINib(nibName: "StudentInfoTCell", bundle: nil), forCellReuseIdentifier: "_StudentInfoTCell") |
| | | studentChooseView.btn_add.setTitle("添加运动营成员", for: .normal) |
| | | }else if itemType == .activity{ |
| | | }else{ |
| | | studentChooseView.tableView.register(UINib(nibName: "StudentInfo_2_TCell", bundle: nil), forCellReuseIdentifier: "_StudentInfo_2_TCell") |
| | | studentChooseView.btn_add.setTitle("添加人员", for: .normal) |
| | | } |
| | |
| | | studentChooseView.itemType = itemType |
| | | studentChooseView.clickClouse = clickClouse |
| | | studentChooseView.needAddClouse = needAddClouse |
| | | studentChooseView.authGender = authGender |
| | | studentChooseView.authAgeRange = authAgeRange |
| | | sceneDelegate?.window?.addSubview(studentChooseView) |
| | | studentChooseView.cons_bottom.constant = 0 |
| | | |
| | |
| | | } |
| | | }else{ |
| | | let item = actViewModel.dataSource.value[indexPath.row] |
| | | |
| | | |
| | | if authGender != nil{ |
| | | if item.gender.rawValue != authGender! && authGender != 0{ |
| | | alert(msg: "该成员性别不符合要求");return |
| | | } |
| | | } |
| | | |
| | | if authAgeRange != nil{ |
| | | if item.age < authAgeRange!.0 || item.age > authAgeRange!.1{ |
| | | alert(msg: "该成员年龄不符合要求");return |
| | | } |
| | | } |
| | | |
| | | if self.selectStudents.contains(where: {($0 as! ActivityDetailPartModel).id == item.id}){ |
| | | if self.selectStudents.count == 1{ |
| | | alert(msg: "至少选择一位运动营成员");return |
| | | if itemType == .worldCup{ |
| | | alert(msg: "至少选择一位成员") |
| | | }else{ |
| | | alert(msg: "至少选择一位运动营成员") |
| | | } |
| | | return |
| | | } |
| | | if let index = self.selectStudents.firstIndex(where: {($0 as! ActivityDetailPartModel).id == item.id}){ |
| | | self.selectStudents.remove(at: index) |
| | |
| | | } |
| | | cell.studentModel = item |
| | | return cell |
| | | }else if itemType == .activity{ |
| | | }else if itemType == .activity || itemType == .worldCup{ |
| | | let item = actViewModel.dataSource.value[indexPath.row] |
| | | let cell = tableView.dequeueReusableCell(withIdentifier: "_StudentInfo_2_TCell") as! StudentInfo_2_TCell |
| | | cell.btn_delete.isHidden = true |