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.
 
 
 
 
 

631 lines
24 KiB

@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Form.cshtml";
}
<link href="~/Content/js/select2/select2.min.css" rel="stylesheet" />
<script src="~/Content/js/datepicker/WdatePicker.js"></script>
<script src="~/Content/js/select2/select2.min.js"></script>
<style>
#Additem {
margin-left: 45%;
}
#AddTemitem {
margin-right: 45%;
}
</style>
<script>
var _Clos = new Array();
var rfqcode = $.request("rfqcode");
var ID = $.request("ID");
var _LW = new Array();
function GetDate() {
let currentTime = new Date();
let year = currentTime.getFullYear();
let month = currentTime.getMonth() + 1; // 注意,月份是从0开始的,所以要加1
let date = currentTime.getDate();
let hours = currentTime.getHours();
let minutes = currentTime.getMinutes();
let seconds = currentTime.getSeconds();
// 格式化时间,补全前导零
month = month < 10 ? '0' + month : month;
date = date < 10 ? '0' + date : date;
hours = hours < 10 ? '0' + hours : hours;
minutes = minutes < 10 ? '0' + minutes : minutes;
seconds = seconds < 10 ? '0' + seconds : seconds;
// 拼接时间字符串
let formattedTime = `${year}-${month}-${date} ${hours}:${minutes}:${seconds}`;
return formattedTime;
}
$(function(){
SetCols();
if (ID=='') {
$(".MOPick").css('display', 'none');
}
var Muser = '@NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode'
var date = GetDate();
$("#txtMUSER").val(Muser);
$("#txtMTIME").val(date);
InitControl();
InitContro5();
ClearTemp();
reloadData();
$("#sel_CodeType").change(function () {
$.ajax({
url: "/DHAY/ICSMOIssue/GetBidCode" + "?" + Math.random(),
dataType: "json",
async: false,
success: function (data) {
if (data.Code != '') {
$("#Code").val(data.Code);
$("#Code").attr("disabled", "disabled");
}
}
});
});
$("#sel_CodeType").val('18').trigger("change");
})
function GetSelect_Project() {
debugger;
var Header = {
TypeName:"项目",
OrgCode: '@NFine.Code.OperatorProvider.Provider.GetCurrent().Location'
}
var str = "";
$.ajax({
url: "/DHAY/ICSCustomerSuppliedReturn/GetU9CodeType?" + Math.random(),
dataType: "json",
data: { key1: JSON.stringify(Header) },
async: false,
async: false,
success: function (data) {
var jsonobj = eval(data);
var length = jsonobj.length;
for (var i = 0; i < length; i++) {
if (i != length - 1) {
str += jsonobj[i].Code + ":" + jsonobj[i].Name + ";";
} else {
str += jsonobj[i].Code + ":" + jsonobj[i].Name;// 这里是option里面的 value:label
}
var objFiledName = {
Code: jsonobj[i].Code,
Name: jsonobj[i].Name,
}
_LW.push(objFiledName);
}
}
});
return str;
}
function SetCols() {
$.ajax({
url: "/Print/SelectColumnName?" + Math.random(),
dataType: "json",
async: false,
success: function (data) {
var cols = new Array();
var collast = { label: '主键', name: 'ID', width: 150, align: 'left', hidden: true, key: true };
cols.push(collast);
var collast = { label: 'ID', name: 'ID', width: 150, align: 'left', hidden: true };
cols.push(collast);
//var collast = {
// label: '查看', width: 100, align: 'left',
// formatter: btnLook
//};
// cols.push(collast);
var collast = { label: '工单编码', name: 'MOCode', width: 100, align: 'left' };
cols.push(collast);
var collast = { label: '料品编码', name: 'InvCode', width: 100, align: 'left' };
cols.push(collast);
var collast = { label: '料品名称', name: 'INVNAME', width: 100, align: 'left' };
cols.push(collast);
var collast = { label: '规格型号', name: 'InvStd', width: 100, align: 'left' };
cols.push(collast);
var collast = { label: '仓库编码', name: 'WHCode', width: 100, align: 'left', hidden: true };
cols.push(collast);
var collast = { label: '仓库名称', name: 'WHCodeName', width: 100, align: 'left', editable: true };
cols.push(collast);
var collast = { label: '批号', name: 'Batch', width: 100, align: 'left', editable: true };
cols.push(collast);
var collast = { label: '数量', name: 'Quantity', width: 100, align: 'left', editable: true, editrules: { number: true } };
cols.push(collast);
var collast = { label: '备注', name: 'DetailReamrk', width: 150, align: 'left', editable: true };
cols.push(collast);
if (data != null && data.length > 0) {
DateList = data;
for (var i = 0; i < data.length; i++) {
var ColName = data[i].ColName;
var ColCode = data[i].ColCode;
if (ColName!="批次") {
var obj = new Array();
obj = {
label: ColName,
name: ColCode,
width: 80,
align: "left"
}
cols.push(obj);
}
}
}
_Clos = cols;
}
});
}
function reloadData() {
$("#gridList").dataGrid({
url: "/WMS/ProductionIssue/GetICSReturnTemporary?rfqno=" + $("#txtApplyNegCode").val() + "&" + Math.random(),
//postData: { rfqno: $("#RFQNO").val() },
height: $(window).height() - 300,
width: $(window).width(),
cellEdit: true,
colModel: _Clos,
cellsubmit: "clientArray",
width: "100%",
//autowidth: true,
rownumbers: true,
viewrecords: true,
ondblClickRow: function (rowid, cellname, value) {
var colModel = $("#gridList").jqGrid("getGridParam", "colModel");
var cellIndex = $("#gridList").jqGrid("getGridParam", "iCol");
var cellname = colModel[cellIndex].name;
if (cellname == "MOCode") {
$.modalOpen({
id: "InvCodeSelect",
title: "选择生产订单备料信息",
url: "/DHAY/ICSMOIssue/GetInvCode",
width: "50%",
height: "50%",
callBack: function (iframeId) {
var objArr = top.frames[iframeId].submitForm();
for (var j = 0; j < objArr.length; j++) {
$("#gridList").jqGrid('addRowData', objArr[j].ID, objArr[j], 'last');
}
top.frames[iframeId].Close();
$("#gridList").delRowData(rowid);
}
});
} else if (cellname == "WHCodeName") {
$.modalOpen({
id: "GetWHCode",
title: "选择仓库",
url: "/DHAY/ICSCustomerSuppliedReturn/GetWHCode",
width: "50%",
height: "50%",
callBack: function (iframeId) {
debugger;
var obj = top.frames[iframeId].submitForm();
$("#gridList").jqGrid('setCell', rowid, 'WHCode', obj.WarehouseCode, 'review-' + rowid);
$("#gridList").jqGrid('setCell', rowid, 'WHCodeName', obj.WarehouseName, 'review-' + rowid);
$("#gridList").jqGrid("saveCell", rowid, 1);
$("#gridList").jqGrid("saveCell", rowid, 2);
$("#gridList").jqGrid("saveCell", rowid, 3);
$("#gridList").jqGrid("saveCell", rowid, 4);
$("#gridList").jqGrid("saveCell", rowid, 5);
$("#gridList").jqGrid("saveCell", rowid, 6);
$("#gridList").jqGrid("saveCell", rowid, 7);
$("#gridList").jqGrid("saveCell", rowid, 8);
$("#gridList").jqGrid("saveCell", rowid, 9);
top.frames[iframeId].Close();
}
});
} else if (cellname == "Batch") {
var invCode = $("#gridList").jqGrid("getRowData", rowid).InvCode;
$.modalOpen({
id: "InvCodeSelect",
title: "选择批次信息",
url: "/DHAY/ICSSDN/GetBatch?InvCode=" + invCode,
width: "50%",
height: "50%",
callBack: function (iframeId) {
debugger;
var obj = top.frames[iframeId].submitForm();
$("#gridList").jqGrid('setCell', rowid, 'Batch', obj.BatchCode, 'review-' + rowid);
$("#gridList").jqGrid("saveCell", rowid, 1);
$("#gridList").jqGrid("saveCell", rowid, 2);
$("#gridList").jqGrid("saveCell", rowid, 3);
$("#gridList").jqGrid("saveCell", rowid, 4);
$("#gridList").jqGrid("saveCell", rowid, 5);
$("#gridList").jqGrid("saveCell", rowid, 6);
$("#gridList").jqGrid("saveCell", rowid, 7);
$("#gridList").jqGrid("saveCell", rowid, 8);
$("#gridList").jqGrid("saveCell", rowid, 9);
top.frames[iframeId].Close();
}
});
}
}, afterSaveCell: function (rowid, celname, value, iRow, iCol) {// var datatime = '';
debugger;
// var aaa = "2999-12-31";
if (celname == "Quantity") {
var YLOTQTY = Number(value);
var ThisNumber = Number($("#gridList").jqGrid("getCell", rowid, 'Quantity'));
var InvCode = $("#gridList").jqGrid("getCell", rowid, 'InvCode');
$.ajax({
url: "/DHAY/ICSAccessoriesMOApply/GetInvCodeCount?invCode=" + InvCode + "&" + Math.random(),
dataType: "json",
async: false,
success: function (data) {
debugger;
var AllNumber = Number(data);
if (YLOTQTY > AllNumber) {
$("#gridList").jqGrid('setCell', rowid, 'Quantity', null);
$.modalAlertNew("WMSAPIInfo507");
return;
}
}
})
}
}
});
}
function btnLook(cellvalue, options, rowObject) {
return cellvalue = "<a class=\"btn btn-primary dropdown-text\" onclick=\"UpLoadClick('" + rowObject.ID + "')\">查看</a>";
}
function UpLoadClick(ID) {
$.modalOpen({
id: "selectDeatil",
title: "查看修改物料",
url: "/WMS/ProductionIssue/SeachInventory?ID=" + ID + "&" + Math.random(),
width: "1000px",
height: "1000px",
callBack: function (iframeId) {
var obj = top.frames[iframeId].submitForm();
var rowData = $("#gridList").jqGrid('getRowData', ID);
rowData.TLZID = obj.TLZID,
rowData.ZJID = obj.ZJID,
rowData.InvCode = obj.InvCode,
rowData.InvName = obj.InvName,
rowData.InvStd = obj.InvStd,
rowData.InvUnit = obj.InvUnit,
rowData.Quantity = obj.Quantity,
rowData.IssueNegQuantity = obj.IssueQuantity,
rowData.Amount = obj.Amount,
rowData.ExtensionID = obj.ExtensionID,
rowData.ProjectCode = obj.ProjectCode,
rowData.BatchCode = obj.BatchCode,
rowData.Version = obj.Version,
rowData.Brand = obj.Brand,
rowData.cFree1 = obj.cFree1,
rowData.cFree2 = obj.cFree2,
rowData.cFree3 = obj.cFree3,
rowData.cFree4 = obj.cFree4,
rowData.cFree5 = obj.cFree5,
rowData.cFree6 = obj.cFree6,
rowData.cFree7 = obj.cFree7,
rowData.cFree8 = obj.cFree8,
rowData.cFree9 = obj.cFree9,
rowData.cFree10 = obj.cFree10
$("#gridList").jqGrid('setRowData', ID, rowData);
$(".unwritten").hide();
top.frames[iframeId].Close();
}
});
}
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);
});
}
//最后一行新增数据
function AddRowToLast() {
var obj = {
ID: guid(),
WHCode: ""
};
$("#gridList").jqGrid('addRowData', obj.ID, obj, 'last');
$(".unwritten").hide();
}
function DeleteRowToLast() {
debugger;
var rowid = $("#gridList").jqGridRowValue().ID
$("#gridList").delRowData(rowid);
}
//获取U9单据类型
function InitControl() {
var $CodeType = $("#sel_CodeType");
$CodeType.select2({
allowClear: true,
escapeMarkup: function (m) {
return m;
}
});
$.ajax({
url: "/DHAY/ICSMOIssue/GetU9CodeType?type=超额领料"+"&" + Math.random(),
dataType: "json",
async: false,
success: function (data) {
$CodeType.append("<option value=''></option>");
$.each(data, function (index, item) {
$CodeType.append("<option value='" + item.Code + "'>&nbsp;" + item.Name + "</option>");
});
}
});
}
//获取工单编码
function InitContro2() {
var $Dept = $("#sel_MOCode");
$Dept.select2({
allowClear: true,
escapeMarkup: function (m) {
return m;
}
});
$.ajax({
url: "/DHAY/ICSMOIssue/GetU9CodeType?type=部门" + "&" + Math.random(),
dataType: "json",
async: false,
success: function (data) {
$Dept.append("<option value=''></option>");
$.each(data, function (index, item) {
$Dept.append("<option value='" + item.Code + "'>&nbsp;" + item.Name + "</option>");
});
}
});
}
//获取U9客户
function InitContro3() {
var $Custmer = $("#sel_Custmer");
$Custmer.select2({
allowClear: true,
escapeMarkup: function (m) {
return m;
}
});
$.ajax({
url: "/DHAY/ICSMOIssue/GetU9CodeType?type=客户" + "&" + Math.random(),
dataType: "json",
async: false,
success: function (data) {
$Custmer.append("<option value=''></option>");
$.each(data, function (index, item) {
$Custmer.append("<option value='" + item.Code + "'>&nbsp;" + item.Name + "</option>");
});
}
});
}
//获取U9项目
function InitContro4() {
var $Project = $("#sel_SYproject");
$Project.select2({
allowClear: true,
escapeMarkup: function (m) {
return m;
}
});
$.ajax({
url: "/DHAY/ICSMOIssue/GetU9CodeType?type=项目" + "&" + Math.random(),
dataType: "json",
async: false,
success: function (data) {
$Project.append("<option value=''></option>");
$.each(data, function (index, item) {
$Project.append("<option value='" + item.Code + "'>&nbsp;" + item.Name + "</option>");
});
}
});
}
//获取领用部门
function InitContro5() {
var $Dept = $("#sel_LYDept");
$Dept.select2({
allowClear: true,
escapeMarkup: function (m) {
return m;
}
});
$.ajax({
url: "/DHAY/ICSMOIssue/GetLYDep?" + Math.random(),
dataType: "json",
async: false,
success: function (data) {
$Dept.append("<option value=''></option>");
$.each(data, function (index, item) {
$Dept.append("<option value='" + item.Code + "'>&nbsp;" + item.Name + "</option>");
});
}
});
}
function ClearTemp() {
$.ajax({
url: "/WMS/ProductionIssue/ClearTemp?" + Math.random(),
datatype: "json",
async: false
})
}
function submitForm() {
$("#gridList").find($("td[aria-describedby='gridList_rn']")).click();
debugger;
if (!$('#form1').formValid()) {
return false;
}
var SYprojectCode = '';
var CodeType = $("#sel_CodeType").val();//单据类型
var LYDept = $("#sel_LYDept").val();//部门
var Remarks = $("#Remarks").val();//备注
var Code = $("#Code").val();//单据号
var MTIME = $("#txtMTIME").val();//
var RoleEnCode = '@NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode'
var WorkPoint = '@NFine.Code.OperatorProvider.Provider.GetCurrent().Location'
var IDlist = "";
var Details = [];
SelPerson = "#SelBR_"
var obj_vendor = $("#gridList");
var rowIds_vendor = obj_vendor.getDataIDs();
var arrayData_vendor = new Array();
if (rowIds_vendor.length > 0) {
for (var i = 0; i < rowIds_vendor.length; i++) {
var vendorRowData = obj_vendor.getRowData(rowIds_vendor[i]);
debugger;
if (vendorRowData.Quantity == "" || vendorRowData.Quantity == 'undefined') {
$.modalAlertNew("WMS00089");
return;
}
var obj = {
ID: vendorRowData.ID,
Sequence: i + 1,
InvCode: vendorRowData.InvCode,
Quantity: vendorRowData.Quantity,
WHCode: vendorRowData.WHCode,
SourceCode: vendorRowData.MOCode,
DetailReamrk: vendorRowData.DetailReamrk,
Batch: vendorRowData.Batch
};
Details.push(obj);
}
var ICSASNs = {
Dept: '',
CodeType: CodeType,
Remarks: Remarks,
Code: Code,
MTIME: MTIME,
User: RoleEnCode,
Detail: Details,
}
var ICSASN = [];
ICSASN.push(ICSASNs);
$.submitForm({
url: "/DHAY/ICSMOIssue/SaveICSMOIssue?" + Math.random(),
param: { ICSASN: JSON.stringify(ICSASN) },
success: function () {
$.currentWindow().$("#gridList").trigger("reloadGrid");
}
})
}
}
function GetSelectPerson(ID, WHCode) {
debugger;
var str = "";
$.ajax({
url: "/DHAY/ICSCustomerSuppliedReturn/Select_ICSWHCode",
dataType: "json",
async: false,
async: false,
success: function (data) {
if (data != null && data.length > 0) {
$("#SelBR_" + ID + "").find("option").remove();
for (var i = 0; i < data.length; i++) {
$("#SelBR_" + ID + "").append("<option value='" + data[i].WarehouseCode + "'>" + data[i].WarehouseName + "</option>");
}
}
}
});
}
</script>
<form id="form1">
<div class="topPanel" style="height:10px">
<div class="btn-group">
@*<a id="AddItemLot" style="margin-left:3px;" class="btn btn-primary" onclick="btnCreate()"><i class="fa fa-pencil-square-o"></i>添加明细</a>
<a id="refresh" class="btn btn-primary" style="margin-left:3px;" onclick="reloadData()"><span class="glyphicon glyphicon-refresh"></span></a>*@
</div>
</div>
<div style="margin-right: 20px;">
<table class="form">
<thead>主表信息</thead>
<tr>
<th class="formTitle">单据类型:</th>
<td class="formValue">
<select id="sel_CodeType" name="sel_CodeType" class="form-control select2 required" style="width: 230px" placeholder="请选择单据类型..."></select>
<input type="hidden" id="hidetext" />
</td>
<th class="formTitle">单号:</th>
<td class="formValue">
<input id="Code" type="text" readonly="readonly" class="form-control required" />
</td>
</tr>
@*<tr>
<th class="formTitle">项目编号:</th>
<td class="formValue">
<input type="text" id="Remarks2" class="form-control" />
</td>
<th class="formTitle">领用部门:</th>
<td class="formValue">
<select id="sel_LYDept" name="sel_LYDept" class="form-control select2 " style="width: 230px" placeholder="请选择领用部门..."></select>
<input type="hidden" id="hidetext" />
</td>
</tr>*@
<tr>
<th class="formTitle">维护人:</th>
<td class="formValue">
<input id="txtMUSER" type="text" readonly="readonly" class="form-control" />
</td>
<th class="formTitle">维护时间:</th>
<td class="formValue">
<input id="txtMTIME" type="text" readonly="readonly" class="form-control" />
</td>
</tr>
<tr>
<th class="formTitle">超额原因:</th>
<td class="formValue">
<input type="text" id="Remarks" class="form-control" required />
</td>
</tr>
</table>
</div>
<div class="gridPanel" style="margin-left:10px">
<span><strong>子表信息</strong></span>
<table id="gridList"></table>
<div style="text-align:center">
<button id="AddRow" class="btn btn-primary" type="button" onclick="AddRowToLast()">添加</button>
<button id="DeleteRow" type="button" class="btn btn-primary" onclick="DeleteRowToLast()">删除</button>
</div>
</div>
</form>