root 8 years ago
parent
commit
ce75edb146

+ 18 - 15
css/model/sys/dict/index.css

@ -1,15 +1,18 @@
1
@charset "utf-8";
2
.sys_dict_index .queryForm{
3
	position: relative;
4
}
5
.sys_dict_index .queryForm .icon-search{
6
	position: absolute;
7
	top:7px;
8
	right:15px;
9
	font-size:25px;
10
}
11
.sys_dict_index .table-opt .icon {
12
	margin: 10px;
13
	font-size: 20px;
14
}
15

1
@charset "utf-8";
2
.sys_dict_index .queryForm{
3
	position: relative;
4
}
5
.sys_dict_index .queryForm .icon-search{
6
	position: absolute;
7
	top:7px;
8
	right:15px;
9
	font-size:25px;
10
}
11
.sys_dict_index .table-opt .icon {
12
	margin: 10px;
13
	font-size: 20px;
14
}
15
.sys_dict_add,.sys_dict_edit{
16
	width:800px;
17
18
}

+ 0 - 5
css/model/sys/dict/add.css

@ -1,5 +0,0 @@
1
@charset "utf-8";
2
.sys_dict_add{
3
	width:800px;
4

5
}

+ 0 - 5
css/model/sys/dict/edit.css

@ -1,5 +0,0 @@
1
@charset "utf-8";
2
.sys_dict_edit{
3
	width:800px;
4

5
}

+ 17 - 15
css/model/sys/resource/index.css

@ -1,15 +1,17 @@
1
@charset "utf-8";
2
.sys_resource_index .queryForm{
3
	position: relative;
4
}
5
.sys_resource_index .queryForm .icon-search{
6
	position: absolute;
7
	top:7px;
8
	right:15px;
9
	font-size:25px;
10
}
11
.sys_resource_index .table-opt .icon {
12
	margin: 10px;
13
	font-size: 20px;
14
}
15

1
@charset "utf-8";
2
.sys_resource_index .queryForm{
3
	position: relative;
4
}
5
.sys_resource_index .queryForm .icon-search{
6
	position: absolute;
7
	top:7px;
8
	right:15px;
9
	font-size:25px;
10
}
11
.sys_resource_index .table-opt .icon {
12
	margin: 10px;
13
	font-size: 20px;
14
}
15
.sys_resource_edit,.sys_resource_new{
16
	width:800px;
17
}

+ 0 - 5
css/model/sys/resource/new.css

@ -1,5 +0,0 @@
1
@charset "utf-8";
2
.sys_resource_new{
3
	width:800px;
4

5
}

+ 8 - 5
html/demo.html

@ -148,11 +148,14 @@
148 148

149 149
	<script>
