Index.cshtml 12 KB

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