This commit is contained in:
DDIsFriend
2023-08-18 17:28:57 +08:00
commit f0e8a1709d
4282 changed files with 192396 additions and 0 deletions

View File

@@ -0,0 +1,313 @@
//
// AdditionalPhotoController.swift
// OrderScheduling
//
// Created by on 2023/8/14.
//
import Foundation
import DDControlsKit_Private
import DDAutoUIKit_Private
import RxSwift
import ZLPhotoBrowser
import RxCocoa
import RxRelay
extension AdditionalPhotoController{
func addActions() {
refreshRelay
.flatMapLatest {[weak self] _ in
return RQ.orderPhotoList(prameters: OrderPhotoList(userOrderId: (self?.userOrderId)!, orderCode: (self?.orderCode)!, taskOrderId: (self?.taskOrderId)!))
}
.observe(on: MainScheduler.instance)
.subscribe(onNext: {[weak self] response in
if response?.success == true {
if let data = response?.data {
self?.resultArr.removeAll()
self?.resultArr.append(contentsOf: data)
for section in 0..<(self?.resultArr.count ?? 0) {
let sectionModel = self?.resultArr[section]
for item in 0..<(sectionModel?.photoList.count ?? 0) {
let itemModel = sectionModel?.photoList[item]
itemModel?.taskStatus = sectionModel?.taskStatus
}
}
self?.additionalPhotoView.collectionView.reloadData()
}
}else{
self?.view.dd_makeToast(response?.msg)
}
})
.disposed(by: disposeBag)
refreshRelay.accept(nil)
uploadImageRelay
.flatMapLatest {[weak self] itemModel in
return RQ.supplementOrderPhoto(prameters: SupplementOrderPhoto(userOrderId: (self?.userOrderId)!, orderCode: (self?.orderCode)!, taskOrderId: (self?.taskOrderId)!, taskStatus: (itemModel.taskStatus)!, tag: itemModel.tag, file: (itemModel.uploadImage)!)) { multipartFormData in
multipartFormData.append((itemModel.uploadImage)!, withName: "file",fileName: "\(String(Date.init().timeIntervalSince1970*1000))",mimeType: "text/plain")
if let data = itemModel.tag.data(using: .utf8) {
multipartFormData.append(data, withName: "tag")
}
if let data = String((itemModel.taskStatus)!).data(using: .utf8) {
multipartFormData.append(data, withName: "taskStatus")
}
if let data = String((self?.taskOrderId)!).data(using: .utf8) {
multipartFormData.append(data, withName: "taskOrderId")
}
if let data = String((self?.orderCode)!).data(using: .utf8) {
multipartFormData.append(data, withName: "orderCode")
}
if let data = String((self?.userOrderId)!).data(using: .utf8) {
multipartFormData.append(data, withName: "userOrderId")
}
} uploadProgress: { progress in
}
}
.observe(on: MainScheduler.instance)
.subscribe(onNext: {[weak self] response in
if response?.success == true {
self?.refreshRelay.accept(nil)
}else{
self?.view.dd_makeToast(response?.msg)
}
})
.disposed(by: disposeBag)
}
}
// MARK: UICollectionViewDelegate, UICollectionViewDataSource
extension AdditionalPhotoController : UICollectionViewDelegate, UICollectionViewDataSource {
public func numberOfSections(in collectionView: UICollectionView) -> Int {
return resultArr.count
}
public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
let model = resultArr[section]
return model.photoList.count
}
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as? AdditionalPhotoCell
let sectionModel = resultArr[indexPath.section]
let itemModel = sectionModel.photoList[indexPath.item]
cell?.titleLabel.text = itemModel.imageTitle
cell?.backgroundImageView.sd_setImage(with: URL(string: ""))
if let photoUrl = itemModel.photoUrl {
cell?.uploadImageView.isHidden = false
cell?.uploadImageView.sd_setImage(with: URL(string: photoUrl))
}else{
cell?.uploadImageView.isHidden = true
cell?.uploadImageView.sd_setImage(with: nil)
}
cell?.takePhotoButton.rx.tap
.observe(on: MainScheduler.instance)
.subscribe(onNext: { _ in
ZLPhotoConfiguration.default().allowSelectVideo = false
ZLPhotoConfiguration.default().maxSelectCount = 1
ZLPhotoConfiguration.default().allowTakePhotoInLibrary = true
ZLPhotoConfiguration.default().allowEditImage = false
let photoPreviewSheet = ZLPhotoPreviewSheet.init()
photoPreviewSheet.selectImageBlock = { [weak self] results, isOriginal in
let image = results.map { $0.image }.first
// let imageCreateDate = results.map { $0.asset.creationDate }.first ?? Date()
itemModel.uploadImage = image?.dd_compressedToData(withQulitySize: 1048576)
self?.uploadImageRelay.accept(itemModel)
}
photoPreviewSheet.showPhotoLibrary(sender: self)
})
.disposed(by: cell!.disposeBag)
return cell!
}
public func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "AdditionalPhotoHeaderView", for: indexPath) as? AdditionalPhotoHeaderView
let sectionModel = resultArr[indexPath.section]
headerView?.titleLabel.text = String(indexPath.section + 1)+""+sectionModel.taskStatusString
return headerView!
}
}
open class AdditionalPhotoController : DDViewController {
private let additionalPhotoView = AdditionalPhotoView()
private let disposeBag = DisposeBag()
private let refreshRelay = ReplayRelay<Any?>.create(bufferSize: 1)
private let uploadImageRelay = ReplayRelay<OrderPhotoListDataModel.PhotoList>.create(bufferSize: 1)
private let userOrderId : Int
private let orderCode : String
private let taskOrderId : Int
private var resultArr : [OrderPhotoListDataModel] = []
public init(userOrderId: Int, orderCode: String, taskOrderId: Int){
self.userOrderId = userOrderId
self.orderCode = orderCode
self.taskOrderId = taskOrderId
super.init(nibName: nil, bundle: nil)
}
public required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
open override func viewDidLoad() {
super.viewDidLoad()
dd_navigationItemTitle = "工单照片"
dd_navigationBarBackgroundColor = .hex("354683")
dd_navigationBarTitleTextAttributes = [.foregroundColor : UIColor.white(alpha: 0.7),.font:UIFont.mediumFont(17)]
addSubviews()
addActions()
}
func addSubviews() {
view.backgroundColor = .white
view.addSubview(additionalPhotoView)
additionalPhotoView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.bottom.equalTo(-view.safeAreaInsets.bottom - auto(10))
}
additionalPhotoView.collectionView.register(AdditionalPhotoCell.self, forCellWithReuseIdentifier: "cell")
additionalPhotoView.collectionView.register(AdditionalPhotoHeaderView.self, forSupplementaryViewOfKind: DDCollectionView.elementKindSectionHeader, withReuseIdentifier: "AdditionalPhotoHeaderView")
additionalPhotoView.collectionView.delegate = self
additionalPhotoView.collectionView.dataSource = self
}
}
open class AdditionalPhotoView : DDView {
public var collectionView : DDCollectionView
public override init(frame: CGRect) {
let flowLayout = UICollectionViewFlowLayout.init()
flowLayout.itemSize = CGSize(width: auto(165), height: auto(100))
flowLayout.headerReferenceSize = CGSizeMake(0, auto(30))
flowLayout.scrollDirection = .vertical
flowLayout.minimumLineSpacing = auto(10)
flowLayout.sectionInset = UIEdgeInsets(top: auto(10), left: auto(15), bottom: auto(10), right: auto(15))
collectionView = DDCollectionView(frame: .zero, collectionViewLayout: flowLayout)
super.init(frame: frame)
collectionView.backgroundColor = .white
addSubview(collectionView)
collectionView.snp.makeConstraints { make in
make.top.left.right.bottom.equalToSuperview()
}
}
public required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
open class AdditionalPhotoCell : DDCollectionViewCell {
public let titleLabel : DDLabel
public let backgroundImageView : DDImageView
public let backgroundCoverView : DDView
public let stateView : DDView
public let stateLabel : DDLabel
public let takePhotoButton : DDButton
public let uploadImageView : DDImageView
public var disposeBag = DisposeBag()
public override init(frame: CGRect) {
titleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("8B8A8B"))
backgroundImageView = DDImageView.init()
backgroundCoverView = DDView.init()
stateView = DDView.init()
stateLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .white)
takePhotoButton = DDButton.dd_initCustom()
uploadImageView = DDImageView.init()
super.init(frame: .zero)
addSubview(titleLabel)
backgroundImageView.layer.borderColor = UIColor.hex("000000").alpha(0.1).cgColor
backgroundImageView.layer.borderWidth = 0.5
backgroundImageView.layer.cornerRadius = auto(4)
backgroundImageView.layer.masksToBounds = true
backgroundImageView.isUserInteractionEnabled = true
addSubview(backgroundImageView)
backgroundCoverView.backgroundColor = .white.alpha(0.3)
backgroundImageView.addSubview(backgroundCoverView)
stateView.backgroundColor = .hex("000000").alpha(0.5)
backgroundImageView.addSubview(stateView)
stateLabel.text = "补充"
backgroundImageView.addSubview(stateLabel)
uploadImageView.isHidden = true
uploadImageView.isUserInteractionEnabled = true
backgroundImageView.addSubview(uploadImageView)
takePhotoButton.setImage(UIImage(named: "additionalPhotot_takePhoto"), for: .normal)
backgroundImageView.addSubview(takePhotoButton)
titleLabel.snp.makeConstraints { make in
make.left.equalTo(auto(5))
make.top.equalTo(0)
}
backgroundImageView.snp.makeConstraints { make in
make.top.equalTo(titleLabel.snp.bottom).offset(auto(5))
make.left.equalToSuperview().offset(auto(5))
make.right.equalToSuperview()
make.bottom.equalToSuperview()
}
backgroundCoverView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
stateView.snp.makeConstraints { make in
make.left.bottom.right.equalToSuperview()
make.height.equalTo(auto(25))
}
stateLabel.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.centerY.equalTo(stateView)
}
takePhotoButton.snp.makeConstraints { make in
make.centerX.centerY.equalToSuperview()
}
uploadImageView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
}
public required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
open override func prepareForReuse() {
super.prepareForReuse()
disposeBag = DisposeBag()
}
}
open class AdditionalPhotoHeaderView : DDCollectionViewCell {
public let titleLabel : DDLabel
public override init(frame: CGRect) {
titleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(14)), textColor: .hex("000000").alpha(0.85))
super.init(frame: .zero)
addSubview(titleLabel)
titleLabel.snp.makeConstraints { make in
make.left.equalTo(auto(20))
make.centerY.equalToSuperview()
}
}
public required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}

