Index.cshtml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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. postData: { commandId: "1004" },
  33. autowidth: true,
  34. colModel: [
  35. { label: 'MeterID', name: 'MeterID', hidden: false, fixed: true },
  36. { label: 'IOT_Code', name: 'IOT_Code', hidden: false, 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: "IMEI", width: 150, align: "right", sortable: false, fixed: true },
  45. { label: "IMEI", name: "ElecAddress", 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/ReSetMeterAddress/ReSetAddrForm?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 OpenCloseMore() {
  105. var addr = $("#gridTable").jqGridRowValue("ElecAddress");
  106. var id = $("#gridTable").jqGridRowValue("MeterID");
  107. var IOT_Code = $("#gridTable").jqGridRowValue("IOT_Code");
  108. if (checkedRow(addr)) {
  109. dialogOpen({
  110. id: "Form",
  111. title: '修改上报重试次数',
  112. url: '/NBManage/ReSetReportNum/ResetManyTimes?addr=' + addr + '&id=' + id + '&IOT_Code=' + IOT_Code,
  113. width: "750px",
  114. height: "460px",
  115. callBack: function (iframeId) {
  116. top.frames[iframeId].AcceptClick();
  117. setInterval("reload()", 5000);
  118. }
  119. });
  120. }
  121. }
  122. function historyCmd() {
  123. var id = $("#gridTable").jqGridRowValue("MeterID");
  124. if (checkedRow(id)) {
  125. dialogOpen({
  126. id: "Form",
  127. title: '历史命令',
  128. url: '/NBManage/NBCommandHis/index?id=' + id + '&cmdType=1004',
  129. width: "1400px",
  130. height: "760px",
  131. callBack: function (iframeId) {
  132. top.frames[iframeId].AcceptClick();
  133. setInterval("reload()", 30000);
  134. }
  135. });
  136. }
  137. }
  138. var value = "";
  139. function initControl() {
  140. //小区
  141. $("#AreaId").ComboBox({
  142. url: "/NBManage/NBHistorySearch/GetAreaListJson",
  143. id: "AreaId",
  144. text: "AreaName",
  145. description: "选择小区",
  146. height: "170px"
  147. }).bind("change", function () {
  148. value = $(this).attr('data-value');
  149. SetComboxInit("BldgId", "选择楼宇");
  150. SetComboxInit("ApmtId", "选择单元");
  151. SetComboxInit("RoomId", "选择房间");
  152. $("#BldgId").ComboBox({
  153. url: "/NBManage/NBHistorySearch/GetBldgListJson",
  154. param: { parentId: value },
  155. id: "BldgId",
  156. text: "BldgName",
  157. description: "选择楼宇",
  158. height: "170px"
  159. }).bind("change", function () {
  160. value = $(this).attr('data-value');
  161. SetComboxInit("ApmtId", "选择单元");
  162. SetComboxInit("RoomId", "选择房间");
  163. $("#ApmtId").ComboBox({
  164. url: "/NBManage/NBHistorySearch/GetApmtListJson",
  165. param: { parentId: value },
  166. id: "ApmtId",
  167. text: "ApmtName",
  168. description: "选择单元",
  169. height: "170px"
  170. }).bind("change", function () {
  171. value = $(this).attr('data-value');
  172. SetComboxInit("RoomId", "选择房间");
  173. $("#RoomId").ComboBox({
  174. url: "/NBManage/NBHistorySearch/GetRoomListJson",
  175. param: { parentId: value },
  176. id: "RoomID",
  177. text: "RoomName",
  178. description: "选择房间",
  179. height: "170px"
  180. });
  181. });
  182. })
  183. });
  184. function SetComboxInit(domId, text) {
  185. $("#" + domId).removeAttr('data-value');
  186. $("#" + domId).removeAttr('data-text');
  187. $("#" + domId + " .ui-select-text").text(text);
  188. $("#" + domId).ComboBoxTree({
  189. height: "170px"
  190. })
  191. }
  192. $("#RoomId").ComboBox({
  193. description: "选择房间",
  194. height: "170px"
  195. })
  196. $("#ApmtId").ComboBox({
  197. description: "选择单元",
  198. height: "170px"
  199. })
  200. $("#BldgId").ComboBox({
  201. description: "选择楼宇",
  202. height: "170px"
  203. })
  204. }
  205. function btn_Search() {
  206. var areaId = $("#AreaId").attr('data-value');
  207. var bldgId = $('#BldgId').attr('data-value');
  208. var apmtId = $('#ApmtId').attr('data-value');
  209. var roomId = $('#RoomId').attr('data-value');
  210. var queryType = 1;
  211. var queryValue = "";
  212. var userNo = $("#txt_userno").val();
  213. var imei = $("#txt_imei").val();
  214. if (!areaId) {
  215. queryType = 1;
  216. queryValue = "";
  217. } else {
  218. if (!bldgId) {
  219. queryType = 1;
  220. queryValue = areaId;
  221. } else {
  222. if (!apmtId) {
  223. queryType = 2;
  224. queryValue = bldgId;
  225. } else {
  226. if (!roomId) {
  227. queryType = 3;
  228. queryValue = apmtId;
  229. } else {
  230. queryType = 4;
  231. queryValue = roomId;
  232. }
  233. }
  234. }
  235. }
  236. console.log(areaId);
  237. $("#gridTable").jqGrid('setGridParam', {
  238. postData: {
  239. queryType: queryType,
  240. queryValue: queryValue,
  241. userNo: userNo,
  242. imei: imei
  243. }
  244. }).trigger('reloadGrid');
  245. }
  246. </script>
  247. <div class="titlePanel">
  248. <div class="title-search">
  249. <table>
  250. <tr>
  251. <td>
  252. <div id="queryCondition" >
  253. <div id="AreaId" type="select" class="ui-select" style="float: left; width: 150px; margin-right: 1px;"></div>
  254. <div id="BldgId" type="select" class="ui-select" style="float: left; width: 100px; margin-right: 1px;"></div>
  255. <div id="ApmtId" type="select" class="ui-select" style="float: left; width: 100px; margin-right: 1px;"></div>
  256. <div id="RoomId" type="select" class="ui-select" style="float: left; width: 100px; margin-right: 1px;"></div>
  257. </div>
  258. </td>
  259. <td style="padding-left: 2px;">
  260. <input id="txt_userno" type="text" class="form-control" placeholder="用户编号" style="width: 200px;" />
  261. </td>
  262. <td style="padding-left: 2px;">
  263. <input id="txt_imei" type="text" class="form-control" placeholder="IMEI" style="width: 200px;" />
  264. </td>
  265. <td style="padding-left: 5px;">
  266. <a id="btn_Search" class="btn btn-primary" onclick="btn_Search()"><i class="fa fa-search"></i>&nbsp;查询</a>
  267. </td>
  268. </tr>
  269. </table>
  270. </div>
  271. <div class="toolbar">
  272. <div class="btn-group">
  273. <a id="lr-replace" class="btn btn-default" onclick="OpenClose();"><i class="fa fa-refresh"></i>&nbsp;设置</a>
  274. <a id="lr-replace" class="btn btn-default" onclick="historyCmd();"><i class="fa fa-history"></i>&nbsp;历史命令</a>
  275. <a id="lr-replace" class="btn btn-default" onclick="reload();"><i class="fa fa-refresh"></i>&nbsp;刷新</a>
  276. </div>
  277. </div>
  278. </div>
  279. <div class="gridPanel">
  280. <table id="gridTable"></table>
  281. <div id="gridPager"></div>
  282. </div>