deptMgr.jsp 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <%@ page contentType="text/html;charset=GBK"%>
  2. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
  3. <%@ taglib uri="/WEB-INF/tlds/author.tld" prefix="h"%>
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  5. <HEAD>
  6. <TITLE>部门管理</TITLE>
  7. <link href="${pageContext.request.contextPath}/main.css" rel="stylesheet" type="text/css" />
  8. <link href="${pageContext.request.contextPath}/liger/lib/ligerUI/skins/${sessionScope.css}/css/ligerui-all.css" rel="stylesheet" type="text/css"></link>
  9. <script type=text/javascript src="${pageContext.request.contextPath}/js/jquery-1.3.2.min.js"></script>
  10. <script type="text/javascript" src="/shares/js/constant.js"></script>
  11. <script type="text/javascript" src="/shares/js/common.js"></script>
  12. <script type="text/javascript" src="${pageContext.request.contextPath}/liger/lib/ligerUI/js/core/base.js"></script>
  13. <script type="text/javascript" src="${pageContext.request.contextPath}/liger/lib/ligerUI/js/plugins/ligerLayout.js"></script>
  14. <script type="text/javascript" src="${pageContext.request.contextPath}/liger/lib/ligerUI/js/ligerui.all.js"></script>
  15. <style type="text/css">
  16. body {
  17. padding: 5px;
  18. margin: 0;
  19. }
  20. #layout1 {
  21. width: 100%;
  22. margin: 0;
  23. padding: 0;
  24. }
  25. .l-button {
  26. margin-left: 1px;
  27. }
  28. #deptBtn {
  29. width: 100%;
  30. background: #e5ecf9;
  31. text-align: center;
  32. height: 25px;
  33. padding-top: 3px
  34. }
  35. .l-layout-left {
  36. overflow-y: auto;
  37. }
  38. </style>
  39. <script type="text/javascript">
  40. var managerTree = "";
  41. var dialog = "";
  42. var rootId = "1";
  43. $(document).ready(function(){
  44. loadTree();
  45. });
  46. function loadTree(){
  47. $("#deptTree").empty();
  48. managerTree = procuctTypeTree("erpDeptAction.do?task=deptTreeData","deptTree",clickEvent,onSuccess);
  49. }
  50. function procuctTypeTree(treeAction, treeId, clickEvent) {
  51. var manager = "";
  52. $("#" + treeId).ligerTree({
  53. url : PROJECT_NAME + "/" + changePath(treeAction),
  54. checkbox : false,
  55. folderCheckbox : false,
  56. single : true,
  57. childIcon : 'folder',
  58. idFieldName : 'universalid',
  59. parentIDFieldName : 'dept_pid',
  60. textFieldName : 'text',
  61. slide : false,
  62. nodeWidth : 160,
  63. openFolderEven: false,
  64. attribute : [ 'universalid', 'url' ],
  65. onSelect : function(node) {
  66. },
  67. onclick : function(node) {
  68. clickEvent(node);
  69. },
  70. onSuccess : function() {
  71. if (onSuccess)
  72. onSuccess();
  73. }
  74. });
  75. manager = $("#" + treeId).ligerGetTreeManager();
  76. return manager;
  77. }
  78. function clickEvent(node){
  79. var id = node.data.universalid;
  80. $("#selectDeptPid").val(id);
  81. /*
  82. if(id == 1){
  83. $('#editDeptBtn').attr("disabled","disabled");
  84. $('#delDeptBtn').attr("disabled","disabled");
  85. $('#addDeptBtn').attr("disabled","disabled");
  86. }else{
  87. $('#editDeptBtn').attr("disabled","");
  88. $('#delDeptBtn').attr("disabled","");
  89. $('#addDeptBtn').attr("disabled","");
  90. }*/
  91. }
  92. function onSuccess(){
  93. managerTree.expandAll();
  94. var id = rootId;
  95. managerTree.selectNode(id);
  96. $("#selectDeptPid").val(id);
  97. /*
  98. if(id == 1){
  99. $('#editDeptBtn').attr("disabled","disabled");
  100. $('#delDeptBtn').attr("disabled","disabled");
  101. $('#addDeptBtn').attr("disabled","disabled");
  102. }else{
  103. $('#editDeptBtn').attr("disabled","");
  104. $('#addDeptBtn').attr("disabled","");
  105. $('#addDeptBtn').attr("disabled","");
  106. } */
  107. }
  108. //添加
  109. function addDept(){
  110. var selectDeptId = $("#selectDeptPid").val();
  111. dialog = $.ligerDialog.open({ height: 300,width:480,url: 'erpDeptAction.do?task=toEdit&pid='+selectDeptId});
  112. }
  113. //编辑
  114. function editDept(){
  115. var selectDeptId = $("#selectDeptPid").val();
  116. if(selectDeptId == rootId){
  117. alert("根目录不能编辑!");
  118. return;
  119. }
  120. dialog = $.ligerDialog.open({ height: 300,width:480,url: 'erpDeptAction.do?task=toEdit&id='+selectDeptId});
  121. }
  122. //删除
  123. function delDept(){
  124. var selectDeptId = $("#selectDeptPid").val();
  125. if(selectDeptId == rootId){
  126. alert("根目录不能删除!");
  127. return;
  128. }
  129. var text = managerTree.getDataByID(selectDeptId).text;
  130. if (window.confirm("确定要删除 “"+text+"”吗?")){
  131. $.ajax({
  132. type:"POST",
  133. url:"erpDeptAction.do?task=delete",
  134. data : {"universalid":selectDeptId},
  135. timeout:10000,
  136. cache:false,
  137. dataType:"json",
  138. success:function(data){
  139. var success = data.success;
  140. if(success != undefined){
  141. if(success==0){
  142. $.ligerDialog.success("删除成功。");
  143. loadTree();
  144. }else if(success==1){
  145. $.ligerDialog.error("删除失败!");
  146. }else if(success==2){
  147. $.ligerDialog.warn("有子级不能删除!");
  148. }else if(success==3){
  149. $.ligerDialog.warn("根节点不能删除!");
  150. }else if(success==4){
  151. $.ligerDialog.warn("已在出库单中不能删除!");
  152. }else{
  153. $.ligerDialog.error("删除失败!");
  154. }
  155. }else{
  156. showAjaxError(null, data.error);
  157. }
  158. },
  159. error:showAjaxError
  160. });
  161. }
  162. }
  163. // 导入
  164. var importDlg;
  165. function importExcel(){
  166. var type="erpDept";
  167. importDlg = $.ligerDialog.open({
  168. height: 120,
  169. width:440,
  170. url: 'initStockAction.do?task=toImport&type='+type,
  171. allowClose:false,
  172. title:'导入部门',
  173. buttons : [ {
  174. text : '导入',
  175. onclick : function(item,dialog){
  176. dialog.frame.importExcel(window);
  177. }
  178. },{
  179. text : '关闭',
  180. onclick : function(item,dialog){
  181. importDlg.close();
  182. grid.loadData();
  183. }
  184. }]
  185. });
  186. }
  187. </script>
  188. </HEAD>
  189. <BODY>
  190. <%@ include file="/include/button.jsp"%>
  191. <%@ include file="/include/message.jsp"%>
  192. <div class="l-content">
  193. <form name="deptForm" method="post">
  194. <input type="hidden" name="selectDeptPid" id="selectDeptPid" />
  195. <div id="layout1">
  196. <div position="left" title="出库部门" class="user-tree-style">
  197. <div id="title" class="form-button" style="top: 0;left: 0;position: fixed; width: 100%; z-index: 200">
  198. <input type="button" value="新增" class="l-button" onclick="addDept()" id="addDeptBtn" />
  199. <input type="button" value="修改" class="l-button" onclick="editDept()" id="editDeptBtn" />
  200. <input type="button" value="删除" class="l-button" onclick="delDept()" id="delDeptBtn" />
  201. <input type="button" value="刷新" class="l-button" onclick="loadTree()" id="refreshBtn" />
  202. <input type="button" value="导入" class="l-button" onclick="importExcel()" id="importExcelBtn" />
  203. </div>
  204. <div style="margin-top:35px;">
  205. <ul id="deptTree" class="tree" style="margin-top: 3px;">
  206. </div>
  207. </div>
  208. </div>
  209. </form>
  210. </div>
  211. </BODY>
  212. </HTML>