Index.cshtml 7.7 KB

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