Skip to content

Commit af8507a

Browse files
committed
树选择控件,增加搜索功能。感谢:联何的贡献
1 parent f9753e6 commit af8507a

File tree

7 files changed

+81
-12
lines changed

7 files changed

+81
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ JeeSite 提供了常用工具进行封装,包括日志工具、缓存工具、
7171

7272
1. 具备运行环境:JDK1.6、Maven3.0、MySql5。
7373
2. 修改src\main\resources\application.properties文件中的数据库设置参数。
74-
3. 根据修改参数创建对应MySql数据库。
74+
3. 根据修改参数创建对应MySql数据库(数据库编码:UTF-8)
7575
4. 运行bin\resresh-db\refresh-db.bat脚本,即可导入表结构及演示数据
7676
5. 运行bin\jetty.bat,启动Web服务器(第一次运行,需要下载依赖jar包,请耐心等待)。
7777
6. 最高管理员账号,用户名:thinkgem 密码:admin

bin/refresh-db/init-data.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,11 @@
207207
<!-- 系统部门:编号、父级编号、所有父级编号、归属区域编号、部门编码 、部门名称、备注、删除标记(0:正常;1:删除) -->
208208
<sys_office id="1" parent_id="0" parent_ids="0," area_id="1" code="" name="顶级部门" remarks="" />
209209
<sys_office id="2" parent_id="1" parent_ids="0,1," area_id="1" code="0001" name="系统管理" remarks="" />
210-
<sys_office id="4" parent_id="2" parent_ids="0,1," area_id="1" code="000101" name="系统管理1" remarks="" />
211-
<sys_office id="5" parent_id="2" parent_ids="0,1," area_id="1" code="000102" name="系统管理2" remarks="" />
210+
<sys_office id="4" parent_id="2" parent_ids="0,1,2," area_id="1" code="000101" name="系统管理1" remarks="" />
211+
<sys_office id="5" parent_id="2" parent_ids="0,1,2," area_id="1" code="000102" name="系统管理2" remarks="" />
212212
<sys_office id="3" parent_id="1" parent_ids="0,1," area_id="1" code="0002" name="系统维护" remarks="" />
213-
<sys_office id="6" parent_id="2" parent_ids="0,1," area_id="1" code="000201" name="系统维护1" remarks="" />
214-
<sys_office id="7" parent_id="2" parent_ids="0,1," area_id="1" code="000202" name="系统维护2" remarks="" />
213+
<sys_office id="6" parent_id="3" parent_ids="0,1,3," area_id="1" code="000201" name="系统维护1" remarks="" />
214+
<sys_office id="7" parent_id="3" parent_ids="0,1,3," area_id="1" code="000202" name="系统维护2" remarks="" />
215215

216216
<!-- 系统菜单表:编号、父级编号、名称、链接 、目标、图标、排序(升序)、是否在菜单中显示(1:显示;0:不显示)、权限标识-->
217217
<sys_menu id="1" parent_id="0" parent_ids="0," name="顶级菜单" href="" target="" icon="" sort="0" is_show="1" permission="" user_id="1" />

doc/JeeSite About.docx

656 Bytes
Binary file not shown.

doc/JeeSite Developer.docx

-56 Bytes
Binary file not shown.

src/main/webapp/WEB-INF/views/include/head.jsp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<link href="${ctxStatic}/jquery-validation/1.11.0/jquery.validate.min.css" type="text/css" rel="stylesheet" />
1111
<script src="${ctxStatic}/jquery-validation/1.11.0/jquery.validate.min.js" type="text/javascript"></script>
1212
<script src="${ctxStatic}/jquery-validation/1.11.0/jquery.validate.method.min.js" type="text/javascript"></script>
13-
<link href="${ctxStatic}/bootstrap/2.3.1/css_${ctxTheme}/bootstrap.min.css" type="text/css" rel="stylesheet" />
13+
<link href="${ctxStatic}/bootstrap/2.3.1/css_${not empty ctxTheme?ctxTheme:'default'}/bootstrap.min.css" type="text/css" rel="stylesheet" />
1414
<script src="${ctxStatic}/bootstrap/2.3.1/js/bootstrap.min.js" type="text/javascript"></script>
1515
<!--[if lte IE 6]><link href="${ctxStatic}/bootstrap/bsie/css/bootstrap-ie6.min.css" type="text/css" rel="stylesheet" />
1616
<script src="${ctxStatic}/bootstrap/bsie/js/bootstrap-ie.min.js" type="text/javascript"></script><![endif]-->

