Index.cshtml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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/NBHistorySearch/GetRecordJson",
  30. datatype: "json",
  31. height: $(window).height() - 148.5,
  32. autowidth: true,
  33. postData:{thisDate:"@LeaRun.Util.Time.GetDate(0)",lastDate:"@LeaRun.Util.Time.GetDate(1)"},
  34. colModel: [
  35. { label: '主键', name: 'OrganizeId', hidden: true },
  36. { label: "区域名称", name: "area", width: 200, align: "left", sortable: false ,fixed:true},
  37. { label: "用户编号", name: "UserNo", width: 150, align: "left", sortable: false, hidden: true, fixed: true },
  38. { label: "用户名称", name: "UserName", width: 150, align: "left", sortable: false, hidden: true, fixed: true },
  39. { label: "门牌号", name: "HouseNo", width: 100, align: "left", sortable: false, hidden: true, fixed: true },
  40. { label: "表类型", name: "MeterType", width: 100, align: "left", sortable: false, hidden: true, fixed: true },
  41. { label: "表地址", name: "ElecAddress", width: 100, align: "right", sortable: false, fixed: true },
  42. { label: "IMIE", name: "IMEI", width: 150, align: "right", sortable: false, fixed: true },
  43. { label: "表状态", name: "Description", width: 200, align: "left", sortable: false, hidden: true, fixed: true },
  44. { label: "表读数", name: "MeterReading", width: 200, align: "left", sortable: false, hidden: true, fixed: true },
  45. { label: "阀门状态", name: "ValveState", width: 200, align: "left", sortable: false, hidden: true, fixed: true },
  46. { label: "净累计(m³)", name: "Total", width: 120, align: "right", formatter: 'number', formatoptions: { decimalPlaces: 2, defaulValue: "", thousandsSeparator: "," }, fixed: true },
  47. { label: "正累计(m³)", name: "TotalUp", width: 120, align: "right", formatter: 'number', formatoptions: { decimalPlaces: 2, defaulValue: "", thousandsSeparator: "," }, fixed: true },
  48. { label: "负累计(m³)", name: "TotalDown", width: 120, align: "right", formatter: 'number', formatoptions: { decimalPlaces: 2, defaulValue: "", thousandsSeparator: "," }, fixed: true },
  49. { label: "瞬时流量(L/H)", name: "Instance", width: 120, align: "right", formatter: 'number', formatoptions: { decimalPlaces: 2, defaulValue: "", thousandsSeparator: "," }, fixed: true },
  50. { label: "抄表时间", name: "ReadingDT", width: 165, align: "right", formatter: "date", formatoptions: { srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s' }, fixed: true },
  51. { label: "电池电量(%)", name: "BatteryLevel", width: 100, align: "right", fixed: true ,hidden: true },
  52. { label: "信号强度", name: "Rsrp", width: 100, align: "right", sortable: false, fixed: true },
  53. { label: "信号覆盖等级", name: "Ecl", width: 100, align: "right", sortable: false, fixed: true, hidden: true },
  54. { label: "信噪比", name: "Snr", width: 100, align: "right", sortable: false, hidden: true, fixed: true },
  55. { label: "电池门", name: "BatteryDoor", width: 100, align: "right", sortable: false, fixed: true },
  56. { label: "公司代码", name: "FactoryCode", width: 100, align: "right", sortable: false, fixed: true },
  57. { label: "方向", name: "Direction", width: 100, align: "right", sortable: false, fixed: true },
  58. { label: "数据错误标识", name: "DataRight", width: 100, align: "right", sortable: false, fixed: true },
  59. { label: "电池电量", name: "BatteryQuantity", width: 100, align: "right", sortable: false, fixed: true },
  60. { label: "计量状态", name: "MeasureState", width: 100, align: "right", sortable: false, fixed: true },
  61. { label: "水表电子号", name: "MeterEleno", width: 100, align: "right", sortable: false, fixed: true },
  62. { label: "基站信息", name: "Pci", width: 100, align: "right", sortable: false, fixed: true },
  63. { label: "其它报警值", name: "OtherState", width: 100, align: "right", sortable: false, fixed: true },
  64. { label: "day1-15", name: "day1_day15", width: 200, align: "right", sortable: false, fixed: true },
  65. { label: "otherpart", name: "OtherPart", width: 200, align: "right", sortable: false, fixed: true },
  66. {
  67. label: "阀门状态", name: "ValveStatus", width: 100, align: "left", sortable: false,
  68. formatter: function (cellvalue, options, rowObject) {
  69. if (cellvalue == "00") { return "开" }
  70. if (cellvalue == "01") { return "关" }
  71. if (cellvalue == "11") { return "异常" }
  72. else { return "开" }
  73. }
  74. ,fixed:true},
  75. {
  76. label: "电池状态", name: "BatteryStatus", width: 100, align: "left", sortable: false, hidden: true,
  77. formatter: function (cellvalue, options, rowObject) {
  78. if (cellvalue == "00") { return "正常" }
  79. if (cellvalue == "01") { return "欠压" }
  80. if (cellvalue == "11") { return "严重欠压" }
  81. }
  82. , fixed: true
  83. },
  84. {
  85. label: "磁攻击报警", name: "Attack", width: 100, align: "left", sortable: false, hidden: true,
  86. formatter: function (cellvalue, options, rowObject) {
  87. if (cellvalue == "0") { return "无磁攻击" }
  88. if (cellvalue == "1") { return "正在磁攻击" }
  89. }
  90. , fixed: true
  91. },
  92. {
  93. label: "曾经磁攻击", name: "AttackEver", width: 100, align: "left", sortable: false, hidden: true,
  94. formatter: function (cellvalue, options, rowObject) {
  95. if (cellvalue == "0") { return "无磁攻击" }
  96. if (cellvalue == "1") { return "曾经磁攻击" }
  97. }
  98. , fixed: true
  99. },
  100. {
  101. label: "水流量超过水表Q4值", name: "Q4", width: 150, align: "left", sortable: false,
  102. formatter: function (cellvalue, options, rowObject) {
  103. if (cellvalue == "0") { return "正常" }
  104. if (cellvalue == "1") { return "异常" }
  105. }
  106. , fixed: true, hidden: true
  107. }
  108. ],
  109. viewrecords: true,
  110. rowNum: 30,
  111. rowList: [30, 50, 100],
  112. pager: "#gridPager",
  113. gridview: true,
  114. rownumbers: true,
  115. sortable: true,
  116. sortname: "ReadingDT",
  117. sortorder:"desc",
  118. gridComplete: function () {
  119. $("#" + this.id).setSelection(selectedRowIndex, false);
  120. }
  121. });
  122. //$gridTable.authorizeColModel();
  123. //查询条件设置
  124. }
  125. var value = "";
  126. function initControl() {
  127. //小区
  128. $("#AreaId").ComboBox({
  129. url: "/NBManage/NBHistorySearch/GetAreaListJson",
  130. id: "AreaId",
  131. text: "AreaName",
  132. description: "选择小区",
  133. height: "170px"
  134. }).bind("change", function () {
  135. value = $(this).attr('data-value');
  136. SetComboxInit("BldgId", "选择楼宇");
  137. SetComboxInit("ApmtId", "选择单元");
  138. SetComboxInit("RoomId", "选择房间");
  139. $("#BldgId").ComboBox({
  140. url: "/NBManage/NBHistorySearch/GetBldgListJson",
  141. param: { parentId: value },
  142. id: "BldgId",
  143. text: "BldgName",
  144. description: "选择楼宇",
  145. height: "170px"
  146. }).bind("change", function () {
  147. value = $(this).attr('data-value');
  148. SetComboxInit("ApmtId", "选择单元");
  149. SetComboxInit("RoomId", "选择房间");
  150. $("#ApmtId").ComboBox({
  151. url: "/NBManage/NBHistorySearch/GetApmtListJson",
  152. param: { parentId: value },
  153. id: "ApmtId",
  154. text: "ApmtName",
  155. description: "选择单元",
  156. height: "170px"
  157. }).bind("change", function () {
  158. value = $(this).attr('data-value');
  159. SetComboxInit("RoomId", "选择房间");
  160. $("#RoomId").ComboBox({
  161. url: "/NBManage/NBHistorySearch/GetRoomListJson",
  162. param: { parentId: value },
  163. id: "RoomID",
  164. text: "RoomName",
  165. description: "选择房间",
  166. height: "170px"
  167. });
  168. });
  169. })
  170. });
  171. function SetComboxInit(domId, text) {
  172. $("#" + domId).removeAttr('data-value');
  173. $("#" + domId).removeAttr('data-text');
  174. $("#" + domId + " .ui-select-text").text(text);
  175. $("#" + domId).ComboBoxTree({
  176. height: "170px"
  177. })
  178. }
  179. $("#RoomId").ComboBox({
  180. description: "选择房间",
  181. height: "170px"
  182. })
  183. $("#ApmtId").ComboBox({
  184. description: "选择单元",
  185. height: "170px"
  186. })
  187. $("#BldgId").ComboBox({
  188. description: "选择楼宇",
  189. height: "170px"
  190. })
  191. }
  192. function btn_Search() {
  193. var areaId = $("#AreaId").attr('data-value');
  194. var bldgId = $('#BldgId').attr('data-value');
  195. var apmtId = $('#ApmtId').attr('data-value');
  196. var roomId = $('#RoomId').attr('data-value');
  197. var thisDate = $('#ThisDate').val();
  198. var lastDate = $('#LastDate').val();
  199. var queryType = 1;
  200. var queryValue = "";
  201. var userNo = $("#txt_userno").val();
  202. var imei = $("#txt_imei").val();
  203. if (!areaId) {
  204. queryType = 1;
  205. queryValue = "";
  206. } else {
  207. if (!bldgId) {
  208. queryType = 1;
  209. queryValue = areaId;
  210. } else {
  211. if (!apmtId) {
  212. queryType = 2;
  213. queryValue = bldgId;
  214. } else {
  215. if (!roomId) {
  216. queryType = 3;
  217. queryValue = apmtId;
  218. } else {
  219. queryType = 4;
  220. queryValue = roomId;
  221. }
  222. }
  223. }
  224. }
  225. $("#gridTable").jqGrid('setGridParam', {
  226. postData: {
  227. queryType: queryType,
  228. queryValue: queryValue,
  229. userNo: userNo,
  230. imei: imei,
  231. thisDate: thisDate,
  232. lastDate: lastDate,
  233. searchFlag: 1
  234. }
  235. }).trigger('reloadGrid');
  236. }
  237. //导出
  238. function btn_export() {
  239. var datavalue = $("#gridTable").jqGrid('getRowData'); //获取全部数据
  240. dialogOpen({
  241. id: "ExcelIExportDialog",
  242. title: '导出',
  243. url: '/Utility/ExcelExportForm?gridId=gridTable&filename=历史记录',
  244. width: "500px",
  245. height: "380px",
  246. callBack: function (iframeId) {
  247. top.frames[iframeId].AcceptClick();
  248. }, btn: ['导出Excel', '关闭']
  249. });
  250. }
  251. </script>
  252. <div class="titlePanel">
  253. <div class="title-search">
  254. <table>
  255. <tr>
  256. <td>
  257. <div id="queryCondition">
  258. <div id="AreaId" type="select" class="ui-select" style="float: left; min-width: 150px; margin-right: 1px;"></div>
  259. <div id="BldgId" type="select" class="ui-select" style="float: left; min-width: 100px; margin-right: 1px;"></div>
  260. <div id="ApmtId" type="select" class="ui-select" style="float: left; min-width: 100px; margin-right: 1px;"></div>
  261. <div id="RoomId" type="select" class="ui-select" style="float: left; min-width: 100px; margin-right: 1px;"></div>
  262. </div>
  263. </td>
  264. <td style="padding-left: 2px;">
  265. <input id="txt_userno" type="text" class="form-control" placeholder="用户编号" style="width: 200px;" />
  266. </td>
  267. <td style="padding-left: 2px;">
  268. <input id="txt_imei" type="text" class="form-control" placeholder="IMEI" style="width: 200px;" />
  269. </td>
  270. <td>开始日期</td>
  271. <td>
  272. <input id="ThisDate" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker()" value="@LeaRun.Util.Time.GetDate(-7)" />
  273. </td>
  274. <td>结束日期</td>
  275. <td>
  276. <input id="LastDate" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker()" value="@LeaRun.Util.Time.GetDate(1)" />
  277. </td>
  278. <td style="padding-left: 5px;">
  279. <a id="btn_Search" class="btn btn-primary" onclick="btn_Search()"><i class="fa fa-search"></i>&nbsp;查询</a>
  280. </td>
  281. </tr>
  282. </table>
  283. </div>
  284. <div class="toolbar">
  285. <div class="btn-group">
  286. <a id="lr-replace" class="btn btn-default" onclick="reload();"><i class="fa fa-refresh"></i>&nbsp;刷新</a>
  287. <a id="lr-edit" class="btn btn-default" onclick="btn_export()"><i class="fa fa-file-excel-o"></i>&nbsp;导出</a>
  288. </div>
  289. </div>
  290. </div>
  291. <div class="gridPanel">
  292. <table id="gridTable"></table>
  293. <div id="gridPager"></div>
  294. </div>