소스 검색

菜单交互

温红权 9 년 전
부모
커밋
6978fa77a9

+ 50 - 31
VisualInspection/js/main.js

@@ -1,3 +1,4 @@
+var MENU;
 //计算左面的
 $(document).ready(function() {
 
@@ -19,7 +20,39 @@ $(document).ready(function() {
 
 
     MenuGetAll(function(data) {
-        alert(data)
+        //初始化菜单
+        var treedata = [];
+        for (var i = 0; i < data.length; i++) {
+            var menu = data[i];
+            var datatemp = {}
+            datatemp["html"] = "<a class=\"p_m\" href=\"#\"><i class=\"icon icon-" + menu.iconClass + "\"></i>" + menu.menuname + "</a>";
+
+            datatemp["open"] = false;
+            if (menu.childs.length > 0) {
+                var datac = [];
+                for (var j = 0; j < menu.childs.length; j++) {
+                    var datactemp = {}
+                    var mtemp = menu.childs[j];
+                    datactemp["html"] = "<a id=\"" + mtemp.id + "\" href=\"#\"><i class=\"icon\">·</i>" + mtemp.menuname + "</a>";
+                    datac.push(datactemp);
+                }
+                datatemp["children"] = datac;
+            }
+
+
+            treedata.push(datatemp)
+        }
+
+        // 获取 tree 实例
+        var myTree = $('#treeMenu').data('zui.tree');
+
+        // 更新数据
+        myTree.reload(treedata);
+        myTree.collapse();
+
+        MENU = data;
+
+
     }, function(error) {
 
     });
@@ -39,39 +72,25 @@ function setletftime() {
 
 function getPageInfo(id) {
     var html = "";
-    switch (id) {
-        case "1_1":
-            {
-                html = __inline('/view/mytask/unchecked.html');
-                break;
-            }
-        case "1_2":
-            {
-                html = __inline('/view/mytask/unexamined.html');
-                break;
-            }
-        case "1_3":
-            {
-                html = __inline('/view/mytask/undispatched.html');
-                break;
+    if (typeof(MENU) != undefined && MENU != null) {
+        for (var i = 0; i < MENU.length; i++) {
+            var menu = MENU[i];
+            if (menu.id == id) {
+                html = ViewMap.get(menu.url)
+                return html;
             }
-        case "1_4":
-            {
-                html = __inline('/view/mytask/dispatched.html');
-                break;
-            }
-        case "7_5":
-            {
-                html = __inline('/view/constant/constant.html');
-                break;
-            }
-        default:
-            {
-                html = __inline('/view/user/aa.html');
+            if (menu.childs.length > 0) {
+                for (var j = 0; j < menu.childs.length; j++) {
+                    var mtemp = menu.childs[j];
+                    if (mtemp.id == id) {
+                        html = ViewMap.get(mtemp.url)
+                        return html;
+                    }
+                }
             }
 
+        }
     }
-
-    return html;
+    return __inline('/view/user/aa.html');
 
 }

+ 9 - 1
VisualInspection/js/util/util.js

@@ -59,4 +59,12 @@ function ajaxDelete(dataurl, data, sucessCallBack, errorCallBack) {
 
     doajax("DELETE", dataurl, data, sucessCallBack, errorCallBack)
 
-}
+}
+
+
+var ViewMap = new HashMap()
+ViewMap.set("/view/mytask/unchecked.html", __inline('/view/mytask/unchecked.html'));
+ViewMap.set("/view/mytask/unexamined.html", __inline('/view/mytask/unexamined.html'));
+ViewMap.set("/view/mytask/undispatched.html", __inline('/view/mytask/undispatched.html'));
+ViewMap.set("/view/mytask/dispatched.html", __inline('/view/mytask/dispatched.html'));
+ViewMap.set("/view/constant/constant.html", __inline('/view/constant/constant.html'));

+ 28 - 0
VisualInspection/node_modules/hashmap/.jshintrc

@@ -0,0 +1,28 @@
+{
+	"shadow": "inner",
+	"indent": 1,
+
+	"camelcase": false,
+	"eqeqeq": true,
+	"eqnull": true,
+	"freeze": true,
+	"funcscope": true,
+	"newcap": true,
+	"noarg": true,
+	"noempty": true,
+	"nonbsp": true,
+	"unused": "vars",
+	"undef": true,
+	"scripturl": true,
+	"loopfunc": true,
+	"strict": "implied",
+	"validthis": true,
+
+	"esnext": true,
+	"globals": {},
+	"browser": true,
+	"devel": true,
+	"mocha": true,
+	"node": true,
+	"jquery": true
+}

+ 41 - 0
VisualInspection/node_modules/hashmap/CHANGELOG.md

@@ -0,0 +1,41 @@
+# Changelog
+
+## 2.0.6
+- Names of chained methods is hardcoded rather than using the "return" trick. Fixes bug when minified, thanks @fresheneesz.
+- Added jshint to be run before any commit
+
+## 2.0.5
+- count() is now O(1), thanks @qbolec
+
+## 2.0.4
+- hasOwnProperty() is used to check for the internal expando, thanks @psionski
+
+## 2.0.3
+- forEach method accepts a context as 2nd argument, thanks @mvayngrib
+
+## 2.0.2
+- Make collisions rarer
+
+## 2.0.1
+- AMD CommonJS export is now compatible
+
+## 2.0.0
+- Added chaining to all methods with no returned value
+- Added multi() method
+- Added clone() method
+- Added copy() method
+- constructor accepts one argument for cloning or several for multi()
+
+## 1.2.0
+- Added search() method, thanks @rafalwrzeszcz
+
+## 1.1.0
+- AMD support, thanks @khrome
+
+## 1.0.1
+- forEach() callback receives the hashmap as `this`
+- Added keys()
+- Added values()
+
+## 1.0.0
+- First release

+ 22 - 0
VisualInspection/node_modules/hashmap/LICENSE

@@ -0,0 +1,22 @@
+(The MIT License)
+
+Copyright (c) 2012 Ariel Flesler <aflesler@gmail.com>
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+ 148 - 0
VisualInspection/node_modules/hashmap/Readme.md

@@ -0,0 +1,148 @@
+# HashMap Class for JavaScript
+
+## Installation
+
+[![NPM](https://nodei.co/npm/hashmap.png?compact=true)](https://npmjs.org/package/hashmap)
+
+Using [npm](https://npmjs.org/package/hashmap):
+
+    $ npm install hashmap
+
+Using bower:
+
+    $ bower install hashmap
+
+You can download the last stable version from the [releases page](https://github.com/flesler/hashmap/releases).
+
+If you like risk, you can download the [latest master version](https://raw.github.com/flesler/hashmap/master/hashmap.js), it's usually stable.
+
+To run the tests:
+
+    $ npm test
+
+## Description
+
+This project provides a `HashMap` class that works both on __Node.js__ and the __browser__.
+HashMap instances __store key/value pairs__ allowing __keys of any type__.
+
+Unlike regular objects, __keys will not be stringified__. For example numbers and strings won't be mixed, you can pass `Date`'s, `RegExp`'s, DOM Elements, anything! (even `null` and `undefined`)
+
+## HashMap constructor overloads
+- `new HashMap()` creates an empty hashmap
+- `new HashMap(map:HashMap)` creates a hashmap with the key-value pairs of `map`
+- `new HashMap(key:*, value:*, key2:*, value2:*, ...)` creates a hashmap with several key-value pairs
+
+## HashMap methods
+
+- `get(key:*) : *` returns the value stored for that key.
+- `set(key:*, value:*) : HashMap` stores a key-value pair
+- `multi(key:*, value:*, key2:*, value2:*, ...) : HashMap` stores several key-value pairs
+- `copy(other:HashMap) : HashMap` copies all key-value pairs from other to this instance
+- `has(key:*) : Boolean` returns whether a key is set on the hashmap
+- `search(value:*) : *` returns key under which given value is stored (`null` if not found)
+- `remove(key:*) : HashMap` deletes a key-value pair by key
+- `type(key:*) : String` returns the data type of the provided key (used internally)
+- `keys() : Array<*>` returns an array with all the registered keys
+- `values() : Array<*>` returns an array with all the values
+- `count() : Number` returns the amount of key-value pairs
+- `clear() : HashMap` removes all the key-value pairs on the hashmap
+- `clone() : HashMap` creates a new hashmap with all the key-value pairs of the original
+- `hash(key:*) : String` returns the stringified version of a key (used internally)
+- `forEach(function(value, key)) : HashMap` iterates the pairs and calls the function for each one
+
+### Method chaining
+
+All methods that don't return something, will return the HashMap instance to enable chaining.
+
+## Examples
+
+Assume this for all examples below
+
+```js
+var map = new HashMap();
+```
+
+If you're using this within Node, you first need to import the class
+
+```js
+var HashMap = require('hashmap');
+```
+
+### Basic use case
+
+```js
+map.set("some_key", "some value");
+map.get("some_key"); // --> "some value"
+```
+### No stringification
+
+```js
+map.set("1", "string one");
+map.set(1, "number one");
+map.get("1"); // --> "string one"
+```
+
+A regular `Object` used as a map would yield `"number one"`
+
+### Objects as keys
+
+```js
+var key = {};
+var key2 = {};
+map.set(key, 123);
+map.set(key2, 321);
+map.get(key); // --> 123
+```
+A regular `Object` used as a map would yield `321`
+
+### Iterating
+
+```js
+map.set(1, "test 1");
+map.set(2, "test 2");
+map.set(3, "test 3");
+
+map.forEach(function(value, key) {
+    console.log(key + " : " + value);
+});
+```
+
+### Method chaining
+
+```js
+map
+  .set(1, "test 1")
+  .set(2, "test 2")
+  .set(3, "test 3")
+  .forEach(function(value, key) {
+      console.log(key + " : " + value);
+  });
+```
+
+## LICENSE
+
+The MIT License (MIT)
+
+Copyright (c) 2012 Ariel Flesler
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF
+
+## To-Do
+
+* (?) Allow extending the hashing function in a AOP way or by passing a service
+* Make tests work on the browser

+ 29 - 0
VisualInspection/node_modules/hashmap/bower.json

@@ -0,0 +1,29 @@
+{
+  "name": "hashmap",
+  "version": "2.0.6",
+  "description": "HashMap Class for JavaScript",
+  "homepage": "https://github.com/flesler/hashmap",
+  "main": "./hashmap.js",
+  "dependencies": {},
+  "keywords": [
+    "hashmap",
+    "map",
+    "object",
+    "array",
+    "associative",
+    "javascript",
+    "nodejs",
+    "node",
+    "browser"
+  ],
+  "author": {
+    "name": "Ariel Flesler",
+    "web": "http://flesler.blogspot.com/"
+  },
+  "ignore": [
+    "**/.*",
+    "node_modules",
+    "test",
+    "components"
+  ]
+}

+ 190 - 0
VisualInspection/node_modules/hashmap/hashmap.js

@@ -0,0 +1,190 @@
+/**
+ * HashMap - HashMap Class for JavaScript
+ * @author Ariel Flesler <aflesler@gmail.com>
+ * @version 2.0.6
+ * Homepage: https://github.com/flesler/hashmap
+ */
+
+(function(factory) {
+	/* global define */
+	if (typeof define === 'function' && define.amd) {
+		// AMD. Register as an anonymous module.
+		define([], factory);
+	} else if (typeof module === 'object') {
+		// Node js environment
+		var HashMap = module.exports = factory();
+		// Keep it backwards compatible
+		HashMap.HashMap = HashMap;
+	} else {
+		// Browser globals (this is window)
+		this.HashMap = factory();
+	}
+}(function() {
+
+	function HashMap(other) {
+		this.clear();
+		switch (arguments.length) {
+			case 0: break;
+			case 1: this.copy(other); break;
+			default: multi(this, arguments); break;
+		}
+	}
+
+	var proto = HashMap.prototype = {
+		constructor:HashMap,
+
+		get:function(key) {
+			var data = this._data[this.hash(key)];
+			return data && data[1];
+		},
+
+		set:function(key, value) {
+			// Store original key as well (for iteration)
+			var hash = this.hash(key);
+			if ( !(hash in this._data) ) {
+				this._count++;
+			}
+			this._data[hash] = [key, value];
+		},
+
+		multi:function() {
+			multi(this, arguments);
+		},
+
+		copy:function(other) {
+			for (var hash in other._data) {
+				if ( !(hash in this._data) ) {
+					this._count++;
+				}
+				this._data[hash] = other._data[hash];
+			}
+		},
+
+		has:function(key) {
+			return this.hash(key) in this._data;
+		},
+
+		search:function(value) {
+			for (var key in this._data) {
+				if (this._data[key][1] === value) {
+					return this._data[key][0];
+				}
+			}
+
+			return null;
+		},
+
+		remove:function(key) {
+			var hash = this.hash(key);
+			if ( hash in this._data ) {
+				this._count--;
+				delete this._data[hash];
+			}
+		},
+
+		type:function(key) {
+			var str = Object.prototype.toString.call(key);
+			var type = str.slice(8, -1).toLowerCase();
+			// Some browsers yield DOMWindow or Window for null and undefined, works fine on Node
+			if (!key && (type === 'domwindow' || type === 'window')) {
+				return key + '';
+			}
+			return type;
+		},
+
+		keys:function() {
+			var keys = [];
+			this.forEach(function(_, key) { keys.push(key); });
+			return keys;
+		},
+
+		values:function() {
+			var values = [];
+			this.forEach(function(value) { values.push(value); });
+			return values;
+		},
+
+		count:function() {
+			return this._count;
+		},
+
+		clear:function() {
+			// TODO: Would Object.create(null) make any difference
+			this._data = {};
+			this._count = 0;
+		},
+
+		clone:function() {
+			return new HashMap(this);
+		},
+
+		hash:function(key) {
+			switch (this.type(key)) {
+				case 'undefined':
+				case 'null':
+				case 'boolean':
+				case 'number':
+				case 'regexp':
+					return key + '';
+
+				case 'date':
+					return '♣' + key.getTime();
+
+				case 'string':
+					return '♠' + key;
+
+				case 'array':
+					var hashes = [];
+					for (var i = 0; i < key.length; i++) {
+						hashes[i] = this.hash(key[i]);
+					}
+					return '♥' + hashes.join('⁞');
+
+				default:
+					// TODO: Don't use expandos when Object.defineProperty is not available?
+					if (!key.hasOwnProperty('_hmuid_')) {
+						key._hmuid_ = ++HashMap.uid;
+						hide(key, '_hmuid_');
+					}
+
+					return '♦' + key._hmuid_;
+			}
+		},
+
+		forEach:function(func, ctx) {
+			for (var key in this._data) {
+				var data = this._data[key];
+				func.call(ctx || this, data[1], data[0]);
+			}
+		}
+	};
+
+	HashMap.uid = 0;
+
+	//- Add chaining to all methods that don't return something
+
+	['set','multi','copy','remove','clear','forEach'].forEach(function(method) {
+		var fn = proto[method];
+		proto[method] = function() {
+			fn.apply(this, arguments);
+			return this;
+		};
+	});
+
+	//- Utils
+
+	function multi(map, args) {
+		for (var i = 0; i < args.length; i += 2) {
+			map.set(args[i], args[i+1]);
+		}
+	}
+
+	function hide(obj, prop) {
+		// Make non iterable if supported
+		if (Object.defineProperty) {
+			Object.defineProperty(obj, prop, {enumerable:false});
+		}
+	}
+
+	return HashMap;
+}));

+ 110 - 0
VisualInspection/node_modules/hashmap/package.json

@@ -0,0 +1,110 @@
+{
+  "_args": [
+    [
+      {
+        "raw": "hashmap",
+        "scope": null,
+        "escapedName": "hashmap",
+        "name": "hashmap",
+        "rawSpec": "",
+        "spec": "latest",
+        "type": "tag"
+      },
+      "/Users/wenhongquan/Desktop/项目/新通/沿海高速/VisualInspection/VisualInspection"
+    ]
+  ],
+  "_cnpm_publish_time": 1491578762709,
+  "_from": "hashmap@latest",
+  "_hasShrinkwrap": false,
+  "_id": "hashmap@2.1.0",
+  "_inCache": true,
+  "_location": "/hashmap",
+  "_nodeVersion": "6.10.1",
+  "_npmOperationalInternal": {
+    "host": "packages-18-east.internal.npmjs.com",
+    "tmp": "tmp/hashmap-2.1.0.tgz_1491578760959_0.7539032222703099"
+  },
+  "_npmUser": {
+    "name": "flesler",
+    "email": "aflesler@gmail.com"
+  },
+  "_npmVersion": "3.10.10",
+  "_phantomChildren": {},
+  "_requested": {
+    "raw": "hashmap",
+    "scope": null,
+    "escapedName": "hashmap",
+    "name": "hashmap",
+    "rawSpec": "",
+    "spec": "latest",
+    "type": "tag"
+  },
+  "_requiredBy": [
+    "#USER",
+    "/"
+  ],
+  "_resolved": "https://registry.npm.taobao.org/hashmap/download/hashmap-2.1.0.tgz",
+  "_shasum": "fe163aa781db4665bbd76f554e390c8c55ce920a",
+  "_shrinkwrap": null,
+  "_spec": "hashmap",
+  "_where": "/Users/wenhongquan/Desktop/项目/新通/沿海高速/VisualInspection/VisualInspection",
+  "author": {
+    "name": "Ariel Flesler",
+    "email": "aflesler@gmail.com"
+  },
+  "bugs": {
+    "url": "https://github.com/flesler/hashmap/issues"
+  },
+  "dependencies": {},
+  "description": "HashMap Class for JavaScript",
+  "devDependencies": {
+    "chai": "3.5.0",
+    "husky": "0.11.4",
+    "jshint": "2.9.2",
+    "mocha": "2.5.1"
+  },
+  "directories": {},
+  "dist": {
+    "shasum": "fe163aa781db4665bbd76f554e390c8c55ce920a",
+    "size": 4914,
+    "noattachment": false,
+    "tarball": "http://registry.npm.taobao.org/hashmap/download/hashmap-2.1.0.tgz"
+  },
+  "engines": {
+    "node": "*"
+  },
+  "gitHead": "d0ad325c3f894b493a65770e6aa2ef4da468f6e1",
+  "homepage": "https://github.com/flesler/hashmap",
+  "keywords": [
+    "hashmap",
+    "map",
+    "object",
+    "array",
+    "associative",
+    "javascript",
+    "nodejs",
+    "node",
+    "browser"
+  ],
+  "license": "MIT",
+  "main": "./hashmap.js",
+  "maintainers": [
+    {
+      "name": "flesler",
+      "email": "aflesler@gmail.com"
+    }
+  ],
+  "name": "hashmap",
+  "optionalDependencies": {},
+  "publish_time": 1491578762709,
+  "readme": "ERROR: No README data found!",
+  "repository": {
+    "type": "git",
+    "url": "git://github.com/flesler/hashmap.git"
+  },
+  "scripts": {
+    "precommit": "jshint hashmap.js",
+    "prepush": "mocha test/ --reporter dot"
+  },
+  "version": "2.1.0"
+}

+ 1 - 0
VisualInspection/package.json

@@ -22,6 +22,7 @@
   "homepage": "https://github.com/fis-scaffold/default",
   "dependencies": {
     "blueimp-md5": "^2.7.0",
+    "hashmap": "^2.1.0",
     "moment": "^2.18.1",
     "websocket": "^1.0.24",
     "zui": "^1.6.0"

+ 1 - 0
VisualInspection/view/common/commonscriptlink.html

@@ -8,6 +8,7 @@
 <script src="/node_modules/moment/locale/zh-cn.js"></script>
 <script src="/node_modules/axios/dist/axios.min.js"></script>
 <script src="/node_modules/blueimp-md5/js/md5.min.js"></script>
+<script src="/node_modules/hashmap/hashmap.js"></script>
 <script src="/js/util/util.js"></script>
 <script src="/js/util/service.js"></script>