src/main/webapp/WEB-INF/views/modules/sys/tagIconselect.jsp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<%@ page contentType="text/html;charset=UTF-8" %>
22
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
3-
<html>
3+
<!DOCTYPE html>
4+
<html style="overflow-x:hidden;overflow-y:auto;">
45
<head>
56
<title>图标选择</title>
6-
<meta name="decorator" content="default"/>
7+
<%@include file="/WEB-INF/views/include/head.jsp" %>
78
<style type="text/css">
89
.the-icons {padding:25px 10px 15px;list-style:none;}
910
.the-icons li {float:left;width:22%;line-height:25px;margin:2px 5px;cursor:pointer;}

src/main/webapp/WEB-INF/views/modules/sys/tagTreeselect.jsp

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
<%@ page contentType="text/html;charset=UTF-8" %>
22
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
3-
<html>
3+
<!DOCTYPE html>
4+
<html style="overflow-x:hidden;overflow-y:auto;">
45
<head>
56
<title>栏目列表</title>
6-
<meta name="decorator" content="default"/>
7+
<%@include file="/WEB-INF/views/include/head.jsp" %>
78
<%@include file="/WEB-INF/views/include/treeview.jsp" %>
89
<script type="text/javascript">
10+
var key, lastValue = "", nodeList = [];
911
var tree, setting = {view:{selectedMulti:false},check:{enable:"${checked}",nocheckInherit:true},
10-
data:{simpleData:{enable:true}},callback:{beforeClick:function(id, node){
12+
data:{simpleData:{enable:true}},
13+
view:{
14+
fontCss:function(treeId, treeNode) {
15+
return (!!treeNode.highlight) ? {"font-weight":"bold"} : {"font-weight":"normal"};
16+
}
17+
},
18+
callback:{beforeClick:function(id, node){
1119
if("${checked}" == "true"){
1220
tree.checkNode(node, !node.checked, true, true);
1321
return false;
1422
}
15-
}, onDblClick:function(){
23+
},
24+
onDblClick:function(){
1625
top.$.jBox.getBox().find("button[value='ok']").trigger("click");
1726
//alert($("input[type='text']", top.mainFrame.document).val());
1827
//$("input[type='text']", top.mainFrame.document).focus();
@@ -21,6 +30,7 @@
2130
$.get("${ctx}${url}${fn:indexOf(url,'?')==-1?'?':'&'}&extId=${extId}&module=${module}&t="+new Date().getTime(), function(zNodes){
2231
// 初始化树结构
2332
tree = $.fn.zTree.init($("#tree"), setting, eval("("+zNodes+")"));
33+
2434
// 默认展开一级节点
2535
var nodes = tree.getNodesByParam("level", 0);
2636
for(var i=0; i<nodes.length; i++) {
@@ -38,9 +48,67 @@
3848
}
3949
}
4050
});
51+
key = $("#key");
52+
key.bind("focus", focusKey).bind("blur", blurKey).bind("change keydown cut input propertychange", searchNode);
4153
});
54+
function focusKey(e) {
55+
if (key.hasClass("empty")) {
56+
key.removeClass("empty");
57+
}
58+
}
59+
function blurKey(e) {
60+
if (key.get(0).value === "") {
61+
key.addClass("empty");
62+
}
63+
searchNode(e);
64+
}
65+
function searchNode(e) {
66+
// 取得输入的关键字的值
67+
var value = $.trim(key.get(0).value);
68+
69+
// 按名字查询
70+
var keyType = "name";
71+
if (key.hasClass("empty")) {
72+
value = "";
73+
}
74+
75+
// 如果和上次一次,就退出不查了。
76+
if (lastValue === value) {
77+
return;
78+
}
79+
80+
// 保存最后一次
81+
lastValue = value;
82+
83+
// 如果要查空字串,就退出不查了。
84+
if (value === "") {
85+
return;
86+
}
87+
updateNodes(false);
88+
nodeList = tree.getNodesByParamFuzzy(keyType, value);
89+
updateNodes(true);
90+
}
91+
function updateNodes(highlight) {
92+
for(var i=0, l=nodeList.length; i<l; i++) {
93+
nodeList[i].highlight = highlight;
94+
tree.updateNode(nodeList[i]);
95+
tree.expandNode(nodeList[i].getParentNode(), true, false, false);
96+
}
97+
}
98+
function search() {
99+
$("#search").slideToggle(200);
100+
$("#txt").toggle();
101+
$("#key").focus();
102+
}
42103
</script>
43104
</head>
44105
<body>
106+
<div style="position:absolute;right:8px;top:5px;cursor:pointer;" onclick="search();">
107+
<i class="icon-search"></i><label id="txt">搜索</label>
108+
</div>
109+
<div id="search" class="control-group hide" style="padding:10px 0 0 15px;">
110+
<label for="key" class="control-label" style="float:left;padding:5px 5px 3px;">关键字:</label>
111+
<input type="text" class="empty" id="key" name="key" maxlength="50" style="width:180px;">
112+
</div>
45113
<div id="tree" class="ztree" style="padding:15px 20px;"></div>
46114
</body>

0 commit comments

Comments
 (0)