|
|
@{ ViewBag.Title = "Index"; Layout = "~/Views/Shared/_Index.cshtml"; }
<script>
$(function () {
gridList(); SireCodeBinding(); LotNoBinding(); });
function gridList() {
var $gridList = $("#gridList"); $gridList.dataGrid({ url: "/WMS/BasicSettings/GetSendContainerLot?" + Math.random(), height: $(window).height() -50, width: $(window).width() - 400, cellEdit: true, cellsubmit: "clientArray", colModel: [ { label: "主键", name: "ID", hidden: true, key: true }, { label: '删除', width: 100, align: 'left', formatter: btnLook }, { label: '条码', name: 'LotNo', width: 120, align: 'left' }, { label: '料品编码', name: 'InvCode', width: 150, align: 'left' }, { label: '料品名称', name: 'InvName', width: 100, align: 'left' }, { label: '规格型号', name: 'InvStd', width: 200, align: 'left' }, { label: '单位', name: 'InvUnit', width: 200, align: 'left' }, { label: '生产日期', name: 'ProductDate', width: 200, align: 'left' }, { label: '数量', name: 'Quantity', width: 200, align: 'left' }, { label: '项目号', name: 'ProjectCode', width: 200, align: 'left',hidden:true }, { label: '批次', name: 'BatchCode', width: 200, align: 'left', hidden: true }, { label: '版本', name: 'Version', width: 200, align: 'left', hidden: true }, { label: '厂牌', name: 'Brand', width: 200, align: 'left', hidden: true }, { label: '自由项1', name: 'cFree1', width: 200, align: 'left', hidden: true }, { label: '自由项2', name: 'cFree2', width: 200, align: 'left', hidden: true }, { label: '自由项3', name: 'cFree3', width: 200, align: 'left', hidden: true }, { label: '自由项4', name: 'cFree4', width: 200, align: 'left', hidden: true }, { label: '自由项5', name: 'cFree5', width: 200, align: 'left', hidden: true }, { label: '自由项6', name: 'cFree6', width: 200, align: 'left', hidden: true }, { label: '自由项7', name: 'cFree7', width: 200, align: 'left', hidden: true }, { label: '自由项8', name: 'cFree8', width: 200, align: 'left', hidden: true }, { label: '自由项9', name: 'cFree9', width: 200, align: 'left', hidden: true }, { label: '自由项10', name: 'cFree10', width: 200, align: 'left', hidden: true }, ], afterSaveCell: function (rowid, cellname, value) { if (cellname === 'ProjectCN') { $gridList.jqGrid("setCell", rowid, 'ProjectID', value); } }, width: "100%",
autowidth: true, rownumbers: true, viewrecords: true, }); }
function btnLook(cellvalue, options, rowObject) { return cellvalue = "<a class=\"btn btn-primary dropdown-text\" onclick=\"UpLoadClick('" + rowObject.ID + "')\">删除</a>"; }
function UpLoadClick(ID) { $("#gridList").delRowData(ID); }
function SireCodeBinding() { $("#SireCode").keydown(function (e) { var curKey = e.which; debugger; if (curKey == 13) { var SireCode = $("#SireCode").val();//需绑定容器 $.ajax({ url: "/WMS/BasicSettings/GetBindContainerID?SireCode=" + SireCode, dataType: "json", async: false, success: function (data) { debugger; if (data == "" || data == null) { $.modalAlertNew("WMS00022"); return; } $("#SireID").val(data.rows[0].ID); $("#LotNo").focus(); } }); $("#SireCode").attr("disabled", "disabled"); } }); };
function LotNoBinding() { $("#LotNo").keydown(function (e) { var curKey = e.which; debugger; if (curKey == 13) { var LotNo = $("#LotNo").val();//需绑定容器 $.ajax({ url: "/WMS/BasicSettings/GetContainerLotInfo?LotNo=" + LotNo, dataType: "json", async: false, success: function (data) { debugger; if (data == "" || data == null) { $.modalAlertNew("WMS00022"); return; } //最后一行新增数据 var obj = { ID: data.rows[0].ID, LotNo: data.rows[0].LotNo, InvCode: data.rows[0].InvCode, InvName: data.rows[0].InvName, InvStd: data.rows[0].InvStd, InvUnit: data.rows[0].InvUnit, ProductDate: data.rows[0].ProductDate, Quantity: data.rows[0].Quantity, ProjectCode: data.rows[0].ProjectCode, BatchCode: data.rows[0].BatchCode, Version: data.rows[0].Version, Brand: data.rows[0].Brand, cFree1: data.rows[0].cFree1, cFree2: data.rows[0].cFree2, cFree3: data.rows[0].cFree3, cFree4: data.rows[0].cFree4, cFree5: data.rows[0].cFree5, cFree6: data.rows[0].cFree6, cFree7: data.rows[0].cFree7, cFree8: data.rows[0].cFree8, cFree9: data.rows[0].cFree9, cFree10: data.rows[0].cFree10 }; $("#gridList").jqGrid('addRowData', obj.ID, obj, 'first'); $(".unwritten").hide(); } }); } }); };
//function submitForm() { // debugger; // var SireID = $("#SireID").val(); // var SireCode = $("#SireCode").val(); // var ICSMTDOC = []; // var obj_Item1 = $("#gridList"); // 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]); // var obj = { // LotNo: RowData_Item1.LotNo, // }; // ICSMTDOC.push(obj); // }
// } // debugger; // $.modalConfirm("确定绑定吗?", function (r) { // if (r) { // $.submitForm({ // url: "/WMS/BasicSettings/BindingContainerLotID?SireID=" + SireID + "&SireCode=" + SireCode + "&" + Math.random(), // param: { ICSMTDOC: JSON.stringify(ICSMTDOC) }, // success: function () { // $.currentWindow().$("#gridList").trigger("reloadGrid"); // } // }) // } // });
//} function submitForm() { debugger; var RoleEnCode = '@NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode' var WorkPoint = '@NFine.Code.OperatorProvider.Provider.GetCurrent().Location' var SireCode = $("#SireCode").val();//需绑定容器 var date = new Date(); var Details = []; var obj_Item1 = $("#gridList"); 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]); var obj = { LotNo: RowData_Item1.LotNo, ContainerCode: SireCode, ProjectCode: RowData_Item1.ProjectCode, BatchCode: RowData_Item1.BatchCode, Version: RowData_Item1.Version, Brand: RowData_Item1.Brand, cFree1: RowData_Item1.cFree1, cFree2: RowData_Item1.cFree2, cFree3: RowData_Item1.cFree3, cFree4: RowData_Item1.cFree4, cFree5: RowData_Item1.cFree5, cFree6: RowData_Item1.cFree6, cFree7: RowData_Item1.cFree7, cFree8: RowData_Item1.cFree8, cFree9: RowData_Item1.cFree9, cFree10: RowData_Item1.cFree10, }; Details.push(obj); }
} var Header = { WorkPoint: WorkPoint, User: RoleEnCode, detail:Details } var Parameter = []; Parameter.push(Header); $.modalConfirm("确定绑定吗?", function (r) { $.submitForm({ url: "/WMS/BasicSettings/BindingContainerLotID?SireID="+ "?" + Math.random(), param: { keyValue: JSON.stringify(Parameter) }, success: function () { $.currentWindow().$("#gridList").trigger("reloadGrid"); } }) }) }
</script>
<form id="form1">
<div style="padding-top: 20px; margin-right: 20px;"> <table class="form"> <tr> <th class="formTitle">容器:</th> <td class="formValue"> <input id="SireCode" type="text" class="form-control" style="width: 300px;" οnkeydοwn="SireCodeBinding()" /> <input id="SireID" type="text" class="form-control" style="display:none" /> </td> <th class="formTitle">条码:</th> <td class="formValue"> <input id="LotNo" type="text" class="form-control" style="width: 300px;" οnkeydοwn="LotNoBinding()" /> </td> </tr> </table> </div> </form> <!--色牢度--> <div class="gridPanel" style="width: 100% "> <div class="ibox-title"> 子表 </div> <div class="gridPanel"> <table id="gridList"></table> </div> </div>
|