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.
171 lines
6.3 KiB
171 lines
6.3 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>
|
|
debugger;
|
|
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();
|
|
SetCols();
|
|
gridList();
|
|
});
|
|
|
|
})
|
|
//初始化所有grid
|
|
function SetCols() {
|
|
|
|
var cols = new Array();
|
|
var collast = {
|
|
label: "TOP厂商", name: "供应商", width: 200, align: "center", sortable: false, frozen: true,
|
|
cellattr: function (rowId, tv, rawObject, cm, rdata) {
|
|
//合并单元格
|
|
return 'id=\'供应商' + rowId + "\'";
|
|
}
|
|
};
|
|
cols.push(collast);
|
|
var collast = {
|
|
label: "项目类别", name: "类别", width: 120, align: "center", sortable: false, frozen: true,
|
|
cellattr: function (rowId, tv, rawObject, cm, rdata) {
|
|
//合并单元格
|
|
return 'id=\'类别' + rowId + "\'";
|
|
}
|
|
};
|
|
cols.push(collast);
|
|
|
|
var collast = {
|
|
label: "物料编码", name: "物料编码", width: 120, align: "center", sortable: false, frozen: true,
|
|
cellattr: function (rowId, tv, rawObject, cm, rdata) {
|
|
//合并单元格
|
|
return 'id=\'产品大类' + rowId + "\'";
|
|
}
|
|
};
|
|
cols.push(collast);
|
|
if (currentMonth - 0 < 10) {
|
|
var collast = {
|
|
label: currentMonth + '月', name: currentyear + '-0' + currentMonth, width: 100, align: "center", sortable: false, frozen: true,
|
|
cellattr: function (rowId, tv, rawObject, cm, rdata) {
|
|
//合并单元格
|
|
return 'id=\'YB' + rowId + "\'";
|
|
}
|
|
};
|
|
cols.push(collast);
|
|
|
|
} else{
|
|
var collast = {
|
|
label: currentMonth + '月', name: currentyear + '-' + currentMonth, width: 100, align: "center", sortable: false, frozen: true,
|
|
cellattr: function (rowId, tv, rawObject, cm, rdata) {
|
|
//合并单元格
|
|
return 'id=\'YB' + rowId + "\'";
|
|
}
|
|
};
|
|
cols.push(collast);
|
|
}
|
|
|
|
|
|
|
|
_Closs = cols;
|
|
}
|
|
|
|
|
|
function gridList() {
|
|
debugger;
|
|
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/GetPassFirstTime5" + "?" + Math.random(),
|
|
postData: { queryJson: JSON.stringify(queryJson) },
|
|
height: $(window).height() - 128,
|
|
width: $(window).width() - 128,
|
|
colModel: _Closs,
|
|
rownumbers: false,
|
|
rowNum: 2000,
|
|
footerrow: true,//启用底部行(对列汇总时要启用)第一步
|
|
gridComplete: function () {
|
|
var gridName = "gridList";
|
|
Merger(gridName, '供应商');
|
|
},
|
|
Number: 1000
|
|
|
|
});
|
|
|
|
// 搜索按钮点击事件
|
|
|
|
}
|
|
function Merger(gridName, CellName) {
|
|
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[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/ExportAll5?" + 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>
|
|
|