departmentList.jsp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
  2. <jsp:include page="../../common/include.jsp" />
  3. <% String basePath = request.getScheme()+ "://" + request.getServerName() + ":" +request.getServerPort() + request.getContextPath(); %>
  4. <script src="<%=basePath %>/js/ajaxfileupload.js"></script>
  5. <script type="text/javascript">
  6. /**摊位显示区*/
  7. $(function() {
  8. $('#departmentDataGrid').datagrid({
  9. rownumbers:true,
  10. fit:true,
  11. pageSize:20,
  12. pageList : [ 10, 20, 30, 40, 50 ],
  13. fitColumns:false,
  14. border:false,
  15. sortOrder:'desc',
  16. pagination:true,
  17. idField:'id',
  18. url:whzl.basePath + '/departmentAction_listDepartment',
  19. toolbar:'#searchtool',
  20. checkOnSelect:true,
  21. selectOnCheck:true,
  22. nowrap:true,
  23. loadFilter:function(result){
  24. if(result.success){
  25. return result.obj;
  26. }else{
  27. $.messager.alert('提示',result.message,'error');
  28. return ;
  29. }
  30. }
  31. }
  32. );
  33. });
  34. /**查询*/
  35. function searchFun(){
  36. $("#departmentDataGrid").datagrid("load", {
  37. "department.name":$("#tblQuery").find("input[id='name']").val()
  38. });
  39. }
  40. /*清除查询条件**/
  41. function ClearQuery() {
  42. $("#tblQuery").find("input").val("");
  43. $("#tblQuery").find("select").val("-1");
  44. }
  45. /**详细*/
  46. var detailsFormatter = function(value , row , index){
  47. return "<img src='<%=basePath%>/js/easyui/themes/itemicon/detail.png' title='查看详情' onclick=departmentDetails(" + row.id + ") style='cursor:pointer' />";
  48. };
  49. /**详细页面对话框*/
  50. var departmentDetails = function(id){
  51. $("#detailDepartmentDialog").dialog(
  52. {
  53. buttons : [
  54. {
  55. text : '确定',
  56. iconCls : 'icon-ok',
  57. handler : function(){
  58. $("#detailDepartmentDialog").dialog("close");
  59. }
  60. }
  61. ],
  62. onLoad : function(){
  63. $.ajax({
  64. type: "post",//使用get方法访问后台
  65. dataType: "json",//返回json格式的数据
  66. url: "departmentAction_findById",//要访问的后台地址
  67. data: "department.id="+id,//要发送的数据
  68. complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
  69. success: function(msg){//msg为返回的数据,在这里做数据绑定
  70. $("#name_detail").text(msg.obj.name);
  71. $("#desc_detail").text(msg.obj.desc);
  72. $("#parentName_detail").text(msg.obj.parentName);
  73. $("#responsibleName_detail").text(msg.obj.responsibleName);
  74. }
  75. });
  76. }
  77. }
  78. );
  79. };
  80. /**更新*/
  81. var updateFormatter = function(value , row , index){
  82. return "<img src='<%=basePath%>/js/easyui/themes/itemicon/update.png' title='修改' onclick=updateRow(" + row.id + ") style='cursor:pointer' />";
  83. };
  84. /**更新事件*/
  85. function updateRow(id){
  86. var updateIndex = $('#departmentDataGrid').datagrid('getRowIndex', id);
  87. $('#updateDepartmentDialog').dialog(
  88. {
  89. buttons : [
  90. {
  91. text : '提交',
  92. iconCls : 'icon-ok',
  93. handler : function(){
  94. $("#responsibleId_update").val($("#responsibleId").combotree("getValues"));
  95. $("#responsibleName_update").val($("#responsibleId").combotree("getText"));
  96. $('#updateDepartmentForm').form('submit',
  97. {
  98. url : whzl.basePath+'/departmentAction_updateDepartment',
  99. success : function(result){
  100. var parseResult = $.parseJSON(result);
  101. if(parseResult.success){
  102. //修改完数据,更新对应行的数据
  103. $('#departmentDataGrid').datagrid('updateRow',
  104. {
  105. index : updateIndex,
  106. row : parseResult.obj
  107. }
  108. );
  109. $("#updateDepartmentDialog").dialog("close");
  110. $('#allDepartmentTree').tree('reload');
  111. }else{
  112. $.messager.alert('出错了',parseResult.message);
  113. }
  114. }
  115. }
  116. );
  117. }
  118. },
  119. {
  120. text : '取消',
  121. iconCls : 'icon-cancel',
  122. handler : function(){
  123. $("#updateDepartmentDialog").dialog("close");
  124. }
  125. }
  126. ],
  127. onLoad : function(){
  128. $.ajax({
  129. type: "post",//使用get方法访问后台
  130. dataType: "json",//返回json格式的数据
  131. url: "departmentAction_findById",//要访问的后台地址
  132. data: "department.id="+id,//要发送的数据
  133. complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
  134. success: function(msg){//msg为返回的数据,在这里做数据绑定
  135. $("#id_update").val(msg.obj.id);
  136. $("#name_update").val(msg.obj.name);
  137. $("#desc_update").val(msg.obj.desc);
  138. if(msg.obj.parentId >0){
  139. $('#p_id_update').combotree('setValue',msg.obj.parentId);
  140. }
  141. if(msg.obj.responsibleId != ""){
  142. $('#responsibleId').combotree ({
  143. url:"departmentAction_findByUserIdList?userId=" + msg.obj.responsibleId
  144. });
  145. $('#responsibleId').combotree('setValue',msg.obj.responsibleId);
  146. }
  147. $("#sort_update").numberbox('setValue',msg.obj.sort);
  148. }
  149. });
  150. }
  151. }
  152. );
  153. }
  154. /**删除*/
  155. var delFormatter = function(value , row , index){
  156. return "<img src='<%=basePath%>/js/easyui/themes/itemicon/delete.png' title='删除' onclick=deleteRow(" + row.id + ") style='cursor:pointer' />";
  157. };
  158. /**删除功能*/
  159. function deleteRow(id){
  160. $.messager.confirm('删除提示', '确定删除这条记录吗?', function(r){
  161. if (r){
  162. $.ajax({
  163. type: "post",//使用get方法访问后台
  164. dataType: "json",//返回json格式的数据
  165. url: "departmentAction_deleteDepartment",//要访问的后台地址
  166. data: "department.id="+id,//要发送的数据
  167. complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
  168. success: function(msg){//msg为返回的数据,在这里做数据绑定
  169. if(msg.success){
  170. $.messager.alert('提示','删除成功!');
  171. $('#departmentDataGrid').datagrid('reload');
  172. $('#allDepartmentTree').tree('reload');
  173. }else{
  174. $.messager.alert('提示',msg.message,'error');
  175. }
  176. }
  177. });
  178. }
  179. });
  180. }
  181. /**增加*/
  182. function departmentAdd(){
  183. $('#addDepartmentDialog').dialog(
  184. {
  185. buttons : [
  186. {
  187. text : '保存',
  188. iconCls : 'icon-add',
  189. handler : function(){
  190. $("#responsibleId_add").val($("#responsible_add").combotree("getValues"));
  191. $("#responsibleName_add").val($("#responsible_add").combotree("getText"));
  192. $('#addDepartmentForm').form('submit',
  193. {
  194. url : whzl.basePath+'/departmentAction_addDepartment',
  195. success : function(result){
  196. var parseResult = $.parseJSON(result);
  197. if(parseResult.success){
  198. $("#addDepartmentDialog").dialog("close");
  199. $('#departmentDataGrid').datagrid('reload');
  200. $('#allDepartmentTree').tree('reload');
  201. }else{
  202. $.messager.alert('提示',parseResult.message,'error');
  203. }
  204. }
  205. }
  206. );
  207. }
  208. },
  209. {
  210. text : '取消',
  211. iconCls : 'icon-cancel',
  212. handler : function(){
  213. $("#addDepartmentDialog").dialog("close");
  214. var img = $("#imagePath_add").val();
  215. }
  216. }
  217. ]
  218. }
  219. );
  220. }
  221. $(function(){
  222. $('#allDepartmentTree').tree({
  223. url:whzl.basePath+'/departmentAction_tree',
  224. loadFilter: function(result){
  225. if(result.success){
  226. return result.obj;
  227. }else{
  228. $.messager.alert('提示',result.message);
  229. }
  230. }
  231. });
  232. });
  233. /**移动*/
  234. var moveFormatter = function(value , row , index){
  235. return "<img src='<%=basePath%>/images/up.png' title='上移' onclick=up(" + row.id + ") style='cursor:pointer' /> <img src='<%=basePath%>/images/down.png' title='下移' onclick=down(" + row.id + ") style='cursor:pointer' />";
  236. };
  237. function up(id){
  238. $.ajax({
  239. type: "post",//使用get方法访问后台
  240. dataType: "json",//返回json格式的数据
  241. url: "departmentAction_upSort",//要访问的后台地址
  242. data: "department.id="+id,//要发送的数据
  243. complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
  244. success: function(msg){//msg为返回的数据,在这里做数据绑定
  245. if(msg.success){
  246. $('#departmentDataGrid').datagrid('reload');
  247. }else{
  248. $.messager.alert('提示','操作失败!');
  249. }
  250. }
  251. });
  252. }
  253. function down(id){
  254. $.ajax({
  255. type: "post",//使用get方法访问后台
  256. dataType: "json",//返回json格式的数据
  257. url: "departmentAction_downSort",//要访问的后台地址
  258. data: "department.id="+id,//要发送的数据
  259. complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
  260. success: function(msg){//msg为返回的数据,在这里做数据绑定
  261. if(msg.success){
  262. $('#departmentDataGrid').datagrid('reload');
  263. }else{
  264. $.messager.alert('提示','操作失败!');
  265. }
  266. }
  267. });
  268. }
  269. </script>
  270. <div style="width: 70%;height: 100%;boreder:1px solid red;float: left;background-color: #E0ECFF;">
  271. <div class="easyui-layout" data-options="fit:true,border:false">
  272. <div data-options="region:'center',border:false">
  273. <div id="searchtool" data-options="region:'north' , border:false">
  274. <table id="tblQuery" style="width:100%;">
  275. <tr>
  276. <td align="right"><span>组织机构名称</span></td>
  277. <td><input id="name" name="department.name" type="text"/></td>
  278. <td align="left">
  279. <a href="javascript:searchFun();" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true">查询</a>
  280. <a href="javascript:ClearQuery();" class="easyui-linkbutton" data-options="iconCls:'icon-emptied',plain:true">清空</a>
  281. <a href="javascript:departmentAdd();" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">增加部门信息</a>
  282. </td>
  283. </tr>
  284. </table>
  285. </div>
  286. <table id="departmentDataGrid">
  287. <thead frozen="true">
  288. <tr>
  289. <th data-options="field:'id',checkbox:true,width:30">ID</th>
  290. <th data-options="field:'parentName',sortable:true,width:150">所属组织机构</th>
  291. </tr>
  292. </thead>
  293. <thead>
  294. <tr>
  295. <th data-options="field:'name',sortable:true,width:200">名称</th>
  296. <th data-options="field:'responsibleName',sortable:true,width:100">负责人</th>
  297. <th data-options="field:'sort',sortable:true,width:40">排序</th>
  298. <th data-options="field:'up',align:'center',width:60,formatter:moveFormatter">排序移动</th>
  299. <th data-options="field:'details',align:'center',formatter:detailsFormatter,width:64">查看详情</th>
  300. <th data-options="field:'update',align:'center',formatter:updateFormatter,width:40">修改</th>
  301. <th data-options="field:'delete',align:'center',formatter:delFormatter,width:40">删除</th>
  302. </tr>
  303. </thead>
  304. </table>
  305. </div>
  306. </div>
  307. </div>
  308. <div style="width: 30%;height: 100%;boreder:1px solid red;float: left;background-color: #E0ECFF;">
  309. <div class="easyui-accordion" data-options="fit:true,border:false">
  310. <div title="组织机构" data-options="iconCls:'icon-menu'">
  311. <ul id="allDepartmentTree" class="easyui-tree" data-options="lines:true" style="margin-top:5px;margin-left: 20px;">
  312. </ul>
  313. </div>
  314. </div>
  315. </div>
  316. <div id="detailDepartmentDialog" data-options="title:'&nbsp;部门详细信息',iconCls:'icon-details',width:500,height:300,modal:true,href:'<%=basePath %>/departmentAction_toDetail'">
  317. </div>
  318. <div id="updateDepartmentDialog" data-options="title:'&nbsp;修改部门信息',iconCls:'icon-edit',width:500,height:300,modal:true,href:'<%=basePath %>/departmentAction_toUpdate'">
  319. </div>
  320. <div id="addDepartmentDialog" data-options="title:'&nbsp;增加部门信息',iconCls:'icon-add',width:500,height:300,modal:true,href:'<%=basePath %>/departmentAction_toAdd'">
  321. </div>
  322. <script type="text/javascript">
  323. parent.$.messager.progress('close');
  324. </script>