RealtimeDevice.cshtml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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/Device/GetAllDeviceRealTimeData",
  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. //查询事件
  197. $("#btn_point_Search").click(function () {
  198. var PointStartTime = $("#PointStartTime").val();
  199. var PointEndTime = $("#PointEndTime").val();
  200. if (checkedIds.length == 0) {
  201. dialogMsg('请选择测点!', 0);
  202. return;
  203. }
  204. $gridTable.jqGrid('setGridParam', {
  205. postData: { ids: checkedIds.toString() },
  206. page: 1
  207. }).trigger('reloadGrid');
  208. });
  209. }
  210. //导出
  211. function btn_point_export() {
  212. dialogOpen({
  213. id: "ExcelIExportDialog",
  214. title: '导出采购报表',
  215. url: '/Utility/ExcelExportForm?gridId=pointGridTable',
  216. width: "500px",
  217. height: "380px",
  218. callBack: function (iframeId) {
  219. top.frames[iframeId].AcceptClick();
  220. }, btn: ['导出Excel', '关闭']
  221. });
  222. }
  223. </script>
  224. <div class="ui-layout" id="layout" style="height: 100%; width: 100%;">
  225. <div class="ui-layout-west">
  226. <div class="west-Panel">
  227. <div class="panel-Title">测点列表</div>
  228. <div id="itemTree"></div>
  229. </div>
  230. </div>
  231. <div class="ui-layout-center">
  232. <div class="center-Panel">
  233. <div class="panel-Title">实时数据</div>
  234. <div class="titlePanel">
  235. <div class="title-search">
  236. <table>
  237. <tr>
  238. @* <td style="padding-left: 10px;">测点名称:
  239. </td>
  240. <td style="padding-left: 10px;">
  241. <input type="text" id="device" name="device" class="form-control" style="width: 130px;" />
  242. </td>
  243. <td style="padding-left: 10px;">
  244. 开始时间:
  245. </td>
  246. <td style="padding-left: 10px;">
  247. <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">
  248. </td>
  249. <td style="padding-left: 10px;">
  250. 结束时间:
  251. </td>
  252. <td style="padding-left: 10px;">
  253. <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">
  254. </td>
  255. <td style="padding-left: 10px;">
  256. <div id="time_horizon" class="btn-group">
  257. <a class="btn btn-default" data-value="1">24小时</a>
  258. <a class="btn btn-default active" data-value="2">近7天</a>
  259. <a class="btn btn-default" data-value="3">近1个月</a>
  260. <a class="btn btn-default" data-value="4">自定义</a>
  261. </div>
  262. </td>*@
  263. <td style="padding-left: 10px;">
  264. <a id="btn_point_Search" class="btn btn-primary">&nbsp;查&nbsp;&nbsp;询</a>
  265. </td>
  266. </tr>
  267. </table>
  268. </div>
  269. <div class="toolbar">
  270. <div class="btn-group">
  271. <a id="lr-replace" class="btn btn-default" onclick="reload();"><i class="fa fa-refresh"></i>&nbsp;刷新</a>
  272. <a id="lr-export" class="btn btn-default" onclick="btn_point_export()"><i class="fa fa-sign-out"></i>&nbsp;导出</a>
  273. </div>
  274. </div>
  275. </div>
  276. <div class="gridPanel">
  277. <table id="pointGridTable"></table>
  278. <div id="gridPager"></div>
  279. </div>
  280. </div>
  281. </div>
  282. </div>