Browse Source

设计搜索功能

huqi 5 years ago
parent
commit
02d28c3827

+ 112 - 0
o2web/source/o2_core/o2/widget/$Arraylist/findDesigner/css.wcss

@@ -0,0 +1,112 @@
+{
+	"container": {
+		"border-top": "1px solid #999",
+		"border-bottom": "1px solid #999",
+		"overflow": "auto"
+	},
+	
+	"titleNode": {
+		"height": "30px",
+		"line-height": "30px",
+		"background": "#EEE"
+	},
+	
+	"titleActionNode": {
+		"float": "right",
+		"width": "20px",
+		"height": "20px",
+		"background": "url("+o2.session.path+"/widget/$ScriptArea/default/icon/add2.png) center center no-repeat",
+		"cursor": "pointer"
+	},
+	
+	"titleTextNode": {
+		"line-height": "30px",
+		"font-size": "12px",
+		"padding-left": "5px"
+	},
+	"contentNode": {
+		"overflow": "hidden",
+		"font-size": "12px",
+		"cursor": "default",
+		"padding": "3px 3px"
+	},
+	"contentStartNode": {
+		"height": "18px",
+		"line-height": "18px",
+		"font-family": "Verdana, Geneva, sans-serif",
+		"cursor": "default",
+		"background": "transparent"
+	},
+	"contentStartNodeOver": {
+		"height": "18px",
+		"line-height": "18px",
+		"font-family": "Verdana, Geneva, sans-serif",
+		"cursor": "default",
+		"background": "#E9E9E9"
+	},
+	
+	"contentItemsNode": {
+		"margin-left": "2px",
+		"overflow": "hidden",
+		"min-height": "12px"
+	},
+	"contentEndNode": {
+		"height": "18px",
+		"line-height": "18px",
+		"font-family": "Verdana, Geneva, sans-serif",
+		"cursor": "default",
+		"background": "transparent"
+	},
+	"contentEndNodeOver": {
+		"height": "18px",
+		"line-height": "18px",
+		"font-family": "Verdana, Geneva, sans-serif",
+		"cursor": "default",
+		"background": "#E9E9E9"
+	},
+	"contentItemNode": {
+		"height": "22px",
+		"line-height": "22px",
+		"background": "transparent"
+	},
+	"contentItemNodeOver": {
+		"height": "22px",
+		"line-height": "22px",
+		"background": "#E9E9E9"
+	},
+	"contentItemIconNode": {
+		"width": "16px",
+		"height": "22px",
+		"float": "left"
+	},
+	"contentItemKeyNode": {
+		"color": "#C80000",
+		"font-family": "Verdana, Geneva, sans-serif",
+		"cursor": "default"
+	},
+	"contentItemValueNode": {
+		"color": "#395cdf",
+		"margin-left": "3px",
+		"font-family": "Verdana, Geneva, sans-serif",
+		"cursor": "default"
+	},
+	"contentItemColonNode": {
+		"margin-left": "2px"
+	},
+	
+	"editInputDiv": {
+		"border": "1px solid #999",
+		"height": "16px",
+		"line-height": "16px",
+		"overflow": "hidden",
+		"display": "inline",
+		"box-shadow": "0px 2px 5px #999"
+	},
+	
+	"editInput": {
+		"border": "0px",
+		"font-size": "12px",
+		"font-family": "Verdana, Geneva, sans-serif"
+	}
+	
+}

BIN
o2web/source/o2_core/o2/widget/$Arraylist/findDesigner/icon/add.png


BIN
o2web/source/o2_core/o2/widget/$Arraylist/findDesigner/icon/add2.png


BIN
o2web/source/o2_core/o2/widget/$Arraylist/findDesigner/icon/add3.png


BIN
o2web/source/o2_core/o2/widget/$Arraylist/findDesigner/icon/delete.png


BIN
o2web/source/o2_core/o2/widget/$Arraylist/findDesigner/icon/delete3.png


BIN
o2web/source/o2_core/o2/widget/$Arraylist/findDesigner/icon/error.png


+ 11 - 1
o2web/source/o2_core/o2/widget/Arraylist.js

@@ -4,6 +4,7 @@ o2.widget.Arraylist = new Class({
 	Extends: o2.widget.Common,
 	options: {
 		"title": "arraylist",
+		"htmlTitle": "",
 		"style": "default",
 		
 		"isAdd": true,
@@ -53,7 +54,9 @@ o2.widget.Arraylist = new Class({
 		this.titleTextNode = new Element("div", {
 			"styles": this.css.titleTextNode,
 			"text": this.options.title
-		}).inject(this.titleNode);	
+		}).inject(this.titleNode);
+
+		if (this.options.htmlTitle) this.titleTextNode.set("html", this.options.htmlTitle);
 	},
 	
 	createContent: function(arr){
@@ -110,6 +113,13 @@ o2.widget.Arraylist = new Class({
 			}
 		});
 		return arr;
+	},
+	getValue: function(){
+		return this.toArray();
+	},
+	destroy: function(){
+		this.container.destroy();
+		o2.release(this);
 	}
 	
 });

