huqi 5 лет назад
Родитель
Сommit
12d0cf7346

BIN
o2web/source/o2_core/o2/widget/$Tree/findDesigner/blank.gif


BIN
o2web/source/o2_core/o2/widget/$Tree/findDesigner/blankOperate.gif


BIN
o2web/source/o2_core/o2/widget/$Tree/findDesigner/collapse.gif


+ 55 - 0
o2web/source/o2_core/o2/widget/$Tree/findDesigner/css.wcss

@@ -0,0 +1,55 @@
+{
+	"areaNode": {
+		"cursor": "pointer",
+		"margin": "10px"
+	},
+
+	"treeNode": {
+		"line-height": "24px"
+	},
+	
+	"treeItemNode":{
+		"height": "24px"
+	},
+	"treeChildrenNode": {
+	},
+	"blankLevelNode": {
+		"height": "24px",
+		"width": "15px"
+	},
+	"operateNode": {
+		"height": "24px",
+		"width": "20px",
+		"background-position": "center 2px",
+		"background-repeat": "no-repeat"
+	},
+	"nodeTable": {},
+	"iconNode": {
+		"height": "24px",
+		"width": "20px",
+		"background-position": "center center"
+	},
+	"textNode": {
+		"height": "24px"
+	},
+	"textDivNode": {
+		"line-height": "24px",
+		"font-size":"12px",
+		"word-break": "keep-all",
+		"white-space": "nowrap",
+		"padding-left": "5px",
+		"padding-right": "5px",
+		"background": "transparent",
+		"color": "#000"
+	},
+	"textDivNodeSelected": {
+		"line-height": "24px",
+		"font-size":"12px",
+		"word-break": "keep-all",
+		"white-space": "nowrap",
+		"padding-left": "5px",
+		"padding-right": "5px",
+		"background": "#dddddd",
+		"color": "#FFF"
+	}
+}

BIN
o2web/source/o2_core/o2/widget/$Tree/findDesigner/expand.gif


+ 7 - 5
o2web/source/o2_core/o2/widget/Tree.js

@@ -229,8 +229,9 @@ o2.widget.Tree.Node = new Class({
 			"border": "0",
 			"cellpadding": "0",
 			"cellspacing": "0",
-			"styles": this.tree.css.nodeTable
+			"styles": {"width": "fit-content", "table-layout": "fixed"}
 		}).inject(this.itemNode);
