Эх сурвалжийг харах

启动流程的列表可配置是否显示

fancy 5 жил өмнө
parent
commit
afc65d2772

+ 2 - 2
o2ios/O2Platform/App/Work-工作/c/category/ZoneMainCategoryViewController.swift

@@ -12,7 +12,7 @@ class ZoneMainCategoryViewController: UITableViewController {
     
     public static let SELECT_MSG_NAME = Notification.Name("CATEGORY_SELECT_OBJ")
     
-    public var apps:[Application] = [] {
+    public var apps:[O2Application] = [] {
         didSet {
             self.tableView.reloadData()
             if apps.count > 0 {
@@ -70,7 +70,7 @@ class ZoneMainCategoryViewController: UITableViewController {
         self.postMessage(sAPP)
     }
     
-    private func postMessage(_ currenApp:Application){
+    private func postMessage(_ currenApp: O2Application){
         NotificationCenter.default.post(name: ZoneMainCategoryViewController.SELECT_MSG_NAME, object: currenApp)
     }
     

+ 105 - 19
o2ios/O2Platform/App/Work-工作/c/category/ZoneMenuViewController.swift

@@ -12,7 +12,7 @@ import AlamofireImage
 import AlamofireObjectMapper
 import SwiftyJSON
 import ObjectMapper
-
+import Promises
 import CocoaLumberjack
 
 class ZoneMenuViewController: UIViewController {
@@ -22,12 +22,12 @@ class ZoneMenuViewController: UIViewController {
     
     private var subVC:ZoneSubCategoryViewController!
     
-    
-    fileprivate var apps:[Application] = [] {
-        didSet {
-            self.mainVC.apps = apps
-        }
-    }
+    private let o2ProcessAPI = OOMoyaProvider<OOApplicationAPI>()
+//    fileprivate var apps:[Application] = [] {
+//        didSet {
+//            self.mainVC.apps = apps
+//        }
+//    }
     
     
     override func viewWillAppear(_ animated: Bool) {
@@ -73,7 +73,73 @@ class ZoneMenuViewController: UIViewController {
     
     @objc private func reveiveCategoryNotification(_ notification:NSNotification){
         let obj = notification.object
-        self.subVC.app = obj as? Application
+        if let app = obj as? O2Application {
+            DispatchQueue.main.async {
+                self.showLoading()
+            }
+            self.loadProcessList(appId: app.id!).then { (list)  in
+                self.hideLoading()
+                self.subVC.processList = list
+            }.catch { (err) in
+                DDLogError(err.localizedDescription)
+                DispatchQueue.main.async {
+                    self.showError(title: "没有获取到流程列表!")
+                }
+            }
+        }
+    }
+    
+    /// 查询流程列表。如果新接口没有 就用老接口
+    private func loadProcessList(appId: String) -> Promise<[AppProcess]> {
+        return Promise {fulfill, reject in
+            self.loadProcessListWithFilter(appId: appId).then { (list)  in
+                fulfill(list)
+            }.catch { (err) in
+                DDLogError(err.localizedDescription)
+                //可能新接口不存在 查询老接口
+                self.loadProcessListOld(appId: appId).then { (oldList) in
+                    fulfill(oldList)
+                }.catch { (err) in
+                    reject(err)
+                }
+            }
+        }
+    }
+    
+    ///新接口 过滤仅pc的流程
+    private func loadProcessListWithFilter(appId: String) -> Promise<[AppProcess]> {
+        return Promise {fulfill, reject in
+            self.o2ProcessAPI.request(.applicationItemWithFilter(appId), completion: {result in
+                let response = OOResult<BaseModelClass<[AppProcess]>>(result)
+                if response.isResultSuccess() {
+                    if let list = response.model?.data {
+                        fulfill(list)
+                    }else {
+                        reject(OOAppError.apiEmptyResultError)
+                    }
+                }else {
+                    reject(response.error!)
+                }
+            })
+        }
+    }
+    
+    /// 老接口 不过滤
+    private func loadProcessListOld(appId: String) -> Promise<[AppProcess]> {
+        return Promise {fulfill, reject in
+            self.o2ProcessAPI.request(.applicationItem(appId), completion: {result in
+                let response = OOResult<BaseModelClass<[AppProcess]>>(result)
+                if response.isResultSuccess() {
+                    if let list = response.model?.data {
+                        fulfill(list)
+                    }else {
+                        reject(OOAppError.apiEmptyResultError)
+                    }
+                }else {
+                    reject(response.error!)
+                }
+            })
+        }
     }
     
     @objc private func receiveSubNotification(_ notification:NSNotification){
@@ -83,20 +149,40 @@ class ZoneMenuViewController: UIViewController {
     
     
     func loadAppList(){
-        let url = AppDelegate.o2Collect.generateURLWithAppContextKey(ApplicationContext.applicationContextKey, query: ApplicationContext.applicationListQuery, parameter: nil)
         self.showLoading(title: "应用加载中...")
-        self.apps.removeAll()
-        Alamofire.request(url!).responseArray(queue: nil, keyPath: "data", context: nil, completionHandler: { (response:DataResponse<[Application]>) in
-            switch response.result {
-            case .success(let apps):
-                self.apps.append(contentsOf: apps)
-                self.showSuccess(title: "加载完成")
-            case .failure(let err):
-                DDLogError(err.localizedDescription)
-                self.showError(title: "加载失败")
+//        let url = AppDelegate.o2Collect.generateURLWithAppContextKey(ApplicationContext.applicationContextKey, query: ApplicationContext.applicationListQuery, parameter: nil)
+        
+//        self.apps.removeAll()
+//        Alamofire.request(url!).responseArray(queue: nil, keyPath: "data", context: nil, completionHandler: { (response:DataResponse<[Application]>) in
+//            switch response.result {
+//            case .success(let apps):
+//                self.apps.append(contentsOf: apps)
+//                self.showSuccess(title: "加载完成")
+//            case .failure(let err):
+//                DDLogError(err.localizedDescription)
+//                self.showError(title: "加载失败")
+//            }
+//
+//        })
+        
+        self.o2ProcessAPI.request(.applicationOnlyList, completion: {result in
+            let response = OOResult<BaseModelClass<[O2Application]>>(result)
+            if response.isResultSuccess() {
+                let list = response.model?.data
+                if let apps = list {
+                    DispatchQueue.main.async {
+                        self.showSuccess(title: "加载完成")
+                        self.mainVC.apps = apps
+                    }
+                }else {
+                   DispatchQueue.main.async { self.showError(title: "没有应用数据!") }
+                }
+            }else {
+                DDLogError(response.error?.errorDescription ?? "")
+                DispatchQueue.main.async { self.showError(title: "加载失败") }
             }
-            
         })
+        
     }
     
     //获取身份列表

+ 18 - 17
o2ios/O2Platform/App/Work-工作/c/category/ZoneSubCategoryViewController.swift

@@ -9,11 +9,16 @@
 import UIKit
 
 class ZoneSubCategoryViewController: UITableViewController {
-    
-    
+
     public static let SELEC_SUB_ITEM = NSNotification.Name("SELECT_ITEM_OBJ")
-    
-    public var app:Application! {
+
+//    public var app:Application! {
+//        didSet {
+//            self.tableView.reloadData()
+//        }
+//    }
+
+    var processList: [AppProcess] = [] {
         didSet {
             self.tableView.reloadData()
         }
@@ -41,24 +46,20 @@ class ZoneSubCategoryViewController: UITableViewController {
         return 1
     }
 
-   override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
         // #warning Incomplete implementation, return the number of rows
-        if let _  = self.app {
-            return (self.app.processList?.count)!
-        }else{
-            return 0
-        }
+        return self.processList.count
     }
 
-    
-   override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
-    let cell = tableView.dequeueReusableCell(withIdentifier: "ZoneSubCategoryTableViewCell", for: indexPath) as! ZoneSubCategoryTableViewCell
-    cell.itemLabel.text = self.app.processList?[indexPath.row].name
-    return cell
+
+    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+        let cell = tableView.dequeueReusableCell(withIdentifier: "ZoneSubCategoryTableViewCell", for: indexPath) as! ZoneSubCategoryTableViewCell
+        cell.itemLabel.text = self.processList[indexPath.row].name
+        return cell
     }
-    
+
     override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
-        let item = self.app.processList?[indexPath.row]
+        let item = self.processList[indexPath.row]
         NotificationCenter.default.post(name: ZoneSubCategoryViewController.SELEC_SUB_ITEM, object: item)
     }
 

+ 14 - 13
o2ios/O2Platform/App/Work-工作/m/AppProcess.swift

@@ -8,25 +8,26 @@
 
 import Foundation
 import ObjectMapper
-class AppProcess:Mappable {
-    var id:String?
-    var name:String?
-    var alias:String?
-    var description:String?
-    var creatorPerson:String?
-    var application:String?
-    var icon:String?
-    var defaultStartMode: String?
+import HandyJSON
+
+
+class AppProcess: NSObject, DataModel  {
+    @objc var id:String?
+    @objc var name:String?
+    @objc var alias:String?
+    @objc var desc:String?
+    @objc var creatorPerson:String?
+    @objc var application:String?
+    @objc var icon:String?
+    @objc var defaultStartMode: String?
     
-    required init?(map: Map) {
-        
-    }
+    required override init(){}
     
     func mapping(map: Map) {
         id <- map["id"]
         name <- map["name"]
         alias <- map["alias"]
-        description <- map["description"]
+        desc <- map["description"]
         creatorPerson <- map["creatorPerson"]
         application <- map["application"]
         icon <- map["icon"]

+ 27 - 102
o2ios/O2Platform/App/Work-工作/m/O2Application.swift

@@ -7,38 +7,30 @@ import ObjectMapper
 import HandyJSON
 
 
-class O2Application : NSObject, NSCoding, Mappable{
+class O2Application : NSObject, DataModel {
 
-	var alias : String?
-	var applicationCategory : String?
-	var availableCompanyList : [AnyObject]?
-	var availableDepartmentList : [String]?
-	var availableIdentityList : [AnyObject]?
-	var controllerList : [AnyObject]?
-	var createTime : String?
-	var creatorPerson : String?
-	var descriptionField : String?
-	var icon : String?
-	var id : String?
-	var lastUpdatePerson : String?
-	var lastUpdateTime : String?
-	var name : String?
-	var updateTime : String?
+	@objc var alias : String?
+	@objc var applicationCategory : String?
+	@objc var controllerList : [String]?
+	@objc var createTime : String?
+	@objc var creatorPerson : String?
+	@objc var descriptionField : String?
+	@objc var icon : String?
+	@objc var id : String?
+	@objc var lastUpdatePerson : String?
+	@objc var lastUpdateTime : String?
+	@objc var name : String?
+	@objc var updateTime : String?
 
 
-	class func newInstance(map: Map) -> Mappable?{
-		return O2Application()
-	}
-	required init?(map: Map){}
-	private override init(){}
+	 
+	 
+	required override init(){}
 
 	func mapping(map: Map)
 	{
 		alias <- map["alias"]
 		applicationCategory <- map["applicationCategory"]
-		availableCompanyList <- map["availableCompanyList"]
-		availableDepartmentList <- map["availableDepartmentList"]
-		availableIdentityList <- map["availableIdentityList"]
 		controllerList <- map["controllerList"]
 		createTime <- map["createTime"]
 		creatorPerson <- map["creatorPerson"]
@@ -49,86 +41,9 @@ class O2Application : NSObject, NSCoding, Mappable{
 		lastUpdateTime <- map["lastUpdateTime"]
 		name <- map["name"]
 		updateTime <- map["updateTime"]
-		
-	}
-
-    /**
-    * NSCoding required initializer.
-    * Fills the data from the passed decoder
-    */
-    @objc required init(coder aDecoder: NSCoder)
-	{
-         alias = aDecoder.decodeObject(forKey: "alias") as? String
-         applicationCategory = aDecoder.decodeObject(forKey: "applicationCategory") as? String
-         availableCompanyList = aDecoder.decodeObject(forKey: "availableCompanyList") as? [AnyObject]
-         availableDepartmentList = aDecoder.decodeObject(forKey: "availableDepartmentList") as? [String]
-         availableIdentityList = aDecoder.decodeObject(forKey: "availableIdentityList") as? [AnyObject]
-         controllerList = aDecoder.decodeObject(forKey: "controllerList") as? [AnyObject]
-         createTime = aDecoder.decodeObject(forKey: "createTime") as? String
-         creatorPerson = aDecoder.decodeObject(forKey: "creatorPerson") as? String
-         descriptionField = aDecoder.decodeObject(forKey: "description") as? String
-         icon = aDecoder.decodeObject(forKey: "icon") as? String
-         id = aDecoder.decodeObject(forKey: "id") as? String
-         lastUpdatePerson = aDecoder.decodeObject(forKey: "lastUpdatePerson") as? String
-         lastUpdateTime = aDecoder.decodeObject(forKey: "lastUpdateTime") as? String
-         name = aDecoder.decodeObject(forKey: "name") as? String
-         updateTime = aDecoder.decodeObject(forKey: "updateTime") as? String
-
 	}
 
-    /**
-    * NSCoding required method.
-    * Encodes mode properties into the decoder
-    */
-    @objc func encode(with aCoder: NSCoder)
-	{
-		if alias != nil{
-			aCoder.encode(alias, forKey: "alias")
-		}
-		if applicationCategory != nil{
-			aCoder.encode(applicationCategory, forKey: "applicationCategory")
-		}
-		if availableCompanyList != nil{
-			aCoder.encode(availableCompanyList, forKey: "availableCompanyList")
-		}
-		if availableDepartmentList != nil{
-			aCoder.encode(availableDepartmentList, forKey: "availableDepartmentList")
-		}
-		if availableIdentityList != nil{
-			aCoder.encode(availableIdentityList, forKey: "availableIdentityList")
-		}
-		if controllerList != nil{
-			aCoder.encode(controllerList, forKey: "controllerList")
-		}
-		if createTime != nil{
-			aCoder.encode(createTime, forKey: "createTime")
-		}
-		if creatorPerson != nil{
-			aCoder.encode(creatorPerson, forKey: "creatorPerson")
-		}
-		if descriptionField != nil{
-			aCoder.encode(descriptionField, forKey: "description")
-		}
-		if icon != nil{
-			aCoder.encode(icon, forKey: "icon")
-		}
-		if id != nil{
-			aCoder.encode(id, forKey: "id")
-		}
-		if lastUpdatePerson != nil{
-			aCoder.encode(lastUpdatePerson, forKey: "lastUpdatePerson")
-		}
-		if lastUpdateTime != nil{
-			aCoder.encode(lastUpdateTime, forKey: "lastUpdateTime")
-		}
-		if name != nil{
-			aCoder.encode(name, forKey: "name")
-		}
-		if updateTime != nil{
-			aCoder.encode(updateTime, forKey: "updateTime")
-		}
-
-	}
+    
 
 }
 
@@ -143,3 +58,13 @@ class O2ApplicationIcon: NSObject, DataModel {
     func mapping(mapper: HelpingMapper) {
     }
 }
+
+/// 根据应用查询流程 applicationItemWithFilter filter对象
+class O2ProcessFilter: NSObject, DataModel {
+    @objc var startableTerminal: String? //可启动流程终端类型,可选值 client,mobile,all
+    required override init() {
+    }
+    
+    func mapping(mapper: HelpingMapper) {
+    }
+}

+ 1 - 1
o2ios/O2Platform/App/Work-工作/task.storyboard

@@ -155,7 +155,7 @@
                         <outlet property="tableView" destination="vbb-IJ-YEQ" id="Ov2-c9-jlM"/>
                         <outlet property="tableViewTopConstraint" destination="MI0-xl-tRF" id="d3z-LJ-hc9"/>
                         <segue destination="1VT-mT-wvg" kind="show" identifier="showTodoTaskSegue" id="SwG-Rc-UPd"/>
-                        <segue destination="Lit-tA-usI" kind="show" identifier="showAppCategorySegue" id="V8m-f4-bAt"/>
+                        <segue destination="Lit-tA-usI" kind="show" identifier="showAppCategorySegue" animates="NO" id="V8m-f4-bAt"/>
                         <segue destination="g80-nM-0Sh" kind="show" identifier="showMailSegue" id="97y-zw-SwJ"/>
                     </connections>
                 </viewController>

+ 9 - 2
o2ios/O2Platform/Framework/O2API/TaskAPI/OOApplicationAPI.swift

@@ -14,7 +14,8 @@ import O2OA_Auth_SDK
 enum OOApplicationAPI {
     case applicationList
     case applicationOnlyList
-    case applicationItem(String)
+    case applicationItem(String) // 更加应用获取流程列表
+    case applicationItemWithFilter(String) //新版 根据应用获取流程列表 有移动端过滤 仅pc的流程不出现在这里
     case availableIdentityWithProcess(String)
     case startProcess(String, String, String) // processId identity title
     case icon(String)
@@ -50,6 +51,8 @@ extension OOApplicationAPI:TargetType {
             return "/jaxrs/application/list"
         case .applicationItem(let appId):
             return "/jaxrs/process/list/application/\(appId)"
+        case .applicationItemWithFilter(let appId):
+            return "/jaxrs/process/list/application/\(appId)/filter"
         case .availableIdentityWithProcess(let processId):
             return "/jaxrs/process/list/available/identity/process/\(processId)"
         case .startProcess(let processId, _, _):
@@ -61,7 +64,7 @@ extension OOApplicationAPI:TargetType {
     
     var method: Moya.Method {
         switch self {
-        case .startProcess(_, _, _):
+        case .startProcess(_, _, _), .applicationItemWithFilter(_):
             return .post
         default:
             return .get
@@ -76,6 +79,10 @@ extension OOApplicationAPI:TargetType {
         switch self {
         case .startProcess(_, let identity, let title):
             return .requestParameters(parameters: ["identity": identity, "title": title], encoding: JSONEncoding.default)
+        case .applicationItemWithFilter(_):
+            let filter = O2ProcessFilter()
+            filter.startableTerminal = "mobile" //移动端过滤 仅pc的流程不出现在这里
+            return .requestParameters(parameters: filter.toJSON()!, encoding: JSONEncoding.default)
         default:
             return .requestPlain
         }