Index.cshtml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. @{
  2. ViewBag.Title = "历史记录查询";
  3. Layout = "~/Views/Shared/_LayoutIndex.cshtml";
  4. }
  5. <script>
  6. var checkedIds = [];
  7. $(function () {
  8. InitialPage();
  9. GetTree();
  10. GetPointGrid();
  11. $("#tabs").tabs();
  12. //device.init();
  13. });
  14. function getSelectedTabIndex() {
  15. return $("#tabs").tabs('option', 'active');
  16. }
  17. //初始化页面
  18. function InitialPage() {
  19. //layout布局
  20. $('#layout').layout({
  21. applyDemoStyles: true,
  22. onresize: function () {
  23. $(window).resize();
  24. }
  25. });
  26. //resize重设(表格、树形)宽高
  27. $(window).resize(function (e) {
  28. window.setTimeout(function () {
  29. $("#itemTree").setTreeHeight($(window).height() - 52);
  30. $("#pointGridTable").setGridHeight($(window).height() - 72);
  31. }, 200);
  32. e.stopPropagation();
  33. });
  34. }
  35. //加载树
  36. function GetTree() {
  37. var item = {
  38. height: $(window).height() - 52,
  39. url: "/SecondaryWaterSupply/Device/GetDeviceTree?showcheck=true",
  40. oncheckboxclick: function (item, status) {
  41. GetAllCheckNodes(item.id, status, item.text);//维护 选中元素id的数组
  42. }
  43. };
  44. //初始化
  45. $("#itemTree").treeview(item);
  46. }
  47. //被选中元素的ID,TEXT 数组维护
  48. function GetAllCheckNodes(id, status, text) {
  49. //数据加入数组
  50. if (status == 1) {
  51. if (!checkedIds.contain(id)) {
  52. checkedIds.push(id);
  53. }
  54. }
  55. if (status == 0) {
  56. if (checkedIds.contain(id)) {
  57. checkedIds.splice(checkedIds.indexOf(id), 1);
  58. }
  59. }
  60. }
  61. //AutoComplete
  62. var device = {
  63. init: function () {
  64. var width = $('#device').width();
  65. $('#device').autocomplete({
  66. source: function (request, response) {
  67. $.ajax({
  68. url: "/IPm/DeviceInfo/GetDeviceBySearch",
  69. type: "GET",
  70. data: { q: $('#device').val() },
  71. dataType: "json",
  72. success: function (data) {
  73. response($.map(data, function (item) {
  74. console.log(item);
  75. return {
  76. label: item.label,
  77. value: "dev" + item.value
  78. }
  79. }));
  80. }
  81. });
  82. },
  83. select: function (event, ui) {
  84. $("#device").val(ui.item.label);
  85. PointTreeCode = ui.item.value;
  86. return false;
  87. }
  88. });
  89. }
  90. };
  91. function GetPointGrid() {
  92. var selectedRowIndex = 0;
  93. var $gridTable = $('#pointGridTable');
  94. $gridTable.jqGrid({
  95. url: "/SecondaryWaterSupply/History/GetHistoryData",
  96. datatype: "json",
  97. width: $('.gridPanel').width(),
  98. height:$(window).height() - 72,
  99. autowidth: true,
  100. rownumbers: true,
  101. colModel: [
  102. { label: '设备ID', name: 'SecondaryWaterSupplyId', hidden: true, frozen: true },
  103. { label: '泵房名称', name: 'PumpHouseName', width: 100, frozen: true, align: 'center' },
  104. {
  105. label: '厂商编码', name: 'ManufacturerCode', width: 280, align: 'center', frozen: true,
  106. formatter: function (cellvalue, options, rowObject) {
  107. return cellvalue.trim();
  108. }
  109. },
  110. {
  111. label: '泵站编码', name: 'PumpingStationNumber', width: 100, align: 'center', frozen: true,
  112. formatter: function (cellvalue, options, rowObject) {
  113. return cellvalue.trim();
  114. }
  115. },
  116. {
  117. label: '采集时间', name: 'GetDateTime', width: 100, align: 'center', frozen: true,
  118. formatter: "date", formatoptions: { srcformat: 'Y-m-d H:i', newformat: 'Y-m-d H:i' }
  119. },
  120. { label: '净累计流量', name: 'NetCumulativeFlow', width: 100, frozen: true, align: 'center' },
  121. { label: '进水压力', name: 'InletPressure', width: 80, frozen: true, align: 'center' },
  122. { label: '出水压力', name: 'OutletPressure', width: 80, frozen: true, align: 'center' },
  123. { label: '瞬时流量', name: 'InstantaneousFlow', width: 80, frozen: true, align: 'center' },
  124. { label: '余氯', name: 'ResidualChlorine', width: 80, frozen: true, align: 'center' },
  125. { label: '浊度', name: 'Turbidity', width: 80, frozen: true, align: 'center' },
  126. { label: '温度', name: 'Temperature', align: 'center', frozen: true, width: 80 },
  127. { label: '工频/变频', name: 'PressureUpAlarm', width: 80, frozen: true, align: 'center' },
  128. { label: 'A相电压', name: 'VoltageA_1', width: 80, align: 'center' },
  129. { label: 'B相电压', name: 'VoltageB_1', width: 80, align: 'center' },
  130. { label: 'C相电压', name: 'VoltageC_1', width: 80, align: 'center' },
  131. { label: 'A相电流', name: 'CurrentA_1', width: 80, align: 'center' },
  132. { label: 'B相电流', name: 'CurrentB_1', width: 80, align: 'center' },
  133. { label: 'C相电流', name: 'CurrentC_1', width: 80, align: 'center' },
  134. { label: '有功电能', name: 'ActiveElectricalEnergy_1', width: 80, align: 'center' },
  135. { label: '频率', name: 'Frequency_1', width: 80, align: 'center' },
  136. { label: '运行状态', name: 'RunningState_1', width: 80, align: 'center' },
  137. { label: 'A相电压', name: 'VoltageA_2', width: 80, align: 'center' },
  138. { label: 'B相电压', name: 'VoltageB_2', width: 80, align: 'center' },
  139. { label: 'C相电压', name: 'VoltageC_2', width: 80, align: 'center' },
  140. { label: 'A相电流', name: 'CurrentA_2', width: 80, align: 'center' },
  141. { label: 'B相电流', name: 'CurrentB_2', width: 80, align: 'center' },
  142. { label: 'C相电流', name: 'CurrentC_2', width: 80, align: 'center' },
  143. { label: '有功电能', name: 'ActiveElectricalEnergy_2', width: 80, align: 'center' },
  144. { label: '频率', name: 'Frequency_2', width: 80, align: 'center' },
  145. { label: '运行状态', name: 'RunningState_2', width: 80, align: 'center' },
  146. { label: 'A相电压', name: 'VoltageA_3', width: 80, align: 'center' },
  147. { label: 'B相电压', name: 'VoltageB_3', width: 80, align: 'center' },
  148. { label: 'C相电压', name: 'VoltageC_3', width: 80, align: 'center' },
  149. { label: 'A相电流', name: 'CurrentA_3', width: 80, align: 'center' },
  150. { label: 'B相电流', name: 'CurrentB_3', width: 80, align: 'center' },
  151. { label: 'C相电流', name: 'CurrentC_3', width: 80, align: 'center' },
  152. { label: '有功电能', name: 'ActiveElectricalEnergy_3', width: 80, align: 'center' },
  153. { label: '频率', name: 'Frequency_3', width: 80, align: 'center' },
  154. { label: '运行状态', name: 'RunningState_3', width: 80, align: 'center' },
  155. { label: 'A相电压', name: 'VoltageA_4', width: 80, align: 'center' },
  156. { label: 'B相电压', name: 'VoltageB_4', width: 80, align: 'center' },
  157. { label: 'C相电压', name: 'VoltageC_4', width: 80, align: 'center' },
  158. { label: 'A相电流', name: 'CurrentA_4', width: 80, align: 'center' },
  159. { label: 'B相电流', name: 'CurrentB_4', width: 80, align: 'center' },
  160. { label: 'C相电流', name: 'CurrentC_4', width: 80, align: 'center' },
  161. { label: '有功电能', name: 'ActiveElectricalEnergy_4', width: 80, align: 'center' },
  162. { label: '频率', name: 'Frequency_4', width: 80, align: 'center' },
  163. { label: '运行状态', name: 'RunningState_4', width: 80, align: 'center' },
  164. { label: 'A相电压', name: 'VoltageA_5', width: 80, align: 'center' },
  165. { label: 'B相电压', name: 'VoltageB_5', width: 80, align: 'center' },
  166. { label: 'C相电压', name: 'VoltageC_5', width: 80, align: 'center' },
  167. { label: 'A相电流', name: 'CurrentA_5', width: 80, align: 'center' },
  168. { label: 'B相电流', name: 'CurrentB_5', width: 80, align: 'center' },
  169. { label: 'C相电流', name: 'CurrentC_5', width: 80, align: 'center' },
  170. { label: '有功电能', name: 'ActiveElectricalEnergy_5', width: 80, align: 'center' },
  171. { label: '频率', name: 'Frequency_5', width: 80, align: 'center' },
  172. { label: '运行状态', name: 'RunningState_5', width: 80, align: 'center' }
  173. ],
  174. viewrecords: true,
  175. rowNum: 30,
  176. rowList: [30, 50, 100],
  177. pager: "#gridPager",
  178. gridview: true,
  179. onSelectRow: function () {
  180. selectedRowIndex = $("#" + this.id).getGridParam('selrow');
  181. },
  182. gridComplete: function () {
  183. $("#" + this.id).setSelection(selectedRowIndex, false);
  184. }
  185. });
  186. $gridTable.jqGrid('setGroupHeaders', {
  187. useColSpanStyle: true,
  188. groupHeaders: [
  189. { startColumnName: 'VoltageA_1', numberOfColumns: 9, titleText: '1号泵' },
  190. { startColumnName: 'VoltageA_2', numberOfColumns: 9, titleText: '2号泵' },
  191. { startColumnName: 'VoltageA_3', numberOfColumns: 9, titleText: '3号泵' },
  192. { startColumnName: 'VoltageA_4', numberOfColumns: 9, titleText: '4号泵' },
  193. { startColumnName: 'VoltageA_5', numberOfColumns: 9, titleText: '5号泵' }
  194. ]
  195. });
  196. //点击时间范围(今天、近7天、近一个月、近三个月)
  197. $("#time_horizon a.btn-default").click(function () {
  198. $("#time_horizon a.btn-default").removeClass("active");
  199. $(this).addClass("active");
  200. switch ($(this).attr('data-value')) {
  201. case "1"://今天
  202. $("#PointStartTime").val("@DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss")");
  203. $("#PointEndTime").val("@DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")");
  204. break;
  205. case "2"://近7天
  206. $("#PointStartTime").val("@DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd")");
  207. $("#PointEndTime").val("@DateTime.Now.ToString("yyyy-MM-dd")");
  208. break;
  209. case "3"://近一个月
  210. $("#PointStartTime").val("@DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd")");
  211. $("#PointEndTime").val("@DateTime.Now.ToString("yyyy-MM-dd")");
  212. break;
  213. case "4"://自定义
  214. $("#PointStartTime").val("");
  215. $("#PointEndTime").val("");
  216. break;
  217. default:
  218. break;
  219. }
  220. });
  221. //查询事件
  222. $("#btn_point_Search").click(function () {
  223. var PointStartTime = $("#PointStartTime").val();
  224. var PointEndTime = $("#PointEndTime").val();
  225. if (checkedIds.length == 0) {
  226. dialogMsg('请选择测点!', 0);
  227. return;
  228. }
  229. if (PointStartTime.length <= 0 || PointEndTime.length <= 0) {
  230. dialogMsg('请选择时间!', 0);
  231. return;
  232. }
  233. $gridTable.jqGrid('setGridParam', {
  234. postData: { ids: checkedIds.toString(), start: PointStartTime, end: PointEndTime },
  235. page: 1
  236. }).trigger('reloadGrid');
  237. });
  238. }
  239. //导出
  240. function btn_point_export() {
  241. dialogOpen({
  242. id: "ExcelIExportDialog",
  243. title: '导出采购报表',
  244. url: '/Utility/ExcelExportForm?gridId=pointGridTable',
  245. width: "500px",
  246. height: "380px",
  247. callBack: function (iframeId) {
  248. top.frames[iframeId].AcceptClick();
  249. }, btn: ['导出Excel', '关闭']
  250. });
  251. }
  252. </script>
  253. <div class="ui-layout" id="layout" style="height: 100%; width: 100%;">
  254. <div class="ui-layout-west">
  255. <div class="west-Panel">
  256. <div class="panel-Title">测点列表</div>
  257. <div id="itemTree"></div>
  258. </div>
  259. </div>
  260. <div class="ui-layout-center">
  261. <div class="center-Panel">
  262. <div class="panel-Title">历史记录</div>
  263. <div class="titlePanel">
  264. <div class="title-search">
  265. <table>
  266. <tr>
  267. @* <td style="padding-left: 10px;">测点名称:
  268. </td>
  269. <td style="padding-left: 10px;">
  270. <input type="text" id="device" name="device" class="form-control" style="width: 130px;" />
  271. </td>*@
  272. <td style="padding-left: 10px;">
  273. 开始时间:
  274. </td>
  275. <td style="padding-left: 10px;">
  276. <input id="PointStartTime" readonly type="text" value="@LeaRun.Util.Time.GetDate(-7)" class="form-control input-wdatepicker" onfocus="WdatePicker({maxDate:'%y-%M-%d',dateFmt:'yyyy-MM-dd HH:mm:ss',maxDate:'#F{$dp.$D(\'PointEndTime\')}'})" style="width:175px">
  277. </td>
  278. <td style="padding-left: 10px;">
  279. 结束时间:
  280. </td>
  281. <td style="padding-left: 10px;">
  282. <input id="PointEndTime" readonly type="text" value="@LeaRun.Util.Time.GetToday()" class="form-control input-wdatepicker" onfocus="WdatePicker({maxDate:'%y-%M-%d',dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'#F{$dp.$D(\'PointStartTime\')}'})" style="width:175px">
  283. </td>
  284. <td style="padding-left: 10px;">
  285. <div id="time_horizon" class="btn-group">
  286. <a class="btn btn-default" data-value="1">24小时</a>
  287. <a class="btn btn-default active" data-value="2">近7天</a>
  288. <a class="btn btn-default" data-value="3">近1个月</a>
  289. <a class="btn btn-default" data-value="4">自定义</a>
  290. </div>
  291. </td>
  292. <td style="padding-left: 10px;">
  293. <a id="btn_point_Search" class="btn btn-primary">&nbsp;查&nbsp;&nbsp;询</a>
  294. </td>
  295. </tr>
  296. </table>
  297. </div>
  298. <div class="toolbar">
  299. <div class="btn-group">
  300. <a id="lr-replace" class="btn btn-default" onclick="reload();"><i class="fa fa-refresh"></i>&nbsp;刷新</a>
  301. <a id="lr-export" class="btn btn-default" onclick="btn_point_export()"><i class="fa fa-sign-out"></i>&nbsp;导出</a>
  302. </div>
  303. </div>
  304. </div>
  305. <div class="gridPanel">
  306. <table id="pointGridTable"></table>
  307. <div id="gridPager"></div>
  308. </div>
  309. </div>
  310. </div>
  311. </div>