MeterIndex.cshtml 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. @{
  2. ViewBag.Title = "设备管理";
  3. Layout = "~/Views/Shared/_LayoutIndex.cshtml";
  4. }
  5. <script>
  6. $(function () {
  7. InitialPage();
  8. GetGrid();
  9. });
  10. //初始化页面
  11. function InitialPage() {
  12. //resize重设(表格、树形)宽高
  13. $(window).resize(function (e) {
  14. window.setTimeout(function () {
  15. $('#gridTable').setGridWidth(($('.gridPanel').width()));
  16. $("#gridTable").setGridHeight($(window).height() - 136.5);
  17. }, 200);
  18. e.stopPropagation();
  19. });
  20. }
  21. //加载表格
  22. function GetGrid() {
  23. var selectedRowIndex = 0;
  24. var $gridTable = $('#gridTable');
  25. $gridTable.jqGrid({
  26. url: "/PipeNetworkManage/Meter/GetMeterList",
  27. datatype: "json",
  28. height: $(window).height() - 136.5,
  29. autowidth: true,
  30. colModel: [
  31. { label: '设备ID', name: 'MeterAssessmentId', hidden: true },
  32. { label: '考核表名称', name: 'MeterAssessmentName', index: 'MeterAssessmentName', width: 200, align: 'left' },
  33. { label: '考核表类型ID', name: 'MeterTypeId', index: 'MeterTypeId', hidden: true },
  34. { label: '考核表类型', name: 'MeterTypeName', index: 'MeterTypeName', width: 150, align: 'left' },
  35. {
  36. label: '厂商编码', name: 'ManufacturerCode', width: 280, align: 'left',
  37. formatter: function (cellvalue, options, rowObject) {
  38. return cellvalue.trim();
  39. }
  40. },
  41. {
  42. label: '考核表编号', name: 'MeterAssessmentCode', index: 'MeterAssessmentCode', width: 100, align: 'right',
  43. formatter: function (cellvalue, options, rowObject) {
  44. return cellvalue.trim();
  45. }
  46. },
  47. {
  48. label: '换表时间', name: 'ChangeMeterTime', index: 'ChangeMeterTime', width: 130, align: 'right',
  49. formatter: "date", formatoptions: { srcformat: 'Y-m-d H:i', newformat: 'Y-m-d H:i' }
  50. },
  51. {
  52. label: '采集时间', name: 'GetDateTime', index: 'CreateDate', width: 130, align: 'right',
  53. formatter: "date", formatoptions: { srcformat: 'Y-m-d H:i', newformat: 'Y-m-d H:i' }
  54. },
  55. { label: '净累计流量', name: 'NetCumulativeFlow', index: 'NetCumulativeFlow', width: 100, align: 'right' },
  56. { label: '正累计流量', name: 'PositiveCumulativeFlow', index: 'PositiveCumulativeFlow', width: 100, align: 'right' },
  57. { label: '负累计流量', name: 'NegativeCumulativeFlow', index: 'NegativeCumulativeFlow', width: 100, align: 'right' },
  58. { label: '瞬时流量', name: 'InstantaneousFlow', index: 'InstantaneousFlow', width: 100, align: 'right' },
  59. { label: '瞬时流量上限报警值(参考值)', name: 'InstantaneousFlowUpAlarm', index: 'InstantaneousFlowUpAlarm', width: 100, align: 'right' },
  60. { label: '瞬时流量下限报警值(参考值)', name: 'InstantaneousFlowDownAlarm', index: 'InstantaneousFlowDownAlarm', width: 100, align: 'right' },
  61. { label: '压力', name: 'Pressure', index: 'Pressure', width: 100, align: 'right' },
  62. { label: '压力上限报警值(参考值)', name: 'PressureUpAlarm', index: 'PressureUpAlarm', width: 100, align: 'right' },
  63. { label: '压力下限报警值(参考值)', name: 'PressureDownAlarm', index: 'PressureDownAlarm', width: 100, align: 'right' },
  64. { label: '电池电压值', name: 'BatteryVoltageValue', index: 'BatteryVoltageValue', width: 100, align: 'right' },
  65. { label: '电池电压状态', name: 'BatteryVoltageState', index: 'BatteryVoltageState', width: 100, align: 'right' },
  66. { label: '箱门报警', name: 'BoxDoorAlarm', index: 'BoxDoorAlarm', width: 100, align: 'right' },
  67. { label: '流量计故障', name: 'MeterFault', index: 'MeterFault', width: 100, align: 'right' },
  68. { label: '换表组标记', name: 'MeterTag', index: 'MeterTag', width: 100, align: 'right' },
  69. {
  70. label: '数据更新时间', name: 'UpdateTime', index: 'UpdateTime', width: 130, align: 'right',
  71. formatter: "date", formatoptions: { srcformat: 'Y-m-d H:i', newformat: 'Y-m-d H:i' }
  72. }
  73. ],
  74. viewrecords: true,
  75. rowNum: 30,
  76. rowList: [30, 50, 100],
  77. pager: "#gridPager",
  78. sortname: 'CreateDate',
  79. sortorder: 'desc',
  80. rownumbers: true,
  81. shrinkToFit: false,
  82. gridview: true,
  83. onSelectRow: function () {
  84. selectedRowIndex = $("#" + this.id).getGridParam('selrow');
  85. },
  86. gridComplete: function () {
  87. $("#" + this.id).setSelection(selectedRowIndex, false);
  88. }
  89. });
  90. //查询条件
  91. $("#queryCondition .dropdown-menu li").click(function () {
  92. var text = $(this).find('a').html();
  93. var value = $(this).find('a').attr('data-value');
  94. $("#queryCondition .dropdown-text").html(text).attr('data-value', value)
  95. });
  96. //查询事件
  97. $("#btn_Search").click(function () {
  98. var queryJson = {
  99. condition: $("#queryCondition").find('.dropdown-text').attr('data-value'),
  100. keyword: $("#txt_Keyword").val()
  101. }
  102. $gridTable.jqGrid('setGridParam', {
  103. postData: { queryJson: JSON.stringify(queryJson) },
  104. page: 1
  105. }).trigger('reloadGrid');
  106. });
  107. //查询回车
  108. $('#txt_Keyword').bind('keypress', function (event) {
  109. if (event.keyCode == "13") {
  110. $('#btn_Search').trigger("click");
  111. }
  112. });
  113. }
  114. //新增
  115. function btn_add() {
  116. dialogOpen({
  117. id: "Form",
  118. title: '添加表设备',
  119. url: '/PipeNetworkManage/Meter/MeterForm',
  120. width: "750px",
  121. height: "460px",
  122. callBack: function (iframeId) {
  123. top.frames[iframeId].AcceptClick();
  124. }
  125. });
  126. };
  127. //编辑
  128. function btn_edit() {
  129. var keyValue = $("#gridTable").jqGridRowValue("MeterAssessmentId");
  130. if (checkedRow(keyValue)) {
  131. dialogOpen({
  132. id: "Form",
  133. title: '编辑表设备',
  134. url: '/PipeNetworkManage/Meter/MeterForm?keyValue=' + keyValue,
  135. width: "750px",
  136. height: "460px",
  137. callBack: function (iframeId) {
  138. top.frames[iframeId].AcceptClick();
  139. }
  140. });
  141. }
  142. }
  143. //删除
  144. function btn_delete() {
  145. var keyValue = $("#gridTable").jqGridRowValue("MeterAssessmentId");
  146. if (keyValue) {
  147. $.RemoveForm({
  148. url: "/PipeNetworkManage/Meter/DeleteMeter",
  149. param: { keyValue: keyValue },
  150. success: function (data) {
  151. $("#gridTable").trigger("reloadGrid");
  152. }
  153. })
  154. } else {
  155. dialogMsg('请选择需要删除的数据项!', 0);
  156. }
  157. }
  158. </script>
  159. <div class="titlePanel">
  160. <div class="title-search">
  161. <table>
  162. <tr>
  163. <td>
  164. <div id="queryCondition" class="btn-group">
  165. <a class="btn btn-default dropdown-text" data-toggle="dropdown">选择条件</a>
  166. <a class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></a>
  167. <ul class="dropdown-menu">
  168. <li><a data-value="EnCode">角色编号</a></li>
  169. <li><a data-value="FullName">角色名称</a></li>
  170. </ul>
  171. </div>
  172. </td>
  173. <td style="padding-left: 2px;">
  174. <input id="txt_Keyword" type="text" class="form-control" placeholder="请输入要查询关键字" style="width: 200px;" />
  175. </td>
  176. <td style="padding-left: 5px;">
  177. <a id="btn_Search" class="btn btn-primary"><i class="fa fa-search"></i>&nbsp;查询</a>
  178. </td>
  179. </tr>
  180. </table>
  181. </div>
  182. <div class="toolbar">
  183. <div class="btn-group">
  184. <a id="lr-replace" class="btn btn-default" onclick="reload();"><i class="fa fa-refresh"></i>&nbsp;刷新</a>
  185. <a id="lr-add" class="btn btn-default" onclick="btn_add()"><i class="fa fa-plus"></i>&nbsp;新增</a>
  186. <a id="lr-edit" class="btn btn-default" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>&nbsp;编辑</a>
  187. <a id="lr-delete" class="btn btn-default" onclick="btn_delete()"><i class="fa fa-trash-o"></i>&nbsp;删除</a>
  188. </div>
  189. </div>
  190. </div>
  191. <div class="gridPanel">
  192. <table id="gridTable"></table>
  193. <div id="gridPager"></div>
  194. </div>