|
|
@{ ViewBag.Title = "Index"; Layout = "~/Views/Shared/_Index.cshtml"; } <link href="~/Content/js/select2/select2.min.css" rel="stylesheet" /> <script src="~/Content/js/select2/select2.min.js"></script> <script> var InvCode = decodeURI($.request("InvCode")); var JYID = decodeURI($.request("JYID")); var SampleQuantity = $.request("SampleQuantity"); var ResultINp = decodeURI($.request("Result")); $(function () { debugger; gridList(); })
function gridList() { debugger; var $gridList = $("#gridList"); if (ResultINp == "") { $gridList.dataGrid({ url: "/WMS/ICSRCVIQCs/GetInventoryInspection?InvCode=" + InvCode + "&" + Math.random() + "&SampleQuantity=" + SampleQuantity + "&ResultINp=" + ResultINp, height: $(window).height() - 50, width: $(window).height() - 200, cellEdit: true, colModel: [ { label: "主键", name: "ID", hidden: true, key: true }, { label: '检验ID', name: 'InspectionID', hidden: true }, { label: "抽样次数", name: "NUM", width: 100, align: 'left' }, { label: "检验项目组代码", name: "GroupCode", width: 100, align: 'left' }, { label: "检验项目组名称", name: "GroupName", width: 100, align: 'left' }, { label: "检验项目代码", name: "ListCode", width: 100, align: 'left' }, { label: "检验项目名称", name: "ListName", width: 100, align: 'left' }, { label: "单位", name: "Unit", width: 100, align: 'left' }, { label: '标准上限', name: 'SetValueMax', width: 80, align: 'left' }, { label: '标准下限', name: 'SetValueMin', width: 80, align: 'left' }, { label: '实际值', name: 'SetValue', width: 150, align: 'left', editable: true, editrules: { number: true } }, { label: '是否合格', name: 'Result', width: 80, align: 'left' },
], //pager: "#gridPager", cellsubmit: "clientArray", //sortname: 'ListCode', viewrecords: true, rowNum: 200, afterSaveCell: function (rowid, cellname, value) { debugger; //总扣分数加其他扣分数 if (cellname === 'SetValue') { Price = Number(value); if (Price < 0) { $.modalAlert("请输入大于0的单价!"); return; } SetValueMax = Number($gridList.jqGrid("getCell", rowid, 'SetValueMax')); SetValueMin = Number($gridList.jqGrid("getCell", rowid, 'SetValueMin')); SumSetValue = SetValueMax + SetValueMin if (Price != 0) { if (Price > SumSetValue) { $("#gridList").jqGrid('setCell', rowid, "Result", "不合格"); } else { $("#gridList").jqGrid('setCell', rowid, "Result", "合格"); } } } } }); } else { $gridList.dataGrid({ url: "/WMS/ICSRCVIQCs/GetInventoryInspection?InvCode=" + InvCode + "&" + Math.random() + "&SampleQuantity=" + SampleQuantity + "&ResultINp=" + ResultINp, height: $(window).height() - 50, width: $(window).height() - 200, cellEdit: true, colModel: [ { label: "主键", name: "ID", hidden: true, key: true }, { label: '检验ID', name: 'InspectionID', hidden: true }, { label: "抽样次数", name: "NUM", width: 100, align: 'left' }, { label: "检验项目组代码", name: "GroupCode", width: 100, align: 'left' }, { label: "检验项目组名称", name: "GroupName", width: 100, align: 'left' }, { label: "检验项目代码", name: "ListCode", width: 100, align: 'left' }, { label: "检验项目名称", name: "ListName", width: 100, align: 'left' }, { label: "单位", name: "Unit", width: 100, align: 'left' }, { label: '标准上限', name: 'SetValueMax', width: 80, align: 'left' }, { label: '标准下限', name: 'SetValueMin', width: 80, align: 'left' }, { label: '实际值', name: 'SetValue', width: 150, align: 'left', editable: true, editrules: { number: true } }, { label: '是否合格', name: 'Result', width: 80, align: 'left' },
], //pager: "#gridPager", cellsubmit: "clientArray", sortname: 'NUM,GroupCode', sortorder: "asc", viewrecords: true, rowNum: 200, afterSaveCell: function (rowid, cellname, value) { debugger; //总扣分数加其他扣分数 if (cellname === 'SetValue') { Price = Number(value); if (Price < 0) { $.modalAlert("请输入大于0的单价!"); return; } SetValueMax = Number($gridList.jqGrid("getCell", rowid, 'SetValueMax')); SetValueMin = Number($gridList.jqGrid("getCell", rowid, 'SetValueMin')); SumSetValue = SetValueMax + SetValueMin if (Price != 0) { if (Price > SumSetValue) { $("#gridList").jqGrid('setCell', rowid, "Result", "不合格"); } else { $("#gridList").jqGrid('setCell', rowid, "Result", "合格"); } } } } }); } }
function submitForm() { debugger; var ICSMTDOC = []; var obj_Item1 = $("#gridList"); var Result = ''; var rowIds_Item1 = obj_Item1.getDataIDs(); if (rowIds_Item1.length > 0) { for (var i = 0; i < rowIds_Item1.length; i++) { var RowData_Item1 = obj_Item1.getRowData(rowIds_Item1[i]); if (RowData_Item1.SetValue=='') { $.modalAlertNew("WMS00105"); return; } if (RowData_Item1.Result == '') { $.modalAlertNew("WMS00105"); return; } if (RowData_Item1.Result == "合格") { Result='1'; }else { Result='0'; } var obj = { ID: RowData_Item1.ID, InspectionID: JYID, GroupCode: RowData_Item1.GroupCode, GroupName: RowData_Item1.GroupName, ListCode: RowData_Item1.ListCode, ListName: RowData_Item1.ListName, Unit: RowData_Item1.Unit, SetValueMax: RowData_Item1.SetValueMax, SetValueMin: RowData_Item1.SetValueMin, SetValue: RowData_Item1.SetValue, Result: Result, NUM: RowData_Item1.NUM }; ICSMTDOC.push(obj); }
} debugger; $.modalConfirm("确定保存吗?", function (r) { if (r) { $.submitForm({ url: "/WMS/ICSRCVIQCs/SaveICSInspectionDetail?InvCode=" + InvCode + "&" + Math.random() + "&ResultINp=" + ResultINp, param: { ICSMTDOC: JSON.stringify(ICSMTDOC) }, success: function () { $.currentWindow().$("#gridList").trigger("reloadGrid"); } }) } });
}
</script>
<form id="form1">
<div class="gridPanel"> <table id="gridList"></table> @*<div id="gridPager"></div>*@ </div>
</form>
|