123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- var checkedIds = [];
- var checkedNoteName = [];
- $(function () {
- InitialPage();
- GetTree();
- $("#tabs").tabs({
- select: function (event, ui) { alert(ui.index); }
- });
-
- });
- //初始化页面
- function InitialPage() {
- //layout布局
- $('#layout').layout({
- applyDemoStyles: true,
- onresize: function () {
- $(window).resize();
- }
- });
- //resize重设(表格、树形)宽高
- $(window).resize(function (e) {
- window.setTimeout(function () {
- $('#gridTable').setGridWidth(($('.gridPanel').width()));
- $("#gridTable").setGridHeight($(window).height() - 141);
- $("#itemTree").setTreeHeight($(window).height() - 52);
- }, 200);
- e.stopPropagation();
- });
- }
- //加载树
- function GetTree() {
- var item = {
- height: $(window).height() - 52,
- url: "/PipeNetworkManage/Meter/GetMeterTreeJson?showCheck=true",
- onnodeclick: function (item) {
- PointTreeCode = item.id;
- //展开下级
- $(".bbit-tree-selected").children('.bbit-tree-ec-icon').trigger("click");
- },
- oncheckboxclick: function (item, status) {
-
- GetAllCheckNodes(item.id, status,item.text);//维护 选中元素id的数组
- var tabIndex = getSelectedTabIndex();
- if (tabIndex == 0) {
- DynamicLoadDayGrid();//动态加载 表格数据
- }
- if (tabIndex == 1) {
- DynamicLoadMonthGrid();//动态加载 表格数据
- }
- if (tabIndex == 2) {
- DynamicLoadYearGrid();//动态加载 表格数据
- }
-
- }
- };
- //初始化
- $("#itemTree").treeview(item);
- }
- //被选中元素的ID,TEXT 数组维护
- function GetAllCheckNodes(id, status, text) {
- //数据加入数组
- if (status == 1) {
- if (!checkedIds.contain(id)) {
- checkedIds.push(id);
- }
- if (!checkedNoteName.contain(text)) {
- checkedNoteName.push(text);
- }
- }
- if (status == 0) {
- if (checkedIds.contain(id)) {
- checkedIds.splice(checkedIds.indexOf(id), 1);
- }
- if (checkedNoteName.contain(text)) {
- checkedNoteName.splice(checkedNoteName.indexOf(text), 1);
- }
- }
- }
- function DynamicLoadDayGrid() {
- $.ajax({
- type: "POST",
- async: false,
- url: "/PipeNetworkManage/Pressure/GetPressureReportDayHead",
- dataType: "json",
- data: { ids: checkedIds.toString() },
- success: function (data) {
- GetGrid(data, "dayGrid", $("#dayDate").val(),checkedIds.toString(),0);
- },
- error: function (xhr, status, error) {
-
- }
- });
- }
- function DynamicLoadMonthGrid() {
- $.ajax({
- type: "POST",
- async: false,
- url: "/PipeNetworkManage/Pressure/GetPressureMonthReportHead",
- dataType: "json",
- data: { ids: checkedIds.toString() },
- success: function (data) {
- GetGrid(data, "monthGrid", $("#monthDate").val(), checkedIds.toString(), 1);
- },
- error: function (xhr, status, error) {
- }
- });
- }
- function DynamicLoadYearGrid() {
- $.ajax({
- type: "POST",
- async: false,
- url: "/PipeNetworkManage/Pressure/GetPressureMonthReportHead",
- dataType: "json",
- data: { ids: checkedIds.toString() },
- success: function (data) {
- GetGrid(data, "yearGrid", $("#yearDate").val(), checkedIds.toString(), 2);
- },
- error: function (xhr, status, error) {
- }
- });
- }
- function GetGrid(data,gridId,dateTime,ids,typeFlat) {
- $("#" + gridId).jqGrid('GridUnload');
- $("#" + gridId).jqGrid({
- url: "/PipeNetworkManage/Pressure/GetPressureReport",
- datatype: "json",
- postData: { ids: ids, typeFlag: typeFlat, time: dateTime },
- height: $(window).height() - 170,
- colModel: data,
- rownumbers: true,
- viewrecords: true,
- rowNum: 50,
- gridview: true,
- footerrow: true,
- gridComplete: function () {
- GridHeadSetting(gridId);
- },
- loadError: function (xhr, status, error) {
- }
- });
- }
- //表头格式化
- function GridHeadSetting(gridId) {
- var index = getSelectedTabIndex();
- var groupHeaders = "[";
-
- if (index == 1)
- {
- for (var i = 0; i < checkedIds.length; i++) {
- groupHeaders = groupHeaders + "{\"startColumnName\":\"avg_" + checkedIds[i] + "\",\"numberOfColumns\": \"3\", \"titleText\": \"" + checkedNoteName[i] + "\"}";
- if (i < checkedIds.length - 1) groupHeaders = groupHeaders + ",";
- }
- }
- groupHeaders = groupHeaders + "]";
-
- $("#" + gridId).setGroupHeaders({
- useColSpanStyle: true, //表头是否合并行
- groupHeaders: JSON.parse(groupHeaders)
- });
- }
- function getSelectedTabIndex() {
- return $("#tabs").tabs('option', 'active');
- }
|