View File

@@ -0,0 +1,320 @@
//
// ReviewFailedController.swift
// OrderScheduling
//
// Created by on 2023/8/14.
//
import Foundation
import DDAutoUIKit_Private
import DDControlsKit_Private
import SnapKit
import RxSwift
import RxRelay
import RxCocoa
import MJRefresh
extension ReviewFailedController {
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)
NotificationCenter.default.post(name: NSNotification.Name(rawValue: Notification_reloadRescusControolerToDoMessageCount), object: nil)
messageCenterView.tableView.mj_header = MJRefreshNormalHeader(refreshingBlock: {[weak self] in
self?.pageNum = 1
self?.refreshRelay.accept(self?.pageNum ?? 1)
})
messageCenterView.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_AUDIT_FAILED)).asObservable(), Observable.just(pageNum))
}
.observe(on: MainScheduler.instance)
.subscribe(onNext: {[weak self] (response, pageNum) in
if response?.success == true {
if pageNum == 1 {
if response?.data?.isEmpty == false {
self?.resultArr.removeAll()
self?.messageCenterView.tableView.mj_footer?.resetNoMoreData()
}
self?.messageCenterView.tableView.mj_header?.endRefreshing()
}else{
if response?.data?.isEmpty == false {
self?.messageCenterView.tableView.mj_footer?.endRefreshing()
}else{
self?.messageCenterView.tableView.mj_footer?.endRefreshingWithNoMoreData()
}
}
if let array = response?.data {
self?.resultArr.append(contentsOf: array)
self?.messageCenterView.tableView.reloadData()
}
}else{
if pageNum == 1 {
self?.messageCenterView.tableView.mj_header?.endRefreshing()
}else{
self?.messageCenterView.tableView.mj_footer?.endRefreshing()
}
self?.view.dd_makeToast(response?.msg)
}
})
.disposed(by: disposeBag)
messageCenterView.tableView.mj_header?.beginRefreshing()
}
}
// MARK: UITableViewDelegate,UITableViewDataSource
extension ReviewFailedController : UITableViewDelegate,UITableViewDataSource {
public func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return resultArr.count
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCell(withIdentifier: "cell") as? ReviewFailedCell
if cell == nil {
cell = ReviewFailedCell(style: .default, reuseIdentifier: "cell")
}
let model = resultArr[indexPath.row]
cell!.descLabel.text = model.auditFailReason
cell!.typeLabel.text = model.taskServiceName
cell!.stateLabel.text = model.taskOrderStatusString
cell!.orderNumLabel.text = model.orderCode
cell!.dateLabel.text = model.createTime
cell!.additionalButton.rx.tap
.observe(on: MainScheduler.instance)
.subscribe(onNext: {[weak self] _ in
let vc = AdditionalPhotoController(userOrderId: model.userOrderId, orderCode: model.orderCode, taskOrderId: model.taskOrderId)
self?.navigationController?.pushViewController(vc, animated: true)
})
.disposed(by: cell!.disposeBag)
return cell!
}
}
open class ReviewFailedController : DDViewController {
private let messageCenterView = ReviewFailedView()
private var pageNum : Int = 1
private var refreshRelay = ReplayRelay<Int>.create(bufferSize: 1)
private let disposeBag = DisposeBag()
private var resultArr : [OrderListDataModel] = []
private let messageTapGes = UITapGestureRecognizer()
private let messageView = MessageView()
private let pendingTapGes = UITapGestureRecognizer()
private let pendingView = MessageView()
open override func viewDidLoad() {
super.viewDidLoad()
dd_navigationItemTitle = "审核失败"
dd_navigationBarBackgroundColor = .hex("354683")
dd_navigationBarTitleTextAttributes = [.foregroundColor : UIColor.white(alpha: 0.7),.font:UIFont.mediumFont(17)]
navigationItem.leftBarButtonItems = nil
addSubviews()
addActions()
}
func addSubviews() {
view.backgroundColor = .hex("F4F5F7")
view.addSubview(messageCenterView)
messageCenterView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.bottom.equalTo(-view.safeAreaInsets.bottom)
}
messageCenterView.tableView.delegate = self
messageCenterView.tableView.dataSource = self
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)
}
}
open override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
}
open class ReviewFailedView : DDView {
public let tableView : DDTableView
public override init(frame: CGRect) {
tableView = DDTableView(frame: CGRectZero, style: .plain)
super.init(frame: frame)
tableView.backgroundColor = .hex("F4F5F7")
tableView.separatorStyle = .none
addSubview(tableView)
tableView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
}
public required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
open class ReviewFailedCell : DDTableViewCell {
public let radiusView : DDView
public let typeLabel : DDLabel
public let orderNumLabel : DDLabel
public let stateLabel : DDLabel
public let descLabel : DDLabel
public let dateLabel : DDLabel
public let additionalButton : DDButton
public var additionalLayer : 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()
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
radiusView = DDView()
typeLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(14)), textColor: .hex("000000").alpha(0.85))
orderNumLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.55))
stateLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("09B820"))
descLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(13)), textColor: .hex("FF8F37"))
dateLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000").alpha(0.55))
additionalButton = DDButton.dd_initCustom()
super.init(style: style, reuseIdentifier: reuseIdentifier)
backgroundColor = .hex("F4F5F7")
selectionStyle = .none
radiusView.backgroundColor = .white
radiusView.layer.cornerRadius = auto(6)
radiusView.layer.shadowColor = UIColor.hex("D8D8D8").cgColor
radiusView.layer.shadowOffset = CGSize(width: 0, height: 3)
radiusView.layer.shadowRadius = 5
radiusView.layer.shadowOpacity = 1
contentView.addSubview(radiusView)
radiusView.addSubview(typeLabel)
radiusView.addSubview(orderNumLabel)
radiusView.addSubview(stateLabel)
descLabel.numberOfLines = 0
radiusView.addSubview(descLabel)
radiusView.addSubview(dateLabel)
additionalButton.setTitle("补充", for: .normal)
additionalButton.setTitleColor(.white, for: .normal)
additionalButton.titleLabel?.font = .mediumFont(auto(13))
additionalButton.layer.cornerRadius = auto(4)
additionalButton.layer.masksToBounds = true
radiusView.addSubview(additionalButton)
additionalButton.layer.insertSublayer(additionalLayer, at: 0)
radiusView.snp.makeConstraints { make in
make.left.top.equalTo(auto(10))
make.right.equalTo(-auto(10))
make.bottom.equalTo(0)
}
typeLabel.snp.makeConstraints { make in
make.top.left.equalTo(auto(10))
make.height.equalTo(auto(15))
}
orderNumLabel.snp.makeConstraints { make in
make.left.equalTo(typeLabel.snp.right).offset(auto(20))
make.centerY.equalTo(typeLabel)
}
stateLabel.snp.makeConstraints { make in
make.right.equalTo(-auto(10))
make.centerY.equalTo(typeLabel)
}
descLabel.snp.makeConstraints { make in
make.top.equalTo(typeLabel.snp.bottom).offset(auto(10))
make.left.equalTo(typeLabel)
make.right.equalTo(stateLabel)
}
dateLabel.snp.makeConstraints { make in
make.left.equalTo(descLabel)
make.top.equalTo(descLabel.snp.bottom).offset(auto(10))
make.bottom.equalTo(-auto(15))
}
additionalButton.snp.makeConstraints { make in
make.right.equalTo(stateLabel)
make.centerY.equalTo(dateLabel)
make.width.equalTo(auto(50))
make.height.equalTo(auto(20))
}
}
public required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
open override func prepareForReuse() {
super.prepareForReuse()
disposeBag = DisposeBag()
}
open override func layoutSubviews() {
super.layoutSubviews()
additionalLayer.frame = CGRectMake(0, 0, auto(50), auto(20))
}
}