Index.cshtml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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: "1002" },
  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(cmdText) {
  87. var addr = $("#gridTable").jqGridRowValue("ElecAddress");
  88. var id = $("#gridTable").jqGridRowValue("MeterID");
  89. var IOT_Code = $("#gridTable").jqGridRowValue("IOT_Code");
  90. var ValveStatus = $("#gridTable").jqGridRowValue("ValveStatus");
  91. if (cmdText == 55 && ValveStatus == "开") {
  92. dialogConfirm("注:当前阀门为开启状态,确定重复开阀?", function (r) {
  93. if (!r) {
  94. return;
  95. }
  96. });
  97. }
  98. if (cmdText == 99 && ValveStatus == "关") {
  99. dialogConfirm("注:当前阀门为关闭状态,确定重复关阀?", function (r) {
  100. if (r) {
  101. return;
  102. }
  103. });
  104. }
  105. if (checkedRow(addr)) {
  106. $.ajax({
  107. url: "/NBManage/NBValveControl/SendCommandSY",
  108. type: "POST",
  109. data: { code: IOT_Code, commandValue: 1002, addr: addr, id: id, cmdText: cmdText },
  110. cache: false,
  111. async: false,
  112. datatype: "json",
  113. success: function (data) {
  114. if (cmdText == "55") {
  115. dialogMsg("开阀命令发送成功!", 1);
  116. } else {
  117. dialogMsg("关阀命令发送成功!", 1);
  118. }
  119. setInterval("reload()", 5000);
  120. }
  121. });
  122. }
  123. }
  124. function historyCmd() {
  125. var id = $("#gridTable").jqGridRowValue("MeterID");
  126. if (checkedRow(id)) {
  127. dialogOpen({
  128. id: "Form",
  129. title: '历史命令',
  130. url: '/NBManage/NBCommandHis/index?id=' + id + '&cmdType=1002',
  131. width: "1400px",
  132. height: "760px",
  133. callBack: function (iframeId) {
  134. top.frames[iframeId].AcceptClick();
  135. setInterval("reload()", 5000);
  136. }
  137. });
  138. }
  139. }
  140. var value = "";
  141. function initControl() {
  142. //小区
  143. $("#AreaId").ComboBox({
  144. url: "/NBManage/NBHistorySearch/GetAreaListJson",
  145. id: "AreaId",
  146. text: "AreaName",
  147. description: "选择小区",
  148. height: "170px"
  149. }).bind("change", function () {
  150. value = $(this).attr('data-value');
  151. SetComboxInit("BldgId", "选择楼宇");
  152. SetComboxInit("ApmtId", "选择单元");
  153. SetComboxInit("RoomId", "选择房间");
  154. $("#BldgId").ComboBox({
  155. url: "/NBManage/NBHistorySearch/GetBldgListJson",
  156. param: { parentId: value },
  157. id: "BldgId",
  158. text: "BldgName",
  159. description: "选择楼宇",
  160. height: "170px"
  161. }).bind("change", function () {
  162. value = $(this).attr('data-value');
  163. SetComboxInit("ApmtId", "选择单元");
  164. SetComboxInit("RoomId", "选择房间");
  165. $("#ApmtId").ComboBox({
  166. url: "/NBManage/NBHistorySearch/GetApmtListJson",
  167. param: { parentId: value },
  168. id: "ApmtId",
  169. text: "ApmtName",
  170. description: "选择单元",
  171. height: "170px"
  172. }).bind("change", function () {
  173. value = $(this).attr('data-value');
  174. SetComboxInit("RoomId", "选择房间");
  175. $("#RoomId").ComboBox({
  176. url: "/NBManage/NBHistorySearch/GetRoomListJson",
  177. param: { parentId: value },
  178. id: "RoomID",
  179. text: "RoomName",
  180. description: "选择房间",
  181. height: "170px"
  182. });
  183. });
  184. })
  185. });
  186. function SetComboxInit(domId, text) {
  187. $("#" + domId).removeAttr('data-value');
  188. $("#" + domId).removeAttr('data-text');
  189. $("#" + domId + " .ui-select-text").text(text);
  190. $("#" + domId).ComboBoxTree({
  191. height: "170px"
  192. })
  193. }
  194. $("#RoomId").ComboBox({
  195. description: "选择房间",
  196. height: "170px"
  197. })
  198. $("#ApmtId").ComboBox({
  199. description: "选择单元",
  200. height: "170px"
  201. })
  202. $("#BldgId").ComboBox({
  203. description: "选择楼宇",
  204. height: "170px"
  205. })
  206. }
  207. function btn_Search() {
  208. var areaId = $("#AreaId").attr('data-value');
  209. var bldgId = $('#BldgId').attr('data-value');
  210. var apmtId = $('#ApmtId').attr('data-value');
  211. var roomId = $('#RoomId').attr('data-value');
  212. var queryType = 1;
  213. var queryValue = "";
  214. var userNo = $("#txt_userno").val();
  215. var imei = $("#txt_imei").val();
  216. if (!areaId) {
  217. queryType = 1;
  218. queryValue = "";
  219. } else {
  220. if (!bldgId) {
  221. queryType = 1;
  222. queryValue = areaId;
  223. } else {
  224. if (!apmtId) {
  225. queryType = 2;
  226. queryValue = bldgId;
  227. } else {
  228. if (!roomId) {
  229. queryType = 3;
  230. queryValue = apmtId;
  231. } else {
  232. queryType = 4;
  233. queryValue = roomId;
  234. }
  235. }
  236. }
  237. }
  238. console.log(areaId);
  239. $("#gridTable").jqGrid('setGridParam', {
  240. postData: {
  241. queryType: queryType,
  242. queryValue: queryValue,
  243. userNo: userNo,
  244. imei: imei
  245. }
  246. }).trigger('reloadGrid');
  247. }
  248. //导出
  249. function btn_export() {
  250. var datavalue = $("#gridTable").jqGrid('getRowData'); //获取全部数据
  251. dialogOpen({
  252. id: "ExcelIExportDialog",
  253. title: '导出',
  254. url: '/Utility/ExcelExportForm?gridId=gridTable&filename=零用水量明细',
  255. width: "500px",
  256. height: "380px",
  257. callBack: function (iframeId) {
  258. top.frames[iframeId].AcceptClick();
  259. }, btn: ['导出Excel', '关闭']
  260. });
  261. }
  262. </script>
  263. <div class="titlePanel">
  264. <div class="title-search">
  265. <table>
  266. <tr>
  267. <td>
  268. <div id="queryCondition">
  269. <div id="AreaId" type="select" class="ui-select" style="float: left; width: 150px; margin-right: 1px;"></div>
  270. <div id="BldgId" type="select" class="ui-select" style="float: left; width: 100px; margin-right: 1px;"></div>
  271. <div id="ApmtId" type="select" class="ui-select" style="float: left; width: 100px; margin-right: 1px;"></div>
  272. <div id="RoomId" type="select" class="ui-select" style="float: left; width: 100px; margin-right: 1px;"></div>
  273. </div>
  274. </td>
  275. <td style="padding-left: 2px;">
  276. <input id="txt_userno" type="text" class="form-control" placeholder="用户编号" style="width: 200px;" />
  277. </td>
  278. <td style="padding-left: 2px;">
  279. <input id="txt_imei" type="text" class="form-control" placeholder="IMEI" style="width: 200px;" />
  280. </td>
  281. <td style="padding-left: 5px;">
  282. <a id="btn_Search" class="btn btn-primary" onclick="btn_Search()"><i class="fa fa-search"></i>&nbsp;查询</a>
  283. </td>
  284. </tr>
  285. </table>
  286. </div>
  287. <div class="toolbar">
  288. <div class="btn-group">
  289. <a id="lr-replace" class="btn btn-default" onclick="OpenClose(55);"><i class="fa fa-circle-o"></i>&nbsp;开阀</a>
  290. <a id="lr-replace" class="btn btn-default" onclick="OpenClose(99);"><i class="fa fa-circle"></i>&nbsp;关阀</a>
  291. <a id="lr-replace" class="btn btn-default" onclick="historyCmd();"><i class="fa fa-history"></i>&nbsp;历史命令</a>
  292. <a id="lr-replace" class="btn btn-default" onclick="reload();"><i class="fa fa-refresh"></i>&nbsp;刷新</a>
  293. </div>
  294. </div>
  295. </div>
  296. <div class="gridPanel">
  297. <table id="gridTable"></table>
  298. <div id="gridPager"></div>
  299. </div>