// // RescueController.swift // OrderScheduling // // Created by 中道 on 2023/8/4. // import Foundation import JXCategoryView import SnapKit import DDCategoryKit_Private import DDAutoUIKit_Private import DDControlsKit_Private import RxSwift import RxRelay import MJRefresh import DDWebImageKit_Private import ESTabBarController_swift import DDUtilsSwiftKit_Private // MARK: Action extension RescueController { func addActions() { MCOUNT.messageCountRelay .subscribe(onNext: {[weak self] count in if count > 0 { self?.messageView.countLabel.isHidden = false self?.messageView.countLabel.text = String(count) self?.messageView.countLabel.snp.updateConstraints({ make in make.width.equalTo(20) }) }else{ self?.messageView.countLabel.isHidden = true self?.messageView.countLabel.snp.updateConstraints({ make in make.width.equalTo(0) }) } }) .disposed(by: disposeBag) MCOUNT.pendingCountRelay .subscribe(onNext: {[weak self] count in if count > 0 { self?.pendingView.countLabel.isHidden = false self?.pendingView.countLabel.text = String(count) self?.pendingView.countLabel.snp.updateConstraints({ make in make.width.equalTo(20) }) }else{ self?.pendingView.countLabel.isHidden = true self?.pendingView.countLabel.snp.updateConstraints({ make in make.width.equalTo(0) }) } }) .disposed(by: disposeBag) messageTapGes.rx.event .subscribe(onNext: {[weak self] _ in MESSAGETOOL.openMessageCenter(by: self?.navigationController) }) .disposed(by: disposeBag) pendingTapGes.rx.event .observe(on: MainScheduler.instance) .subscribe(onNext: { _ in WEBTOOL.open(name: .todoList,appending: nil) }) .disposed(by: disposeBag) // 点击tabBar 需要刷下下列 preRefreshRelay .observe(on: MainScheduler.instance) .subscribe(onNext: {[weak self] _ in MCOUNT.newestMessage() self?.categoryView.reloadData() }) .disposed(by: disposeBag) } } extension RescuePendingOrderController { func addActions() { pendingOrderView.tableView.mj_header = MJRefreshNormalHeader(refreshingBlock: {[weak self] in self?.pageNum = 1 self?.refreshRelay.accept(self?.pageNum ?? 1) }) pendingOrderView.tableView.mj_footer = MJRefreshBackNormalFooter(refreshingBlock: {[weak self] in self?.pageNum+=1 self?.refreshRelay.accept(self?.pageNum ?? 1) }) refreshRelay .flatMapLatest { pageNum in return Observable.zip(RQ.orderList(parameters: OrderListParameters(pageNum: pageNum, queryType: .TO_ACCEPT_DISPATCH)).asObservable(), Observable.just(pageNum)) } .observe(on: MainScheduler.instance) .subscribe(onNext: {[weak self] (response, pageNum) in if response?.success == true { if pageNum == 1 { self?.resultArr.removeAll() self?.pendingOrderView.tableView.mj_footer?.resetNoMoreData() self?.pendingOrderView.tableView.mj_header?.endRefreshing() }else{ if response?.data?.isEmpty == false { self?.pendingOrderView.tableView.mj_footer?.endRefreshing() }else{ self?.pendingOrderView.tableView.mj_footer?.endRefreshingWithNoMoreData() } } if let array = response?.data { self?.resultArr.append(contentsOf: array) } if self?.resultArr.isEmpty == false { self?.emptyView.isHidden = true }else{ self?.emptyView.isHidden = false } self?.pendingOrderView.tableView.reloadData() }else{ if pageNum == 1 { self?.pendingOrderView.tableView.mj_header?.endRefreshing() }else{ self?.pendingOrderView.tableView.mj_footer?.endRefreshing() } self?.view.dd_makeToast(response?.msg) } }) .disposed(by: disposeBag) refuseOrderConfirmView.cancelButton.rx.tap .subscribe(onNext: { _ in ENTRY.dismiss(name: refuseOrderConfirmEntry) }) .disposed(by: disposeBag) refuseOrderConfirmView.sureButton.rx.tap .subscribe(onNext: {[weak self] _ in ENTRY.dismiss(name: refuseOrderConfirmEntry) {[weak self] in if let model = self?.refuseOrderModel { self?.refuseRemarkIdRelay.accept(model) } } }) .disposed(by: disposeBag) refuseRemarkIdRelay .observe(on: MainScheduler.instance) .do(onNext: {[weak self] _ in self?.view.dd_showHUD() }) .flatMapLatest { model in return Observable.zip(RQ.refuseDispatch(parameters: RefuseDispatchParameters(userOrderId: model.userOrderId, taskOrderId: model.taskOrderId)).asObservable(), Observable.just(model)) } .observe(on: MainScheduler.instance) .do(onNext: {[weak self] _ in self?.view.dd_hideHUD() }) .observe(on: MainScheduler.instance) .subscribe(onNext: {[weak self] (response,model) in if response?.success == true { self?.entry(model: model,remarkId: response?.data) }else{ self?.view.dd_makeToast(response?.msg) } }) .disposed(by: disposeBag) acceptOrderRelay .flatMapLatest { model in return Observable.zip(RQ.acceptDispatch(parameters: AcceptDispatchParameters(userOrderId: model.userOrderId, taskOrderId: model.taskOrderId)).asObservable(), Observable.just(model)) } .observe(on: MainScheduler.instance) .subscribe(onNext: {[weak self] (response,model) in if response?.success == true { self?.resultArr.removeAll { _model in _model.userOrderId == model.userOrderId } if self?.resultArr.isEmpty == false { self?.emptyView.isHidden = true }else{ self?.emptyView.isHidden = false } self?.pendingOrderView.tableView.reloadData() }else{ self?.view.dd_makeToast(response?.msg) } }) .disposed(by: disposeBag) USER.refreshTokenSub .observe(on: MainScheduler.instance) .subscribe(onNext: {[weak self] _ in self?.pendingOrderView.tableView.mj_header?.beginRefreshing() }) .disposed(by: disposeBag) USERP.userPermissionRelay .observe(on: MainScheduler.instance) .subscribe(onNext: {[weak self] _ in self?.pendingOrderView.tableView.reloadData() }) .disposed(by: disposeBag) } func entry(model:OrderListDataModel,remarkId:String?) { let view = RefuseOrderEntryView() view.exitButton.rx.tap .observe(on: MainScheduler.instance) .subscribe(onNext: { _ in ENTRY.dismiss(name: refuseOrderEntry) }) .disposed(by: disposeBag) view.submitButton.rx.tap .flatMapLatest({[weak self] _ in return self?.getRefuseParameters(view:view,model: model,remarkId: remarkId) ?? Observable.just(RefuseDispatchParameters(userOrderId: model.userOrderId, taskOrderId: model.taskOrderId)) }) .flatMapLatest({ parameters in return RQ.refuseDispatch(parameters: parameters) }) .observe(on: MainScheduler.instance) .subscribe(onNext: {[weak self] response in if response?.success == true { self?.resultArr.removeAll { _model in _model.userOrderId == model.userOrderId } if self?.resultArr.isEmpty == false { self?.emptyView.isHidden = true }else{ self?.emptyView.isHidden = false } self?.pendingOrderView.tableView.reloadData() ENTRY.dismiss(name: refuseOrderEntry) }else{ UIApplication.shared.dd_keyWindow.dd_makeToast(response?.msg) } }) .disposed(by: disposeBag) ENTRY.showRefuseOrderEntry(view: view,name: refuseOrderEntry) } func getRefuseParameters(view:RefuseOrderEntryView,model:OrderListDataModel,remarkId:String?) -> Observable{ return Observable.create { ob in var refuseReasonItem : String? var refuseReasonDesc : String? if view.timeView.selectButton.isSelected == true { refuseReasonItem = RefuseDispatchParameters.RefuseReasonItemEnum.time.rawValue if view.timeTextFieldView.textFiled.text?.isEmpty == false { refuseReasonDesc = (view.timeTextFieldView.textFiled.text)!+(view.timeTextFieldView.unitLabel.text)! }else{ refuseReasonDesc = nil } } if view.distanceView.selectButton.isSelected == true { refuseReasonItem = RefuseDispatchParameters.RefuseReasonItemEnum.disatance.rawValue if view.distanceTextFieldView.textFiled.text?.isEmpty == false { refuseReasonDesc = (view.distanceTextFieldView.textFiled.text)!+(view.distanceTextFieldView.unitLabel.text)! }else{ refuseReasonDesc = nil } } if view.cannotDispatchView.selectButton.isSelected == true { refuseReasonItem = RefuseDispatchParameters.RefuseReasonItemEnum.cannotDispatch.rawValue refuseReasonDesc = view.cannotDispatchTextViewView.textView.text } let parameters = RefuseDispatchParameters(userOrderId: model.userOrderId, taskOrderId: model.taskOrderId,remarkId: remarkId,refuseReasonItem: refuseReasonItem,refuseReasonDesc: refuseReasonDesc) ob.onNext(parameters) ob.onCompleted() return Disposables.create() } } } extension RescuePendingDispatchController { func addActions() { pendingDispatchView.tableView.mj_header = MJRefreshNormalHeader(refreshingBlock: {[weak self] in self?.pageNum = 1 self?.refreshRelay.accept(self?.pageNum ?? 1) }) pendingDispatchView.tableView.mj_footer = MJRefreshBackNormalFooter(refreshingBlock: {[weak self] in self?.pageNum+=1 self?.refreshRelay.accept(self?.pageNum ?? 1) }) refreshRelay .flatMapLatest { pageNum in return Observable.zip(RQ.orderList(parameters: OrderListParameters(pageNum: pageNum, queryType: .TO_DISPATCH_VEHICLE)).asObservable(), Observable.just(pageNum)) } .observe(on: MainScheduler.instance) .subscribe(onNext: {[weak self] (response, pageNum) in if response?.success == true { if pageNum == 1 { self?.resultArr.removeAll() self?.pendingDispatchView.tableView.mj_footer?.resetNoMoreData() self?.pendingDispatchView.tableView.mj_header?.endRefreshing() }else{ if response?.data?.isEmpty == false { self?.pendingDispatchView.tableView.mj_footer?.endRefreshing() }else{ self?.pendingDispatchView.tableView.mj_footer?.endRefreshingWithNoMoreData() } } if let array = response?.data { self?.resultArr.append(contentsOf: array) } if self?.resultArr.isEmpty == false { self?.emptyView.isHidden = true }else{ self?.emptyView.isHidden = false } self?.pendingDispatchView.tableView.reloadData() }else{ if pageNum == 1 { self?.pendingDispatchView.tableView.mj_header?.endRefreshing() }else{ self?.pendingDispatchView.tableView.mj_footer?.endRefreshing() } self?.view.dd_makeToast(response?.msg) } }) .disposed(by: disposeBag) USER.refreshTokenSub .observe(on: MainScheduler.instance) .subscribe(onNext: {[weak self] _ in self?.pendingDispatchView.tableView.mj_header?.beginRefreshing() }) .disposed(by: disposeBag) USERP.userPermissionRelay .observe(on: MainScheduler.instance) .subscribe(onNext: {[weak self] _ in self?.pendingDispatchView.tableView.reloadData() }) .disposed(by: disposeBag) } } extension RescueIsIngController { func addActions() { pendingIsIngView.tableView.mj_header = MJRefreshNormalHeader(refreshingBlock: {[weak self] in self?.pageNum = 1 self?.refreshRelay.accept(self?.pageNum ?? 1) }) pendingIsIngView.tableView.mj_footer = MJRefreshBackNormalFooter(refreshingBlock: {[weak self] in self?.pageNum+=1 self?.refreshRelay.accept(self?.pageNum ?? 1) }) refreshRelay .flatMapLatest { pageNum in return Observable.zip(RQ.orderList(parameters: OrderListParameters(pageNum: pageNum, queryType: .TO_RESCUE)).asObservable(), Observable.just(pageNum)) } .observe(on: MainScheduler.instance) .subscribe(onNext: {[weak self] (response, pageNum) in if response?.success == true { if pageNum == 1 { self?.resultArr.removeAll() self?.pendingIsIngView.tableView.mj_footer?.resetNoMoreData() self?.pendingIsIngView.tableView.mj_header?.endRefreshing() }else{ if response?.data?.isEmpty == false { self?.pendingIsIngView.tableView.mj_footer?.endRefreshing() }else{ self?.pendingIsIngView.tableView.mj_footer?.endRefreshingWithNoMoreData() } } if let array = response?.data { self?.resultArr.append(contentsOf: array) } if self?.resultArr.isEmpty == false { self?.emptyView.isHidden = true }else{ self?.emptyView.isHidden = false } self?.pendingIsIngView.tableView.reloadData() }else{ if pageNum == 1 { self?.pendingIsIngView.tableView.mj_header?.endRefreshing() }else{ self?.pendingIsIngView.tableView.mj_footer?.endRefreshing() } self?.view.dd_makeToast(response?.msg) } }) .disposed(by: disposeBag) USER.refreshTokenSub .observe(on: MainScheduler.instance) .subscribe(onNext: {[weak self] _ in self?.pendingIsIngView.tableView.mj_header?.beginRefreshing() }) .disposed(by: disposeBag) USERP.userPermissionRelay .observe(on: MainScheduler.instance) .subscribe(onNext: {[weak self] _ in self?.pendingIsIngView.tableView.reloadData() }) .disposed(by: disposeBag) } } // MARK: JXCategoryViewDelegate,JXCategoryListContainerViewDelegate extension RescueController : JXCategoryViewDelegate,JXCategoryListContainerViewDelegate { func categoryView(_ categoryView: JXCategoryBaseView!, didSelectedItemAt index: Int) { DispatchQueue.main.async { [weak self] in if index == 0 { self?.pendingTableView?.mj_header?.beginRefreshing() }else if index == 1 { self?.dispatchTableView?.mj_header?.beginRefreshing() }else if index == 2 { self?.isRescueTableView?.mj_header?.beginRefreshing() } } } func number(ofListsInlistContainerView listContainerView: JXCategoryListContainerView!) -> Int { return categoryView.titles.count } func listContainerView(_ listContainerView: JXCategoryListContainerView!, initListFor index: Int) -> JXCategoryListContentViewDelegate! { if index == 0 { let vc = RescuePendingOrderController.init() pendingTableView = vc.pendingOrderView.tableView return vc } if index == 1 { let vc = RescuePendingDispatchController.init() dispatchTableView = vc.pendingDispatchView.tableView return vc } let vc = RescueIsIngController.init() isRescueTableView = vc.pendingIsIngView.tableView return vc } } // MARK: UITableViewDelegate,UITableViewDataSource extension RescuePendingOrderController : UITableViewDelegate,UITableViewDataSource { func numberOfSections(in tableView: UITableView) -> Int { return 1 } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return resultArr.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { var cell = tableView.dequeueReusableCell(withIdentifier: "cell") as? RescuePendingOrderCell if cell == nil { cell = RescuePendingOrderCell(style: .default, reuseIdentifier: "cell") cell?.line.backgroundColor = .hex("E9E9EA").alpha(0.6) cell?.merchantTitleLabel.text = "商户名称:" cell?.serviceTitleLabel.text = "服务地:" cell?.acceptButton.setTitle("接单", for: .normal) cell?.refuseButton.setTitle("拒单", for: .normal) } // let model = resultArr[indexPath.row] cell?.typeLabel.text = model.taskServiceName cell?.orderNumLabel.text = model.orderCode cell?.merchantLabel.text = model.contractName if model.model?.isEmpty == false { cell?.carTypeTitleLabel.text = "车型:" cell?.carTypeLabel.text = model.model cell?.carTypeTitleLabel.snp.updateConstraints({ make in make.top.equalTo(cell!.merchantLabel.snp.bottom).offset(auto(8)) }) }else{ cell?.carTypeTitleLabel.text = nil cell?.carTypeLabel.text = nil cell?.carTypeTitleLabel.snp.updateConstraints({ make in make.top.equalTo(cell!.merchantLabel.snp.bottom).offset(0) }) } cell?.serviceLabel.text = model.vehiclePointAddress if model.destinationAddress?.isEmpty == false || (model.taskFlowId != 1) { cell?.destinationTitleLabel.text = "目的地:" cell?.destinationLabel.text = model.destinationAddress?.isEmpty == false ? model.destinationAddress : " " cell?.destinationTitleLabel.snp.updateConstraints({ make in make.top.equalTo(cell!.serviceLabel.snp.bottom).offset(auto(8)) }) }else{ cell?.destinationTitleLabel.text = nil cell?.destinationLabel.text = nil cell?.destinationTitleLabel.snp.updateConstraints({ make in make.top.equalTo(cell!.serviceLabel.snp.bottom).offset(0) }) } if model.appointTime?.isEmpty == false { cell?.reserveTitleLabel.text = "预约时间:" cell?.reserveLabel.text = model.appointTime cell?.reserveTitleLabel.snp.updateConstraints({ make in make.top.equalTo(cell!.destinationLabel.snp.bottom).offset(auto(8)) }) }else{ cell?.reserveTitleLabel.text = nil cell?.reserveLabel.text = nil cell?.reserveTitleLabel.snp.updateConstraints({ make in make.top.equalTo(cell!.destinationLabel.snp.bottom).offset(0) }) } cell?.refuseButton.rx.tap .subscribe(onNext: {[weak self] _ in if let refuseOrderConfirmView = self?.refuseOrderConfirmView { self?.refuseOrderModel = model ENTRY.showRefuseOrderConfirmEntry(view: refuseOrderConfirmView,name:refuseOrderConfirmEntry) } }) .disposed(by: cell!.disposeBag) cell?.acceptButton.rx.tap .subscribe(onNext: {[weak self] _ in self?.acceptOrderRelay.accept(model) }) .disposed(by: cell!.disposeBag) if USERP.canRejectDispatchHandle == true { cell?.refuseButton.isHidden = false cell?.refuseButton.snp.updateConstraints({ make in make.right.equalTo(cell!.acceptButton.snp.left).offset(-auto(10)) make.width.equalTo(auto(80)) }) }else{ cell?.refuseButton.isHidden = true cell?.refuseButton.snp.updateConstraints({ make in make.right.equalTo(cell!.acceptButton.snp.left).offset(0) make.width.equalTo(0) }) } if USERP.canAcceptDispatchHandle == true { cell?.acceptButton.isHidden = false cell?.acceptButton.snp.updateConstraints({ make in make.width.equalTo(auto(80)) make.right.equalTo(-auto(10)) }) }else{ cell?.acceptButton.isHidden = true cell?.acceptButton.snp.updateConstraints({ make in make.width.equalTo(0) make.right.equalTo(0) }) } if USERP.canRejectDispatchHandle == false && USERP.canAcceptDispatchHandle == false { cell?.acceptButton.snp.updateConstraints({ make in make.height.equalTo(0) }) }else{ cell?.acceptButton.snp.updateConstraints({ make in make.height.equalTo(auto(30)) }) } return cell! } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let model = resultArr[indexPath.item] WEBTOOL.open(name: .workOrderDetail, appending: "&queryType=\(OrderTypeEnum.TO_ACCEPT_DISPATCH.rawValue)&userOrderId=\(model.userOrderId)&orderCode=\(model.orderCode)&taskOrderId=\(model.taskOrderId)") } } extension RescuePendingDispatchController : UITableViewDelegate,UITableViewDataSource { func numberOfSections(in tableView: UITableView) -> Int { return 1 } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return resultArr.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { var cell = tableView.dequeueReusableCell(withIdentifier: "cell") as? RescuePendingDispatchCell if cell == nil { cell = RescuePendingDispatchCell(style: .default, reuseIdentifier: "cell") cell?.line.backgroundColor = .hex("E9E9EA").alpha(0.6) cell?.merchantTitleLabel.text = "客商:" cell?.serviceTitleLabel.text = "事发地:" cell?.contactButton.setTitle("联系客户", for: .normal) cell?.dispatchButton.setTitle("指派车辆", for: .normal) } let model = resultArr[indexPath.row] cell?.typeLabel.text = model.taskServiceName cell?.orderNumLabel.text = model.orderCode cell?.merchantLabel.text = model.contractName if model.model?.isEmpty == false { cell?.carTypeTitleLabel.text = "车型:" cell?.carTypeLabel.text = model.model cell?.carTypeTitleLabel.snp.updateConstraints({ make in make.top.equalTo(cell!.merchantLabel.snp.bottom).offset(auto(8)) }) }else{ cell?.carTypeTitleLabel.text = nil cell?.carTypeLabel.text = nil cell?.carTypeTitleLabel.snp.updateConstraints({ make in make.top.equalTo(cell!.merchantLabel.snp.bottom).offset(0) }) } if model.positionEnvironment?.label.isEmpty == false { cell?.positionTitleLabel.text = "所处位置:" cell?.positionLabel.text = model.positionEnvironment?.label cell?.positionTitleLabel.snp.updateConstraints({ make in make.top.equalTo(cell!.carTypeLabel.snp.bottom).offset(auto(8)) }) }else{ cell?.positionTitleLabel.text = nil cell?.positionLabel.text = nil cell?.positionTitleLabel.snp.updateConstraints({ make in make.top.equalTo(cell!.carTypeLabel.snp.bottom).offset(auto(0)) }) } cell?.serviceLabel.text = model.vehiclePointAddress if model.vehiclePointRemark?.isEmpty == false { cell?.serviceNoticeLabel.text = "备注:"+(model.vehiclePointRemark ?? "") cell?.serviceNoticeView.snp.updateConstraints({ make in make.top.equalTo(cell!.serviceLabel.snp.bottom).offset(auto(4)) }) cell?.serviceNoticeLabel.snp.updateConstraints({ make in make.top.equalTo(auto(5)) make.bottom.equalTo(-auto(5)) }) cell?.destinationTitleLabel.snp.updateConstraints({ make in make.top.equalTo(cell!.serviceNoticeView.snp.bottom).offset(auto(4)) }) }else{ cell?.serviceNoticeLabel.text = nil cell?.serviceNoticeView.snp.updateConstraints({ make in make.top.equalTo(cell!.serviceLabel.snp.bottom).offset(0) }) cell?.serviceNoticeLabel.snp.updateConstraints({ make in make.top.equalTo(0) make.bottom.equalTo(0) }) cell?.destinationTitleLabel.snp.updateConstraints({ make in make.top.equalTo(cell!.serviceNoticeView.snp.bottom).offset(auto(8)) }) } if model.destinationAddress?.isEmpty == false || (model.taskFlowId != 1) { cell?.destinationTitleLabel.text = "目的地:" cell?.destinationLabel.text = model.destinationAddress?.isEmpty == false ? model.destinationAddress : " " }else{ cell?.destinationTitleLabel.text = nil cell?.destinationLabel.text = nil cell?.destinationTitleLabel.snp.updateConstraints({ make in make.top.equalTo(cell!.serviceNoticeView.snp.bottom).offset(0) }) } // if model.destinationRemark?.isEmpty == false { // cell?.destinationNoticeView.isHidden = false // cell?.destinationNoticeLabel.text = "备注:"+(model.destinationRemark ?? "") // cell?.destinationNoticeView.snp.updateConstraints({ make in // make.top.equalTo(cell!.destinationLabel.snp.bottom).offset(auto(4)) // }) // cell?.destinationNoticeLabel.snp.updateConstraints({ make in // make.top.equalTo(auto(5)) // make.bottom.equalTo(-auto(5)) // }) // }else{ // cell?.destinationNoticeView.isHidden = true // cell?.destinationNoticeLabel.text = nil // cell?.destinationNoticeView.snp.updateConstraints({ make in // make.top.equalTo(cell!.destinationLabel.snp.bottom).offset(auto(4)) // }) // cell?.destinationNoticeLabel.snp.updateConstraints({ make in // make.top.equalTo(0) // make.bottom.equalTo(0) // }) // } if model.appointTime?.isEmpty == false { cell?.reserveTitleLabel.text = "预约时间:" cell?.reserveLabel.text = model.appointTime cell?.reserveTitleLabel.snp.updateConstraints({ make in make.top.equalTo(cell!.destinationLabel.snp.bottom).offset(auto(8)) }) }else{ cell?.reserveTitleLabel.text = nil cell?.reserveLabel.text = nil cell?.reserveTitleLabel.snp.updateConstraints({ make in make.top.equalTo(cell!.destinationLabel.snp.bottom).offset(0) }) } cell?.photoCollectionView.tag = indexPath.row cell?.photoCollectionView.delegate = self cell?.photoCollectionView.dataSource = self cell?.photoCollectionView.register(RescuePendingDispatchPhotoCell.self, forCellWithReuseIdentifier: "cell") if model.environmentPic?.isEmpty == false { cell?.photoTitleLabel.text = "查看照片:" cell?.photoView.isHidden = false cell?.photoTitleLabel.snp.updateConstraints({ make in make.top.equalTo(cell!.reserveTitleLabel.snp.bottom).offset(auto(8)) }) cell?.photoView.snp.updateConstraints({ make in make.height.equalTo(auto(50)) }) cell?.photoCollectionView.reloadData() }else{ cell?.photoTitleLabel.text = nil cell?.photoView.isHidden = true cell?.photoTitleLabel.snp.updateConstraints({ make in make.top.equalTo(cell!.reserveTitleLabel.snp.bottom).offset(0) }) cell?.photoView.snp.updateConstraints({ make in make.height.equalTo(0) }) } cell?.contactButton.rx.tap .subscribe(onNext: { _ in SC.userOrderId = model.userOrderId SC.orderCode = model.orderCode SC.taskOrderId = model.taskOrderId URLLINKS.openUrl(type: .phone, appending: model.userPhone) }) .disposed(by: cell!.disposeBag) cell?.dispatchButton.rx.tap .observe(on: MainScheduler.instance) .subscribe(onNext: {[weak self] _ in let vc = DispatchOrderController.init(userOrderId: model.userOrderId, taskOrderId: model.taskOrderId,serviceAddressLat: model.vehiclePointLatitude,serviceAddressLon: model.vehiclePointLongitude) vc.dispatchCompletionHandler = {[weak self] _ in self?.resultArr.removeAll(where: { _model in _model.userOrderId == model.userOrderId }) self?.pendingDispatchView.tableView.reloadData() } self?.navigationController?.pushViewController(vc, animated: true) }) .disposed(by: cell!.disposeBag) if USERP.canWaitdispatchBtn == true { cell?.dispatchButton.isHidden = false cell?.dispatchButton.snp.updateConstraints({ make in make.right.equalTo(-auto(10)) make.width.equalTo(auto(80)) }) }else{ cell?.dispatchButton.isHidden = true cell?.dispatchButton.snp.updateConstraints({ make in make.right.equalTo(0) make.width.equalTo(0) }) } return cell! } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let model = resultArr[indexPath.item] WEBTOOL.open(name: .workOrderDetail, appending: "&queryType=\(OrderTypeEnum.TO_DISPATCH_VEHICLE.rawValue)&userOrderId=\(model.userOrderId)&orderCode=\(model.orderCode)&taskOrderId=\(model.taskOrderId)") } } extension RescueIsIngController : UITableViewDelegate,UITableViewDataSource { func numberOfSections(in tableView: UITableView) -> Int { return 1 } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return resultArr.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { var cell = tableView.dequeueReusableCell(withIdentifier: "cell") as? RescueIsIngCell if cell == nil { cell = RescueIsIngCell(style: .default, reuseIdentifier: "cell") cell?.line.backgroundColor = .hex("E9E9EA").alpha(0.6) cell?.orderStatusTitleLabel.text = "状态:" cell?.serviceTitleLabel.text = "故障地:" cell?.destinationTitleLabel.text = "目的地:" cell?.reportButton.setTitle("报备", for: .normal) cell?.reportDetailButton.setTitle("报备查看", for: .normal) cell?.dispatchButton.setTitle("改派", for: .normal) } let model = resultArr[indexPath.row] cell?.typeLabel.text = model.taskServiceName cell?.orderStatusLabel.text = model.taskOrderStatusString cell?.orderNumLabel.text = model.orderCode cell?.orderDateLabel.text = model.createTime if model.driverName?.isEmpty == false && model.driverPhone?.isEmpty == false { cell?.driverLabel.text = "\(model.driverName!)/\(model.driverPhone!)" }else if model.driverName?.isEmpty == false { cell?.driverLabel.text = model.driverName! }else if model.driverPhone?.isEmpty == false { cell?.driverLabel.text = model.driverPhone! }else{ cell?.driverLabel.text = nil } cell?.serviceLabel.text = model.vehiclePointAddress if model.destinationAddress?.isEmpty == false || (model.taskFlowId != 1) { cell?.destinationTitleLabel.text = "目的地:" cell?.destinationLabel.text = model.destinationAddress?.isEmpty == false ? model.destinationAddress : " " cell?.destinationTitleLabel.snp.updateConstraints({ make in make.top.equalTo(cell!.serviceLabel.snp.bottom).offset(auto(8)) }) }else{ cell?.destinationTitleLabel.text = nil cell?.destinationLabel.text = nil cell?.destinationTitleLabel.snp.updateConstraints({ make in make.top.equalTo(cell!.serviceLabel.snp.bottom).offset(0) }) } cell?.dispatchButton.rx.tap .observe(on: MainScheduler.instance) .subscribe(onNext: {[weak self] _ in let vc = DispatchOrderController.init(userOrderId: model.userOrderId, taskOrderId: model.taskOrderId,serviceAddressLat: model.vehiclePointLatitude,serviceAddressLon: model.vehiclePointLongitude) vc.dispatchCompletionHandler = {[weak self] _ in self?.resultArr.removeAll(where: { _model in _model.userOrderId == model.userOrderId }) self?.pendingIsIngView.tableView.reloadData() } self?.navigationController?.pushViewController(vc, animated: true) }) .disposed(by: cell!.disposeBag) cell?.reportButton.rx.tap .observe(on: MainScheduler.instance) .subscribe(onNext: { _ in WEBTOOL.open(name: .reporting,appending: "&queryType=\(OrderTypeEnum.TO_RESCUE.rawValue)&userOrderId=\(model.userOrderId)&orderCode=\(model.orderCode)") }) .disposed(by: cell!.disposeBag) cell?.reportDetailButton.rx.tap .observe(on: MainScheduler.instance) .subscribe(onNext: { _ in WEBTOOL.open(name: .reportingList,appending: "&queryType=\(OrderTypeEnum.TO_RESCUE.rawValue)&userOrderId=\(model.userOrderId)&orderCode=\(model.orderCode)&taskOrderId=\(model.taskOrderId)") }) .disposed(by: cell!.disposeBag) // 设置按钮权限 if USERP.canWaitModifyDispatchBtn == true { cell?.dispatchButton.isHidden = false cell?.dispatchButton.snp.updateConstraints({ make in make.right.equalTo(cell!.reportDetailButton.snp.left).offset(-auto(10)) make.width.equalTo(auto(80)) }) }else{ cell?.dispatchButton.isHidden = true cell?.dispatchButton.snp.updateConstraints({ make in make.right.equalTo(cell!.reportDetailButton.snp.left).offset(0) make.width.equalTo(0) }) } if USERP.canSupplierRemarkBtn == true { cell?.reportButton.isHidden = false cell?.reportButton.snp.updateConstraints({ make in make.width.equalTo(auto(80)) make.right.equalTo(-auto(10)) }) }else{ cell?.reportButton.isHidden = true cell?.reportButton.snp.updateConstraints({ make in make.width.equalTo(0) make.right.equalTo(0) }) } if USERP.canWaitModifyDispatchBtn == false && USERP.canSupplierRemarkBtn == false { cell?.reportButton.snp.updateConstraints({ make in make.height.equalTo(0) }) cell?.reportDetailButton.snp.updateConstraints({ make in make.height.equalTo(0) }) }else{ cell?.reportButton.snp.updateConstraints({ make in make.height.equalTo(auto(30)) }) cell?.reportDetailButton.snp.updateConstraints({ make in make.height.equalTo(auto(30)) }) } // 需要放在权限的代码后面 if (model.taskOrderStatus ?? 0) >= 12001 { cell?.dispatchButton.isHidden = true }else{ cell?.dispatchButton.isHidden = false } return cell! } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let model = resultArr[indexPath.item] WEBTOOL.open(name: .workOrderDetail, appending: "&queryType=\(OrderTypeEnum.TO_RESCUE.rawValue)&userOrderId=\(model.userOrderId)&orderCode=\(model.orderCode)&taskOrderId=\(model.taskOrderId)") } } // MARK: UICollectionViewDelegate, UICollectionViewDataSource extension RescuePendingDispatchController : UICollectionViewDelegate, UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { let model = resultArr[collectionView.tag] let environmentPics = model.environmentPic?.components(separatedBy: ",") ?? [] return environmentPics.count > 4 ? 4 : environmentPics.count } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as? RescuePendingDispatchPhotoCell let model = resultArr[collectionView.tag] let environmentPics = model.environmentPic?.components(separatedBy: ",") ?? [] let imageUrlStr = environmentPics[indexPath.item] cell!.imageView.image = nil if imageUrlStr.contains(".mp4?") == true { if let url = URL(string: imageUrlStr) { DispatchQueue.global().async { DDImage.dd_thumbnailImage(forVideo: url) { (thumbnailImage, _, _) in let image = thumbnailImage?.dd_compress(withQulitySize: 5 * 1024) DispatchQueue.main.async { cell!.imageView.image = image } } } DispatchQueue.global().async { let cmTime = TOOL.getDuration(url: url) DispatchQueue.main.async { cell!.dateLabel.text = TOOL.getVideoDateString(duration: Int(cmTime.seconds)) } } } }else{ cell!.imageView.sd_setImage(with: URL(string: imageUrlStr)) cell!.dateLabel.text = nil } return cell! } func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { let model = resultArr[collectionView.tag] let environmentPics = model.environmentPic?.components(separatedBy: ",") ?? [] let vc = RescuePhotoController(environmentPics: environmentPics) navigationController?.pushViewController(vc, animated: true) } } // MARK: 救援中 class RescueController : ZDViewController { public let categoryView = JXCategoryTitleView() private lazy var categoryContainerView = JXCategoryListContainerView(type: .scrollView, delegate: self) private let messageTapGes = UITapGestureRecognizer() private let messageView = MessageView() private let pendingTapGes = UITapGestureRecognizer() private let pendingView = MessageView() private let disposeBag = DisposeBag() private let h5Relay = ReplayRelay.create(bufferSize: 1) private var pendingTableView : DDTableView? private var dispatchTableView : DDTableView? private var isRescueTableView : DDTableView? private var preRefreshRelay = ReplayRelay.create(bufferSize: 1) override func viewDidLoad() { super.viewDidLoad() dd_navigationBarBackgroundColor = .hex("354683") dd_navigationBarTitleTextAttributes = [.foregroundColor : UIColor.white(alpha: 0.7),.font:UIFont.mediumFont(auto(15))] dd_navigationBarBarButtonItemAttributes = [.foregroundColor : UIColor.white] dd_navigationItemTitle = "救援工单" navigationItem.leftBarButtonItems = nil addSubviews() addActions() } func addSubviews() { categoryView.titles = ["待接单","待派车","救援中"] categoryView.titleColor = .hex("737373").alpha(0.55) categoryView.titleSelectedColor = .hex("3678FF") categoryView.backgroundColor = .hex("FAFAFA") categoryView.delegate = self view.addSubview(categoryView) // 指示器 let indicator = JXCategoryIndicatorLineView() indicator.indicatorColor = .hex("3678FF") indicator.indicatorWidth = JXCategoryViewAutomaticDimension indicator.verticalMargin = 7 indicator.indicatorWidth = auto(18) categoryView.indicators = [indicator] if let categoryContainerView { view.addSubview(categoryContainerView) categoryView.listContainer = categoryContainerView } messageView.titleLabel.text = "消息" messageView.addGestureRecognizer(messageTapGes) navigationItem.leftBarButtonItem = UIBarButtonItem(customView: messageView) messageView.snp.makeConstraints { make in make.height.equalTo(40) make.width.greaterThanOrEqualTo(40) } pendingView.titleLabel.text = "待办" pendingView.addGestureRecognizer(pendingTapGes) navigationItem.rightBarButtonItem = UIBarButtonItem(customView: pendingView) pendingView.snp.makeConstraints { make in make.height.equalTo(40) make.width.greaterThanOrEqualTo(40) } } override func viewSafeAreaInsetsDidChange() { super.viewSafeAreaInsetsDidChange() categoryView.snp.remakeConstraints { make in make.left.right.equalToSuperview() make.top.equalTo(view.safeAreaInsets.top) make.height.equalTo(auto(44)) } categoryContainerView?.snp.remakeConstraints({ make in make.top.equalTo(categoryView.snp.bottom) make.left.right.equalToSuperview() make.bottom.equalTo(-view.safeAreaInsets.bottom) }) } override func reloadData() { super.reloadData() preRefreshRelay.accept(nil) } } // MARK: 待派单 class RescuePendingOrderController : ZDViewController { private let disposeBag = DisposeBag() public let pendingOrderView = RescuePendingOrderView() public let refuseOrderConfirmView = RefuseOrderConfirmView() public var refuseOrderModel : OrderListDataModel? private var resultArr : [OrderListDataModel] = [] private var refreshRelay = ReplayRelay.create(bufferSize: 1) private var pageNum : Int = 1 private var refuseRemarkIdRelay = ReplayRelay.create(bufferSize: 1) private var refuseSubmitRelay = ReplayRelay.create(bufferSize: 1) private var acceptOrderRelay = ReplayRelay.create(bufferSize: 1) private var emptyView = EmptyView() override func viewDidLoad() { super.viewDidLoad() dd_navigationBarBackgroundColor = .hex("354683") dd_navigationBarTitleTextAttributes = [.foregroundColor : UIColor.white(alpha: 0.7),.font:UIFont.mediumFont(17)] dd_navigationBarBarButtonItemAttributes = [.foregroundColor : UIColor.white] addSubviews() addActions() } func addSubviews() { view.addSubview(pendingOrderView) pendingOrderView.snp.makeConstraints { make in make.edges.equalToSuperview() } pendingOrderView.tableView.addSubview(emptyView) emptyView.snp.makeConstraints { make in make.centerX.centerY.equalToSuperview() make.width.equalTo(auto(303)) make.height.equalTo(auto(94)) } pendingOrderView.tableView.backgroundColor = .hex("FAFAFA") pendingOrderView.tableView.delegate = self pendingOrderView.tableView.dataSource = self } } // MARK: 待派车 class RescuePendingDispatchController : ZDViewController { private let disposeBag = DisposeBag() public let pendingDispatchView = RescuePendingDispatchView() private var resultArr : [OrderListDataModel] = [] private var refreshRelay = ReplayRelay.create(bufferSize: 1) private var pageNum : Int = 1 private var emptyView = EmptyView() override func viewDidLoad() { super.viewDidLoad() dd_navigationBarBackgroundColor = .hex("354683") dd_navigationBarTitleTextAttributes = [.foregroundColor : UIColor.white(alpha: 0.7),.font:UIFont.mediumFont(17)] dd_navigationBarBarButtonItemAttributes = [.foregroundColor : UIColor.white] addSubviews() addActions() } func addSubviews() { view.addSubview(pendingDispatchView) pendingDispatchView.snp.makeConstraints { make in make.edges.equalToSuperview() } pendingDispatchView.tableView.addSubview(emptyView) emptyView.snp.makeConstraints { make in make.centerX.centerY.equalToSuperview() make.width.equalTo(auto(303)) make.height.equalTo(auto(94)) } pendingDispatchView.tableView.backgroundColor = .hex("FAFAFA") pendingDispatchView.tableView.delegate = self pendingDispatchView.tableView.dataSource = self } } // MARK: 救援中 class RescueIsIngController : ZDViewController { private let disposeBag = DisposeBag() public let pendingIsIngView = RescueIsIngView() private var resultArr : [OrderListDataModel] = [] private var refreshRelay = ReplayRelay.create(bufferSize: 1) private var pageNum : Int = 1 private var emptyView = EmptyView() override func viewDidLoad() { super.viewDidLoad() dd_navigationBarBackgroundColor = .hex("354683") dd_navigationBarTitleTextAttributes = [.foregroundColor : UIColor.white(alpha: 0.7),.font:UIFont.mediumFont(17)] dd_navigationBarBarButtonItemAttributes = [.foregroundColor : UIColor.white] addSubviews() addActions() } func addSubviews() { view.addSubview(pendingIsIngView) pendingIsIngView.snp.makeConstraints { make in make.edges.equalToSuperview() } pendingIsIngView.tableView.addSubview(emptyView) emptyView.snp.makeConstraints { make in make.centerX.centerY.equalToSuperview() make.width.equalTo(auto(303)) make.height.equalTo(auto(94)) } pendingIsIngView.tableView.backgroundColor = .hex("FAFAFA") pendingIsIngView.tableView.delegate = self pendingIsIngView.tableView.dataSource = self } } // MARK: Cell class RescuePendingOrderCell : DDTableViewCell { public let radiusView : DDView public let typeLabel : DDLabel public let orderNumLabel : DDLabel public let line : DDView public let merchantTitleLabel : DDLabel public let merchantLabel : DDLabel public let carTypeTitleLabel : DDLabel public let carTypeLabel : DDLabel public let serviceTitleLabel : DDLabel public let serviceLabel : DDLabel public let destinationTitleLabel : DDLabel public let destinationLabel : DDLabel public let reserveTitleLabel : DDLabel public let reserveLabel : DDLabel public let refuseButton : DDButton public let acceptButton : DDButton public var acceptLayer : CAGradientLayer = { var layer = CAGradientLayer.init() layer.startPoint = CGPoint(x: 0, y: 0) layer.endPoint = CGPoint(x: 1, y: 1) layer.locations = [0.0,1.0] layer.colors = [UIColor.hex("FF5A2C").cgColor,UIColor.hex("FE9D4D").cgColor] layer.cornerRadius = auto(4) layer.masksToBounds = true return layer }() public var disposeBag : DisposeBag override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { radiusView = DDView.init() typeLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(13)), textColor: .hex("000000").alpha(0.85)) orderNumLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(11)), textColor: .hex("000000").alpha(0.55)) line = DDView.init() merchantTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5)) merchantLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000")) carTypeTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5)) carTypeLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000")) serviceTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5)) serviceLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000")) destinationTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5)) destinationLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000")) reserveTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5)) reserveLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000")) refuseButton = DDButton.dd_initCustom() refuseButton.titleLabel?.font = .mediumFont(auto(13)) refuseButton.setTitleColor(.hex("000000").alpha(0.7), for: .normal) acceptButton = DDButton.dd_initCustom() acceptButton.titleLabel?.font = .mediumFont(auto(13)) acceptButton.setTitleColor(.hex("FFFFFF"), for: .normal) disposeBag = DisposeBag() super.init(style: style, reuseIdentifier: reuseIdentifier) contentView.backgroundColor = .hex("F4F5F7") radiusView.layer.cornerRadius = auto(6) radiusView.layer.shadowColor = UIColor.black(alpha: 0.1).cgColor radiusView.layer.shadowOpacity = 1.0 radiusView.layer.shadowRadius = 3 radiusView.layer.shadowOffset = CGSize(width: 0, height: 3) radiusView.backgroundColor = .white contentView.addSubview(radiusView) radiusView.addSubview(typeLabel) radiusView.addSubview(orderNumLabel) radiusView.addSubview(line) radiusView.addSubview(merchantTitleLabel) radiusView.addSubview(merchantLabel) carTypeLabel.numberOfLines = 0 radiusView.addSubview(carTypeLabel) radiusView.addSubview(carTypeTitleLabel) radiusView.addSubview(serviceTitleLabel) serviceLabel.numberOfLines = 0 radiusView.addSubview(serviceLabel) radiusView.addSubview(destinationTitleLabel) destinationLabel.numberOfLines = 0 radiusView.addSubview(destinationLabel) radiusView.addSubview(reserveTitleLabel) radiusView.addSubview(reserveLabel) refuseButton.layer.borderColor = UIColor.hex("DDDDDD").cgColor refuseButton.layer.borderWidth = 1 refuseButton.layer.cornerRadius = auto(4) refuseButton.setImage(UIImage(named: "rescue_orderPending_refuse"), for: .normal) radiusView.addSubview(refuseButton) acceptButton.layer.cornerRadius = auto(4) acceptButton.layer.masksToBounds = true acceptButton.backgroundColor = .hex("FF5A2C") acceptButton.layer.insertSublayer(acceptLayer, at: 0) radiusView.addSubview(acceptButton) radiusView.snp.makeConstraints { make in make.left.equalTo(auto(12)) make.right.equalTo(-auto(12)) make.top.equalTo(0) make.bottom.equalTo(-auto(12)) } typeLabel.snp.makeConstraints { make in make.left.equalTo(auto(18)) make.top.equalTo(auto(13)) } orderNumLabel.snp.makeConstraints { make in make.centerY.equalTo(typeLabel) make.left.equalTo(typeLabel.snp.right).offset(auto(10)) } line.snp.makeConstraints { make in make.top.equalTo(typeLabel.snp.bottom).offset(auto(7)) make.left.right.equalTo(0) make.height.equalTo(0.5) } merchantTitleLabel.snp.makeConstraints { make in make.top.equalTo(line.snp.bottom).offset(auto(8)) make.left.equalTo(typeLabel) make.width.equalTo(auto(60)) } merchantLabel.snp.makeConstraints { make in make.centerY.equalTo(merchantTitleLabel) make.left.equalTo(merchantTitleLabel.snp.right) make.right.equalTo(-auto(20)) } carTypeTitleLabel.snp.makeConstraints { make in make.top.equalTo(merchantLabel.snp.bottom).offset(auto(8)) make.left.equalTo(typeLabel) make.width.equalTo(merchantTitleLabel) } carTypeLabel.snp.makeConstraints { make in make.top.equalTo(carTypeTitleLabel) make.left.equalTo(carTypeTitleLabel.snp.right) make.right.equalTo(-auto(20)) } serviceTitleLabel.snp.makeConstraints { make in make.top.equalTo(carTypeLabel.snp.bottom).offset(auto(8)) make.left.equalTo(typeLabel) make.width.equalTo(merchantTitleLabel) } serviceLabel.snp.makeConstraints { make in make.top.equalTo(serviceTitleLabel) make.left.equalTo(serviceTitleLabel.snp.right) make.right.equalTo(-auto(20)) } destinationTitleLabel.snp.makeConstraints { make in make.top.equalTo(serviceLabel.snp.bottom).offset(auto(8)) make.left.equalTo(typeLabel) make.width.equalTo(merchantTitleLabel) } destinationLabel.snp.makeConstraints { make in make.top.equalTo(destinationTitleLabel) make.left.equalTo(destinationTitleLabel.snp.right) make.right.equalTo(-auto(20)) } reserveTitleLabel.snp.makeConstraints { make in make.top.equalTo(destinationLabel.snp.bottom).offset(auto(8)) make.left.equalTo(typeLabel) make.width.equalTo(merchantTitleLabel) } reserveLabel.snp.makeConstraints { make in make.centerY.equalTo(reserveTitleLabel) make.left.equalTo(reserveTitleLabel.snp.right) } acceptButton.snp.makeConstraints { make in make.right.equalToSuperview().offset(-auto(10)) make.top.equalTo(reserveTitleLabel.snp.bottom).offset(auto(10)) make.width.equalTo(auto(80)) make.height.equalTo(auto(30)) make.bottom.equalToSuperview().offset(-auto(10)) } refuseButton.snp.makeConstraints { make in make.right.equalTo(acceptButton.snp.left).offset(-auto(10)) make.top.equalTo(acceptButton) make.width.equalTo(auto(80)) make.height.equalTo(auto(30)) } } required public init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func layoutSubviews() { super.layoutSubviews() acceptLayer.frame = CGRectMake(0, 0, auto(80), auto(30)) refuseButton.dd_customize(with: .ImageLeftPaddingTitleRightWithWholeCenter, padding: 5) } override func prepareForReuse() { super.prepareForReuse() disposeBag = DisposeBag() } } class RescuePendingDispatchCell : DDTableViewCell { public let radiusView : DDView public let typeLabel : DDLabel public let orderNumLabel : DDLabel public let line : DDView public let merchantTitleLabel : DDLabel public let merchantLabel : DDLabel public let carTypeTitleLabel : DDLabel public let carTypeLabel : DDLabel public let positionTitleLabel : DDLabel public let positionLabel : DDLabel public let serviceTitleLabel : DDLabel public let serviceLabel : DDLabel public let serviceNoticeView : DDView public let serviceNoticeLabel : DDLabel public let destinationTitleLabel : DDLabel public let destinationLabel : DDLabel // public let destinationNoticeView : DDView // public let destinationNoticeLabel : DDLabel public let reserveTitleLabel : DDLabel public let reserveLabel : DDLabel public let photoTitleLabel : DDLabel public let photoView : DDView public let photoCollectionView : DDCollectionView public let contactButton : DDButton public let dispatchButton : DDButton public var dispatchLayer : CAGradientLayer = { var layer = CAGradientLayer.init() layer.startPoint = CGPoint(x: 0, y: 0) layer.endPoint = CGPoint(x: 1, y: 1) layer.locations = [0.0,1.0] layer.colors = [UIColor.hex("FF5A2C").cgColor,UIColor.hex("FE9D4D").cgColor] layer.cornerRadius = auto(4) layer.masksToBounds = true return layer }() public var disposeBag : DisposeBag override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { radiusView = DDView.init() typeLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(13)), textColor: .hex("000000").alpha(0.85)) orderNumLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(11)), textColor: .hex("000000").alpha(0.55)) line = DDView.init() merchantTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5)) merchantLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000")) carTypeTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5)) carTypeLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000")) positionTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5)) positionLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000")) serviceTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5)) serviceLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000")) serviceNoticeView = DDView.init() serviceNoticeLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(11)), textColor: .hex("FF8F37")) destinationTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5)) destinationLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000")) // destinationNoticeView = DDView.init() // destinationNoticeLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(11)), textColor: .hex("FF8F37")) reserveTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5)) reserveLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000")) photoTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5)) photoView = DDView.init() let flowLayout = UICollectionViewFlowLayout.init() flowLayout.itemSize = CGSize(width: auto(60), height: auto(45)) flowLayout.scrollDirection = .vertical flowLayout.minimumInteritemSpacing = auto(5) photoCollectionView = DDCollectionView(frame: CGRectZero, collectionViewLayout: flowLayout) contactButton = DDButton.dd_initCustom() contactButton.titleLabel?.font = .mediumFont(auto(13)) contactButton.setTitleColor(.hex("000000").alpha(0.7), for: .normal) contactButton.setImage(UIImage(named: "rescue_orderDispatch_call"), for: .normal) dispatchButton = DDButton.dd_initCustom() dispatchButton.setTitleColor(.hex("FFFFFF"), for: .normal) dispatchButton.titleLabel?.font = .mediumFont(auto(13)) disposeBag = DisposeBag() super.init(style: style, reuseIdentifier: reuseIdentifier) contentView.backgroundColor = .hex("F4F5F7") radiusView.layer.cornerRadius = auto(6) radiusView.layer.shadowColor = UIColor.black(alpha: 0.1).cgColor radiusView.layer.shadowOpacity = 1.0 radiusView.layer.shadowRadius = 3 radiusView.layer.shadowOffset = CGSize(width: 0, height: 3) radiusView.backgroundColor = .white contentView.addSubview(radiusView) radiusView.addSubview(typeLabel) radiusView.addSubview(orderNumLabel) radiusView.addSubview(line) radiusView.addSubview(merchantTitleLabel) radiusView.addSubview(merchantLabel) radiusView.addSubview(positionTitleLabel) radiusView.addSubview(positionLabel) carTypeLabel.numberOfLines = 0 radiusView.addSubview(carTypeLabel) radiusView.addSubview(carTypeTitleLabel) radiusView.addSubview(serviceTitleLabel) serviceLabel.numberOfLines = 0 radiusView.addSubview(serviceLabel) serviceNoticeView.backgroundColor = .hex("FFF7EE") radiusView.addSubview(serviceNoticeView) serviceNoticeLabel.numberOfLines = 0 serviceNoticeView.addSubview(serviceNoticeLabel) radiusView.addSubview(destinationTitleLabel) destinationLabel.numberOfLines = 0 radiusView.addSubview(destinationLabel) // destinationNoticeView.backgroundColor = .hex("FFF7EE") // radiusView.addSubview(destinationNoticeView) // destinationNoticeLabel.numberOfLines = 0 // destinationNoticeView.addSubview(destinationNoticeLabel) radiusView.addSubview(reserveTitleLabel) radiusView.addSubview(reserveLabel) radiusView.addSubview(photoTitleLabel) radiusView.addSubview(photoView) photoCollectionView.backgroundColor = .white photoView.addSubview(photoCollectionView) contactButton.layer.borderColor = UIColor.hex("DDDDDD").cgColor contactButton.layer.borderWidth = 1 contactButton.layer.cornerRadius = auto(4) radiusView.addSubview(contactButton) dispatchButton.layer.cornerRadius = auto(4) dispatchButton.layer.masksToBounds = true dispatchButton.backgroundColor = .hex("FF5A2C") dispatchButton.layer.insertSublayer(dispatchLayer, at: 0) radiusView.addSubview(dispatchButton) radiusView.snp.makeConstraints { make in make.left.equalTo(auto(12)) make.right.equalTo(-auto(12)) make.top.equalTo(0) make.bottom.equalTo(-auto(12)) } typeLabel.snp.makeConstraints { make in make.left.equalTo(auto(18)) make.top.equalTo(auto(13)) } orderNumLabel.snp.makeConstraints { make in make.centerY.equalTo(typeLabel) make.left.equalTo(typeLabel.snp.right).offset(auto(10)) } line.snp.makeConstraints { make in make.top.equalTo(typeLabel.snp.bottom).offset(auto(7)) make.left.right.equalTo(0) make.height.equalTo(0.5) } merchantTitleLabel.snp.makeConstraints { make in make.top.equalTo(line.snp.bottom).offset(auto(8)) make.left.equalTo(typeLabel) make.width.equalTo(auto(60)) } merchantLabel.snp.makeConstraints { make in make.centerY.equalTo(merchantTitleLabel) make.left.equalTo(merchantTitleLabel.snp.right) make.right.equalTo(-auto(20)) } carTypeTitleLabel.snp.makeConstraints { make in make.top.equalTo(merchantLabel.snp.bottom).offset(auto(8)) make.left.equalTo(typeLabel) make.width.equalTo(merchantTitleLabel) } carTypeLabel.snp.makeConstraints { make in make.top.equalTo(carTypeTitleLabel) make.left.equalTo(carTypeTitleLabel.snp.right) make.right.equalTo(-auto(20)) } positionTitleLabel.snp.makeConstraints { make in make.top.equalTo(carTypeLabel.snp.bottom).offset(auto(8)) make.left.equalTo(typeLabel) make.width.equalTo(merchantTitleLabel) } positionLabel.snp.makeConstraints { make in make.top.equalTo(positionTitleLabel) make.left.equalTo(positionTitleLabel.snp.right) make.right.equalTo(-auto(20)) } serviceTitleLabel.snp.makeConstraints { make in make.top.equalTo(positionLabel.snp.bottom).offset(auto(8)) make.left.equalTo(typeLabel) make.width.equalTo(merchantTitleLabel) } serviceLabel.snp.makeConstraints { make in make.top.equalTo(serviceTitleLabel) make.left.equalTo(serviceTitleLabel.snp.right) make.right.equalTo(-auto(20)) } serviceNoticeView.snp.makeConstraints { make in make.top.equalTo(serviceLabel.snp.bottom).offset(auto(4)) make.left.equalTo(auto(10)) make.right.equalTo(-auto(10)) } serviceNoticeLabel.snp.makeConstraints { make in make.top.left.equalToSuperview().offset(auto(5)) make.bottom.right.equalToSuperview().offset(-auto(5)) } destinationTitleLabel.snp.makeConstraints { make in make.top.equalTo(serviceNoticeView.snp.bottom).offset(auto(4)) make.left.equalTo(typeLabel) make.width.equalTo(merchantTitleLabel) } destinationLabel.snp.makeConstraints { make in make.top.equalTo(destinationTitleLabel) make.left.equalTo(destinationTitleLabel.snp.right) make.right.equalTo(-auto(20)) } // destinationNoticeView.snp.makeConstraints { make in // make.top.equalTo(destinationLabel.snp.bottom).offset(auto(4)) // make.left.equalTo(auto(10)) // make.right.equalTo(-auto(10)) // } // // destinationNoticeLabel.snp.makeConstraints { make in // make.top.left.equalToSuperview().offset(auto(5)) // make.bottom.right.equalToSuperview().offset(-auto(5)) // } reserveTitleLabel.snp.makeConstraints { make in make.top.equalTo(destinationLabel.snp.bottom).offset(auto(8)) make.left.equalTo(typeLabel) make.width.equalTo(merchantTitleLabel) } reserveLabel.snp.makeConstraints { make in make.centerY.equalTo(reserveTitleLabel) make.left.equalTo(reserveTitleLabel.snp.right) } photoTitleLabel.snp.makeConstraints { make in make.left.equalTo(typeLabel) make.top.equalTo(reserveTitleLabel.snp.bottom).offset(auto(8)) make.width.equalTo(merchantTitleLabel) } photoView.snp.makeConstraints { make in make.left.equalTo(photoTitleLabel.snp.right) make.top.equalTo(photoTitleLabel) make.right.equalToSuperview().offset(-auto(5)) make.height.equalTo(auto(50)) } photoCollectionView.snp.makeConstraints { make in make.edges.equalToSuperview() } dispatchButton.snp.makeConstraints { make in make.right.equalToSuperview().offset(-auto(10)) make.top.equalTo(photoView.snp.bottom).offset(auto(10)) make.width.equalTo(auto(80)) make.height.equalTo(auto(30)) make.bottom.equalToSuperview().offset(-auto(10)) } contactButton.snp.makeConstraints { make in make.right.equalTo(dispatchButton.snp.left).offset(-auto(10)) make.top.equalTo(dispatchButton) make.width.equalTo(auto(80)) make.height.equalTo(auto(30)) } } required public init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func layoutSubviews() { super.layoutSubviews() dispatchLayer.frame = CGRectMake(0, 0, auto(80), auto(30)) contactButton.dd_customize(with: .ImageLeftPaddingTitleRightWithWholeCenter, padding: 3) } override func prepareForReuse() { super.prepareForReuse() disposeBag = DisposeBag() } } class RescuePendingDispatchPhotoCell : DDCollectionViewCell { public let imageView : DDImageView public let dateLabel : DDLabel override init(frame: CGRect) { imageView = DDImageView.init() dateLabel = DDLabel.dd_init(withText: "", font: .regularFont(12), textColor: .white) super.init(frame: frame) contentView.backgroundColor = .hex("F4F5F7") imageView.contentMode = .scaleAspectFill imageView.layer.masksToBounds = true addSubview(imageView) addSubview(dateLabel) imageView.snp.makeConstraints { make in make.edges.equalToSuperview() } dateLabel.snp.makeConstraints { make in make.right.equalToSuperview().offset(-auto(2)) make.bottom.equalToSuperview().offset(-auto(2)) } } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } } class RescueIsIngCell : DDTableViewCell { public let radiusView : DDView public let typeLabel : DDLabel public let orderNumLabel : DDLabel public let orderStatusTitleLabel : DDLabel public let orderStatusLabel : DDLabel public let line : DDView public let orderDateLabel : DDLabel public let driverLabel : DDLabel public let serviceTitleLabel : DDLabel public let serviceLabel : DDLabel public let destinationTitleLabel : DDLabel public let destinationLabel : DDLabel public let dispatchButton : DDButton public let reportButton : DDButton public let reportDetailButton : DDButton public var disposeBag : DisposeBag override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { radiusView = DDView.init() typeLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(13)), textColor: .hex("000000").alpha(0.85)) orderNumLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(11)), textColor: .hex("000000").alpha(0.55)) orderStatusTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5)) orderStatusLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("E69B0B")) line = DDView.init() orderDateLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("252525")) driverLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("252525")) serviceTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5)) serviceLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000")) destinationTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5)) destinationLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000")) dispatchButton = DDButton.dd_initCustom() dispatchButton.titleLabel?.font = .mediumFont(13) dispatchButton.setTitleColor(.hex("000000").alpha(0.7), for: .normal) reportButton = DDButton.dd_initCustom() reportButton.titleLabel?.font = .mediumFont(13) reportButton.setTitleColor(.hex("FFFFFF"), for: .normal) reportDetailButton = DDButton.dd_initCustom() reportDetailButton.titleLabel?.font = .mediumFont(13) reportDetailButton.setTitleColor(.hex("000000").alpha(0.7), for: .normal) disposeBag = DisposeBag() super.init(style: style, reuseIdentifier: reuseIdentifier) contentView.backgroundColor = .hex("F4F5F7") radiusView.layer.cornerRadius = auto(6) radiusView.layer.shadowColor = UIColor.black(alpha: 0.1).cgColor radiusView.layer.shadowOpacity = 1.0 radiusView.layer.shadowRadius = 3 radiusView.layer.shadowOffset = CGSize(width: 0, height: 3) radiusView.backgroundColor = .white contentView.addSubview(radiusView) radiusView.addSubview(typeLabel) radiusView.addSubview(orderNumLabel) radiusView.addSubview(orderStatusTitleLabel) orderStatusLabel.numberOfLines = 0 radiusView.addSubview(orderStatusLabel) radiusView.addSubview(line) radiusView.addSubview(orderDateLabel) radiusView.addSubview(driverLabel) radiusView.addSubview(serviceTitleLabel) serviceLabel.numberOfLines = 0 radiusView.addSubview(serviceLabel) radiusView.addSubview(destinationTitleLabel) destinationLabel.numberOfLines = 0 radiusView.addSubview(destinationLabel) dispatchButton.layer.borderColor = UIColor.hex("DDDDDD").cgColor dispatchButton.layer.borderWidth = 1 dispatchButton.layer.cornerRadius = auto(4) radiusView.addSubview(dispatchButton) reportButton.layer.cornerRadius = auto(4) reportButton.layer.masksToBounds = true reportButton.backgroundColor = .hex("2A5094") radiusView.addSubview(reportButton) reportDetailButton.layer.borderColor = UIColor.hex("DDDDDD").cgColor reportDetailButton.layer.borderWidth = 1 reportDetailButton.layer.cornerRadius = auto(4) radiusView.addSubview(reportDetailButton) radiusView.snp.makeConstraints { make in make.left.equalTo(auto(12)) make.right.equalTo(-auto(12)) make.top.equalTo(0) make.bottom.equalTo(-auto(12)) } typeLabel.snp.makeConstraints { make in make.left.equalTo(auto(18)) make.top.equalTo(auto(13)) } orderNumLabel.snp.makeConstraints { make in make.centerY.equalTo(typeLabel) make.left.equalTo(typeLabel.snp.right).offset(auto(10)) } line.snp.makeConstraints { make in make.top.equalTo(typeLabel.snp.bottom).offset(auto(7)) make.left.right.equalTo(0) make.height.equalTo(0.5) } orderDateLabel.snp.makeConstraints { make in make.left.equalTo(typeLabel) make.top.equalTo(line.snp.bottom).offset(auto(5)) } driverLabel.snp.makeConstraints { make in make.left.equalTo(orderDateLabel.snp.right).offset(auto(10)) make.centerY.equalTo(orderDateLabel) } orderStatusTitleLabel.snp.makeConstraints { make in make.top.equalTo(orderDateLabel.snp.bottom).offset(auto(8)) make.left.equalTo(typeLabel) make.width.equalTo(auto(60)) } orderStatusLabel.snp.makeConstraints { make in make.right.equalTo(-auto(20)) make.top.equalTo(orderStatusTitleLabel) make.left.equalTo(orderStatusTitleLabel.snp.right) } serviceTitleLabel.snp.makeConstraints { make in make.top.equalTo(orderStatusLabel.snp.bottom).offset(auto(8)) make.left.equalTo(typeLabel) make.width.equalTo(orderStatusTitleLabel) } serviceLabel.snp.makeConstraints { make in make.top.equalTo(serviceTitleLabel) make.left.equalTo(serviceTitleLabel.snp.right) make.right.equalTo(-auto(20)) } destinationTitleLabel.snp.makeConstraints { make in make.top.equalTo(serviceLabel.snp.bottom).offset(auto(8)) make.left.equalTo(typeLabel) make.width.equalTo(serviceTitleLabel) } destinationLabel.snp.makeConstraints { make in make.top.equalTo(destinationTitleLabel) make.left.equalTo(destinationTitleLabel.snp.right) make.right.equalTo(-auto(20)) } reportButton.snp.makeConstraints { make in make.right.equalToSuperview().offset(-auto(10)) make.top.equalTo(destinationLabel.snp.bottom).offset(auto(10)) make.width.equalTo(auto(80)) make.height.equalTo(auto(30)) make.bottom.equalToSuperview().offset(-auto(10)) } reportDetailButton.snp.makeConstraints { make in make.right.equalTo(reportButton.snp.left).offset(-auto(10)) make.top.equalTo(reportButton) make.width.equalTo(auto(80)) make.height.equalTo(auto(30)) } dispatchButton.snp.makeConstraints { make in make.right.equalTo(reportDetailButton.snp.left).offset(-auto(10)) make.top.equalTo(reportButton) make.width.equalTo(auto(80)) make.height.equalTo(auto(30)) } } required public init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func prepareForReuse() { super.prepareForReuse() disposeBag = DisposeBag() } } // MARK: View class RescuePendingOrderView : DDView { public let tableView = DDTableView.init(frame: CGRectZero) override init(frame: CGRect) { super.init(frame: frame) tableView.separatorStyle = .none addSubview(tableView) tableView.snp.makeConstraints { make in make.edges.equalToSuperview() } } required public init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } } class RescuePendingDispatchView : DDView { public let tableView = DDTableView.init(frame: CGRectZero) override init(frame: CGRect) { super.init(frame: frame) tableView.separatorStyle = .none addSubview(tableView) tableView.snp.makeConstraints { make in make.edges.equalToSuperview() } } required public init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } } class RescueIsIngView : DDView { public let tableView = DDTableView.init(frame: CGRectZero) override init(frame: CGRect) { super.init(frame: frame) tableView.separatorStyle = .none addSubview(tableView) tableView.snp.makeConstraints { make in make.edges.equalToSuperview() } } required public init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } } // MARK: JXCategoryListContentViewDelegate extension RescuePendingOrderController : JXCategoryListContentViewDelegate { func listView() -> UIView! { return view } } extension RescuePendingDispatchController : JXCategoryListContentViewDelegate { func listView() -> UIView! { return view } } extension RescueIsIngController : JXCategoryListContentViewDelegate { func listView() -> UIView! { return view } }