Index.cshtml 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. @{
  2. ViewBag.Title = "换标操作";
  3. Layout = "~/Views/Shared/_Index.cshtml";
  4. }
  5. <script>
  6. $(document).ready(function () {
  7. initControl();
  8. initialPage();
  9. GetGrid();
  10. //表格表头居中显示
  11. $(".ui-th-column").css("text-align", "center");
  12. });
  13. //重设(表格)宽高
  14. function initialPage() {
  15. //resize重设(表格、树形)宽高
  16. $(window).resize(function (e) {
  17. window.setTimeout(function () {
  18. $('#gridTable').setGridWidth(($('.gridPanel').width()));
  19. $("#gridTable").setGridHeight($(window).height() - 108.5);
  20. }, 200);
  21. e.stopPropagation();
  22. });
  23. }
  24. //加载表格
  25. function GetGrid() {
  26. var selectedRowIndex = 0;
  27. var $gridTable = $('#gridTable');
  28. $gridTable.jqGrid({
  29. url: "/NBManage/NBChangeMeterManage/GetRecordJson",
  30. datatype: "json",
  31. height: $(window).height() - 138.5,
  32. autowidth: true,
  33. colModel: [
  34. { label: 'MeterID', name: 'MeterID', hidden: true ,fixed:true},
  35. { label: "区域名称", name: "AreaName", width: 190, align: "left", sortable: false, fixed: true },
  36. { label: "楼宇名称", name: "BldgName", width: 150, align: "left", sortable: false, fixed: true },
  37. { label: "单元", name: "ApmtName", width: 100, align: "left", sortable: false, fixed: true },
  38. { label: "门牌号", name: "RoomNo", width: 100, align: "left", sortable: false, fixed: true },
  39. { label: "用户编号", name: "UserNo", width: 100, align: "left", sortable: false, fixed: true },
  40. { label: "用户名称", name: "UserName", width: 150, align: "left", sortable: false, fixed: true },
  41. { label: "表类型", name: "MeterTypeName", width: 150, align: "left", sortable: false, fixed: true },
  42. { label: "表地址", name: "ElecAddress", width: 150, align: "right", sortable: false, fixed: true },
  43. { label: "IMEI", name: "IMEI", width: 150, align: "right", sortable: false, fixed: true },
  44. { label: "表读数", name: "NowReading", width: 150, align: "right", sortable: false, formatter: 'number', formatoptions: { decimalPlaces: 2, defaulValue: "", thousandsSeparator: "," }, fixed: true },
  45. { label: "NB表类型", name: "NBDevTypeName", width: 100, align: "left", sortable: false, fixed: true },
  46. { label: "NB厂商", name: "NBDevManufacturerName", width: 100, align: "left", sortable: false, fixed: true },
  47. { label: "NB厂商ID", name: "NBDevManufacturerCodeName", width: 100, align: "left", sortable: false, fixed: true },
  48. { label: "NB型号", name: "NBTypeCodeName", width: 100, align: "left", sortable: false, fixed: true }
  49. ],
  50. treeGrid: true,
  51. treeGridModel: "nested",
  52. ExpandColumn: "EnCode",
  53. viewrecords: true,
  54. rowNum: 30,
  55. rowList: [30, 50, 100],
  56. rownumbers: true,
  57. pager: "#gridPager",
  58. gridComplete: function () {
  59. $("#" + this.id).setSelection(selectedRowIndex, false);
  60. }
  61. });
  62. }
  63. var value = "";
  64. function initControl() {
  65. //小区
  66. $("#AreaId").ComboBox({
  67. url: "/NBManage/NBHistorySearch/GetAreaListJson",
  68. id: "AreaId",
  69. text: "AreaName",
  70. description: "选择小区",
  71. height: "170px"
  72. }).bind("change", function () {
  73. value = $(this).attr('data-value');
  74. SetComboxInit("BldgId", "选择楼宇");
  75. SetComboxInit("ApmtId", "选择单元");
  76. SetComboxInit("RoomId", "选择房间");
  77. $("#BldgId").ComboBox({
  78. url: "/NBManage/NBHistorySearch/GetBldgListJson",
  79. param: { parentId: value },
  80. id: "BldgId",
  81. text: "BldgName",
  82. description: "选择楼宇",
  83. height: "170px"
  84. }).bind("change", function () {
  85. value = $(this).attr('data-value');
  86. SetComboxInit("ApmtId", "选择单元");
  87. SetComboxInit("RoomId", "选择房间");
  88. $("#ApmtId").ComboBox({
  89. url: "/NBManage/NBHistorySearch/GetApmtListJson",
  90. param: { parentId: value },
  91. id: "ApmtId",
  92. text: "ApmtName",
  93. description: "选择单元",
  94. height: "170px"
  95. }).bind("change", function () {
  96. value = $(this).attr('data-value');
  97. SetComboxInit("RoomId", "选择房间");
  98. $("#RoomId").ComboBox({
  99. url: "/NBManage/NBHistorySearch/GetRoomListJson",
  100. param: { parentId: value },
  101. id: "RoomID",
  102. text: "RoomName",
  103. description: "选择房间",
  104. height: "170px"
  105. });
  106. });
  107. })
  108. });
  109. function SetComboxInit(domId, text) {
  110. $("#" + domId).removeAttr('data-value');
  111. $("#" + domId).removeAttr('data-text');
  112. $("#" + domId + " .ui-select-text").text(text);
  113. $("#" + domId).ComboBoxTree({
  114. height: "170px"
  115. })
  116. }
  117. $("#RoomId").ComboBox({
  118. description: "选择房间",
  119. height: "170px"
  120. })
  121. $("#ApmtId").ComboBox({
  122. description: "选择单元",
  123. height: "170px"
  124. })
  125. $("#BldgId").ComboBox({
  126. description: "选择楼宇",
  127. height: "170px"
  128. })
  129. }
  130. function btn_Search() {
  131. var areaId = $("#AreaId").attr('data-value');
  132. var bldgId = $('#BldgId').attr('data-value');
  133. var apmtId = $('#ApmtId').attr('data-value');
  134. var roomId = $('#RoomId').attr('data-value');
  135. var queryType=1;
  136. var queryValue="";
  137. var userNo = $("#txt_userno").val();
  138. var imei = $("#txt_imei").val();
  139. if (!areaId) {
  140. queryType = 1;
  141. queryValue = "";
  142. } else {
  143. if (!bldgId) {
  144. queryType = 1;
  145. queryValue = areaId;
  146. } else {
  147. if (!apmtId) {
  148. queryType = 2;
  149. queryValue = bldgId;
  150. } else {
  151. if (!roomId) {
  152. queryType = 3;
  153. queryValue = apmtId;
  154. } else {
  155. queryType = 4;
  156. queryValue = roomId;
  157. }
  158. }
  159. }
  160. }
  161. $("#gridTable").jqGrid('setGridParam', {
  162. postData: {
  163. queryType: queryType,
  164. queryValue:queryValue,
  165. userNo:userNo,
  166. imei: imei
  167. }
  168. }).trigger('reloadGrid');
  169. }
  170. //编辑
  171. function btn_edit() {
  172. var keyValue = $("#gridTable").jqGridRowValue("MeterID");
  173. if (checkedRow(keyValue)) {
  174. dialogOpen({
  175. id: "Form",
  176. title: '换表',
  177. url: '/NBManage/NBChangeMeterManage/Form?keyValue=' + keyValue ,
  178. width: "750px",
  179. height: "500px",
  180. callBack: function (iframeId) {
  181. top.frames[iframeId].AcceptClick();
  182. }
  183. });
  184. }
  185. }
  186. </script>
  187. <div class="titlePanel">
  188. <div class="title-search">
  189. <table>
  190. <tr>
  191. <td>
  192. <div id="queryCondition">
  193. <div id="AreaId" type="select" class="ui-select" style="float: left; min-width: 150px; margin-right: 1px;"></div>
  194. <div id="BldgId" type="select" class="ui-select" style="float: left; min-width: 100px; margin-right: 1px;"></div>
  195. <div id="ApmtId" type="select" class="ui-select" style="float: left; min-width: 100px; margin-right: 1px;"></div>
  196. <div id="RoomId" type="select" class="ui-select" style="float: left; min-width: 100px; margin-right: 1px;"></div>
  197. </div>
  198. </td>
  199. <td style="padding-left: 2px;">
  200. <input id="txt_userno" type="text" class="form-control" placeholder="用户编号" style="width: 200px;" />
  201. </td>
  202. <td style="padding-left: 2px;">
  203. <input id="txt_imei" type="text" class="form-control" placeholder="IMEI" style="width: 200px;" />
  204. </td>
  205. <td style="padding-left: 5px;">
  206. <a id="btn_Search" class="btn btn-primary" onclick="btn_Search()"><i class="fa fa-search"></i>&nbsp;查询</a>
  207. </td>
  208. </tr>
  209. </table>
  210. </div>
  211. <div class="toolbar">
  212. <div class="btn-group">
  213. <a id="lr-replace" class="btn btn-default" onclick="reload();"><i class="fa fa-refresh"></i>&nbsp;刷新</a>
  214. <a id="lr-add" class="btn btn-default" onclick="btn_edit()"><i class="fa fa-exchange"></i>&nbsp;换表</a>
  215. <a id="lr-edit" class="btn btn-default" onclick="btn_export()"><i class="fa fa-file-excel-o"></i>&nbsp;导出</a>
  216. </div>
  217. </div>
  218. </div>
  219. <div class="gridPanel">
  220. <table id="gridTable"></table>
  221. <div id="gridPager"></div>
  222. </div>