Commit 08dde6a9 authored by 曹云霄's avatar 曹云霄

新建工单接口调用

parent fd6ee8b2
This diff is collapsed.
......@@ -18,7 +18,6 @@ class BaseTableViewPullController: BaseViewController {
/// 分页下标
final var pullPageIndex: Int = kONE
override func viewDidLoad() {
super.viewDidLoad()
......@@ -47,7 +46,6 @@ class BaseTableViewPullController: BaseViewController {
let header = MJRefreshNormalHeader(refreshingTarget: self, refreshingAction: #selector(BaseTableViewPullController.loadTableViewHeader))
header?.lastUpdatedTimeLabel.isHidden = true
header?.stateLabel.isHidden = true
header?.stateLabel.textColor = kNavColor
header?.beginRefreshing()
tableView.mj_header = header
}
......@@ -55,7 +53,7 @@ class BaseTableViewPullController: BaseViewController {
// MARK: - 添加上拉加载更多
func setupTableViewFooter() {
let footer = MJRefreshAutoNormalFooter(refreshingTarget: self, refreshingAction: #selector(BaseTableViewPullController.loadTableViewFooter))
footer?.setTitle("", for: .idle)
footer?.setTitle("~ 加载更多 ~", for: .idle)
footer?.setTitle("~ 加载中 ~", for: .refreshing)
footer?.setTitle("~ end ~", for: .noMoreData)
footer?.stateLabel.textColor = kNavColor
......@@ -107,7 +105,7 @@ class BaseTableViewPullController: BaseViewController {
extension BaseTableViewPullController: DZNEmptyDataSetSource,DZNEmptyDataSetDelegate {
func image(forEmptyDataSet scrollView: UIScrollView!) -> UIImage! {
return UIImage(named: "logo-github")
return UIImage(named: "not_data")
}
func description(forEmptyDataSet scrollView: UIScrollView!) -> NSAttributedString! {
......
......@@ -87,6 +87,34 @@ public enum TODO_STATE: String {
}
/// 工单状态类型
///
/// - CREATED: 未发出
/// - SUBMIT: 已发出
/// - PROCESSING: 处理中
/// - FINISHED: 已完成
/// - DELETED: 已删除
/// - CANCLED: 已作废
public enum SUBMIT_REPAIR_ORDER_STATE: String {
case CREATED = "created"
case SUBMIT = "submit"
case PROCESSING = "processing"
case FINISHED = "finished"
case DELETED = "deleted"
case CANCLED = "cancled"
}
......@@ -15,6 +15,8 @@ public var kNavColor: UIColor = UIColor.RGB(44, g: 48, b: 52)
public let kMainColor: UIColor = UIColor.RGB(67, g: 132, b: 196)
public let kBlueColor: UIColor = UIColor.RGB(77, g: 131, b: 242)
public let kGaryColor: UIColor = UIColor.RGB(240, g: 240, b: 240)
public let kLightGaryColor: UIColor = UIColor.RGB(170, g: 170, b: 170)
public let kBlackColor: UIColor = UIColor.black
......@@ -36,7 +38,7 @@ public let kWindow: UIWindow = ((UIApplication.shared.delegate?.window)!)!
/// 用户信息
public func kUser() -> UserModel {
return AppManager.shareInstance.userModel
return AppManager.shareInstance.userModel!
}
......
......@@ -10,11 +10,44 @@ 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 BaseUrl: String = "http://dev.gomoretech.com/ifs-server/rest"
/// 登录
public let loginUrl: String = "/user/login/%@"
/// 待办事项
public let todoUrl: String = "/message/query"
/// 新建工单来源
public let sourceUrl: String = "/config/getValue/source"
/// 新建工单服务类型
public let serviceTypeUrl: String = "/config/getValue/serviceType"
/// 新建工单优先级
public let prorityUrl: String = "/config/getValue/prorityOption"
/// 新建工单报事人
public let initiatorUrl: String = "/user/query"
/// 新建工单位置
public let positionUrl: String = "/information/position/query"
/// 新建工单设施
public let deviceUrl: String = "/information/device/query"
/// 新建工单提交
public let saveRepairOrderUrl: String = "/work/saveOrUpdate"
/// 工单列表查询
public let repairOrderUrl: String = "/work/query"
......@@ -77,3 +77,18 @@ extension NSString {
}
extension String {
//将原始的url编码为合法的url
func urlEncoded() -> String {
let encodeUrlString = self.addingPercentEncoding(withAllowedCharacters:
.urlQueryAllowed)
return encodeUrlString ?? ""
}
//将编码后的url转换回原始的url
func urlDecoded() -> String {
return self.removingPercentEncoding ?? ""
}
}
......@@ -7,18 +7,21 @@
//
import Moya
import SwiftyJSON
import YXAlertController
struct Network {
// 请求头
static let publicParamEndpointClosure = { (target: Service) -> Endpoint<Service> in
let url = target.baseURL.appendingPathComponent(target.path).absoluteString
// 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)
return endpoint.adding(newHTTPHeaderFields: ["Content-Type" : "application/json;charset=utf-8"])
if let userModel = AppManager.shareInstance.userModel {
return endpoint.adding(newHTTPHeaderFields: ["enterprise" : userModel.enterpriseUuid,"Content-Type" : "application/json;charset=utf-8"])
}
return endpoint.adding(newHTTPHeaderFields: ["Content-Type" : "application/json;charset=utf-8"])
}
// 设置超时时间
static let myRequestClosure = {(endpoint: Endpoint<Service>, closure: MoyaProvider<Service>.RequestResultClosure) -> Void in
do {
......@@ -64,8 +67,10 @@ struct Network {
//打印参数、返回
print("url = " + (response.request?.url?.absoluteString)!)
do {
let body = try JSON(data: (response.request?.httpBody)!)
print(body)
if let data = response.request!.httpBody {
let body = try JSON(data: data)
print(body)
}
let result = try JSON(data: response.data)
print(result)
}catch {}
......
......@@ -12,11 +12,26 @@ import Alamofire
import SwiftyJSON
public enum Service {
// MARK: - 登录
case Login(String,String)
// MARK: - 待办事项查询
case QueryTodo(QueryTodoModel)
// MARK: - 新建工单查询来源
case QuerySource()
// MARK: - 新建工单服务类型
case QueryServerType()
// MARK: - 新建工单优先级
case QueryPrority()
// MARK: - 查询报事人
case QueryInitiator()
// MARK: - 查询位置
case QueryPosition()
// MARK: - 查询设施
case QueryDevice(DeviceQueryModel)
// MARK: - 提交工单
case SubmitOrder(SaveRepairOrderModel)
// MARK: - 查询工单列表
case QueryRepairOrder(RepairOrderQuery)
}
extension Service: TargetType {
......@@ -30,15 +45,40 @@ extension Service: TargetType {
return String(format: loginUrl, name)
case .QueryTodo(_):
return todoUrl
case .QuerySource:
return sourceUrl
case .QueryServerType:
return serviceTypeUrl
case .QueryPrority:
return prorityUrl
case .QueryInitiator():
return initiatorUrl
case .QueryPosition():
return positionUrl
case .QueryDevice(_):
return deviceUrl
case .SubmitOrder(_):
let path = saveRepairOrderUrl + "?operator.operId=\(kUser().userCode!)&operator.operName=\(kUser().userName!)&time=\(NSDate().httpParameterString()!)"
return path.urlEncoded()
case .QueryRepairOrder(_):
return repairOrderUrl
}
}
public var method: Moya.Method {
switch self {
case .Login(_, _),
.QueryTodo(_):
.QueryTodo(_),
.QueryPosition(),
.QueryDevice(_),
.SubmitOrder(_),
.QueryRepairOrder(_),
.QueryInitiator(_):
return .post
case .QuerySource(),
.QueryServerType(),
.QueryPrority():
return .get
}
}
......@@ -55,6 +95,24 @@ extension Service: TargetType {
case .QueryTodo(let model):
return .requestParameters(parameters: model.toDictionary(),
encoding: JSONEncoding.default)
case .QuerySource(),
.QueryServerType(),
.QueryPrority():
return .requestPlain
case .QueryInitiator(),
.QueryPosition():
let model = EmptyModel()
return .requestParameters(parameters: model.toJSON()!,
encoding: JSONEncoding.default)
case .QueryDevice(let queryModel):
return .requestParameters(parameters: queryModel.toDictionary(),
encoding: JSONEncoding.default)
case .SubmitOrder(let submitModel):
return .requestParameters(parameters: submitModel.toDictionary(),
encoding: JSONEncoding.default)
case .QueryRepairOrder(let queryModel):
return .requestParameters(parameters: queryModel.toDictionary(),
encoding: JSONEncoding.default)
}
}
......
//
// FilterViewController.swift
// IFS
//
// Created by 曹云霄 on 2018/1/4.
// Copyright © 2018年 上海勾芒信息科技有限公司. All rights reserved.
//
import UIKit
/// 确认选择后回传数据
typealias SendValueClosure = (PublicFilterModel,Int) ->Void
class FilterViewController: BaseViewController {
/// 搜索关键字
@IBOutlet weak var searchBar: UISearchBar!
/// 搜索
@IBOutlet weak var filterTablView: UITableView!
/// 公共过滤ViewModel
lazy final var publicViewModel: FilterViewModel = {
var publicViewModel = FilterViewModel()
return publicViewModel;
}()
/// 回传数据
open var affirmSelectedBlock: SendValueClosure?
override func viewDidLoad() {
super.viewDidLoad()
addBarButtonItem()
setupConfigAction()
}
// MARK: - 添加提交按钮
fileprivate func addBarButtonItem() {
navigationItem.rightBarButtonItem = createButtonItem("确认", nil, self, #selector(FilterViewController.affirmButtonClickAction))
}
// MARK: - 设置导航栏
open func setNavigationTitle(_ title: String, _ block: @escaping SendValueClosure) {
self.title = title
self.affirmSelectedBlock = block
}
// MARK: - 初始化
func setupConfigAction() {
publicViewModel.displayArray = NSArray(array: publicViewModel.filterArray)
filterTablView.reloadData()
}
// MARK: - 确认选择
@objc func affirmButtonClickAction() {
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))
popVC()
}
}
}
// MARK: - UITableViewDelegate,UITableDataSource
extension FilterViewController: UITableViewDelegate,UITableViewDataSource {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
return publicViewModel.dequeueReusableCell(indexPath, FilterTableViewCell.name(), tableView)
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return publicViewModel.displayArray.count
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
view.endEditing(true)
publicViewModel.deselectRow(indexPath)
tableView.reloadData()
}
}
extension FilterViewController: UISearchBarDelegate {
func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
let predicate = NSPredicate(format: "title CONTAINS [cd] %@ ", searchText)
publicViewModel.displayArray = publicViewModel.filterArray.filtered(using: predicate) as NSArray
if searchText.isEmpty {
publicViewModel.displayArray = NSArray(array: publicViewModel.filterArray)
}
filterTablView.reloadData()
}
}
//
// SearchViewController.swift
// IFS
//
// Created by 曹云霄 on 2018/1/4.
// Copyright © 2018年 上海勾芒信息科技有限公司. All rights reserved.
//
import UIKit
class SearchViewController: BaseTableViewPullController {
override func viewDidLoad() {
super.viewDidLoad()
}
}
//
// DeviceModel.swift
//
// Create by 云霄 曹 on 11/1/2018
// Copyright © 2018. All rights reserved.
import Foundation
import SwiftyJSON
class DeviceModel {
var data : DeviceData!
var message : String!
var success : Bool!
init(fromJson json: JSON!){
if json.isEmpty{
return
}
let dataJson = json["data"]
if !dataJson.isEmpty{
data = DeviceData(fromJson: dataJson)
}
message = json["message"].stringValue
success = json["success"].boolValue
}
}
class DeviceData{
var paging : Paging!
var records : [DeviceRecord]!
init(fromJson json: JSON!){
if json.isEmpty{
return
}
let pagingJson = json["paging"]
if !pagingJson.isEmpty{
paging = Paging(fromJson: pagingJson)
}
records = [DeviceRecord]()
let recordsArray = json["records"].arrayValue
for recordsJson in recordsArray{
let value = DeviceRecord(fromJson: recordsJson)
records.append(value)
}
}
}
class DeviceRecord{
var code : String!
var createId : String!
var createOperName : String!
var createTime : String!
var deviceType : AnyObject!
var enabled : Bool!
var lastModifyId : String!
var lastModifyOperName : String!
var lastModifyTime : String!
var name : String!
var position : UCN!
var store : UCN!
var uuid : String!
var version : Int!
/**
* 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
createId = json["create_id"].stringValue
createOperName = json["create_operName"].stringValue
createTime = json["create_time"].stringValue
deviceType = json["deviceType"] as AnyObject
enabled = json["enabled"].boolValue
lastModifyId = json["lastModify_id"].stringValue
lastModifyOperName = json["lastModify_operName"].stringValue
lastModifyTime = json["lastModify_time"].stringValue
name = json["name"].stringValue
let positionJson = json["position"]
if !positionJson.isEmpty{
position = UCN(fromJson: positionJson)
}
let storeJson = json["store"]
if !storeJson.isEmpty{
store = UCN(fromJson: storeJson)
}
uuid = json["uuid"].stringValue
version = json["version"].intValue
}
}
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
}
}
//
// DeviceQueryModel.swift
// IFS
//
// Created by 曹云霄 on 2018/1/11.
// Copyright © 2018年 上海勾芒信息科技有限公司. All rights reserved.
//
import UIKit
import SwiftyJSON
open class DeviceQueryModel {
var codeEquals : String!
var nameLike : String!
var order : DeviceOrder!
var page : Int!
var pageSize : Int!
var stateEquals : String!
func toDictionary() -> [String:Any]
{
var dictionary = [String:Any]()
if codeEquals != nil{
dictionary["codeEquals"] = codeEquals
}
if nameLike != nil{
dictionary["nameLike"] = nameLike
}
if order != nil{
dictionary["order"] = order.toDictionary()
}
if page != nil{
dictionary["page"] = page
}
if pageSize != nil{
dictionary["pageSize"] = pageSize
}
if stateEquals != nil{
dictionary["stateEquals"] = stateEquals
}
return dictionary
}
}
class DeviceOrder{
var direction : String!
var field : String!
func toDictionary() -> [String:Any]
{
var dictionary = [String:Any]()
if direction != nil{
dictionary["direction"] = direction
}
if field != nil{
dictionary["field"] = field
}
return dictionary
}
}
//
// SearchViewModel.swift
// EmptyModel.swift
// IFS
//
// Created by 曹云霄 on 2018/1/4.
// Created by 曹云霄 on 2018/1/11.
// Copyright © 2018年 上海勾芒信息科技有限公司. All rights reserved.
//
import UIKit
class SearchViewModel: BaseViewModel {
class EmptyModel: BaseModel {
}
//
// InitiatorModel.swift
//
// Create by 云霄 曹 on 11/1/2018
// Copyright © 2018. All rights reserved.
//报事人
import Foundation
import SwiftyJSON
class InitiatorModel{
var data : InitiatorData!
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 = InitiatorData(fromJson: dataJson)
}
message = json["message"].stringValue
success = json["success"].boolValue
}
}
class InitiatorData {
var paging : Paging!
var records : [InitiatorRecord]!
/**
* 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 = [InitiatorRecord]()
let recordsArray = json["records"].arrayValue
for recordsJson in recordsArray{
let value = InitiatorRecord(fromJson: recordsJson)
records.append(value)
}
}
}
class InitiatorRecord{
var login : String!
var name : String!
var position : 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
}
login = json["login"].stringValue
name = json["name"].stringValue
position = json["position"].stringValue
uuid = json["uuid"].stringValue
}
}
//
// LocationModel.swift
//
// Create by 云霄 曹 on 11/1/2018
// Copyright © 2018. All rights reserved.
import Foundation
import SwiftyJSON
class LocationModel{
var data : LocationData!
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 = LocationData(fromJson: dataJson)
}
message = json["message"].stringValue
success = json["success"].boolValue
}
}
class LocationData{
var paging : Paging!
var records : [LocationRecord]!
/**
* 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 = [LocationRecord]()
let recordsArray = json["records"].arrayValue
for recordsJson in recordsArray{
let value = LocationRecord(fromJson: recordsJson)
records.append(value)
}
}
}
class LocationRecord{
var buldingName : AnyObject!
var code : String!
var createId : String!
var createOperName : String!
var createTime : String!
var enabled : Bool!
var floorName : AnyObject!
var lastModifyId : String!
var lastModifyOperName : String!
var lastModifyTime : String!
var name : String!
var positionCategory : AnyObject!
var store : AnyObject!
var uuid : String!
var version : Int!
/**
* Instantiate the instance using the passed json values to set the properties values
*/
init(fromJson json: JSON!){
if json.isEmpty{
return
}
buldingName = json["buldingName"] as AnyObject
code = json["code"].stringValue
createId = json["create_id"].stringValue
createOperName = json["create_operName"].stringValue
createTime = json["create_time"].stringValue
enabled = json["enabled"].boolValue
floorName = json["floorName"] as AnyObject
lastModifyId = json["lastModify_id"].stringValue
lastModifyOperName = json["lastModify_operName"].stringValue
lastModifyTime = json["lastModify_time"].stringValue
name = json["name"].stringValue
positionCategory = json["positionCategory"] as AnyObject
store = json["store"] as AnyObject
uuid = json["uuid"].stringValue
version = json["version"].intValue
}
}
//
// ProjectSponsorsModel.swift
//
// Create by 云霄 曹 on 11/1/2018
// Copyright © 2018. All rights reserved.
//来源、服务类型、优先级
import Foundation
import SwiftyJSON
class ProjectSponsorsModel : NSObject{
var data : [String]!
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 = [String]()
let dataArray = json["data"].arrayValue
for dataJson in dataArray{
data.append(dataJson.stringValue)
}
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
}
if message != nil{
dictionary["message"] = message
}
if success != nil{
dictionary["success"] = success
}
return dictionary
}
}
//
// PublicFilterModel.swift
// IFS
//
// Created by 曹云霄 on 2018/1/11.
// Copyright © 2018年 上海勾芒信息科技有限公司. All rights reserved.
//
import UIKit
class PublicFilterModel: NSObject {
var uuid: String?
@objc var title: String!
// 0 表示为选中
// 1 表示选中
@objc var isSelected: String!
init(uuid: String, title: String, isSelected: String) {
self.uuid = uuid
self.title = title
self.isSelected = isSelected
}
}
//
// SearchTableViewCell.swift
// FilterTableViewCell.swift
// IFS
//
// Created by 曹云霄 on 2018/1/4.
......@@ -8,7 +8,7 @@
import UIKit
class SearchTableViewCell: UITableViewCell {
class FilterTableViewCell: UITableViewCell {
/// 标题
......
//
// FilterViewModel.swift
// IFS
//
// Created by 曹云霄 on 2018/1/4.
// Copyright © 2018年 上海勾芒信息科技有限公司. All rights reserved.
//
import UIKit
import RxSwift
class FilterViewModel: BaseViewModel {
/// 公共过滤数组,需要把外界传入数据转化为此类型
lazy final var filterArray: NSMutableArray = {
var filterArray = NSMutableArray()
return filterArray
}()
/// 过滤后显示数据源
lazy final var displayArray: NSArray = {
var displayArray = NSArray()
return displayArray
}()
}
// MARK: - UI
extension FilterViewModel {
func dequeueReusableCell(_ indexPath: IndexPath,_ identifier: String, _ tableView: UITableView) ->UITableViewCell {
let publicFilterCell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath) as! FilterTableViewCell
let model = displayArray[indexPath.row] as! PublicFilterModel
publicFilterCell.accessoryType = model.isSelected == "\(kONE)" ? .checkmark : .none
publicFilterCell.titleLabel.text = model.title
return publicFilterCell
}
func deselectRow(_ indexPath: IndexPath){
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)"
}
}
// MARK: - 数据请求
extension FilterViewModel {
// MARK: - 查询工程发起方
func queryProjectSponsors() ->Observable<[String]> {
return Observable.create({ (observer) -> Disposable in
Network.request(target: .QuerySource(), 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 queryServerType() ->Observable<[String]> {
return Observable.create({ (observer) -> Disposable in
Network.request(target: .QueryServerType(), 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 queryProrityOption() ->Observable<[String]> {
return Observable.create({ (observer) -> Disposable in
Network.request(target: .QueryPrority(), 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 queryInitiator() ->Observable<[InitiatorRecord]> {
return Observable.create({ (observer) -> Disposable in
Network.request(target: .QueryInitiator(), success: { (json) in
let resultModel = InitiatorModel(fromJson: json)
if resultModel.success {
observer.onNext(resultModel.data.records)
}else {
ShowMessage(resultModel.message)
}
}, failure: { (error) in
ShowMessage(error.localizedDescription)
})
return Disposables.create()
})
}
// MARK: - 查询报事人
func queryLocation() ->Observable<[LocationRecord]> {
return Observable.create({ (observer) -> Disposable in
Network.request(target: .QueryPosition(), success: { (json) in
let resultModel = LocationModel(fromJson: json)
if resultModel.success {
observer.onNext(resultModel.data.records)
}else {
ShowMessage(resultModel.message)
}
}, failure: { (error) in
ShowMessage(error.localizedDescription)
})
return Disposables.create()
})
}
// MARK: - 查询设施
func queryDevice() ->Observable<[DeviceRecord]> {
let queryModel = DeviceQueryModel()
return Observable.create({ (observer) -> Disposable in
Network.request(target: .QueryDevice(queryModel), success: { (json) in
let resultModel = DeviceModel(fromJson: json)
if resultModel.success {
observer.onNext(resultModel.data.records)
}else {
ShowMessage(resultModel.message)
}
}, failure: { (error) in
ShowMessage(error.localizedDescription)
})
return Disposables.create()
})
}
}
......@@ -8,7 +8,6 @@
import UIKit
import Kingfisher
import YXAlertController
class AccountTableViewController: BaseTableViewController {
......
......@@ -7,21 +7,20 @@
//
import UIKit
import YXAlertController
class AccountViewModel: BaseViewModel {
// MARK: - 退出登录
func loginOutAction() {
ShowAlertView("提示", "请确认是否退出登录?", ["取消","确认"], .alert) { (index) in
if index == kZERO { return }
do {
try FileManager.default.removeItem(atPath: accountPath)
}catch {
ShowMessage("删除用户信息失败")
}
AppManager.shareInstance.openLoginVc()
}
// ShowAlertView("提示", "请确认是否退出登录?", ["取消","确认"], .alert) { (index) in
// if index == kZERO { return }
// do {
// try FileManager.default.removeItem(atPath: accountPath)
// }catch {
// ShowMessage("删除用户信息失败")
// }
// AppManager.shareInstance.openLoginVc()
// }
}
}
......@@ -32,6 +32,12 @@ class RepairOrderAddTableViewController: BaseTableViewController {
@IBOutlet weak var specifiedLocationLabel: UILabel!
/// 设施信息
@IBOutlet weak var facilitiesSwitch: UISwitch!
/// 设施
@IBOutlet weak var deviceTitleLabel: UILabel!
/// 设施位置
@IBOutlet weak var deviceLocationLabel: UITextField!
/// 设置故障时间
@IBOutlet weak var deviceFaultTimeLabel: UILabel!
/// 联系电话
@IBOutlet weak var phoneNumberText: UITextField!
/// 工单描述
......@@ -48,10 +54,11 @@ class RepairOrderAddTableViewController: BaseTableViewController {
return attachmentVc
}()
/// RepairOrderViewModel
lazy final var repairOrderViewModel: RepairOrderViewModel = {
var repairOrderViewModel = RepairOrderViewModel()
return repairOrderViewModel
/// RepairOrderAddViewModel
/// 新建工单ViewModel
lazy final var repairOrderAddViewModel: RepairOrderAddViewModel = {
var repairOrderAddViewModel = RepairOrderAddViewModel()
return repairOrderAddViewModel
}()
override func viewDidLoad() {
......@@ -72,7 +79,12 @@ class RepairOrderAddTableViewController: BaseTableViewController {
// MARK: - 提交工单
@objc fileprivate func submitButtonClickAction() {
if repairOrderAddViewModel.repairOrderAvailable(facilitiesSwitch) {
repairOrderAddViewModel.submitRepairOrder().subscribe(onNext: {[weak self] (result) in
ShowMessage("提交成功")
self?.popVC()
}).disposed(by: disposeBag)
}
}
// MARK: - 设置附件VC
......@@ -87,6 +99,10 @@ class RepairOrderAddTableViewController: BaseTableViewController {
facilitiesSwitch.rx.controlEvent(UIControlEvents.valueChanged).subscribe(onNext: {[weak self] (event) in
self?.tableView.reloadData()
}).disposed(by: disposeBag)
describeTextView.rx.text.subscribe(onNext: {[weak self] (string) in
self?.repairOrderAddViewModel.saveOrderModel.descriptionField = string
}).disposed(by: disposeBag)
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
......@@ -126,7 +142,7 @@ class RepairOrderAddTableViewController: BaseTableViewController {
}
return kSectionZero
}
return 10
return kSectionTen
}
override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
......@@ -139,8 +155,17 @@ class RepairOrderAddTableViewController: BaseTableViewController {
}
return super.tableView(tableView, viewForHeaderInSection: section)
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
repairOrderAddViewModel.didSelectRowAtIndePath(indexPath, self)
}
deinit {
print("释放")
}
}
// MARK: - 更新附件高度
extension RepairOrderAddTableViewController: PhotoAttachmentDelegate {
func updatePhotoAttachment(_ height: CGFloat, _ key: String?) {
attachmentHeight = height
......
......@@ -25,7 +25,6 @@ class RepairOrderViewController: BaseTableViewPullController {
/// 优先级选择
@IBOutlet weak var priorityChooseButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
......@@ -118,6 +117,10 @@ class RepairOrderViewController: BaseTableViewPullController {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
self.performSegue(withIdentifier: RepairOrderDetailViewController.name(), sender: nil)
}
deinit {
print("释放")
}
}
......
//
// PublicResultModel.swift
//
// Create by 云霄 曹 on 11/1/2018
// Copyright © 2018. All rights reserved.
import Foundation
import SwiftyJSON
class PublicResultModel : NSObject{
var data : String!
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 = json["data"].stringValue
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
}
if message != nil{
dictionary["message"] = message
}
if success != nil{
dictionary["success"] = success
}
return dictionary
}
}
//
// RootClass.swift
//
// Create by 云霄 曹 on 11/1/2018
// Copyright © 2018. All rights reserved.
import Foundation
import SwiftyJSON
open class RepairOrderQuery : NSObject{
var endCreateTime : String!
var level : AnyObject!
var order : Order!
var page : Int!
var pageSize : Int!
var source : String!
var startCreateTime : String!
var state : AnyObject!
/**
* 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 endCreateTime != nil{
dictionary["endCreateTime"] = endCreateTime
}
if level != nil{
dictionary["level"] = level
}
if order != nil{
dictionary["order"] = order.toDictionary()
}
if page != nil{
dictionary["page"] = page
}
if pageSize != nil{
dictionary["pageSize"] = pageSize
}
if source != nil{
dictionary["source"] = source
}
if startCreateTime != nil{
dictionary["startCreateTime"] = startCreateTime
}
if state != nil{
dictionary["state"] = state
}
return dictionary
}
}
//
// SaveRepairOrderModel.swift
//
// Create by 云霄 曹 on 11/1/2018
// Copyright © 2018. All rights reserved.
import Foundation
import SwiftyJSON
open class SaveRepairOrderModel {
var attachmentId : String!
var brokenTime : String!
var descriptionField : String!
var device : UCN!
var level : String!
var position : UCN!
var receiveTime : String!
var reportOrg : String!
var reportUser : UCN!
var reporterPhone : String!
var requestTime : String!
var serviceType : String!
var source : String!
var state : String!
var workNo : String!
func toDictionary() -> [String:Any]
{
var dictionary = [String:Any]()
if attachmentId != nil{
dictionary["attachmentId"] = attachmentId
}
if brokenTime != nil{
dictionary["brokenTime"] = brokenTime
}
if descriptionField != nil{
dictionary["description"] = descriptionField
}
if device != nil{
dictionary["device"] = device.toDictionary()
}
if level != nil{
dictionary["level"] = level
}
if position != nil{
dictionary["position"] = position.toDictionary()
}
if receiveTime != nil{
dictionary["receiveTime"] = receiveTime
}
if reportOrg != nil{
dictionary["reportOrg"] = reportOrg
}
if reportUser != nil{
dictionary["reportUser"] = reportUser.toDictionary()
}
if reporterPhone != nil{
dictionary["reporterPhone"] = reporterPhone
}
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 workNo != nil{
dictionary["workNo"] = workNo
}
return dictionary
}
}
......@@ -28,7 +28,7 @@ class TodoResultModel{
}
}
class Record{
class TodoRecord{
var content : String!
var createTime : String!
......@@ -82,12 +82,34 @@ class Paging{
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
}
}
class TodoData{
var paging : Paging!
var records : [Record]!
var records : [TodoRecord]!
/**
* Instantiate the instance using the passed json values to set the properties values
......@@ -100,10 +122,10 @@ class TodoData{
if !pagingJson.isEmpty{
paging = Paging(fromJson: pagingJson)
}
records = [Record]()
records = [TodoRecord]()
let recordsArray = json["records"].arrayValue
for recordsJson in recordsArray{
let value = Record(fromJson: recordsJson)
let value = TodoRecord(fromJson: recordsJson)
records.append(value)
}
}
......
......@@ -20,8 +20,8 @@ class TodoViewModel: BaseViewModel {
}()
/// 待办事项结果
lazy final var todoArray: Array<Record> = {
var todoArray = Array<Record>()
lazy final var todoArray: Array<TodoRecord> = {
var todoArray = Array<TodoRecord>()
return todoArray
}()
......
......@@ -2231,7 +2231,7 @@
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="设施位置" textAlignment="right" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="RU6-Ko-ArY">
<textField opaque="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="设施位置" textAlignment="right" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="RU6-Ko-ArY">
<rect key="frame" x="177" y="7" width="178" height="30"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="3ge-2h-6nJ"/>
......@@ -2334,6 +2334,9 @@
</tableView>
<connections>
<outlet property="describeTextView" destination="FOQ-jt-XWe" id="cZ8-3z-plz"/>
<outlet property="deviceFaultTimeLabel" destination="cWq-pB-V59" id="lTg-JL-70h"/>
<outlet property="deviceLocationLabel" destination="RU6-Ko-ArY" id="Xfh-Yd-NGV"/>
<outlet property="deviceTitleLabel" destination="DNT-zw-QBe" id="AyI-ho-vLY"/>
<outlet property="facilitiesSwitch" destination="3eR-qR-Yth" id="d6r-tH-PvV"/>
<outlet property="originatorLabel" destination="Uew-aE-Bpk" id="hOV-CM-3cw"/>
<outlet property="originatorTimeLabel" destination="7V7-W8-vDD" id="Rhs-0w-COm"/>
......@@ -2349,10 +2352,10 @@
</objects>
<point key="canvasLocation" x="1413.5999999999999" y="103.89805097451276"/>
</scene>
<!--Search View Controller-->
<!--Filter View Controller-->
<scene sceneID="20S-eS-CdS">
<objects>
<viewController storyboardIdentifier="SearchViewController" id="8GR-Sb-4CG" customClass="SearchViewController" customModule="IFS" customModuleProvider="target" sceneMemberID="viewController">
<viewController storyboardIdentifier="FilterViewController" id="8GR-Sb-4CG" customClass="FilterViewController" customModule="IFS" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="QR7-6q-ejE">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
......@@ -2367,8 +2370,9 @@
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="yYK-zZ-1UW">
<rect key="frame" x="0.0" y="76" width="375" height="591"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="tintColor" red="0.17254901959999999" green="0.1764705882" blue="0.21176470589999999" alpha="1" colorSpace="calibratedRGB"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="checkmark" indentationWidth="10" reuseIdentifier="SearchTableViewCell" id="XfJ-qw-Kjk" customClass="SearchTableViewCell" customModule="IFS" customModuleProvider="target">
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" accessoryType="checkmark" indentationWidth="10" reuseIdentifier="FilterTableViewCell" id="XfJ-qw-Kjk" customClass="FilterTableViewCell" customModule="IFS" customModuleProvider="target">
<rect key="frame" x="0.0" y="28" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="XfJ-qw-Kjk" id="0w7-kb-upd">
......@@ -2392,6 +2396,10 @@
</connections>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="8GR-Sb-4CG" id="5G0-R8-i32"/>
<outlet property="delegate" destination="8GR-Sb-4CG" id="CAJ-OT-ff0"/>
</connections>
</tableView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
......@@ -2407,7 +2415,8 @@
<viewLayoutGuide key="safeArea" id="MNG-bG-b3U"/>
</view>
<connections>
<outlet property="tableView" destination="yYK-zZ-1UW" id="A0m-tL-mEA"/>
<outlet property="filterTablView" destination="yYK-zZ-1UW" id="pyV-ui-6k8"/>
<outlet property="searchBar" destination="3to-sp-EdU" id="XJc-8E-SUw"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="VmD-ke-gmg" userLabel="First Responder" sceneMemberID="firstResponder"/>
......
......@@ -12,7 +12,7 @@ import Hero
class AppManager: NSObject {
/// 登录用户信息
open var userModel: UserModel!
open var userModel: UserModel?
/// 单例模式
static var shareInstance: AppManager = {
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "空页面.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
......@@ -5,6 +5,7 @@
#import "UIImage+Category.h"
#import "UINavigationController+FDFullscreenPopGesture.h"
#import "YXKitHeader.h"
#import "YXPickerManager.h"
@import YXPickerView;
@import YXAlertController;
#import "IQTextView.h"
#import "UIDevice+Helper.h"
......@@ -15,10 +15,10 @@ target ‘IFS’ do
pod 'HandyJSON', '~> 4.0.0-beta.1'
pod 'MJRefresh', '~> 3.1.15.1'
pod 'YXKit'
pod 'YXAlertController', '~> 1.0.8'
pod 'IQKeyboardManager', '~> 5.0.6'
pod 'FDFullscreenPopGesture', '~> 1.1'
pod 'YXPickerView', '~> 0.0.4'
pod 'ImagePicker'
pod 'SKPhotoBrowser', '~> 5.0.0'
pod 'YXPickerView'
pod 'YXAlertController'
end
......@@ -24,7 +24,7 @@ PODS:
- SwiftyJSON (4.0.0)
- YXAlertController (1.0.8)
- YXKit (0.0.8)
- YXPickerView (0.0.5)
- YXPickerView (1.0.0)
DEPENDENCIES:
- DeviceKit
......@@ -43,9 +43,9 @@ DEPENDENCIES:
- SKPhotoBrowser (~> 5.0.0)
- SnapKit
- SwiftyJSON
- YXAlertController (~> 1.0.8)
- YXAlertController
- YXKit
- YXPickerView (~> 0.0.4)
- YXPickerView
SPEC CHECKSUMS:
Alamofire: f41a599bd63041760b26d393ec1069d9d7b917f4
......@@ -68,8 +68,8 @@ SPEC CHECKSUMS:
SwiftyJSON: 070dabdcb1beb81b247c65ffa3a79dbbfb3b48aa
YXAlertController: 37a54642cb8e8b43b79004fe9148bb8ff2fab814
YXKit: 73d6ffbcf7530f1159e030460207286e9153b080
YXPickerView: 435b7b1362931fe63f2aab25d2810b1cf5ca2226
YXPickerView: 720c5568f16e4ebcfc5468e3a29d1a0e69293b0c
PODFILE CHECKSUM: 36ab8d11dc09b068c8608b937c8558d98c298b69
PODFILE CHECKSUM: bbdde573a885a7ec99a2e993aa40f5a213c0d05d
COCOAPODS: 1.3.0
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