150 150
		$(function() {
151
			$.spa.build();
152
			$(".opt-logout").on("click", function() {
153
				$.util.get("../ajax/sys/user/logout", null, function() {
154
					window.location.href = "login.html";
155
				}, {});
151
			$.use(["spa","util"],function(spa,util){
152
				spa.build();
153
				$(".opt-logout").on("click", function() {
154
					util.get("../ajax/sys/user/logout", null, function() {
155
						window.location.href = "login.html";
156
					}, {});
157
				});
158
				
156 159
			});
157 160
		});
158 161
	</script>

+ 5 - 7
html/model/sys/dict/index.html

@ -2,7 +2,6 @@
2 2
	<div class="modal-ctrl">
3 3
		<i class="icon icon-times"></i>
4 4
	</div>
5

6 5
	<div class="container queryForm">
7 6
		<div class="row">
8 7
			<div class="col-6">
@ -10,7 +9,6 @@
10 9
					<i class="icon-plus"></i>
11 10
					新增
12 11
				</div>
13
				
14 12
			</div>
15 13
			<div class="col-6 dt-form">				
16 14
				<div class="form-item text" name="key"></div><i class="icon icon-search opt-query"></i>
@ -31,9 +29,9 @@
31 29
					<th>操作</th>
32 30
				</tr>
33 31
			</thead>
34
			<tbody class="code-tpl code-tag-hold" code-func="data-list">
35
				<tr>
36
					<td>{{any-[]}}</td>
32
			<tbody>
33
				<tr ch-dir="list">
34
					<td>{{-_index}}</td>
37 35
					<td>{{pi}}</td>
38 36
					<td>{{code}}</td>
39 37
					<td>{{caption}}</td>
@ -42,9 +40,9 @@
42 40
					<td class="table-opt" dictCode="{{code}}"><i class="icon icon-remove-sign"></i><i class="icon icon-edit"></i><i class="icon icon-list-ul"></i><i class="icon icon-tasks"></i></td>
43 41
				</tr>
44 42
			</tbody>
45
			<tbody class="code-tpl code-tag-hold" code-func="data-emptylist">
43
			<tbody ch-dir="array.empty">
46 44
				<tr>
47
					<td class="empty-desc" colspan="7">表格暂无数据</td>
45
					<td colspan="7">表格暂无数据</td>
48 46
				</tr>
49 47
			</tbody>
50 48
		</table>

+ 15 - 1
html/model/sys/dict/itemlist.html

@ -1,4 +1,19 @@
1 1
<div class-"sys_dict_itemlist centerModal">
2
	<div class="modal-ctrl">
3
		<i class="icon icon-times"></i>
4
	</div>
5
	<ul>
6
		<li class="ld-item">
7
			<div class="item-code" ov="{{code}}">{{code}}</div>
8
			<div class="item-code" ov="{{caption}}">{{caption}}</div>
9
			<div class="item-code" ov="{{shortCode}}">{{shortCode}}</div>
10
			<div class="item-code" ov="{{enabled}}">{{enabled-itemE}}</div>
11
			<div class="item-code" ov="{{system}}">{{system-itemS}}</div>
12
			<div ch-dir="each" class="item-code" ov="{{data-json}}"></div>
13
			<div class="item-code" ov="{{code}}">{{code}}</div>
14
		</li>
15
	</ul>
16
	
2 17
	<dvi class="item-list">
3 18
		<div calss="code-tpl" code-func="data-list">
4 19
			<div class="item">
@ -8,7 +23,6 @@
8 23
				<div class="item-enabled" objVal="{{enabled}}">{{enabled}}</div>
9 24
				<div class="item-system" objVal="{{system}}">{{code}}</div>
10 25
				<div class="item-data" objVal="{{code}}">{{code}}</div>
11
				
12 26
			</div>
13 27
		</div>
14 28
		

+ 2 - 2
html/model/sys/org/index.html

@ -1,4 +1,4 @@
1
<div class="sys_org_index" loadUri="../ajax/sys/org/pq" pageSize="7" pageNo="1" pageIndex="pi">
1
<div class="sys_org_index" loadUri="../ajax/sys/org/pq" pageSize="5" pageNo="1" pageIndex="pi">
2 2
	<div class="modal-ctrl">
3 3
		<i class="icon icon-times"></i>
4 4
	</div>
@ -74,7 +74,7 @@
74 74
			</tbody>
75 75
			<tbody ch-dir="array.empty">
76 76
				<tr>
77
					<td class="empty-desc" colspan="6">表格暂无数据</td>
77
					<td colspan="6">表格暂无数据</td>
78 78
				</tr>
79 79
			</tbody>
80 80
		</table>

+ 69 - 0
html/model/sys/resource/edit.html

@ -0,0 +1,69 @@
1
<div class="sys_resource_edit centerModal">
2
	<div class="modal-ctrl">
3
		<i class="icon icon-times"></i>
4
	</div>
5
	<div class="container opt-form">
6
		<div class="row">
7
			<div class="col-2 item-caption ">MODAL</div>
8
			<div class="col-4">
9
				<div class="form-item select bool" dictCode="bool" defVal="" name="modal"></div>
10
			</div>
11
			<div class="col-2 item-caption ">MAIN</div>
12
			<div class="col-4">
13
				<div class="form-item select bool" dictCode="bool" defVal="" name="main"></div>
14
			</div>
15
		</div>
16
		<div class="row">
17
			<div class="col-2 item-caption ">资源权限</div>
18
			<div class="col-4">
19
				<div class="form-item int text" defVal="0" name="authRight"></div>
20
			</div>
21
			<div class="col-2 item-caption ">资源类型</div>
22
			<div class="col-4">
23
				<div class="form-item select" dictCode="bool" defVal="" name="type"></div>
24
			</div>
25
		</div>
26
		<div class="row">
27
			<div class="col-2 item-caption">资源ID</div>
28
			<div class="col-10">
29
				<div class="form-item text" defVal="" name="id"></div>
30
			</div>
31
		</div>
32
		<div class="row">
33
			<div class="col-2 item-caption">资源NAME</div>
34
			<div class="col-10">
35
				<div class="form-item text" defVal="" name="name"></div>
36
			</div>
37
		</div>
38
		<div class="row">
39
			<div class="col-2 item-caption">资源URI</div>
40
			<div class="col-10">
41
				<div class="form-item text" defVal="" name="uri"></div>
42
			</div>
43
		</div>
44
		<div class="row">
45
			<div class="col-2 item-caption">资源CSS</div>
46
			<div class="col-10">
47
				<div class="form-item text" defVal="" name="css"></div>
48
			</div>
49
		</div>
50
		<div class="row">
51
			<div class="col-2 item-caption">资源SCRIPT</div>
52
			<div class="col-10">
53
				<div class="form-item text" defVal="" name="script"></div>
54
			</div>
55
		</div>
56
57
		<div class="row">
58
			<div class="col-10"></div>
59
			<div class="col-2">
60
				<div class="btn pull-right opt-save">
61
					<i class="icon-check"></i> SAVE
62
				</div>
63
64
			</div>
65
66
		</div>
67
	</div>
68
69
</div>

+ 6 - 6
html/model/sys/resource/index.html

@ -32,21 +32,21 @@
32 32
					<th>操作</th>
33 33
				</tr>
34 34
			</thead>
35
			<tbody class="code-tpl code-tag-hold" code-func="data-list">
36
				<tr>
37
					<td>{{any-[]}}</td>
35
			<tbody>
36
				<tr ch-dir="list">
37
					<td>{{-_index}}</td>
38 38
					<td>{{name}}</td>
39 39
					<td>{{uri}}</td>
40 40
					<td>{{css}}</td>
41 41
					<td>{{script}}</td>
42 42
					<td>{{modal-bool}}</td>
43 43
					<td>{{main-bool}}</td>
44
					<td class="table-opt" resourceId="{{id}}"><i class="icon icon-remove-sign"></i><i class="icon icon-edit"></i></td>
44
					<td class="table-opt" resourceId="{{id}}"><i class="icon icon-remove-sign opt-del"></i><i class="icon icon-edit opt-edit"></i></td>
45 45
				</tr>
46 46
			</tbody>
47
			<tbody class="code-tpl code-tag-hold" code-func="data-emptylist">
47
			<tbody ch-dir="array.empty">
48 48
				<tr>
49
					<td class="empty-desc" colspan="8">表格暂无数据</td>
49
					<td colspan="8">表格暂无数据</td>
50 50
				</tr>
51 51
			</tbody>
52 52
		</table>

+ 7 - 20
js/codehtml.js

@ -242,8 +242,6 @@ $.define(["jQuery", "doc", "body", "util"], "code", function($, doc, $body, util
242 242
			},
243 243
			"val": function(env) {
244 244
				var hand = env.dir["_"],
245
					as = this.as,
246
					es = this.es,
247 245
					items, item, data = env.cd,
248 246
					p = this.p;
249 247
				if(p && p.length && p[0]) {
@ -252,39 +250,28 @@ $.define(["jQuery", "doc", "body", "util"], "code", function($, doc, $body, util
252 250
					while(items.length && data) {
253 251
						data = data[items.shift()];
254 252
					}
255
					if(items.length === 0 && data) {
253
					if(items.length === 0) {
256 254
						env.cd = data;
257
						hand.call(this, env);
255
				t
258 256
					}
259 257
					env.cd = env.ds.pop();
260 258
				}
261 259
			},
262 260
			"valTag": function(env) {
263
				var hand = env.dir["_"],
264
					as = this.as,
265
					es = this.es,
266
					items, item, data = env.cd,
267
					p = this.p;
261
				var items, item, data = env.cd,
262
					p = this.p,es = this.es;
268 263
				if(p && p.length && p[0]) {
269 264
					items = p[0].split("\\.");
270 265
					env.ds.push(data);
271 266
					while(items.length && data) {
272 267
						data = data[items.shift()];
273 268
					}
274
					if(items.length === 0 && data) {
269
					if(items.length === 0) {
275 270
						env.cd = data;
276
						var ele = doc.createElement(this.n);
277
						env.ce.appendChild(ele);
278
						env.es.push(env.ce);
279
						env.ce = ele;
280
						for(var i = 0; i < as.length; ++i) {
281
							as[i].h(env);
282
						}
283 271
						for(var i = 0; i < es.length; ++i) {
284 272
							item = es[i];
285 273
							env.dir(item.h).call(item, env);
286 274
						}
287
						env.ce = env.es.pop();
288 275
					}
289 276
					env.cd = env.ds.pop();
290 277
				}
@ -303,7 +290,7 @@ $.define(["jQuery", "doc", "body", "util"], "code", function($, doc, $body, util
303 290
						hObj.t = false;
304 291
						attrs = ele.attributes;
305 292
						ch = (ele.getAttribute("ch-dir") || "_").split("-");
306
						ev = { n: ele.nodeName, h: ch.shift(), p: ch };
293
						ev = { n: ele.nodeName, h: (ch.shift()||"_"), p: ch };
307 294
						as = ev.as = [];
308 295
						es = ev.es = [];
309 296
						hObj.r.push(ev);
@ -380,7 +367,7 @@ $.define(["jQuery", "doc", "body", "util"], "code", function($, doc, $body, util
380 367
			};
381 368
		},
382 369
		parseCode = function(ele) {
383
			var hand = parseElement(ele),
370
			var ele=ele.jquery?ele[0]:ele, hand = parseElement(ele),
384 371
				$ele = $(ele),
385 372
				bh = util.nochange,
386 373
				lses = [];

+ 6 - 5
js/common.js

@ -237,7 +237,7 @@ if(typeof jQuery === 'undefined') {
237 237
			 * ep={code:"",msg:"",detailMsg:"",url:""} pa=function(code,msg,detailMsg)
238 238
			 * pa=boolean
239 239
			 */
240
			ajaxErrHand = function(errparam, errHand) {
240
			defErrHand = function(errparam, errHand) {
241 241
				if(errHand) {
242 242
					var pt = $.type(errHand);
243 243
					if(pt == "booean") {
@ -277,11 +277,11 @@ if(typeof jQuery === 'undefined') {
277 277
					} else {
278 278
						rd.code = "" + rd.code;
279 279
						rd.url = pUrl;
280
						ajaxErrHand(rd, eh);
280
						defErrHand(rd, eh);
281 281
					}
282 282
				};
283 283
				config.error = function(jqXHR, textStatus, errorThrown) {
284
					ajaxErrHand({
284
					defErrHand({
285 285
						code: "err_" + (textStatus || ""),
286 286
						msg: textStatus,
287 287
						detailMsg: textStatus,
@ -365,7 +365,7 @@ if(typeof jQuery === 'undefined') {
365 365
					config);
366 366
			},
367 367
			del: function(url, sh, eh, pObj) {
368
				ajaxAccess("DELETE", url, null, sh, eh, pOjb);
368
				ajaxAccess("DELETE", url, null, sh, eh,pObj);
369 369
			},
370 370
			noop: noop,
371 371
			nochange: function(d) { return d },
@ -409,7 +409,8 @@ if(typeof jQuery === 'undefined') {
409 409
				buildElement(docf, obj);
410 410
				e.appendChild(docf);
411 411
			},
412
			serialize: serialize
412
			serialize: serialize,
413
			raise:function(err){defErrHand(err)}
413 414
		};
414 415
		$.util=ret;
415 416
		return ret;

+ 20 - 22
js/model/sys/dict/edit.js

@ -1,24 +1,22 @@
1
;
2
spa_define(function(spa) {
3

4
	return {
5
		modal: function(data) {
6
			var modalCtn =spa.getLastModalCtn();
7
			var root = modalCtn = modalCtn.children();	
8
			var form = root.find(".newForm").form();
9
			root.find(".modal-ctrl .icon-times").on("click",function(){
10
				spa.closeModal();
11
			});
12
			form.val(data.data);
13
			root.find(".opt-save").on("click",function(){
14
				form.doPut("../ajax/sys/dict/info",function(){
1
;spa_define(function() {
2
	return $.use(["spa","form"], function(spa,fb) {
3
		return {
4
			modal : function(data) {
5
				var root = spa.findInModal(".sys_dict_edit")
6
				var form = fb.build(root.find(".newForm"));
7
				root.find(".modal-ctrl .icon-times").on("click", function() {
15 8
					spa.closeModal();
16
					if(data.hand){
17
						data.hand();
18
					}
19
				},{});
20
			});
21
		}
22
	};
23

9
				});
10
				form.val(data.data);
11
				root.find(".opt-save").on("click", function() {
12
					form.doPut("../ajax/sys/dict/info", function() {
13
						spa.closeModal();
14
						if (data.hand) {
15
							data.hand();
16
						}
17
					}, {});
18
				});
19
			}
20
		};
21
	});
24 22
});

+ 63 - 147
js/model/sys/dict/index.js

@ -1,157 +1,73 @@
1
;
2
spa_define(function(spa) {
3

4
	return {
5
		main: function() {
6
			var root = spa.mainEle.children(".sys_dict_index");
7
			var pdg = root.pdg();
8

9
			var bindDataEvent = function() {
10
				root.find(".table-opt i.icon-edit").on("click", function() {
11
					var $this = $(this);
12
					var code = $this.parent().attr("dictCode");
13
					if(code) {
14
						$.util.get("../ajax/sys/dict/info/" + code, null, function(data) {
15
							if(data.readonly) {
16
								$.util.alertMsg("只读的");
17
							} else {
18
								spa.showModal("sys_dict_edit", {
1
;spa_define(function() {
2
	return  $.use(["spa","pagedatagrid","util","dict"],function(spa,pdgf,util,dict){
3
		return {
4
			main:function(){
5
				var root = spa.findInMain(".sys_dict_index");
6
				root.find(".opt-new").on("click", function() {
7
					spa.showModal("sys_dict_add", function() { pdg.load() });
8
				});
9
				var pdg = pdgf.build(root);
10
				var bindDataEvent =function(){
11
					root.find(".table-opt i.icon-edit").on("click", function() {
12
						var $this = $(this);
13
						var code = $this.parent().attr("dictCode");
14
						if(code) {
15
							util.get("../ajax/sys/dict/info/" + code, null, function(data) {
16
								if(data.readonly) {
17
									util.alert("只读的");
18
								} else {
19
									spa.showModal("sys_dict_edit", {
20
										data: data,
21
										hand: function() {
22
											pdg.load();
23
										}
24
									});
25
								}
26
							});
27
						}
28
					});
29
					root.find(".table-opt i.icon-list-ul").on("click",function(){
30
						var $this = $(this);
31
						var code = $this.parent().attr("dictCode");
32
						if(code) {
33
							util.get("../ajax/sys/dict/item/" + code, null, function(data) {
34
								spa.showModal("sys_dict_itemlist", {
19 35
									data: data,
20 36
									hand: function() {
21 37
										pdg.load();
22 38
									}
23 39
								});
24
							}
25
						}, {});
26
					}
27

28
				});
29
			};
30

31
			pdg.codeRef.addValueListener($.util.dictDisplay);
32
			pdg.codeRef.addValueListener(bindDataEvent);
33
			root.find(".opt-query").on("click", function() {
34
				//				console.log("dt load")
35
				pdg.load();
36
			});
37

38
			//console.log(pdg.formRef.val());
39
			pdg.load();
40

41
			root.find(".opt-new").on("click", function() {
42
				spa.showModal("sys_dict_add", function() { pdg.load() });
43
			});
44

45
			root.find(".table-opt i.icon-edit").on("click", function() {
46
				var $this = $(this);
47
				var code = $this.parent().attr("dictCode");
48
				if(code) {
49
					$.util.get("../ajax/sys/dict/info/" + code, null, function(data) {
50
						if(data.readonly) {
51
							$.util.alert("只读的");
52
						} else {
53
							spa.showModal("sys_dict_edit", {
54
								data: data,
55
								hand: function() {
56
									pdg.load();
57
								}
58 40
							});
59 41
						}
60
					}, {});
61
				}
62

63
			});
64

65
			//			root.find(".dt-tpl").on("click", "th.opt-check>i.icon-st-check", function() {
66
			//				var $this = $(this);
67
			//				$this.toggleClass("checked");
68
			//				if($this.hasClass("checked")) {
69
			//					root.find(".dt-tpl td.opt-check>i.icon-st-check").addClass("checked");
70
			//				} else {
71
			//					root.find(".dt-tpl td.opt-check>i.icon-st-check").removeClass("checked");
72
			//				}
73
			//			});
74
			//			root.find(".dt-tpl").on("click", "td.opt-check>i.icon-st-check", function() {
75
			//				var $this = $(this);
76
			//				$this.toggleClass("checked");
77
			//			});
78
			//			root.find(".opt-edit").on("click", function(nv) {
79
			//				var $org = root.find("td.opt-check>i.checked");
80
			//				if($org.length) {
81
			//					if($org.length > 1) {
82
			//						$.util.alertMsg("只能选择一个机构");
83
			//					} else {
84
			//						$.util.get("../ajax/sys/org/id/"+$org.attr("orgId"),null,function(rd){
85
			//							if(rd){
86
			//								spa.showModal("sys_org_edit", { data:rd, hand: function() { pdg.load() } })								
87
			//							}else{
88
			//								$.util.alertMsg("机构已不存在", function(){pdg.load();});
89
			//							}
90
			//						},{});
91
			//					}
92
			//				} else {
93
			//					$.util.alertMsg("请选择一个机构");
94
			//				}
95
			//			});
96
			//			root.find(".opt-del").on("click", function() {
97
			//				var $org = root.find("td.opt-check>i.checked");
98
			//				if($org.length) {
99
			//					var ret =[];
100
			//					$org.each(function(){
101
			//						ret.push($(this).attr("orgId"));						
102
			//					});
103
			//					$.util.boxMsg({
104
			//						title: "确认删除",
105
			//						content: "您是否要删除选中的机构信息,机构信息删除后不可恢复!!!!!!!!!!!!!!!!!!",
106
			//						btns: [{ caption: "删除", hand: function() {
107
			//							$.util.post("../ajax/sys/org/del",{ids:ret},function(){pdg.load()},{});							
108
			//						} },
109
			//							{ caption: "取消" }
110
			//						]
111
			//					});
112
			//				} else {
113
			//					$.util.alertMsg("请选择一个机构");
114
			//				}
115
			//			});
116
		},
117
		modal: function(data) {
118
			//console.log(spa.getLastModalCtn())
119
			//spa.getLastModalCtn().html(" in modal:"+(new Date()).toString());	
120
			//			var modalCtn =spa.getLastModalCtn();
121
			//			var root = modalCtn = modalCtn.children();	
122
			//			root.css("width","80%");
123
			//			root.find(".upload-btn").upload({
124
			//				uri:"/ajax/upload",
125
			//				maxSize:1048576,
126
			//				accept:"image/*",
127
			//				start:function(){console.log("start:"+JSON.stringify(this))},
128
			//				done:function(data){console.log("done:"+JSON.stringify({ref:this,data:data}))},
129
			//				fail:function(type,param){console.log("fail:"+JSON.stringify({ref:this,type:type,param:param}))},
130
			//				notity:function(total,loaded){console.log("notity:"+JSON.stringify({ref:this,total:total,loaded:loaded}))},
131
			//			});
132
			//			root.find(".icon-times").on("click",function(){
133
			//				spa.closeModal();
134
			//			});
135
			//			var pdg =root.pdg();
136
			//			pdg.codeRef.addValueListener($.util.dictDisplay);
137
			//			root.find(".query").on("click", function() {
138
			//				console.log("dt load")
139
			//				pdg.load();
140
			//			});
141
			//			root.find(".reset").on("click", function() {
142
			//				console.log("dt reset")
143
			//				pdg.formRef.reset();
144
			//			});
145
			//			console.log(pdg.formRef.val());
146
			//			pdg.load();
147

148
		},
149
		mainDestory: function() {
150

151
		},
152
		modalDestory: function() {
42
					});
43
					root.find(".table-opt i.icon-tasks").on("click",function(){
44
						var $this = $(this);
45
						var code = $this.parent().attr("dictCode");
46
						if(code) {
47
							util.get("../ajax/sys/dict/editItem/" + code, null, function(data) {
48
								spa.showModal("sys_dict_itemedit", {
49
									data: data,
50
									hand: function() {
51
										pdg.load();
52
									}
53
								});
54
							});
55
						}
56
					});
57
				};
58
				pdg.code.listen(dict.doTransfer);
59
				pdg.code.listen(bindDataEvent);
60
				pdg.code.shell("bool",function(env){
61
					var v = env.cd[this.k];
62
					return v===true?"是":(v===false?"否":"");
63
				});
64
				root.find(".opt-query").on("click", function() {
65
					pdg.load();
66
				});
67
				pdg.load();
153 68

154
		}
155
	};
156 69

70
			}
71
		};
72
	});
157 73
});

+ 73 - 113
js/model/sys/org/index.js

@ -1,119 +1,79 @@
1 1
;
2
spa_define(function(spa) {
3

4
	return {
5
		main: function() {
6
			var root = spa.mainEle().children(".sys_org_index");
7
			var pdg = root.pdg();
8
			pdg.code.shell("showDay", function(env) {
9
				if(env.cd && env.cd[this.k]) {
10
					var day = env.cd[this.k];
11
					return day.substring(0, 4) + "年" + day.substring(4, 6) + "月" + day.substring(6, 8) + "日";
12
				}
13
				return "";
14
			});
15
			pdg.code.listen($.dict.doTransfer);
16
			root.find(".opt-query").on("click", function() {
17
				//				console.log("dt load")
2
spa_define(function(){
3
	return $.use(["spa","pagedatagrid","util"],function(spa,pdgf,util){
4
		return{
5
			main: function() {				
6
				var root = spa.findInMain(".sys_org_index");
7
				var pdg = pdgf.build(root);
8
				pdg.code.shell("showDay", function(env) {
9
					if(env.cd && env.cd[this.k]) {
10
						var day = env.cd[this.k];
11
						return day.substring(0, 4) + "年" + day.substring(4, 6) + "月" + day.substring(6, 8) + "日";
12
					}
13
					return "";
14
				});
15
				pdg.code.listen($.dict.doTransfer);
16
				root.find(".opt-query").on("click", function() {
17
					pdg.load();
18
				});
18 19
				pdg.load();
19
			});
20

21
			//console.log(pdg.formRef.val());
22
			pdg.load();
23

24
			root.find(".opt-new").on("click", function() {
25
				spa.showModal("sys_org_new", function() { pdg.load() });
26
			});
27
			root.find(".dt-tpl").on("click", "th.opt-check>i.icon-st-check", function() {
28
				var $this = $(this);
29
				$this.toggleClass("checked");
30
				if($this.hasClass("checked")) {
31
					root.find(".dt-tpl td.opt-check>i.icon-st-check").addClass("checked");
32
				} else {
33
					root.find(".dt-tpl td.opt-check>i.icon-st-check").removeClass("checked");
34
				}
35
			});
36
			root.find(".dt-tpl").on("click", "td.opt-check>i.icon-st-check", function() {
37
				var $this = $(this);
38
				$this.toggleClass("checked");
39
			});
40
			root.find(".opt-edit").on("click", function() {
41
				var $org = root.find("td.opt-check>i.checked");
42
				if($org.length) {
43
					if($org.length > 1) {
44
						$.util.alertMsg("只能选择一个机构");
20
				root.find(".opt-new").on("click", function() {
21
					spa.showModal("sys_org_new", function() { pdg.load() });
22
				});
23
				root.find(".dt-tpl").on("click", "th.opt-check>i.icon-st-check", function() {
24
					var $this = $(this);
25
					$this.toggleClass("checked");
26
					if($this.hasClass("checked")) {
27
						root.find(".dt-tpl td.opt-check>i.icon-st-check").addClass("checked");
45 28
					} else {
46
						$.util.get("../ajax/sys/org/id/"+$org.attr("orgId"),null,function(rd){
47
							if(rd){
48
								spa.showModal("sys_org_edit", { data:rd, hand: function() { pdg.load() } })								
49
							}else{
50
								$.util.alertMsg("机构已不存在", function(){pdg.load();});
51
							}
52
						},{});
29
						root.find(".dt-tpl td.opt-check>i.icon-st-check").removeClass("checked");
53 30
					}
54
				} else {
55
					$.util.alertMsg("请选择一个机构");
56
				}
57
			});
58
			root.find(".opt-del").on("click", function() {
59
				var $org = root.find("td.opt-check>i.checked");
60
				if($org.length) {
61
					var ret =[];
62
					$org.each(function(){
63
						ret.push($(this).attr("orgId"));						
64
					});
65
					$.util.boxMsg({
66
						title: "确认删除",
67
						content: "您是否要删除选中的机构信息,机构信息删除后不可恢复!!!!!!!!!!!!!!!!!!",
68
						btns: [{ caption: "删除", hand: function() {
69
							$.util.post("../ajax/sys/org/del",{ids:ret},function(){pdg.load()},{});							
70
						} },
71
							{ caption: "取消" }
72
						]
73
					});
74
				} else {
75
					$.util.alertMsg("请选择一个机构");
76
				}
77
			});
78
		},
79
		modal: function(data) {
80
			//console.log(spa.getLastModalCtn())
81
			//spa.getLastModalCtn().html(" in modal:"+(new Date()).toString());	
82
			//			var modalCtn =spa.getLastModalCtn();
83
			//			var root = modalCtn = modalCtn.children();	
84
			//			root.css("width","80%");
85
			//			root.find(".upload-btn").upload({
86
			//				uri:"/ajax/upload",
87
			//				maxSize:1048576,
88
			//				accept:"image/*",
89
			//				start:function(){console.log("start:"+JSON.stringify(this))},
90
			//				done:function(data){console.log("done:"+JSON.stringify({ref:this,data:data}))},
91
			//				fail:function(type,param){console.log("fail:"+JSON.stringify({ref:this,type:type,param:param}))},
92
			//				notity:function(total,loaded){console.log("notity:"+JSON.stringify({ref:this,total:total,loaded:loaded}))},
93
			//			});
94
			//			root.find(".icon-times").on("click",function(){
95
			//				spa.closeModal();
96
			//			});
97
			//			var pdg =root.pdg();
98
			//			pdg.codeRef.addValueListener($.util.dictDisplay);
99
			//			root.find(".query").on("click", function() {
100
			//				console.log("dt load")
101
			//				pdg.load();
102
			//			});
103
			//			root.find(".reset").on("click", function() {
104
			//				console.log("dt reset")
105
			//				pdg.formRef.reset();
106
			//			});
107
			//			console.log(pdg.formRef.val());
108
			//			pdg.load();
109

110
		},
111
		mainDestory: function() {
112

113
		},
114
		modalDestory: function() {
115

116
		}
117
	};
31
				});
32
				root.find(".dt-tpl").on("click", "td.opt-check>i.icon-st-check", function() {
33
					var $this = $(this);
34
					$this.toggleClass("checked");
35
				});
36
				root.find(".opt-edit").on("click", function() {
37
					var $org = root.find("td.opt-check>i.checked");
38
					if($org.length) {
39
						if($org.length > 1) {
40
							util.alertMsg("只能选择一个机构");
41
						} else {
42
							$.util.get("../ajax/sys/org/id/"+$org.attr("orgId"),null,function(rd){
43
								if(rd){
44
									spa.showModal("sys_org_edit", { data:rd, hand: function() { pdg.load() } })								
45
								}else{
46
									util.alertMsg("机构已不存在", function(){pdg.load();});
47
								}
48
							},{});
49
						}
50
					} else {
51
						util.alert("请选择一个机构");
52
					}
53
				});
54
				root.find(".opt-del").on("click", function() {
55
					var $org = root.find("td.opt-check>i.checked");
56
					if($org.length) {
57
						var ret =[];
58
						$org.each(function(){
59
							ret.push($(this).attr("orgId"));						
60
						});
61
						util.boxMsg({
62
							title: "确认删除",
63
							content: "您是否要删除选中的机构信息,机构信息删除后不可恢复!!!!!!!!!!!!!!!!!!",
64
							btns: [{ caption: "删除", hand: function() {
65
								util.post("../ajax/sys/org/del",{ids:ret},function(){pdg.load()},{});							
66
							} },
67
								{ caption: "取消" }
68
							]
69
						});
70
					} else {
71
						util.alert("请选择一个机构");
72
					}
73
				});
74
			},mainDestory: function() {
118 75

76
			},
77
		};
78
	});
119 79
});

+ 19 - 21
js/model/sys/org/new.js

@ -1,25 +1,23 @@
1 1
;
2
spa_define(function(spa) {
3

4
	return {
5
		modal: function(data) {
6
			var modalCtn =spa.getLastModalCtn();
7
			var root = modalCtn = modalCtn.children();	
8
			var form = root.find(".newForm").form();
9
			root.find(".modal-ctrl .icon-times").on("click",function(){
10
				spa.closeModal();
11
			});
12
			
13
			root.find(".opt-save").on("click",function(){
14
				form.doPost("../ajax/sys/org",function(){
2
spa_define(function() {
3
	return $.use(["spa","util","form"], function(spa,util,fb) {
4
		return {
5
			modal : function(data) {
6
				var root = spa.findInModal(".sys_resource_new");
7
				var form =fb(root.find(".newForm"));
8
				root.find(".modal-ctrl .icon-times").on("click", function() {
15 9
					spa.closeModal();
16
					if(data){
17
						data();
18
					}
19
				},{});
20
			});
21
			
22
		}
23
	};
10
				});
24 11

12
				root.find(".opt-save").on("click", function() {
13
					form.doPost("../ajax/sys/org", function() {
14
						spa.closeModal();
15
						if (data) {
16
							data();
17
						}
18
					}, {});
19
				});
20
			}
21
		}
22
	});
25 23
});

+ 22 - 0
js/model/sys/resource/edit.js

@ -0,0 +1,22 @@
1
;spa_define(function(){
2
	return $.use(["spa","util","form"],function(spa,util,form){
3
		return {
4
			modal:function(data){
5
				var root = spa.findInModal(".sys_resource_edit");
6
				root.find(".modal-ctrl .icon-times").on("click",function(){
7
					spa.closeModal();
8
				});
9
				var ef = form.build(root.find(".opt-form"));
10
				ef.val(data.data);
11
				root.find(".opt-save").on("click",function(){
12
					ef.doPut("../ajax/sys/resource",function(){
13
						spa.closeModal();
14
						if(data.hand){
15
							data.hand();
16
						}
17
					},{});
18
				});
19
			}
20
		};
21
	});
22
});

+ 69 - 89
js/model/sys/resource/index.js

@ -1,93 +1,73 @@
1 1
;
2
spa_define(function(spa) {
3

4
	return {
5
		main: function() {
6
			var form = spa.mainEle.find(".queryForm").form();
7
			var codeRef = spa.mainEle.find(".dt-tpl").code();
8
			var queryBtn = spa.mainEle.find(".queryForm .icon-search");
9
			var newBtn = spa.mainEle.find(".opt-new");
10
			newBtn.on("click", function() {
11
				spa.showModal("sys_resource_new",load);
12
			});
13
			var tableData = { data: [] },
14
				allData = [];
15
			var query = function() {
16
				var val = form.item("qn").val();
17
				if(val) {
18
					var td = tableData.data = [];
19
					for(var i = 0; i < allData.length; ++i) {
20
						var item = allData[i];
21
						if(item && item.name && item.name.indexOf(val) >= 0) {
22
							td.push(item);
2
spa_define(function() {
3
	return $.use(["spa","code","form","util"],function(spa,code,form,util){
4
		return {
5
			main: function() {
6
				var root = spa.findInMain(".sys_resource_index");
7
				var qf = form.build(root.find(".queryForm"));
8
				var cr = code.parseCode(root.find(".dt-tpl"));
9
				var queryBtn = root.find(".queryForm .icon-search");
10
				var newBtn = root.find(".opt-new");
11
				root.on("click",".opt-del",function(){
12
					var resId = $(this).parent().attr("resourceId");
13
					if(resId){
14
						util.boxMsg({
15
							title: "确认删除",
16
							content: "您是否要删除选中的资源信息,资源信息删除后不可恢复!!!!!!!!!!!!!!!!!!",
17
							btns: [{ caption: "删除", hand: function() {
18
								util.del("../ajax/sys/resource/id/"+resId,load,{});							
19
							} },
20
								{ caption: "取消" }
21
							]
22
						});
23
					}
24
				});
25
				root.on("click",".opt-edit",function(){
26
					var resId = $(this).parent().attr("resourceId");
27
					if(resId){
28
						var resource = allData.find(function(item){return item.id===resId});
29
						if(resource){
30
							spa.showModal("sys_resource_edit",{data:resource,hand:load});
31
						}
32
					}
33
				});
34
				cr.shell("bool",function(env){
35
					var v = env.cd[this.k];
36
					return v===true?"是":(v===false?"否":"");
37
				});
38
				newBtn.on("click", function() {
39
					spa.showModal("sys_resource_new",load);
40
				});
41
				var tableData = { data: [] },
42
					allData = [];
43
				var query = function() {
44
					var val = qf.item("qn").get();
45
					if(val) {
46
						var td = tableData.data = [];
47
						for(var i = 0; i < allData.length; ++i) {
48
							var item = allData[i];
49
							if(item && item.name && item.name.indexOf(val) >= 0) {
50
								td.push(item);
51
							}
23 52
						}
53
					} else {
54
						tableData.data = allData;
24 55
					}
25
				} else {
26
					tableData.data = allData;
27
				}
28
				codeRef.val(tableData);
29
			};
30
			var load = function() {
31
				$.util.get("../ajax/sys/resource/all", null, function(data) {
32
					allData = data || [];
33
					query();
34
				}, {});
35
			};
36

37
			queryBtn.on("click", query);
38
			load();
39

40
			//			var pdg = spa.mainEle.children(".main1").pdg();
41
			//			pdg.codeRef.addValueListener($.util.dictDisplay);
42
			//			spa.mainEle.find(".query").on("click", function() {
43
			////				console.log("dt load")
44
			//				pdg.load();
45
			//			});
46
			//			spa.mainEle.find(".reset").on("click", function() {
47
			////				console.log("dt reset")
48
			//				pdg.formRef.reset();
49
			//			});
50
			//			//console.log(pdg.formRef.val());
51
			//			pdg.load();
52
		},
53
		modal: function(data) {
54
			//console.log(spa.getLastModalCtn())
55
			//spa.getLastModalCtn().html(" in modal:"+(new Date()).toString());	
56
			//			var modalCtn =spa.getLastModalCtn();
57
			//			var root = modalCtn = modalCtn.children();	
58
			//			root.css("width","80%");
59
			//			root.find(".upload-btn").upload({
60
			//				uri:"/ajax/upload",
61
			//				maxSize:1048576,
62
			//				accept:"image/*",
63
			//				start:function(){console.log("start:"+JSON.stringify(this))},
64
			//				done:function(data){console.log("done:"+JSON.stringify({ref:this,data:data}))},
65
			//				fail:function(type,param){console.log("fail:"+JSON.stringify({ref:this,type:type,param:param}))},
66
			//				notity:function(total,loaded){console.log("notity:"+JSON.stringify({ref:this,total:total,loaded:loaded}))},
67
			//			});
68
			//			root.find(".icon-times").on("click",function(){
69
			//				spa.closeModal();
70
			//			});
71
			//			var pdg =root.pdg();
72
			//			pdg.codeRef.addValueListener($.util.dictDisplay);
73
			//			root.find(".query").on("click", function() {
74
			//				console.log("dt load")
75
			//				pdg.load();
76
			//			});
77
			//			root.find(".reset").on("click", function() {
78
			//				console.log("dt reset")
79
			//				pdg.formRef.reset();
80
			//			});
81
			//			console.log(pdg.formRef.val());
82
			//			pdg.load();
83

84
		},
85
		mainDestory: function() {
86

87
		},
88
		modalDestory: function() {
89

90
		}
91
	};
92

56
					cr.val(tableData.data);
57
				};
58
				var load = function() {
59
					util.get("../ajax/sys/resource/all", null, function(data) {
60
						allData = data || [];
61
						query();
62
					}, {});
63
				};
64
	
65
				queryBtn.on("click", query);
66
				load();	
67
			},
68
			mainDestory: function() {
69
	
70
			}
71
		};
72
	});
93 73
});

+ 2 - 2
js/pageDataGrid.js

@ -1,11 +1,11 @@
1
$.define(["jQuery", "util", "form", "code", "pager"], "pageDataGrid", function($, util, form, code, pager) {
1
$.define(["jQuery", "util", "form", "code", "pager"], "pagedatagrid", function($, util, form, code, pager) {
2 2
	var qf = ".dt-form",
3 3
		qt = ".dt-tpl",
4 4
		qp = ".dt-pager",
5 5
		derr = {},
6 6
		dajaxCfg = {},
7 7
		configPageIndex = function(fn, data) {
8
			if(fn && data  && data.data && data.data.length) {
8
			if(fn && data && data.data && data.data.length) {
9 9
				var b = (data.pageNo - 1) * data.pageSize;
10 10
				data.data.forEach(function(obj) {
11 11
					++b;

+ 21 - 18
js/spa.js

@ -7,16 +7,10 @@ $.define(["jQuery", "util", "doc", "win", "body"], "spa", function($, util, doc,
7 7
		resCache = {},
8 8
		cssCache = {},
9 9
		htmlCache = { "#": "#" },
10
		modelCache = {},
10
		modelCache = {"_def_error_form":{}},
11 11
		scriptCache = {}, resUri, menuUri, menuEle,
12 12
		main, mainEle,
13
		errHand = {
14
			"defErrHand": function(err) {
15
				showModal("_def_err_form", err);
16
			}
17
		},
18 13
		cfg = {
19
			error: errHand,
20 14
			ajaxCfg: { mask: true },
21 15
			mask: true,
22 16
			loadEnabled: true
@ -33,14 +27,14 @@ $.define(["jQuery", "util", "doc", "win", "body"], "spa", function($, util, doc,
33 27
						});
34 28
					}
35 29
					menuUri ? load_menu() : showMain();
36
				}, cfg.error, cfg.ajaxCfg);
30
				},false, cfg.ajaxCfg);
37 31
			}
38 32
		},
39 33
		load_menu = function() {
40 34
			util.get(menuUri, null, function(menu) {
41 35
				build_menu(menu);
42 36
				showMain();
43
			}, cfg.error, cfg.ajaxCfg);
37
			},false, cfg.ajaxCfg);
44 38
		},
45 39
		build_menu = function(menu) {
46 40
			if(menuEle && menuEle.length && menu && menu.length) {
@ -180,7 +174,7 @@ $.define(["jQuery", "util", "doc", "win", "body"], "spa", function($, util, doc,
180 174
				}).fail(function(jqXHR, textStatus, errorThrown) {
181 175
					model.state = 12;
182 176
					if(cfg.mask) { util.hideLoading(); }
183
					cfg.error({
177
					uril.raise({
184 178
						code: "loadModelHtml_" + (textStatus || ""),
185 179
						msg: textStatus,
186 180
						detailMsg: textStatus,
@ -235,7 +229,7 @@ $.define(["jQuery", "util", "doc", "win", "body"], "spa", function($, util, doc,
235 229
					if(cfg.mask) {
236 230
						util.hideLoading();
237 231
					}
238
					cfg.error({
232
					util.raise({
239 233
						code: "buildModelFactory_" + err.toString(),
240 234
						msg: err.toString() || "",
241 235
						detailMsg: err.toString() || "",
@ -264,7 +258,7 @@ $.define(["jQuery", "util", "doc", "win", "body"], "spa", function($, util, doc,
264 258
					}
265 259
					if(model.state < 22) {
266 260
						model.state = 22;
267
						cfg.error({
261
						util.raise({
268 262
							code: "loadModelScript_" + err.toString(),
269 263
							msg: err.toString() || "",
270 264
							detailMsg: err.toString() || "",
@ -286,7 +280,7 @@ $.define(["jQuery", "util", "doc", "win", "body"], "spa", function($, util, doc,
286 280
									if(cfg.mask) {
287 281
										util.hideLoading();
288 282
									}
289
									cfg.error({
283
									util.raise({
290 284
										code: "loadModelScript_timeout",
291 285
										msg: "",
292 286
										detailMsg: "",
@ -328,7 +322,7 @@ $.define(["jQuery", "util", "doc", "win", "body"], "spa", function($, util, doc,
328 322
				if(model) {
329 323
					loadModel(model, afterLoadByModal, data);
330 324
				} else {
331
					cfg.error({ code: "invalid_model", msg: "不正确的模块[" + id + "]", detailMsg: "不正确的模块[" + id + "]" });
325
					util.raise({ code: "invalid_model", msg: "不正确的模块[" + id + "]", detailMsg: "不正确的模块[" + id + "]" });
332 326
				}
333 327
			}
334 328
		},
@ -346,7 +340,7 @@ $.define(["jQuery", "util", "doc", "win", "body"], "spa", function($, util, doc,
346 340
				if(model) {
347 341
					loadModel(model, afterLoadByMain);
348 342
				} else {
349
					cfg.error({ code: "invalid_model", msg: "不正确的模块[" + id + "]", detailMsg: "不正确的模块[" + id + "]" });
343
					util.raise({ code: "invalid_model", msg: "不正确的模块[" + id + "]", detailMsg: "不正确的模块[" + id + "]" });
350 344
				}
351 345
			}
352 346
		},
@ -378,7 +372,7 @@ $.define(["jQuery", "util", "doc", "win", "body"], "spa", function($, util, doc,
378 372
					util.closeModal();
379 373
				}
380 374
			} else {
381
				cfg.error({ code: "invalid_dir", msg: "can't close modal:has top layer", detailMsg: "can't close modal:has top layer" });
375
				util.raise({ code: "invalid_dir", msg: "can't close modal:has top layer", detailMsg: "can't close modal:has top layer" });
382 376
			}
383 377
		},
384 378
		build = function(config) {
@ -400,8 +394,17 @@ $.define(["jQuery", "util", "doc", "win", "body"], "spa", function($, util, doc,
400 394
			getLastModalIndex: getLastModalIndex,
401 395
			showMain: showMain,
402 396
			showModal: showModal,
403
			mainEle:function(){
404
				return mainEle;
397
			mainChildren:function(selector){
398
				return mainEle.children(selector);
399
			},
400
			modalChildren:function(selector){
401
				return getLastModalCtn.children(selector);
402
			},
403
			findInMain:function(selector){
404
				return mainEle.find(selector);
405
			},
406
			findInModal:function(selector){
407
				return getLastModalCtn().find(selector);
405 408
			}
406 409
		};
407 410
		$.spa=spa;