dept.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /**
  2. * 部门管理初始化
  3. */
  4. var Dept = {
  5. id: "DeptTable", //表格id
  6. seItem: null, //选中的条目
  7. table: null,
  8. layerIndex: -1
  9. };
  10. /**
  11. * 初始化表格的列
  12. */
  13. Dept.initColumn = function () {
  14. return [
  15. {field: 'selectItem', radio: true},
  16. {title: 'id', field: 'id', align: 'center', valign: 'middle',width:'50px'},
  17. {title: '部门简称', field: 'simplename', align: 'center', valign: 'middle', sortable: true},
  18. {title: '部门全称', field: 'fullname', align: 'center', valign: 'middle', sortable: true},
  19. {title: '排序', field: 'num', align: 'center', valign: 'middle', sortable: true},
  20. {title: '备注', field: 'tips', align: 'center', valign: 'middle', sortable: true}];
  21. };
  22. /**
  23. * 检查是否选中
  24. */
  25. Dept.check = function () {
  26. var selected = $('#' + this.id).bootstrapTreeTable('getSelections');
  27. if(selected.length == 0){
  28. Feng.info("请先选中表格中的某一记录!");
  29. return false;
  30. }else{
  31. Dept.seItem = selected[0];
  32. return true;
  33. }
  34. };
  35. /**
  36. * 点击添加部门
  37. */
  38. Dept.openAddDept = function () {
  39. var index = layer.open({
  40. type: 2,
  41. title: '添加部门',
  42. area: ['800px', '420px'], //宽高
  43. fix: false, //不固定
  44. maxmin: true,
  45. content: Feng.ctxPath + '/dept/dept_add'
  46. });
  47. this.layerIndex = index;
  48. };
  49. /**
  50. * 打开查看部门详情
  51. */
  52. Dept.openDeptDetail = function () {
  53. if (this.check()) {
  54. var index = layer.open({
  55. type: 2,
  56. title: '部门详情',
  57. area: ['800px', '420px'], //宽高
  58. fix: false, //不固定
  59. maxmin: true,
  60. content: Feng.ctxPath + '/dept/dept_update/' + Dept.seItem.id
  61. });
  62. this.layerIndex = index;
  63. }
  64. };
  65. /**
  66. * 删除部门
  67. */
  68. Dept.delete = function () {
  69. if (this.check()) {
  70. var operation = function(){
  71. var ajax = new $ax(Feng.ctxPath + "/dept/delete", function () {
  72. Feng.success("删除成功!");
  73. Dept.table.refresh();
  74. }, function (data) {
  75. Feng.error("删除失败!" + data.responseJSON.message + "!");
  76. });
  77. ajax.set("deptId",Dept.seItem.id);
  78. ajax.start();
  79. };
  80. Feng.confirm("是否刪除该部门?", operation);
  81. }
  82. };
  83. /**
  84. * 查询部门列表
  85. */
  86. Dept.search = function () {
  87. var queryData = {};
  88. queryData['condition'] = $("#condition").val();
  89. Dept.table.refresh({query: queryData});
  90. };
  91. $(function () {
  92. var defaultColunms = Dept.initColumn();
  93. var table = new BSTreeTable(Dept.id, "/dept/list", defaultColunms);
  94. table.setExpandColumn(2);
  95. table.setIdField("id");
  96. table.setCodeField("id");
  97. table.setParentCodeField("pid");
  98. table.setExpandAll(true);
  99. table.init();
  100. Dept.table = table;
  101. });