+ 4 - 1
o2web/source/o2_core/o2/widget/Maplist.js

@@ -424,6 +424,7 @@ o2.widget.Maplist.Item = new Class({
 	},
 	
 	editItemComplate: function(node, input){
+		var isChangeed = false;
 		var text = input.get("value");
 		if (node == this.keyNode){
 			if (!text){
@@ -438,6 +439,7 @@ o2.widget.Maplist.Item = new Class({
 			}.bind(this));
 			
 			if (flag){
+				if (this.key !== text) isChangeed = true;
 				this.key = text;
 				this.editValue();
 				this.maplist.notAddItem = true;
@@ -451,6 +453,7 @@ o2.widget.Maplist.Item = new Class({
 		
 		var addNewItem = false;
 		if (node == this.valueNode){
+			if (this.value !== text) isChangeed = true;
 			this.value = text;
 			if (this.isEnterKey){
 				if (this.isNewItem){
@@ -464,7 +467,7 @@ o2.widget.Maplist.Item = new Class({
 		this.iconNode.setStyle("background", "transparent ");
 		this.iconNode.title = "";
 
-		this.maplist.fireEvent("change");
+		if (isChangeed) this.maplist.fireEvent("change");
 		
 		if (addNewItem){
 			this.maplist.notAddItem = false;

+ 5 - 3
o2web/source/x_component_FindDesigner/FindWorker.js

@@ -500,7 +500,7 @@ _worker.findInDesigner_map = function(formData, key, module, designer, propertyD
         }
     });
 };
-_worker.findInDesigner_array = function(formData, key, module, designer, propertyDefinition, option, mode){
+_worker.findInDesigner_array = function(formData, key, module, designer, propertyDefinition, option, mode, path){
     var arr = formData[key];
     arr.forEach(function(v, i) {
         this.keywordRegexp.lastIndex = 0;
@@ -520,9 +520,10 @@ _worker.findInDesigner_array = function(formData, key, module, designer, propert
         }
     });
 };
-_worker.findInDesigner_objectArray = function(formData, key, module, designer, propertyDefinition, option, mode){
+_worker.findInDesigner_objectArray = function(formData, key, module, designer, propertyDefinition, option, mode, path){
     var arr = formData[key];
     arr.forEach(function(map, i) {
+        var p = path.concat(i);
         Object.keys(map).forEach(function(evkey) {
             this.keywordRegexp.lastIndex = 0;
             var text = map[evkey];
@@ -535,7 +536,8 @@ _worker.findInDesigner_objectArray = function(formData, key, module, designer, p
                     "line": i+1,
                     "key": key,
                     "value": evkey+": "+text,
-                    "mode": mode
+                    "mode": mode,
+                    "path": p.concat(evkey)
                 }), option);
             }
         });

+ 87 - 21
o2web/source/x_component_FindDesigner/Main.js

@@ -718,11 +718,17 @@ MWF.xApplication.FindDesigner.Main = new Class({
 				this.reLocationMapEditor(pattern);
 				break;
 			case "array":
-				this.reLocationMapEditor(pattern);
+				this.reLocationArrayEditor(pattern);
 				break;
 
 		}
 	},
+	reLocationArrayEditor: function(pattern){
+		if (this.editor){
+			var i = pattern.pattern.line-1;
+			if (this.editor.items[i]) this.editor.items[i].editValue();
+		}
+	},
 	reLocationMapEditor: function(pattern){
 		if (this.editor){
 			var keyv = pattern.pattern.value.split(":");
@@ -765,7 +771,7 @@ MWF.xApplication.FindDesigner.Main = new Class({
 			case "map":
 				this.openPatternFormEditor_map(data, node);
 				break;
-			case "map":
+			case "array":
 				this.openPatternFormEditor_array(data, node);
 				break;
 
@@ -786,36 +792,49 @@ MWF.xApplication.FindDesigner.Main = new Class({
 		}
 		return d;
 	},
+	getTitleWithPath: function(data, pattern){
+		var el = this.lp.elementPattern.replace("{element}", "<"+pattern.pattern.type+">"+pattern.pattern.name).
+		replace("{property}", pattern.pattern.propertyName+"{"+pattern.pattern.key+"}");
+		var title = "<b>"+this.lp[pattern.module]+":<span style='color: #4A90E2'>"+pattern.appName+"</span></b>->"+": "+"<b>["+pattern.pattern.mode+this.lp[pattern.designerType]+"]</b>&nbsp;"+pattern.designerName+"->"+el;
+
+		return "<div style='line-height: 30px'>"+title+"</div>"
+	},
 	openPatternFormEditor_array: function(data, node){
 		var d = this.getValueWithPath(data, node.pattern);
-
 		if (d){
+			var title = this.getTitleWithPath(data, node.pattern);
+			o2.require("o2.widget.Arraylist", function(){
+				this.editor = new o2.widget.Arraylist(this.previewContentNode, {
+					"htmlTitle": title,
+					"style": "findDesigner",
+					"onChange": function(){
+						this.reFindInFormDesigner();
+					}.bind(this),
+					"onPostLoad": function(){
+						if (this.previewToolbar){
+							this.previewToolbar.childrenButton[0].enable();
+							this.previewToolbar.childrenButton[1].enable();
+						}
+					}.bind(this),
+				});
+				this.editor.pattern = node.pattern;
+				this.editor.designerNode = node;
+				this.editor.designerData = data;
 
+				this.editor.load(d);
+
+				this.resetFormEditor(node.pattern);
+
+			}.bind(this))
 		}
 	},
 
 	openPatternFormEditor_map: function(data, node){
 		debugger;
-		var path = node.pattern.pattern.path;
-		var d = data;
-		var i=0;
-		while (i<path.length){
-			if (path[i]=="styles"){
-				d.styles = d.recoveryStyles;
-			}else if (path[i]=="inputStyles"){
-				d.inputStyles = d.recoveryInputStyles;
-			}
-			d = d[path[i]];
-			i++;
-		}
+		var d = this.getValueWithPath(data, node.pattern);
 
 		if (d){
-			var el = this.lp.elementPattern.replace("{element}", "&lt;"+node.pattern.pattern.type+"&gt;"+node.pattern.pattern.name).
-			replace("{property}", node.pattern.pattern.propertyName+"{"+node.pattern.pattern.key+"}");
-			var title = "<b>"+this.lp[node.pattern.module]+":<span style='color: #4A90E2'>"+node.pattern.appName+"</span></b>->"+": "+"<b>["+node.pattern.pattern.mode+this.lp[node.pattern.designerType]+"]</b>&nbsp;"+node.pattern.designerName+"->"+el;
-
-			title = "<div style='line-height: 30px'>"+title+"</div>"
-
+			var title = this.getTitleWithPath(data, node.pattern);
 			o2.require("o2.widget.Maplist", function(){
 				this.editor = new o2.widget.Maplist(this.previewContentNode, {
 					"htmlTitle": title,
@@ -1047,11 +1066,58 @@ debugger;
 				case "map":
 					this.reFindInFormDesigner_map(removeNodes, pattern);
 					break;
+				case "array":
+					this.reFindInFormDesigner_array(removeNodes, pattern);
+					break;
 			}
 			this.subResultCount(this.editor.pattern);
 		}
 		this.editor.isRefind = false;
 	},
+	reFindInFormDesigner_array: function(removeNodes, pattern){
+		var arr = this.editor.getValue();
+		if (arr){
+			var regex = this.getFilterOptionRegex(this.filterOption)
+			removeNodes.forEach(function(i){
+				var idx = i.pattern.pattern.line.toInt()-1;
+				var value = arr[idx] || "";
+				if (i.pattern.pattern.value!=value){
+					i.pattern.pattern.value = value;
+					var text = this.getFormPatternNodeText(i.pattern, regex)
+					var textDivNode = i.textNode.getElement("div");
+					if (textDivNode){
+						textDivNode.set("html", "<span style='color: #000000'>"+text+"</span>");
+					}
+				}
+			}.bind(this));
+
+			arr.forEach(function(v, i) {
+				regex.lastIndex = 0;
+				var text = v.toString();
+				if (regex.test(text)){
+
+
+					var n = removeNodes.filter(function(n){
+						var idx = n.pattern.pattern.line.toInt()-1;
+						return (idx==i);
+					});
+					if (!n.length){
+						this.showFindResult(this._createFindMessageReplyData(this.editor.pattern.module, this.editor.pattern, "", {
+							"type": pattern.pattern.type,
+							"propertyType": pattern.pattern.propertyType,
+							"propertyName": pattern.pattern.propertyName,
+							"name": pattern.pattern.name,
+							"line": i+1,
+							"key": pattern.pattern.key,
+							"value": text,
+							"mode": pattern.pattern.mode,
+							"path": pattern.pattern.path
+						}), this.filterOption, removeNodes[removeNodes.length-1].nextSibling);
+					}
+				}
+			}.bind(this));
+		}
+	},
 	reFindInFormDesigner_map: function(removeNodes, pattern){
 		var map = this.editor.getValue();
 		if (map){