You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

417 lines
19 KiB

@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Index.cshtml";
}
<script src="~/Content/js/CommonReport/CommonReport.js"></script>
<script src="~/Content/js/datepicker/WdatePicker.js"></script>
<script>
;
var _Closs = new Array();
// 创建一个新的 Date 对象,表示当前日期和时间
var currentDate = new Date();
// 获取当前月份(注意:月份是从0开始计数的)
var currentMonth = currentDate.getMonth() + 1; // 加1以符合人类习惯
var currentyear = currentDate.getFullYear();
$(function () {
;
$("#txt_DateNow").val(currentyear + "-" + currentMonth)
SetCols();
gridList();
$("#btn_search").click(function () {
;
currentDate = new Date($("#txt_DateNow").val());
currentMonth = currentDate.getMonth() + 1; // 加1以符合人类习惯
currentyear = currentDate.getFullYear();
//var queryJson = {
// DateNow: $("#txt_DateNow").val(),
//}
//$gridList.jqGrid('setGridParam', {
// postData: { queryJson: JSON.stringify(queryJson) },
//}).trigger('reloadGrid');
SetCols();
gridList();
});
})
//初始化所有grid
function SetCols() {
var cols = new Array();
var collast = {
label: "不良描述", name: "BRGDesc", width: 100, align: "center", sortable: false, frozen: true,
cellattr: function (rowId, tv, rawObject, cm, rdata) {
//合并单元格
return 'id=\'BRGDesc' + rowId + "\'";
}
};
cols.push(collast);
var collast = {
label: "占比(%)", name: "Proportion", width: 120, align: "center", sortable: false, frozen: true,
cellattr: function (rowId, tv, rawObject, cm, rdata) {
//合并单元格
return 'id=\'Proportion' + rowId + "\'";
}
};
cols.push(collast);
var collast = {
label: "不良原因", name: "BadReasonDesc", width: 100, align: "center", sortable: false, frozen: true,
cellattr: function (rowId, tv, rawObject, cm, rdata) {
//合并单元格
return 'id=\'BadReasonDesc' + rowId + "\'";
}
};
cols.push(collast);
var collast = {
label: "改善对策", name: "Improvementmeasures", width: 120, align: "center", sortable: false, frozen: true,
cellattr: function (rowId, tv, rawObject, cm, rdata) {
//合并单元格
return 'id=\'Improvementmeasures' + rowId + "\'";
}
};
cols.push(collast);//下面这句代码是加入图片的关键,
var collast = {
label: "责任部门", name: "Responsibledepartment", width: 100, align: "center", sortable: false, frozen: true,
cellattr: function (rowId, tv, rawObject, cm, rdata) {
//合并单元格
return 'id=\'Responsibledepartment' + rowId + "\'";
}
};
cols.push(collast);
var collast = {
label: currentMonth + '月第1周', name: '周1', width: 90, align: "center", sortable: false, frozen: true,
cellattr: function (rowId, tv, rawObject, cm, rdata) {
//合并单元格
return 'id=\'周1' + rowId + "\'";
}
};
cols.push(collast);
var collast = {
label: currentMonth + '月第2周', name: '周2', width: 90, align: "center", sortable: false, frozen: true,
cellattr: function (rowId, tv, rawObject, cm, rdata) {
//合并单元格
return 'id=\'周2' + rowId + "\'";
}
};
cols.push(collast);
var collast = {
label: currentMonth + '月第3周', name: '周3', width: 90, align: "center", sortable: false,
cellattr: function (rowId, tv, rawObject, cm, rdata) {
//合并单元格
return 'id=\'周3' + rowId + "\'";
}
};
cols.push(collast);
var collast = {
label: currentMonth + '月第4周', name: '周4', width: 90, align: "center", sortable: false,
cellattr: function (rowId, tv, rawObject, cm, rdata) {
//合并单元格
return 'id=\'周4' + rowId + "\'";
}
};
cols.push(collast);
var collast = {
label: currentMonth + '月第5周', name: '周5', width: 90, align: "center", sortable: false,
cellattr: function (rowId, tv, rawObject, cm, rdata) {
//合并单元格
return 'id=\'周5' + rowId + "\'";
}
};
cols.push(collast);
var collast = {
label: currentMonth + '月第6周', name: '周6', width: 90, align: "center", sortable: false,
cellattr: function (rowId, tv, rawObject, cm, rdata) {
//合并单元格
return 'id=\'周6' + rowId + "\'";
}
};
cols.push(collast);
var collast = {
label: "合计", name: "ZBCount", width: 120, align: "center", sortable: false, frozen: true,
cellattr: function (rowId, tv, rawObject, cm, rdata) {
//合并单元格
return 'id=\'ZBCount' + rowId + "\'";
}
};
cols.push(collast);
var collast = {
label: "年度累计", name: "YBCount", width: 120, align: "center", sortable: false, frozen: true,
cellattr: function (rowId, tv, rawObject, cm, rdata) {
//合并单元格
return 'id=\'YBCount' + rowId + "\'";
}
};
cols.push(collast);
var collast = {
label: '1月', name: '月1', width: 90, align: "center", sortable: false, frozen: true,
cellattr: function (rowId, tv, rawObject, cm, rdata) {
//合并单元格
return 'id=\'Annualcumulative' + rowId + "\'";
}
};
cols.push(collast);
var collast = {
label: '2月', name: '月2', width: 90, align: "center", sortable: false, frozen: true,
cellattr: function (rowId, tv, rawObject, cm, rdata) {
//合并单元格
return 'id=\'Annualcumulative' + rowId + "\'";
}
};
cols.push(collast);
var collast = {
label: '3月', name: '月3', width: 90, align: "center", sortable: false, frozen: true,
cellattr: function (rowId, tv, rawObject, cm, rdata) {
//合并单元格
return 'id=\'Annualcumulative' + rowId + "\'";
}
};
cols.push(collast);
var collast = {
label: '4月', name: '月4', width: 90, align: "center", sortable: false, frozen: true,
cellattr: function (rowId, tv, rawObject, cm, rdata) {
//合并单元格
return 'id=\'Annualcumulative' + rowId + "\'";
}
};
cols.push(collast);
var collast = {
label: '5月', name: '月5', width: 90, align: "center", sortable: false, frozen: true,
cellattr: function (rowId, tv, rawObject, cm, rdata) {
//合并单元格
return 'id=\'Annualcumulative' + rowId + "\'";
}
};
cols.push(collast);
var collast = {
label: '6月', name: '月6', width: 90, align: "center", sortable: false, frozen: true,
cellattr: function (rowId, tv, rawObject, cm, rdata) {
//合并单元格
return 'id=\'Annualcumulative' + rowId + "\'";
}
};
cols.push(collast);
var collast = {
label: '7月', name: '月7', width: 90, align: "center", sortable: false, frozen: true,
cellattr: function (rowId, tv, rawObject, cm, rdata) {
//合并单元格
return 'id=\'Annualcumulative' + rowId + "\'";
}
};
cols.push(collast);
var collast = {
label: '8月', name: '月8', width: 90, align: "center", sortable: false, frozen: true,
cellattr: function (rowId, tv, rawObject, cm, rdata) {
//合并单元格
return 'id=\'Annualcumulative' + rowId + "\'";
}
};
cols.push(collast);
var collast = {
label: '9月', name: '月9', width: 90, align: "center", sortable: false, frozen: true,
cellattr: function (rowId, tv, rawObject, cm, rdata) {
//合并单元格
return 'id=\'Annualcumulative' + rowId + "\'";
}
};
cols.push(collast);
var collast = {
label: '10月', name: '月10', width: 90, align: "center", sortable: false, frozen: true,
cellattr: function (rowId, tv, rawObject, cm, rdata) {
//合并单元格
return 'id=\'Annualcumulative' + rowId + "\'";
}
};
cols.push(collast);
var collast = {
label: '11月', name: '月11', width: 90, align: "center", sortable: false, frozen: true,
cellattr: function (rowId, tv, rawObject, cm, rdata) {
//合并单元格
return 'id=\'Annualcumulative' + rowId + "\'";
}
};
cols.push(collast);
var collast = {
label: '12月', name: '月12', width: 90, align: "center", sortable: false, frozen: true,
cellattr: function (rowId, tv, rawObject, cm, rdata) {
//合并单元格
return 'id=\'Annualcumulative' + rowId + "\'";
}
};
cols.push(collast);
_Closs = cols;
}
function gridList() {
;
document.getElementById("gridPanel").innerHTML = '<table id="gridList"></table><div id="gridPager"></div> ';//重置grid
var $gridList = $("#gridList");
var queryJson = {
DateNow: $("#txt_DateNow").val(),
}
// 初始化表格
$gridList.dataGrid({
url: "/KBSWMS/ICSInspectionReports/GetPassFirstTime2" + "?" + Math.random(),
postData: { queryJson: JSON.stringify(queryJson) },
height: $(window).height() - 128,
width: $(window).width() - 128,
colModel: _Closs,
rownumbers: true,
footerrow: true,//启用底部行(对列汇总时要启用)第一步
gridComplete: function () {
var gridName = "gridList";
Merger(gridName, 'BRGDesc');
Merger1(gridName, 'ZBCount', 'BRGDesc');
Merger1(gridName, 'Proportion', 'BRGDesc');
Merger1(gridName, 'YBCount', 'BRGDesc');
var Z1_total = $(this).getCol('周1', false, 'sum');
var Z2_total = $(this).getCol('周2', false, 'sum');
var Z3_total = $(this).getCol('周3', false, 'sum');
var Z4_total = $(this).getCol('周4', false, 'sum');
var Z5_total = $(this).getCol('周5', false, 'sum');
var Z6_total = $(this).getCol('周6', false, 'sum');
var Y1_total = $(this).getCol('月1', false, 'sum');
var Y2_total = $(this).getCol('月2', false, 'sum');
var Y3_total = $(this).getCol('月3', false, 'sum');
var Y4_total = $(this).getCol('月4', false, 'sum');
var Y5_total = $(this).getCol('月5', false, 'sum');
var Y6_total = $(this).getCol('月6', false, 'sum');
var Y7_total = $(this).getCol('月7', false, 'sum');
var Y8_total = $(this).getCol('月8', false, 'sum');
var Y9_total = $(this).getCol('月9', false, 'sum');
var Y10_total = $(this).getCol('月10', false, 'sum');
var Y11_total = $(this).getCol('月11', false, 'sum');
var Y12_total = $(this).getCol('月12', false, 'sum');
$(this).footerData('set', {
"周1": Z1_total,//声明需要汇总的列并写自定义函数endMoney_total
"周2": Z2_total,//声明需要汇总的列并写自定义函数endMoney_total
"周3": Z3_total,//声明需要汇总的列并写自定义函数endMoney_total
"周4": Z4_total,//声明需要汇总的列并写自定义函数endMoney_total
"周5": Z5_total,//声明需要汇总的列并写自定义函数endMoney_total
"周6": Z6_total,//声明需要汇总的列并写自定义函数endMoney_total
"月1": Y1_total,//声明需要汇总的列并写自定义函数endMoney_total
"月2": Y2_total,//声明需要汇总的列并写自定义函数endMoney_total
"月3": Y3_total,//声明需要汇总的列并写自定义函数endMoney_total
"月4": Y4_total,//声明需要汇总的列并写自定义函数endMoney_total
"月5": Y5_total,//声明需要汇总的列并写自定义函数endMoney_total
"月6": Y6_total,//声明需要汇总的列并写自定义函数endMoney_total
"月7": Y7_total,//声明需要汇总的列并写自定义函数endMoney_total
"月8": Y8_total,//声明需要汇总的列并写自定义函数endMoney_total
"月9": Y9_total,//声明需要汇总的列并写自定义函数endMoney_total
"月10": Y10_total,//声明需要汇总的列并写自定义函数endMoney_total
"月11": Y11_total,//声明需要汇总的列并写自定义函数endMoney_total
"月12": Y12_total,//声明需要汇总的列并写自定义函数endMoney_total
});
$(this).footerData('set', { "BadReasonDesc": "合计:" });
},
});
// 搜索按钮点击事件
}
function Merger(gridName, CellName) {
;
//得到显示到界面的id集合
var mya = $("#" + gridName + "").getDataIDs();
//当前显示多少条
var length = mya.length;
for (var i = 0; i < length; i++) {
//从上到下获取一条信息
var before = $("#" + gridName + "").jqGrid('getRowData', mya[i]);
//定义合并行数
var rowSpanTaxCount = 1;
for (j = i + 1; j <= length; j++) {
//和上边的信息对比 如果值一样就合并行数+1 然后设置rowspan 让当前单元格隐藏
var end = $("#" + gridName + "").jqGrid('getRowData', mya[j]);
if (before[CellName] == end[CellName]) {
rowSpanTaxCount++;
$("#" + gridName + "").setCell(mya[j], CellName, '', { display: 'none' });
} else {
rowSpanTaxCount = 1;
break;
}
$("#" + CellName + "" + mya[i] + "").attr("rowspan", rowSpanTaxCount);
}
}
}
function Merger1(gridName, CellName, CellName1) {
debugger;
//得到显示到界面的id集合
var mya = $("#" + gridName + "").getDataIDs();
//当前显示多少条
var length = mya.length;
for (var i = 0; i < length; i++) {
//从上到下获取一条信息
var before = $("#" + gridName + "").jqGrid('getRowData', mya[i]);
//定义合并行数
var rowSpanTaxCount = 1;
for (j = i + 1; j <= length; j++) {
//和上边的信息对比 如果值一样就合并行数+1 然后设置rowspan 让当前单元格隐藏
var end = $("#" + gridName + "").jqGrid('getRowData', mya[j]);
if (before[CellName1] == end[CellName1]) {
if (before[CellName] == end[CellName]) {
rowSpanTaxCount++;
$("#" + gridName + "").setCell(mya[j], CellName, '', { display: 'none' });
} else {
rowSpanTaxCount = 1;
break;
}
$("#" + CellName + "" + mya[i] + "").attr("rowspan", rowSpanTaxCount);
}
}
}
}
function btn_Export() {
var data = "&DateNow=" + $("#txt_DateNow").val()
$.download("/KBSWMS/ICSInspectionReports/ExportAll?" + Math.random(), data, 'post');
}
</script>
<iframe id="ifrm" src="" width="0" height="0"></iframe>
<div class="topPanel" style="height:50px">
<div class="toolbar">
<div class="btn-group">
<a class="btn btn-primary" id="btn_search"><span class="glyphicon glyphicon-refresh"></span></a>
<a id="NF-Export" authorize="yes" class="btn btn-primary" onclick="btn_Export()"><i class="fa fa-download"></i>当前页导出</a>
</div>
</div>
<div class="search">
<table>
<tr>
<th class="formTitle">
<span style="color: red;">*</span>日期:
</th>
<td class="formValue">
<input type="text" name="txt_DateNow" id="txt_DateNow" class="form-control" style="width: 100px;height:13px" maxlength="10" onclick="WdatePicker({ dateFmt: 'yyyy-MM' })" placeholder="日期" />
</td>
</tr>
</table>
</div>
</div>
<div class="gridPanel" id="gridPanel">
<table id="gridList"></table>
<div id="gridPager"></div>
</div>