无故事王国
2024-03-15 7ab2d732db69aed82fa019a5ee6f4b5888cd399a
WanPai/Root/Other/View/StudentChooseView.swift
@@ -41,7 +41,9 @@
            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()
@@ -64,7 +66,7 @@
                        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!
@@ -72,7 +74,7 @@
                        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)
                        }
@@ -81,6 +83,8 @@
                        studentChooseView.itemType = itemType
                        studentChooseView.clickClouse = clickClouse
                        studentChooseView.needAddClouse = needAddClouse
                        studentChooseView.authGender = authGender
                        studentChooseView.authAgeRange = authAgeRange
                        sceneDelegate?.window?.addSubview(studentChooseView)
                        studentChooseView.cons_bottom.constant = 0
                        
@@ -171,9 +175,28 @@
                                    }
                        }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)
@@ -210,7 +233,7 @@
                                    }
                                    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