Index.cshtml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. @{
  2. ViewBag.Title = "公告管理";
  3. Layout = "~/Views/Shared/_Index.cshtml";
  4. }
  5. <script>
  6. $(function () {
  7. InitialPage();
  8. GetGrid();
  9. });
  10. //初始化页面
  11. function InitialPage() {
  12. //resize重设(表格、树形)宽高
  13. $(window).resize(function (e) {
  14. window.setTimeout(function () {
  15. $('#gridTable').setGridWidth(($('.gridPanel').width()));
  16. $("#gridTable").setGridHeight($(window).height() - 136.5);
  17. }, 200);
  18. e.stopPropagation();
  19. });
  20. }
  21. //加载表格
  22. function GetGrid() {
  23. var selectedRowIndex = 0;
  24. var $grid = $("#gridTable");
  25. $grid.jqGrid({
  26. url: "../../PublicInfoManage/Notice/GetPageListJson",
  27. datatype: "json",
  28. height: $(window).height() - 136.5,
  29. autowidth: true,
  30. colModel: [
  31. { label: '主键', name: 'NewsId', hidden: true },
  32. {
  33. label: '公告标题', name: 'FullHead', index: 'FullHead', width: 600, align: 'left',
  34. formatter: function (cellvalue, options, rowObject) {
  35. return '<p style="color: ' + rowObject.FullHeadColor + ';">' + cellvalue + '</p>';
  36. }
  37. },
  38. { label: '公告类别', name: 'Category', index: 'Category', width: 100, align: 'center' },
  39. {
  40. label: "发布时间", name: "ReleaseTime", index: "ReleaseTime", width: 140, align: "center",
  41. formatter: function (cellvalue, options, rowObject) {
  42. return formatDate(cellvalue, 'yyyy-MM-dd hh:mm');
  43. }
  44. },
  45. { label: '信息来源', name: 'SourceName', index: 'SourceName', width: 100, align: 'center' },
  46. { label: '阅读次数', name: 'PV', index: 'PV', width: 80, align: 'center' },
  47. {
  48. label: "发布状态", name: "EnabledMark", index: "EnabledMark", width: 80, align: "center", autowidth: false,
  49. formatter: function (cellvalue, options, rowObject) {
  50. if (cellvalue == 1) {
  51. return "<span class=\"label label-success\">已发布</span>";
  52. } else {
  53. return "<span class=\"label label-danger\">未发布</span>";
  54. }
  55. }
  56. }
  57. ],
  58. viewrecords: true,
  59. rowNum: 30,
  60. rowList: [30, 50, 100],
  61. pager: "#gridPager",
  62. sortname: 'CreateDate',
  63. sortorder: 'desc',
  64. rownumbers: true,
  65. shrinkToFit: false,
  66. gridview: true,
  67. onSelectRow: function () {
  68. selectedRowIndex = $grid.getGridParam('selrow');
  69. },
  70. gridComplete: function () {
  71. $grid.setSelection(selectedRowIndex, false);
  72. }
  73. });
  74. //查询事件
  75. $("#btn_Search").click(function () {
  76. var queryJson = {
  77. FullHead: $("#txt_Keyword").val()
  78. }
  79. $grid.jqGrid('setGridParam', {
  80. postData: { queryJson: JSON.stringify(queryJson) },
  81. }).trigger('reloadGrid');
  82. });
  83. }
  84. //新增
  85. function btn_add() {
  86. dialogOpen({
  87. id: "Form",
  88. title: '添加公告',
  89. url: '/PublicInfoManage/Notice/Form',
  90. width: "1000px",
  91. height: "600px",
  92. callBack: function (iframeId) {
  93. top.frames[iframeId].AcceptClick();
  94. }
  95. });
  96. };
  97. //编辑
  98. function btn_edit() {
  99. var keyValue = $("#gridTable").jqGridRowValue("NewsId");
  100. if (checkedRow(keyValue)) {
  101. dialogOpen({
  102. id: "Form",
  103. title: '修改公告',
  104. url: '/PublicInfoManage/Notice/Form?keyValue=' + keyValue,
  105. width: "1000px",
  106. height: "600px",
  107. callBack: function (iframeId) {
  108. top.frames[iframeId].AcceptClick();
  109. }
  110. });
  111. }
  112. }
  113. //删除
  114. function btn_delete() {
  115. var keyValue = $("#gridTable").jqGridRowValue("NewsId");
  116. if (keyValue) {
  117. $.RemoveForm({
  118. url: "../../PublicInfoManage/Notice/RemoveForm",
  119. param: { keyValue: keyValue },
  120. success: function (data) {
  121. $("#gridTable").trigger("reloadGrid");
  122. }
  123. })
  124. } else {
  125. dialogMsg('请选择需要删除的公告!', 0);
  126. }
  127. }
  128. //公告类别
  129. function btn_category() {
  130. dialogOpen({
  131. id: "DataItemList",
  132. title: '公告分类',
  133. url: '/SystemManage/DataItemList/Index?ItemCode=NoticeCategory',
  134. width: "800px",
  135. height: "500px",
  136. btn: null
  137. });
  138. }
  139. </script>
  140. <div class="titlePanel">
  141. <div class="title-search">
  142. <table>
  143. <tr>
  144. <td>
  145. <input id="txt_Keyword" type="text" class="form-control" placeholder="请输入要查询关键字" style="width: 200px;" />
  146. </td>
  147. <td style="padding-left: 5px;">
  148. <a id="btn_Search" class="btn btn-primary"><i class="fa fa-search"></i>&nbsp;查询</a>
  149. </td>
  150. </tr>
  151. </table>
  152. </div>
  153. <div class="toolbar">
  154. <div class="btn-group">
  155. <a id="lr-replace" class="btn btn-default" onclick="reload();"><i class="fa fa-refresh"></i>&nbsp;刷新</a>
  156. <a id="lr-add" class="btn btn-default" onclick="btn_add()"><i class="fa fa-plus"></i>&nbsp;新增</a>
  157. <a id="lr-edit" class="btn btn-default" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>&nbsp;编辑</a>
  158. <a id="lr-delete" class="btn btn-default" onclick="btn_delete()"><i class="fa fa-trash-o"></i>&nbsp;删除</a>
  159. </div>
  160. <div class="btn-group">
  161. <a id="lr-category" class="btn btn-default" onclick="btn_category()"><i class="fa fa-tags"></i>&nbsp;公告类别</a>
  162. </div>
  163. <script>$('.toolbar').authorizeButton()</script>
  164. </div>
  165. </div>
  166. <div class="gridPanel">
  167. <table id="gridTable"></table>
  168. <div id="gridPager"></div>
  169. </div>