Index.cshtml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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() - 141);
  25. $("#itemTree").setTreeHeight($(window).height() - 52);
  26. }, 200);
  27. e.stopPropagation();
  28. });
  29. }
  30. //加载树
  31. var AreaCode = 0;
  32. function GetTree() {
  33. var item = {
  34. height: $(window).height() - 52,
  35. url: "../../SystemManage/Area/GetTreeJson",
  36. onnodeclick: function (item) {
  37. AreaCode = item.id;
  38. //展开下级
  39. $(".bbit-tree-selected").children('.bbit-tree-ec-icon').trigger("click");
  40. $('#btn_Search').trigger("click");
  41. },
  42. };
  43. //初始化
  44. $("#itemTree").treeview(item);
  45. }
  46. //加载表格
  47. function GetGrid() {
  48. var selectedRowIndex = 0;
  49. var $gridTable = $("#gridTable");
  50. $gridTable.jqGrid({
  51. url: "../../SystemManage/Area/GetListJson",
  52. datatype: "json",
  53. height: $(window).height() - 141,
  54. autowidth: true,
  55. colModel: [
  56. { label: '主键', name: 'AreaId', hidden: true },
  57. { label: '编号', name: 'AreaCode', index: 'AreaCode', width: 100, align: 'left' },
  58. { label: '名称', name: 'AreaName', index: 'AreaName', width: 300, align: 'left' },
  59. { label: '简拼', name: 'SimpleSpelling', index: 'SimpleSpelling', width: 100, align: 'left' },
  60. { label: '级', name: 'Layer', index: 'Layer', width: 50, align: 'center' },
  61. {
  62. label: "有效", name: "EnabledMark", index: "EnabledMark", width: 50, align: "center",
  63. formatter: function (cellvalue, options, rowObject) {
  64. return cellvalue == 1 ? "<i class=\"fa fa-toggle-on\"></i>" : "<i class=\"fa fa-toggle-off\"></i>";
  65. }
  66. },
  67. { label: "备注", name: "Description", index: "Description", width: 200, align: "left" }
  68. ],
  69. rowNum: "10000",
  70. rownumbers: true,
  71. onSelectRow: function () {
  72. selectedRowIndex = $("#" + this.id).getGridParam('selrow');
  73. },
  74. gridComplete: function () {
  75. $("#" + this.id).setSelection(selectedRowIndex, false);
  76. }
  77. });
  78. $gridTable.authorizeColModel();
  79. //查询事件
  80. $("#btn_Search").click(function () {
  81. $gridTable.jqGrid('setGridParam', {
  82. postData: { value: AreaCode, keyword: $("#txt_Keyword").val() },
  83. }).trigger('reloadGrid');
  84. });
  85. }
  86. //新增
  87. function btn_add() {
  88. var AreaId = AreaCode;
  89. dialogOpen({
  90. id: "Form",
  91. title: '添加区域',
  92. url: '/SystemManage/Area/Form?parentId=' + AreaId,
  93. width: "500px",
  94. height: "310px",
  95. callBack: function (iframeId) {
  96. top.frames[iframeId].AcceptClick();
  97. }
  98. });
  99. };
  100. //编辑
  101. function btn_edit() {
  102. var keyValue = $("#gridTable").jqGridRowValue("AreaId");
  103. if (checkedRow(keyValue)) {
  104. dialogOpen({
  105. id: "Form",
  106. title: '编辑区域',
  107. url: '/SystemManage/Area/Form?keyValue=' + keyValue,
  108. width: "500px",
  109. height: "310px",
  110. callBack: function (iframeId) {
  111. top.frames[iframeId].AcceptClick();
  112. }
  113. });
  114. }
  115. }
  116. //删除
  117. function btn_delete() {
  118. var keyValue = $("#gridTable").jqGridRowValue("AreaId");
  119. if (keyValue) {
  120. $.RemoveForm({
  121. url: "../../SystemManage/Area/RemoveForm",
  122. param: { keyValue: keyValue },
  123. success: function (data) {
  124. $("#gridTable").trigger("reloadGrid");
  125. }
  126. })
  127. } else {
  128. dialogMsg('请选择需要删除的区域!', 0);
  129. }
  130. }
  131. //详细
  132. function btn_detail() {
  133. var keyValue = $("#gridTable").jqGridRowValue("AreaId");
  134. if (checkedRow(keyValue)) {
  135. dialogOpen({
  136. id: "Detail",
  137. title: '区域信息',
  138. url: '/SystemManage/Area/Detail?keyValue=' + keyValue,
  139. width: "500px",
  140. height: "430px",
  141. btn: null
  142. });
  143. }
  144. }
  145. </script>
  146. <div class="ui-layout" id="layout" style="height: 100%; width: 100%;">
  147. <div class="ui-layout-west">
  148. <div class="west-Panel">
  149. <div class="panel-Title">目录信息</div>
  150. <div id="itemTree"></div>
  151. </div>
  152. </div>
  153. <div class="ui-layout-center">
  154. <div class="center-Panel">
  155. <div class="panel-Title">区域信息</div>
  156. <div class="titlePanel">
  157. <div class="title-search">
  158. <table>
  159. <tr>
  160. <td>
  161. <input id="txt_Keyword" type="text" class="form-control" placeholder="请输入要查询关键字" style="width: 200px;" />
  162. </td>
  163. <td style="padding-left: 5px;">
  164. <a id="btn_Search" class="btn btn-primary"><i class="fa fa-search"></i>&nbsp;查询</a>
  165. </td>
  166. </tr>
  167. </table>
  168. </div>
  169. <div class="toolbar">
  170. <div class="btn-group">
  171. <a id="lr-replace" class="btn btn-default" onclick="reload();"><i class="fa fa-refresh"></i>&nbsp;刷新</a>
  172. <a id="lr-add" class="btn btn-default" onclick="btn_add()"><i class="fa fa-plus"></i>&nbsp;新增</a>
  173. <a id="lr-edit" class="btn btn-default" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>&nbsp;编辑</a>
  174. <a id="lr-delete" class="btn btn-default" onclick="btn_delete()"><i class="fa fa-trash-o"></i>&nbsp;删除</a>
  175. <a id="lr-detail" class="btn btn-default" onclick="btn_detail()"><i class="fa fa-list-alt"></i>&nbsp;详细</a>
  176. </div>
  177. <script>$('.toolbar').authorizeButton()</script>
  178. </div>
  179. </div>
  180. <div class="gridPanel">
  181. <table id="gridTable"></table>
  182. </div>
  183. </div>
  184. </div>
  185. </div>