+		this.nodeTable.setStyles(this.tree.css.nodeTable);
 
         if (this.options.style){
             if (this.tree.css[this.options.style]){
@@ -312,12 +313,13 @@ o2.widget.Tree.Node = new Class({
         }
 	//	var width = this.tree.container.getSize().x - (this.level*20+40);
 	//	this.textNode.setStyle("width", ""+width+"px");
-		
+
 		var textDivNode = new Element("div", {
-			"styles": this.tree.css.textDivNode,
-		//	"html": this.options.text,
+			"styles": {"display": "inline-block"},
+			//	"html": this.options.text,
 			"title": this.options.title
 		});
+		textDivNode.setStyles(this.tree.css.textDivNode);
         if (this.options.style){
             if (this.tree.css[this.options.style]){
                 textDivNode.setStyles(this.tree.css[this.options.style].textDivNode);
@@ -450,4 +452,4 @@ o2.widget.Tree.Node = new Class({
 		this.node.destroy();
 		delete this;
 	}
-});
+});

+ 7 - 3
o2web/source/o2_core/o2/widget/Tree2.js

@@ -62,8 +62,10 @@ o2.widget.Tree2.Node = new Class({
 			"border": "0",
 			"cellpadding": "0",
 			"cellspacing": "0",
-			"styles": this.tree.css.nodeTable
+			"styles": {"width": "fit-content", "table-layout": "fixed"}
 		}).inject(this.itemNode);
+		this.nodeTable.setStyles(this.tree.css.nodeTable);
+
 		var tbody = new Element("tbody").inject(this.nodeTable);
 		this.nodeArea = new Element("tr").inject(tbody);
 		
@@ -130,10 +132,12 @@ o2.widget.Tree2.Node = new Class({
 	//	this.textNode.setStyle("width", ""+width+"px");
 		
 		var textDivNode = new Element("div", {
-			"styles": this.tree.css.textDivNode,
+			"styles": {"display": "inline-block"},
 		//	"html": this.options.text,
 			"title": this.options.title
 		});
+		textDivNode.setStyles(this.tree.css.textDivNode);
+
         if (this.tree.options.text=="html"){
             textDivNode.set("html", this.options.text);
         }else{
@@ -242,4 +246,4 @@ o2.widget.Tree2.Node = new Class({
 		this.node.destroy();
 		delete this;
 	}
-});
+});

+ 0 - 1
o2web/source/x_component_FindDesigner/$Main/default/style.css

@@ -297,7 +297,6 @@
     text-align: center;
 }
 .listContentNode {
-    overflow: hidden;
 }
 .loadding {
     background-repeat: no-repeat;

+ 109 - 65
o2web/source/x_component_FindDesigner/FindWorker.js

@@ -109,7 +109,7 @@ _worker._createFilterOption = function(moduleType, appId, desingerType, desinger
     var filterOption = JSON.parse(_worker.filterOptionTemplete);
     filterOption.moduleList.push({
         "moduleType": moduleType,
-        "moduleAppList": [{"appId": appId, "designerList": [{"desingerType": desingerType, "designerIdList": desingerId}]}]
+        "moduleAppList": [{"appId": appId, "designerList": [{"desingerType": desingerType, "designerIdList": [desingerId]}]}]
     });
     this.filterOptionList.push(filterOption);
     return filterOption;
@@ -212,20 +212,20 @@ _worker._parseFindModule = function(moduleList){
                 var filterOption = JSON.parse(_worker.filterOptionTemplete);
                 filterOption.moduleList.push({
                     "moduleType": module.moduleType,
-                    "flagList": ["invoke"]
+                    "moduleAppList": [{"appId": "invoke"}]
                 });
                 this.filterOptionList.push(filterOption);
 
                 var filterOption = JSON.parse(_worker.filterOptionTemplete);
                 filterOption.moduleList.push({
                     "moduleType": module.moduleType,
-                    "flagList": ["agent"]
+                    "moduleAppList": [{"appId": "agent"}]
                 });
                 this.filterOptionList.push(filterOption);
 
-                promiseArr.push(Promise.resolve(""));
-                // promiseArr = promiseArr.concat(_worker["_getDesinger_"+module.moduleType]("invoke"));
-                // promiseArr = promiseArr.concat(_worker["_getDesinger_"+module.moduleType]("agent"));
+                //promiseArr.push(Promise.resolve(""));
+                promiseArr = promiseArr.concat(_worker["_getDesinger_"+module.moduleType]("invoke"));
+                promiseArr = promiseArr.concat(_worker["_getDesinger_"+module.moduleType]("agent"));
             }else{
                 module.flagList.forEach(function(flag){
                     if (!flag.designerList || !flag.designerList.length){
@@ -243,23 +243,23 @@ _worker._parseFindModule = function(moduleList){
                 var p = _worker._listApplication(module.moduleType);
                 promiseArr.push(p.then(function(json){
 
-                    json.data.forEach(function(app){
-                        var filterOption = JSON.parse(_worker.filterOptionTemplete);
-                        filterOption.moduleList.push({
-                            "moduleType": module.moduleType,
-                            "flagList": [app.id]
-                        });
-                        this.filterOptionList.push(filterOption);
-                    });
-                    return Promise.resolve("");
+                    // json.data.forEach(function(app){
+                    //     var filterOption = JSON.parse(_worker.filterOptionTemplete);
+                    //     filterOption.moduleList.push({
+                    //         "moduleType": module.moduleType,
+                    //         "moduleAppList": [{"appId": app.id}]
+                    //     });
+                    //     this.filterOptionList.push(filterOption);
+                    // });
+                    // return Promise.resolve("");
                     //临时处理
 
 
-                    // var pArr = [];
-                    // json.data.forEach(function(app){
-                    //     pArr = pArr.concat(_worker["_getDesinger_"+module.moduleType](app.id));
-                    // });
-                    // return Promise.all(pArr);
+                    var pArr = [];
+                    json.data.forEach(function(app){
+                        pArr = pArr.concat(_worker["_getDesinger_"+module.moduleType](app.id));
+                    });
+                    return Promise.all(pArr);
                 }, function(){}));
 
             }else{
@@ -279,26 +279,35 @@ _worker._parseFindModule = function(moduleList){
     return promiseArr;
 }
 
-_worker._findMessageReply = function(data){
+_worker._findMessageReply = function(data, option){
+    _worker.setTimeout(function(){
+        _worker.postMessage({
+            "type": "find",
+            "data": data,
+            "option": option
+        });
+    }, 200);
+};
+_worker._findOptionReply = function(){
     _worker.postMessage({
-        "type": "find",
-        "data": data
+        "type": "done"
     });
 };
 
-_worker._createFindMessageReplyData = function(designer, pattern){
+
+
+_worker._createFindMessageReplyData = function(module, designer, aliase, pattern){
     return {
-        "module": "processPlatform",
+        "module": module,
         "appId": designer.appId,
         "appName": designer.appName,
         "designerId": designer.designerId,
         "designerName": designer.designerName,
         "designerType": designer.designerType,
-        "pattern": {
-            "property": pattern.property,
-            "value": json.data[pattern.property]
-        }
-    }
+        "designerAliase": aliase,
+
+        "pattern": pattern
+    };
 };
 
 _worker._setFilterOptionRegex = function(){
@@ -308,7 +317,7 @@ _worker._setFilterOptionRegex = function(){
         this.keywordRegexp =  new RegExp(keyword, flag);
     }else{
         var flag = (_worker.findData.filterOption.caseSensitive) ? "g" : "gi";
-        keyword = (_worker.findData.filterOption.matchWholeWord) ? "\\b"+keyword+"\\b";
+        keyword = (_worker.findData.filterOption.matchWholeWord) ? "\\b"+keyword+"\\b" : keyword;
         this.keywordRegexp = new RegExp(keyword, flag);
     }
 };
@@ -316,18 +325,19 @@ _worker._setFilterOptionRegex = function(){
 _worker._findProcessPlatformParse_script = function(designer){
     if (designer.patternList && designer.patternList.length){
         var action = this.findData.actions.getProcessScript;
-        var p = _worker.action.sendRequest(_worker._getRequestOption({"url": action}, {"id": designer.designerId}););
+
+        var p = _worker.action.sendRequest(_worker._getRequestOption({"url": action}, {"id": designer.designerId}));
         p.then(function(json){
-            designer.patternList.each(function(pattern){
+            designer.patternList.forEach(function(pattern){
                 if (pattern.property=="text"){
-                    var scriptLines = json.data.text.split(/\s*\n\s*/);
-                    pattern.lines.each(function(line){
+                    var scriptLines = json.data.text.split(/\n/);
+                    pattern.lines.forEach(function(line){
                         var scriptText = scriptLines[line-1];
                         while ((arr = this.keywordRegexp.exec(scriptText)) !== null) {
                             var col = arr.index;
                             var key = arr[0];
                             var value = arr.input;
-                            _worker._findMessageReply(_worker._createFindMessageReplyData(designer, {
+                            _worker._findMessageReply(_worker._createFindMessageReplyData("processPlatform", designer, json.data.aliase, {
                                 "property": pattern.property,
                                 "value": value,
                                 "line": line,
@@ -337,7 +347,7 @@ _worker._findProcessPlatformParse_script = function(designer){
                         }
                     });
                 }else{
-                    _worker._findMessageReply(_worker._createFindMessageReplyData(designer, {
+                    _worker._findMessageReply(_worker._createFindMessageReplyData("processPlatform", designer, json.data.aliase, {
                         "property": pattern.property,
                         "value": json.data[pattern.property]
                     }));
@@ -356,7 +366,7 @@ _worker._findProcessPlatformParse_process = function(designer){
 };
 
 _worker._findProcessPlatformParse = function(resultList){
-    resultList.each(function(designer){
+    resultList.forEach(function(designer){
         switch (designer.designerType){
             case "script":
                 _worker._findProcessPlatformParse_script(designer);
@@ -372,40 +382,71 @@ _worker._findProcessPlatformParse = function(resultList){
 };
 
 
-_worker._doFindDesigner = function(option){
-    var res = _worker._getRequestOption({
-        "method": "post",
-        "url": this.findData.actions.findAction,
-        "body": JSON.stringify(option),
-        "debug": this.findData.debug,
-        "token": this.findData.token
-    });
-    this.action.sendRequest(res).then(function(json){
-        if (json.data.processPlatformList && json.data.processPlatformList.length){
-            _worker._findProcessPlatformParse(json.data.processPlatformList);
-        }
-        if (json.data.cmsList && json.data.cmsList.length){
+_worker._doFindDesigner = function(option, idx){
 
-        }
-        if (json.data.portalList && json.data.portalList.length){
+    var option = this.filterOptionList[idx];
+
+        var res = _worker._getRequestOption({
+            "method": "post",
+            "url": this.findData.actions.findAction,
+            "body": JSON.stringify(option),
+            "debug": this.findData.debug,
+            "token": this.findData.token
+        });
+        this.action.sendRequest(res).then(function(json){
+            if (json.data.processPlatformList && json.data.processPlatformList.length){
+
+                // var worker = new Worker("../x_component_FindDesigner/PatternWorker.js");
+                // worker.onmessage = function(e) {
+                //     if (e.data) _worker._findMessageReply(e.data, option);
+                // }.bind(this);
+                // worker.postMessage({
+                //     "parser": "_findProcessPlatformParse",
+                //     "actions": _worker.findData.actions,
+                //     "option": option,
+                //     "pattern": json.data.processPlatformList
+                // });
+
+               _worker._findProcessPlatformParse(json.data.processPlatformList);
+            }
+            if (json.data.cmsList && json.data.cmsList.length){
+
+            }
+            if (json.data.portalList && json.data.portalList.length){
+
+            }
+            if (json.data.queryList && json.data.queryList.length){
+
+            }
+            if (json.data.serviceList && json.data.serviceList.length){
+
+            }
+            _worker._findOptionReply();
+
+            idx++;
+            if (this.filterOptionList.length>idx)  _worker._doFindDesigner(null, idx);
+            //this.filterOptionList[idx];
+
+            //_worker._findMessageReply(json.data, option);
+        }, function(xhr){
+            _worker._findOptionReply(null);
+            _worker._findMessageReply(null);
+
+            idx++;
+            if (this.filterOptionList.length>idx)  _worker._doFindDesigner(null, idx);
+        });
 
-        }
-        if (json.data.queryList && json.data.queryList.length){
 
-        }
-        if (json.data.serviceList && json.data.serviceList.length){
 
-        }
-        _worker._findMessageReply({"option": option, "data": json.data});
-    }, function(xhr){
-        _worker._findMessageReply({"option": option, "data": null});
-    });
 },
 
 _worker._doFindDesignerFromFilterOption = function(){
-    this.filterOptionList.forEach(function(option){
-        _worker._doFindDesigner(option);
-    });
+    var idx = 0;
+    //this.filterOptionList.forEach(function(option){
+    //    _worker._doFindDesigner(option, idx);
+    //});
+
+    _worker._doFindDesigner(null, idx);
 },
 onmessage = function(e) {
     this.findData = e.data;
@@ -417,6 +458,9 @@ onmessage = function(e) {
     this.filterOptionList = [];
 
     Promise.all(_worker._parseFindModule(moduleList)).then(function(){
+        // this.filterOptionList[0].moduleList=[];
+        // //_worker._doFindDesigner(this.filterOptionList[0]);
+        // this.filterOptionList = [this.filterOptionList[0]];
         _worker._readyMessageReply();
         _worker._doFindDesignerFromFilterOption();
     });

+ 121 - 20
o2web/source/x_component_FindDesigner/Main.js

@@ -348,38 +348,137 @@ MWF.xApplication.FindDesigner.Main = new Class({
 		this.findWorker.onmessage = function(e) {
 			if (e.data && e.data.type=="receive") this.setReceiveMessage();
 			if (e.data && e.data.type=="ready") this.setReadyMessage(e.data);
+			if (e.data && e.data.type=="done") this.doFindOptionResult(e.data);
 			if (e.data && e.data.type=="find") this.doFindResult(e.data);
 		}.bind(this);
 	},
-	doFindResult: function(data){
+	doFindOptionResult: function(){
+		// this.listInfoNode.hide();
+		// this.listContentNode.show();
+		// moduleNode = this.createResultCategroyItem("xxxx", "", this.tree);
 		this.findOptionModuleProcessed++;
 		this.updateFindProgress();
-		this.showFindResult(data);
+	},
+	doFindResult: function(data){
+		if (data.data) this.showFindResult(data.data);
 	},
 
 	getResultTree: function(callback){
 		if (!this.tree){
 			o2.require("o2.widget.Tree", function(){
 				this.tree = new o2.widget.Tree(this.listContentNode, {
+					"style": "findDesigner"
 					// "onQueryExpand": function(item){
 					// 	if (item.designer) this.loadDesignerPattern(item);
 					// }.bind(this)
 				});
 				this.tree.load();
 				if (callback) callback();
-			}.bind(this));
+			}.bind(this), null, false);
 		}else{
 			if (callback) callback();
 		}
 	},
+	createResultCategroyItem: function(text, title, tree){
+		var obj = {
+			"title": title,
+			"text": "<span style='font-weight: bold'>"+text+"</span>",
+			"icon": ""
+		}
+		return tree.appendChild(obj);
+	},
+	createResultAppItem: function(text, title, tree){
+		var obj = {
+			"title": title,
+			"text": "<span style='font-weight: bold; color: #0b58a2'>"+text+"</span>",
+			"icon": ""
+		}
+		return tree.appendChild(obj);
+	},
+	createResultTypeItem: function(text, title, tree){
+		var obj = {
+			"title": title,
+			"text": "<span>"+text+"</span>",
+			"icon": ""
+		}
+		return tree.appendChild(obj);
+	},
+	createResultPatternItem: function(text, title, tree){
+		var obj = {
+			"title": title,
+			"text": "<span style='color: #666666'>"+text+"</span>",
+			"icon": ""
+		}
+		return tree.appendChild(obj);
+	},
+	showFindResult: function(data){
+		if (!this.patternCount) this.patternCount = 0;
+		this.patternCount++;
+		var t = this.lp.findPatternCount.replace("{n}", this.patternCount);
+		this.listTitleInfoNode.set("text", t);
 
-	showFindResult: function(){
+		this.listInfoNode.hide();
+		this.listContentNode.show();
+		// this.listContentNode.appendHTML("<div>2</div>");
+		//return "";
+		//this.getResultTree(function(){
+			var moduleNode = (this.tree.modules) ? this.tree.modules[data.module] : null;
+			if (!moduleNode){
+				moduleNode = this.createResultCategroyItem(this.lp[data.module], this.lp[data.module], this.tree);
+				if (!this.tree.modules) this.tree.modules = {};
+				this.tree.modules[data.module] = moduleNode;
+			}
+			var appNode = (moduleNode.apps) ? moduleNode.apps[data.appId] : null;
+			if (!appNode){
+				appNode = this.createResultAppItem(data.appName, data.appName, moduleNode);
+				if (!moduleNode.apps) moduleNode.apps = {};
+				moduleNode.apps[data.appId] = appNode;
+			}
 
+			var typeNode = (appNode.types) ? appNode.types[data.designerType] : null;
+			if (!typeNode){
+				typeNode = this.createResultTypeItem(this.lp[data.designerType], this.lp[data.designerType], appNode);
+				if (!appNode.types) appNode.types = {};
+				appNode.types[data.designerType] = typeNode;
+			}
 
-	},
+			var designerNode = (typeNode.designers) ? typeNode.designers[data.designerId] : null;
+			if (!designerNode){
+				designerNode = this.createResultTypeItem(data.designerName, data.designerName, typeNode);
+				if (!typeNode.designers) typeNode.designers = {};
+				typeNode.designers[data.designerId] = designerNode;
+			}
+
+
+			switch (data.designerType){
+				case "script":
+					this.createScriptPatternNode(data, designerNode);
+					break;
+				case "form":
+
+					break;
+				case "process":
 
+					break;
+
+			}
+
+		//}.bind(this));
+	},
+	createScriptPatternNode: function(data, node){
+		var patternNode;
+		var text;
+		if (data.pattern.property=="text"){
+			text = data.pattern.line+" "+data.pattern.value;
+			patternNode = this.createResultPatternItem(text, "", node);
+		}else{
+			text = "<b>"+data.pattern.property+"</b> "+data.pattern.value;
+			patternNode = this.createResultPatternItem(text, "", node);
+		}
 
 	},
+
+
 	setReceiveMessage: function(){
 		this.listTitleInfoNode.set("text", this.lp.receiveToFind);
 	},
@@ -444,16 +543,25 @@ MWF.xApplication.FindDesigner.Main = new Class({
 	},
 
 	findDesigner: function(){
+		this.listContentNode.hide();
+		this.listContentNode.empty();
+		this.listInfoNode.show().getFirst().set("text", "");
+		this.listInfoNode.addClass("loadding");
+		this.patternCount = 0;
+
 		this.getFindWorker();
 		var actions = this.getActionsUrl();
 
-		var workerMessage = {
-			actions:actions,
-			filterOption: this.filterOption,
-			debug: (window.layout && layout["debugger"]),
-			token: (window.layout && layout.session && layout.session.user) ? layout.session.user.token : ""
-		};
-		this.findWorker.postMessage(workerMessage);
+		this.tree = null;
+		this.getResultTree(function(){
+			var workerMessage = {
+				actions:actions,
+				filterOption: this.filterOption,
+				debug: (window.layout && layout["debugger"]),
+				token: (window.layout && layout.session && layout.session.user) ? layout.session.user.token : ""
+			};
+			this.findWorker.postMessage(workerMessage);
+		}.bind(this));
 	},
 
 	//------------------------------------------------------------
@@ -478,14 +586,7 @@ MWF.xApplication.FindDesigner.Main = new Class({
 		}.bind(this));
 	},
 
-	createResultCategroyItem: function(text, title, tree){
-		var obj = {
-			"title": title,
-			"text": "<span style='font-weight: bold'>"+text+"</span>",
-			"icon": ""
-		}
-		return tree.appendChild(obj);
-	},
+
 	createResultAppItem: function(text, title, tree){
 		var obj = {
 			"title": title,

+ 431 - 0
o2web/source/x_component_FindDesigner/PatternWorker.js

@@ -0,0 +1,431 @@
+var _worker = self;
+var _action = {
+    _checkRequest: function(s,f){
+        if (this.request.readyState === XMLHttpRequest.DONE) {
+            if (this.request.status === 200) {
+                this._doneRequest(s);
+            } else {
+                this._errorRequest(f);
+            }
+        }
+    },
+    _createRequest: function(s, f){
+        var request = new XMLHttpRequest();
+        request.addEventListener("readystatechange",function(){
+            if (this.readyState === XMLHttpRequest.DONE) {
+                if (this.status === 200) {
+                    var json = JSON.parse(this.responseText);
+                    var xToken = this.getResponseHeader("x-token");
+                    if (xToken){
+                        json.xToken = xToken;
+                    }
+                    if (s) s(json);
+                } else {
+                    if (f) f(this, this.responseText);
+                }
+            }
+        });
+        return request
+    },
+    sendRequest: function(data){
+        return new Promise(function(s, f){
+            var request = this._createRequest(s, f);
+            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());
+
+            request.open(method, url, async);
+
+            request.withCredentials = withCredentials;
+            request.setRequestHeader("Content-Type", "application/json; charset=utf-8");
+            request.setRequestHeader("Accept", "text/html,application/json,*/*");
+            if (debug) request.setRequestHeader("x-debugger", "true");
+            if (token){
+                request.setRequestHeader("x-token", token);
+                request.setRequestHeader("authorization", token);
+            }
+
+            request.send(body);
+        }.bind(this));
+    },
+
+    _doneRequest: function(s){
+        var json = JSON.parse(this.request.responseText);
+        var xToken = this.request.getResponseHeader("x-token");
+        if (xToken){
+            json.xToken = xToken;
+        }
+        if (s) s(json);
+        // _worker.postMessage({"type": "done", "data": json});
+        // _worker.close();
+    },
+    _errorRequest: function(f){
+        if (s) s(this.request, this.request.responseText);
+        // _worker.postMessage({"type":"error", "data": {"status":  this.request.status, "statusText":  this.request.statusText, "responseText":this.request.responseText}});
+        // _worker.close();
+    }
+};
+
+_worker.action = _action;
+
+_worker._receiveMessageReply = function(){
+    _worker.postMessage({
+        "type": "receive"
+    });
+};
+_worker._readyMessageReply = function(){
+    _worker.postMessage({
+        "type": "ready",
+        "count": this.filterOptionList.length
+    });
+};
+
+_worker._getRequestOption = function(data, par){
+    if (par){
+        Object.keys(par).forEach(function(k){
+            data.url = data.url.replace("{"+k+"}", par[k]);
+        });
+    }
+    return {
+        "method": data.method||"get",
+        "noCache": false,
+        "loadAsync": true,
+        "credentials": true,
+        "address": data.url,
+        "body": data.body || "",
+        "debug": data.debug || _worker.findData.debug,
+        "token": data.token || _worker.findData.token
+    };
+};
+
+_worker._createFilterOption = function(moduleType, appId, desingerType, desingerId){
+    var filterOption = JSON.parse(_worker.filterOptionTemplete);
+    filterOption.moduleList.push({
+        "moduleType": moduleType,
+        "moduleAppList": [{"appId": appId, "designerList": [{"desingerType": desingerType, "designerIdList": [desingerId]}]}]
+    });
+    this.filterOptionList.push(filterOption);
+    return filterOption;
+};
+_worker._getDesingerModule = function(id, restful, par, moduleType, desingerType){
+    var p = _worker.action.sendRequest(_worker._getRequestOption({"url": restful, "debug": _worker.findData.debug, "token": _worker.findData.token }, par));
+    return p.then(function(json){
+        list = json.data;
+        list.forEach(function(designer){
+            _worker._createFilterOption(moduleType, id, desingerType, designer.id)
+        });
+    }, function(){});
+};
+
+_worker._getDesinger_processPlatform = function(id){
+    var promiseArr = [];
+    if (_worker.findData.filterOption.designerTypes.indexOf("script")!=-1){    //所有脚本
+        promiseArr.push(_worker._getDesingerModule(id, _worker.findData.actions.listProcessScript, {"applicationId": id}, "processPlatform", "script"));
+    }
+    if (_worker.findData.filterOption.designerTypes.indexOf("form")!=-1){      //所有表单
+        promiseArr.push(_worker._getDesingerModule(id, _worker.findData.actions.listProcessForm, {"applicationId": id}, "processPlatform", "form"));
+    }
+    if (_worker.findData.filterOption.designerTypes.indexOf("process")!=-1){   //所有流程
+        promiseArr.push(_worker._getDesingerModule(id, _worker.findData.actions.listProcessProcess, {"applicationId": id}, "processPlatform", "process"));
+    }
+    return promiseArr;
+};
+
+_worker._getDesinger_cms = function(id){
+    var promiseArr = [];
+    if (_worker.findData.filterOption.designerTypes.indexOf("script")!=-1){    //所有脚本
+        promiseArr.push(_worker._getDesingerModule(id, _worker.findData.actions.listCmsScript, {"flag": id}, "cms", "script"));
+    }
+    if (_worker.findData.filterOption.designerTypes.indexOf("form")!=-1){      //所有表单
+        promiseArr.push(_worker._getDesingerModule(id, _worker.findData.actions.listCmsForm, {"appId": id}, "cms", "form"));
+    }
+    return promiseArr;
+};
+
+_worker._getDesinger_portal = function(id){
+    var promiseArr = [];
+    if (_worker.findData.filterOption.designerTypes.indexOf("script")!=-1){    //所有脚本
+        promiseArr.push(_worker._getDesingerModule(id, _worker.findData.actions.listPortalScript, {"portalId": id}, "portal", "script"));
+    }
+    if (_worker.findData.filterOption.designerTypes.indexOf("page")!=-1){      //所有表单
+        promiseArr.push(_worker._getDesingerModule(id, _worker.findData.actions.listPortalPage, {"portalId": id}, "portal", "page"));
+    }
+    if (_worker.findData.filterOption.designerTypes.indexOf("widget")!=-1){   //所有流程
+        promiseArr.push(_worker._getDesingerModule(id, _worker.findData.actions.listPortalWidget, {"portalId": id}, "portal", "widget"));
+    }
+    return promiseArr;
+};
+
+_worker._getDesinger_query = function(id){
+    var promiseArr = [];
+    if (_worker.findData.filterOption.designerTypes.indexOf("view")!=-1){    //所有脚本
+        promiseArr.push(_worker._getDesingerModule(id, _worker.findData.actions.listQueryView, {"flag": id}, "query", "view"));
+    }
+    if (_worker.findData.filterOption.designerTypes.indexOf("stat")!=-1){      //所有表单
+        promiseArr.push(_worker._getDesingerModule(id, _worker.findData.actions.listQueryStat, {"flag": id}, "query", "stat"));
+    }
+    if (_worker.findData.filterOption.designerTypes.indexOf("statement")!=-1){   //所有流程
+        promiseArr.push(_worker._getDesingerModule(id, _worker.findData.actions.listQueryStatement, {"flag": id}, "query", "statement"));
+    }
+    return promiseArr;
+};
+
+_worker._getDesinger_service = function(id){
+    var promiseArr = [];
+    if (_worker.findData.filterOption.designerTypes.indexOf("script")!=-1){    //所有脚本
+        if (id=="invoke"){
+            promiseArr.push(_worker._getDesingerModule(id, _worker.findData.actions.listInvoke, null, "service", "script"));
+        }else{
+            promiseArr.push(_worker._getDesingerModule(id, _worker.findData.actions.listAgent, null, "service", "script"));
+        }
+    }
+    return promiseArr;
+};
+
+
+_worker._listApplication = function(type){
+    switch (type){
+        case "processPlatform":
+            return this.action.sendRequest(_worker._getRequestOption({"url": this.findData.actions.listProcess, "debug": this.findData.debug, "token": this.findData.token }));
+        case "cms":
+            return this.action.sendRequest(_worker._getRequestOption({"url": this.findData.actions.listCms, "debug": this.findData.debug, "token": this.findData.token }));
+        case "portal":
+            return this.action.sendRequest(_worker._getRequestOption({"url": this.findData.actions.listPortal, "debug": this.findData.debug, "token": this.findData.token }));
+        case "query":
+            return this.action.sendRequest(_worker._getRequestOption({"url": this.findData.actions.listQuery, "debug": this.findData.debug, "token": this.findData.token }));
+    }
+
+};
+_worker._parseFindModule = function(moduleList){
+    var promiseArr = [];
+    moduleList.forEach(function(module){
+        if (module.moduleType==="service"){
+            if (!module.flagList || !module.flagList.length){
+
+                var filterOption = JSON.parse(_worker.filterOptionTemplete);
+                filterOption.moduleList.push({
+                    "moduleType": module.moduleType,
+                    "moduleAppList": [{"appId": "invoke"}]
+                });
+                this.filterOptionList.push(filterOption);
+
+                var filterOption = JSON.parse(_worker.filterOptionTemplete);
+                filterOption.moduleList.push({
+                    "moduleType": module.moduleType,
+                    "moduleAppList": [{"appId": "agent"}]
+                });
+                this.filterOptionList.push(filterOption);
+
+                //promiseArr.push(Promise.resolve(""));
+                promiseArr = promiseArr.concat(_worker["_getDesinger_"+module.moduleType]("invoke"));
+                promiseArr = promiseArr.concat(_worker["_getDesinger_"+module.moduleType]("agent"));
+            }else{
+                module.flagList.forEach(function(flag){
+                    if (!flag.designerList || !flag.designerList.length){
+                        promiseArr = promiseArr.concat(_worker["_getDesinger_"+module.moduleType](flag.id));
+                    }else{
+                        flag.designerList.forEach(function(designer){
+                            var filterOption = _worker._createFilterOption(module.moduleType, flag.id, designer.desingerType, designer.id)
+                            promiseArr = promiseArr.concat(Promise.resolve(filterOption));
+                        });
+                    }
+                });
+            }
+        }else{
+            if (!module.flagList || !module.flagList.length){
+                var p = _worker._listApplication(module.moduleType);
+                promiseArr.push(p.then(function(json){
+
+                    // json.data.forEach(function(app){
+                    //     var filterOption = JSON.parse(_worker.filterOptionTemplete);
+                    //     filterOption.moduleList.push({
+                    //         "moduleType": module.moduleType,
+                    //         "moduleAppList": [{"appId": app.id}]
+                    //     });
+                    //     this.filterOptionList.push(filterOption);
+                    // });
+                    // return Promise.resolve("");
+                    //临时处理
+
+
+                    var pArr = [];
+                    json.data.forEach(function(app){
+                        pArr = pArr.concat(_worker["_getDesinger_"+module.moduleType](app.id));
+                    });
+                    return Promise.all(pArr);
+                }, function(){}));
+
+            }else{
+                module.flagList.forEach(function(flag){
+                    if (!flag.designerList || !flag.designerList.length){
+                        promiseArr = promiseArr.concat(_worker["_getDesinger_"+module.moduleType](flag.id));
+                    }else{
+                        flag.designerList.forEach(function(designer){
+                            var filterOption = _worker._createFilterOption(module.moduleType, flag.id, designer.desingerType, designer.id)
+                            promiseArr = promiseArr.concat(Promise.resolve(filterOption));
+                        });
+                    }
+                });
+            }
+        }
+    }.bind(this));
+    return promiseArr;
+}
+
+_worker._findMessageReply = function(data, option){
+    _worker.setTimeout(function(){
+        _worker.postMessage(data);
+    }, 100);
+
+};
+_worker._findOptionReply = function(){
+    _worker.postMessage({
+        "type": "done"
+    });
+};
+
+
+
+_worker._createFindMessageReplyData = function(module, designer, aliase, pattern){
+    return {
+        "module": module,
+        "appId": designer.appId,
+        "appName": designer.appName,
+        "designerId": designer.designerId,
+        "designerName": designer.designerName,
+        "designerType": designer.designerType,
+        "designerAliase": aliase,
+
+        "pattern": pattern
+    };
+};
+
+_worker._setFilterOptionRegex = function(){
+    var keyword = _worker.findData.option.keyword;
+    if (_worker.findData.option.matchRegExp){
+        var flag = (_worker.findData.option.caseSensitive) ? "g" : "gi";
+        this.keywordRegexp =  new RegExp(keyword, flag);
+    }else{
+        var flag = (_worker.findData.option.caseSensitive) ? "g" : "gi";
+        keyword = (_worker.findData.option.matchWholeWord) ? "\\b"+keyword+"\\b" : keyword;
+        this.keywordRegexp = new RegExp(keyword, flag);
+    }
+};
+
+_worker._findProcessPlatformParse_script = function(designer){
+    if (designer.patternList && designer.patternList.length){
+        var action = this.findData.actions.getProcessScript;
+
+        var p = _worker.action.sendRequest(_worker._getRequestOption({"url": action}, {"id": designer.designerId}));
+        p.then(function(json){
+            designer.patternList.forEach(function(pattern){
+                if (pattern.property=="text"){
+                    var scriptLines = json.data.text.split(/\n/);
+                    pattern.lines.forEach(function(line){
+                        var scriptText = scriptLines[line-1];
+                        while ((arr = this.keywordRegexp.exec(scriptText)) !== null) {
+                            var col = arr.index;
+                            var key = arr[0];
+                            var value = arr.input;
+                            _worker._findMessageReply(_worker._createFindMessageReplyData("processPlatform", designer, json.data.aliase, {
+                                "property": pattern.property,
+                                "value": value,
+                                "line": line,
+                                "column": col,
+                                "key": key
+                            }));
+                        }
+                    });
+                }else{
+                    _worker._findMessageReply(_worker._createFindMessageReplyData("processPlatform", designer, json.data.aliase, {
+                        "property": pattern.property,
+                        "value": json.data[pattern.property]
+                    }));
+                }
+            });
+        }, function(){});
+    }
+};
+
+_worker._findProcessPlatformParse_form = function(designer){
+
+};
+
+_worker._findProcessPlatformParse_process = function(designer){
+
+};
+
+_worker._findProcessPlatformParse = function(resultList){
+    resultList.forEach(function(designer){
+        switch (designer.designerType){
+            case "script":
+                _worker._findProcessPlatformParse_script(designer);
+                break;
+            case "form":
+                _worker._findProcessPlatformParse_form(designer);
+                break;
+            case "process":
+                _worker._findProcessPlatformParse_process(designer);
+                break;
+        }
+    });
+};
+
+
+_worker._doFindDesigner = function(option){
+
+        var res = _worker._getRequestOption({
+            "method": "post",
+            "url": this.findData.actions.findAction,
+            "body": JSON.stringify(option),
+            "debug": this.findData.debug,
+            "token": this.findData.token
+        });
+        this.action.sendRequest(res).then(function(json){
+            if (json.data.processPlatformList && json.data.processPlatformList.length){
+                _worker._findProcessPlatformParse(json.data.processPlatformList);
+            }
+            if (json.data.cmsList && json.data.cmsList.length){
+
+            }
+            if (json.data.portalList && json.data.portalList.length){
+
+            }
+            if (json.data.queryList && json.data.queryList.length){
+
+            }
+            if (json.data.serviceList && json.data.serviceList.length){
+
+            }
+            _worker._findOptionReply();
+            //_worker._findMessageReply(json.data, option);
+        }, function(xhr){
+            _worker._findOptionReply(null);
+            _worker._findMessageReply(null);
+        });
+
+
+
+},
+
+_worker._doFindDesignerFromFilterOption = function(){
+    this.filterOptionList.forEach(function(option){
+        _worker._doFindDesigner(option);
+    });
+},
+onmessage = function(e) {
+    this.findData = e.data;
+    _worker._setFilterOptionRegex();
+    // "parser": "_findProcessPlatformParse",
+    //     "actions": _worker.findData.actions,
+    //     "option": option,
+    //     "pattern": json.data.processPlatformList
+    _worker[e.data.parser](e.data.pattern);
+}

+ 2 - 1
o2web/source/x_component_FindDesigner/lp/zh-cn.js

@@ -32,5 +32,6 @@ MWF.xApplication.FindDesigner.LP = {
 	"patternCount": "{n} 项匹配",
 
 	"receiveToFind": "正在准备查询数据 ...",
-	"readyToFind": "设计元素准备完毕(共{n}个) ..."
+	"readyToFind": "设计元素准备完毕(共{n}个) ...",
+	"findPatternCount": "已找到{n}项匹配"
 };