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.
 
 
 
 
 

198 lines
8.0 KiB

@{
ViewBag.Title = "SeachInventory";
Layout = "~/Views/Shared/_Index.cshtml";
}
<link href="~/Content/js/select2/select2.min.css" rel="stylesheet" />
<link href="~/Content/js/dialog/dialog.css?v=20120420" rel="stylesheet" />
<script src="~/Content/js/datepicker/WdatePicker.js"></script>
<script src="~/Content/js/select2/select2.min.js"></script>
<script>
debugger;
var _Clos = new Array();
var MOCode = $.request("MOCode");
var Sequence = $.request("Sequence");
$(function () {
DateTime();
SetCols();
Init();
})
function DateTime() {
var myDate = new Date();
var year = myDate.getFullYear(); // 获取当前年
var monFrom = myDate.getMonth() === 0 ? 12 : myDate.getMonth(); // 上个月,如果当前是1月,则为12
var yearForLastMonth = myDate.getMonth() === 0 ? year - 1 : year; // 如果当前为1月,年份减1
// 获取上个月的日期
var dateFrom = myDate.getDate() < 10 ? "0" + myDate.getDate() : myDate.getDate(); // 获取当前日
monFrom = monFrom < 10 ? "0" + monFrom : monFrom; // 将月份格式化为两位数
var MtimeFrom = yearForLastMonth + "-" + monFrom + "-" + dateFrom; // 上个月的日期
$("#TimeFrom").val(MtimeFrom);
var mon = myDate.getMonth() + 1 < 10 ? "0" + (myDate.getMonth() + 1) : myDate.getMonth() + 1; //获取当前月
var date = myDate.getDate() + 1 < 10 ? "0" + myDate.getDate() : myDate.getDate(); //获取当前日
var MtimeArrive = year + "-" + mon + "-" + date;
$("#TimeArrive").val(MtimeArrive);
}
function SetCols() {
var cols = new Array();
var collast = { label: '主键', name: 'ID', hidden: true, key: true };
cols.push(collast);
var collast = { label: '工单号', name: 'MoCode', hidden: true, };
cols.push(collast);
var collast = { label: '工单行号', name: 'MoSeq', hidden: true,};
cols.push(collast);
var collast = { label: '追踪单号', name: 'Code', width: 100, align: 'left' };
cols.push(collast);
var collast = { label: '物料编码', name: 'ItemCode', width: 120, align: 'left' };
cols.push(collast);
var collast = { label: '物料名称', name: 'InvName', width: 100, align: 'left' };
cols.push(collast);
var collast = { label: '批次', name: 'BatchCode', width: 100, align: 'left' };
cols.push(collast);
var collast = { label: '单据数量', name: 'Qty', width: 100, align: 'left' };
cols.push(collast);
var collast = { label: '剩余可生成数', name: 'RemainingQTY2', width: 150, align: 'left' };
cols.push(collast);
var collast = { label: '生成数', name: 'RemainingQTY', width: 80, align: 'left' ,editable: true, editrules: { number: true } };
cols.push(collast);
_Clos = cols;
}
function Init() {
document.getElementById("gridPanel").innerHTML = ' <span><strong>详细信息</strong></span> <table id="gridList"></table> ';//重置grid
var invcode = $("#txt_Invcode").val();
var Code = $("#txt_Code").val();
var Invstd = $("#txt_Invstd").val();
var EATTRIBUTE2 = $("#txt_EATTRIBUTE2").val();
var TimeFrom = $("#TimeFrom").val();
var TimeArrive = $("#TimeArrive").val();
$("#gridList").dataGrid({
url: "/RTWMS/WMSCreateItemLot/GetCode" + "?MOCode=" + MOCode + "&Sequence=" + Sequence + "&" + Math.random(),
height: $(window).height() - 20,
width: $(window).width() - 300,
cellEdit: true,
colModel: _Clos,
cellsubmit: "clientArray",
pager: "#gridPager",
sortorder: "desc",
sortname: 'Code',
rowNum: 10000,
viewrecords: true,
multiselect: true,
beforeSelectRow: function (rowid) {
debugger;
// 获取批次列的值
var BatchCode = $("#gridList").jqGrid("getCell", rowid, 'BatchCode');
// 将批次值赋值给 id 为 input 的元素
$('#txt_BatchCode').val(BatchCode);
},
gridComplete: function () {
$("#gridList").jqGrid('setLabel', 'RemainingQTY', '', { 'color': 'red' });
},
afterSaveCell: function (rowid, cellname, value) {
//debugger;
var RemainingQTY2 = $("#gridList").jqGrid("getCell", rowid, 'RemainingQTY2');
//总扣分数加其他扣分数
if (cellname === 'RemainingQTY') {
var RemainingQTY = Number(value);
if (RemainingQTY <= 0) {
$.modalAlert("请输入大于0的生成数!", "warning");
return;
}
if (RemainingQTY > RemainingQTY2) {
RemainingQTY = 0;
$.modalAlert("所输入的生成数量不能大于跟踪单剩余可生成数!", "warning");
return;
}
$("#gridList").jqGrid("setCell", rowid, 'RemainingQTY', RemainingQTY);
}
},
})
};
function submitForm() {
debugger;
var rows = $("#gridList").jqGrid('getGridParam', 'selarrrow');
//if (rows.length < 1) {
// $.modalAlertNew("WMS00079");
// return;
//}
var BatchCode = $("#txt_BatchCode").val();
if (BatchCode=="") {
$.modalAlert("请输入条码批次!", "warning");
return;
}
var ARRS = [];
var objs = [];
var CodeInfo ='';
var thisCreateQty=0;
// var rowdata = $("#gridList").jqGrid("getRowData", rows[0]);
for (var i = 0; i < rows.length; i++) {
CodeInfo = CodeInfo+ $("#gridList").jqGrid('getRowData', rows[i]).Code + ',';
thisCreateQty += Number($("#gridList").jqGrid('getRowData', rows[i]).RemainingQTY);
var obj = {
MoCode: $("#gridList").jqGrid('getRowData', rows[i]).MoCode,
MoSeq: $("#gridList").jqGrid('getRowData', rows[i]).MoSeq,
Code: $("#gridList").jqGrid('getRowData', rows[i]).Code,
ItemCode: $("#gridList").jqGrid('getRowData', rows[i]).ItemCode,
InvName: $("#gridList").jqGrid('getRowData', rows[i]).InvName,
BatchCode: $("#gridList").jqGrid('getRowData', rows[i]).BatchCode,
Qty: $("#gridList").jqGrid('getRowData', rows[i]).Qty,
RemainingQTY2: $("#gridList").jqGrid('getRowData', rows[i]).RemainingQTY2,
RemainingQTY: $("#gridList").jqGrid('getRowData', rows[i]).RemainingQTY,
}
objs.push(obj);
}
CodeInfo = CodeInfo.slice(0, CodeInfo.length - 1);
ARRS = {
CodeInfo: CodeInfo,
thisCreateQty: thisCreateQty,
BatchCode:BatchCode,
objs:objs
};
return ARRS;
};
function Close() {
$.modalClose();
}
function reloadData() {
}
function guid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
</script>
<div class="topPanel" style="height:60px">
<div class="search">
<table>
<tr>
<td>
<label>请输入条码批次:</label>
</td>
<td>
<div class="input-group">
<input id="txt_BatchCode" type="text" class="form-control" placeholder="条码批次" style="width: 120px;">
</div>
</td>
</table>
</div>
</div>
<div class="gridPanel" id="gridPanel">
<table id="gridList"></table>
<div id="gridPager"></div>
</div>