notice.js 3.4 KB

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