notice.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /**
  2. * 通知管理初始化
  3. */
  4. var Notice = {
  5. id: "NoticeTable", //表格id
  6. seItem: null, //选中的条目
  7. table: null,
  8. layerIndex: -1
  9. };
  10. /**
  11. * 初始化表格的列
  12. */
  13. Notice.initColumn = function () {
  14. return [
  15. {field: 'selectItem', radio: true},
  16. {title: 'id', field: 'id', visible: false, align: 'center', valign: 'middle'},
  17. {title: '标题', field: 'title', align: 'center', valign: 'middle', sortable: true},
  18. {title: '内容', field: 'content', align: 'center', valign: 'middle', sortable: true,
  19. formatter: function (value, row, index) {
  20. if (row.showWay == 2) {
  21. return '<a href="/common/notice/view/id/' + row.id + '">' + row.title + '</a>';
  22. }
  23. return value;
  24. }
  25. },
  26. {title: '发布者', field: 'createrName', align: 'center', valign: 'middle', sortable: true},
  27. {title: '创建时间', field: 'createtime', align: 'center', valign: 'middle', sortable: true}
  28. ];
  29. };
  30. /**
  31. * 检查是否选中
  32. */
  33. Notice.check = function () {
  34. var selected = $('#' + this.id).bootstrapTable('getSelections');
  35. if (selected.length == 0) {
  36. Feng.info("请先选中表格中的某一记录!");
  37. return false;
  38. } else {
  39. Notice.seItem = selected[0];
  40. return true;
  41. }
  42. };
  43. /**
  44. * 点击添加通知
  45. */
  46. Notice.openAddNotice = function () {
  47. var index = layer.open({
  48. type: 2,
  49. title: '添加通知',
  50. area: ['800px', '500px'], //宽高
  51. fix: false, //不固定
  52. maxmin: true,
  53. content: Feng.ctxPath + '/admin/notice/add'
  54. });
  55. this.layerIndex = index;
  56. };
  57. /**
  58. * 打开查看通知详情
  59. */
  60. Notice.openNoticeDetail = function () {
  61. if (this.check()) {
  62. var index = layer.open({
  63. type: 2,
  64. title: '通知详情',
  65. area: ['800px', '420px'], //宽高
  66. fix: false, //不固定
  67. maxmin: true,
  68. content: Feng.ctxPath + '/admin/notice/edit/id/' + Notice.seItem.id
  69. });
  70. this.layerIndex = index;
  71. }
  72. };
  73. /**
  74. * 删除通知
  75. */
  76. Notice.delete = function () {
  77. if (this.check()) {
  78. var operation = function () {
  79. var ajax = new $ax(Feng.ctxPath + "/admin/notice/delete", function (data) {
  80. Feng.success("删除成功!");
  81. Notice.table.refresh();
  82. }, function (data) {
  83. Feng.error("删除失败!" + data.responseJSON.message + "!");
  84. });
  85. ajax.set("id", Notice.seItem.id);
  86. ajax.start();
  87. };
  88. Feng.confirm("是否删除通知 " + Notice.seItem.title + "?", operation);
  89. }
  90. };
  91. Notice.top = function (isTop) {
  92. if (this.check()) {
  93. var operation = function () {
  94. var ajax = new $ax(Feng.ctxPath + "/admin/notice/top", function (data) {
  95. Feng.success("置顶成功!");
  96. Notice.table.refresh();
  97. }, function (data) {
  98. Feng.error("置顶成功!" + data.responseJSON.message + "!");
  99. });
  100. ajax.set("id", Notice.seItem.id);
  101. ajax.set("isTop", isTop);
  102. ajax.start();
  103. };
  104. Feng.confirm("确定置顶 " + Notice.seItem.title + "吗?", operation);
  105. }
  106. }
  107. /**
  108. * 查询通知列表
  109. */
  110. Notice.search = function () {
  111. var queryData = {};
  112. queryData['condition'] = $("#condition").val();
  113. Notice.table.refresh({query: queryData});
  114. };
  115. $(function () {
  116. var defaultColunms = Notice.initColumn();
  117. var table = new BSTable(Notice.id, "/admin/notice/list", defaultColunms);
  118. //table.setPaginationType("client");
  119. Notice.table = table.init();
  120. });