Index.cshtml 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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/NBMonthInfo/GetRecordJson",
  30. datatype: "json",
  31. height: $(window).height() - 138.5,
  32. autowidth: true,
  33. colModel: [
  34. { label: '主键', name: 'OrganizeId', hidden: true },
  35. { label: "区域名称", name: "AreaInfo", width: 200, align: "left", sortable: false },
  36. { label: "用户编号", name: "UserNo", width: 150, align: "left", sortable: false },
  37. { label: "用户名称", name: "UserName", width: 150, align: "left", sortable: false },
  38. { label: "门牌号", name: "HouseNo", width: 100, align: "left", sortable: false },
  39. { label: "表类型", name: "MeterType", width: 100, align: "left", sortable: false },
  40. { label: "IMEI", name: "MeterIMEI", width: 200, align: "right", sortable: false },
  41. { label: "起数(m³)", name: "StartReading", width: 200, align: "right", sortable: false, formatter: 'number', formatoptions: { decimalPlaces: 2, defaulValue: "", thousandsSeparator: "," } },
  42. { label: "止数(m³)", name: "EndReading", width: 200, align: "right", sortable: false, formatter: 'number', formatoptions: { decimalPlaces: 2, defaulValue: "", thousandsSeparator: "," } },
  43. { label: "用量(m³)", name: "WaterUsed", width: 200, align: "right", sortable: false, formatter: 'number', formatoptions: { decimalPlaces: 2, defaulValue: "", thousandsSeparator: "," } }
  44. ],
  45. viewrecords: true,
  46. rowNum: 30,
  47. rowList: [30, 50, 100],
  48. rownumbers: true,
  49. pager: "#gridPager",
  50. gridComplete: function () {
  51. $("#" + this.id).setSelection(selectedRowIndex, false);
  52. }
  53. });
  54. //$gridTable.authorizeColModel();
  55. //查询条件设置
  56. }
  57. var value = "";
  58. function initControl() {
  59. //小区
  60. $("#AreaId").ComboBox({
  61. url: "/NBManage/NBHistorySearch/GetAreaListJson",
  62. id: "AreaId",
  63. text: "AreaName",
  64. description: "选择小区",
  65. height: "170px"
  66. }).bind("change", function () {
  67. value = $(this).attr('data-value');
  68. SetComboxInit("BldgId", "选择楼宇");
  69. SetComboxInit("ApmtId", "选择单元");
  70. SetComboxInit("RoomId", "选择房间");
  71. $("#BldgId").ComboBox({
  72. url: "/NBManage/NBHistorySearch/GetBldgListJson",
  73. param: { parentId: value },
  74. id: "BldgId",
  75. text: "BldgName",
  76. description: "选择楼宇",
  77. height: "170px"
  78. }).bind("change", function () {
  79. value = $(this).attr('data-value');
  80. SetComboxInit("ApmtId", "选择单元");
  81. SetComboxInit("RoomId", "选择房间");
  82. $("#ApmtId").ComboBox({
  83. url: "/NBManage/NBHistorySearch/GetApmtListJson",
  84. param: { parentId: value },
  85. id: "ApmtId",
  86. text: "ApmtName",
  87. description: "选择单元",
  88. height: "170px"
  89. }).bind("change", function () {
  90. value = $(this).attr('data-value');
  91. SetComboxInit("RoomId", "选择房间");
  92. $("#RoomId").ComboBox({
  93. url: "/NBManage/NBHistorySearch/GetRoomListJson",
  94. param: { parentId: value },
  95. id: "RoomID",
  96. text: "RoomName",
  97. description: "选择房间",
  98. height: "170px"
  99. });
  100. });
  101. })
  102. });
  103. function SetComboxInit(domId, text) {
  104. $("#" + domId).removeAttr('data-value');
  105. $("#" + domId).removeAttr('data-text');
  106. $("#" + domId + " .ui-select-text").text(text);
  107. $("#" + domId).ComboBoxTree({
  108. height: "170px"
  109. })
  110. }
  111. $("#RoomId").ComboBox({
  112. description: "选择房间",
  113. height: "170px"
  114. })
  115. $("#ApmtId").ComboBox({
  116. description: "选择单元",
  117. height: "170px"
  118. })
  119. $("#BldgId").ComboBox({
  120. description: "选择楼宇",
  121. height: "170px"
  122. })
  123. }
  124. function btn_Search() {
  125. var areaId = $("#AreaId").attr('data-value');
  126. var bldgId = $('#BldgId').attr('data-value');
  127. var apmtId = $('#ApmtId').attr('data-value');
  128. var roomId = $('#RoomId').attr('data-value');
  129. var thisDate = $('#ThisDate').val();
  130. var lastDate = $('#LastDate').val();
  131. var queryType=1;
  132. var queryValue="";
  133. var userNo = $("#txt_userno").val();
  134. var imei = $("#txt_imei").val();
  135. if (isNotNull(thisDate)) {
  136. dialogMsg("开始日期不能为空", -1);
  137. return;
  138. }
  139. if (isNotNull(lastDate)) {
  140. dialogMsg("结束日期不能为空", -1);
  141. return;
  142. }
  143. if (!areaId) {
  144. queryType = 1;
  145. queryValue = "";
  146. } else {
  147. if (!bldgId) {
  148. queryType = 1;
  149. queryValue = areaId;
  150. } else {
  151. if (!apmtId) {
  152. queryType = 2;
  153. queryValue = bldgId;
  154. } else {
  155. if (!roomId) {
  156. queryType = 3;
  157. queryValue = apmtId;
  158. } else {
  159. queryType = 4;
  160. queryValue = roomId;
  161. }
  162. }
  163. }
  164. }
  165. $("#gridTable").jqGrid('setGridParam', {
  166. postData: {
  167. queryType: queryType,
  168. queryValue:queryValue,
  169. userNo:userNo,
  170. imei: imei,
  171. thisDate: thisDate,
  172. lastDate:lastDate
  173. }
  174. }).trigger('reloadGrid');
  175. }
  176. function isNotNull(obj) {
  177. obj = $.trim(obj);
  178. if (obj.length == 0 || obj == null || obj == undefined) {
  179. return true;
  180. }
  181. else
  182. return false;
  183. }
  184. //导出
  185. function btn_export() {
  186. var datavalue = $("#gridTable").jqGrid('getRowData'); //获取全部数据
  187. dialogOpen({
  188. id: "ExcelIExportDialog",
  189. title: '导出',
  190. url: '/Utility/ExcelExportForm?gridId=gridTable&filename=月用水量明细',
  191. width: "500px",
  192. height: "380px",
  193. callBack: function (iframeId) {
  194. top.frames[iframeId].AcceptClick();
  195. }, btn: ['导出Excel', '关闭']
  196. });
  197. }
  198. </script>
  199. <div class="titlePanel">
  200. <div class="title-search">
  201. <table>
  202. <tr>
  203. <td>
  204. <div id="queryCondition" >
  205. <div id="AreaId" type="select" class="ui-select" style="float: left; width: 150px; margin-right: 1px;"></div>
  206. <div id="BldgId" type="select" class="ui-select" style="float: left; width: 100px; margin-right: 1px;"></div>
  207. <div id="ApmtId" type="select" class="ui-select" style="float: left; width: 100px; margin-right: 1px;"></div>
  208. <div id="RoomId" type="select" class="ui-select" style="float: left; width: 100px; margin-right: 1px;"></div>
  209. </div>
  210. </td>
  211. <td style="padding-left: 2px;">
  212. <input id="txt_userno" type="text" class="form-control" placeholder="用户编号" style="width: 200px;" />
  213. </td>
  214. <td style="padding-left: 2px;">
  215. <input id="txt_imei" type="text" class="form-control" placeholder="IMEI" style="width: 200px;" />
  216. </td>
  217. <td>开始日期</td>
  218. <td>
  219. <input id="ThisDate" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker()" value="@LeaRun.Util.Time.GetDate(-30)"/>
  220. </td>
  221. <td>结束日期</td>
  222. <td>
  223. <input id="LastDate" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker()" value="@LeaRun.Util.Time.GetDate(0)"/>
  224. </td>
  225. <td style="padding-left: 5px;">
  226. <a id="btn_Search" class="btn btn-primary" onclick="btn_Search()"><i class="fa fa-search"></i>&nbsp;查询</a>
  227. </td>
  228. </tr>
  229. </table>
  230. </div>
  231. <div class="toolbar">
  232. <div class="btn-group">
  233. <a id="lr-replace" class="btn btn-default" onclick="reload();"><i class="fa fa-refresh"></i>&nbsp;刷新</a>
  234. <a id="lr-edit" class="btn btn-default" onclick="btn_export()"><i class="fa fa-file-excel-o"></i>&nbsp;导出</a>
  235. </div>
  236. </div>
  237. </div>
  238. <div class="gridPanel">
  239. <table id="gridTable"></table>
  240. <div id="gridPager"></div>
  241. </div>