| | |
| | | import HandyJSON |
| | | |
| | | class ActivityStudentViewModel:RefreshModel<ActivityDetailPartModel>{ |
| | | override func api() -> (Observable<BaseResponse<[ActivityDetailPartModel]>>)? { |
| | | return Services.queryParticipantList() |
| | | } |
| | | override func api() -> (Observable<BaseResponse<[ActivityDetailPartModel]>>)? { |
| | | return Services.queryParticipantList() |
| | | } |
| | | } |
| | | |
| | | class ActivityStudentListVC: BaseVC { |
| | | |
| | | @IBOutlet weak var btn_addStudent: QMUIButton! |
| | | @IBOutlet weak var tableView: BaseTableView! |
| | | private var viewModel = ActivityStudentViewModel() |
| | | @IBOutlet weak var btn_addStudent: QMUIButton! |
| | | @IBOutlet weak var tableView: BaseTableView! |
| | | private var viewModel = ActivityStudentViewModel() |
| | | |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | title = "选择人员" |
| | | viewModel.configure(tableView,needMore: false) |
| | | viewModel.beginRefresh() |
| | | } |
| | | |
| | | override func setUI() { |
| | | btn_addStudent.imagePosition = .right |
| | | btn_addStudent.spacingBetweenImageAndTitle = 4 |
| | | |
| | | tableView.delegate = self |
| | | tableView.dataSource = self |
| | | tableView.separatorStyle = .none |
| | | tableView.register(UINib(nibName: "StudentInfo_2_TCell", bundle: nil), forCellReuseIdentifier: "_StudentInfo_2_TCell") |
| | | // tableView.jq_setEmptyView("暂无活动人员") |
| | | } |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | title = "选择人员" |
| | | viewModel.configure(tableView,needMore: false) |
| | | viewModel.beginRefresh() |
| | | } |
| | | |
| | | override func setRx() { |
| | | NotificationCenter.default.rx.notification(StudentUpdate_Nofi).take(until: self.rx.deallocated).subscribe(onNext: {[weak self] noti in |
| | | self?.viewModel.beginRefresh() |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | |
| | | @IBAction func addStudentAction(_ sender: Any) { |
| | | let vc = AddStudentVC(type: .activity) |
| | | push(vc: vc) |
| | | } |
| | | override func setUI() { |
| | | btn_addStudent.imagePosition = .right |
| | | btn_addStudent.spacingBetweenImageAndTitle = 4 |
| | | |
| | | tableView.delegate = self |
| | | tableView.dataSource = self |
| | | tableView.separatorStyle = .none |
| | | tableView.register(UINib(nibName: "StudentInfo_2_TCell", bundle: nil), forCellReuseIdentifier: "_StudentInfo_2_TCell") |
| | | // tableView.jq_setEmptyView("暂无活动人员") |
| | | } |
| | | |
| | | override func setRx() { |
| | | NotificationCenter.default.rx.notification(StudentUpdate_Nofi).take(until: self.rx.deallocated).subscribe(onNext: {[weak self] noti in |
| | | self?.viewModel.beginRefresh() |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | |
| | | @IBAction func addStudentAction(_ sender: Any) { |
| | | let vc = AddStudentVC(type: .activity) |
| | | push(vc: vc) |
| | | } |
| | | } |
| | | |
| | | extension ActivityStudentListVC:UITableViewDelegate{ |
| | | |
| | | |
| | | } |
| | | |
| | | extension ActivityStudentListVC:UITableViewDataSource{ |
| | | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { |
| | | let cell = tableView.dequeueReusableCell(withIdentifier: "_StudentInfo_2_TCell") as! StudentInfo_2_TCell |
| | | cell.indexPath = indexPath |
| | | cell.img_radio.isHidden = true |
| | | cell.activityDetailPartModel = viewModel.dataSource.value[indexPath.row] |
| | | cell.btn_verifiy.isHidden = !viewModel.dataSource.value[indexPath.row].idcard.isEmpty |
| | | cell.btn_delete.isHidden = viewModel.dataSource.value[indexPath.row].isStudent == 1 |
| | | cell.delClouse = {index in |
| | | CommonAlertView.show(title: "提示", content: "确认删除当前人员吗?") { [weak self] status in |
| | | guard let weakSelf = self else { return } |
| | | if status{ |
| | | let m = weakSelf.viewModel.dataSource.value[index.row] |
| | | Services.deleParticipant(id: m.id).subscribe(onNext: { data in |
| | | weakSelf.viewModel.beginRefresh() |
| | | }).disposed(by: weakSelf.disposeBag) |
| | | } |
| | | } |
| | | } |
| | | return cell |
| | | } |
| | | |
| | | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
| | | return viewModel.dataSource.value.count |
| | | } |
| | | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { |
| | | let cell = tableView.dequeueReusableCell(withIdentifier: "_StudentInfo_2_TCell") as! StudentInfo_2_TCell |
| | | cell.indexPath = indexPath |
| | | cell.img_radio.isHidden = true |
| | | cell.activityDetailPartModel = viewModel.dataSource.value[indexPath.row] |
| | | cell.btn_verifiy.isHidden = !viewModel.dataSource.value[indexPath.row].idcard.isEmpty |
| | | cell.btn_delete.isHidden = viewModel.dataSource.value[indexPath.row].isStudent == 1 |
| | | cell.delClouse = {index in |
| | | CommonAlertView.show(title: "提示", content: "确认删除当前人员吗?") { [weak self] status in |
| | | guard let weakSelf = self else { return } |
| | | if status{ |
| | | let m = weakSelf.viewModel.dataSource.value[index.row] |
| | | Services.deleParticipant(id: m.id).subscribe(onNext: { data in |
| | | weakSelf.viewModel.beginRefresh() |
| | | }).disposed(by: weakSelf.disposeBag) |
| | | } |
| | | } |
| | | } |
| | | return cell |
| | | } |
| | | |
| | | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
| | | return viewModel.dataSource.value.count |
| | | } |
| | | } |