Index.cshtml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. @{
  2. ViewBag.Title = "Index";
  3. Layout = "~/Views/Shared/_LayoutIndex.cshtml";
  4. }
  5. <script>
  6. var checkedIds = [];
  7. $(function () {
  8. InitialPage();
  9. GetTree();
  10. GetGrid();
  11. //device.init();
  12. });
  13. //初始化页面
  14. function InitialPage() {
  15. //layout布局
  16. $('#layout').layout({
  17. applyDemoStyles: true,
  18. onresize: function () {
  19. $(window).resize();
  20. }
  21. });
  22. //resize重设(表格、树形)宽高
  23. $(window).resize(function (e) {
  24. window.setTimeout(function () {
  25. $('#gridTable').setGridWidth(($('.gridPanel').width()));
  26. $("#gridTable").setGridHeight($(window).height() - 141);
  27. $("#itemTree").setTreeHeight($(window).height() - 52);
  28. }, 200);
  29. e.stopPropagation();
  30. });
  31. }
  32. //加载树
  33. function GetTree() {
  34. var item = {
  35. height: $(window).height() - 52,
  36. url: "/PipeNetworkManage/Meter/GetMeterTreeJson?showcheck=true&checkstate=1",
  37. onnodeclick: function (item) {
  38. //展开下级
  39. $(".bbit-tree-selected").children('.bbit-tree-ec-icon').trigger("click");
  40. },
  41. oncheckboxclick: function (item, status) {
  42. GetAllCheckNodes(item.id, status, item.text);//维护 选中元素id的数组
  43. }
  44. };
  45. //初始化
  46. $("#itemTree").treeview(item);
  47. getNodes();
  48. }
  49. function getNodes() {
  50. var nodes = $("#itemTree").getTSNs(true);//获取所有勾选节点包括半勾选
  51. $.each(nodes, function (i, value) {
  52. var id = value.id;
  53. checkedIds.push(id);
  54. });
  55. }
  56. //被选中元素的ID,TEXT 数组维护
  57. function GetAllCheckNodes(id, status, text) {
  58. //数据加入数组
  59. if (status == 1) {
  60. if (!checkedIds.contain(id)) {
  61. checkedIds.push(id);
  62. }
  63. }
  64. if (status == 0) {
  65. if (checkedIds.contain(id)) {
  66. checkedIds.splice(checkedIds.indexOf(id), 1);
  67. }
  68. }
  69. }
  70. //AutoComplete
  71. var device = {
  72. init: function () {
  73. var width = $('#device').width();
  74. $('#device').autocomplete({
  75. source: function (request, response) {
  76. $.ajax({
  77. url: "/IPm/DeviceInfo/GetDeviceBySearch",
  78. type: "GET",
  79. data: { q: $('#device').val() },
  80. dataType: "json",
  81. success: function (data) {
  82. response($.map(data, function (item) {
  83. console.log(item);
  84. return {
  85. label: item.label,
  86. value: "dev" + item.value
  87. }
  88. }));
  89. }
  90. });
  91. },
  92. select: function (event, ui) {
  93. DepartmentId = "";
  94. TypeID = "";
  95. DeviceID = "";
  96. $("#device").val(ui.item.label);
  97. DeviceID = ui.item.value.substring(3);
  98. PointTreeCode = ui.item.value;
  99. return false;
  100. }
  101. });
  102. }
  103. };
  104. function returnFloat(value) {
  105. var value = Math.round(parseFloat(value) * 100) / 100;
  106. var xsd = value.toString().split(".");
  107. if (xsd.length == 1) {
  108. value = value.toString() + ".00";
  109. return value;
  110. }
  111. if (xsd.length > 1) {
  112. if (xsd[1].length < 2) {
  113. value = value.toString() + "0";
  114. }
  115. return value;
  116. }
  117. }
  118. function GetGrid() {
  119. var $gridTable = $('#gridTable');
  120. $gridTable.jqGrid({
  121. url: "/PipeNetworkManage/RealTimeMonitoring/GetRealTimeData",
  122. postData: { devId: checkedIds.toString() },
  123. datatype: "json",
  124. height: $(window).height() - 170,
  125. autowidth: true,
  126. rownumbers: true,
  127. colModel: [
  128. { name: "DevName", label: "测点名称", align: "left" },
  129. { name: "采集时间", label: "采集时间", align: "right" },
  130. {
  131. name: "净累计流量", label: "净累计流量(m³)", align: "right",
  132. formatter: function (cellvalue, options, rowObject) {
  133. if (cellvalue != null && cellvalue != "" && cellvalue!="--") {
  134. return cellvalue = returnFloat(cellvalue)
  135. } else {
  136. return cellvalue;
  137. }
  138. }
  139. },
  140. {
  141. name: "正累计流量", label: "正累计流量(m³)", align: "right",
  142. formatter: function (cellvalue, options, rowObject) {
  143. if (cellvalue != null && cellvalue != "" && cellvalue!="--") {
  144. return cellvalue = returnFloat(cellvalue)
  145. } else {
  146. return cellvalue;
  147. }
  148. }
  149. },
  150. {
  151. name: "负累计流量", label: "负累计流量(m³)", align: "right",
  152. formatter: function (cellvalue, options, rowObject) {
  153. if (cellvalue != null && cellvalue != "" && cellvalue!="--") {
  154. return cellvalue = returnFloat(cellvalue)
  155. } else {
  156. return cellvalue;
  157. }
  158. }
  159. },
  160. {
  161. name: "瞬时流量", label: "瞬时流量(m³/h)", align: "right",
  162. formatter: function (cellvalue, options, rowObject) {
  163. if (cellvalue != null && cellvalue != "" && cellvalue!="--") {
  164. return cellvalue = returnFloat(cellvalue)
  165. } else {
  166. return cellvalue;
  167. }
  168. }
  169. },
  170. {
  171. name: "压力", label: "压力(MPa)", align: "right",
  172. formatter: function (cellvalue, options, rowObject) {
  173. if (cellvalue != null && cellvalue != "" && cellvalue!="--") {
  174. return cellvalue = returnFloat(cellvalue)
  175. } else {
  176. return cellvalue;
  177. }
  178. }
  179. },
  180. {
  181. name: "压力上限报警", label: "压力上限报警", align: "right",
  182. formatter: function (cellvalue, options, rowObject) {
  183. if (cellvalue != null && cellvalue != "" && cellvalue!="--") {
  184. return cellvalue = returnFloat(cellvalue)
  185. } else {
  186. return cellvalue;
  187. }
  188. }
  189. },
  190. {
  191. name: "压力下限报警", label: "压力下限报警", align: "right",
  192. formatter: function (cellvalue, options, rowObject) {
  193. if (cellvalue != null && cellvalue != "" && cellvalue!="--") {
  194. return cellvalue = returnFloat(cellvalue)
  195. } else {
  196. return cellvalue;
  197. }
  198. }
  199. },
  200. {
  201. name: "电池电压", label: "电池电压(v)", align: "right",
  202. formatter: function (cellvalue, options, rowObject) {
  203. if (cellvalue != null && cellvalue != "" && cellvalue!="--") {
  204. return cellvalue = returnFloat(cellvalue)
  205. } else {
  206. return cellvalue;
  207. }
  208. }
  209. },
  210. { name: "测控箱开门报警", label: "测控箱开门报警", align: "center" }
  211. ],
  212. viewrecords: true,
  213. rowNum: 30,
  214. rowList: [30, 50, 100],
  215. pager: "#gridPager",
  216. gridview: true,
  217. gridComplete: function () {
  218. }
  219. });
  220. //查询事件
  221. $("#btn_Search").click(function () {
  222. if (checkedIds.length == 0) {
  223. dialogMsg('请选择测点!', 0);
  224. return;
  225. }
  226. $gridTable.jqGrid("clearGridData");
  227. $gridTable.jqGrid('setGridParam', {
  228. postData: { devId: checkedIds.toString() },
  229. page: 1
  230. }).trigger('reloadGrid');
  231. });
  232. }
  233. </script>
  234. <div class="ui-layout" id="layout" style="height: 100%; width: 100%;">
  235. <div class="ui-layout-west">
  236. <div class="west-Panel">
  237. <div class="panel-Title">测点列表</div>
  238. <div id="itemTree"></div>
  239. </div>
  240. </div>
  241. <div class="ui-layout-center">
  242. <div class="center-Panel">
  243. <div class="panel-Title">实时信息</div>
  244. <div class="titlePanel">
  245. <div class="title-search">
  246. <table>
  247. <tr>
  248. @*<td style="padding-left: 10px;">测点名称:
  249. </td>
  250. <td style="padding-left: 10px;">
  251. <input type="text" id="device" name="device" class="form-control" style="width: 130px;" />
  252. </td>*@
  253. <td style="padding-left: 10px;">
  254. <a id="btn_Search" class="btn btn-primary">&nbsp;查&nbsp;&nbsp;询</a>
  255. </td>
  256. </tr>
  257. </table>
  258. </div>
  259. </div>
  260. <div class="gridPanel">
  261. <table id="gridTable"></table>
  262. <div id="gridPager"></div>
  263. </div>
  264. </div>
  265. </div>
  266. </div>