Commit 18f8fd9c authored by 曹云霄's avatar 曹云霄

工单详情接口调用、界面逻辑处理、附件上传处理完成

parent 08dde6a9
This diff is collapsed.
......@@ -16,7 +16,7 @@ class BaseTableViewPullController: BaseViewController {
/// 公共Tableview
@IBOutlet weak var tableView: UITableView!
/// 分页下标
final var pullPageIndex: Int = kONE
final var pullPageIndex: Int = kZERO
override func viewDidLoad() {
super.viewDidLoad()
......@@ -71,7 +71,7 @@ class BaseTableViewPullController: BaseViewController {
@objc func loadTableViewHeader() {
setupNotDataDelegate()
tableView.mj_footer.resetNoMoreData()
pullPageIndex = kONE
pullPageIndex = kZERO
loadWebDataSource()
}
......
......@@ -17,3 +17,7 @@ public let add_Photo: String = "add_photo"
/// 子订单完成界面,维修前、维修后
public let after: String = "after"
public let befor: String = "befor"
public let sure: String = "确认"
public let cancel: String = "取消"
public let hint: String = "提示"
......@@ -31,6 +31,16 @@ public enum ATTACHMENT_LOCATION: String {
}
/// 图片上传类型
///
/// - BILL_ATTACHMENT_TYPE: 工单上传类型
/// - CHILD_BILL_ATTACHMENT_TYPE: 子工单上传类型
public enum ATTACHMENT_TYPE: String {
case BILL_ATTACHMENT_TYPE = "workbill"
case CHILD_BILL_ATTACHMENT_TYPE = "WorkExecute"
}
/// 新建工单界面分区
///
/// - BASIC: 基本信息
......@@ -95,6 +105,10 @@ public enum TODO_STATE: String {
/// - FINISHED: 已完成
/// - DELETED: 已删除
/// - CANCLED: 已作废
/// - INIT: 未开始
/// - DREW: 已领单
/// - DONE: 已作废
public enum SUBMIT_REPAIR_ORDER_STATE: String {
case CREATED = "created"
case SUBMIT = "submit"
......@@ -102,7 +116,88 @@ public enum SUBMIT_REPAIR_ORDER_STATE: String {
case FINISHED = "finished"
case DELETED = "deleted"
case CANCLED = "cancled"
case ALL = ""
case INIT = "init"
case DREW = "drew"
case DONE = "done"
}
/// 工单状态码转中文
///
/// - Parameter state: 状态码
/// - Returns: 对应中文
public func repairOrderChineseState(_ state: String) ->String {
switch state {
case SUBMIT_REPAIR_ORDER_STATE.CREATED.rawValue:
return "未发出"
case SUBMIT_REPAIR_ORDER_STATE.SUBMIT.rawValue:
return "已发出"
case SUBMIT_REPAIR_ORDER_STATE.PROCESSING.rawValue:
return "处理中"
case SUBMIT_REPAIR_ORDER_STATE.FINISHED.rawValue:
return "已完成"
case SUBMIT_REPAIR_ORDER_STATE.DELETED.rawValue:
return "已删除"
case SUBMIT_REPAIR_ORDER_STATE.CANCLED.rawValue:
return "已作废"
case SUBMIT_REPAIR_ORDER_STATE.INIT.rawValue:
return "未开始"
case SUBMIT_REPAIR_ORDER_STATE.DONE.rawValue:
return "已完成"
case SUBMIT_REPAIR_ORDER_STATE.DREW.rawValue:
return "已领单"
default:
break
}
return "未知状态"
}
/// 工单状态码转英文
///
/// - Parameter state: 状态码
/// - Returns: 对应英文
public func repairOrderEnglishState(_ state: String) ->String {
switch state {
case "未发出":
return SUBMIT_REPAIR_ORDER_STATE.CREATED.rawValue
case "已发出":
return SUBMIT_REPAIR_ORDER_STATE.SUBMIT.rawValue
case "处理中":
return SUBMIT_REPAIR_ORDER_STATE.PROCESSING.rawValue
case "已完成":
return SUBMIT_REPAIR_ORDER_STATE.FINISHED.rawValue
case "已删除":
return SUBMIT_REPAIR_ORDER_STATE.DELETED.rawValue
case "已作废":
return SUBMIT_REPAIR_ORDER_STATE.CANCLED.rawValue
case "全部状态":
return ""
default:
break
}
return "未知状态"
}
/// 工单列表过滤器
///
/// - TIME: 时间
/// - STATE: 状态
/// - SOURCE: 来源
/// - PRIORITY: 优先级
public enum REPAIR_ORDER_FILTER_BUTTON_TAG: Int {
case TIME = 0
case STATE
case SOURCE
case PRIORITY
}
/// 过滤界面选择类型
///
/// - SINGLE: 单选
/// - MULTIPLE: 多选
public enum FILTER_TYPE: Int {
case SINGLE = 0
case MULTIPLE
}
......@@ -117,4 +212,23 @@ public enum SUBMIT_REPAIR_ORDER_STATE: String {
......@@ -10,14 +10,17 @@ import Foundation
/// BaseUrl
public let BaseUrl: String = "http://192.168.1.176:9030/ifs-server/rest"
//public let BaseUrl: String = "http://dev.gomoretech.com/ifs-server/rest"
//public let BaseUrl: String = "http://192.168.1.176:9030/ifs-server/rest"
//public let BaseAttachmentUrl: String = "http://192.168.1.176:9030"
public let BaseUrl: String = "http://dev.gomoretech.com/ifs-server/rest"
public let BaseAttachmentUrl: String = "http://dev.gomoretech.com"
/// 登录
public let loginUrl: String = "/user/login/%@"
/// 待办事项
public let todoUrl: String = "/message/query"
public let todoUrl: String = "/todo/workExecute/query"
/// 新建工单来源
public let sourceUrl: String = "/config/getValue/source"
/// 新建工单服务类型
......@@ -34,15 +37,32 @@ public let deviceUrl: String = "/information/device/query"
public let saveRepairOrderUrl: String = "/work/saveOrUpdate"
/// 工单列表查询
public let repairOrderUrl: String = "/work/query"
/// 工单详情get
public let getBillDetailUrl: String = "/work/get/%@"
/// 工单详情转交部门
public let organizationUrl : String = "/organization/query"
/// 工单详情转交
public let batchTransferUrl : String = "/work/batchTransfer"
/// 工单详情完成
public let completedBillUrl: String = "/work/finish"
/// 主管指引/备件/工具
public let toolOptionUrl: String = "/config/getValue/toolOption"
/// 安全/防护/围封/环保
public let protectOptionUrl: String = "/config/getValue/protectOption"
/// 故障原因
public let brokenOptionUrl: String = "/config/getValue/brokenOption"
/// 处理方式
public let processMethodsUrl: String = "/config/getValue/processMethods"
/// 上传图片附件
public let uploadAttachmentUrl: String = "/attachment/upload_by_file?entity_type=%@&entity_uuid=%@"
/// 下载图片附件
public let downloadAttachmentUrl: String = "/attachment/get?entity_type=%@&entity_uuid=%@"
/// 显示图片附件
public let attachmentUrl: String = "\(BaseAttachmentUrl)/ifs-web/attachment/download.thor?entityType=%@&entityUuid=%@&fileName=%@"
/// 子工单领单
public let drawExecute: String = "/work/drawExecute/%@"
/// 子工单保存及提交
public let saveExecute: String = "/work/saveExecute/%@"
......
......@@ -10,6 +10,29 @@ import UIKit
extension NSString {
/*
#pragma mark - 获取当前时间之前或者之后的时间(之前传入负数)
+ (NSString *)getTimeby:(NSInteger)day
{
NSDate *nowDate = [NSDate date];
NSDate *theDate;
if(day!=0){
NSTimeInterval oneDay = 24*60*60*1; //1天的长度
theDate = [nowDate initWithTimeIntervalSinceNow: oneDay*day];
}else{
theDate = nowDate;
}
NSDateFormatter *date_formatter = [[NSDateFormatter alloc] init];
[date_formatter setDateFormat:@"yyyy-MM-dd"];
NSString *the_date_str = [date_formatter stringFromDate:theDate];
return the_date_str;
}
*/
// 计算字符串的宽度,高度
open func calculateStringSize(_ size: CGSize,font: UIFont) ->CGSize {
let attributes = [NSAttributedStringKey.font:font]
......
//
// UIButton+Extension.swift
// IFS
//
// Created by 曹云霄 on 2018/1/12.
// Copyright © 2018年 上海勾芒信息科技有限公司. All rights reserved.
//
import Foundation
......@@ -7,6 +7,7 @@
//
import Foundation
import SnapKit
import UIKit
......@@ -34,6 +35,95 @@ extension UIViewController {
extension UIViewController {
// MARK: - 添加搜索框到导航栏
open func addSearchBarToNav() ->UISearchBar {
let searchBar = UISearchBar()
searchBar.barStyle = .black
searchBar.placeholder = "请输入关键字"
navigationItem.titleView = searchBar
return searchBar
}
// MARK: - 创建UIBarbuttonItem
open func createButtonItem(_ title: String?, _ imageName: String?,_ target: Any,_ action: Selector) ->UIBarButtonItem {
let button = UIButton(type: .custom)
button.addTarget(target, action: action, for: .touchUpInside)
button.titleLabel?.font = UIFont.boldSystemFont(ofSize: 15)
if title != nil {
button.setTitle(title, for: .normal)
}else if imageName != nil {
button.setImage(UIImage(named: imageName!), for: .normal)
}else {
button.setTitle("确认", for: .normal)
}
button.sizeToFit()
return UIBarButtonItem(customView: button)
}
///EZSE: Pushes a view controller onto the receiver’s stack and updates the display.
open func pushVC(_ vc: UIViewController) {
navigationController?.pushViewController(vc, animated: true)
}
///EZSE: Pops the top view controller from the navigation stack and updates the display.
open func popVC() {
_ = navigationController?.popViewController(animated: true)
}
/// EZSE: Hide or show navigation bar
public var isNavBarHidden: Bool {
get {
return (navigationController?.isNavigationBarHidden)!
}
set {
navigationController?.isNavigationBarHidden = newValue
}
}
/// EZSE: Added extension for popToRootViewController
open func popToRootVC() {
_ = navigationController?.popToRootViewController(animated: true)
}
///EZSE: Presents a view controller modally.
open func presentVC(_ vc: UIViewController) {
present(vc, animated: true, completion: nil)
}
/// 显示加载中
open func startLoading() {
let titleView = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 40))
navigationItem.titleView = titleView
let loadingLabel = UILabel()
loadingLabel.text = "加载中..."
loadingLabel.textColor = UIColor.white
loadingLabel.textAlignment = .center
loadingLabel.font = UIFont.boldSystemFont(ofSize: 16)
titleView.addSubview(loadingLabel)
loadingLabel.snp.makeConstraints({ (make) in
make.center.equalTo(titleView.snp.center)
})
let loadingView = UIActivityIndicatorView(activityIndicatorStyle: .white)
loadingView.startAnimating()
titleView.addSubview(loadingView)
loadingView.snp.makeConstraints({ (make) in
make.centerX.equalTo(titleView.snp.centerX).offset(-50)
make.centerY.equalTo(titleView.snp.centerY)
make.size.equalTo(CGSize(width: 30, height: 30))
})
}
// MARK: - 停止加载中
open func stopLoading() {
self.navigationItem.titleView = nil
}
}
......
//
// UIViewControllerExtensions.swift
// EZSwiftExtensions
//
// Created by Goktug Yilmaz on 15/07/15.
// Copyright (c) 2015 Goktug Yilmaz. All rights reserved.
#if os(iOS) || os(tvOS)
import UIKit
import SnapKit
extension UIViewController {
// MARK: - 添加搜索框到导航栏
open func addSearchBarToNav() ->UISearchBar {
let searchBar = UISearchBar()
searchBar.barStyle = .black
searchBar.placeholder = "请输入关键字"
navigationItem.titleView = searchBar
return searchBar
}
// MARK: - 创建UIBarbuttonItem
open func createButtonItem(_ title: String?, _ imageName: String?,_ target: Any,_ action: Selector) ->UIBarButtonItem {
let button = UIButton(type: .custom)
button.addTarget(target, action: action, for: .touchUpInside)
if title != nil {
button.setTitle(title, for: .normal)
}else if imageName != nil {
button.setImage(UIImage(named: imageName!), for: .normal)
}else {
button.setTitle("确认", for: .normal)
}
button.sizeToFit()
return UIBarButtonItem(customView: button)
}
///EZSE: Pushes a view controller onto the receiver’s stack and updates the display.
open func pushVC(_ vc: UIViewController) {
navigationController?.pushViewController(vc, animated: true)
}
///EZSE: Pops the top view controller from the navigation stack and updates the display.
open func popVC() {
_ = navigationController?.popViewController(animated: true)
}
/// EZSE: Hide or show navigation bar
public var isNavBarHidden: Bool {
get {
return (navigationController?.isNavigationBarHidden)!
}
set {
navigationController?.isNavigationBarHidden = newValue
}
}
/// EZSE: Added extension for popToRootViewController
open func popToRootVC() {
_ = navigationController?.popToRootViewController(animated: true)
}
///EZSE: Presents a view controller modally.
open func presentVC(_ vc: UIViewController) {
present(vc, animated: true, completion: nil)
}
/// 显示加载中
open func startLoading() {
let titleView = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 40))
navigationItem.titleView = titleView
let loadingLabel = UILabel()
loadingLabel.text = "加载中..."
loadingLabel.textColor = UIColor.white
loadingLabel.textAlignment = .center
loadingLabel.font = UIFont.boldSystemFont(ofSize: 16)
titleView.addSubview(loadingLabel)
loadingLabel.snp.makeConstraints({ (make) in
make.center.equalTo(titleView.snp.center)
})
let loadingView = UIActivityIndicatorView(activityIndicatorStyle: .white)
loadingView.startAnimating()
titleView.addSubview(loadingView)
loadingView.snp.makeConstraints({ (make) in
make.centerX.equalTo(titleView.snp.centerX).offset(-50)
make.centerY.equalTo(titleView.snp.centerY)
make.size.equalTo(CGSize(width: 30, height: 30))
})
}
// MARK: - 停止加载中
open func stopLoading() {
self.navigationItem.titleView = nil
}
}
#endif
......@@ -13,7 +13,6 @@ struct Network {
// 请求头
static let publicParamEndpointClosure = { (target: Service) -> Endpoint<Service> in
// let url = target.baseURL.appendingPathComponent(target.path).absoluteString
let url = target.baseURL.absoluteString + target.path
let endpoint = Endpoint<Service>(url: url, sampleResponseClosure: { .networkResponse(200, target.sampleData) }, method: target.method, task: target.task, httpHeaderFields: target.headers)
if let userModel = AppManager.shareInstance.userModel {
......@@ -99,6 +98,7 @@ struct Network {
break
case let .failure(error):
failure(error)
print(error.localizedDescription)
break
}
}
......
......@@ -31,7 +31,33 @@ public enum Service {
// MARK: - 提交工单
case SubmitOrder(SaveRepairOrderModel)
// MARK: - 查询工单列表
case QueryRepairOrder(RepairOrderQuery)
case QueryRepairOrder(RepairOrderQueryModel)
// MARK: - 查询工单详情
case GetRepairOrderDetail(String)
// MARK: - 查询工单详情转交部门
case GetRepairOrderDepartment()
// MARK: - 工单详情转交
case TransferOrder(DepartmentQueryModel)
// MARK: - 工单详情完成
case CompleteOrder(BillCompletedRequestModel)
// MARK: - 主管指引/备件/工具
case QueryToolOption()
// MARK: - 安全/防护/围封/环保
case QueryProtectOption()
// MARK: - 故障原因
case QuerybrokenOption()
// MARK: - 处理方式
case QueryprocessMethods()
// MARK: - 上传图片附件
// 图片entityUuid 本地文件路径
case UploadAttachment(UploadPhotoAttachmentModel)
// MARK: - 下载图片附件
// String 附件类型 String 附件id
case DownloadAttachment(String,String)
// MARK: - 子工单工单uuid
case GetChildBill(String)
// MARK: - 保存及更新子工单
case SaveChildBill(ChildBillSaveOrUpdateModel)
}
extension Service: TargetType {
......@@ -61,7 +87,35 @@ extension Service: TargetType {
let path = saveRepairOrderUrl + "?operator.operId=\(kUser().userCode!)&operator.operName=\(kUser().userName!)&time=\(NSDate().httpParameterString()!)"
return path.urlEncoded()
case .QueryRepairOrder(_):
return repairOrderUrl
let path = repairOrderUrl + "?operator.operId=\(kUser().userCode!)&operator.operName=\(kUser().userName!)&time=\(NSDate().httpParameterString()!)"
return path.urlEncoded()
case .GetRepairOrderDetail(let billNumber):
return String(format: getBillDetailUrl, billNumber)
case .GetRepairOrderDepartment:
return organizationUrl
case .TransferOrder(_):
let path = batchTransferUrl + "?operator.operId=\(kUser().userCode!)&operator.operName=\(kUser().userName!)&time=\(NSDate().httpParameterString()!)"
return path.urlEncoded()
case .GetChildBill(let billUuid):
let path = String(format: drawExecute, billUuid) + "?operator.operId=\(kUser().userCode!)&operator.operName=\(kUser().userName!)&time=\(NSDate().httpParameterString()!)"
return path.urlEncoded()
case .SaveChildBill(_):
let path = saveExecute + "?operator.operId=\(kUser().userCode!)&operator.operName=\(kUser().userName!)&time=\(NSDate().httpParameterString()!)"
return path.urlEncoded()
case .QueryToolOption:
return toolOptionUrl
case .QueryProtectOption:
return protectOptionUrl
case .QuerybrokenOption:
return brokenOptionUrl
case .QueryprocessMethods:
return protectOptionUrl
case .CompleteOrder:
return completedBillUrl
case .UploadAttachment(let model):
return String(format: uploadAttachmentUrl, model.entityType,model.entityUuid)
case .DownloadAttachment(let entity_type, let entity_uuid):
return String(format: downloadAttachmentUrl, entity_type,entity_uuid)
}
}
......@@ -73,10 +127,22 @@ extension Service: TargetType {
.QueryDevice(_),
.SubmitOrder(_),
.QueryRepairOrder(_),
.GetRepairOrderDepartment(),
.TransferOrder(_),
.CompleteOrder(_),
.UploadAttachment(_),
.QueryInitiator(_):
return .post
case .QuerySource(),
.QueryServerType(),
.GetRepairOrderDetail(_),
.QueryToolOption(),
.QueryProtectOption(),
.QuerybrokenOption(),
.QueryprocessMethods(),
.DownloadAttachment(_, _),
.SaveChildBill(_),
.GetChildBill(_),
.QueryPrority():
return .get
}
......@@ -97,9 +163,17 @@ extension Service: TargetType {
encoding: JSONEncoding.default)
case .QuerySource(),
.QueryServerType(),
.GetRepairOrderDetail(_),
.QueryToolOption(),
.QueryProtectOption(),
.QuerybrokenOption(),
.QueryprocessMethods(),
.DownloadAttachment(_,_),
.GetChildBill(_),
.QueryPrority():
return .requestPlain
case .QueryInitiator(),
.GetRepairOrderDepartment(),
.QueryPosition():
let model = EmptyModel()
return .requestParameters(parameters: model.toJSON()!,
......@@ -113,6 +187,18 @@ extension Service: TargetType {
case .QueryRepairOrder(let queryModel):
return .requestParameters(parameters: queryModel.toDictionary(),
encoding: JSONEncoding.default)
case .TransferOrder(let queryModel):
return .requestParameters(parameters: queryModel.toDictionary(),
encoding: JSONEncoding.default)
case .CompleteOrder(let queryModel):
return .requestParameters(parameters: queryModel.toDictionary(),
encoding: JSONEncoding.default)
case .UploadAttachment(let attachmentModel):
let data = MultipartFormData(provider: .file(URL(fileURLWithPath: attachmentModel.fileUrl)), name: "file", fileName: attachmentModel.fileName, mimeType: "image/jpeg")
return .uploadMultipart([data])
case .SaveChildBill(let model):
return .requestParameters(parameters: model.toDictionary(),
encoding: JSONEncoding.default)
}
}
......
......@@ -33,7 +33,7 @@ class PhotoAttachmentViewController: BaseViewController {
/// 间隔
let SPACE: Int = 5
/// 每行个数
let COUNT: Int = 2
var COUNT: Int = 2
/// 图片高度
lazy final var imageHeight: CGFloat = {
// 30表示UICollectionView距左右边距
......@@ -54,6 +54,13 @@ class PhotoAttachmentViewController: BaseViewController {
setupCollectionView()
}
/// 设置item Size
open func setItemSize(_ size: CGSize, _ count: Int) {
self.collectionViewFlowLayout.itemSize = size
self.imageHeight = size.height
self.COUNT = count
}
// MARK: - 设置图片附件
fileprivate func setupCollectionView() {
collectionViewFlowLayout.minimumLineSpacing = CGFloat(SPACE)
......
......@@ -10,7 +10,7 @@ import UIKit
/// 确认选择后回传数据
typealias SendValueClosure = (PublicFilterModel,Int) ->Void
typealias SendValueClosure = ([PublicFilterModel],Int?) ->Void
class FilterViewController: BaseViewController {
......@@ -26,7 +26,11 @@ class FilterViewController: BaseViewController {
}()
/// 回传数据
open var affirmSelectedBlock: SendValueClosure?
var affirmSelectedBlock: SendValueClosure?
/// 选择类型
/// 单选、多选
var choiceType: FILTER_TYPE?
override func viewDidLoad() {
super.viewDidLoad()
......@@ -41,9 +45,10 @@ class FilterViewController: BaseViewController {
}
// MARK: - 设置导航栏
open func setNavigationTitle(_ title: String, _ block: @escaping SendValueClosure) {
open func setNavigationTitle(_ title: String,_ type: FILTER_TYPE, _ block: @escaping SendValueClosure) {
self.title = title
self.affirmSelectedBlock = block
self.choiceType = type
}
// MARK: - 初始化
......@@ -57,9 +62,17 @@ class FilterViewController: BaseViewController {
if let affirmSelectedBlock = affirmSelectedBlock {
let predicate = NSPredicate(format: "isSelected=%@", "\(kONE)")
let tempArray = publicViewModel.displayArray.filtered(using: predicate)
let model = tempArray.first as! PublicFilterModel
affirmSelectedBlock(model, publicViewModel.filterArray.index(of: model))
guard tempArray.count > kZERO else {
ShowMessage("请选择至少一项")
return
}
popVC()
if choiceType == FILTER_TYPE.SINGLE {
let model = tempArray.first as! PublicFilterModel
affirmSelectedBlock(tempArray as! [PublicFilterModel], publicViewModel.filterArray.index(of: model))
}else {
affirmSelectedBlock(tempArray as! [PublicFilterModel], nil)
}
}
}
}
......@@ -76,7 +89,7 @@ extension FilterViewController: UITableViewDelegate,UITableViewDataSource {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
view.endEditing(true)
publicViewModel.deselectRow(indexPath)
publicViewModel.deselectRow(indexPath,choiceType!)
tableView.reloadData()
}
}
......
......@@ -98,43 +98,5 @@ class DeviceRecord{
}
class UCN {
var code : String!
var name : String!
var uuid : String!
init(_ code: String, _ name: String ,_ uuid: String) {
self.code = code
self.name = name
self.uuid = uuid
}
/**
* Instantiate the instance using the passed json values to set the properties values
*/
init(fromJson json: JSON!){
if json.isEmpty{
return
}
code = json["code"].stringValue
name = json["name"].stringValue
uuid = json["uuid"].stringValue
}
func toDictionary() -> [String:Any]
{
var dictionary = [String:Any]()
if code != nil{
dictionary["code"] = code
}
if name != nil{
dictionary["name"] = name
}
if uuid != nil{
dictionary["uuid"] = uuid
}
return dictionary
}
}
//
// PublicModel.swift
// IFS
//
// Created by 曹云霄 on 2018/1/12.
// Copyright © 2018年 上海勾芒信息科技有限公司. All rights reserved.
//
import Foundation
import SwiftyJSON
class UCN {
var code : String!
var name : String!
var uuid : String!
init(_ code: String, _ name: String ,_ uuid: String) {
self.code = code
self.name = name
self.uuid = uuid
}
/**
* Instantiate the instance using the passed json values to set the properties values
*/
init(fromJson json: JSON!){
if json.isEmpty{
return
}
code = json["code"].stringValue
name = json["name"].stringValue
uuid = json["uuid"].stringValue
}
func toDictionary() -> [String:Any]
{
var dictionary = [String:Any]()
if code != nil{
dictionary["code"] = code
}
if name != nil{
dictionary["name"] = name
}
if uuid != nil{
dictionary["uuid"] = uuid
}
return dictionary
}
}
class Paging{
var page : Int!
var pageCount : Int!
var pageSize : Int!
var recordCount : Int!
/**
* Instantiate the instance using the passed json values to set the properties values
*/
init(fromJson json: JSON!){
if json.isEmpty{
return
}
page = json["page"].intValue
pageCount = json["pageCount"].intValue
pageSize = json["pageSize"].intValue
recordCount = json["recordCount"].intValue
}
/**
* Returns all the available property values in the form of [String:Any] object where the key is the approperiate json key and the value is the value of the corresponding property
*/
func toDictionary() -> [String:Any]
{
var dictionary = [String:Any]()
if page != nil{
dictionary["page"] = page
}
if pageCount != nil{
dictionary["pageCount"] = pageCount
}
if pageSize != nil{
dictionary["pageSize"] = pageSize
}
if recordCount != nil{
dictionary["recordCount"] = recordCount
}
return dictionary
}
}
......@@ -35,14 +35,21 @@ extension FilterViewModel {
return publicFilterCell
}
func deselectRow(_ indexPath: IndexPath){
for model in displayArray {
(model as! PublicFilterModel).isSelected = "\(kZERO)"
}
for model in filterArray {
(model as! PublicFilterModel).isSelected = "\(kZERO)"
// MARK: - 选择item
func deselectRow(_ indexPath: IndexPath, _ type: FILTER_TYPE){
if (displayArray[indexPath.row] as! PublicFilterModel).isSelected == "\(kONE)" {
(displayArray[indexPath.row] as! PublicFilterModel).isSelected = "\(kZERO)"
}else {
if type == .SINGLE {
for model in displayArray {
(model as! PublicFilterModel).isSelected = "\(kZERO)"
}
for model in filterArray {
(model as! PublicFilterModel).isSelected = "\(kZERO)"
}
}
(displayArray[indexPath.row] as! PublicFilterModel).isSelected = "\(kONE)"
}
(displayArray[indexPath.row] as! PublicFilterModel).isSelected = "\(kONE)"
}
}
......@@ -116,7 +123,7 @@ extension FilterViewModel {
})
}
// MARK: - 查询报事人
// MARK: - 查询报事人位置
func queryLocation() ->Observable<[LocationRecord]> {
return Observable.create({ (observer) -> Disposable in
Network.request(target: .QueryPosition(), success: { (json) in
......@@ -150,6 +157,74 @@ extension FilterViewModel {
return Disposables.create()
})
}
// MARK: - 主管指引/备件/工具
func queryToolOption() ->Observable<[String]> {
return Observable.create({ (observer) -> Disposable in
Network.request(target: .QueryToolOption(), success: { (json) in
let resultModel = ProjectSponsorsModel(fromJson: json)
if resultModel.success {
observer.onNext(resultModel.data)
}else {
ShowMessage(resultModel.message)
}
}, failure: { (error) in
ShowMessage(error.localizedDescription)
})
return Disposables.create()
})
}
// MARK: - 安全/防护/围封/环保
func queryProtectOption() ->Observable<[String]> {
return Observable.create({ (observer) -> Disposable in
Network.request(target: .QueryProtectOption(), success: { (json) in
let resultModel = ProjectSponsorsModel(fromJson: json)
if resultModel.success {
observer.onNext(resultModel.data)
}else {
ShowMessage(resultModel.message)
}
}, failure: { (error) in
ShowMessage(error.localizedDescription)
})
return Disposables.create()
})
}
// MARK: - 故障原因
func queryBrokenOption() ->Observable<[String]> {
return Observable.create({ (observer) -> Disposable in
Network.request(target: .QuerybrokenOption(), success: { (json) in
let resultModel = ProjectSponsorsModel(fromJson: json)
if resultModel.success {
observer.onNext(resultModel.data)
}else {
ShowMessage(resultModel.message)
}
}, failure: { (error) in
ShowMessage(error.localizedDescription)
})
return Disposables.create()
})
}
// MARK: - 处理方式
func queryProcessMethods() ->Observable<[String]> {
return Observable.create({ (observer) -> Disposable in
Network.request(target: .QueryprocessMethods(), success: { (json) in
let resultModel = ProjectSponsorsModel(fromJson: json)
if resultModel.success {
observer.onNext(resultModel.data)
}else {
ShowMessage(resultModel.message)
}
}, failure: { (error) in
ShowMessage(error.localizedDescription)
})
return Disposables.create()
})
}
}
......
......@@ -12,6 +12,8 @@ import SKPhotoBrowser
import RxSwift
import RxCocoa
class RepairOrderAddTableViewController: BaseTableViewController {
/// RxSwift自动释放
......@@ -77,14 +79,62 @@ class RepairOrderAddTableViewController: BaseTableViewController {
navigationItem.rightBarButtonItem = createButtonItem("提交", nil, self, #selector(RepairOrderAddTableViewController.submitButtonClickAction))
}
// MARK: - 保存图片附件至沙盒
fileprivate func saveImage(currentImage: UIImage, persent: CGFloat, imageName: String) ->String {
if let imageData = UIImageJPEGRepresentation(currentImage, persent) as NSData? {
let fullPath = NSHomeDirectory().appending("/Documents/Files").appending(imageName)
imageData.write(toFile: fullPath, atomically: true)
return fullPath
}
return ""
}
// MARK: - 提交工单
@objc fileprivate func submitButtonClickAction() {
if repairOrderAddViewModel.repairOrderAvailable(facilitiesSwitch) {
repairOrderAddViewModel.submitRepairOrder().subscribe(onNext: {[weak self] (result) in
ShowMessage("提交成功")
self?.popVC()
}).disposed(by: disposeBag)
var fileUrlArray = Array<String>()
for i in 0..<attachmentVc.attachmentViewModel.photoAttachments.count - 1 {
let image = attachmentVc.attachmentViewModel.photoAttachments[i]
let imageName = randomMD5()
let fileUrl = saveImage(currentImage: image.attachment as! UIImage, persent: 0.8, imageName: imageName + ".jpg")
fileUrlArray.append(fileUrl)
}
let entityUuid = randomMD5()
for i in 0..<fileUrlArray.count {
let fileUrl = fileUrlArray[i]
let model = UploadPhotoAttachmentModel(randomMD5(), fileUrl, ATTACHMENT_TYPE.BILL_ATTACHMENT_TYPE.rawValue,entityUuid)
Network.request(target: .UploadAttachment(model), success: {[weak self] (json) in
let model = AttachmentReponseModel(fromJson: json)
if model.success {
if i == fileUrlArray.count - kONE {
if self!.repairOrderAddViewModel.repairOrderAvailable(self!.facilitiesSwitch) {
self?.repairOrderAddViewModel.saveOrderModel.attachmentId = entityUuid
self?.repairOrderAddViewModel.submitRepairOrder().subscribe(onNext: {[weak self] (result) in
ShowMessage("提交成功")
self?.popVC()
}).disposed(by: self!.disposeBag)
}
}
}
}, failure: { (error) in
ShowMessage(error.localizedDescription)
HideLoadingView(kWindow)
return
})
}
}
// MARK: - 生成随机字符串
fileprivate func randomMD5() -> String {
let identifier = CFUUIDCreate(nil)
let identifierString = CFUUIDCreateString(nil, identifier) as String
let cStr = identifierString.cString(using: .utf8)
var digest = [UInt8](repeating: 0, count: Int(CC_MD5_DIGEST_LENGTH))
CC_MD5(cStr, CC_LONG(strlen(cStr)), &digest)
var output = String()
for i in digest {
output = output.appendingFormat("%02X", i)
}
return output;
}
// MARK: - 设置附件VC
......
//
// RepairOrderCompletedViewController.swift
// IFS
//
// Created by 曹云霄 on 2018/1/15.
// Copyright © 2018年 上海勾芒信息科技有限公司. All rights reserved.
//
import UIKit
import RxSwift
import SwiftyJSON
class RepairOrderCompletedViewController: BaseTableViewController {
/// RxSwift自动释放
let disposeBag = DisposeBag()
/// 已解决
@IBOutlet weak var resolvedButton: UIButton!
/// 未解决
@IBOutlet weak var unsolvedButton: UIButton!
/// 详细完成情况
@IBOutlet weak var remarkTextView: IQTextView!
/// 工单完成ViewModel
lazy final var billCompleteViewModel: RepairOrderDetailViewModel = {
var billCompleteViewModel = RepairOrderDetailViewModel()
return billCompleteViewModel
}()
override func viewDidLoad() {
super.viewDidLoad()
uiConfigAction()
}
// MARK: - UI
fileprivate func uiConfigAction() {
remarkTextView.placeholder = "详细完成情况"
navigationItem.rightBarButtonItem = createButtonItem("完成", nil, self, #selector(RepairOrderCompletedViewController.saveButtonClickAction))
resolvedButton.horizontalCenterImageAndTitle(5)
unsolvedButton.horizontalCenterImageAndTitle(5)
}
// MARK: - 完成工单
@objc fileprivate func saveButtonClickAction() {
billCompleteViewModel.billCompltedModel.finishNote = remarkTextView.text
billCompleteViewModel.billCompltedModel.finish = resolvedButton.isSelected
billCompleteViewModel.billCompltedModel.finishTime = NSDate().httpParameterString()
let finishModel = UCN(kUser().userCode, kUser().userName, kUser().userUuid)
billCompleteViewModel.billCompltedModel.finishUser = finishModel
billCompleteViewModel.complteRepairOrderAction(billCompleteViewModel.billCompltedModel).subscribe(onNext: {[weak self] () in
ShowMessage("完成成功")
self?.popVC()
}).disposed(by: disposeBag)
}
// MARK: - 已解决
@IBAction func resolvedButtonClickAction(_ sender: UIButton) {
sender.isSelected = true
unsolvedButton.isSelected = false
}
// MARK: - 未解决
@IBAction func unsolvedButtonClickAction(_ sender: UIButton) {
sender.isSelected = true
resolvedButton.isSelected = false
}
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if section == 0 {
return kSectionZero
}
return kSectionTen
}
override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return kSectionZero
}
}
//
// RepairOrderDetailBgController.swift
// IFS
//
// Created by 曹云霄 on 2018/1/12.
// Copyright © 2018年 上海勾芒信息科技有限公司. All rights reserved.
//
import UIKit
import SnapKit
import SwiftyJSON
class RepairOrderDetailBgController: BaseViewController {
/// 工单数据
open var billModel: RepairOrderRecord!
/// 转交、完成背景
@IBOutlet weak var bottomBgView: UIView!
@IBOutlet weak var bottomLayoutHeight: NSLayoutConstraint!
/// 详情内容背景
@IBOutlet weak var contentBgView: UIView!
/// 转交
@IBOutlet weak var transferButton: UIButton!
/// 完成
@IBOutlet weak var completeButton: UIButton!
/// 工单详情控制器
lazy final var detailVc: RepairOrderDetailViewController = {
var detailVc = RepairOrderDetailViewController.instantiateViewController(.Function) as! RepairOrderDetailViewController
return detailVc
}()
override func viewDidLoad() {
super.viewDidLoad()
addChildBillDetailVc()
}
// MARK: - 添加工单详情控制器
fileprivate func addChildBillDetailVc() {
detailVc.billModel = billModel
contentBgView.addSubview(detailVc.view)
detailVc.view.snp.makeConstraints { (make) in
make.edges.equalTo(self.contentBgView)
}
addChildViewController(detailVc)
detailVc.setStateBlock {[weak self] (state) in
/*
/// - FINISHED: 已完成
/// - DELETED: 已删除
/// - CANCLED
*/
if state == SUBMIT_REPAIR_ORDER_STATE.FINISHED.rawValue || state == SUBMIT_REPAIR_ORDER_STATE.DELETED.rawValue || state == SUBMIT_REPAIR_ORDER_STATE.CANCLED.rawValue {
self?.bottomLayoutHeight.constant = 0
UIView.animate(withDuration: 0.5, animations: {
self?.view.layoutIfNeeded()
})
}else {
self?.bottomLayoutHeight.constant = 50
UIView.animate(withDuration: 0.5, animations: {
self?.view.layoutIfNeeded()
})
}
}
}
// MARK: - 转交工单
@IBAction func transferButtonClickAction(_ sender: UIButton) {
detailVc.transferRepairOrder()
}
// MARK: - 传递工单数据到工单完成界面
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == RepairOrderCompletedViewController.name() {
let completeVc = segue.destination as! RepairOrderCompletedViewController
let model = BillCompletedRequestModel.init(fromJson: JSON(detailVc.orderDetailViewModel.billDetailModel.toDictionary()))
completeVc.billCompleteViewModel.billCompltedModel = model
}
}
}
......@@ -21,6 +21,29 @@ class RepairOrderEditSonOrderViewController: BaseTableViewController {
var beforAttachmentHeight: CGFloat! = 0
/// 维修后图片附件高度
var afterAttachmentHeight: CGFloat! = 0
/// 工单数据
open var billModel: BillDetailExecute!
/// 主管指引、备件、工具
@IBOutlet weak var toolOptionLabel: UILabel!
/// 安全、防护、围封、环保
@IBOutlet weak var protectOptionLabel: UILabel!
/// 出工人
@IBOutlet weak var workPersonLabel: UILabel!
/// 到位时间
@IBOutlet weak var placeTimeLabel: UILabel!
/// 离开时间
@IBOutlet weak var leaveTimeLabel: UILabel!
/// 故障原因
@IBOutlet weak var failureCauseLabel: UILabel!
/// 处理方式
@IBOutlet weak var processModeLabel: UILabel!
/// 人工费
@IBOutlet weak var costLaborText: UITextField!
/// 物料费用
@IBOutlet weak var materialCostLabel: UILabel!
/// 描述
@IBOutlet weak var describeTextView: IQTextView!
/// 维修前图片附件
lazy final var beforAttachmentVc: PhotoAttachmentViewController = {
......@@ -36,11 +59,32 @@ class RepairOrderEditSonOrderViewController: BaseTableViewController {
return attachmentVc
}()
/// 子工单详情ViewModel
lazy final var childBillViewModel: ReparirChildBillViewModel = {
var childBillViewModel = ReparirChildBillViewModel()
return childBillViewModel
}()
/// 主工单详情ViewModel
lazy final var orderDetailViewModel: RepairOrderDetailViewModel = {
var orderDetailViewModel = RepairOrderDetailViewModel()
return orderDetailViewModel
}()
override func viewDidLoad() {
super.viewDidLoad()
setupTableView()
setupPhotoAttachmentVc()
getBillDetailAction()
}
// MARK: - 获取子工单详情
fileprivate func getBillDetailAction() {
orderDetailViewModel.billDetailModel = BillDetailData(billModel.state)
orderDetailViewModel.queryRepairOrderDetailAction(billModel.uuid).subscribe {[weak self] (event) in
self?.tableView.reloadData()
}.disposed(by: disposeBag)
}
// MARK: - 设置附件VC
......@@ -62,6 +106,15 @@ class RepairOrderEditSonOrderViewController: BaseTableViewController {
self?.gotoChildBillDetailVc()
}).disposed(by: disposeBag)
tableView.tableFooterView = completeView
navigationItem.rightBarButtonItem = createButtonItem("保存", nil, self, #selector(RepairOrderEditSonOrderViewController.saveButtonClickAction))
}
// MARK: - 提交、保存工单
@objc fileprivate func saveButtonClickAction() {
childBillViewModel.saveChildBillAction().subscribe(onNext: {[weak self] () in
ShowMessage("保存成功")
self?.popVC()
}).disposed(by: disposeBag)
}
// MARK: - 跳转子工单详情
......@@ -106,6 +159,10 @@ class RepairOrderEditSonOrderViewController: BaseTableViewController {
}
return super.tableView(tableView, heightForRowAt: indexPath)
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
childBillViewModel.didSelectRowAtIndexPath(indexPath, self)
}
}
extension RepairOrderEditSonOrderViewController: PhotoAttachmentDelegate {
......@@ -123,8 +180,3 @@ extension RepairOrderEditSonOrderViewController: PhotoAttachmentDelegate {
tableView.reloadData()
}
}
......@@ -25,6 +25,12 @@ class RepairOrderViewController: BaseTableViewPullController {
/// 优先级选择
@IBOutlet weak var priorityChooseButton: UIButton!
/// 工单列表ViewModel
lazy final var repairOrderViewModel: RepairOrderViewModel = {
var repairOrderViewModel = RepairOrderViewModel()
return repairOrderViewModel
}()
override func viewDidLoad() {
super.viewDidLoad()
......@@ -39,10 +45,10 @@ class RepairOrderViewController: BaseTableViewPullController {
stateChooseButton.addBorder(1.0, kGaryColor)
sourceChooseButton.addBorder(1.0, kGaryColor)
priorityChooseButton.addBorder(1.0, kGaryColor)
dateChooseButton.horizontalCenterTitleAndImage(5)
stateChooseButton.horizontalCenterTitleAndImage(5)
sourceChooseButton.horizontalCenterTitleAndImage(5)
priorityChooseButton.horizontalCenterTitleAndImage(5)
dateChooseButton.horizontalCenterTitleAndImageRight(5)
stateChooseButton.horizontalCenterTitleAndImageRight(5)
sourceChooseButton.horizontalCenterTitleAndImageRight(5)
priorityChooseButton.horizontalCenterTitleAndImageRight(5)
}
// MARK: - 绑定RxSwift事件
......@@ -50,64 +56,64 @@ class RepairOrderViewController: BaseTableViewPullController {
dateChooseButton.rx.controlEvent(UIControlEvents.touchUpInside).subscribe(onNext: {[weak self] (event) in
self?.dateChooseButton.isSelected = true
self?.dateChooseButton.addBorder(1.0, kBlueColor)
YXPickerManager.share().showGeneralPickerView(kNavColor, dataArray: ["最近一周","最近两周","最近一个月"], defaultString: self?.dateChooseButton.currentTitle, commit: { (text, index) in
self?.dateChooseButton.isSelected = false
self?.dateChooseButton.addBorder(1.0, kGaryColor)
}, cancel: {
self?.dateChooseButton.isSelected = false
self?.dateChooseButton.addBorder(1.0, kGaryColor)
})
self?.repairOrderViewModel.repairOrderFilterBtnAction((self?.dateChooseButton)!).subscribe(onNext: { () in
self?.tableView.mj_header.beginRefreshing()
}).disposed(by: (self?.disposeBag)!)
}).disposed(by: disposeBag)
stateChooseButton.rx.controlEvent(UIControlEvents.touchUpInside).subscribe(onNext: {[weak self] (event) in
self?.stateChooseButton.isSelected = true
self?.stateChooseButton.addBorder(1.0, kBlueColor)
YXPickerManager.share().showGeneralPickerView(kNavColor, dataArray: ["全部状态","已完成","已提交","已取消"], defaultString: self?.stateChooseButton.currentTitle, commit: { (text, index) in
self?.stateChooseButton.isSelected = false
self?.stateChooseButton.addBorder(1.0, kGaryColor)
}, cancel: {
self?.stateChooseButton.isSelected = false
self?.stateChooseButton.addBorder(1.0, kGaryColor)
})
self?.repairOrderViewModel.repairOrderFilterBtnAction((self?.stateChooseButton)!).subscribe(onNext: { () in
self?.tableView.mj_header.beginRefreshing()
}).disposed(by: (self?.disposeBag)!)
}).disposed(by: disposeBag)
sourceChooseButton.rx.controlEvent(UIControlEvents.touchUpInside).subscribe(onNext: {[weak self] (event) in
self?.sourceChooseButton.isSelected = true
self?.sourceChooseButton.addBorder(1.0, kBlueColor)
YXPickerManager.share().showGeneralPickerView(kNavColor, dataArray: ["全部来源","内部","外部"], defaultString: self?.sourceChooseButton.currentTitle, commit: { (text, index) in
self?.sourceChooseButton.isSelected = false
self?.sourceChooseButton.addBorder(1.0, kGaryColor)
}, cancel: {
self?.sourceChooseButton.isSelected = false
self?.sourceChooseButton.addBorder(1.0, kGaryColor)
})
self?.repairOrderViewModel.repairOrderFilterBtnAction((self?.sourceChooseButton)!).subscribe(onNext: { () in
self?.tableView.mj_header.beginRefreshing()
}).disposed(by: (self?.disposeBag)!)
}).disposed(by: disposeBag)
priorityChooseButton.rx.controlEvent(UIControlEvents.touchUpInside).subscribe(onNext: {[weak self] (event) in
self?.priorityChooseButton.isSelected = true
self?.priorityChooseButton.addBorder(1.0, kBlueColor)
YXPickerManager.share().showGeneralPickerView(kNavColor, dataArray: ["全部优先级","高","中","低"], defaultString: self?.priorityChooseButton.currentTitle, commit: { (text, index) in
self?.priorityChooseButton.isSelected = false
self?.priorityChooseButton.addBorder(1.0, kGaryColor)
}, cancel: {
self?.priorityChooseButton.isSelected = false
self?.priorityChooseButton.addBorder(1.0, kGaryColor)
})
self?.repairOrderViewModel.repairOrderFilterBtnAction((self?.priorityChooseButton)!).subscribe(onNext: { () in
self?.tableView.mj_header.beginRefreshing()
}).disposed(by: (self?.disposeBag)!)
}).disposed(by: disposeBag)
}
// MARK: - 加载数据
override func loadWebDataSource() {
endRefresh()
repairOrderViewModel.queryModel.page = pullPageIndex
repairOrderViewModel.queryRepairOrderAction().subscribe {[weak self] (event) in
switch event {
case .next(let page):
if (self?.pullPageIndex)! >= page {
self?.endRefreshNomoreData()
}else {
self?.endRefresh()
}
break
case .error(_):
self?.endRefreshNomoreData()
break
default:
break
}
self?.tableView.reloadData()
}.disposed(by: disposeBag)
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let orderCell = tableView.dequeueReusableCell(withIdentifier: RepairOrderTableViewCell.name(), for: indexPath)
return orderCell
return repairOrderViewModel.dequeueReusableCell(RepairOrderTableViewCell.name(),tableView,indexPath)
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10
return repairOrderViewModel.repairOrderArray.count
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
......@@ -115,13 +121,16 @@ class RepairOrderViewController: BaseTableViewPullController {
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
self.performSegue(withIdentifier: RepairOrderDetailViewController.name(), sender: nil)
self.performSegue(withIdentifier: RepairOrderDetailBgController.name(), sender: indexPath)
}
deinit {
print("释放")
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == RepairOrderDetailBgController.name() {
let detailBgVc = segue.destination as! RepairOrderDetailBgController
let indexPath = sender as! IndexPath
detailBgVc.billModel = repairOrderViewModel.repairOrderArray[indexPath.row]
}
}
}
......
//
// RootClass.swift
//
// Create by 云霄 曹 on 15/1/2018
// Copyright © 2018. All rights reserved.
import Foundation
import SwiftyJSON
class AttachmentReponseModel : NSObject{
var data : [AttachmentReponseData]!
var message : String!
var success : Bool!
/**
* Instantiate the instance using the passed json values to set the properties values
*/
init(fromJson json: JSON!){
if json.isEmpty{
return
}
data = [AttachmentReponseData]()
let dataArray = json["data"].arrayValue
for dataJson in dataArray{
let value = AttachmentReponseData(fromJson: dataJson)
data.append(value)
}
message = json["message"].stringValue
success = json["success"].boolValue
}
/**
* Returns all the available property values in the form of [String:Any] object where the key is the approperiate json key and the value is the value of the corresponding property
*/
func toDictionary() -> [String:Any]
{
var dictionary = [String:Any]()
if data != nil{
var dictionaryElements = [[String:Any]]()
for dataElement in data {
dictionaryElements.append(dataElement.toDictionary())
}
dictionary["data"] = dictionaryElements
}
if message != nil{
dictionary["message"] = message
}
if success != nil{
dictionary["success"] = success
}
return dictionary
}
}
class AttachmentReponseData : NSObject{
var entityType : String!
var entityUuid : String!
var fileName : String!
var fileUrl : AnyObject!
var lastModified : AnyObject!
var thumbnailFileName : AnyObject!
var uuid : String!
init(fromJson json: JSON!){
if json.isEmpty{
return
}
entityType = json["entityType"].stringValue
entityUuid = json["entityUuid"].stringValue
fileName = json["fileName"].stringValue
fileUrl = json["fileUrl"] as AnyObject
lastModified = json["lastModified"] as AnyObject
thumbnailFileName = json["thumbnailFileName"] as AnyObject
uuid = json["uuid"].stringValue
}
func toDictionary() -> [String:Any]
{
var dictionary = [String:Any]()
if entityType != nil{
dictionary["entityType"] = entityType
}
if entityUuid != nil{
dictionary["entityUuid"] = entityUuid
}
if fileName != nil{
dictionary["fileName"] = fileName
}
if fileUrl != nil{
dictionary["fileUrl"] = fileUrl
}
if lastModified != nil{
dictionary["lastModified"] = lastModified
}
if thumbnailFileName != nil{
dictionary["thumbnailFileName"] = thumbnailFileName
}
if uuid != nil{
dictionary["uuid"] = uuid
}
return dictionary
}
}
//
// RootClass.swift
//
// Create by 云霄 曹 on 15/1/2018
// Copyright © 2018. All rights reserved.
import Foundation
import SwiftyJSON
class AttachmentResultModel : NSObject{
var data : [AttachmentData]!
var message : String!
var success : Bool!
/**
* Instantiate the instance using the passed json values to set the properties values
*/
init(fromJson json: JSON!){
if json.isEmpty{
return
}
data = [AttachmentData]()
let dataArray = json["data"].arrayValue
for dataJson in dataArray{
let value = AttachmentData(fromJson: dataJson)
data.append(value)
}
message = json["message"].stringValue
success = json["success"].boolValue
}
/**
* Returns all the available property values in the form of [String:Any] object where the key is the approperiate json key and the value is the value of the corresponding property
*/
func toDictionary() -> [String:Any]
{
var dictionary = [String:Any]()
if data != nil{
var dictionaryElements = [[String:Any]]()
for dataElement in data {
dictionaryElements.append(dataElement.toDictionary())
}
dictionary["data"] = dictionaryElements
}
if message != nil{
dictionary["message"] = message
}
if success != nil{
dictionary["success"] = success
}
return dictionary
}
}
class AttachmentData : NSObject{
var entityType : String!
var entityUuid : String!
var fileName : String!
var fileUrl : String!
var lastModified : String!
var thumbnailFileName : String!
var uuid : String!
/**
* Instantiate the instance using the passed json values to set the properties values
*/
init(fromJson json: JSON!){
if json.isEmpty{
return
}
entityType = json["entityType"].stringValue
entityUuid = json["entityUuid"].stringValue
fileName = json["fileName"].stringValue
fileUrl = json["fileUrl"].stringValue
lastModified = json["lastModified"].stringValue
thumbnailFileName = json["thumbnailFileName"].stringValue
uuid = json["uuid"].stringValue
}
/**
* Returns all the available property values in the form of [String:Any] object where the key is the approperiate json key and the value is the value of the corresponding property
*/
func toDictionary() -> [String:Any]
{
var dictionary = [String:Any]()
if entityType != nil{
dictionary["entityType"] = entityType
}
if entityUuid != nil{
dictionary["entityUuid"] = entityUuid
}
if fileName != nil{
dictionary["fileName"] = fileName
}
if fileUrl != nil{
dictionary["fileUrl"] = fileUrl
}
if lastModified != nil{
dictionary["lastModified"] = lastModified
}
if thumbnailFileName != nil{
dictionary["thumbnailFileName"] = thumbnailFileName
}
if uuid != nil{
dictionary["uuid"] = uuid
}
return dictionary
}
}
//
// BillCompletedRequestModel.swift
//
// Create by 云霄 曹 on 15/1/2018
// Copyright © 2018. All rights reserved.
import Foundation
import SwiftyJSON
open class BillCompletedRequestModel : NSObject{
var brokenTime : String!
var descriptionField : String!
var device : UCN!
var finish : Bool!
var finishNote : String!
var finishTime : String!
var finishUser : UCN!
var level : String!
var position : UCN!
var receiveTime : String!
var reportUser : UCN!
var requestTime : String!
var serviceType : String!
var source : String!
var state : String!
var uuid : String!
var version : Int!
var workNo : String!
/**
* Instantiate the instance using the passed json values to set the properties values
*/
init(fromJson json: JSON!){
if json.isEmpty{
return
}
brokenTime = json["brokenTime"].stringValue
descriptionField = json["description"].stringValue
let deviceJson = json["device"]
if !deviceJson.isEmpty{
device = UCN(fromJson: deviceJson)
}
finish = json["finish"].boolValue
finishNote = json["finishNote"].stringValue
finishTime = json["finishTime"].stringValue
let finishUserJson = json["finishUser"]
if !finishUserJson.isEmpty{
finishUser = UCN(fromJson: finishUserJson)
}
level = json["level"].stringValue
let positionJson = json["position"]
if !positionJson.isEmpty{
position = UCN(fromJson: positionJson)
}
receiveTime = json["receiveTime"].stringValue
let reportUserJson = json["reportUser"]
if !reportUserJson.isEmpty{
reportUser = UCN(fromJson: reportUserJson)
}
requestTime = json["requestTime"].stringValue
serviceType = json["serviceType"].stringValue
source = json["source"].stringValue
state = json["state"].stringValue
uuid = json["uuid"].stringValue
version = json["version"].intValue
workNo = json["workNo"].stringValue
}
/**
* Returns all the available property values in the form of [String:Any] object where the key is the approperiate json key and the value is the value of the corresponding property
*/
func toDictionary() -> [String:Any]
{
var dictionary = [String:Any]()
if brokenTime != nil{
dictionary["brokenTime"] = brokenTime
}
if descriptionField != nil{
dictionary["description"] = descriptionField
}
if device != nil{
dictionary["device"] = device.toDictionary()
}
if finish != nil{
dictionary["finish"] = finish
}
if finishNote != nil{
dictionary["finishNote"] = finishNote
}
if finishTime != nil{
dictionary["finishTime"] = finishTime
}
if finishUser != nil{
dictionary["finishUser"] = finishUser.toDictionary()
}
if level != nil{
dictionary["level"] = level
}
if position != nil{
dictionary["position"] = position.toDictionary()
}
if receiveTime != nil{
dictionary["receiveTime"] = receiveTime
}
if reportUser != nil{
dictionary["reportUser"] = reportUser.toDictionary()
}
if requestTime != nil{
dictionary["requestTime"] = requestTime
}
if serviceType != nil{
dictionary["serviceType"] = serviceType
}
if source != nil{
dictionary["source"] = source
}
if state != nil{
dictionary["state"] = state
}
if uuid != nil{
dictionary["uuid"] = uuid
}
if version != nil{
dictionary["version"] = version
}
if workNo != nil{
dictionary["workNo"] = workNo
}
return dictionary
}
}
//
// ChildBillSaveOrUpdateModel.swift
//
// Create by 云霄 曹 on 15/1/2018
// Copyright © 2018. All rights reserved.
import Foundation
import SwiftyJSON
open class ChildBillSaveOrUpdateModel : NSObject{
var beginAttachmentId : String!
var dept : UCN!
var endAttachmentId : String!
var executeMateriels : [AnyObject]!
var executeNo : String!
var executeOutsources : [AnyObject]!
var hasOut : Bool!
var hasPaid : Bool!
var labourfee : AnyObject!
var materielfee : Int!
var note : AnyObject!
var owner : AnyObject!
var ownerTime : AnyObject!
var processBegin : AnyObject!
var processEnd : AnyObject!
var processMode : AnyObject!
var processor : AnyObject!
var property1 : AnyObject!
var property2 : AnyObject!
var reason : AnyObject!
var state : String!
var workid : String!
func toDictionary() -> [String:Any]
{
var dictionary = [String:Any]()
if beginAttachmentId != nil{
dictionary["beginAttachmentId"] = beginAttachmentId
}
if dept != nil{
dictionary["dept"] = dept.toDictionary()
}
if endAttachmentId != nil{
dictionary["endAttachmentId"] = endAttachmentId
}
if executeMateriels != nil{
dictionary["executeMateriels"] = executeMateriels
}
if executeNo != nil{
dictionary["executeNo"] = executeNo
}
if executeOutsources != nil{
dictionary["executeOutsources"] = executeOutsources
}
if hasOut != nil{
dictionary["hasOut"] = hasOut
}
if hasPaid != nil{
dictionary["hasPaid"] = hasPaid
}
if labourfee != nil{
dictionary["labourfee"] = labourfee
}
if materielfee != nil{
dictionary["materielfee"] = materielfee
}
if note != nil{
dictionary["note"] = note
}
if owner != nil{
dictionary["owner"] = owner
}
if ownerTime != nil{
dictionary["ownerTime"] = ownerTime
}
if processBegin != nil{
dictionary["processBegin"] = processBegin
}
if processEnd != nil{
dictionary["processEnd"] = processEnd
}
if processMode != nil{
dictionary["processMode"] = processMode
}
if processor != nil{
dictionary["processor"] = processor
}
if property1 != nil{
dictionary["property1"] = property1
}
if property2 != nil{
dictionary["property2"] = property2
}
if reason != nil{
dictionary["reason"] = reason
}
if state != nil{
dictionary["state"] = state
}
if workid != nil{
dictionary["workid"] = workid
}
return dictionary
}
}
//
// DepartmentQueryModel.swift
//
// Create by 云霄 曹 on 12/1/2018
// Copyright © 2018. All rights reserved.
import Foundation
import SwiftyJSON
open class DepartmentQueryModel : NSObject{
var deptUuids : [String]!
var workUuid : String!
/**
* Returns all the available property values in the form of [String:Any] object where the key is the approperiate json key and the value is the value of the corresponding property
*/
func toDictionary() -> [String:Any]
{
var dictionary = [String:Any]()
if deptUuids != nil{
dictionary["deptUuids"] = deptUuids
}
if workUuid != nil{
dictionary["workUuid"] = workUuid
}
return dictionary
}
}
//
// DepartmentResultModel.swift
//
// Create by 云霄 曹 on 12/1/2018
// Copyright © 2018. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
import SwiftyJSON
class DepartmentResultModel : NSObject{
var data : DepartmentData!
var message : String!
var success : Bool!
/**
* Instantiate the instance using the passed json values to set the properties values
*/
init(fromJson json: JSON!){
if json.isEmpty{
return
}
let dataJson = json["data"]
if !dataJson.isEmpty{
data = DepartmentData(fromJson: dataJson)
}
message = json["message"].stringValue
success = json["success"].boolValue
}
/**
* Returns all the available property values in the form of [String:Any] object where the key is the approperiate json key and the value is the value of the corresponding property
*/
func toDictionary() -> [String:Any]
{
var dictionary = [String:Any]()
if data != nil{
dictionary["data"] = data.toDictionary()
}
if message != nil{
dictionary["message"] = message
}
if success != nil{
dictionary["success"] = success
}
return dictionary
}
}
class DepartmentData : NSObject{
var paging : Paging!
var records : [UCN]!
/**
* Instantiate the instance using the passed json values to set the properties values
*/
init(fromJson json: JSON!){
if json.isEmpty{
return
}
let pagingJson = json["paging"]
if !pagingJson.isEmpty{
paging = Paging(fromJson: pagingJson)
}
records = [UCN]()
let recordsArray = json["records"].arrayValue
for recordsJson in recordsArray{
let value = UCN(fromJson: recordsJson)
records.append(value)
}
}
/**
* Returns all the available property values in the form of [String:Any] object where the key is the approperiate json key and the value is the value of the corresponding property
*/
func toDictionary() -> [String:Any]
{
var dictionary = [String:Any]()
if paging != nil{
dictionary["paging"] = paging.toDictionary()
}
if records != nil{
var dictionaryElements = [[String:Any]]()
for recordsElement in records {
dictionaryElements.append(recordsElement.toDictionary())
}
dictionary["records"] = dictionaryElements
}
return dictionary
}
}
......@@ -15,9 +15,49 @@ struct PhotoAttachmentModel<T> {
/// 如果是本地图片则为image
/// 如果是新增附件则为imageName
var attachment: T
var entityType: String!
var entityUuid: String!
init(_ attachment: T, _ type: ATTACHMENT_LOCATION) {
self.attachment = attachment
self.attachmentType = type
}
init(_ attachment: T,_ entityType: String, _ entityUuid: String, _ type: ATTACHMENT_LOCATION) {
self.attachment = attachment
self.attachmentType = type
self.entityType = entityType
self.entityUuid = entityUuid
}
}
/// 附件上传Model
public struct UploadPhotoAttachmentModel {
var entityType: String
var fileUrl: String
var fileName: String
var entityUuid: String
init(_ fileName: String, _ fileUrl: String, _ entityType: String, _ entityUuid: String) {
self.fileName = fileName
self.fileUrl = fileUrl
self.entityType = entityType
self.entityUuid = entityUuid
}
}
......@@ -8,16 +8,15 @@ import Foundation
import SwiftyJSON
open class RepairOrderQuery : NSObject{
open class RepairOrderQueryModel : NSObject{
var endCreateTime : String!
var level : AnyObject!
var order : Order!
var level : String!
var page : Int!
var pageSize : Int!
var source : String!
var startCreateTime : String!
var state : AnyObject!
var state : String!
/**
* Returns all the available property values in the form of [String:Any] object where the key is the approperiate json key and the value is the value of the corresponding property
......@@ -31,9 +30,6 @@ open class RepairOrderQuery : NSObject{
if level != nil{
dictionary["level"] = level
}
if order != nil{
dictionary["order"] = order.toDictionary()
}
if page != nil{
dictionary["page"] = page
}
......
......@@ -8,7 +8,7 @@ import Foundation
import SwiftyJSON
class RepairOrderResult : NSObject{
class RepairOrderResultModel : NSObject{
var data : RepairOrderData!
var message : String!
......@@ -117,7 +117,7 @@ class RepairOrderRecord : NSObject{
var lastModifyId : String!
var lastModifyOperName : String!
var lastModifyTime : String!
var level : AnyObject!
var level : String!
var materielfee : AnyObject!
var note : String!
var position : UCN!
......@@ -174,7 +174,7 @@ class RepairOrderRecord : NSObject{
lastModifyId = json["lastModify_id"].stringValue
lastModifyOperName = json["lastModify_operName"].stringValue
lastModifyTime = json["lastModify_time"].stringValue
level = json["level"] as AnyObject
level = json["level"].stringValue
materielfee = json["materielfee"] as AnyObject
note = json["note"].stringValue
let positionJson = json["position"]
......
......@@ -16,6 +16,4 @@ class RepairOrderDetailSectionView: UITableViewHeaderFooterView {
/// 状态时间
@IBOutlet weak var stateTimeLabel: UILabel!
}
......@@ -34,4 +34,26 @@ class RepairOrderSubOrderTableViewCell: UITableViewCell {
contentBgView.addBorder(1.0, kGaryColor)
}
// MARK: - 更新子工单cell
func updateChildBillCell(_ model: BillDetailExecute, _ indexPath: IndexPath) {
departmentName.text = model.dept.name
transferTimeLabel.text = model.lastModifyTime
subOrderState.text = repairOrderChineseState(model.state)
}
}
......@@ -10,7 +10,6 @@ import UIKit
class RepairOrderTableViewCell: UITableViewCell {
/// 创建时间
@IBOutlet weak var createTimeLabel: UILabel!
/// 单据状态
......@@ -27,9 +26,26 @@ class RepairOrderTableViewCell: UITableViewCell {
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
// MARK: - 更新工单cell
func updateBillCell(_ model: RepairOrderRecord, _ indexPath: IndexPath) {
createTimeLabel.text = model.createTime
orderStateLabel.text = repairOrderChineseState(model.state)
describeLabel.text = model.descriptionField
priorityLabel.text = model.level as? String
sourceLabel.text = model.source
orderNumberLabel.text = String(format: "单号:%@", model.workNo)
}
}
}
......@@ -74,7 +74,7 @@ extension RepairOrderAddViewModel {
// MARK: - 提交工单
func submitRepairOrder() ->Observable<String> {
saveOrderModel.state = SUBMIT_REPAIR_ORDER_STATE.CREATED.rawValue
saveOrderModel.state = SUBMIT_REPAIR_ORDER_STATE.SUBMIT.rawValue
return Observable.create({ (observer) -> Disposable in
Network.request(target: .SubmitOrder(self.saveOrderModel), success: { (json) in
let resultModel = PublicResultModel(fromJson: json)
......@@ -130,10 +130,11 @@ extension RepairOrderAddViewModel {
publicFilterVc.publicViewModel.filterArray.add(filterModel)
}
controller.pushVC(publicFilterVc)
publicFilterVc.setNavigationTitle("筛选报事人", { (model, index) in
controller.originatorLabel.text = model.title
publicFilterVc.setNavigationTitle("筛选报事人",.SINGLE, { (choices, index) in
let choiceModel = choices.first!
controller.originatorLabel.text = choiceModel.title
controller.originatorLabel.textColor = kBlackColor
let model = result[index]
let model = result[index!]
let user = UCN(model.login, model.name, model.uuid)
self?.saveOrderModel.reportUser = user
})
......@@ -163,10 +164,11 @@ extension RepairOrderAddViewModel {
publicFilterVc.publicViewModel.filterArray.add(filterModel)
}
controller.pushVC(publicFilterVc)
publicFilterVc.setNavigationTitle("筛选位置", { (model, index) in
controller.specifiedLocationLabel.text = model.title
publicFilterVc.setNavigationTitle("筛选位置",.SINGLE, { (choices, index) in
let choiceModel = choices.first!
controller.specifiedLocationLabel.text = choiceModel.title
controller.specifiedLocationLabel.textColor = kBlackColor
let model = result[index]
let model = result[index!]
let location = UCN(model.code, model.name, model.uuid)
self?.saveOrderModel.position = location
})
......@@ -179,13 +181,14 @@ extension RepairOrderAddViewModel {
let filterModel = PublicFilterModel(uuid: model.uuid, title: model.name, isSelected: "\(kZERO)")
publicFilterVc.publicViewModel.filterArray.add(filterModel)
}
publicFilterVc.setNavigationTitle("筛选设施", { (model, index) in
let deviceModel = result[index]
controller.deviceTitleLabel.text = model.title
publicFilterVc.setNavigationTitle("筛选设施",.SINGLE, { (choices, index) in
let deviceModel = result[index!]
let choiceModel = choices.first!
controller.deviceTitleLabel.text = choiceModel.title
controller.deviceLocationLabel.text = deviceModel.position.name
controller.deviceTitleLabel.textColor = kBlackColor
controller.deviceLocationLabel.textColor = kBlackColor
let model = result[index]
let model = result[index!]
let device = UCN(model.code, model.name, model.uuid)
self?.saveOrderModel.device = device
})
......
......@@ -7,12 +7,161 @@
//
import UIKit
import RxSwift
import Moya
class RepairOrderViewModel: BaseViewModel {
/// 查询工单列表对象
lazy final var queryModel: RepairOrderQueryModel = {
var queryModel = RepairOrderQueryModel()
queryModel.startCreateTime = NSDate(after: Date(), day: -7).httpParameterString()
queryModel.endCreateTime = NSDate().httpParameterString()
queryModel.pageSize = kPageSize
queryModel.page = kZERO
return queryModel
}()
/// 工单列表数据
lazy final var repairOrderArray: Array<RepairOrderRecord> = {
var repairOrderArray = Array<RepairOrderRecord>()
return repairOrderArray
}()
}
extension RepairOrderViewModel {
/// 查询工单列表
func queryRepairOrderAction() ->Observable<Int> {
return Observable.create({ (observer) -> Disposable in
Network.request(target: .QueryRepairOrder(self.queryModel), success: {[weak self] (json) in
let resultModel = RepairOrderResultModel(fromJson: json)
if resultModel.success {
if self?.queryModel.page == kZERO {
self?.repairOrderArray.removeAll()
}
for model in resultModel.data.records {
self?.repairOrderArray.append(model)
}
observer.onNext(resultModel.data.paging.pageCount)
}else {
ShowMessage(resultModel.message)
observer.onError(MoyaError.requestMapping(resultModel.message))
}
}, failure: { (error) in
ShowMessage(error.localizedDescription)
observer.onError(MoyaError.requestMapping(error.localizedDescription))
})
return Disposables.create()
})
}
}
extension RepairOrderViewModel {
// MARK: - 创建工单列表cell
func dequeueReusableCell(_ identifier: String,_ tableView: UITableView,_ indexPath: IndexPath) -> UITableViewCell {
let billCell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath) as! RepairOrderTableViewCell
billCell.updateBillCell(repairOrderArray[indexPath.row], indexPath)
return billCell
}
// MARK: - 工单列表筛选数据
// 时间、状态、来源、优先级
func repairOrderFilterBtnAction(_ sender: UIButton) ->Observable<Void> {
return Observable.create({ (observer) -> Disposable in
switch sender.tag {
case REPAIR_ORDER_FILTER_BUTTON_TAG.TIME.rawValue:
YXPickerManager.share().showGeneralPickerView(kNavColor, dataArray: ["最近一周","最近两周","最近一个月"], defaultString: sender.currentTitle, commit: { (text, index) in
sender.isSelected = false
sender.addBorder(1.0, kGaryColor)
sender.setTitle(text, for: .normal)
sender.horizontalCenterTitleAndImageRight(5)
var afterDay: Int = -7
switch index {
case 0:
afterDay = -7
break
case 1:
afterDay = -14
break
case 2:
afterDay = -30
break
default:
break
}
self.queryModel.startCreateTime = NSDate(after: Date(), day: afterDay).httpParameterString()
self.queryModel.endCreateTime = NSDate().httpParameterString()
observer.onNext(())
}, cancel: {
sender.isSelected = false
sender.addBorder(1.0, kGaryColor)
})
break
case REPAIR_ORDER_FILTER_BUTTON_TAG.STATE.rawValue:
YXPickerManager.share().showGeneralPickerView(kNavColor, dataArray: ["全部状态","未发出","已发出","处理中","已完成","已删除","已作废"], defaultString: sender.currentTitle, commit: { (text, index) in
sender.isSelected = false
sender.addBorder(1.0, kGaryColor)
sender.setTitle(text, for: .normal)
sender.horizontalCenterTitleAndImageRight(5)
self.queryModel.state = repairOrderEnglishState(text!)
observer.onNext(())
}, cancel: {
sender.isSelected = false
sender.addBorder(1.0, kGaryColor)
})
break
case REPAIR_ORDER_FILTER_BUTTON_TAG.SOURCE.rawValue:
YXPickerManager.share().showGeneralPickerView(kNavColor, dataArray: ["全部来源","内部","外部"], defaultString: sender.currentTitle, commit: { (text, index) in
sender.isSelected = false
sender.addBorder(1.0, kGaryColor)
sender.setTitle(text, for: .normal)
sender.horizontalCenterTitleAndImageRight(5)
sender.updateConstraints()
observer.onNext(())
}, cancel: {
sender.isSelected = false
sender.addBorder(1.0, kGaryColor)
})
break
case REPAIR_ORDER_FILTER_BUTTON_TAG.PRIORITY.rawValue:
YXPickerManager.share().showGeneralPickerView(kNavColor, dataArray: ["全部优先级","高","中","低"], defaultString: sender.currentTitle, commit: { (text, index) in
sender.isSelected = false
sender.addBorder(1.0, kGaryColor)
sender.setTitle(text, for: .normal)
sender.horizontalCenterTitleAndImageRight(5)
self.queryModel.level = text
observer.onNext(())
}, cancel: {
sender.isSelected = false
sender.addBorder(1.0, kGaryColor)
})
break
default:
break
}
return Disposables.create()
})
}
}
......@@ -7,7 +7,120 @@
//
import UIKit
import RxSwift
import RxCocoa
class ReparirChildBillViewModel: BaseViewModel {
/// RxSwift自动释放
let disposeBag = DisposeBag()
/// 子工单保存或者提交Model
lazy final var childBillSaveModel: ChildBillSaveOrUpdateModel = {
var childBillSaveModel = ChildBillSaveOrUpdateModel()
return childBillSaveModel
}()
/// 过滤ViewModel
lazy final var filterViewModel: FilterViewModel = {
var filterViewModel = FilterViewModel()
return filterViewModel
}()
}
extension ReparirChildBillViewModel {
// MARK: - 保存子工单
func saveChildBillAction() ->Observable<Void> {
return Observable.create({ (observer) -> Disposable in
Network.request(target: .SaveChildBill(self.childBillSaveModel), success: { (json) in
let resultModel = PublicResultModel(fromJson: json)
if resultModel.success {
observer.onNext(())
}else {
ShowMessage(resultModel.message)
}
}, failure: { (error) in
ShowMessage(error.localizedDescription)
})
return Disposables.create()
})
}
}
extension ReparirChildBillViewModel {
/// 完成部门工单界面item对应事件
func didSelectRowAtIndexPath(_ indexPath: IndexPath, _ controller: RepairOrderEditSonOrderViewController) {
switch indexPath {
case IndexPath(row: 0, section: 0):
filterViewModel.queryToolOption().subscribe(onNext: {[weak self] (result) in
YXPickerManager.share().showGeneralPickerView(kMainColor, dataArray: result, defaultString: controller.toolOptionLabel.text, commit: { (text, index) in
controller.toolOptionLabel.text = text
controller.toolOptionLabel.textColor = kBlackColor
self?.childBillSaveModel
}, cancel: nil)
}).disposed(by: disposeBag)
break
case IndexPath(row: 1, section: 0):
filterViewModel.queryProtectOption().subscribe(onNext: {[weak self] (result) in
YXPickerManager.share().showGeneralPickerView(kMainColor, dataArray: result, defaultString: controller.toolOptionLabel.text, commit: { (text, index) in
controller.toolOptionLabel.text = text
controller.toolOptionLabel.textColor = kBlackColor
}, cancel: nil)
}).disposed(by: disposeBag)
break
case IndexPath(row: 2, section: 0):
filterViewModel.queryInitiator().subscribe(onNext: {[weak self] (result) in
let publicFilterVc = FilterViewController.instantiateViewController(.Function) as! FilterViewController
for model in result {
let filterModel = PublicFilterModel(uuid: model.uuid, title: model.name, isSelected: "\(kZERO)")
publicFilterVc.publicViewModel.filterArray.add(filterModel)
}
controller.pushVC(publicFilterVc)
publicFilterVc.setNavigationTitle("选择出工人",.SINGLE, { (choices, index) in
let choiceModel = choices.first!
controller.workPersonLabel.text = choiceModel.title
controller.workPersonLabel.textColor = kBlackColor
let model = result[index!]
let user = UCN(model.login, model.name, model.uuid)
// self?.saveOrderModel.reportUser = user
})
}).disposed(by: disposeBag)
break
case IndexPath(row: 3, section: 0):
let defaultDate = controller.placeTimeLabel.text == "请选择" ? NSDate().httpParameterString() : controller.placeTimeLabel.text
YXPickerManager.share().showDatePickerView(kMainColor, datePickerModel: UIDatePickerMode.dateAndTime, minimumDate: Date(), maximumDate: nil, defaultDate: defaultDate, commit: {[weak self] (time) in
controller.placeTimeLabel.text = time
controller.placeTimeLabel.textColor = kBlackColor
// self?.saveOrderModel.receiveTime = time
}, cancel: nil)
break
case IndexPath(row: 4, section: 0):
let defaultDate = controller.leaveTimeLabel.text == "请选择" ? NSDate().httpParameterString() : controller.leaveTimeLabel.text
YXPickerManager.share().showDatePickerView(kMainColor, datePickerModel: UIDatePickerMode.dateAndTime, minimumDate: Date(), maximumDate: nil, defaultDate: defaultDate, commit: {[weak self] (time) in
controller.leaveTimeLabel.text = time
controller.leaveTimeLabel.textColor = kBlackColor
}, cancel: nil)
break
case IndexPath(row: 5, section: 0):
filterViewModel.queryBrokenOption().subscribe(onNext: {[weak self] (result) in
YXPickerManager.share().showGeneralPickerView(kMainColor, dataArray: result, defaultString: controller.failureCauseLabel.text, commit: { (text, index) in
controller.failureCauseLabel.text = text
controller.failureCauseLabel.textColor = kBlackColor
}, cancel: nil)
}).disposed(by: disposeBag)
break
case IndexPath(row: 6, section: 0):
filterViewModel.queryProcessMethods().subscribe(onNext: {[weak self] (result) in
YXPickerManager.share().showGeneralPickerView(kMainColor, dataArray: result, defaultString: controller.processModeLabel.text, commit: { (text, index) in
controller.processModeLabel.text = text
controller.processModeLabel.textColor = kBlackColor
}, cancel: nil)
}).disposed(by: disposeBag)
break
default:
break
}
}
}
......@@ -7,9 +7,14 @@
//
import UIKit
import RxCocoa
import RxSwift
class TodoViewController: BaseTableViewPullController {
/// RxSwift自动释放
let disposeBag = DisposeBag()
/// TodoViewModel
lazy final var todoViewModel: TodoViewModel = {
var todoViewModel = TodoViewModel()
......@@ -24,7 +29,19 @@ class TodoViewController: BaseTableViewPullController {
// MARK: - 加载数据
override func loadWebDataSource() {
endRefresh()
todoViewModel.queryTodoAction(.ALL).subscribe {[weak self] (event) in
switch event {
case .next():
self?.endRefreshNomoreData()
break
case .error(_):
self?.endRefresh()
break
default:
break
}
self?.tableView.reloadData()
}.disposed(by: disposeBag)
}
// MARK: - 设置tableview高度
......@@ -38,7 +55,23 @@ class TodoViewController: BaseTableViewPullController {
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10
return todoViewModel.todoResultArray.count
}
}
......@@ -8,37 +8,9 @@ import SwiftyJSON
class TodoResultModel{
var data : TodoData!
var message : String!
var success : Bool!
/**
* Instantiate the instance using the passed json values to set the properties values
*/
init(fromJson json: JSON!){
if json.isEmpty{
return
}
let dataJson = json["data"]
if !dataJson.isEmpty{
data = TodoData(fromJson: dataJson)
}
message = json["message"].stringValue
success = json["success"].boolValue
}
}
class TodoRecord{
var content : String!
var createTime : String!
var entityType : String!
var entityUuid : String!
var prompt : String!
var state : Bool!
var userid : String!
var uuid : String!
var version : Int!
var data : [TodoData]!
var message : String!
var success : Bool!
/**
......@@ -48,38 +20,14 @@ class TodoRecord{
if json.isEmpty{
return
}
content = json["content"].stringValue
createTime = json["createTime"].stringValue
entityType = json["entityType"].stringValue
entityUuid = json["entityUuid"].stringValue
prompt = json["prompt"].stringValue
state = json["state"].boolValue
userid = json["userid"].stringValue
uuid = json["uuid"].stringValue
version = json["version"].intValue
}
}
class Paging{
var page : Int!
var pageCount : Int!
var pageSize : Int!
var recordCount : Int!
/**
* Instantiate the instance using the passed json values to set the properties values
*/
init(fromJson json: JSON!){
if json.isEmpty{
return
data = [TodoData]()
let dataArray = json["data"].arrayValue
for dataJson in dataArray{
let value = TodoData(fromJson: dataJson)
data.append(value)
}
page = json["page"].intValue
pageCount = json["pageCount"].intValue
pageSize = json["pageSize"].intValue
recordCount = json["recordCount"].intValue
message = json["message"].stringValue
success = json["success"].boolValue
}
/**
......@@ -88,28 +36,34 @@ class Paging{
func toDictionary() -> [String:Any]
{
var dictionary = [String:Any]()
if page != nil{
dictionary["page"] = page
if data != nil{
var dictionaryElements = [[String:Any]]()
for dataElement in data {
dictionaryElements.append(dataElement.toDictionary())
}
dictionary["data"] = dictionaryElements
}
if pageCount != nil{
dictionary["pageCount"] = pageCount
if message != nil{
dictionary["message"] = message
}
if pageSize != nil{
dictionary["pageSize"] = pageSize
}
if recordCount != nil{
dictionary["recordCount"] = recordCount
if success != nil{
dictionary["success"] = success
}
return dictionary
}
}
class TodoData{
var paging : Paging!
var records : [TodoRecord]!
var dateTime : String!
var dept : UCN!
var executeId : String!
var executeNo : String!
var state : String!
var uuid : String!
/**
* Instantiate the instance using the passed json values to set the properties values
......@@ -118,16 +72,42 @@ class TodoData{
if json.isEmpty{
return
}
let pagingJson = json["paging"]
if !pagingJson.isEmpty{
paging = Paging(fromJson: pagingJson)
dateTime = json["dateTime"].stringValue
let deptJson = json["dept"]
if !deptJson.isEmpty{
dept = UCN(fromJson: deptJson)
}
executeId = json["executeId"].stringValue
executeNo = json["executeNo"].stringValue
state = json["state"].stringValue
uuid = json["uuid"].stringValue
}
/**
* Returns all the available property values in the form of [String:Any] object where the key is the approperiate json key and the value is the value of the corresponding property
*/
func toDictionary() -> [String:Any]
{
var dictionary = [String:Any]()
if dateTime != nil{
dictionary["dateTime"] = dateTime
}
if dept != nil{
dictionary["dept"] = dept.toDictionary()
}
if executeId != nil{
dictionary["executeId"] = executeId
}
if executeNo != nil{
dictionary["executeNo"] = executeNo
}
records = [TodoRecord]()
let recordsArray = json["records"].arrayValue
for recordsJson in recordsArray{
let value = TodoRecord(fromJson: recordsJson)
records.append(value)
if state != nil{
dictionary["state"] = state
}
if uuid != nil{
dictionary["uuid"] = uuid
}
return dictionary
}
}
......@@ -24,6 +24,11 @@ class TodoTableViewCell: UITableViewCell {
// Initialization code
}
// MARK: - 更新待办cell
func updateTodoCell(_ model: TodoData, _ indexPath: IndexPath) {
titleCodeLabel.text = String(format: "%@(%@)", model.dept.name,model.dept.code)
operationDateLabel.text = String(format: "转交时间:%@", model.dateTime)
todoStateLabel.text = repairOrderChineseState(model.state)
}
}
......@@ -8,21 +8,22 @@
import UIKit
import RxSwift
import Moya
class TodoViewModel: BaseViewModel {
/// 查询待办事项model
lazy final var queryModel: QueryTodoModel = {
var queryModel = QueryTodoModel()
queryModel.prompt = "未处理"
queryModel.receiver = kUser().userUuid
queryModel.entityType = "work"
queryModel.userId = kUser().userUuid
return queryModel
}()
/// 待办事项结果
lazy final var todoArray: Array<TodoRecord> = {
var todoArray = Array<TodoRecord>()
return todoArray
lazy final var todoResultArray: Array<TodoData> = {
var todoResultArray = Array<TodoData>()
return todoResultArray
}()
......@@ -31,23 +32,19 @@ class TodoViewModel: BaseViewModel {
/// - Parameters:
/// - page: 页数
/// - state: 状态
func queryTodoAction(_ page: Int,_ state: TODO_STATE) ->Observable<Int> {
queryModel.page = page
queryModel.pageSize = kPageSize
queryModel.state = state.rawValue
func queryTodoAction(_ state: TODO_STATE) ->Observable<Void> {
queryModel.stateEquals = state.rawValue
return Observable.create({ (observer) -> Disposable in
Network.request(target: .QueryTodo(self.queryModel), success: {[weak self] (json) in
let resultModel = TodoResultModel(fromJson: json)
if resultModel.success {
if page == kZERO {
self?.todoArray.removeAll()
for data in resultModel.data {
self?.todoResultArray.append(data)
}
for data in resultModel.data.records {
self?.todoArray.append(data)
}
observer.onNext(resultModel.data.paging.pageCount)
observer.onNext(())
}else {
ShowMessage(resultModel.message)
observer.onError(MoyaError.requestMapping(resultModel.message))
}
}, failure: { (error) in
ShowMessage(error.localizedDescription)
......@@ -59,16 +56,17 @@ class TodoViewModel: BaseViewModel {
extension TodoViewModel {
/// 待办事项菜单调用
func dequeueReusableCell(_ identifier: String, _ indexPath: IndexPath, _ tableView: UITableView) -> UITableViewCell {
let todoCell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath) as! TodoTableViewCell
todoCell.updateTodoCell(todoResultArray[indexPath.item],indexPath)
return todoCell
}
/// 首页待办事项调用
func dequeueReusableHomeCell(_ identifier: String, _ indexPath: IndexPath, _ tableView: UITableView) -> UITableViewCell {
let todoCell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath) as! HomeTableViewCell
todoCell.updateTodoCell(todoResultArray[indexPath.item],indexPath)
return todoCell
}
}
......
......@@ -31,14 +31,19 @@ class HomeTableViewController: BaseTableViewPullController {
// MARK: - 获取数据
override func loadWebDataSource() {
todoViewModel.queryTodoAction(pullPageIndex, todoState).subscribe(onNext: {[weak self] (pageCount) in
if (self?.pullPageIndex)! >= pageCount {
todoViewModel.queryTodoAction(todoState).subscribe {[weak self] (event) in
switch event {
case .next():
self?.endRefreshNomoreData()
}else {
break
case .error(_):
self?.endRefresh()
break
default:
break
}
self?.tableView.reloadData()
}).disposed(by: disposeBag)
}.disposed(by: disposeBag)
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
......@@ -46,7 +51,7 @@ class HomeTableViewController: BaseTableViewPullController {
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return todoViewModel.todoArray.count
return todoViewModel.todoResultArray.count
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
......
......@@ -9,86 +9,34 @@ import SwiftyJSON
public class QueryTodoModel {
var content : String!
var order : Order!
var overReceiver : String!
var overSpecifyRole : String!
var overtime : String!
var page : Int!
var pageSize : Int!
var prompt : String!
var receiver : String!
var remindTime : String!
var specifyRole : String!
var state : String!
var userId: String!
//drew 已领单
//init 未开始
var stateEquals: String!
var entityType: String!
// var page: Int!
// var pageSize: Int!
/**
* Returns all the available property values in the form of [String:Any] object where the key is the approperiate json key and the value is the value of the corresponding property
*/
func toDictionary() -> [String:Any]
{
var dictionary = [String:Any]()
if content != nil{
dictionary["content"] = content
if userId != nil{
dictionary["userId"] = userId
}
if order != nil{
dictionary["order"] = order.toDictionary()
if stateEquals != nil{
dictionary["stateEquals"] = stateEquals
}
if overReceiver != nil{
dictionary["overReceiver"] = overReceiver
}
if overSpecifyRole != nil{
dictionary["overSpecifyRole"] = overSpecifyRole
}
if overtime != nil{
dictionary["overtime"] = overtime
}
if page != nil{
dictionary["page"] = page
}
if pageSize != nil{
dictionary["pageSize"] = pageSize
}
if prompt != nil{
dictionary["prompt"] = prompt
}
if receiver != nil{
dictionary["receiver"] = receiver
}
if remindTime != nil{
dictionary["remindTime"] = remindTime
}
if specifyRole != nil{
dictionary["specifyRole"] = specifyRole
}
if state != nil{
dictionary["state"] = state
if entityType != nil{
dictionary["entityType"] = entityType
}
// if page != nil{
// dictionary["page"] = page
// }
// if pageSize != nil{
// dictionary["pageSize"] = pageSize
// }
return dictionary
}
}
public class Order{
var direction : String!
var field : String!
/**
* Returns all the available property values in the form of [String:Any] object where the key is the approperiate json key and the value is the value of the corresponding property
*/
func toDictionary() -> [String:Any]
{
var dictionary = [String:Any]()
if direction != nil{
dictionary["direction"] = direction
}
if field != nil{
dictionary["field"] = field
}
return dictionary
}
}
......@@ -18,7 +18,11 @@ class HomeTableViewCell: UITableViewCell {
override func awakeFromNib() {
super.awakeFromNib()
}
// MARK: - 更新待办cell
func updateTodoCell(_ model: TodoData, _ indexPath: IndexPath) {
departmentLabel.text = String(format: "%@(%@)", model.dept.name,model.dept.code)
orderTimeLabel.text = String(format: "转交时间:%@", model.dateTime)
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "bill_completed_state@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "bill_completed_state@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "bill_completed_state_selected@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "bill_completed_state_selected@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
......@@ -7,5 +7,7 @@
#import "YXKitHeader.h"
@import YXPickerView;
@import YXAlertController;
@import YXKit;
#import "IQTextView.h"
#import "UIDevice+Helper.h"
#import <CommonCrypto/CommonCrypto.h>
......@@ -16,15 +16,15 @@ PODS:
- Alamofire (~> 4.1)
- Result (~> 3.0)
- Result (3.2.4)
- RxCocoa (4.1.0):
- RxCocoa (4.1.1):
- RxSwift (~> 4.0)
- RxSwift (4.1.0)
- RxSwift (4.1.1)
- SKPhotoBrowser (5.0.3)
- SnapKit (4.0.0)
- SwiftyJSON (4.0.0)
- YXAlertController (1.0.8)
- YXKit (0.0.8)
- YXPickerView (1.0.0)
- YXPickerView (2.0.0)
DEPENDENCIES:
- DeviceKit
......@@ -61,14 +61,14 @@ SPEC CHECKSUMS:
MJRefresh: 5f8552bc25ca8751c010f621c1098dbdaacbccd6
Moya: 9e621707ff754eeb51ff3ec51a3d54e517c0733a
Result: d2d07204ce72856f1fd9130bbe42c35a7b0fea10
RxCocoa: cc1fec49cdc8fabe645964de7c51c099a36c2aa8
RxSwift: 4219941c1244c88002901bd87a69d3aea9ae71f0
RxCocoa: fd0862fd2df95fa55562ad28ffd2522c25eb4a85
RxSwift: c6e3b1c7b325c7d121cd4327e9d98b7ed746b570
SKPhotoBrowser: 6de77f7004442e79059f19d86e2e7e6a03b43a13
SnapKit: a42d492c16e80209130a3379f73596c3454b7694
SwiftyJSON: 070dabdcb1beb81b247c65ffa3a79dbbfb3b48aa
YXAlertController: 37a54642cb8e8b43b79004fe9148bb8ff2fab814
YXKit: 73d6ffbcf7530f1159e030460207286e9153b080
YXPickerView: 720c5568f16e4ebcfc5468e3a29d1a0e69293b0c
YXPickerView: 527ca74d8fbe73b4e9bd0bbff6e143133dced907
PODFILE CHECKSUM: bbdde573a885a7ec99a2e993aa40f5a213c0d05d
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment