Просмотр исходного кода

Merge branch 'feature/async_form' into 'wrdp'

表单支持Promise作为默认值,优化表单性能

See merge request o2oa/o2oa!2179
胡起 5 лет назад
Родитель
Сommit
0f0225473a
35 измененных файлов с 4493 добавлено и 1384 удалено
  1. 4 0
      o2ios/O2Platform.xcodeproj/project.pbxproj
  2. 77 72
      o2ios/O2Platform/App/Login-绑定登录/c/LoginViewController.swift
  3. 25 0
      o2ios/O2Platform/App/Login-绑定登录/c/OOLoginViewController.swift
  4. 44 0
      o2ios/O2Platform/Manager/SecurityCheckManager.swift
  5. 1 2
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/service/CmsBatchOperationPersistService.java
  6. 446 68
      o2web/source/o2_core/o2.js
  7. 90 0
      o2web/source/o2_core/o2/actionWorker.js
  8. 19 1
      o2web/source/o2_core/o2/widget/chart/Line.js
  9. 37 4
      o2web/source/o2_core/o2/xDesktop/Actions/RestActions.js
  10. 9 3
      o2web/source/o2_core/o2/xDesktop/Common.js
  11. 1 1
      o2web/source/o2_core/o2/xScript/Actions/UnitActions.js
  12. 574 182
      o2web/source/o2_core/o2/xScript/CMSEnvironment.js
  13. 568 176
      o2web/source/o2_core/o2/xScript/Environment.js
  14. 645 253
      o2web/source/o2_core/o2/xScript/PageEnvironment.js
  15. 650 250
      o2web/source/o2_core/o2/xScript/ViewEnvironment.js
  16. 2 0
      o2web/source/o2_lib/polyfill/polyfill.js
  17. 9 8
      o2web/source/x_component_process_FormDesigner/Module/Checkbox/checkbox.html
  18. 9 13
      o2web/source/x_component_process_FormDesigner/Module/Org/org.html
  19. 9 8
      o2web/source/x_component_process_FormDesigner/Module/Radio/radio.html
  20. 38 38
      o2web/source/x_component_process_FormDesigner/Module/Select/select.html
  21. 1 2
      o2web/source/x_component_process_ProcessDesigner/$Process/flat/css.wcss
  22. 66 4
      o2web/source/x_component_process_Xform/$Input.js
  23. 30 2
      o2web/source/x_component_process_Xform/Calendar.js
  24. 109 45
      o2web/source/x_component_process_Xform/Checkbox.js
  25. 123 26
      o2web/source/x_component_process_Xform/DatagridMobile.js
  26. 102 45
      o2web/source/x_component_process_Xform/DatagridPC.js
  27. 12 0
      o2web/source/x_component_process_Xform/Documenteditor.js
  28. 21 3
      o2web/source/x_component_process_Xform/Label.js
  29. 9 1
      o2web/source/x_component_process_Xform/Number.js
  30. 355 100
      o2web/source/x_component_process_Xform/Org.js
  31. 170 44
      o2web/source/x_component_process_Xform/Radio.js
  32. 159 26
      o2web/source/x_component_process_Xform/Select.js
  33. 65 6
      o2web/source/x_component_process_Xform/Textarea.js
  34. 1 0
      o2web/source/x_desktop/index.html
  35. 13 1
      o2web/source/x_desktop/res/config/config.json

+ 4 - 0
o2ios/O2Platform.xcodeproj/project.pbxproj

@@ -273,6 +273,7 @@
 		B1D1BC8F234C8349002025DA /* CloudFileCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1D1BC8E234C8349002025DA /* CloudFileCell.swift */; };
 		B1D4AFED24B409A9004E648E /* AudioTouchButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1D4AFEC24B409A9004E648E /* AudioTouchButton.swift */; };
 		B1DA305F2282754500669418 /* QCalendarPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1DA305E2282754500669418 /* QCalendarPicker.swift */; };
+		B1DB0843252314F400EE6673 /* SecurityCheckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1DB0842252314F400EE6673 /* SecurityCheckManager.swift */; };
 		B1DB6EA5237E6F2C00D7BA94 /* O2VersionInfoModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1DB6EA4237E6F2C00D7BA94 /* O2VersionInfoModel.swift */; };
 		B1DE853823602D36003C36E2 /* Languager.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1DE853723602D36003C36E2 /* Languager.swift */; };
 		B1DE8564236030E2003C36E2 /* Bundle+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1DE8563236030E2003C36E2 /* Bundle+Extension.swift */; };
@@ -1444,6 +1445,7 @@
 		B1D1BC8E234C8349002025DA /* CloudFileCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudFileCell.swift; sourceTree = "<group>"; };
 		B1D4AFEC24B409A9004E648E /* AudioTouchButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioTouchButton.swift; sourceTree = "<group>"; };
 		B1DA305E2282754500669418 /* QCalendarPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QCalendarPicker.swift; sourceTree = "<group>"; };
+		B1DB0842252314F400EE6673 /* SecurityCheckManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecurityCheckManager.swift; sourceTree = "<group>"; };
 		B1DB6EA4237E6F2C00D7BA94 /* O2VersionInfoModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = O2VersionInfoModel.swift; sourceTree = "<group>"; };
 		B1DE853723602D36003C36E2 /* Languager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Languager.swift; sourceTree = "<group>"; };
 		B1DE8563236030E2003C36E2 /* Bundle+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Bundle+Extension.swift"; sourceTree = "<group>"; };
@@ -2813,6 +2815,7 @@
 				B14E0C0B2484F1F0008AF6AE /* O2WebsocketManager.swift */,
 				B15BE0BD2499BCEF008CD1DB /* O2RecordVoiceManager.swift */,
 				B15BE110249A6002008CD1DB /* AudioPlayerManager.swift */,
+				B1DB0842252314F400EE6673 /* SecurityCheckManager.swift */,
 			);
 			path = Manager;
 			sourceTree = "<group>";
@@ -5645,6 +5648,7 @@
 				B15F8129210EF15E00B81F35 /* OOCalendarEventViewController.swift in Sources */,
 				09E02E941F16319600579887 /* String+Haneke.swift in Sources */,
 				E40E24B420B7DA3C009F8BE7 /* OOMeetingModels.swift in Sources */,
+				B1DB0843252314F400EE6673 /* SecurityCheckManager.swift in Sources */,
 				E4B888F61D9D48F1002E1A46 /* Application.swift in Sources */,
 				E4C24C3F208D7EDE00E426B0 /* OOContactSearchViewModel.swift in Sources */,
 				E4B697FC2076520E0062F6E8 /* OOFileModels.swift in Sources */,

+ 77 - 72
o2ios/O2Platform/App/Login-绑定登录/c/LoginViewController.swift

@@ -68,84 +68,89 @@ class LoginViewController: UIViewController {
     }
 
     func startFlowForPromise() {
-        
-        if !O2IsConnect2Collect {
-            let unit = O2BindUnitModel()
-            if let infoPath = Bundle.main.path(forResource: "Info", ofType: "plist"), let dic = NSDictionary(contentsOfFile: infoPath) {
-                let o2Server = dic["o2 server"] as? NSDictionary
-                let id = o2Server?["id"] as? String
-                let name = o2Server?["name"] as? String
-                let centerHost = o2Server?["centerHost"] as? String
-                let centerContext = o2Server?["centerContext"] as? String
-                let centerPort = o2Server?["centerPort"] as? Int
-                let httpProtocol = o2Server?["httpProtocol"] as? String
-                DDLogDebug("连接服务器:\(String(describing: name)) , host:\(String(describing: centerHost)) , context:\(String(describing: centerContext)), port:\(centerPort ?? 0), portocal:\(String(describing: httpProtocol)) ")
-                if name == nil || centerHost == nil || centerContext == nil {
-                    self.showError(title:  "服务器配置信息异常!")
+        //越狱检查
+        if SecurityCheckManager.shared.isJailBroken() {
+            self.showSystemAlert(title: "提示", message: "当前运行环境已经越狱,本应用将不提供服务!") { (action) in
+                DDLogError("已经越狱的机器,不进入app!")
+            }
+        }else {
+            if !O2IsConnect2Collect {
+                let unit = O2BindUnitModel()
+                if let infoPath = Bundle.main.path(forResource: "Info", ofType: "plist"), let dic = NSDictionary(contentsOfFile: infoPath) {
+                    let o2Server = dic["o2 server"] as? NSDictionary
+                    let id = o2Server?["id"] as? String
+                    let name = o2Server?["name"] as? String
+                    let centerHost = o2Server?["centerHost"] as? String
+                    let centerContext = o2Server?["centerContext"] as? String
+                    let centerPort = o2Server?["centerPort"] as? Int
+                    let httpProtocol = o2Server?["httpProtocol"] as? String
+                    DDLogDebug("连接服务器:\(String(describing: name)) , host:\(String(describing: centerHost)) , context:\(String(describing: centerContext)), port:\(centerPort ?? 0), portocal:\(String(describing: httpProtocol)) ")
+                    if name == nil || centerHost == nil || centerContext == nil {
+                        self.showError(title:  "服务器配置信息异常!")
+                        return
+                    }
+                    unit.id = id
+                    unit.centerContext = centerContext
+                    unit.centerHost = centerHost
+                    unit.centerPort = centerPort
+                    unit.httpProtocol = httpProtocol
+                    unit.name = name
+                }else {
+                    self.showError(title:  "没有配置服务器信息!")
                     return
                 }
-                unit.id = id
-                unit.centerContext = centerContext
-                unit.centerHost = centerHost
-                unit.centerPort = centerPort
-                unit.httpProtocol = httpProtocol
-                unit.name = name
-            }else {
-                self.showError(title:  "没有配置服务器信息!")
-                return
-            }
-            
-            O2AuthSDK.shared.launchInner(unit: unit) { (state, msg) in
-                switch state {
-                case .bindError:
-                    //校验绑定结点信息错误
-                   self.showError(title: "未知错误!")
-                    break
-                case .loginError:
-                    self.forwardToSegue("loginSystemSegue")
-                    //自动登录出错
-                    break
-                case .unknownError:
-                    self.showError(title: msg ?? "未知错误!")
-                    break
-                case .success:
-                    //处理移动端应用
-                    self.viewModel._saveAppConfigToDb()
-                    //跳转到主页
-                    let destVC = O2MainController.genernateVC()
-                    destVC.selectedIndex = 2 // 首页选中 TODO 图标不亮。。。。。
-                    UIApplication.shared.keyWindow?.rootViewController = destVC
-                    UIApplication.shared.keyWindow?.makeKeyAndVisible()
+                
+                O2AuthSDK.shared.launchInner(unit: unit) { (state, msg) in
+                    switch state {
+                    case .bindError:
+                        //校验绑定结点信息错误
+                       self.showError(title: "未知错误!")
+                        break
+                    case .loginError:
+                        self.forwardToSegue("loginSystemSegue")
+                        //自动登录出错
+                        break
+                    case .unknownError:
+                        self.showError(title: msg ?? "未知错误!")
+                        break
+                    case .success:
+                        //处理移动端应用
+                        self.viewModel._saveAppConfigToDb()
+                        //跳转到主页
+                        let destVC = O2MainController.genernateVC()
+                        destVC.selectedIndex = 2 // 首页选中 TODO 图标不亮。。。。。
+                        UIApplication.shared.keyWindow?.rootViewController = destVC
+                        UIApplication.shared.keyWindow?.makeKeyAndVisible()
+                    }
                 }
-            }
-        }else {
-            //本地 -> 校验 -> 下载NodeAPI -> 下载configInfo -> 自动登录
-            O2AuthSDK.shared.launch { (state, msg) in
-                switch state {
-                case .bindError:
-                    //校验绑定结点信息错误
-                    self.forwardToSegue("bindPhoneSegue")
-                    break
-                case .loginError:
-                    self.forwardToSegue("loginSystemSegue")
-                    //自动登录出错
-                    break
-                case .unknownError:
-//                    self.showError(title: msg ?? "未知错误!")
-                    self.needReBind(msg ?? "未知错误!")
-                    break
-                case .success:
-                    //处理移动端应用
-                    self.viewModel._saveAppConfigToDb()
-                    //跳转到主页
-                    let destVC = O2MainController.genernateVC()
-                    destVC.selectedIndex = 2 // 首页选中 TODO 图标不亮。。。。。
-                    UIApplication.shared.keyWindow?.rootViewController = destVC
-                    UIApplication.shared.keyWindow?.makeKeyAndVisible()
+            }else {
+                //本地 -> 校验 -> 下载NodeAPI -> 下载configInfo -> 自动登录
+                O2AuthSDK.shared.launch { (state, msg) in
+                    switch state {
+                    case .bindError:
+                        //校验绑定结点信息错误
+                        self.forwardToSegue("bindPhoneSegue")
+                        break
+                    case .loginError:
+                        self.forwardToSegue("loginSystemSegue")
+                        //自动登录出错
+                        break
+                    case .unknownError:
+    //                    self.showError(title: msg ?? "未知错误!")
+                        self.needReBind(msg ?? "未知错误!")
+                        break
+                    case .success:
+                        //处理移动端应用
+                        self.viewModel._saveAppConfigToDb()
+                        //跳转到主页
+                        let destVC = O2MainController.genernateVC()
+                        destVC.selectedIndex = 2 // 首页选中 TODO 图标不亮。。。。。
+                        UIApplication.shared.keyWindow?.rootViewController = destVC
+                        UIApplication.shared.keyWindow?.makeKeyAndVisible()
+                    }
                 }
             }
         }
-        
     }
 
     

+ 25 - 0
o2ios/O2Platform/App/Login-绑定登录/c/OOLoginViewController.swift

@@ -48,11 +48,22 @@ class OOLoginViewController: OOBaseViewController {
     
     override func viewDidLoad() {
         super.viewDidLoad()
+        //监听截屏通知
+        NotificationCenter.default.addObserver(self, selector: #selector(screenshots),
+                                               name: UIApplication.userDidTakeScreenshotNotification,
+                                               object: nil)
+        NotificationCenter.default.addObserver(self, selector: #selector(didEnterBackground), name: UIApplication.didEnterBackgroundNotification, object: nil)
+                
         //delegate
         passwordTextField.buttonDelegate = self
         setupUI()
         
     }
+    
+    deinit {
+        NotificationCenter.default.removeObserver(self, name: UIApplication.userDidTakeScreenshotNotification, object: nil)
+    }
+    
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
         let bioAuthUser = AppConfigSettings.shared.bioAuthUser
@@ -71,6 +82,7 @@ class OOLoginViewController: OOBaseViewController {
         }
         
     }
+     
     
     @IBAction func unwindFromBioAuthLogin(_ unwindSegue: UIStoryboardSegue) {
         if unwindSegue.identifier == "goBack2Login" {
@@ -79,6 +91,19 @@ class OOLoginViewController: OOBaseViewController {
         }
     }
     
+    @objc private func didEnterBackground() {
+        DDLogDebug("进入后台.................")
+        self.userNameTextField.text = ""
+        self.passwordField.text = ""
+    }
+    
+    //截屏提示
+    @objc private func screenshots() {
+        self.showSystemAlert(title: "提示", message: "为了保护用户名密码安全,请不要截图!") { (action) in
+            DDLogDebug("确定提示。")
+        }
+    }
+    
     private func setupUI(){
         logoImageView.image = OOCustomImageManager.default.loadImage(.login_avatar)
         let backImageView = UIImageView(image: #imageLiteral(resourceName: "pic_beijing"))

+ 44 - 0
o2ios/O2Platform/Manager/SecurityCheckManager.swift

@@ -0,0 +1,44 @@
+//
+//  SecurityCheckManager.swift
+//  O2Platform
+//
+//  Created by FancyLou on 2020/9/29.
+//  Copyright © 2020 zoneland. All rights reserved.
+//
+
+import Foundation
+
+
+class SecurityCheckManager {
+    
+    static let shared : SecurityCheckManager = {
+        return SecurityCheckManager()
+    }()
+    
+    private init() {}
+    
+    ///判断是否存在越狱的软件
+    func isJailBroken() -> Bool {
+      //判断设备上是否安装了这些程序
+      let apps = ["/APPlications/Cydia.app",
+                  "/Library/MobileSubstrate/MobileSubstrate.dylib",
+                  "/bin/bash",
+                  "/usr/sbin/sshd",
+                  "/etc/apt",
+                  "/usr/bin/ssh",
+                  "/APPlications/limera1n.app",
+                  "/APPlications/greenpois0n.app",
+                  "/APPlications/blackra1n.app",
+                  "/APPlications/blacksn0w.app",
+                  "/APPlications/redsn0w.app",
+                  "/APPlications/Absinthe.app"]
+       for app in apps {
+           //通过文件管理器,判断在指定的目录下,是否在对应的应用程序。如果存在的话。就表示当前设备为越狱设备。
+           if FileManager.default.fileExists(atPath: app){
+               return true
+           }
+       }
+       return false
+   }
+    
+}

+ 1 - 2
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/service/CmsBatchOperationPersistService.java

@@ -72,8 +72,7 @@ public class CmsBatchOperationPersistService {
 		cmsBatchOperation.setErrorCount( 0 );
 		cmsBatchOperation.setIsRunning( false );
 		cmsBatchOperation.setOldInfo( oldInfo );
-		addOperation( cmsBatchOperation );	
-		return cmsBatchOperation;
+		return addOperation( cmsBatchOperation ) ;
 	}
 	
 	/**

+ 446 - 68
o2web/source/o2_core/o2.js

@@ -207,15 +207,58 @@
     this.o2.uuid = _uuid;
 
 
-    var _runCallback = function(callback, key, par){
-        if (typeOf(callback).toLowerCase() === 'function'){
-            if (key.toLowerCase()==="success") callback.apply(callback, par);
-        }else{
-            if (typeOf(callback).toLowerCase()==='object'){
+    var _runCallback = function(callback, key, par, bind, promise_cb){
+        var b = bind || callback;
+        if (!key) key = "success";
+
+        var cb;
+        if (callback){
+            var type = o2.typeOf(callback).toLowerCase();
+            if (key.toLowerCase()==="success" && type==="function"){
+                cb = callback;
+            }else{
                 var name = ("on-"+key).camelCase();
-                if (callback[name]) callback[name].apply(callback, par);
+                cb = (callback[name]) ? callback[name] : ((callback[key]) ? callback[key] : null);
             }
         }
+        if (cb) return (promise_cb) ? promise_cb(cb.apply(b, par)) : cb.apply(b, par) ;
+        return (promise_cb) ? promise_cb.apply(b, par) : null;
+
+        // if (key.toLowerCase()==="success" && (type==="function" || type==="o2_async_function")){
+        //     (promise_cb) ? promise_cb(callback.apply(b, par)) : callback.apply(b, par) ;
+        // }else{
+        //     if (type==="function" || type==="object" || type==="o2_async_function"){
+        //         var name = ("on-"+key).camelCase();
+        //         if (callback[name]){
+        //             (promise_cb) ? promise_cb(callback[name].apply(b, par)) : callback[name].apply(b, par);
+        //         }else{
+        //             if (callback[key]) (promise_cb) ? promise_cb(callback[key].apply(b, par)) : callback[key].apply(b, par);
+        //         }
+        //     }
+        // }
+
+
+        // if (typeOf(callback).toLowerCase() === 'function'){
+        //     if (key.toLowerCase()==="success"){
+        //         callback.apply(b, par);
+        //     }else{
+        //         if (callback[key]){
+        //             callback[key].apply(b, par);
+        //         }else{
+        //             var name = ("on-"+key).camelCase();
+        //             if (callback[name]) callback[name].apply(b, par);
+        //         }
+        //     }
+        // }else{
+        //     if (typeOf(callback).toLowerCase()==='object'){
+        //         if (callback[key]){
+        //             callback[key].apply(b, par);
+        //         }else{
+        //             var name = ("on-"+key).camelCase();
+        //             if (callback[name]) callback[name].apply(b, par);
+        //         }
+        //     }
+        // }
     };
     this.o2.runCallback = _runCallback;
 
@@ -978,11 +1021,13 @@
 (function (){
     var _Class = {
         create: function(options) {
-            var newClass = function() {
-                this.initialize.apply(this, arguments);
-            };
-            _copyPrototype(newClass, options);
-            return newClass;
+            // var newClass = function() {
+            //     this.initialize.apply(this, arguments);
+            // };
+            return _copyPrototype(function() {
+                return this.initialize.apply(this, arguments) || this;
+            }, options);
+            //return newClass;
         }
     };
     var _copyPrototype = function (currentNS, props){
@@ -1271,6 +1316,71 @@
         // /jaxrs\/authentication/ig
         // /jaxrs\/statement\/.*\/execute\/page\/.*\/size\/.*/ig
     ];
+    // _restful_bak = function(method, address, data, callback, async, withCredentials, cache){
+    //     var loadAsync = (async !== false);
+    //     var credentials = (withCredentials !== false);
+    //     address = (address.indexOf("?")!==-1) ? address+"&v="+o2.version.v : address+"?v="+o2.version.v;
+    //     //var noCache = cache===false;
+    //     var noCache = !cache;
+    //
+    //
+    //     //if (Browser.name == "ie")
+    //     if (_cacheUrls.length){
+    //         for (var i=0; i<_cacheUrls.length; i++){
+    //             _cacheUrls[i].lastIndex = 0;
+    //             if (_cacheUrls[i].test(address)){
+    //                 noCache = false;
+    //                 break;
+    //             }
+    //         }
+    //     }
+    //     //var noCache = false;
+    //     var res = new Request.JSON({
+    //         url: o2.filterUrl(address),
+    //         secure: false,
+    //         method: method,
+    //         emulation: false,
+    //         noCache: noCache,
+    //         async: loadAsync,
+    //         withCredentials: credentials,
+    //         onSuccess: function(responseJSON, responseText){
+    //             // var xToken = this.getHeader("authorization");
+    //             // if (!xToken) xToken = this.getHeader("x-token");
+    //             var xToken = this.getHeader("x-token");
+    //             if (xToken){
+    //                 if (window.layout){
+    //                     if (!layout.session) layout.session = {};
+    //                     layout.session.token = xToken;
+    //                 }
+    //             }
+    //             o2.runCallback(callback, "success", [responseJSON]);
+    //         },
+    //         onFailure: function(xhr){
+    //             o2.runCallback(callback, "requestFailure", [xhr]);
+    //         }.bind(this),
+    //         onError: function(text, error){
+    //             o2.runCallback(callback, "error", [text, error]);
+    //         }.bind(this)
+    //     });
+    //
+    //     res.setHeader("Content-Type", "application/json; charset=utf-8");
+    //     res.setHeader("Accept", "text/html,application/json,*/*");
+    //     if (window.layout) {
+    //         if (layout["debugger"]){
+    //             res.setHeader("x-debugger", "true");
+    //         }
+    //         if (layout.session && layout.session.user){
+    //             if (layout.session.user.token) {
+    //                 res.setHeader("x-token", layout.session.user.token);
+    //                 res.setHeader("authorization", layout.session.user.token);
+    //             }
+    //         }
+    //     }
+    //     //Content-Type	application/x-www-form-urlencoded; charset=utf-8
+    //     res.send(data);
+    //     return res;
+    // };
+
     _restful = function(method, address, data, callback, async, withCredentials, cache){
         var loadAsync = (async !== false);
         var credentials = (withCredentials !== false);
@@ -1278,7 +1388,6 @@
         //var noCache = cache===false;
         var noCache = !cache;
 
-
         //if (Browser.name == "ie")
         if (_cacheUrls.length){
             for (var i=0; i<_cacheUrls.length; i++){
@@ -1289,51 +1398,101 @@
                 }
             }
         }
+
+        var useWebWorker = (window.layout && layout.config && layout.config.useWebWorker);
         //var noCache = false;
-        var res = new Request.JSON({
-            url: o2.filterUrl(address),
-            secure: false,
-            method: method,
-            emulation: false,
-            noCache: noCache,
-            async: loadAsync,
-            withCredentials: credentials,
-            onSuccess: function(responseJSON, responseText){
-                // var xToken = this.getHeader("authorization");
-                // if (!xToken) xToken = this.getHeader("x-token");
-                var xToken = this.getHeader("x-token");
-                if (xToken){
-                    if (window.layout){
-                        if (!layout.session) layout.session = {};
-                        layout.session.token = xToken;
+        if (!loadAsync || !useWebWorker){
+            debugger;
+            var res;
+            var p = new Promise(function(s,f){
+                res = new Request.JSON({
+                    url: o2.filterUrl(address),
+                    secure: false,
+                    method: method,
+                    emulation: false,
+                    noCache: noCache,
+                    async: loadAsync,
+                    withCredentials: credentials,
+                    onSuccess: function(responseJSON, responseText){
+                        // var xToken = this.getHeader("authorization");
+                        // if (!xToken) xToken = this.getHeader("x-token");
+                        var xToken = this.getHeader("x-token");
+                        if (xToken){
+                            if (window.layout){
+                                if (!layout.session) layout.session = {};
+                                layout.session.token = xToken;
+                            }
+                        }
+                        return o2.runCallback(callback, "success", [responseJSON],null, s);
+                    },
+                    onFailure: function(xhr){
+                        return o2.runCallback(callback, "requestFailure", [xhr], null, f);
+                    }.bind(this),
+                    onError: function(text, error){
+                        return o2.runCallback(callback, "error", [text, error], null, f);
+                    }.bind(this)
+                });
+
+                res.setHeader("Content-Type", "application/json; charset=utf-8");
+                res.setHeader("Accept", "text/html,application/json,*/*");
+                if (window.layout) {
+                    if (layout["debugger"]){
+                        res.setHeader("x-debugger", "true");
+                    }
+                    if (layout.session && layout.session.user){
+                        if (layout.session.user.token) {
+                            res.setHeader("x-token", layout.session.user.token);
+                            res.setHeader("authorization", layout.session.user.token);
+                        }
                     }
                 }
-                o2.runCallback(callback, "success", [responseJSON]);
-            },
-            onFailure: function(xhr){
-                o2.runCallback(callback, "requestFailure", [xhr]);
-            }.bind(this),
-            onError: function(text, error){
-                o2.runCallback(callback, "error", [text, error]);
-            }.bind(this)
-        });
+                //Content-Type	application/x-www-form-urlencoded; charset=utf-8
+                res.send(data);
+            }.bind(this));
 
-        res.setHeader("Content-Type", "application/json; charset=utf-8");
-        res.setHeader("Accept", "text/html,application/json,*/*");
-        if (window.layout) {
-            if (layout["debugger"]){
-                res.setHeader("x-debugger", "true");
-            }
-            if (layout.session && layout.session.user){
-                if (layout.session.user.token) {
-                    res.setHeader("x-token", layout.session.user.token);
-                    res.setHeader("authorization", layout.session.user.token);
+            //var oReturn = (callback.success && callback.success.isAG) ? callback.success : callback;
+            var oReturn = p;
+            oReturn.res = res;
+            return oReturn;
+        }else{
+            var workerMessage = {
+                method: method,
+                noCache: noCache,
+                loadAsync: loadAsync,
+                credentials: credentials,
+                address: o2.filterUrl(address),
+                body: data,
+                debug: (window.layout && layout["debugger"]),
+                token: (window.layout && layout.session && layout.session.user) ? layout.session.user.token : ""
+            }
+            var actionWorker = new Worker("../o2_core/o2/actionWorker.js");
+            var p = new Promise(function(s,f){
+                actionWorker.onmessage = function(e) {
+                    result = e.data;
+                    if (result.type==="done"){
+                        var xToken = result.data.xToken;
+                        if (xToken){
+                            if (window.layout){
+                                if (!layout.session) layout.session = {};
+                                layout.session.token = xToken;
+                            }
+                        }
+                        o2.runCallback(callback, "success", [result.data], null, s);
+                    }else{
+                        o2.runCallback(callback, "failure", [result.data], null, f);
+                    }
+                    actionWorker.terminate();
                 }
-            }
+                actionWorker.postMessage(workerMessage);
+            }.bind(this));
+
+            //var oReturn = (callback.success && callback.success.addResolve) ? callback.success : callback;
+            var oReturn = p;
+            oReturn.actionWorker = actionWorker;
+            return oReturn;
+            //return callback;
         }
-        //Content-Type	application/x-www-form-urlencoded; charset=utf-8
-        res.send(data);
-        return res;
+        //return res;
     };
 
     var _release = function(o){
@@ -1480,23 +1639,242 @@
         }
         return arr;
     }
-    Date.implement({
-        // "getFromServer": function(){
-        //     var d;
-        //     o2.Actions.get("x_program_center").echo(function(json){
-        //         d = Date.parse(json.data.serverTime);
-        //     }, null, false);
-        //     return d;
-        // }
-        "getFromServer": function(callback){
-            var async = !!callback;
-            var d;
-            var r = o2.Actions.get("x_program_center").echo(function(json){
-                d = Date.parse(json.data.serverTime);
-                if (callback) callback(d);
-            }, null, async);
-            return d || r;
+    // Date.implement({
+    //     "getFromServer": function(callback){
+    //         if (callback){
+    //             o2.Actions.get("x_program_center").echo(function(json){
+    //                 d = Date.parse(json.data.serverTime);
+    //                 callback(d);
+    //             });
+    //         }else{
+    //             var d;
+    //             o2.Actions.get("x_program_center").echo(function(json){
+    //                 d = Date.parse(json.data.serverTime);
+    //             }, null, false);
+    //             return d;
+    //         }
+    //     }
+    // });
+    Date.getFromServer = function(async){
+        var d;
+        var cb = ((async && o2.typeOf(async)=="function") ? async : null) || function(json){
+        //var cb = function(json){
+            d = Date.parse(json.data.serverTime);
+            return d;
+        };
+
+        var promise = o2.Actions.get("x_program_center").echo(cb, null, !!async);
+
+        return (!!async) ? promise : d;
+
+            // if (callback){
+            //     o2.Actions.get("x_program_center").echo(function(json){
+            //         d = Date.parse(json.data.serverTime);
+            //         o2.runCallback(callback, "success", [d]);
+            //     });
+            // }else{
+            //     var d;
+            //     o2.Actions.get("x_program_center").echo(function(json){
+            //         d = Date.parse(json.data.serverTime);
+            //     }, null, false);
+            //     return d;
+            // }
+    };
+
+    // Object.appendChain = function(oChain, oProto) {
+    //     if (arguments.length < 2) {
+    //         throw new TypeError('Object.appendChain - Not enough arguments');
+    //     }
+    //     if (typeof oProto === 'number' || typeof oProto === 'boolean') {
+    //         throw new TypeError('second argument to Object.appendChain must be an object or a string');
+    //     }
+    //
+    //     var oNewProto = oProto,
+    //         oReturn,
+    //         o2nd,
+    //         oLast;
+    //
+    //     oReturn = o2nd = oLast = oChain instanceof this ? oChain : new oChain.constructor(oChain);
+    //
+    //     for (var o1st = this.getPrototypeOf(o2nd);
+    //          o1st !== Object.prototype && o1st !== Function.prototype;
+    //          o1st = this.getPrototypeOf(o2nd)
+    //     ) {
+    //         o2nd = o1st;
+    //     }
+    //
+    //     if (oProto.constructor === String) {
+    //         oNewProto = Function.prototype;
+    //         oReturn = Function.apply(null, Array.prototype.slice.call(arguments, 1));
+    //         oReturn = oReturn.bind(oLast);
+    //         this.setPrototypeOf(oReturn, oLast);
+    //     }
+    //
+    //     this.setPrototypeOf(o2nd, oNewProto);
+    //     return oReturn;
+    // }
+
+    // user promise
+    // var _AsyncGeneratorPrototype = _Class.create({
+    //     initialize: function(resolve, reject, name){
+    //         this.isAG = true;
+    //         this.name = name || "";
+    //         this._createSuccess();
+    //         this._createFailure();
+    //         if (resolve) this.success.resolve = resolve;
+    //         if (reject) this.failure.reject = reject;
+    //     },
+    //     //$family: function(){ return "o2_async_function"; },
+    //     _createSuccess: function(){
+    //         var _self = this;
+    //         this.success = function(){
+    //             var result;
+    //             if (_self.success.resolve) result = _self.success.resolve.apply(this, arguments);
+    //             if (_self.success.resolveList){
+    //                 _self.success.resolveList.each(function(r){
+    //                     result = r(result, arguments) || result;
+    //                 });
+    //             }
+    //             _self.isSuccess = true;
+    //             _self.result = result;
+    //             _self.arg = arguments;
+    //             return result;
+    //         }
+    //     },
+    //     _createFailure: function(){
+    //         var _self = this;
+    //         this.failure = function(){
+    //             var result;
+    //             if (_self.failure.reject) result = _self.failure.reject.apply(this, arguments);
+    //             if (_self.failure.rejectList){
+    //                 _self.failure.rejectList.each(function(r){
+    //                     result = r(result, arguments) || result;
+    //                 });
+    //             }
+    //             _self.isFailure = true;
+    //             _self.result = result;
+    //             _self.arg = arguments;
+    //             return result;
+    //         }
+    //     },
+    //     setResolve: function(resolve){
+    //         if (!this.success) this._createSuccess();
+    //         this.success.resolve = resolve;
+    //         return this;
+    //     },
+    //     setReject: function(reject){
+    //         if (!this.failure) this._createFailure();
+    //         this.failure.reject = reject;
+    //         return this;
+    //     },
+    //     addResolve: function(resolve){
+    //         if (!this.success) this._createSuccess();
+    //         if (resolve){
+    //             if (this.isSuccess){
+    //                 this.result = resolve(this.result, this.arg);
+    //             }else{
+    //                 if (!this.success.resolve){
+    //                     this.success.resolve = resolve;
+    //                 }else{
+    //                     if (!this.success.resolveList) this.success.resolveList = [];
+    //                     this.success.resolveList.push(resolve);
+    //                 }
+    //             }
+    //         }
+    //         return this;
+    //     },
+    //     addReject: function(reject){
+    //         if (!this.failure) this._createFailure();
+    //         if (reject){
+    //             if (this.isFailure){
+    //                 this.result = reject(this.result, this.arg);
+    //             }else{
+    //                 if (!this.failure.reject){
+    //                     this.failure.reject = reject;
+    //                 }else{
+    //                     if (!this.failure.rejectList) this.failure.rejectList = [];
+    //                     this.failure.rejectList.push(reject);
+    //                 }
+    //             }
+    //         }
+    //         return this;
+    //     },
+    //     then: function(resolve){
+    //         return this.addResolve(resolve);
+    //     },
+    //     "catch": function(reject){
+    //         return this.addReject(reject);
+    //     },
+    // });
+    // var _AsyncGenerator = function(resolve, reject, name){
+    //     var asyncGeneratorPrototype = new _AsyncGeneratorPrototype(resolve, reject, name);
+    //     return Object.appendChain(asyncGeneratorPrototype, "if (this.success) this.success.apply(this, arguments);");
+    // }
+    //
+    // //@todo
+    // _AsyncGenerator.all = function(arr){
+    //     var result = [];
+    //     var ag = function (){
+    //         return result;
+    //     }.ag();
+    //
+    //     if (o2.typeOf(arr) !== "array") arr = [arr];
+    //
+    //     var count  = arr.length;
+    //     var check = function(){
+    //         count--;
+    //         if (count<=0)ag();
+    //     }
+    //
+    //     //window.setTimeout(function(){
+    //         arr.forEach(function(a){
+    //             if (typeOf(a)=="array"){
+    //                 o2.AG.all(a).then(function(v){
+    //                     result = result.concat(v);
+    //                     check();
+    //                 });
+    //             }else{
+    //                 if (a && a.isAG){
+    //                     a.then(function(v){
+    //                         o2.AG.all(v).then(function(r){
+    //                             result = result.concat(r);
+    //                             check();
+    //                         });
+    //                     });
+    //                 }else{
+    //                     result.push(a);
+    //                     check();
+    //                 }
+    //             }
+    //         });
+    //     //}, 0);
+    //     return ag;
+    // }
+    //
+    // o2.AsyncGenerator = o2.AG = _AsyncGenerator;
+    //
+    // Function.prototype.ag = function(){
+    //     return o2.AG(this);
+    // };
+
+    var _promiseAll = function(p){
+        if (o2.typeOf(p)=="array"){
+            if (p.some(function(e){ return (o2.typeOf(e.then)=="function") })){
+                return Promise.all(p);
+            }else{
+                return { "then": function(s){ s(p); return this;} };
+            }
+        }else{
+            if (o2.typeOf(p.then)=="function"){
+                return Promise.resolve(p);
+            }else{
+                return { "then": function(s){ s(p); return this;} };
+            }
         }
+        // var method = (o2.typeOf(p)=="array") ? "all" : "resolve";
+        // return Promise[method](p);
+    }
+    o2.promiseAll = _promiseAll;
 
     });
 })();
@@ -1505,7 +1883,7 @@ o2.core = true;
 
 /** ***** BEGIN LICENSE BLOCK *****
  * |------------------------------------------------------------------------------|
- * | O2OA 活力办公 创意无限    o2.more.js                                            |
+ * | O2OA 活力办公 创意无限    o2.more.js                                          |
  * |------------------------------------------------------------------------------|
  * | Distributed under the AGPL license:                                          |
  * |------------------------------------------------------------------------------|

+ 90 - 0
o2web/source/o2_core/o2/actionWorker.js

@@ -0,0 +1,90 @@
+function V(httpRequest) {
+    if (httpRequest.readyState === XMLHttpRequest.DONE) {
+        if (httpRequest.status === 200) {
+            alert(httpRequest.responseText);
+        } else {
+            alert('There was a problem with the request.');
+        }
+    }
+}
+
+(function(){
+    var _worker = this;
+    var _action = {
+        _checkRequest: function(){
+            if (this.request.readyState === XMLHttpRequest.DONE) {
+                if (this.request.status === 200) {
+                    this._doneRequest();
+                } else {
+                    this._errorRequest();
+                }
+            }
+        },
+        _createRequest: function(){
+            this.request = new XMLHttpRequest();
+            this.request.addEventListener("readystatechange", this._checkRequest.bind(this));
+        },
+        sendRequest: function(data){
+            if (!this.request) this._createRequest();
+            var method = data.method;
+            var noCache = !!data.noCache;
+            var async = !!data.loadAsync;
+            var withCredentials = !!data.credentials;
+            var url = data.address;
+            var body = data.body;
+            var debug = data.debug;
+            var token = data.token;
+
+            if (noCache) url = url+(((url.indexOf("?")!==-1) ? "&" : "?")+(new Date()).getTime());
+
+            this.request.open(method, url, async);
+
+            this.request.withCredentials = withCredentials;
+            this.request.setRequestHeader("Content-Type", "application/json; charset=utf-8");
+            this.request.setRequestHeader("Accept", "text/html,application/json,*/*");
+            if (debug) this.request.setRequestHeader("x-debugger", "true");
+            if (token){
+                this.request.setRequestHeader("x-token", token);
+                this.request.setRequestHeader("authorization", token);
+            }
+
+            this.request.send(body);
+        },
+
+        _doneRequest: function(){
+            var json = JSON.parse(this.request.responseText);
+            var xToken = this.request.getResponseHeader("x-token");
+            if (xToken){
+                json.xToken = xToken;
+            }
+            _worker.postMessage({"type": "done", "data": json});
+            _worker.close();
+        },
+        _errorRequest: function(){
+            _worker.postMessage({"type":"error", "data": {"status":  this.request.status, "statusText":  this.request.statusText, "responseText":this.request.responseText}});
+            _worker.close();
+        }
+    };
+
+    this.action = _action;
+})();
+
+onmessage = function(e) {
+    debugger;
+    this.action.sendRequest(e.data);
+    //
+    //
+    // console.log('Worker: Message received from main script');
+    // var options = e.data;
+    //
+    // httpRequest = new XMLHttpRequest();
+    //
+    //
+    // if (isNaN(result)) {
+    //     postMessage('Please write two numbers');
+    // } else {
+    //     const workerResult = 'Result: ' + result;
+    //     console.log('Worker: Posting message back to main script');
+    //     postMessage(workerResult);
+    // }
+}

+ 19 - 1
o2web/source/o2_core/o2/widget/chart/Line.js

@@ -57,6 +57,24 @@ o2.widget.chart.Line = new Class({
         }.bind(this));
         //this.transition();
     },
+    loadScales: function(){
+        this.xScale = d3.scaleBand().domain(this.data.map(function(d){ return d[this.item];}.bind(this)))
+            .rangeRound(this.getXScaleRange()).paddingOuter(0.3).paddingInner(0.3);
+
+        this.barsData = [];
+        this.bars.each(function(bar, i){
+            this.barsData.push(
+                this.data.map(function(d, idx) {
+                    return {"name": d[this.item], "data": ((typeOf(bar.data)==="function") ? bar.data(d, i) : d[bar.data]), "text": ((typeOf(bar.text)==="function") ? bar.text(d, i) : d[bar.text])}
+                }.bind(this))
+            );
+        }.bind(this));
+        var max = d3.max(this.barsData, function(d){ return d3.max(d, function(d){return d.data}); });
+        var min = d3.min(this.barsData, function(d){ return d3.min(d, function(d){return d.data}); });
+
+        this.yScale = d3.scaleLinear().domain([min*0.9, max*1.1])
+            .range(this.getYScaleRange());
+    },
     setEvents: function(){
         var rects = this.group.selectAll("circle");
         var texts = this.group.selectAll("text");
@@ -129,4 +147,4 @@ o2.widget.chart.Line = new Class({
             // .attr("y", function(d) { return this.yScale(d.data); }.bind(this));
             .attr("d", function(d) { return lines(d) }.bind(this));
     }
-});
+});

+ 37 - 4
o2web/source/o2_core/o2/xDesktop/Actions/RestActions.js

@@ -102,6 +102,32 @@ MWF.xDesktop.Actions.RestActions = new Class({
 
             var async = (option.async===false) ? false : true;
 
+            // if (!option.success) option.success = function(v){return v;}.ag();
+            // if (option.success && !option.success.isAG) option.success = option.success.ag();
+            //
+            // if (option.failure && option.failure.failure) option.failure = option.failure.failure;
+            // if (option.failure) {
+            //     option.success.catch(option.failure);
+            //     option.failure.owner = option.success;
+            // }
+            // if (!option.failure && option.success && option.success.failure){
+            //     option.failure = option.success.failure;
+            //     option.failure.owner = option.success;
+            // }
+
+            // if (option.failure && option.failure.failure) option.failure = option.failure.failure;
+            // if (!option.failure && option.success && option.success.failure){
+            //     option.failure = option.success.failure;
+            //     option.failure.owner = option.success;
+            // }
+            // if (!option.success){
+            //     option.success = function(v){return v;}.ag();
+            //     if (option.failure) {
+            //         option.success.catch(option.failure);
+            //         option.failure.owner = option.success;
+            //     }
+            // }
+
             var callback = new MWF.xDesktop.Actions.RestActions.Callback(option.success, option.failure);
             if (action.enctype && (action.enctype.toLowerCase()=="formdata")){
                 res = this.invokeFormData(method, uri, option.data, option.file, callback, async, progress);
@@ -565,16 +591,16 @@ MWF.xDesktop.Actions.RestActions.Callback = new Class({
 			switch(responseJSON.type) {
 			   case "success":
 				   if (this.appendSuccess) this.appendSuccess(responseJSON);
-				   if (this.success) this.success(responseJSON, responseText);
+				   if (this.success) return this.success(responseJSON, responseText);
 			       break;
 			   case "warn":
 				   MWF.xDesktop.notice("info", {x: "right", y:"top"}, responseJSON.errorMessage.join("\n"));
 				   
 				   if (this.appendSuccess) this.appendSuccess(responseJSON);
-				   if (this.success) this.success(responseJSON);
+				   if (this.success) return this.success(responseJSON);
 			       break;
 			   case "error":
-				   this.doError(null, responseText, responseJSON.message);
+				   return this.doError(null, responseText, responseJSON.message);
 				   break;
 			}
 		}else{
@@ -592,7 +618,14 @@ MWF.xDesktop.Actions.RestActions.Callback = new Class({
 	},
 	doError: function(xhr, text, error){
 		if (this.appendFailure) this.appendFailure(xhr, text, error);
-		if (this.failure) this.failure(xhr, text, error);
+		if (this.failure && this.failure.owner){
+            if (this.failure.reject || (this.failure.rejectList && this.failure.rejectList.length)){
+                return this.failure(xhr, text, error);
+            }
+            this.failure = null;
+        }else{
+            if (this.failure) return this.failure(xhr, text, error);
+        }
 		if (!this.failure && !this.appendFailure){
             if (xhr.status!=0){
                 var errorText = error;

+ 9 - 3
o2web/source/o2_core/o2/xDesktop/Common.js

@@ -492,14 +492,18 @@ MWF.xDesktop.getServiceAddressConfigArray = function(config, callback, error) {
     config.center.each(function(center){
         requests.push(
             MWF.xDesktop.getServiceAddressConfigObject(center, function(serviceAddressList, center){
+                debugger;
                 requests.each(function(res){
-                    if (res) if (res.isRunning && res.isRunning()){res.cancel();}
+                    if (res && res.res) if (res.res.isRunning()){res.res.cancel();}
+                    if (res && res.actionWorker) res.actionWorker.terminate();
                 });
                 if (callback) callback(serviceAddressList, center);
             }.bind(this), function(){
+                debugger;
                 if (requests.length){
                     for (var i=0; i<requests.length; i++){
-                        if (requests[i].isRunning && requests[i].isRunning()) return "";
+                        if (requests[i].res) if (requests[i].res.isRunning()) return "";
+                        if (requests[i].actionWorker && requests[i].actionWorker.terminate) return "";
                     }
                 }
                 if (error) error();
@@ -610,7 +614,9 @@ MWF.org = {
                 "name": data.name,
                 "distinguishedName": data.distinguishedName,
                 "unitLevelName" : data.unitLevelName,
-                "person": data.person
+                "person": data.person,
+                "unit": data.unit,
+                "unitName": data.unitName,
             };
             if( data.ignoreEmpower )rData.ignoreEmpower = true;
             if( data.ignoredEmpower )rData.ignoredEmpower = true;

+ 1 - 1
o2web/source/o2_core/o2/xScript/Actions/UnitActions.js

@@ -3,7 +3,7 @@ MWF.xScript.Actions = MWF.xScript.Actions || {};
 MWF.require("MWF.xDesktop.Actions.RestActions", null, false);
 var invoke = function(serviceName){
     return function(data, success, failure, async){
-        this.action.invoke({"name": serviceName,"data": data, "async": async, "success": success,"failure": failure});
+        return this.action.invoke({"name": serviceName,"data": data, "async": async, "success": success,"failure": failure});
     }
 };
 

Разница между файлами не показана из-за своего большого размера
+ 574 - 182
o2web/source/o2_core/o2/xScript/CMSEnvironment.js


Разница между файлами не показана из-за своего большого размера
+ 568 - 176
o2web/source/o2_core/o2/xScript/Environment.js


Разница между файлами не показана из-за своего большого размера
+ 645 - 253
o2web/source/o2_core/o2/xScript/PageEnvironment.js


Разница между файлами не показана из-за своего большого размера
+ 650 - 250
o2web/source/o2_core/o2/xScript/ViewEnvironment.js


Разница между файлами не показана из-за своего большого размера
+ 2 - 0
o2web/source/o2_lib/polyfill/polyfill.js


+ 9 - 8
o2web/source/x_component_process_FormDesigner/Module/Checkbox/checkbox.html

@@ -13,13 +13,6 @@
 		    <td class="editTableTitle">描述:</td>
 		    <td class="editTableValue"><input type="text" name="description" value="text{$.description}" class="editTableInput"/></td>
 		  </tr>
-		  <tr>
-		    <td class="editTableTitle">可选值:</td>
-		    <td class="editTableValue">
-		    	<input class="editTableRadio" onclick="if (this.checked){ $('text{$.pid}selectEditItemValues').setStyle('display', 'block'); $('text{$.pid}selectEditItemScript').setStyle('display', 'none')}" name="itemType" text{($.itemType=='values')?'checked':''} type="radio" value="values"/>固定值
-		    	<input class="editTableRadio" onclick="if (this.checked){ $('text{$.pid}selectEditItemScript').setStyle('display', 'block'); $('text{$.pid}selectEditItemValues').setStyle('display', 'none')}" name="itemType" text{($.itemType=='script')?'checked':''} type="radio" value="script"/>脚本
-		    </td>
-		  </tr>
             <tr>
                 <td class="editTableTitle">是否只读:</td>
                 <td class="editTableValue">
@@ -27,6 +20,14 @@
                     <input type="radio" name="isReadonly" value="false" text{(!$.isReadonly)?'checked':''}/>否
                 </td>
             </tr>
+		  <tr>
+		    <td class="editTableTitle">可选值:</td>
+		    <td class="editTableValue">
+		    	<input class="editTableRadio" onclick="if (this.checked){ $('text{$.pid}selectEditItemValues').setStyle('display', 'block'); $('text{$.pid}selectEditItemScript').setStyle('display', 'none')}" name="itemType" text{($.itemType=='values')?'checked':''} type="radio" value="values"/>固定值
+		    	<input class="editTableRadio" onclick="if (this.checked){ $('text{$.pid}selectEditItemScript').setStyle('display', 'block'); $('text{$.pid}selectEditItemValues').setStyle('display', 'none')}" name="itemType" text{($.itemType=='script')?'checked':''} type="radio" value="script"/>脚本
+		    </td>
+		  </tr>
+
 		</table>
 		
 		<div id="text{$.pid}selectEditItemValues" style="display: text{($.itemType=='values')?'block':'none'}" class="MWFArraylist" name="itemValues" title="可选值"></div>
@@ -90,4 +91,4 @@
     <div title="JSON"  class="MWFTab">
         <div class="MWFJSONArea" style="font-family: Verdana, Geneva, sans-serif; font-size:14px"></div>
     </div>
-</div>
+</div>

+ 9 - 13
o2web/source/x_component_process_FormDesigner/Module/Org/org.html

@@ -41,6 +41,13 @@
                     <input type="radio" name="isInput" value="false" text{(!$.isInput)?'checked':''}/>否
                 </td>
             </tr>
+            <tr>
+                <td class="editTableTitle">数据保存:</td>
+                <td class="editTableValue">
+                    <input type="radio" name="storeRange" value="full" text{($.section=='full')?'checked':''}/>完整
+                    <input type="radio" name="storeRange" value="simple" text{($.section!=='full')?'checked':''}/>精简
+                </td>
+            </tr>
             <tr>
                 <td class="editTableTitle">分隔符:</td>
                 <td class="editTableValue">
@@ -448,18 +455,7 @@
             <div style="height: 24px; line-height:24px; background-color: #EEE; padding: 0px 6px; border-top: 1px solid #999">通过编写脚本排除组织、身份、个人和群组的选择范围</div>
             <div class="MWFFormulaArea" name="exclude" title="脚本 (S)"></div>
         </div>
-        <div>
-            <div style="text-align: center; height: 24px; background-color: #F1F1F1; line-height: 24px; border-bottom: 1px solid #cccccc; border-top: 1px solid #cccccc;font-weight: bold;">数据保存</div>
-            <table width="100%" border="0" cellpadding="5" cellspacing="0" class="editTable">
-                <tr>
-                    <td class="editTableTitle">数据保存:</td>
-                    <td class="editTableValue">
-                        <input type="radio" name="storeRange" value="full" text{($.section!='simple')?'checked':''}/>完整
-                        <input type="radio" name="storeRange" value="simple" text{($.section=='simple')?'checked':''}/>精简
-                    </td>
-                </tr>
-            </table>
-        </div>
+
     </div>
     <div title="事件"  class="MWFTab">
         <div class="MWFEventsArea" name="events"></div>
@@ -499,4 +495,4 @@
     <div title="JSON"  class="MWFTab">
         <div class="MWFJSONArea" style="font-family: Verdana, Geneva, sans-serif; font-size:14px"></div>
     </div>
-</div>
+</div>

+ 9 - 8
o2web/source/x_component_process_FormDesigner/Module/Radio/radio.html

@@ -13,13 +13,6 @@
 		    <td class="editTableTitle">描述:</td>
 		    <td class="editTableValue"><input type="text" name="description" value="text{$.description}" class="editTableInput"/></td>
 		  </tr>
-		  <tr>
-		    <td class="editTableTitle">可选值:</td>
-		    <td class="editTableValue">
-		    	<input class="editTableRadio" onclick="if (this.checked){ $('text{$.pid}selectEditItemValues').setStyle('display', 'block'); $('text{$.pid}selectEditItemScript').setStyle('display', 'none')}" name="itemType" text{($.itemType=='values')?'checked':''} type="radio" value="values"/>固定值
-		    	<input class="editTableRadio" onclick="if (this.checked){ $('text{$.pid}selectEditItemScript').setStyle('display', 'block'); $('text{$.pid}selectEditItemValues').setStyle('display', 'none')}" name="itemType" text{($.itemType=='script')?'checked':''} type="radio" value="script"/>脚本
-		    </td>
-		  </tr>
             <tr>
                 <td class="editTableTitle">是否只读:</td>
                 <td class="editTableValue">
@@ -27,6 +20,14 @@
                     <input type="radio" name="isReadonly" value="false" text{(!$.isReadonly)?'checked':''}/>否
                 </td>
             </tr>
+		  <tr>
+		    <td class="editTableTitle">可选值:</td>
+		    <td class="editTableValue">
+		    	<input class="editTableRadio" onclick="if (this.checked){ $('text{$.pid}selectEditItemValues').setStyle('display', 'block'); $('text{$.pid}selectEditItemScript').setStyle('display', 'none')}" name="itemType" text{($.itemType=='values')?'checked':''} type="radio" value="values"/>固定值
+		    	<input class="editTableRadio" onclick="if (this.checked){ $('text{$.pid}selectEditItemScript').setStyle('display', 'block'); $('text{$.pid}selectEditItemValues').setStyle('display', 'none')}" name="itemType" text{($.itemType=='script')?'checked':''} type="radio" value="script"/>脚本
+		    </td>
+		  </tr>
+
 		</table>
 		
 		<div id="text{$.pid}selectEditItemValues" style="display: text{($.itemType=='values')?'block':'none'}" class="MWFArraylist" name="itemValues" title="可选值"></div>
@@ -90,4 +91,4 @@
     <div title="JSON"  class="MWFTab">
         <div class="MWFJSONArea" style="font-family: Verdana, Geneva, sans-serif; font-size:14px"></div>
     </div>
-</div>
+</div>

+ 38 - 38
o2web/source/x_component_process_FormDesigner/Module/Select/select.html

@@ -1,25 +1,18 @@
 <div style="background-color: #FFF; overflow: hidden">
-	<div title="基本" class="MWFTab">
-		<table width="100%" border="0" cellpadding="5" cellspacing="0" class="editTable">
-		  <tr>
-		    <td class="editTableTitle">标识:</td>
-		    <td class="editTableValue"><input type="text" name="id" value="text{$.id}" class="editTableInput"/></td>
-		  </tr>
-		  <tr>
-		    <td class="editTableTitle">名称:</td>
-		    <td class="editTableValue"><input type="text" name="name" value="text{$.name}" class="editTableInput"/></td>
-		  </tr>
-		  <tr>
-		    <td class="editTableTitle">描述:</td>
-		    <td class="editTableValue"><input type="text" name="description" value="text{$.description}" class="editTableInput"/></td>
-		  </tr>
-		  <tr>
-		    <td class="editTableTitle">可选值:</td>
-		    <td class="editTableValue">
-		    	<input class="editTableRadio" onclick="if (this.checked){ $('text{$.pid}selectEditItemValues').setStyle('display', 'block'); $('text{$.pid}selectEditItemScript').setStyle('display', 'none')}" name="itemType" text{($.itemType=='values')?'checked':''} type="radio" value="values"/>固定值
-		    	<input class="editTableRadio" onclick="if (this.checked){ $('text{$.pid}selectEditItemScript').setStyle('display', 'block'); $('text{$.pid}selectEditItemValues').setStyle('display', 'none')}" name="itemType" text{($.itemType=='script')?'checked':''} type="radio" value="script"/>脚本
-		    </td>
-		  </tr>
+    <div title="基本" class="MWFTab">
+        <table width="100%" border="0" cellpadding="5" cellspacing="0" class="editTable">
+            <tr>
+                <td class="editTableTitle">标识:</td>
+                <td class="editTableValue"><input type="text" name="id" value="text{$.id}" class="editTableInput"/></td>
+            </tr>
+            <tr>
+                <td class="editTableTitle">名称:</td>
+                <td class="editTableValue"><input type="text" name="name" value="text{$.name}" class="editTableInput"/></td>
+            </tr>
+            <tr>
+                <td class="editTableTitle">描述:</td>
+                <td class="editTableValue"><input type="text" name="description" value="text{$.description}" class="editTableInput"/></td>
+            </tr>
             <tr>
                 <td class="editTableTitle">是否只读:</td>
                 <td class="editTableValue">
@@ -27,14 +20,21 @@
                     <input type="radio" name="isReadonly" value="false" text{(!$.isReadonly)?'checked':''}/>否
                 </td>
             </tr>
-		</table>
-		
-		<div id="text{$.pid}selectEditItemValues" style="display: text{($.itemType=='values')?'block':'none'}" class="MWFArraylist" name="itemValues" title="可选值"></div>
-		<div id="text{$.pid}selectEditItemScript" style="display: text{($.itemType=='script')?'block':'none'}" class="MWFScriptArea" name="itemScript" title="可选值脚本 (S)"></div>
-		
-		<div class="MWFMaplist" name="styles" title="样式"></div>
+            <tr>
+                <td class="editTableTitle">可选值:</td>
+                <td class="editTableValue">
+                    <input class="editTableRadio" onclick="if (this.checked){ $('text{$.pid}selectEditItemValues').setStyle('display', 'block'); $('text{$.pid}selectEditItemScript').setStyle('display', 'none')}" name="itemType" text{($.itemType=='values')?'checked':''} type="radio" value="values"/>固定值
+                    <input class="editTableRadio" onclick="if (this.checked){ $('text{$.pid}selectEditItemScript').setStyle('display', 'block'); $('text{$.pid}selectEditItemValues').setStyle('display', 'none')}" name="itemType" text{($.itemType=='script')?'checked':''} type="radio" value="script"/>脚本
+                </td>
+            </tr>
+        </table>
+
+        <div id="text{$.pid}selectEditItemValues" style="display: text{($.itemType=='values')?'block':'none'}" class="MWFArraylist" name="itemValues" title="可选值"></div>
+        <div id="text{$.pid}selectEditItemScript" style="display: text{($.itemType=='script')?'block':'none'}" class="MWFScriptArea" name="itemScript" title="可选值脚本 (S)"></div>
+
+        <div class="MWFMaplist" name="styles" title="样式"></div>
         <div class="MWFMaplist" name="inputStyles" title="Select样式"></div>
-		<div class="MWFMaplist" name="properties" title="属性"></div>
+        <div class="MWFMaplist" name="properties" title="属性"></div>
 
         <table width="100%" border="0" cellpadding="5" cellspacing="0" class="editTable">
             <tr>
@@ -46,12 +46,12 @@
                 </td>
             </tr>
         </table>
-		<div class="MWFScriptArea" name="defaultValue" title="默认值 (S)"></div>
+        <div class="MWFScriptArea" name="defaultValue" title="默认值 (S)"></div>
 
         <div class="MWFValidation" name="validationConfig"></div>
         <div class="MWFScriptArea" name="validation" title="校验脚本 (S)"></div>
-		
-	</div>
+
+    </div>
     <div title="区段" class="MWFTab">
         <table width="100%" border="0" cellpadding="5" cellspacing="0" class="editTable">
             <tr>
@@ -81,13 +81,13 @@
             </div>
         </div>
     </div>
-	<div title="事件"  class="MWFTab">
-		<div class="MWFEventsArea" name="events"></div>
-	</div>
-	<div title="HTML"  class="MWFTab">
-		<div class="MWFHTMLArea" style="font-family: Verdana, Geneva, sans-serif; font-size:14px"></div>
-	</div>
+    <div title="事件"  class="MWFTab">
+        <div class="MWFEventsArea" name="events"></div>
+    </div>
+    <div title="HTML"  class="MWFTab">
+        <div class="MWFHTMLArea" style="font-family: Verdana, Geneva, sans-serif; font-size:14px"></div>
+    </div>
     <div title="JSON"  class="MWFTab">
         <div class="MWFJSONArea" style="font-family: Verdana, Geneva, sans-serif; font-size:14px"></div>
     </div>
-</div>
+</div>

+ 1 - 2
o2web/source/x_component_process_ProcessDesigner/$Process/flat/css.wcss

@@ -838,8 +838,7 @@
 		"font-size": "12px",
 		"height": "24px",
 		"line-height": "24px",
-		"border-bottom": "1px dashed #CCC",
-		"word-break":"keep-all"
+		"border-bottom": "1px dashed #CCC"
 	},
 	"editTableHeadTitle": {
         "color": "#bf6364",

+ 66 - 4
o2web/source/x_component_process_Xform/$Input.js

@@ -184,15 +184,49 @@ MWF.xApplication.process.Xform.$Input = MWF.APP$Input =  new Class({
         return (this.json.defaultValue && this.json.defaultValue.code) ? this.form.Macro.exec(this.json.defaultValue.code, this): (value || "");
     },
 	getValue: function(){
+        debugger;
+        if (this.moduleValueAG) return this.moduleValueAG;
         var value = this._getBusinessData();
         if (!value) value = this._computeValue();
 		return value || "";
 	},
     _setValue: function(value){
+	    debugger;
+	    // if (value && value.isAG){
+	    //     var ag = o2.AG.all(value).then(function(v){
+	    //         if (o2.typeOf(v)=="array") v = v[0];
+        //         this.__setValue(v);
+        //     }.bind(this));
+        //     this.moduleValueAG = ag;
+	    //     ag.then(function(){
+        //         this.moduleValueAG = null;
+        //     }.bind(this));
+        // }else {
+        if (o2.typeOf(value.then)=="function"){
+            var p = o2.promiseAll(value).then(function(v){
+                this.__setValue(v);
+            }.bind(this));
+            this.moduleValueAG = p;
+            p.then(function(){
+                this.moduleValueAG = null;
+            }.bind(this));
+        }else{
+            this.moduleValueAG = null;
+            this.__setValue(value);
+        }
+
+            //this.__setValue(value);
+        // }
+
+    },
+    __setValue: function(value){
         this._setBusinessData(value);
         if (this.node.getFirst()) this.node.getFirst().set("value", value || "");
         if (this.readonly || this.json.isReadonly) this.node.set("text", value);
+        this.moduleValueAG = null;
+        return value;
     },
+
 	_loadValue: function(){
         this._setValue(this.getValue());
 	},
@@ -237,7 +271,7 @@ MWF.xApplication.process.Xform.$Input = MWF.APP$Input =  new Class({
      */
 	getData: function(when){
         if (this.json.compute == "save") this._setValue(this._computeValue());
-		return this.getInputData();
+        return this.getInputData();
 	},
     getInputData: function(){
         if (this.node.getFirst()){
@@ -257,15 +291,43 @@ MWF.xApplication.process.Xform.$Input = MWF.APP$Input =  new Class({
      *  @param {string/number/jsonObject} .
      */
 	setData: function(data){
+        // if (data && data.isAG){
+        //     var ag = o2.AG.all(data).then(function(v){
+        //         if (o2.typeOf(v)=="array") v = v[0];
+        //         this.__setData(v);
+        //     }.bind(this));
+        //     this.moduleValueAG = ag;
+        //     ag.then(function(){
+        //         this.moduleValueAG = null;
+        //     }.bind(this));
+        // }else{
+        if (o2.typeOf(data.then)=="function"){
+            var p = o2.promiseAll(data).then(function(v){
+                this.__setValue(v);
+            }.bind(this));
+            this.moduleValueAG = p;
+            p.then(function(){
+                this.moduleValueAG = null;
+            }.bind(this));
+        }else{
+            this.moduleValueAG = null;
+            this.__setValue(data);
+        }
+            //this.__setData(data);
+        //}
+	},
+    __setData: function(data){
         this._setBusinessData(data);
-		if (this.node.getFirst()){
+        if (this.node.getFirst()){
             this.node.getFirst().set("value", data);
             this.checkDescription();
             this.validationMode();
         }else{
             this.node.set("text", data);
         }
-	},
+        this.moduleValueAG = null;
+    },
+
 
     createErrorNode: function(text){
 
@@ -474,4 +536,4 @@ MWF.xApplication.process.Xform.$Input = MWF.APP$Input =  new Class({
         return true;
     }
 	
-}); 
+}); 

+ 30 - 2
o2web/source/x_component_process_Xform/Calendar.js

@@ -23,11 +23,27 @@ MWF.xApplication.process.Xform.Calendar = MWF.APPCalendar =  new Class({
             });
         }
     },
+    _getValueAg: function(value,isDate){
+        if (value && value.isAG){
+            return value.then(function(v){
+                this._getValueAg(v, isDate);
+            }.bind(this));
+        }else{
+            var d = (!!value) ? Date.parse(value) : "";
+            if (isDate){
+                return d || null;
+            }else{
+                return (d) ? d.format(this.json.format) : "";
+            }
+        }
+    },
     getValue: function(isDate){
+        if (this.moduleValueAG) return this.moduleValueAG;
         var value = this._getBusinessData();
         if( value && !isDate)return value;
-
         if (!value) value = this._computeValue();
+        if (value.then) return value;
+
         var d = (!!value) ? Date.parse(value) : "";
         if (isDate){
             return d || null;
@@ -35,12 +51,24 @@ MWF.xApplication.process.Xform.Calendar = MWF.APPCalendar =  new Class({
             //if (d) value = Date.parse(value).format(this.json.format);
             return (d) ? d.format(this.json.format) : "";
         }
+
+        return value || "";
     },
     getValueStr : function(){
         var value = this._getBusinessData();
         if (!value) value = this._computeValue();
         return value;
     },
+
+    __setValue: function(value){
+        var v = (value) ? ( Date.parse(value)).format(this.json.format) : "";
+        this._setBusinessData(value);
+        if (this.node.getFirst()) this.node.getFirst().set("value", v || "");
+        if (this.readonly || this.json.isReadonly) this.node.set("text", v);
+        this.moduleValueAG = null;
+        return value;
+    },
+
 	clickSelect: function(){
 	    debugger;
         var _self = this;
@@ -184,4 +212,4 @@ MWF.xApplication.process.Xform.Calendar = MWF.APPCalendar =  new Class({
         }
         return resultArr[0] + "-" + resultArr[1] + "-" + resultArr[2] + " " + resultArr[3]+":"+resultArr[4]+":"+resultArr[5];
     }
-}); 
+}); 

+ 109 - 45
o2web/source/x_component_process_Xform/Checkbox.js

@@ -93,57 +93,107 @@ MWF.xApplication.process.Xform.Checkbox = MWF.APPCheckbox =  new Class({
 		}
 		//return [];
 	},
-	
-	setOptions: function(){
-		var radioValues = this.getOptions();
-        if (!radioValues) radioValues = [];
-        if (o2.typeOf(radioValues)==="array"){
-            var flag = (new MWF.widget.UUID).toString();
-            radioValues.each(function(item){
-                var tmps = item.split("|");
-                var text = tmps[0];
-                var value = tmps[1] || text;
 
-                var radio = new Element("input", {
-                    "type": "checkbox",
-                    "name": ((this.json.properties) ? this.json.properties.name : null) || flag+this.json.id,
-                    "value": value,
-                    "showText": text,
-                    "styles": this.json.buttonStyles
-                }).inject(this.node);
-                //radio.appendText(text, "after");
+    setOptions: function(){
+        var optionItems = this.getOptions();
+        this._setOptions(optionItems);
+    },
+
+    _setOptions: function(optionItems){
+        var p = o2.promiseAll(optionItems).then(function(radioValues){
+            this.moduleSelectAG = null;
+            if (!radioValues) radioValues = [];
+            if (o2.typeOf(radioValues)==="array"){
+                var flag = (new MWF.widget.UUID).toString();
+                radioValues.each(function(item){
+                    var tmps = item.split("|");
+                    var text = tmps[0];
+                    var value = tmps[1] || text;
 
-                var textNode = new Element( "span", {
-                    "text" : text,
-                    "styles" : { "cursor" : "default" }
-                }).inject(this.node);
-                textNode.addEvent("click", function( ev ){
-                    if( this.radio.get("disabled") === true || this.radio.get("disabled") === "true" )return;
-                    this.radio.checked = ! this.radio.checked;
-                    this.radio.fireEvent("change");
-                    this.radio.fireEvent("click");
-                }.bind( {radio : radio} ) );
+                    var radio = new Element("input", {
+                        "type": "checkbox",
+                        "name": ((this.json.properties) ? this.json.properties.name : null) || flag+this.json.id,
+                        "value": value,
+                        "showText": text,
+                        "styles": this.json.buttonStyles
+                    }).inject(this.node);
+                    //radio.appendText(text, "after");
 
-                radio.addEvent("click", function(){
-                    this.validationMode();
-                    if (this.validation()) this._setBusinessData(this.getInputData("change") || []);
-                }.bind(this));
+                    var textNode = new Element( "span", {
+                        "text" : text,
+                        "styles" : { "cursor" : "default" }
+                    }).inject(this.node);
+                    textNode.addEvent("click", function( ev ){
+                        if( this.radio.get("disabled") === true || this.radio.get("disabled") === "true" )return;
+                        this.radio.checked = ! this.radio.checked;
+                        this.radio.fireEvent("change");
+                        this.radio.fireEvent("click");
+                    }.bind( {radio : radio} ) );
+
+                    radio.addEvent("click", function(){
+                        this.validationMode();
+                        if (this.validation()) this._setBusinessData(this.getInputData("change") || []);
+                    }.bind(this));
 
-                Object.each(this.json.events, function(e, key){
-                    if (e.code){
-                        if (this.options.moduleEvents.indexOf(key)!=-1){
-                        }else{
-                            radio.addEvent(key, function(event){
-                                return this.form.Macro.fire(e.code, this, event);
-                            }.bind(this));
+                    Object.each(this.json.events, function(e, key){
+                        if (e.code){
+                            if (this.options.moduleEvents.indexOf(key)!=-1){
+                            }else{
+                                radio.addEvent(key, function(event){
+                                    return this.form.Macro.fire(e.code, this, event);
+                                }.bind(this));
+                            }
                         }
-                    }
-                }.bind(this));
+                    }.bind(this));
 
-            }.bind(this));
-        }
+                }.bind(this));
+            }
+        }.bind(this));
+        this.moduleSelectAG = p;
+        if (p) p.then(function(){
+            this.moduleSelectAG = null;
+        }.bind(this));
 	},
+
     _setValue: function(value){
+        var p = o2.promiseAll(value).then(function(v){
+            //if (o2.typeOf(v)=="array") v = v[0];
+            if (this.moduleSelectAG){
+                this.moduleValueAG = this.moduleSelectAG;
+                this.moduleSelectAG.then(function(){
+                    this.__setValue(v);
+                    return v;
+                }.bind(this));
+            }else{
+                this.__setValue(v)
+            }
+            return v;
+        }.bind(this));
+        this.moduleValueAG = p;
+        if (this.moduleValueAG) this.moduleValueAG.then(function(){
+            this.moduleValueAG = null;
+        }.bind(this));
+
+        // this.moduleValueAG = o2.AG.all(value).then(function(v){
+        //     if (this.moduleSelectAG){
+        //         this.moduleValueAG = this.moduleSelectAG;
+        //         this.moduleSelectAG.then(function(){
+        //             this.moduleValueAG = null;
+        //             this.__setValue(v);
+        //         }.bind(this));
+        //     }else{
+        //         this.moduleValueAG = null;
+        //         this.__setValue(v);
+        //     }
+        //     return v;
+        // }.bind(this));
+        //
+        // if (this.moduleValueAG) this.moduleValueAG.then(function(){
+        //     this.moduleValueAG = "";
+        // }.bind(this));
+    },
+
+    __setValue: function(value){
         this._setBusinessData(value);
         var radios = this.node.getElements("input");
         for (var i=0; i<radios.length; i++){
@@ -208,7 +258,21 @@ MWF.xApplication.process.Xform.Checkbox = MWF.APPCheckbox =  new Class({
     resetData: function(){
         this.setData(this.getValue());
     },
-	setData: function(data){
+
+    setData: function(data){
+	    return this._setValue(data);
+        // if (data && data.isAG){
+        //     this.moduleValueAG = data;
+        //     data.addResolve(function(v){
+        //         this.setData(v);
+        //     }.bind(this));
+        // }else{
+        //     this.__setData(data);
+        //     this.moduleValueAG = null;
+        // }
+    },
+
+    __setData: function(data){
         this._setBusinessData(data);
 
 		var inputs = this.node.getElements("input");
@@ -319,4 +383,4 @@ MWF.xApplication.process.Xform.Checkbox = MWF.APPCheckbox =  new Class({
         return true;
     }
 	
-}); 
+}); 

+ 123 - 26
o2web/source/x_component_process_Xform/DatagridMobile.js

@@ -40,15 +40,24 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
         if (this.editable!=false){
             this._loadDatagridDataModules();
             //this._addTitleActionColumn();
-            this._loadEditDatagrid();
-            //this._loadReadDatagrid();
-            this.fireEvent("postLoad");
-            this.fireEvent("load");
+            // this._loadEditDatagrid();
+            // //this._loadReadDatagrid();
+            // this.fireEvent("postLoad");
+            // this.fireEvent("load");
+            this._loadEditDatagrid(function(){
+                this.fireEvent("postLoad");
+                this.fireEvent("load");
+            }.bind(this));
         }else{
             this._loadDatagridDataModules();
-            this._loadReadDatagrid();
-            this.fireEvent("postLoad");
-            this.fireEvent("load");
+            this._loadReadDatagrid(function(){
+                this.fireEvent("postLoad");
+                this.fireEvent("load");
+            }.bind(this));
+
+            // this._loadReadDatagrid();
+            // this.fireEvent("postLoad");
+            // this.fireEvent("load");
         }
     },
     createMobileTable: function(){
@@ -90,14 +99,18 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
 
     },
     _getValue: function(){
+        if (this.moduleValueAG) return this.moduleValueAG;
         var value = [];
         value = this._getBusinessData();
         if (!value){
             if (this.json.defaultData && this.json.defaultData.code) value = this.form.Macro.exec(this.json.defaultData.code, this);
-            value = {"data": value || []};
+            if (!value.isAG) if (o2.typeOf(value)=="array") value = {"data": value || []};
         }
         return value || [];
     },
+    getValue: function(){
+        return this._getValue();
+    },
 
     _getValueText: function(idx, value){
         var module = this.editModules[idx];
@@ -179,8 +192,34 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
         return flag;
     },
 
-    _loadReadDatagrid: function(){
-        this.gridData = this._getValue();
+    _loadReadDatagrid: function(callback){
+        var p = o2.promiseAll(this.gridData).then(function(v){
+            this.gridData = v;
+            if (o2.typeOf(this.gridData)=="array") this.gridData = {"data": this.gridData};
+            this.__loadReadDatagrid(callback);
+            this.moduleValueAG = null;
+            return v;
+        }.bind(this));
+        this.moduleValueAG = p;
+        if (this.moduleValueAG) this.moduleValueAG.then(function(){
+            this.moduleValueAG = null;
+        }.bind(this));
+
+        // if (this.gridData && this.gridData.isAG){
+        //     this.moduleValueAG = this.gridData;
+        //     this.gridData.addResolve(function(v){
+        //         this.gridData = v;
+        //         this._loadReadDatagrid(callback);
+        //     }.bind(this));
+        // }else{
+        //     if (o2.typeOf(this.gridData)=="array") this.gridData = {"data": this.gridData};
+        //     this.__loadReadDatagrid(callback);
+        //     this.moduleValueAG = null;
+        // }
+    },
+
+    __loadReadDatagrid: function(callback){
+        //this.gridData = this._getValue();
 
         var titleHeaders = this.table.getElements("th");
         var tds = this.table.getElements("td");
@@ -260,13 +299,40 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
                 }.bind(this));
             }.bind(this));
         }
-
+        if (callback) callback();
         //this._loadTotal();
     },
-    _loadEditDatagrid: function(){
+
+    _loadEditDatagrid: function(callback){
+        var p = o2.promiseAll(this.gridData).then(function(v){
+            this.gridData = v;
+            if (o2.typeOf(this.gridData)=="array") this.gridData = {"data": this.gridData};
+            this.__loadEditDatagrid(callback);
+            this.moduleValueAG = null;
+            return v;
+        }.bind(this));
+        this.moduleValueAG = p;
+        if (this.moduleValueAG) this.moduleValueAG.then(function(){
+            this.moduleValueAG = null;
+        }.bind(this));
+
+
+        // if (this.gridData && this.gridData.isAG){
+        //     this.moduleValueAG = this.gridData;
+        //     this.gridData.addResolve(function(v){
+        //         this.gridData = v;
+        //         this._loadEditDatagrid(callback);
+        //     }.bind(this));
+        // }else{
+        //     if (o2.typeOf(this.gridData)=="array") this.gridData = {"data": this.gridData};
+        //     this.__loadEditDatagrid(callback);
+        //     this.moduleValueAG = null;
+        // }
+    },
+    __loadEditDatagrid: function(callback){
         //this._createHelpNode();
 
-        this.gridData = this._getValue();
+        //this.gridData = this._getValue();
 
         var titleHeaders = this.table.getElements("th");
         var tds = this.table.getElements("td");
@@ -358,6 +424,7 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
             }
             // this._loadAddAction();
         }
+        if (callback) callback();
         //this._loadTotal();
     },
     _loadActions: function(titleDiv){
@@ -754,21 +821,20 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
                 }
 
                 var cell;
+                var text = this._getValueText(idx, data.text.join(", "));
+
                 if (dataRow){
                     cell = dataRow.getElement("td");
-
                     if( module.json.type == "ImageClipper" ){
                         this._createImage( cell, module, data.text );
                     }else if( module.json.type == "Attachment" || module.json.type == "AttachmentDg" ){
                         this._createAttachment( cell, module, data );
                     }else{
-                        var text = this._getValueText(idx, data.text.join(", "));
-                        if( module.json.type == "Textarea"){
+                        if( module && module.json.type == "Textarea" ){
                             cell.set("html", text);
                         }else{
-                            cell.set("text", data.text.join(", "));
+                            cell.set("text", text);
                         }
-
                         //cell.set("text", data.text.join(", "));
                     }
                 }else{
@@ -786,8 +852,7 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
                     }else if( module.json.type == "Attachment" || module.json.type == "AttachmentDg" ){
                         this._createAttachment( cell, module, data );
                     }else{
-                        var text = this._getValueText(idx, data.text.join(", "));
-                        if( module.json.type == "Textarea"){
+                        if( module && module.json.type == "Textarea" ){
                             cell.set("html", text);
                         }else{
                             cell.set("text", text);
@@ -1242,13 +1307,45 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
         this.setData(this._getValue());
     },
     setData: function(data){
-        // if( typeOf( data ) === "object" && typeOf(data.data) === "array"  ){
-        if (data){
-            this._setBusinessData(data);
-            this.gridData = data;
-        }else{
-            this.gridData = this._getValue();
+        if (!data){
+            data = this._getValue();
         }
+        this._setData(data);
+    },
+    _setData: function(data){
+        var p = o2.promiseAll(this.data).then(function(v){
+            this.gridData = v;
+            if (o2.typeOf(data)=="array") data = {"data": data};
+            this.__setData(data);
+            this.moduleValueAG = null;
+            return v;
+        }.bind(this));
+        this.moduleValueAG = p;
+        if (this.moduleValueAG) this.moduleValueAG.then(function(){
+            this.moduleValueAG = null;
+        }.bind(this));
+
+        // if (data && data.isAG){
+        //     this.moduleValueAG = data;
+        //     data.addResolve(function(v){
+        //         this._setData(v);
+        //     }.bind(this));
+        // }else{
+        //     if (o2.typeOf(data)=="array") data = {"data": data};
+        //     this.__setData(data);
+        //     this.moduleValueAG = null;
+        // }
+    },
+    __setData: function(data){
+        // if( typeOf( data ) === "object" && typeOf(data.data) === "array"  ){
+        // if (data){
+        //     this._setBusinessData(data);
+        //     this.gridData = data;
+        // }else{
+        //     this.gridData = this._getValue();
+        // }
+        this._setBusinessData(data);
+        this.gridData = data;
 
         // if (this.isEdit) this._completeLineEdit();
         if( this.isEdit ){

+ 102 - 45
o2web/source/x_component_process_Xform/DatagridPC.js

@@ -38,19 +38,20 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 			this._loadDatagridDataModules();
 			this._addTitleActionColumn();
 
-			this._loadEditDatagrid();
-
-			this.fireEvent("postLoad");
-			this.fireEvent("load");
+			this._loadEditDatagrid(function(){
+				this.fireEvent("postLoad");
+				this.fireEvent("load");
+			}.bind(this));
 			//this._loadReadDatagrid();
 		}else{
 			this._loadDatagridDataModules();
 			this._getDatagridEditorTr();
-			this._loadReadDatagrid();
-			if(this.editorTr)this.editorTr.setStyle("display", "none");
+			this._loadReadDatagrid(function(){
+				if(this.editorTr)this.editorTr.setStyle("display", "none");
+				this.fireEvent("postLoad");
+				this.fireEvent("load");
+			}.bind(this));
 
-			this.fireEvent("postLoad");
-			this.fireEvent("load");
 		}
 	},
 	_loadStyles: function(){
@@ -58,14 +59,18 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 		this.node.setStyles(this.json.styles);
 	},
 	_getValue: function(){
+		if (this.moduleValueAG) return this.moduleValueAG;
 		var value = [];
 		value = this._getBusinessData();
 		if (!value){
 			if (this.json.defaultData && this.json.defaultData.code) value = this.form.Macro.exec(this.json.defaultData.code, this);
-			value = {"data": value || []};
+			if (!value.then) if (o2.typeOf(value)=="array") value = {"data": value || []};
 		}
 		return value || {};
 	},
+	getValue: function(){
+		return this._getValue();
+	},
 	_getDatagridTr: function(){
 		this._getDatagridTitleTr();
 		this._getDatagridEditorTr();
@@ -109,7 +114,31 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 		//}
 	},
 
-	_loadEditDatagrid: function(){
+	_loadEditDatagrid: function(callback){
+		var p = o2.promiseAll(this.gridData).then(function(v){
+			this.gridData = v;
+			if (o2.typeOf(this.gridData)=="array") this.gridData = {"data": this.gridData};
+			this.__loadEditDatagrid(callback);
+			this.moduleValueAG = null;
+			return v;
+		}.bind(this));
+		this.moduleValueAG = p;
+		if (this.moduleValueAG) this.moduleValueAG.then(function(){
+			this.moduleValueAG = null;
+		}.bind(this));
+		// if (this.gridData && this.gridData.isAG){
+		// 	this.moduleValueAG = this.gridData;
+		// 	this.gridData.addResolve(function(v){
+		// 		this.gridData = v;
+		// 		this._loadEditDatagrid(callback);
+		// 	}.bind(this));
+		// }else{
+		// 	if (o2.typeOf(this.gridData)=="array") this.gridData = {"data": this.gridData};
+		// 	this.__loadEditDatagrid(callback);
+		// 	this.moduleValueAG = null;
+		// }
+	},
+	__loadEditDatagrid: function(callback){
 		var titleThs = this.titleTr.getElements("th");
 		var editorTds = this.editorTr.getElements("td");
 
@@ -129,11 +158,11 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 				}.bind(this));
 			}.bind(this));
 		}
-
-
 		this.editorTr.setStyle("display", "none");
+		if (callback) callback();
 	},
 
+
 	_getValueText: function(idx, value){
 		debugger;
 		var module = this.editModules[idx];
@@ -791,9 +820,34 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 		drag.start(e);
 		tr.setStyle("display", "none");
 	},
-	_loadReadDatagrid: function(){
-		this.gridData = this._getValue();
+	_loadReadDatagrid: function(callback){
+		var p = o2.promiseAll(this.gridData).then(function(v){
+			this.gridData = v;
+			if (o2.typeOf(this.gridData)=="array") this.gridData = {"data": this.gridData};
+			this.__loadReadDatagrid(callback);
+			this.moduleValueAG = null;
+			return v;
+		}.bind(this));
+		this.moduleValueAG = p;
+		if (this.moduleValueAG) this.moduleValueAG.then(function(){
+			this.moduleValueAG = null;
+		}.bind(this));
+
+		// if (this.gridData && this.gridData.isAG){
+		// 	this.moduleValueAG = this.gridData;
+		// 	this.gridData.addResolve(function(v){
+		// 		this.gridData = v;
+		// 		this._loadReadDatagrid(callback);
+		// 	}.bind(this));
+		// }else{
+		// 	if (o2.typeOf(this.gridData)=="array") this.gridData = {"data": this.gridData};
+		// 	this.__loadReadDatagrid(callback);
+		// 	this.moduleValueAG = null;
+		// }
+	},
 
+	__loadReadDatagrid: function(callback){
+		//this.gridData = this._getValue();
 		if (!this.titleTr) this._getDatagridTitleTr();
 		//var titleTr = this.table.getElement("tr");
 		var titleHeaders = this.titleTr.getElements("th");
@@ -827,23 +881,6 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 									cell.set("text", text);
 								}
 							}
-
-
-							// if (typeOf(v)==="array"){
-							// 	var textArray = [];
-							// 	v.each( function( item ){
-							// 		if (typeOf(item)==="object"){
-							// 			textArray.push( item.name+((item.unitName) ? "("+item.unitName+")" : "") );
-							// 		}else{
-							// 			textArray.push(item);
-							// 		}
-							// 	}.bind(this));
-							// 	cell.set("text", textArray.join(", "));
-							// }else if (typeOf(v)==="object"){
-							//    cell.set("text", v.name+((v.unitName) ? "("+v.unitName+")" : ""));
-							// }else{
-							//    cell.set("text", v);
-							// }
 							break;
 						}
 					}else{ //Sequence
@@ -854,14 +891,9 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 				}.bind(this));
 			}.bind(this));
 		}
-
-
-		//lastTr.destroy();
-
 		this._loadTotal();
-		//   this._loadSequenceRead();
-
 
+		if (callback) callback();
 	},
 
 	_loadDatagridStyle: function(){
@@ -1049,13 +1081,39 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 		this.setData(this._getValue());
 	},
 	setData: function(data){
-		// if( typeOf( data ) === "object" && typeOf(data.data) === "array"  ){
-		if (data){
-			this._setBusinessData(data);
-			this.gridData = data;
-		}else{
-			this.gridData = this._getValue();
+		if (!data){
+			data = this._getValue();
 		}
+		this._setData(data);
+	},
+	_setData: function(data){
+		var p = o2.promiseAll(this.data).then(function(v){
+			this.gridData = v;
+			if (o2.typeOf(data)=="array") data = {"data": data};
+			this.__setData(data);
+			this.moduleValueAG = null;
+			return v;
+		}.bind(this));
+		this.moduleValueAG = p;
+		if (this.moduleValueAG) this.moduleValueAG.then(function(){
+			this.moduleValueAG = null;
+		}.bind(this));
+
+		// if (data && data.isAG){
+		// 	this.moduleValueAG = data;
+		// 	data.addResolve(function(v){
+		// 		this._setData(v);
+		// 	}.bind(this));
+		// }else{
+		// 	if (o2.typeOf(data)=="array") data = {"data": data};
+		// 	this.__setData(data);
+		// 	this.moduleValueAG = null;
+		// }
+	},
+	__setData: function(data){
+		// if( typeOf( data ) === "object" && typeOf(data.data) === "array"  ){
+		this._setBusinessData(data);
+		this.gridData = data;
 
 		// if (this.isEdit) this._completeLineEdit();
 		if( this.isEdit ){ //如果有在编辑的,取消编辑行
@@ -1098,9 +1156,8 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 			}
 			this._loadDatagridStyle();
 		}
-
-
 	},
+
 	getTotal: function(){
 		this._loadTotal();
 		return this.totalResaults;

+ 12 - 0
o2web/source/x_component_process_Xform/Documenteditor.js

@@ -1356,6 +1356,18 @@ MWF.xApplication.process.Xform.Documenteditor = MWF.APPDocumenteditor =  new Cla
                 }
                 //e.editor.getSelection().scrollIntoView();
 
+                var text = this.data.filetext.replace(/\u3000*/g, "");
+                if (!text){
+                    var range = e.editor.createRange();
+                    range.moveToElementEditEnd(e.editor.editable());
+
+                    range.select();
+                    range.scrollIntoView();
+                }else{
+                    e.editor.getSelection().scrollIntoView();
+                }
+                // e.editor.getSelection().scrollIntoView();
+                //
                 //this.getFiletextToolber();
                 //this.filetextToolbarNode.inject(this.layout_filetext.getOffsetParent());
 

+ 21 - 3
o2web/source/x_component_process_Xform/Label.js

@@ -10,7 +10,9 @@ MWF.xApplication.process.Xform.Label = MWF.APPLabel =  new Class({
 		if (this.json.valueType == "script"){
 			var code = (this.json.script) ? this.json.script.code : "";
 			if (code){
-				this.node.set("text", this.form.Macro.exec(code, this) || "");
+			    var value = this.form.Macro.exec(code, this);
+			    this._setNodeText(value);
+				//this.node.set("text", this.form.Macro.exec(code, this) || "");
 			} 
 		}
 		if (this.json.prefixIcon || this.json.suffixIcon){
@@ -41,7 +43,23 @@ MWF.xApplication.process.Xform.Label = MWF.APPLabel =  new Class({
             }
 		}
 	},
+    _setNodeText: function(value){
+        if (value && value.isAG){
+            value.addResolve(function(v){
+                this._setNodeText(v);
+            }.bind(this));
+        }else{
+            o2.promiseAll(value).then(function(v){
+                this.node.set("text", v || "");
+            }.bind(this));
+            //this.node.set("text", value || "");
+        }
+    },
     setText: function(text){
-        this.node.set("text", text);
+        o2.promiseAll(text).then(function(v){
+            this.node.set("text", v || "");
+        }.bind(this));
+
+        //this.node.set("text", text);
     }
-});
+});

+ 9 - 1
o2web/source/x_component_process_Xform/Number.js

@@ -196,8 +196,16 @@ MWF.xApplication.process.Xform.Number = MWF.APPNumber =  new Class({
         return (this.json.defaultValue && this.json.defaultValue.code) ? this.form.Macro.exec(this.json.defaultValue.code, this): (value || "0");
     },
     getValue: function(){
+        if (this.moduleValueAG) return this.moduleValueAG;
         var value = this._getBusinessData();
         if (!value) value = this._computeValue();
         return value || "0";
+    },
+    __setValue: function(value){
+        this._setBusinessData(value);
+        if (this.node.getFirst()) this.node.getFirst().set("value", value || "0");
+        if (this.readonly || this.json.isReadonly) this.node.set("text", value);
+        this.moduleValueAG = null;
+        return value;
     }
-});
+});

+ 355 - 100
o2web/source/x_component_process_Xform/Org.js

@@ -91,8 +91,17 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
         //}
     },
 
-
+    _valueMerge: function(values, v){
+        if (o2.typeOf(v)=="function"){
+            return v.then(function(re){
+                this._valueMerge(values, re)
+            }.bind(this));
+        }else{
+            return values.concat(v);
+        }
+    },
     _computeValue: function(){
+        debugger;
         var simple = this.json.storeRange === "simple";
         var values = [];
         if (this.json.identityValue) {
@@ -109,27 +118,144 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
             if (dutys.length){
                 dutys.each(function(duty){
                     if (duty.code) par = this.form.Macro.exec(duty.code, this);
-                    var code = "return this.org.getDuty(\""+duty.name+"\", \""+par+"\")";
-                    var d = this.form.Macro.exec(code, this);
-                    if (typeOf(d)!=="array") d = (d) ? [d.toString()] : [];
-                    d.each(function(dd){if (dd) values.push(MWF.org.parseOrgData(dd, true, simple));});
+                    if (par){
+                        var promise = o2.promiseAll(par).then(function(p){
+                            var uName = p.distinguishedName || p;
+                            if (o2.typeOf(p)=="array") uName = p[0].distinguishedName || p[0];
+                            var code = "return this.org.getDuty(\""+duty.name+"\", \""+uName+"\", true)";
+                            var r = (!!uName) ? this.form.Macro.exec(code, this) : "";
+
+                            return o2.promiseAll(r).then(function(d){
+                                if (typeOf(d)!=="array") d = (d) ? [d.toString()] : [];
+                                var arr = [];
+                                d.each(function(dd){
+                                    if (dd) arr.push(MWF.org.parseOrgData(dd, true, simple));
+                                });
+                                return arr;
+                            }.bind(this)).catch(function(){
+                                console.log("catch error : get duty")
+                            });
+                        }.bind(this));
+                        values.push(promise);
+                    }
                 }.bind(this));
             }
         }
         if (this.json.defaultValue && this.json.defaultValue.code){
             var fd = this.form.Macro.exec(this.json.defaultValue.code, this);
-            if (typeOf(fd)!=="array") fd = (fd) ? [fd] : [];
-            fd.each(function(fdd){
-                if (fdd){
-                    if (typeOf(fdd)==="string"){
-                        var data;
-                        this.getOrgAction()[this.getValueMethod(fdd)](function(json){ data = MWF.org.parseOrgData(json.data, true, simple); }.bind(this), null, fdd, false);
-                        values.push(data);
+            if (o2.typeOf(fd)=="array"){
+                fd.each(function(v){values.push(v);});
+            }else{
+                values.push(fd);
+            }
+
+            // if (fd && fd.isAG){
+            //     values.push(fd);
+            // }else{
+            //     if (typeOf(fd)!=="array") fd = (fd) ? [fd] : [];
+            //     fd.each(function(fdd){
+            //         if (fdd){
+            //             if (typeOf(fdd)==="string"){
+            //                 var data;
+            //                 this.getOrgAction()[this.getValueMethod(fdd)](function(json){ data = MWF.org.parseOrgData(json.data, true, simple); }.bind(this), null, fdd, false);
+            //                 values.push(data);
+            //             }else{
+            //                 values.push(fdd);
+            //             }
+            //         }
+            //     }.bind(this));
+            // }
+        }
+        // if (this.json.count>0){
+        //     return values.slice(0, this.json.count);
+        // }
+        return values;
+        //return (this.json.defaultValue.code) ? this.form.Macro.exec(this.json.defaultValue.code, this): (value || "");
+    },
+    __computeValue: function(){
+        var simple = this.json.storeRange === "simple";
+        var values = [];
+        if (this.json.identityValue) {
+            this.json.identityValue.each(function(v){
+                if (v) values.push(MWF.org.parseOrgData(v, true, simple))
+            });
+        }
+        if (this.json.unitValue) {
+            this.json.unitValue.each(function(v){ if (v) values.push(MWF.org.parseOrgData(v, true, simple))});
+        }
+        if (this.json.dutyValue) {
+            var dutys = JSON.decode(this.json.dutyValue);
+            var par;
+            if (dutys.length){
+                dutys.each(function(duty){
+                    if (duty.code) par = this.form.Macro.exec(duty.code, this);
+                    if (par && par.isAG){
+                        var ag = o2.AG.all(par).then(function(p){
+                            var uName = "";
+                            if (p && p.length) uName = p[0].distinguishedName || p[0];
+                            var code = "return this.org.getDuty(\""+duty.name+"\", \""+uName+"\", true)";
+                            var r = this.form.Macro.exec(code, this);
+
+                            o2.AG.all(r).then(function(d) {
+                                //var d = rd[0];
+                                if (typeOf(d)!=="array") d = (d) ? [d.toString()] : [];
+                                var arr = [];
+                                d.each(function(dd){
+                                    if (dd) arr.push(MWF.org.parseOrgData(dd, true, simple));
+                                });
+                                return arr;
+                            }.bind(this));
+                        }.bind(this));
+                        values.push(ag);
                     }else{
-                        values.push(fdd);
+                        var code = "return this.org.getDuty(\""+duty.name+"\", \""+par+"\", true)";
+                        var r = this.form.Macro.exec(code, this);
+                        var ag = o2.AG.all(r).then(function(d) {
+                            //var d = rd[0];
+                            if (typeOf(d)!=="array") d = (d) ? [d.toString()] : [];
+                            var arr = [];
+                            d.each(function(dd){
+                                if (dd) arr.push(MWF.org.parseOrgData(dd, true, simple));
+                            });
+                            return arr;
+                        }.bind(this));
+                        values.push(ag);
+
+                        // if (typeOf(d)!=="array") d = (d) ? [d.toString()] : [];
+                        // d.each(function(dd){if (dd) values.push(MWF.org.parseOrgData(dd, true, simple));});
                     }
-                }
-            }.bind(this));
+
+                }.bind(this));
+            }
+        }
+        if (this.json.defaultValue && this.json.defaultValue.code){
+            var fd = this.form.Macro.exec(this.json.defaultValue.code, this);
+
+            if (fd && fd.isAG){
+                // value.addResolve(function(v){
+                //     this._setBusinessData(v);
+                //     if (this.node.getFirst()) this.node.getFirst().set("value", v || "");
+                //     if (this.readonly || this.json.isReadonly) this.node.set("text", v);
+                // }.bind(this));
+                values.push(fd);
+                // fd.then(function(v){
+                //     return this._valueMerge(values, v);
+                // }.bind(this));
+                // return fd;
+            }else{
+                if (typeOf(fd)!=="array") fd = (fd) ? [fd] : [];
+                fd.each(function(fdd){
+                    if (fdd){
+                        if (typeOf(fdd)==="string"){
+                            var data;
+                            this.getOrgAction()[this.getValueMethod(fdd)](function(json){ data = MWF.org.parseOrgData(json.data, true, simple); }.bind(this), null, fdd, false);
+                            values.push(data);
+                        }else{
+                            values.push(fdd);
+                        }
+                    }
+                }.bind(this));
+            }
         }
         if (this.json.count>0){
             return values.slice(0, this.json.count);
@@ -367,6 +493,7 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
         }
     },
     resetData: function(){
+        debugger;
         var v = this.getValue();
         //this.setData((v) ? v.join(", ") : "");
         this.setData(v);
@@ -377,12 +504,15 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
         if( data.length === 0 )return true;
         return false;
     },
+
     getInputData: function(){
         if (this.json.isInput){
             if (this.combox)return this.combox.getData();
-            return this._getBusinessData();
+            //return this._getBusinessData();
+            return this.node.retrieve("data");
         }else{
-            return this._getBusinessData();
+            //return this._getBusinessData();
+            return this.node.retrieve("data");
         }
     },
     _loadNodeRead: function(){
@@ -584,6 +714,7 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
                     //this.fireEvent("change");
                 }.bind(this),
                 "onChange": function(){
+                    this.node.store("data", this.getInputData());
                     this._setBusinessData(this.getInputData());
                     this.fireEvent("change");
                 }.bind(this),
@@ -621,7 +752,10 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
 
         this.combox.addEvent("change", function(){
             this.validationMode();
-            if (this.validation()) this._setBusinessData(this.getInputData("change"));
+            if (this.validation()){
+                this.node.store("data", this.getInputData());
+                this._setBusinessData(this.getInputData("change"));
+            }
         }.bind(this));
     },
 
@@ -674,7 +808,10 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
         this.node.getFirst().setStyle("height", "auto");
         this.node.getFirst().addEvent("change", function(){
             this.validationMode();
-            if (this.validation()) this._setBusinessData(this.getInputData("change"));
+            if (this.validation()){
+                this.node.store("data", this.getInputData());
+                this._setBusinessData(this.getInputData("change"));
+            }
         }.bind(this));
     },
     getDataText: function(data){
@@ -715,51 +852,10 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
             }
         }.bind(this));
     },
-    setData: function(value){
-        if (!value) return false;
-        var oldValues = this.getData();
-        var values = [];
-        var comboxValues = [];
-
-        var simple = this.json.storeRange === "simple";
-
-        var type = typeOf(value);
-        if (type==="array"){
-            value.each(function(v){
-                var vtype = typeOf(v);
-                var data = null;
-                if (vtype==="string"){
-                    var error = (this.json.isInput) ? function(){ comboxValues.push(v); } : null;
-                    this.getOrgAction()[this.getValueMethod(v)](function(json){ data = MWF.org.parseOrgData(json.data, true, simple); }.bind(this), error, v, false);
-                }
-                if (vtype==="object") {
-                    data = MWF.org.parseOrgData(v, true, simple);
-                    if(data.woPerson)delete data.woPerson;
-                }
-                if (data){
-                    values.push(data);
-                    comboxValues.push({"text": this.getDataText(data),"value": data});
-                }
-            }.bind(this));
-        }
-        if (type==="string"){
-            var vData;
-            var error = (this.json.isInput) ? function(){ comboxValues.push(value); } : null;
-            this.getOrgAction()[this.getValueMethod(value)](function(json){ vData = MWF.org.parseOrgData(json.data, true, simple); }.bind(this), error, value, false);
-            if (vData){
-                values.push(vData);
-                comboxValues.push({"text": this.getDataText(vData),"value": vData});
-            }
-        }
-        if (type==="object"){
-            var vData = MWF.org.parseOrgData(value, true, simple);
-            if(vData.woPerson)delete vData.woPerson;
-            values.push( vData );
-            comboxValues.push({"text": this.getDataText(value),"value": vData});
-        }
-
+    checkChange: function(oldValues, values){
         var change = false;
-        if (oldValues.length && values.length){
+        if (!values) values = [];
+        if (oldValues.length && (values && values.length)){
             if (oldValues.length === values.length){
                 for (var i=0; i<oldValues.length; i++){
                     if ((oldValues[i].distinguishedName!==values[i].distinguishedName) || (oldValues[i].name!==values[i].name) || (oldValues[i].unique!==values[i].unique)){
@@ -773,46 +869,113 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
         }else if (values.length || oldValues.length) {
             change = true;
         }
-        this._setBusinessData(values);
         if (change) this.fireEvent("change");
+    },
+    setData: function(value){
+        if (!value) return false;
+        var oldValues = this.getData();
+        if (value.length==1 && !(value[0])) value=[];
 
-        if (this.json.isInput){
-            if (this.combox){
-                this.combox.clear();
-                this.combox.addNewValues(comboxValues);
-            }else{
-                var node = this.node.getFirst();
-                if (node){
-                    node.empty();
-                    comboxValues.each(function(v, i){
-                        this.creteShowNode(v, (i===comboxValues.length-1)).inject(node);
-                    }.bind(this));
-                }
-            }
-            //
-            // this.combox.clear();
-            // values.each(function(v){
-            //     var vtype = typeOf(v);
-            //     if (vtype==="string"){
-            //         var data;
-            //         this.getOrgAction()[this.getValueMethod(v)](function(json){ data = json.data }.bind(this), null, v, false);
-            //         if (data) this.combox.addNewValue(this.getDataText(data), data);
-            //     }
-            //     if (vtype==="object"){
-            //         this.combox.addNewValue(this.getDataText(v), v);
-            //     }
-            // }.bind(this));
-        }else{
-            if (this.node.getFirst()){
-                var node = this.node.getFirst();
-                node.empty();
-                this.loadOrgWidget(values, node)
-            }else{
-                this.node.empty();
-                this.loadOrgWidget(values, this.node);
-            }
-        }
+        var promise = this._setValue(value);
+        promise.then(function(values){
+            o2.promiseAll(values).then(function(v){
+                this.checkChange(oldValues, v)
+            }.bind(this));
+
+            // if (values && values.isAG){
+            //     values.then(function(v){
+            //         this.checkChange(oldValues, v)
+            //     }.bind(this));
+            // }else{
+            //     this.checkChange(oldValues, values)
+            // }
+        }.bind(this));
     },
+    // __setData: function(value){
+    //     if (!value) return false;
+    //     var oldValues = this.getData();
+    //     var values = [];
+    //     var comboxValues = [];
+    //
+    //     var simple = this.json.storeRange === "simple";
+    //
+    //     var type = typeOf(value);
+    //     if (type==="array"){
+    //         value.each(function(v){
+    //             var vtype = typeOf(v);
+    //             var data = null;
+    //             if (vtype==="string"){
+    //                 var error = (this.json.isInput) ? function(){ comboxValues.push(v); } : null;
+    //                 this.getOrgAction()[this.getValueMethod(v)](function(json){ data = MWF.org.parseOrgData(json.data, true, simple); }.bind(this), error, v, false);
+    //             }
+    //             if (vtype==="object") {
+    //                 data = MWF.org.parseOrgData(v, true, simple);
+    //                 if(data.woPerson)delete data.woPerson;
+    //             }
+    //             if (data){
+    //                 values.push(data);
+    //                 comboxValues.push({"text": this.getDataText(data),"value": data});
+    //             }
+    //         }.bind(this));
+    //     }
+    //     if (type==="string"){
+    //         var vData;
+    //         var error = (this.json.isInput) ? function(){ comboxValues.push(value); } : null;
+    //         this.getOrgAction()[this.getValueMethod(value)](function(json){ vData = MWF.org.parseOrgData(json.data, true, simple); }.bind(this), error, value, false);
+    //         if (vData){
+    //             values.push(vData);
+    //             comboxValues.push({"text": this.getDataText(vData),"value": vData});
+    //         }
+    //     }
+    //     if (type==="object"){
+    //         var vData = MWF.org.parseOrgData(value, true, simple);
+    //         if(vData.woPerson)delete vData.woPerson;
+    //         values.push( vData );
+    //         comboxValues.push({"text": this.getDataText(value),"value": vData});
+    //     }
+    //
+    //     var change = false;
+    //     if (oldValues.length && values.length){
+    //         if (oldValues.length === values.length){
+    //             for (var i=0; i<oldValues.length; i++){
+    //                 if ((oldValues[i].distinguishedName!==values[i].distinguishedName) || (oldValues[i].name!==values[i].name) || (oldValues[i].unique!==values[i].unique)){
+    //                     change = true;
+    //                     break;
+    //                 }
+    //             }
+    //         }else{
+    //             change = true;
+    //         }
+    //     }else if (values.length || oldValues.length) {
+    //         change = true;
+    //     }
+    //     this._setBusinessData(values);
+    //     if (change) this.fireEvent("change");
+    //
+    //     if (this.json.isInput){
+    //         if (this.combox){
+    //             this.combox.clear();
+    //             this.combox.addNewValues(comboxValues);
+    //         }else{
+    //             var node = this.node.getFirst();
+    //             if (node){
+    //                 node.empty();
+    //                 comboxValues.each(function(v, i){
+    //                     this.creteShowNode(v, (i===comboxValues.length-1)).inject(node);
+    //                 }.bind(this));
+    //             }
+    //         }
+    //     }else{
+    //         if (this.node.getFirst()){
+    //             var node = this.node.getFirst();
+    //             node.empty();
+    //             this.loadOrgWidget(values, node)
+    //         }else{
+    //             this.node.empty();
+    //             this.loadOrgWidget(values, this.node);
+    //         }
+    //     }
+    // },
     creteShowNode: function(data, islast){
         var nodeText = (data.text) ?  data.text : data;
         if (!islast) nodeText = nodeText + (this.json.splitShow || ", ");
@@ -858,7 +1021,96 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
         return node;
     },
     _setValue: function(value){
+        var values = [];
+        var ags = [];
+        var simple = this.json.storeRange === "simple";
+        var flag = false;
+        if (typeOf(value)!=="array") value = (!!value) ? [value] : [];
+        //value = (value.flat) ? value.flat() : value.flatten();
+
+        var p = o2.promiseAll(value).then(function(d){
+            if (typeOf(d)!=="array") d = (!!d) ? [d] : [];
+            d.each(function(da){
+                if (typeOf(da)!=="array") da = (!!da) ? [da] : [];
+                da.each(function(dd){
+                    if (dd){
+                        if (typeOf(dd)==="string"){
+                            var pp = this.getOrgAction()[this.getValueMethod(dd)](function(json){
+                                return MWF.org.parseOrgData(json.data, true, simple);
+                            }.bind(this), null, dd, true).catch(function(e){
+                                console.log("error:" + e);
+                                console.log(e);
+                            });
+                            ags.push(pp);
+                        }else{
+                            values.push(dd);
+                        }
+                    }
+                }.bind(this));
+            }.bind(this));
+            if (ags.length){
+                return o2.promiseAll(ags).then(function(data){
+                    values = values.concat(data);
+                    flag = true;
+                    this.__setValue(values);
+                    return values;
+                }.bind(this));
+            }else{
+                flag = true;
+                this.__setValue(values);
+                return values
+            }
+        }.bind(this));
+
+        this.moduleValueAG = p;
+        if (p) p.then(function(){
+            this.moduleValueAG = null;
+        }.bind(this));
+        return p;
+
+        // var ag = o2.AG.all(value).then(function(d) {
+        //     if (typeOf(d)!=="array") d = (d) ? [d.toString()] : [];
+        //
+        //     d.each(function(dd){
+        //         //if (dd) arr.push(MWF.org.parseOrgData(dd, true, simple));
+        //         if (dd){
+        //             if (typeOf(dd)==="string"){
+        //                 ags.push(this.getOrgAction()[this.getValueMethod(dd)](function(json){
+        //                     return MWF.org.parseOrgData(json.data, true, simple);
+        //                 }.bind(this).ag(), null, dd, true));
+        //             }else{
+        //                 values.push(dd);
+        //             }
+        //         }
+        //     }.bind(this));
+        //     if (ags.length){
+        //         return o2.AG.all(ags).then(function(data){
+        //             values = values.concat(data);
+        //             flag = true;
+        //             this.__setValue(values);
+        //             return values;
+        //         }.bind(this));
+        //     }else{
+        //         flag = true;
+        //         this.__setValue(values);
+        //         return values
+        //     }
+        // }.bind(this));
+        //
+        // this.moduleValueAG = ag;
+        // if (ag) ag.then(function(){
+        //     this.moduleValueAG = null;
+        // }.bind(this));
+        // return ag;
+    },
+    __setValue: function(value){
+        this.moduleValueAG = null;
         if (value.length==1 && !(value[0])) value=[];
+
+        if (this.json.count>0){
+            value = value.slice(0, this.json.count);
+        }
+
         var values = [];
         var comboxValues = [];
         var type = typeOf(value);
@@ -894,6 +1146,7 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
             comboxValues.push({"text": this.getDataText(v),"value": v});
         }
 
+        this.node.store("data", values);
         this._setBusinessData(values);
 
         if (this.json.isInput){
@@ -922,8 +1175,10 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
         }else{
             if (this.node.getFirst()){
                 var node = this.node.getFirst();
+                node.empty();
                 this.loadOrgWidget(values, node)
             }else{
+                this.node.empty();
                 this.loadOrgWidget(values, this.node);
             }
         }

+ 170 - 44
o2web/source/x_component_process_Xform/Radio.js

@@ -100,56 +100,159 @@ MWF.xApplication.process.Xform.Radio = MWF.APPRadio =  new Class({
 		}
 		return [];
 	},
-	
-	setOptions: function(){
-		var radioValues = this.getOptions();
-        if (!radioValues) radioValues = [];
-        if (o2.typeOf(radioValues)==="array"){
-            var flag = (new MWF.widget.UUID).toString();
-            radioValues.each(function(item){
-                var tmps = item.split("|");
-                var text = tmps[0];
-                var value = tmps[1] || text;
+    setOptions: function(){
+        var optionItems = this.getOptions();
+        this._setOptions(optionItems);
+    },
 
-                var radio = new Element("input", {
-                    "type": "radio",
-                    "name": (this.json.properties && this.json.properties.name) ? this.json.properties.name : flag+this.json.id,
-                    "value": value,
-                    "showText": text,
-                    "styles": this.json.buttonStyles
-                }).inject(this.node);
-                //radio.appendText(text, "after");
+	_setOptions: function(optionItems){
+        var p = o2.promiseAll(optionItems).then(function(radioValues){
+            this.moduleSelectAG = null;
 
-                var textNode = new Element( "span", {
-                    "text" : text,
-                    "styles" : { "cursor" : "default" }
-                }).inject(this.node);
-                textNode.addEvent("click", function( ev ){
-                    if( this.radio.get("disabled") === true || this.radio.get("disabled") === "true" )return;
-                    this.radio.checked = true;
-                    this.radio.fireEvent("change");
-                    this.radio.fireEvent("click");
-                }.bind( {radio : radio} ) );
+            if (!radioValues) radioValues = [];
+            if (o2.typeOf(radioValues)==="array"){
+                var flag = (new MWF.widget.UUID).toString();
+                radioValues.each(function(item){
+                    var tmps = item.split("|");
+                    var text = tmps[0];
+                    var value = tmps[1] || text;
 
-                radio.addEvent("click", function(){
-                    this.validationMode();
-                    if (this.validation()) this._setBusinessData(this.getInputData("change"));
-                }.bind(this));
+                    var radio = new Element("input", {
+                        "type": "radio",
+                        "name": (this.json.properties && this.json.properties.name) ? this.json.properties.name : flag+this.json.id,
+                        "value": value,
+                        "showText": text,
+                        "styles": this.json.buttonStyles
+                    }).inject(this.node);
+                    //radio.appendText(text, "after");
 
-                Object.each(this.json.events, function(e, key){
-                    if (e.code){
-                        if (this.options.moduleEvents.indexOf(key)!=-1){
-                        }else{
-                            radio.addEvent(key, function(event){
-                                return this.form.Macro.fire(e.code, this, event);
-                            }.bind(this));
+                    var textNode = new Element( "span", {
+                        "text" : text,
+                        "styles" : { "cursor" : "default" }
+                    }).inject(this.node);
+                    textNode.addEvent("click", function( ev ){
+                        if( this.radio.get("disabled") === true || this.radio.get("disabled") === "true" )return;
+                        this.radio.checked = true;
+                        this.radio.fireEvent("change");
+                        this.radio.fireEvent("click");
+                    }.bind( {radio : radio} ) );
+
+                    radio.addEvent("click", function(){
+                        this.validationMode();
+                        if (this.validation()) this._setBusinessData(this.getInputData("change"));
+                    }.bind(this));
+
+                    Object.each(this.json.events, function(e, key){
+                        if (e.code){
+                            if (this.options.moduleEvents.indexOf(key)!=-1){
+                            }else{
+                                radio.addEvent(key, function(event){
+                                    return this.form.Macro.fire(e.code, this, event);
+                                }.bind(this));
+                            }
                         }
-                    }
+                    }.bind(this));
                 }.bind(this));
-            }.bind(this));
-        }
+            }
+        }.bind(this));
+        this.moduleSelectAG = p;
+        if (p) p.then(function(){
+            this.moduleSelectAG = null;
+        }.bind(this));
+
+        // this.moduleSelectAG = o2.AG.all(optionItems).then(function(radioValues){
+        //     this.moduleSelectAG = null;
+        //
+        //     if (!radioValues) radioValues = [];
+        //     if (o2.typeOf(radioValues)==="array"){
+        //         var flag = (new MWF.widget.UUID).toString();
+        //         radioValues.each(function(item){
+        //             var tmps = item.split("|");
+        //             var text = tmps[0];
+        //             var value = tmps[1] || text;
+        //
+        //             var radio = new Element("input", {
+        //                 "type": "radio",
+        //                 "name": (this.json.properties && this.json.properties.name) ? this.json.properties.name : flag+this.json.id,
+        //                 "value": value,
+        //                 "showText": text,
+        //                 "styles": this.json.buttonStyles
+        //             }).inject(this.node);
+        //             //radio.appendText(text, "after");
+        //
+        //             var textNode = new Element( "span", {
+        //                 "text" : text,
+        //                 "styles" : { "cursor" : "default" }
+        //             }).inject(this.node);
+        //             textNode.addEvent("click", function( ev ){
+        //                 if( this.radio.get("disabled") === true || this.radio.get("disabled") === "true" )return;
+        //                 this.radio.checked = true;
+        //                 this.radio.fireEvent("change");
+        //                 this.radio.fireEvent("click");
+        //             }.bind( {radio : radio} ) );
+        //
+        //             radio.addEvent("click", function(){
+        //                 this.validationMode();
+        //                 if (this.validation()) this._setBusinessData(this.getInputData("change"));
+        //             }.bind(this));
+        //
+        //             Object.each(this.json.events, function(e, key){
+        //                 if (e.code){
+        //                     if (this.options.moduleEvents.indexOf(key)!=-1){
+        //                     }else{
+        //                         radio.addEvent(key, function(event){
+        //                             return this.form.Macro.fire(e.code, this, event);
+        //                         }.bind(this));
+        //                     }
+        //                 }
+        //             }.bind(this));
+        //         }.bind(this));
+        //     }
+        // }.bind(this))
+        // if (this.moduleSelectAG) this.moduleSelectAG.then(function(){
+        //     this.moduleSelectAG = null;
+        // }.bind(this));
 	},
-	_setValue: function(value){
+
+    _setValue: function(value){
+        var p = o2.promiseAll(value).then(function(v){
+            if (o2.typeOf(v)=="array") v = v[0];
+            if (this.moduleSelectAG){
+                this.moduleValueAG = this.moduleSelectAG;
+                this.moduleSelectAG.then(function(){
+                    this.__setValue(v);
+                    return v;
+                }.bind(this));
+            }else{
+                this.__setValue(v)
+            }
+            return v;
+        }.bind(this));
+
+        this.moduleValueAG = p;
+        if (this.moduleValueAG) this.moduleValueAG.then(function(){
+            this.moduleValueAG = null;
+        }.bind(this));
+
+        // this.moduleValueAG = o2.AG.all(value).then(function(v){
+        //     if (o2.typeOf(v)=="array") v = v[0];
+        //     if (this.moduleSelectAG){
+        //         this.moduleValueAG = this.moduleSelectAG;
+        //         this.moduleSelectAG.then(function(){
+        //             this.__setValue(v);
+        //         }.bind(this));
+        //     }else{
+        //         this.__setValue(v)
+        //     }
+        //     return v;
+        // }.bind(this));
+        //
+        // if (this.moduleValueAG) this.moduleValueAG.then(function(){
+        //     this.moduleValueAG = null;
+        // }.bind(this));
+    },
+
+    __setValue: function(value){
         this._setBusinessData(value);
 		var radios = this.node.getElements("input");
 		for (var i=0; i<radios.length; i++){
@@ -206,7 +309,30 @@ MWF.xApplication.process.Xform.Radio = MWF.APPRadio =  new Class({
         }
         return null;
     },
-	setData: function(data){
+
+    setData: function(data){
+        return this._setValue(data);
+        // if (data && data.isAG){
+        //     this.moduleValueAG = o2.AG.all(data).then(function(v){
+        //         if (o2.typeOf(v)=="array") v = v[0];
+        //         this.__setData(v);
+        //     }.bind(this));
+        // }else{
+        //     this.__setData(data);
+        // }
+
+        // if (data && data.isAG){
+        //     this.moduleValueAG = data;
+        //     data.addResolve(function(v){
+        //         this.setData(v);
+        //     }.bind(this));
+        // }else{
+        //     this.__setData(data);
+        //     this.moduleValueAG = null;
+        // }
+    },
+
+    __setData: function(data){
         this._setBusinessData(data);
 		var inputs = this.node.getElements("input");
 		

+ 159 - 26
o2web/source/x_component_process_Xform/Select.js

@@ -131,21 +131,69 @@ MWF.xApplication.process.Xform.Select = MWF.APPSelect =  new Class({
 	},
 	setOptions: function(){
 		var optionItems = this.getOptions();
-        if (!optionItems) optionItems = [];
-        if (o2.typeOf(optionItems)==="array"){
-			optionItems.each(function(item){
-				var tmps = item.split("|");
-				var text = tmps[0];
-				var value = tmps[1] || text;
+		this._setOptions(optionItems);
+	},
+	_setOptions: function(optionItems){
+		var p = o2.promiseAll(optionItems).then(function(options){
+			this.moduleSelectAG = null;
+			if (!options) options = [];
+			if (o2.typeOf(options)==="array"){
+				options.each(function(item){
+					var tmps = item.split("|");
+					var text = tmps[0];
+					var value = tmps[1] || text;
 
-				var option = new Element("option", {
-					"value": value,
-					"text": text
-				}).inject(this.node);
-			}.bind(this));
-			this.fireEvent("setOptions", [optionItems])
-		}
+					var option = new Element("option", {
+						"value": value,
+						"text": text
+					}).inject(this.node);
+				}.bind(this));
+				this.fireEvent("setOptions", [options])
+			}
+		}.bind(this));
+		this.moduleSelectAG = p;
+		if (p) p.then(function(){
+			this.moduleSelectAG = null;
+		}.bind(this));
+
+		// this.moduleSelectAG = o2.AG.all(optionItems).then(function(options){
+		// 	this.moduleSelectAG = null;
+		// 	if (!options) options = [];
+		// 	if (o2.typeOf(options)==="array"){
+		// 		options.each(function(item){
+		// 			var tmps = item.split("|");
+		// 			var text = tmps[0];
+		// 			var value = tmps[1] || text;
+		//
+		// 			var option = new Element("option", {
+		// 				"value": value,
+		// 				"text": text
+		// 			}).inject(this.node);
+		// 		}.bind(this));
+		// 		this.fireEvent("setOptions", [options])
+		// 	}
+		// }.bind(this));
+		// if (this.moduleSelectAG) this.moduleSelectAG.then(function(){
+		// 	this.moduleSelectAG = null;
+		// }.bind(this));
 	},
+	// __setOptions: function(){
+	// 	var optionItems = this.getOptions();
+    //     if (!optionItems) optionItems = [];
+    //     if (o2.typeOf(optionItems)==="array"){
+	// 		optionItems.each(function(item){
+	// 			var tmps = item.split("|");
+	// 			var text = tmps[0];
+	// 			var value = tmps[1] || text;
+	//
+	// 			var option = new Element("option", {
+	// 				"value": value,
+	// 				"text": text
+	// 			}).inject(this.node);
+	// 		}.bind(this));
+	// 		this.fireEvent("setOptions", [optionItems])
+	// 	}
+	// },
 	addOption: function(text, value){
         var option = new Element("option", {
             "value": value || text,
@@ -153,21 +201,83 @@ MWF.xApplication.process.Xform.Select = MWF.APPSelect =  new Class({
         }).inject(this.node);
 		this.fireEvent("addOption", [text, value])
 	},
+
 	_setValue: function(value){
+		var p = o2.promiseAll(value).then(function(v){
+			if (o2.typeOf(v)=="array") v = v[0];
+			if (this.moduleSelectAG){
+				this.moduleValueAG = this.moduleSelectAG;
+				this.moduleSelectAG.then(function(){
+					this.__setValue(v);
+					return v;
+				}.bind(this));
+			}else{
+				this.__setValue(v)
+			}
+			return v;
+		}.bind(this));
+
+		this.moduleValueAG = p;
+		if (this.moduleValueAG) this.moduleValueAG.then(function(){
+			this.moduleValueAG = null;
+		}.bind(this));
+
+		// this.moduleValueAG = o2.AG.all(value).then(function(v){
+		// 	if (o2.typeOf(v)=="array") v = v[0];
+		// 	if (this.moduleSelectAG){
+		// 		this.moduleValueAG = this.moduleSelectAG;
+		// 		this.moduleSelectAG.then(function(){
+		// 			this.__setValue(v);
+		// 		}.bind(this));
+		// 	}else{
+		// 		this.__setValue(v)
+		// 	}
+		// 	return v;
+		// }.bind(this));
+
+		// if (value && value.isAG){
+		// 	this.moduleValueAG = o2.AG.all(value),then(function(v){
+		// 		this._setValue(v);
+		// 	}.bind(this));
+		// 	// this.moduleValueAG = value;
+		// 	// value.addResolve(function(v){
+		// 	// 	this._setValue(v);
+		// 	// }.bind(this));
+		// }else{
+		//
+		// }
+	},
+	__setValue: function(value){
 		if (!this.readonly && !this.json.isReadonly ) {
-            this._setBusinessData(value);
-            for (var i=0; i<this.node.options.length; i++){
-                var option = this.node.options[i];
-                if (option.value==value){
-                    option.selected = true;
-                    //	break;
-                }else{
-                    option.selected = false;
-                }
-            }
-        }
-		//this.node.set("value", value);
+			this._setBusinessData(value);
+			for (var i=0; i<this.node.options.length; i++){
+				var option = this.node.options[i];
+				if (option.value==value){
+					option.selected = true;
+					//	break;
+				}else{
+					option.selected = false;
+				}
+			}
+		}
+		this.moduleValueAG = null;
 	},
+
+	// _setValue: function(value){
+	// 	if (!this.readonly && !this.json.isReadonly ) {
+    //         this._setBusinessData(value);
+    //         for (var i=0; i<this.node.options.length; i++){
+    //             var option = this.node.options[i];
+    //             if (option.value==value){
+    //                 option.selected = true;
+    //                 //	break;
+    //             }else{
+    //                 option.selected = false;
+    //             }
+    //         }
+    //     }
+	// 	//this.node.set("value", value);
+	// },
 	getTextData: function(){
 		var value = [];
 		var text = [];
@@ -208,6 +318,7 @@ MWF.xApplication.process.Xform.Select = MWF.APPSelect =  new Class({
 		return (value.length==1) ? value[0] : value;
 	},
     resetData: function(){
+		debugger;
         this.setData(this.getValue());
     },
 	getOptionsObj : function(){
@@ -224,7 +335,29 @@ MWF.xApplication.process.Xform.Select = MWF.APPSelect =  new Class({
 		}
 		return { textList : textList, valueList : valueList };
 	},
+
 	setData: function(data){
+		return this._setValue(data);
+		// if (data && data.isAG){
+		// 	this.moduleValueAG = o2.AG.all(data).then(function(v){
+		// 		if (o2.typeOf(v)=="array") v = v[0];
+		// 		this.__setData(v);
+		// 	}.bind(this));
+		// }else{
+		// 	this.__setData(data);
+		// }
+		// if (data && data.isAG){
+		// 	this.moduleValueAG = data;
+		// 	data.addResolve(function(v){
+		// 		this.setData(v);
+		// 	}.bind(this));
+		// }else{
+		// 	this.__setData(data);
+		// 	this.moduleValueAG = null;
+		// }
+	},
+
+	__setData: function(data){
         this._setBusinessData(data);
 		if (this.readonly|| this.json.isReadonly){
 			var d = typeOf(data) === "array" ? data : [data];
@@ -234,7 +367,7 @@ MWF.xApplication.process.Xform.Select = MWF.APPSelect =  new Class({
 				var idx = ops.valueList.indexOf( v );
 				result.push( idx > -1 ? ops.textList[idx] : v);
 			})
-			this.node.set("text", result.join(","))
+			this.node.set("text", result.join(","));
 		}else{
 			var ops = this.node.getElements("option");
 			ops.each(function(op){

+ 65 - 6
o2web/source/x_component_process_Xform/Textarea.js

@@ -4,7 +4,6 @@ MWF.xApplication.process.Xform.Textarea = MWF.APPTextarea =  new Class({
 	Extends: MWF.APP$Input,
 	
 	_loadUserInterface: function(){
-
 		this._loadNode();
         if (this.json.compute == "show"){
             this._setValue(this._computeValue());
@@ -22,17 +21,77 @@ MWF.xApplication.process.Xform.Textarea = MWF.APPTextarea =  new Class({
     _loadNodeRead: function(){
         this.node.empty();
     },
+
+
     _setValue: function(value){
-        this._setBusinessData(value);
-        if (this.node.getFirst()) this.node.getFirst().set("value", value || "");
-        if (this.readonly || this.json.isReadonly){
+        var p = o2.promiseAll(value).then(function(v){
+            if (o2.typeOf(v)=="array") v = v[0];
+            this._setBusinessData(v);
+            if (this.node.getFirst()) this.node.getFirst().set("value", v || "");
+            if (this.readonly || this.json.isReadonly){
                 var reg = new RegExp("\n","g");
                 var reg2 = new RegExp("\u003c","g"); //尖括号转义,否则内容会截断
                 var reg3 = new RegExp("\u003e","g");
                 var text = value.replace(reg2,"&lt").replace(reg3,"&gt").replace(reg,"<br/>");
                 this.node.set("html", text);
-        }
+            }
+            //this.__setValue(v);
+        }.bind(this));
+        this.moduleValueAG = p;
+        p.then(function(){
+            this.moduleValueAG = null;
+        }.bind(this));
+
+        // this.moduleValueAG = o2.AG.all(value).then(function(v){
+        //     this.moduleValueAG = null;
+        //     if (o2.typeOf(v)=="array") v = v[0];
+        //     this._setBusinessData(v);
+        //     if (this.node.getFirst()) this.node.getFirst().set("value", v || "");
+        //     if (this.readonly || this.json.isReadonly){
+        //         var reg = new RegExp("\n","g");
+        //         var reg2 = new RegExp("\u003c","g"); //尖括号转义,否则内容会截断
+        //         var reg3 = new RegExp("\u003e","g");
+        //         var text = value.replace(reg2,"&lt").replace(reg3,"&gt").replace(reg,"<br/>");
+        //         this.node.set("html", text);
+        //     }
+        // }.bind(this));
+        //
+        // if (this.moduleValueAG) this.moduleValueAG.then(function(){
+        //     this.moduleValueAG = null;
+        // }.bind(this));
+
+        return value;
+
+        // if (value && value.isAG){
+        //     this.moduleValueAG = value;
+        //     value.addResolve(function(v){
+        //         this._setValue(v);
+        //     }.bind(this));
+        // }else{
+        //     this._setBusinessData(value);
+        //     if (this.node.getFirst()) this.node.getFirst().set("value", value || "");
+        //     if (this.readonly || this.json.isReadonly){
+        //         var reg = new RegExp("\n","g");
+        //         var reg2 = new RegExp("\u003c","g"); //尖括号转义,否则内容会截断
+        //         var reg3 = new RegExp("\u003e","g");
+        //         var text = value.replace(reg2,"&lt").replace(reg3,"&gt").replace(reg,"<br/>");
+        //         this.node.set("html", text);
+        //     }
+        //     return value;
+        // }
     },
+
+    // _setValue: function(value){
+    //     this._setBusinessData(value);
+    //     if (this.node.getFirst()) this.node.getFirst().set("value", value || "");
+    //     if (this.readonly || this.json.isReadonly){
+    //             var reg = new RegExp("\n","g");
+    //             var reg2 = new RegExp("\u003c","g"); //尖括号转义,否则内容会截断
+    //             var reg3 = new RegExp("\u003e","g");
+    //             var text = value.replace(reg2,"&lt").replace(reg3,"&gt").replace(reg,"<br/>");
+    //             this.node.set("html", text);
+    //     }
+    // },
     _resetNodeEdit: function(){
         var input = new Element("textarea", {"styles": {
                 "background": "transparent",
@@ -130,4 +189,4 @@ MWF.xApplication.process.Xform.Textarea = MWF.APPTextarea =  new Class({
         }
     }
 	
-}); 
+}); 

+ 1 - 0
o2web/source/x_desktop/index.html

@@ -66,6 +66,7 @@
         }
     </script>
 
+    <script src="../o2_lib/polyfill/polyfill.js"></script>
     <script src="../o2_core/o2.min.js"></script>
     <script src="js/base.min.js"></script>
     <script src="js/x.min.js"></script>

+ 13 - 1
o2web/source/x_desktop/res/config/config.json

@@ -19,5 +19,17 @@
     "enable": false,
     "portal": "b82d7669-85d6-4c10-8151-c4d1f18ba6ef",
     "page": ""
+  },
+  "mock": {
+    "x_processplatform_assemble_surface": {
+      "put": {
+        "to": "post",
+        "append": "mockputtopost"
+      },
+      "delete": {
+        "to": "get",
+        "append": "mockdeletetoget"
+      }
+    }
   }
-}
+}

Некоторые файлы не были показаны из-за большого количества измененных файлов