Index.cshtml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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/NBNoUseInfo/GetRecordJson",
  30. datatype: "json",
  31. height: $(window).height() - 138.8,
  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. pager: "#gridPager",
  49. rownumbers: true,
  50. shrinkToFit: false,
  51. gridview: true,
  52. gridComplete: function () {
  53. $("#" + this.id).setSelection(selectedRowIndex, false);
  54. }
  55. });
  56. //$gridTable.authorizeColModel();
  57. //查询条件设置
  58. }
  59. var value = "";
  60. function initControl() {
  61. //小区
  62. $("#AreaId").ComboBox({
  63. url: "/NBManage/NBHistorySearch/GetAreaListJson",
  64. id: "AreaId",
  65. text: "AreaName",
  66. description: "选择小区",
  67. height: "170px"
  68. }).bind("change", function () {
  69. value = $(this).attr('data-value');
  70. SetComboxInit("BldgId", "选择楼宇");
  71. SetComboxInit("ApmtId", "选择单元");
  72. SetComboxInit("RoomId", "选择房间");
  73. $("#BldgId").ComboBox({
  74. url: "/NBManage/NBHistorySearch/GetBldgListJson",
  75. param: { parentId: value },
  76. id: "BldgId",
  77. text: "BldgName",
  78. description: "选择楼宇",
  79. height: "170px"
  80. }).bind("change", function () {
  81. value = $(this).attr('data-value');
  82. SetComboxInit("ApmtId", "选择单元");
  83. SetComboxInit("RoomId", "选择房间");
  84. $("#ApmtId").ComboBox({
  85. url: "/NBManage/NBHistorySearch/GetApmtListJson",
  86. param: { parentId: value },
  87. id: "ApmtId",
  88. text: "ApmtName",
  89. description: "选择单元",
  90. height: "170px"
  91. }).bind("change", function () {
  92. value = $(this).attr('data-value');
  93. SetComboxInit("RoomId", "选择房间");
  94. $("#RoomId").ComboBox({
  95. url: "/NBManage/NBHistorySearch/GetRoomListJson",
  96. param: { parentId: value },
  97. id: "RoomID",
  98. text: "RoomName",
  99. description: "选择房间",
  100. height: "170px"
  101. });
  102. });
  103. })
  104. });
  105. function SetComboxInit(domId, text) {
  106. $("#" + domId).removeAttr('data-value');
  107. $("#" + domId).removeAttr('data-text');
  108. $("#" + domId + " .ui-select-text").text(text);
  109. $("#" + domId).ComboBoxTree({
  110. height: "170px"
  111. })
  112. }
  113. $("#RoomId").ComboBox({
  114. description: "选择房间",
  115. height: "170px"
  116. })
  117. $("#ApmtId").ComboBox({
  118. description: "选择单元",
  119. height: "170px"
  120. })
  121. $("#BldgId").ComboBox({
  122. description: "选择楼宇",
  123. height: "170px"
  124. })
  125. }
  126. function btn_Search() {
  127. var areaId = $("#AreaId").attr('data-value');
  128. var bldgId = $('#BldgId').attr('data-value');
  129. var apmtId = $('#ApmtId').attr('data-value');
  130. var roomId = $('#RoomId').attr('data-value');
  131. var thisDate = $('#ThisDate').val();
  132. var lastDate = $('#LastDate').val();
  133. var queryType=1;
  134. var queryValue="";
  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. //console.log(areaId);
  166. $("#gridTable").jqGrid('setGridParam', {
  167. postData: {
  168. queryType: queryType,
  169. queryValue:queryValue,
  170. thisDate: thisDate,
  171. lastDate:lastDate
  172. }
  173. }).trigger('reloadGrid');
  174. }
  175. function isNotNull(obj) {
  176. obj = $.trim(obj);
  177. if (obj.length == 0 || obj == null || obj == undefined) {
  178. return true;
  179. }
  180. else
  181. return false;
  182. }
  183. //导出
  184. function btn_export() {
  185. var datavalue = $("#gridTable").jqGrid('getRowData'); //获取全部数据
  186. dialogOpen({
  187. id: "ExcelIExportDialog",
  188. title: '导出',
  189. url: '/Utility/ExcelExportForm?gridId=gridTable&filename=零用水量明细',
  190. width: "500px",
  191. height: "380px",
  192. callBack: function (iframeId) {
  193. top.frames[iframeId].AcceptClick();
  194. }, btn: ['导出Excel', '关闭']
  195. });
  196. }
  197. </script>
  198. <div class="titlePanel">
  199. <div class="title-search">
  200. <table>
  201. <tr>
  202. <td>
  203. <div id="queryCondition" >
  204. <div id="AreaId" type="select" class="ui-select" style="float: left; width: 150px; margin-right: 1px;"></div>
  205. <div id="BldgId" type="select" class="ui-select" style="float: left; width: 100px; margin-right: 1px;"></div>
  206. <div id="ApmtId" type="select" class="ui-select" style="float: left; width: 100px; margin-right: 1px;"></div>
  207. <div id="RoomId" type="select" class="ui-select" style="float: left; width: 100px; margin-right: 1px;"></div>
  208. </div>
  209. </td>
  210. <td>开始日期</td>
  211. <td>
  212. <input id="ThisDate" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker()" value="@LeaRun.Util.Time.GetDate(-7)" />
  213. </td>
  214. <td>结束日期</td>
  215. <td>
  216. <input id="LastDate" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker()" value="@LeaRun.Util.Time.GetDate(0)" />
  217. </td>
  218. <td style="padding-left: 5px;">
  219. <a id="btn_Search" class="btn btn-primary" onclick="btn_Search()"><i class="fa fa-search"></i>&nbsp;查询</a>
  220. </td>
  221. </tr>
  222. </table>
  223. </div>
  224. <div class="toolbar">
  225. <div class="btn-group">
  226. <a id="lr-replace" class="btn btn-default" onclick="reload();"><i class="fa fa-refresh"></i>&nbsp;刷新</a>
  227. <a id="lr-edit" class="btn btn-default" onclick="btn_export()"><i class="fa fa-file-excel-o"></i>&nbsp;导出</a>
  228. </div>
  229. </div>
  230. </div>
  231. <div class="gridPanel">
  232. <table id="gridTable"></table>
  233. <div id="gridPager"></div>
  234. </div>