// // StatisticsStuListPageController.swift // JiaPeiManage // // Created by Ning.ge on 2024/4/3. // import UIKit import RxSwift import RxCocoa final class StatisticsStuListPageController: BaseTableViewController { let cellIdentifier:String = "_MeTraineeStuListCell" //VM let statisticsStuListViewModel = StatisticsStuListViewModel() // MARK: UI let let statusBar = UIView().then { $0.backgroundColor = UIColor.db_theme } let navBar = MeTraineeNavBar.loadFromNib().then { $0.title_label.text = "今日预报名" } var s_type = 0 var title_str = "" var dateTime_str = "" init(type:Int,title:String,schoolId:Int,dateTime:String) { super.init() s_type = type title_str = title dateTime_str = dateTime var startDate = "" var endDate = "" let date = NYDate.getThisDate() //今日 switch type { case 0://今日预报名 startDate = date endDate = date case 1://今日 startDate = date endDate = date case 2://本月 let dates = NYDate.getDateMonth()//本月 startDate = dates[0] endDate = dates[1] case 3://本年 let dates = NYDate.getDateYear() //本年 startDate = dates[0] endDate = dates[1] case 4://日 startDate = dateTime_str endDate = dateTime_str case 5://月 //月份判断 let components = dateTime_str.components(separatedBy: "-") if components.count >= 2 { let dates = NYDate.getMonthStartAndEndDates(forMonth: dateTime_str) startDate = dates[0] endDate = dates[1] } case 6://年 startDate = dateTime_str + "-01-01" endDate = dateTime_str + "-12-31" default: startDate = date endDate = date } self.statisticsStuListViewModel.startDate = startDate self.statisticsStuListViewModel.endDate = endDate self.statisticsStuListViewModel.type = s_type == 0 ? .advancet : .official self.statisticsStuListViewModel.state = "" self.statisticsStuListViewModel.schoolId = schoolId } required convenience init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func setupConstraints() { statusBar.snp.makeConstraints { (make) in make.left.right.top.equalToSuperview() make.height.equalTo(Metric.statusBarHeight) } navBar.snp.remakeConstraints { (make) in make.left.right.equalToSuperview() make.height.equalTo(Metric.navBarHeight) make.top.equalTo(statusBar.snp.bottom) } tableView.snp.remakeConstraints { make in make.top.equalTo(navBar.snp.bottom) make.left.right.bottom.equalToSuperview() } } override func viewDidLoad() { super.viewDidLoad() //绑定 setupUI() biandView() //获取list self.statisticsStuListViewModel.getCoachInfoList(vc:self) } func setupUI(){ self.view.addSubview(navBar) self.view.addSubview(statusBar) self.view.backgroundColor = .db_theme self.navBar.back_button.addTarget(self, action: #selector(actionBackdo), for: .touchUpInside) self.navBar.search_button.isHidden = true } func biandView(){ navBar.title_label.text = title_str tableView.delegate = self // tableView.dataSource = self tableView.separatorStyle = .none //去除分割线 tableView.register(UINib(nibName: "MeTraineeSubjectCell", bundle: nil), forCellReuseIdentifier: cellIdentifier) tableView.rowHeight = 288.f setupRefreshHeader(tableView) {[unowned self] in self.statisticsStuListViewModel.getCoachInfoList(vc:self) } // 设置上拉加载更多 tableView.es.addInfiniteScrolling { [unowned self] in if self.statisticsStuListViewModel != nil { self.statisticsStuListViewModel.getLoadMore(vc:self) } } self.isEmptyDisplay = false //RX 绑定 self.statisticsStuListViewModel.items .bind(to: tableView.rx.items(cellIdentifier: cellIdentifier,cellType:MeTraineeSubjectCell.self)) { (row, model, cell) in cell.index_button.setTitle("\(row+1)", for: .normal) cell.setRowInfo(rowInfo:model as! RowInfo) } .disposed(by: disposeBag) // tableView点击事件 tableView.rx.itemSelected.throttle(.seconds(1), scheduler: MainScheduler.instance) .subscribe(onNext: { [weak self]indexPath in print("点击\(indexPath)行") let rowInfo:RowInfo = self!.statisticsStuListViewModel.rows[indexPath.row] if rowInfo != nil { //rowInfo.bmType == "2" NYSwRouter.push(NYSwPushType.trainee_info,context: rowInfo) } self?.tableView.deselectRow(at: indexPath, animated: false) }).disposed(by: disposeBag) } } extension StatisticsStuListPageController:UITableViewDelegate { }