Index.cshtml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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. //重设(表格)宽高
  12. function initialPage() {
  13. //resize重设(表格、树形)宽高
  14. $(window).resize(function (e) {
  15. window.setTimeout(function () {
  16. $('#gridTable').setGridWidth(($('.gridPanel').width()));
  17. $("#gridTable").setGridHeight($(window).height() - 108.5);
  18. }, 200);
  19. e.stopPropagation();
  20. });
  21. }
  22. //加载表格
  23. function GetGrid() {
  24. var selectedRowIndex = 0;
  25. var $gridTable = $('#gridTable');
  26. $gridTable.jqGrid({
  27. url: "/NBManage/NBChangeMeterManage/GetRecordJson",
  28. datatype: "json",
  29. height: $(window).height() - 138.5,
  30. autowidth: true,
  31. colModel: [
  32. { label: 'MeterID', name: 'MeterID', hidden: true },
  33. { label: 'IOT_Code', name: 'IOT_Code', hidden: true },
  34. { label: "区域名称", name: "AreaName", width: 100, align: "left", sortable: false },
  35. { label: "楼宇名称", name: "BldgName", width: 100, align: "left", sortable: false },
  36. { label: "单元", name: "ApmtName", width: 100, align: "left", sortable: false },
  37. { label: "门牌号", name: "RoomNo", width: 100, align: "left", sortable: false },
  38. { label: "用户编号", name: "UserNo", width: 100, align: "left", sortable: false },
  39. { label: "用户名称", name: "UserName", width: 100, align: "left", sortable: false },
  40. { label: "表类型", name: "MeterTypeName", width: 100, align: "left", sortable: false, hidden: true },
  41. { label: "表地址", name: "ElecAddress", width: 150, align: "left", sortable: false },
  42. { label: "IMEI", name: "IMEI", width: 150, align: "left", sortable: false, hidden: true },
  43. { label: "表读数", name: "NowReading", width: 100, align: "left", sortable: false },
  44. { label: "NB表类型", name: "NBDevTypeName", width: 100, align: "left", sortable: false, hidden: true },
  45. { label: "NB厂商", name: "NBDevManufacturerName", width: 100, align: "left", sortable: false, hidden: true },
  46. { label: "NB厂商ID", name: "NBDevManufacturerCodeName", width: 100, align: "left", sortable: false, hidden: true },
  47. { label: "NB型号", name: "NBTypeCodeName", width: 100, align: "left", sortable: false, hidden: true },
  48. { label: "命令ID", name: "CmdID", width: 100, align: "left", sortable: false, hidden: true },
  49. {
  50. label: "阀门状态", name: "ValveStatusNow", width: 100, align: "left", sortable: false,hidden: true ,
  51. formatter: function (cellvalue, options, rowObject) {
  52. if (cellvalue == "1") { return "关" } else { return "开" }
  53. }
  54. },
  55. { label: "命令发送时间", name: "SendTime", width: 150, align: "left", sortable: false, hidden: true },
  56. {
  57. label: "命令状态", name: "CmdResult", width: 100, align: "left", sortable: false,hidden: true ,
  58. formatter: function (cellvalue, options, rowObject) {
  59. if (cellvalue == "PENDING") { return "传达成功,命令等待中" }
  60. if (cellvalue == "1") { return "关" }
  61. }
  62. }
  63. ],
  64. rowNum: 30,
  65. rowList: [30, 50, 100],
  66. rownumbers: true,
  67. pager: "#gridPager",
  68. gridComplete: function () {
  69. $("#" + this.id).setSelection(selectedRowIndex, false);
  70. }
  71. });
  72. }
  73. function OpenClose() {
  74. var addr = $("#gridTable").jqGridRowValue("ElecAddress");
  75. var id = $("#gridTable").jqGridRowValue("MeterID");
  76. var IOT_Code = $("#gridTable").jqGridRowValue("IOT_Code");
  77. if (checkedRow(addr)) {
  78. dialogOpen({
  79. id: "Form",
  80. title: '修改上报重试次数',
  81. url: '/NBManage/ReSetReportNum/ResetReportNumForm?addr=' + addr + '&id=' + id + '&IOT_Code=' + IOT_Code,
  82. width: "750px",
  83. height: "460px",
  84. callBack: function (iframeId) {
  85. top.frames[iframeId].AcceptClick();
  86. setInterval("reload()", 5000);
  87. }
  88. });
  89. }
  90. }
  91. function OpenCloseMore() {
  92. var addr = $("#gridTable").jqGridRowValue("ElecAddress");
  93. var id = $("#gridTable").jqGridRowValue("MeterID");
  94. var IOT_Code = $("#gridTable").jqGridRowValue("IOT_Code");
  95. if (checkedRow(addr)) {
  96. dialogOpen({
  97. id: "Form",
  98. title: '修改上报重试次数',
  99. url: '/NBManage/ReSetReportNum/ResetManyTimes?addr=' + addr + '&id=' + id + '&IOT_Code=' + IOT_Code,
  100. width: "750px",
  101. height: "460px",
  102. callBack: function (iframeId) {
  103. top.frames[iframeId].AcceptClick();
  104. setInterval("reload()", 5000);
  105. }
  106. });
  107. }
  108. }
  109. function historyCmd() {
  110. var id = $("#gridTable").jqGridRowValue("MeterID");
  111. if (checkedRow(id)) {
  112. dialogOpen({
  113. id: "Form",
  114. title: '历史命令',
  115. url: '/NBManage/NBCommandHis/index?id=' + id + '&cmdType=1012' ,
  116. width: "1400px",
  117. height: "760px",
  118. callBack: function (iframeId) {
  119. top.frames[iframeId].AcceptClick();
  120. setInterval("reload()", 30000);
  121. }
  122. });
  123. }
  124. }
  125. function initControl() {
  126. //小区
  127. $("#AreaId").ComboBox({
  128. url: "/NBManage/NBHistorySearch/GetAreaListJson",
  129. id: "AreaId",
  130. text: "AreaName",
  131. description: "选择小区",
  132. height: "170px"
  133. }).bind("change", function () {
  134. var value = $(this).attr('data-value');
  135. $("#BldgId").ComboBox({
  136. url: "/NBManage/NBHistorySearch/GetBldgListJson",
  137. param: { parentId: value },
  138. id: "BldgId",
  139. text: "BldgName",
  140. description: "选择楼宇",
  141. height: "170px"
  142. });
  143. });
  144. //楼宇
  145. $("#BldgId").ComboBox({
  146. description: "选择楼宇",
  147. height: "170px"
  148. }).bind("change", function () {
  149. var value = $(this).attr('data-value');
  150. if (value) {
  151. $("#ApmtId").ComboBox({
  152. url: "/NBManage/NBHistorySearch/GetApmtListJson",
  153. param: { parentId: value },
  154. id: "ApmtId",
  155. text: "ApmtName",
  156. description: "选择单元",
  157. height: "170px"
  158. });
  159. }
  160. });
  161. $("#ApmtId").ComboBox({
  162. description: "选择单元",
  163. height: "170px"
  164. }).bind("change", function () {
  165. var value = $(this).attr('data-value');
  166. if (value) {
  167. $("#RoomId").ComboBox({
  168. url: "/NBManage/NBHistorySearch/GetRoomListJson",
  169. param: { parentId: value },
  170. id: "RoomID",
  171. text: "RoomName",
  172. description: "选择房间",
  173. height: "170px"
  174. });
  175. }
  176. });
  177. $("#RoomId").ComboBox({
  178. description: "选择房间",
  179. height: "170px"
  180. })
  181. }
  182. function btn_Search() {
  183. var areaId = $("#AreaId").attr('data-value');
  184. var bldgId = $('#BldgId').attr('data-value');
  185. var apmtId = $('#ApmtId').attr('data-value');
  186. var roomId = $('#RoomId').attr('data-value');
  187. var queryType = 1;
  188. var queryValue = "";
  189. var userNo = $("#txt_userno").val();
  190. var imei = $("#txt_imei").val();
  191. if (areaId == undefined) {
  192. queryType = 1;
  193. queryValue = "";
  194. } else {
  195. if (bldgId == undefined) {
  196. queryType = 1;
  197. queryValue = areaId;
  198. } else {
  199. if (apmtId == undefined) {
  200. queryType = 2;
  201. queryValue = bldgId;
  202. } else {
  203. if (roomId == undefined) {
  204. queryType = 3;
  205. queryValue = apmtId;
  206. } else {
  207. queryType = 4;
  208. queryValue = roomId;
  209. }
  210. }
  211. }
  212. }
  213. console.log(areaId);
  214. $("#gridTable").jqGrid('setGridParam', {
  215. postData: {
  216. queryType: queryType,
  217. queryValue: queryValue,
  218. userNo: userNo,
  219. imei: imei
  220. }
  221. }).trigger('reloadGrid');
  222. }
  223. </script>
  224. <div class="titlePanel">
  225. <div class="title-search">
  226. <table>
  227. <tr>
  228. <td>
  229. <div id="queryCondition" >
  230. <div id="AreaId" type="select" class="ui-select" style="float: left; width: 100px; margin-right: 1px;"></div>
  231. <div id="BldgId" type="select" class="ui-select" style="float: left; width: 100px; margin-right: 1px;"></div>
  232. <div id="ApmtId" type="select" class="ui-select" style="float: left; width: 100px; margin-right: 1px;"></div>
  233. <div id="RoomId" type="select" class="ui-select" style="float: left; width: 100px; margin-right: 1px;"></div>
  234. </div>
  235. </td>
  236. <td style="padding-left: 2px;">
  237. <input id="txt_userno" type="text" class="form-control" placeholder="用户编号" style="width: 200px;" />
  238. </td>
  239. <td style="padding-left: 2px;">
  240. <input id="txt_imei" type="text" class="form-control" placeholder="IMEI" style="width: 200px;" />
  241. </td>
  242. <td style="padding-left: 5px;">
  243. <a id="btn_Search" class="btn btn-primary" onclick="btn_Search()"><i class="fa fa-search"></i>&nbsp;查询</a>
  244. </td>
  245. </tr>
  246. </table>
  247. </div>
  248. <div class="toolbar">
  249. <div class="btn-group">
  250. <a id="lr-replace" class="btn btn-default" onclick="OpenClose();"><i class="fa fa-refresh"></i>&nbsp;设置</a>
  251. <a id="lr-replace" class="btn btn-default" onclick="OpenCloseMore();"><i class="fa fa-refresh"></i>&nbsp;设置多次</a>
  252. <a id="lr-replace" class="btn btn-default" onclick="historyCmd();"><i class="fa fa-history"></i>&nbsp;历史命令</a>
  253. <a id="lr-replace" class="btn btn-default" onclick="reload();"><i class="fa fa-refresh"></i>&nbsp;刷新</a>
  254. </div>
  255. </div>
  256. </div>
  257. <div class="gridPanel">
  258. <table id="gridTable"></table>
  259. <div id="gridPager"></div>
  260. </div>