officeList.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <%@ page contentType="text/html;charset=UTF-8" %>
  2. <script>
  3. var $treeTable=null;
  4. $(document).ready(function() {
  5. $treeTable=$('#treeTable').treeTable({
  6. theme:'vsStyle',
  7. expandLevel : 2,
  8. column:0,
  9. checkbox: false,
  10. url:'${ctx}/sys/office/getChildren?parentId=',
  11. callback:function(item) {
  12. var officeItemTpl= $("#officeItemTpl").html();
  13. item.typeLabel = jp.getDictLabel(${fns:toJson(fns:getDictList('sys_office_type'))}, item.type);
  14. var result = laytpl(officeItemTpl).render(item);
  15. return result;
  16. },
  17. beforeClick: function($treeTable, id) {
  18. //异步获取数据 这里模拟替换处理
  19. $treeTable.refreshPoint(id);
  20. },
  21. beforeExpand : function($treeTable, id) {
  22. },
  23. afterExpand : function($treeTable, id) {
  24. //layer.closeAll();
  25. },
  26. beforeClose : function($treeTable, id) {
  27. }
  28. });
  29. });
  30. function del(con,id){
  31. jp.confirm('确认要删除机构吗?', function(){
  32. jp.loading();
  33. $.get("${ctx}/sys/office/delete?id="+id, function(data){
  34. if(data.success){
  35. $treeTable.del(id);
  36. jp.success(data.msg);
  37. }else{
  38. jp.error(data.msg);
  39. }
  40. })
  41. });
  42. }
  43. function refresh(){//刷新
  44. var index = jp.loading("正在加载,请稍等...");
  45. $treeTable.refresh();
  46. jp.close(index);
  47. }
  48. function refreshNode(data) {
  49. var current_id = data.body.office.id;
  50. var target = $treeTable.get(current_id);
  51. var old_parent_id = target.attr("pid") == undefined?'0':target.attr("pid");
  52. var current_parent_id = data.body.office.parentId;
  53. var current_parent_ids = data.body.office.parentIds;
  54. if(old_parent_id == current_parent_id){
  55. if(current_parent_id == '0'){
  56. $treeTable.refreshPoint(-1);
  57. }else{
  58. $treeTable.refreshPoint(current_parent_id);
  59. }
  60. }else{
  61. $treeTable.del(current_id);//刷新删除旧节点
  62. $treeTable.initParents(current_parent_ids, "0");
  63. }
  64. }
  65. </script>
  66. <script type="text/html" id="officeItemTpl">
  67. <td><a href="#" onclick="jp.openViewDialog('查看机构', '${ctx}/sys/office/form?id={{d.id}}','800px', '600px')">{{d.name}}</a></td>
  68. <td>{{d.code === undefined ? "": d.code}}</td>
  69. <td>{{d.remarks === undefined ? "":d.remarks}}</td>
  70. <td>
  71. <div class="btn-group">
  72. <button type="button" class="btn btn-primary btn-xs dropdown-toggle" data-toggle="dropdown">
  73. <i class="fa fa-cog"></i>
  74. <span class="fa fa-chevron-down"></span>
  75. </button>
  76. <ul class="dropdown-menu" role="menu">
  77. <shiro:hasPermission name="sys:office:view">
  78. <li><a href="#" onclick="jp.openViewDialog('查看机构', '${ctx}/sys/office/form?id={{d.id}}','800px', '600px')" ><i class="fa fa-search-plus"></i> 查看</a></li>
  79. </shiro:hasPermission>
  80. <shiro:hasPermission name="sys:office:edit">
  81. <li><a href="#" onclick="jp.openSaveDialog('修改机构', '${ctx}/sys/office/form?id={{d.id}}','800px', '600px')" ><i class="fa fa-edit"></i> 修改</a></li>
  82. </shiro:hasPermission>
  83. </ul>
  84. </div>
  85. </td>
  86. </script>