742a494e4a7b1f7bef94562a5da30855888ca994.svn-base 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
  2. <%
  3. String path = request.getContextPath();
  4. %>
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6. <html xmlns="http://www.w3.org/1999/xhtml">
  7. <head>
  8. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  9. <title></title>
  10. <!--框架必需start-->
  11. <script type="text/javascript" src="<%=path%>/libs/js/jquery.js"></script>
  12. <script type="text/javascript" src="<%=path%>/libs/js/language/cn.js"></script>
  13. <script type="text/javascript" src="<%=path%>/libs/js/framework.js"></script>
  14. <link href="<%=path%>/libs/css/import_basic.css" rel="stylesheet" type="text/css"/>
  15. <link rel="stylesheet" type="text/css" id="skin" prePath="<%=path%>/"/>
  16. <link rel="stylesheet" type="text/css" id="customSkin"/>
  17. <!--框架必需end-->
  18. <!-- 树组件start -->
  19. <script type="text/javascript" src="<%=path%>/libs/js/tree/ztree/ztree.js"></script>
  20. <link type="text/css" rel="stylesheet" href="<%=path%>/libs/js/tree/ztree/ztree.css"></link>
  21. <!-- 树组件end -->
  22. <!-- 树形双选器start -->
  23. <script type="text/javascript" src="<%=path%>/libs/js/form/listerTree.js"></script>
  24. <!-- 树形双选器end -->
  25. </head>
  26. <body>
  27. <div class="box1" panelWidth="800">
  28. <fieldset>
  29. <legend>注意</legend>
  30. <p>树形双选器中,可以通过点击节点右侧图标或者拖拽节点进行选择</p>
  31. </fieldset>
  32. <div class="height_15"></div>
  33. <fieldset>
  34. <legend>1、使用url赋值</legend>
  35. <div class="red">此示例由后台支持</div>
  36. <div class="listerTree" id="listerTree1" url="<%=path%>/form/getTreeLister.action"></div>
  37. <input type="button" value="获取值" onclick="getValue()"/>
  38. <input type="button" value="获取选中项文本" onclick="getText()"/>
  39. <input type="button" value="获取选中项数据" onclick="getData()"/>
  40. </fieldset>
  41. <div class="height_15"></div>
  42. <fieldset>
  43. <legend>2、使用url+参数赋值</legend>
  44. <div class="red">此示例由后台支持</div>
  45. <div class="listerTree" id="listerTree1" url="<%=path%>/form/getTreeLister.action" params='{"orgid":"2"}'></div>
  46. </fieldset>
  47. <div class="height_15"></div>
  48. <fieldset>
  49. <legend>3、赋值给标签的data属性</legend>
  50. <div class="listerTree" data='{"toList":[],"fromList":[{"id":"1","parentId":"0","open":"true","name":"部门1","oldParentId":"null","drag":"false"},{"id":"11","parentId":"1","name":"员工1","oldParentId":"1"},{"id":"12","parentId":"1","name":"员工2","oldParentId":"1"},{"id":"13","parentId":"1","name":"员工3","oldParentId":"1","drag":"false"},{"id":"2","parentId":"0","open":"true","name":"部门2","oldParentId":"null","drag":"false"},{"id":"21","parentId":"2","name":"员工4","oldParentId":"2"}]}'></div>
  51. <br/>
  52. <span class="red">这里通过设置“员工3”节点的drag属性让其不可被选中</span>
  53. </fieldset>
  54. <div class="height_15"></div>
  55. <fieldset>
  56. <legend>4、动态设置data(本地数据源)</legend>
  57. <div class="listerTree" id="listerTree4" keepDefaultStyle="true"></div>
  58. </fieldset>
  59. <div class="height_15"></div>
  60. <fieldset>
  61. <legend>5、动态设置data(远程数据源)</legend>
  62. <div class="red">此示例由后台支持</div>
  63. <div class="listerTree" id="listerTree5" keepDefaultStyle="true"></div>
  64. </fieldset>
  65. <div class="height_15"></div>
  66. <fieldset>
  67. <legend>6、初始时存在已选值</legend>
  68. <p>通过设置数据的toList内容来实现已选值</p>
  69. <div class="listerTree" data='{"toList":[{"id":"11","parentId":"1","name":"员工1","oldParentId":"1"},{"id":"12","parentId":"1","name":"员工2","oldParentId":"1"}],"fromList":[{"id":"1","parentId":"0","open":"true","name":"部门1","oldParentId":"null","drag":"false"},{"id":"13","parentId":"1","name":"员工3","oldParentId":"1"},{"id":"2","parentId":"0","open":"true","name":"部门2","oldParentId":"null","drag":"false"},{"id":"21","parentId":"2","name":"员工4","oldParentId":"2"}]}'></div>
  70. <br/> <p>通过设置selectedValue实现已选值</p>
  71. <div class="listerTree" selectedValue="11,12" data='{"toList":[],"fromList":[{"id":"1","parentId":"0","open":"true","name":"部门1","oldParentId":"null","drag":"false"},{"id":"11","parentId":"1","name":"员工1","oldParentId":"1"},{"id":"12","parentId":"1","name":"员工2","oldParentId":"1"},{"id":"13","parentId":"1","name":"员工3","oldParentId":"1"},{"id":"2","parentId":"0","open":"true","name":"部门2","oldParentId":"null","drag":"false"},{"id":"21","parentId":"2","name":"员工4","oldParentId":"2"}]}'></div>
  72. <br/>使用selectedValue实现了已选值,在操作后再使用render()方法刷新后可以还原为初始值。参见最后一个例子:重置树形双选器。
  73. <br/>通过设置数据的toList内容来实现已选值则不可以还原。
  74. </fieldset>
  75. <div class="height_15"></div>
  76. <fieldset>
  77. <legend>7、使用隐藏域</legend>
  78. <p>如果为组件添加name属性,那么会自动生成一个隐藏域input,用来存储组件当前的value,该input的name与组件name一致。<br/>在提交表单时会用到。</p>
  79. <div class="listerTree" name="listerTree7" data='{"toList":[],"fromList":[{"id":"1","parentId":"0","open":"true","name":"部门1","oldParentId":"null","drag":"false"},{"id":"11","parentId":"1","name":"员工1","oldParentId":"1"},{"id":"12","parentId":"1","name":"员工2","oldParentId":"1"},{"id":"13","parentId":"1","name":"员工3","oldParentId":"1"},{"id":"2","parentId":"0","open":"true","name":"部门2","oldParentId":"null","drag":"false"},{"id":"21","parentId":"2","name":"员工4","oldParentId":"2"}]}'></div>
  80. <input type="button" value="获取隐藏域选中值" onclick="getHiddenValue()"/>
  81. </fieldset>
  82. <div class="height_15"></div>
  83. <fieldset>
  84. <legend>8、禁用/启用</legend>
  85. <div class="listerTree" id="listerTree8" disabled="true" data='{"toList":[],"fromList":[{"id":"1","parentId":"0","open":"true","name":"部门1","oldParentId":"null","drag":"false"},{"id":"11","parentId":"1","name":"员工1","oldParentId":"1"},{"id":"12","parentId":"1","name":"员工2","oldParentId":"1"},{"id":"13","parentId":"1","name":"员工3","oldParentId":"1"},{"id":"2","parentId":"0","open":"true","name":"部门2","oldParentId":"null","drag":"false"},{"id":"21","parentId":"2","name":"员工4","oldParentId":"2"}]}'></div>
  86. <br/>
  87. <input type="button" value="启用" onclick="enableLister()" style="width:120px;"/>
  88. <input type="button" value="禁用" onclick="disableLister()" style="width:120px;"/>
  89. </fieldset>
  90. <div class="height_15"></div>
  91. <fieldset>
  92. <legend>9、自定义尺寸</legend>
  93. <div class="listerTree" listerWidth="140" listerHeight="180" data='{"toList":[],"fromList":[{"id":"1","parentId":"0","open":"true","name":"部门1","oldParentId":"null","drag":"false"},{"id":"11","parentId":"1","name":"员工1","oldParentId":"1"},{"id":"12","parentId":"1","name":"员工2","oldParentId":"1"},{"id":"13","parentId":"1","name":"员工3","oldParentId":"1"},{"id":"2","parentId":"0","open":"true","name":"部门2","oldParentId":"null","drag":"false"},{"id":"21","parentId":"2","name":"员工4","oldParentId":"2"}]}'></div>
  94. </fieldset>
  95. <div class="height_15"></div>
  96. <fieldset>
  97. <legend>10、自定义图标</legend>
  98. <div class="listerTree" listerWidth="140" listerHeight="100" data='{"toList":[],"fromList":[{"id":"1","parentId":"0","open":"true","name":"部门","oldParentId":"null","icon":"<%=path%>/libs/icons/user_group.gif","drag":"false"},{"id":"11","parentId":"1","name":"小张","oldParentId":"1","icon":"<%=path%>/libs/icons/user_worker.gif"},{"id":"12","parentId":"1","name":"小王","oldParentId":"1","icon":"<%=path%>/libs/icons/user_worker.gif"},{"id":"13","parentId":"1","name":"小李","oldParentId":"1","icon":"<%=path%>/libs/icons/user_worker.gif"}]}'></div>
  99. </fieldset>
  100. <div class="height_15"></div>
  101. <fieldset>
  102. <legend>11、动态生成双选器</legend>
  103. <div class="red">此示例由后台支持</div>
  104. <input type="button" value="点击生成(使用url)" id="testBtn" onclick="dynamicLister1()" style="width:150px;"/><br/><br/>
  105. <input type="button" value="点击生成(使用data)" id="testBtn2" onclick="dynamicLister2()" style="width:150px;"/><br/><br/>
  106. </fieldset>
  107. <div class="height_15"></div>
  108. <fieldset>
  109. <legend>12、动态改变</legend>
  110. <div class="listerTree" id="listTree12" data='{"toList":[{"id":"11","parentId":"1","name":"员工1","oldParentId":"1"}],"fromList":[{"id":"1","parentId":"0","open":"true","name":"部门1","oldParentId":"null","drag":"false"},{"id":"12","parentId":"1","name":"员工2","oldParentId":"1"},{"id":"13","parentId":"1","name":"员工3","oldParentId":"1"},{"id":"2","parentId":"0","open":"true","name":"部门2","oldParentId":"null","drag":"false"},{"id":"21","parentId":"2","name":"员工4","oldParentId":"2"}]}'></div>
  111. <br/>
  112. <input type="button" value="选中“员工3”" onclick="selectItems()" style="width:120px;"/>
  113. <input type="button" value="反选“员工1”" onclick="unSelectItems()" style="width:120px;"/>
  114. <input type="button" value="设值为“员工3,员工2”"" onclick="setValues()" style="width:120px;"/>
  115. <br/>
  116. <br/>
  117. <input type="button" value="追加一项" onclick="appendItem()" style="width:120px;"/>
  118. <input type="button" value="移除“员工1”" onclick="removeItem()" style="width:120px;"/>
  119. <br/>
  120. <br/>
  121. <input type="button" value="获取选中项文本" onclick="getText2()"/>
  122. </fieldset>
  123. <div class="height_15"></div>
  124. <fieldset>
  125. <legend>13、重置树形双选器</legend>
  126. <form id="form-13">
  127. <table class="tableStyle" formMode="transparent" style="width:500px;">
  128. <tr>
  129. <td>传统表单元素:</td>
  130. <td><input type="text"/></td>
  131. </tr>
  132. <tr>
  133. <td>双向选择器1:</td>
  134. <td> <div class="listerTree" selectedValue="" listerWidth="140" listerHeight="120" fromTitle="" toTitle="" data='{"toList":[],"fromList":[{"id":"1","parentId":"0","open":"true","name":"部门1","oldParentId":"null","drag":"false"},{"id":"11","parentId":"1","name":"员工1","oldParentId":"1"},{"id":"12","parentId":"1","name":"员工2","oldParentId":"1"},{"id":"13","parentId":"1","name":"员工3","oldParentId":"1"},{"id":"2","parentId":"0","open":"true","name":"部门2","oldParentId":"null","drag":"false"},{"id":"21","parentId":"2","name":"员工4","oldParentId":"2"}]}'></div>
  135. </tr>
  136. <tr>
  137. <td>双向选择器2:</td>
  138. <td><div class="listerTree" selectedValue="11,12" listerWidth="140" listerHeight="120" fromTitle="" toTitle="" data='{"toList":[],"fromList":[{"id":"1","parentId":"0","open":"true","name":"部门1","oldParentId":"null","drag":"false"},{"id":"11","parentId":"1","name":"员工1","oldParentId":"1"},{"id":"12","parentId":"1","name":"员工2","oldParentId":"1"},{"id":"13","parentId":"1","name":"员工3","oldParentId":"1"},{"id":"2","parentId":"0","open":"true","name":"部门2","oldParentId":"null","drag":"false"},{"id":"21","parentId":"2","name":"员工4","oldParentId":"2"}]}'></div></td>
  139. </tr>
  140. <tr>
  141. <td colspan="2">
  142. <input type="button" value="提交"/>
  143. <input type="button" value="重置" onclick="resetForm()"/>
  144. </td>
  145. </tr>
  146. </table>
  147. </form>
  148. </fieldset>
  149. <div class="height_15"></div>
  150. <fieldset>
  151. <legend>14、itemClick事件</legend>
  152. <div class="listerTree" id="listerTree14" data='{"toList":[],"fromList":[{"id":"1","parentId":"0","open":"true","name":"部门1","oldParentId":"null","drag":"false"},{"id":"11","parentId":"1","name":"员工1","oldParentId":"1"},{"id":"12","parentId":"1","name":"员工2","oldParentId":"1"},{"id":"13","parentId":"1","name":"员工3","oldParentId":"1"},{"id":"2","parentId":"0","open":"true","name":"部门2","oldParentId":"null","drag":"false"},{"id":"21","parentId":"2","name":"员工4","oldParentId":"2"}]}'></div>
  153. </fieldset>
  154. <div class="height_15"></div>
  155. <fieldset>
  156. <legend>15、节点异步加载</legend>
  157. <div class="red">此示例由后台支持</div>
  158. <div class="listerTree" asyncMode="true" url="<%=path%>/getAsyncTree.action"></div>
  159. </fieldset>
  160. <div class="height_15"></div>
  161. </div>
  162. <script type="text/javascript">
  163. //动态设置data
  164. function initComplete(){
  165. var selData={"toList":[],"fromList":[{"id":"1","parentId":"0","open":"true","name":"部门1","oldParentId":"null","drag":"false"},{"id":"11","parentId":"1","name":"员工1","oldParentId":"1"},{"id":"12","parentId":"1","name":"员工2","oldParentId":"1"},{"id":"13","parentId":"1","name":"员工3","oldParentId":"1"}]}
  166. //赋给data属性
  167. $("#listerTree4").data("data",selData)
  168. $("#listerTree4").render();
  169. //获取json数据
  170. $.post("<%=path%>/form/getTreeLister.action",{},function(result){
  171. //赋给data属性
  172. $("#listerTree5").data("data",result);
  173. $("#listerTree5").render();
  174. },"json");
  175. $("#listerTree14").bind("itemClick",function(e){
  176. alert("触发事件")
  177. })
  178. }
  179. //获取值
  180. function getValue(){
  181. top.Dialog.alert($("#listerTree1").attr("relValue"));
  182. }
  183. //获取选中项文本
  184. function getText(){
  185. alert($("#listerTree1").attr("relText"));
  186. }
  187. //获取数据
  188. function getData(){
  189. alert(JSON.stringify($("#listerTree1").data("selectedNodes")));
  190. }
  191. function getText2(){
  192. alert($("#listTree12").attr("relText"));
  193. }
  194. //获取隐藏域值
  195. function getHiddenValue(){
  196. top.Dialog.alert($("input:hidden[name='listerTree7']").val());
  197. }
  198. //启用
  199. function enableLister(){
  200. $("#listerTree8").attr("disabled",false);
  201. //刷新双选器
  202. $("#listerTree8").render();
  203. }
  204. //禁用
  205. function disableLister(){
  206. $("#listerTree8").attr("disabled",true);
  207. //刷新双选器
  208. $("#listerTree8").render();
  209. }
  210. //动态生成
  211. function dynamicLister1(){
  212. var $listerTree=$('<div class="listerTree"></div>');
  213. $listerTree.attr("url","<%=path%>/form/getTreeLister.action");
  214. $listerTree.attr("params",'{"orgid":"1"}');
  215. //将树形双选器加到按钮的后面
  216. $("#testBtn").after($listerTree);
  217. //渲染树形双选器
  218. $listerTree.render();
  219. }
  220. //动态生成
  221. function dynamicLister2(){
  222. $.post("<%=path%>/form/getTreeLister.action",{"orgid":"1"},function(result){
  223. var $listerTree=$('<div class="listerTree"></div>');
  224. //赋给data属性
  225. $listerTree.data("data",result)
  226. //将树形双选器加到按钮的后面
  227. $("#testBtn2").after($listerTree);
  228. //渲染树形双选器
  229. $listerTree.render();
  230. },"json");
  231. }
  232. //动态选中
  233. function selectItems(){
  234. $("#listTree12").selectValue("13")
  235. }
  236. //动态反选
  237. function unSelectItems(){
  238. $("#listTree12").unSelectValue("11")
  239. }
  240. //动态赋值
  241. function setValues(){
  242. $("#listTree12").setValue("12,13")
  243. }
  244. //添加项
  245. function appendItem(){
  246. $("#listTree12").addItem({"id":"22","parentId":"2","name":"员工5","oldParentId":"1"});
  247. }
  248. //删除项
  249. function removeItem(){
  250. $("#listTree12").removeItem("11");
  251. }
  252. //表单重置
  253. function resetForm(){
  254. $("#form-13")[0].reset();
  255. $("#form-13 .listerTree").resetValue();
  256. }
  257. </script>
  258. </body>
  259. </html>