var mygrid_recv;
var page_count = 5;
var column_count;
var jsonWmsZXInfoObj;
var changeCount = 0;
function $(id) {
return document.getElementById(id);
}
function initWinScreen() {
var winScreenHeight = 0;
var winScreenWidth = 0;
if (window.screen.height) {
winScreenHeight = window.screen.height;
}
if (window.screen.width) {
winScreenWidth = window.screen.width;
}
if (winScreenWidth >= 1440 && winScreenWidth >= 900) {
document.getElementById("mygrid_recv").style.height = "580px";
}
else if (winScreenWidth >= 1366 && winScreenWidth >= 768) {
document.getElementById("mygrid_recv").style.height = "340px";
}
else if (winScreenWidth >= 1024 && winScreenWidth >= 768) {
document.getElementById("mygrid_recv").style.height = "300px";
}
}
function doInitRecvGrid() {
mygrid_recv = new dhtmlXGridObject('mygrid_recv');
mygrid_recv.setImagePath("../images/");
mygrid_recv.setSkin("xp");
// 0 1 2 3 4 5 6 7 8 9
//mygrid_recv.setHeader(",箱号,封号,件数,重量,应收费用,应付费用,备注,剩余件数,库存量");
// 0 1 2 3 4 5 6 7
mygrid_recv.setHeader(",件数,重量,应收费用,应付费用,备注,剩余件数,库存量");
mygrid_recv.setInitWidths("30,100,100,100,100,150,100,100");
mygrid_recv.setColAlign("center,right,right,right,right,left,right,right");
mygrid_recv.setColSorting("na,str,str,str,str,str,str,str");
mygrid_recv.setColTypes("ch,ed,ed,ed,ed,ed,ed,ro,ro");
var urlVal = "WmsLCLInfoGridSource.aspx?read=exist&showcount=1&id=" + $("hdGID").value + "&associatedno=" + $("hid_associatedno").value + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
loader = null;
if (parseInt(loadVal) == 1) {
mygrid_recv.loadXML("WmsLCLInfoGridSource.aspx?read=init&showcount=1&id=" + $("hdGID").value + "&associatedno=" + $("hid_associatedno").value + "&val=" + newGuid());
setTimeout(function() {
//ReShowLabel(mygrid_recv);
}, 200);
}
mygrid_recv.init();
mygrid_recv.enableEditEvents(true, false, true);
mygrid_recv.enableMultiselect(true);
mygrid_recv.enableKeyboardSupport(true);
var pushVal = "";
var pressRecord = "";
var pressRowIndex = -1;
var pressCellIndex = -1;
var pressCount = 0;
var isExchange = false;
var shiftCount = 0;
var isDelete = 0;
var flagFilter = 0;
var flagTab = 0;
var flagEnter = 0;
var flagDelete = 0;
//手动编写Grid控件编辑事件,由于免费控件没有提供完整的编辑判断功能,现特此做更改
var txtEdit;
mygrid_recv.attachEvent("onEditCell", function (stage, rId, cInd, nValue, oValue) {
var newCheckValue = false;
//初始化状态
if (stage == 0) {
var selectedId = mygrid_recv.getSelectedRowId();
var rowIndex = mygrid_recv.getRowIndex(selectedId);
var oldVal = mygrid_recv.cellByIndex(rowIndex, 0).getValue().trim();
return true;
}
if (stage == 1) {
txtEdit = "";
for (i = 0; i < document.all.length; i++) {
if (document.all(i).tagName == "TEXTAREA") {
txtEdit = document.all(i);
txtEdit.focus();
txtEdit.select();
break;
}
}
}
//如果编辑结束
if (stage == 2) {
//获取当前RowID
var selectedId = mygrid_recv.getSelectedRowId();
//获取当前RowIndex
var rowIndex = mygrid_recv.getRowIndex(selectedId);
//获取当前CellIndex(ind)
var ind = mygrid_recv.getSelectedCellIndex();
//触发操作事件前获取单元值
var oldVal = mygrid_recv.cellByIndex(rowIndex, ind).getValue();
if (cInd == 1) {
var cellVal = mygrid_recv.cellByIndex(rowIndex, cInd).getValue();
var isint = IsNum(cellVal);
if (!isint) {
mygrid_recv.cellByIndex(rowIndex, 1).setLabel("0.0000");
alert("件数格式格式有误!");
return true;
}
//
//getGOODSPACK(rowIndex, cellVal);
return true;
}
else if (cInd == 2) {
var cellVal = mygrid_recv.cellByIndex(rowIndex, cInd).getValue();
var isint = IsNum(cellVal);
if (!isint) {
mygrid_recv.cellByIndex(rowIndex, 2).setLabel("0.0000");
alert("计费重量格式有误!");
return true;
}
//
//getGOODSRKSL(rowIndex, cellVal);
return true;
}
else if (cInd == 3) {
var cellVal = mygrid_recv.cellByIndex(rowIndex, cInd).getValue();
var isint = IsNum(cellVal);
if (!isint) {
mygrid_recv.cellByIndex(rowIndex, 3).setLabel("0.00");
alert("入库应收费用格式有误!");
return true;
}
return true;
}
else if (cInd == 4) {
var cellVal = mygrid_recv.cellByIndex(rowIndex, cInd).getValue();
var isint = IsNum(cellVal);
if (!isint) {
mygrid_recv.cellByIndex(rowIndex, 4).setLabel("0.00");
alert("入库应付费用格式有误!");
return true;
}
return true;
}
else {
return true;
}
}
});
//键盘操作事件
mygrid_recv.attachEvent("onKeyPress", function (code, cFlag, sFlag) {
//onKeyPress begin
//获取当前RowID
var selectedId = mygrid_recv.getSelectedRowId();
//获取当前RowIndex
var rowIndex = mygrid_recv.getRowIndex(selectedId);
//获取当前CellIndex(ind)
var ind = mygrid_recv.getSelectedCellIndex();
//触发操作事件前获取单元值
var oldVal = mygrid_recv.cellByIndex(rowIndex, ind).getValue();
//获取编辑单元
var txtEdit;
for (i = 0; i < document.all.length; i++) {
if (document.all(i).tagName == "TEXTAREA") {
txtEdit = document.all(i);
break;
}
}
if (code == 9)//Tab键
{
var colCount = mygrid_recv.getColumnsNum();
var rowCount = mygrid_recv.getRowsNum();
if (ind == 1) {
var cellVal = mygrid_recv.cellByIndex(rowIndex, ind).getValue();
var isint = IsNum(cellVal);
if (!isint) {
mygrid_recv.cellByIndex(rowIndex, 1).setLabel("0.0000");
//alert("件数格式必须为整数!");
return true;
}
}
else if (ind == 2) {
var cellVal = mygrid_recv.cellByIndex(rowIndex, ind).getValue();
var isint = IsNum(cellVal);
if (!isint) {
mygrid_recv.cellByIndex(rowIndex, 2).setLabel("0.0000");
//alert("计费重量格式有误!");
return true;
}
}
else if (ind == 3) {
var cellVal = mygrid_recv.cellByIndex(rowIndex, ind).getValue();
var isint = IsNum(cellVal);
if (!isint) {
mygrid_recv.cellByIndex(rowIndex, 3).setLabel("0.00");
//alert("计费重量格式有误!");
return true;
}
}
else if (ind == 4) {
var cellVal = mygrid_recv.cellByIndex(rowIndex, ind).getValue();
var isint = IsNum(cellVal);
if (!isint) {
mygrid_recv.cellByIndex(rowIndex, 4).setLabel("0.00");
//alert("计费重量格式有误!");
return true;
}
}
if (ind < colCount) {
isExchange = false;
pressRecord = "";
pressRowIndex = -1;
pressCellIndex = -1;
var cInd = ind;
var rId = selectedId;
mygrid_recv.selectCell(rowIndex, ind + 1, true, true);
mygrid_recv.editCell();
if (ind == colCount - 1) {
if (rowIndex < rowCount) {
mygrid_recv.editStop(true);
mygrid_recv.clearSelection();
mygrid_recv.selectCell(rowIndex + 1, 0, true, true);
mygrid_recv.editCell();
}
else {
return;
}
}
else {
return;
}
}
}
else if (code >= 65 && code <= 90) {//如果是输入英文字符
if (ind == 5) {
return true;
}
}
else if (code == 8)//delete
{
return true;
}
else if (code == 40)//向下方向键
{
var rowCount = mygrid_recv.getRowsNum();
mygrid_recv.clearSelection();
mygrid_recv.editStop();
if (rowIndex == (rowCount - 1)) {
addRecvRow();
}
else {
mygrid_recv.selectCell(rowIndex + 1, 0, true, true);
mygrid_recv.editCell();
}
}
else if (code == 38)//向上箭头
{
if (rowIndex > 0) {
mygrid_recv.clearSelection();
mygrid_recv.editStop();
mygrid_recv.selectCell(rowIndex - 1, 0, true, true);
mygrid_recv.editCell();
}
}
else {
return true;
}
});
setTimeout(function() {
markStatusColor(mygrid_recv);
}, 400);
}
//讲下拉列表Combo所有生成Array数组
function setComboByArray(gridNewObj, comboObj, rowGID, colIndex) {
var comboVal_arg = new Array();
comboVal_arg = comboObj.getKeys();
var newCombo = gridNewObj.getCustomCombo(rowGID, colIndex);
for (var i = 0; i < comboVal_arg.length; i++) {
var txtValue = comboObj.get(comboVal_arg[i]);
newCombo.put(comboVal_arg[i], txtValue);
}
}
function spliceBuffer(arrayRow) {
var strBuffer = "";
for (var i = 0; i < arrayRow.length; ++i) {
strBuffer = strBuffer + arrayRow[i];
if (i != arrayRow.length - 1) {
strBuffer = strBuffer + ",";
}
}
alert(strBuffer);
}
function isObjNaN(Obj) {
if (Obj.toString().toLowerCase() == "nan") {
return 0;
} else {
return Obj;
}
}
function addRecvRow() {
if (mygrid_recv.getRowsNum() > 0) {
var newId = newGuid();
//获取插入新纪录位置
var rowCount = mygrid_recv.getRowsNum();
// 0 1 2 3 4 5 6 7
//mygrid_recv.setHeader(",件数,重量,应收费用,应付费用,备注,剩余件数,库存量");
var js = "0.0000";
var zl = "0.0000";
var ys = "0.0000";
var yf = "0.0000";
var bz = "";
if (rowCount > 0) {
js = mygrid_recv.cellByIndex(rowCount - 1, 1).getValue();
if (js.trim() == "") {
js = "0.0000";
}
zl = mygrid_recv.cellByIndex(rowCount - 1, 2).getValue();
if (zl.trim() == "") {
zl = "0.0000";
}
ys = mygrid_recv.cellByIndex(rowCount - 1, 3).getValue();
if (ys.trim() == "") {
ys = "0.00";
}
yf = mygrid_recv.cellByIndex(rowCount - 1, 4).getValue();
if (yf.trim() == "") {
yf = "0.00";
}
bz = mygrid_recv.cellByIndex(rowCount - 1, 5).getValue();
}
mygrid_recv.addRow(newId, [0, js, zl, ys, yf, bz], rowCount);
//mygrid_recv.addRow(newId, [0, "0.0000", "0.0000", "0.00", "0.00", ""], rowCount);
//
mygrid_recv.clearSelection();
mygrid_recv.editStop(true);
mygrid_recv.selectCell(mygrid_recv.getRowIndex(newId), 0, true, true);
mygrid_recv.editCell();
}
else {
var sdfsd= $("hid_associatedno").value;
mygrid_recv.loadXML("WmsLCLInfoGridSource.aspx?read=add&showcount=1&id=" + $("hdGID").value + "&associatedno=" + $("hid_associatedno").value + "&val=" + newGuid());
}
}
function deleteRecvRow() {
mygrid_recv.editStop();
//
var checked = $("hdGID").value;
if (checked != null && checked != "") {
var urlVal = "../SeaiInfoLCL/WmsLCLListGridSource.aspx?handle=getislock&gids=" + checked + "&associatedno=" + $("hid_associatedno").value + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var ls = loader.xmlDoc.responseText;
if (ls.trim() != "0") {
alert("有已入账的信息,不允许操作!");
return;
}
}
//
var selRowID = mygrid_recv.getCheckedRows(0); //所有选中的grid的id编号
var selGroup = new Array();
if (selRowID.indexOf(",") > 0) {
selGroup = selRowID.split(",");
}
else {
if (selRowID != null) {
selGroup.push(selRowID);
}
}
//查看是否有被选中的币别项
if (selGroup.length > 0) {
if (selGroup.length > 1) {
var delCount = 0;
if (window.confirm("您确定要删除吗?")) {
var dg = new dialog();
dg.html = "";
dg.width = 200;
dg.height = 100;
dg.title = "标题";
dg.show();
while (delCount < selGroup.length) {
var urlVal = "WmsLCLInfoGridSource.aspx?read=delete&gid=" + selGroup[delCount] + "&id=" + $("hdGID").value + "&associatedno=" + $("hid_associatedno").value + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
if (loadVal > 0) {
mygrid_recv.deleteRow(selGroup[delCount]);
}
else {
mygrid_recv.deleteSelectedRows();
}
delCount++;
}
dg.close();
}
}
else {
var delCount = 0;
while (delCount < selGroup.length) {
if (window.confirm("您确定要删除吗?")) {
var dg = new dialog();
dg.html = "";
dg.width = 200;
dg.height = 100;
dg.title = "标题";
dg.show();
var urlVal = "WmsLCLInfoGridSource.aspx?read=delete&gid=" + selGroup[delCount] + "&id=" + $("hdGID").value + "&associatedno=" + $("hid_associatedno").value + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
if (loadVal > 0) {
mygrid_recv.deleteRow(selGroup[delCount]);
dg.close();
//alert("删除成功");
}
else {
mygrid_recv.deleteSelectedRows();
dg.close();
}
}
delCount++;
}
}
}
else {
alert("未选中要操作的币别项");
}
}
function saveRecvChange() {
if ($("hd_comboCUSTOMERNAME").value.trim() == "") {
alert("客户名称不允许为空!");
return;
}
if ($("hd_comboTRUCKNAME").value.trim() == "") {
alert("应付客户不允许为空!");
return;
}
if ($("tbWMSDATE").value.trim() == "") {
alert("入库日期不允许为空!");
return;
}
// hd_comboCUSTOMERNAME
// hd_comboWMSOP
// hd_comboSTOREMAN
// tbWMSDATE
//
mygrid_recv.editStop();
jsonWmsInObj = "{\"$type\":\"DSWeb.Models.JsonWmsInGroupEntity3, DSWeb, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\",\"JsonWmsInEntities\":[";
column_count = mygrid_recv.getColumnsNum();
var tempJson = "";
var strError = "";
var isError = 0;
var rowCount = mygrid_recv.getRowsNum();
var jshj = 0.0000;
var slhj = 0.0000;
//
for (var i = 0; i < rowCount; i++) {
//获取RowID
tempJson = "";
var str78 = 0;
var rId = mygrid_recv.getRowId(i);
//判断是否出库
var urlVal = "WmsLCLInfoGridSource.aspx?read=isout&gids=" + rId + "&id=" + $("hdGID").value + "&associatedno=" + $("hid_associatedno").value + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
if (loadVal > 0) {
strError = "已经有相应出库记录的信息,将不不予以更改!";
continue;
}
else
{
isError=1;
}
//
tempJson += "\"$type\":\"DSWeb.Models.JsonWmsInEntity3, DSWeb, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\",";
tempJson += "\"WmsIn1\":\"" + rId + "\","; //gid
for (var j = 0; j < column_count-1; j++) {
var cell = mygrid_recv.cellById(rId, j+1);
var value = "";
//value = cell.cell.innerText; // .getValue();
value = cell.cell.textContent || cell.cell.innerText;
if (j == 0) {
var istr = IsNum(value);
if (!istr) {
alert("件数格式有误!");
return;
}
jshj = jshj + parseFloat(value);
}
if (j == 1) {
var istr = IsNum(value);
if (!istr) {
alert("计费重量格式有误!");
return;
}
slhj = slhj + parseFloat(value);
}
if (j == 2) {
var istr = IsNum(value);
if (!istr) {
alert("入库应收费用格式有误!");
return;
}
}
if (j == 3) {
var istr = IsNum(value);
if (!istr) {
alert("入库应付费用格式有误!");
return;
}
}
if (value.trim() == "") {
value = "null";
}
tempJson += "\"WmsIn" + (j + 2) + "\":\"" + value.trim() + "\"";
}
tempJson = "{" + tempJson + "}";
//
if (i == rowCount - 1) {
jsonWmsInObj = jsonWmsInObj + tempJson;
} else {
jsonWmsInObj = jsonWmsInObj + tempJson + ",";
}
}
//
// var bl = getGOODSPACK(jshj);
// if(!bl) {
// return;
// }
// //
// bl = getGOODSRKSL(slhj);
// if (!bl) {
// return;
// }
//
if (strError != "") {
alert(strError);
}
//
if (isError == 0) {
refreshRecv();
return;
}
jsonWmsInObj += "]}";
var txt_name = $("recvContainer");
txt_name.value = jsonWmsInObj;
saveRateChange();
//saveRecvChange_2();
msgBox();
setTimeout(postEnterWmsZXInfo, 200);
}
function doOnRowSelected(rowID, celInd) {
alert("Selected row ID is " + rowID + "\nUser clicked cell with index " + celInd);
}
function getValue() {
var colLabel = mygrid_recv.getColumnLabel(0);
alert(colLabel);
var colLabel2 = mygrid_recv.getColumnLabel(0, 1);
alert(colLabel2);
}
//post数据
function postEnterWmsZXInfo() {
var myForm = document.getElementById("form1");
myForm.submit();
}
function initGrid() {
doInitRecvGrid();
}
//放弃应收币别修改 重新加载页面
function recoverRecvChange() {
mygrid_recv.editStop();
var selRowID = mygrid_recv.getSelectedRowId();
//查看是否有被选中的币别项
if (selRowID != null) {
var rowIndex = mygrid_recv.getRowIndex(selRowID);
if (window.confirm("您确定放弃当前行的修改吗?")) {
var dg = new dialog();
dg.html = "";
dg.width = 200;
dg.height = 100;
dg.title = "标题";
dg.show();
var urlVal = "WmsLCLInfoGridSource.aspx?read=recover&id=" + $("hdGID").value + "&gid=" + selRowID + "&associatedno=" + $("hid_associatedno").value + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
if (!IsNum(loadVal)) {
var recvArg = new Array();
recvArg = loadVal.split(",");
var selRowIndex = mygrid_recv.getRowIndex(recvArg[0]);
var colCount = mygrid_recv.getColumnsNum();
for (var i = 0; i < colCount; i++) {
mygrid_recv.cellByIndex(selRowIndex, i).setValue(recvArg[i + 1]);
}
dg.close();
//alert("恢复成功");
//refreshRecv();//刷新
}
else {
if (parseInt(loadVal) == -3) {
mygrid_recv.deleteSelectedRows();
}
dg.close();
}
//ReShowLabel(mygrid_recv);
} else {
return;
}
} else {
alert("未选中要操作的币别项");
}
}
function print_recv() {
alert("正在打印");
}
function amountSum(gridName) {
if (gridName == "recv") {
//计算应收
mygrid_recv
} else {
//计算应付
}
}
function outputMoney(number) {
number = number.replace(/\,/g, "");
if (isNaN(number) || number == "") return "";
number = Math.round(number * 100) / 100;
if (number < 0)
return '-' + outputDollars(Math.floor(Math.abs(number) - 0) + '') + outputCents(Math.abs(number) - 0);
else
return outputDollars(Math.floor(number - 0) + '') + outputCents(number - 0);
}
function outputDollars(number) {
if (number.length <= 3)
return (number == '' ? '0' : number);
else {
var mod = number.length % 3;
var output = (mod == 0 ? '' : (number.substring(0, mod)));
for (i = 0; i < Math.floor(number.length / 3); i++) {
if ((mod == 0) && (i == 0))
output += number.substring(mod + 3 * i, mod + 3 * i + 3);
else
output += ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);
}
return (output);
}
}
function outputCents(amount) {
amount = Math.round(((amount) - Math.floor(amount)) * 100);
return (amount < 10 ? '.0' + amount : '.' + amount);
}
//获取GUID
function newGuid() {
var guid = "";
for (var i = 1; i <= 32; i++) {
var n = Math.floor(Math.random() * 16.0).toString(16);
guid += n;
if ((i == 8) || (i == 12) || (i == 16) || (i == 20))
guid += "-";
}
return guid.toUpperCase();
}
function dialog() {
this.width = 450;
this.height = 360;
this.title_height = 20;
this.html = '';
this.title = '';
var self = this;
var bgObj, msgObj, titleObj;
this.close = function () {
document.body.removeChild(document.getElementById("bgDiv"));
document.getElementById("msgDiv").removeChild(document.getElementById("msgTitle"));
document.body.removeChild(document.getElementById("msgDiv"));
}
this.show = function () {
var msgw, msgh, bordercolor;
msgw = self.width;
msgh = self.height;
bordercolor = "#336699";
titlecolor = "#99CCFF";
var sWidth, sHeight;
sWidth = document.body.offsetWidth;
sHeight = screen.height;
bgObj = document.createElement("div");
bgObj.setAttribute('id', 'bgDiv');
bgObj.style.position = "absolute";
bgObj.style.top = "0";
bgObj.style.background = "#777";
bgObj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
bgObj.style.opacity = "0.6";
bgObj.style.left = "0";
bgObj.style.width = sWidth + "px";
bgObj.style.height = sHeight + "px";
bgObj.style.zIndex = "10000";
document.body.appendChild(bgObj);
msgObj = document.createElement("div")
msgObj.setAttribute("id", "msgDiv");
msgObj.setAttribute("align", "center");
msgObj.style.background = "white";
msgObj.style.border = "1px solid " + bordercolor;
msgObj.style.position = "absolute";
msgObj.style.left = "50%";
msgObj.style.top = "30%";
msgObj.style.font = "12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
msgObj.style.marginLeft = "-225px";
msgObj.style.marginTop = -75 + document.documentElement.scrollTop + "px";
msgObj.style.width = msgw + "px";
msgObj.style.height = msgh + "px";
msgObj.style.textAlign = "center";
msgObj.style.lineHeight = "25px";
msgObj.style.zIndex = "10001";
titleObj = document.createElement("h4");
titleObj.setAttribute("id", "msgTitle");
titleObj.setAttribute("align", "center");
titleObj.style.margin = "0";
titleObj.style.padding = "3px";
titleObj.style.background = bordercolor;
titleObj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
titleObj.style.opacity = "0.75";
titleObj.style.border = "1px solid " + bordercolor;
titleObj.style.height = self.title_height + "px";
titleObj.style.font = "12px Verdana, Geneva, Arial, Helvetica, sans-serif";
titleObj.style.color = "white";
titleObj.style.cursor = "pointer";
titleObj.innerHTML = self.title;
//titleObj.onclick=function(){self.close();}
document.body.appendChild(msgObj);
document.getElementById("msgDiv").appendChild(titleObj);
var txt = document.createElement("div");
txt.style.margin = "1em 0"
txt.setAttribute("id", "msgTxt");
txt.innerHTML = self.html;
document.getElementById("msgDiv").appendChild(txt);
}
}
function msgBox() {
var dg = new dialog();
dg.html = "程序正在提交,请稍等!";
//dg.html+="";
dg.width = 200;
dg.height = 100;
dg.title = "标题";
dg.show();
}
//是否为数字
function IsNum(val) {
var re = /^[-\+]?\d+(\.\d+)?$/;
if (!re.test(val)) {
return false;
} else {
return true;
}
}
function ConvertToMoney(strObj) {
var result = strObj.replace(",", "");
return result;
}
function filterComboCustomerPress(gridObj, rowID, rowIndex, colIndex, filterVal, oldVal) {
var combo = gridObj.getCustomCombo(rowID, colIndex);
var comboArg = combo.getKeys();
var doCount = 0;
for (var i = 0; i < comboArg.length; i++) {
if (combo.get(comboArg[i]).toUpperCase().trim().indexOf(filterVal.toUpperCase()) == 0) {
alert(combo.get(comboArg[i]).toUpperCase().trim());
gridObj.cellByIndex(rowIndex, colIndex).setValue(combo.get(comboArg[i]));
gridObj.selectCell(rowIndex, colIndex, true, true, true, true);
doCount = 1;
break;
}
}
}
//两端去空格函数
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); }
//下拉框内容显示value的值
function ReShowLabel(gridObj) {
var columnCount = gridObj.getColumnsNum();
var rowCount = gridObj.getRowsNum();
if (rowCount > 0) {
for (var i = 0; i < rowCount; i++) {
for (var j = 0; j < columnCount; j++) {
// if (j == 3) {
// var cellCurVal = gridObj.cellByIndex(i, j).getValue();
// gridObj.cellByIndex(i, j).setLabel(cellCurVal);
// }
}
}
}
}
function clearNoNum(valObj) {
//先把非数字的都替换掉,除了数字和.
valObj = valObj.replace(/[^\d.]/g, "");
//必须保证第一个为数字而不是.
valObj = valObj.replace(/^\./g, "");
//保证只有出现一个.而没有多个.
valObj = valObj.replace(/\.{2,}/g, ".");
//保证.只出现一次,而不能出现两次以上
valObj = valObj.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
return valObj;
}
function markStatusColor(gridObj) {
var count = gridObj.getRowsNum();
for (var i = 0; i < count; i++) {
var status = gridObj.cellByIndex(i, 0).getValue();
var rowId = gridObj.getRowId(i);
}
}
//刷新应收
function refreshRecv() {
doInitRecvGrid();
}
//全选框
function checkall() {
var checkStatus = $("ck_all").checked;
if (checkStatus == 1) {
var iCount = mygrid_recv.getRowsNum();
for (var i = 0; i < iCount; i++) {
mygrid_recv.cellByIndex(i, 0).setValue(1);
}
}
else {
var iCount = mygrid_recv.getRowsNum();
for (var i = 0; i < iCount; i++) {
mygrid_recv.cellByIndex(i, 0).setValue(0);
}
}
}
//----------------------------------------------------------------------------------------------------------------------------------------
function getisvbm(rId) {
var urlVal3 = "WmsLCLInfoGridSource.aspx?read=isedit&gid=" + rId + "&associatedno=" + $("hid_associatedno").value + "&val=" + newGuid();
var loader3 = dhtmlxAjax.getSync(urlVal3);
var loadVal3 = loader3.xmlDoc.responseText;
if (loadVal3.trim() == "False") {
return false;
}
else {
return true;
}
}
var comboCUSTOMERNAME;
var comboSTORAGENAME; //仓库名称
var comboGOODSNAME; //货物类型
var comboTRUCKNAME;
function initComboCUSTOMERNAME()//委托单位
{
comboCUSTOMERNAME = dhtmlXComboFromSelect("ddlCUSTOMERNAME");
comboCUSTOMERNAME.loadXML("../FeeCodes/WebCrmClientAdapter.aspx?mask=0&pos=0&strIS=ISCONTROLLER");
}
function initComboCUSTOMERNAME2()//委托单位
{
if ($("hdEnabled").value == "false" || $("hdEnabled").value == "falses") {
comboCUSTOMERNAME.disable(true);
}
//
comboCUSTOMERNAME.setOptionWidth(200);
comboCUSTOMERNAME.attachEvent("onChange", function() {
comboCUSTOMERNAME.setComboText($("hd_comboCUSTOMERNAME").value);
});
comboCUSTOMERNAME.attachEvent("onBlur", function() {
var s1 = comboCUSTOMERNAME.getComboText().trim();
var s2 = s1.indexOf("|");
if (s1 == "") {
$("hd_comboCUSTOMERNAME").value = "";
comboCUSTOMERNAME.setComboText($("hd_comboCUSTOMERNAME").value);
}
else {
if (s2 > 0) {
s2 = s2 + 2;
}
var s3 = s1.substring(s2);
if (s2 > 0) {
comboCUSTOMERNAME.setComboText(s3);
$("hd_comboCUSTOMERNAME").value = s3;
}
else {
comboCUSTOMERNAME.setComboText($("hd_comboCUSTOMERNAME").value);
}
getFREESTORAGEPERIOD();
//
}
});
comboCUSTOMERNAME.setComboText($("hd_comboCUSTOMERNAME").value);
comboCUSTOMERNAME.attachEvent("onKeyPressed", function(keyCode) {
if (keyCode != "8") {
var arrayArg = new Array();
setTimeout(function() {
var filterCount = 0;
var is = -1;
var ishd = $("hd_comboCUSTOMERNAME").value.trim();
if ("" != comboCUSTOMERNAME.getComboText().trim()) {
while ("undefined" != typeof comboCUSTOMERNAME.getOptionByIndex(filterCount)) {
var comboValue = comboCUSTOMERNAME.getOptionByIndex(filterCount).text.toUpperCase(); //.value;
var enterValue = comboCUSTOMERNAME.getComboText().trim().toUpperCase();
$("hd_comboCUSTOMERNAME").value = comboCUSTOMERNAME.getComboText().trim().toUpperCase();
if (comboValue.indexOf(enterValue) == 0) {
comboCUSTOMERNAME.selectOption(filterCount, true, true);
is = filterCount;
break;
}
++filterCount;
}
if (is == -1) {
$("hd_comboCUSTOMERNAME").value = ishd;
alert("无此内容,请重新选择!");
}
}
}, 10);
}
});
comboCUSTOMERNAME.attachEvent("onSelectionChange", function() {
$("hd_comboCUSTOMERNAME").value = comboCUSTOMERNAME.getComboText().trim();
});
}
function initComboSTORAGENAME()//仓库名称
{
comboSTORAGENAME = dhtmlXComboFromSelect("ddlSTORAGENAME");
//comboSTORAGENAME.loadXML("../FeeCodes/WmsStorageAdapter.aspx?mask=0&pos=0");
comboSTORAGENAME.loadXML("../FeeCodes/WebCrmClientAdapter.aspx?mask=0&pos=0&strIS=ISWAREHOUSE");
}
function initComboSTORAGENAME2()//仓库名称
{
if ($("hdEnabled").value == "false" || $("hdEnabled").value == "falses") {
comboSTORAGENAME.disable(true);
}
//
comboSTORAGENAME.setOptionWidth(200);
comboSTORAGENAME.attachEvent("onChange", function () {
comboSTORAGENAME.setComboText($("hd_comboSTORAGENAME").value);
});
comboSTORAGENAME.attachEvent("onBlur", function () {
var s1 = comboSTORAGENAME.getComboText().trim();
var s2 = s1.indexOf("|");
if (s1 == "") {
$("hd_comboSTORAGENAME").value = "";
comboSTORAGENAME.setComboText($("hd_comboSTORAGENAME").value);
//
//$("hd_comboSTORAGECODE").value = "";
//
}
else {
if (s2 > 0) {
s2 = s2 + 2;
}
var s3 = s1.substring(s2);
if (s2 > 0) {
comboSTORAGENAME.setComboText(s3);
$("hd_comboSTORAGENAME").value = s3;
}
else {
comboSTORAGENAME.setComboText($("hd_comboSTORAGENAME").value);
}
if ($("hd_comboSTORAGENAME").value.trim() != "") {
comboTRUCKNAME.setComboText($("hd_comboSTORAGENAME").value);
$("hd_comboTRUCKNAME").value = $("hd_comboSTORAGENAME").value;
}
//
//$("hd_comboSTORAGECODE").value = comboSTORAGENAME.getSelectedValue();
//
}
});
comboSTORAGENAME.setComboText($("hd_comboSTORAGENAME").value);
comboSTORAGENAME.attachEvent("onKeyPressed", function (keyCode) {
if (keyCode != "8") {
var arrayArg = new Array();
setTimeout(function () {
var filterCount = 0;
var is = -1;
var ishd = $("hd_comboSTORAGENAME").value.trim();
if ("" != comboSTORAGENAME.getComboText().trim()) {
while ("undefined" != typeof comboSTORAGENAME.getOptionByIndex(filterCount)) {
var comboValue = comboSTORAGENAME.getOptionByIndex(filterCount).text.toUpperCase(); //.value;
var enterValue = comboSTORAGENAME.getComboText().trim().toUpperCase();
$("hd_comboSTORAGENAME").value = comboSTORAGENAME.getComboText().trim().toUpperCase();
if (comboValue.indexOf(enterValue) == 0) {
comboSTORAGENAME.selectOption(filterCount, true, true);
is = filterCount;
break;
}
++filterCount;
}
if (is == -1) {
$("hd_comboSTORAGENAME").value = ishd;
alert("无此内容,请重新选择!");
}
}
}, 10);
}
});
comboSTORAGENAME.attachEvent("onSelectionChange", function () {
$("hd_comboSTORAGENAME").value = comboSTORAGENAME.getComboText().trim();
});
}
function initComboTRUCKNAME()//应付账款客户名称
{
comboTRUCKNAME = dhtmlXComboFromSelect("ddlTRUCKNAME");
//comboTRUCKNAME.loadXML("../FeeCodes/WmsStorageAdapter.aspx?mask=0&pos=0");
comboTRUCKNAME.loadXML("../FeeCodes/WebCrmClientAdapter.aspx?mask=0&pos=0&strIS=ISWAREHOUSE&strIS2=ISTRUCK");
}
function initComboTRUCKNAME2()//应付账款客户名称
{
if ($("hdEnabled").value == "false" || $("hdEnabled").value == "falses") {
comboTRUCKNAME.disable(true);
}
//
comboTRUCKNAME.setOptionWidth(200);
comboTRUCKNAME.attachEvent("onChange", function () {
comboTRUCKNAME.setComboText($("hd_comboTRUCKNAME").value);
});
comboTRUCKNAME.attachEvent("onBlur", function () {
var s1 = comboTRUCKNAME.getComboText().trim();
var s2 = s1.indexOf("|");
if (s1 == "") {
$("hd_comboTRUCKNAME").value = "";
comboTRUCKNAME.setComboText($("hd_comboTRUCKNAME").value);
//
//$("hd_comboSTORAGECODE").value = "";
//
}
else {
if (s2 > 0) {
s2 = s2 + 2;
}
var s3 = s1.substring(s2);
if (s2 > 0) {
comboTRUCKNAME.setComboText(s3);
$("hd_comboTRUCKNAME").value = s3;
}
else {
comboTRUCKNAME.setComboText($("hd_comboTRUCKNAME").value);
}
//
//$("hd_comboSTORAGECODE").value = comboTRUCKNAME.getSelectedValue();
//
}
});
comboTRUCKNAME.setComboText($("hd_comboTRUCKNAME").value);
comboTRUCKNAME.attachEvent("onKeyPressed", function (keyCode) {
if (keyCode != "8") {
var arrayArg = new Array();
setTimeout(function () {
var filterCount = 0;
var is = -1;
var ishd = $("hd_comboTRUCKNAME").value.trim();
if ("" != comboTRUCKNAME.getComboText().trim()) {
while ("undefined" != typeof comboTRUCKNAME.getOptionByIndex(filterCount)) {
var comboValue = comboTRUCKNAME.getOptionByIndex(filterCount).text.toUpperCase(); //.value;
var enterValue = comboTRUCKNAME.getComboText().trim().toUpperCase();
$("hd_comboTRUCKNAME").value = comboTRUCKNAME.getComboText().trim().toUpperCase();
if (comboValue.indexOf(enterValue) == 0) {
comboTRUCKNAME.selectOption(filterCount, true, true);
is = filterCount;
break;
}
++filterCount;
}
if (is == -1) {
$("hd_comboTRUCKNAME").value = ishd;
alert("无此内容,请重新选择!");
}
}
}, 10);
}
});
comboTRUCKNAME.attachEvent("onSelectionChange", function () {
$("hd_comboTRUCKNAME").value = comboTRUCKNAME.getComboText().trim();
});
}
function initComboGOODSNAME()//货物描述类型
{
comboGOODSNAME = dhtmlXComboFromSelect("ddlGOODSNAME");
comboGOODSNAME.loadXML("../FeeCodes/TCodeGoodsAdapter.aspx?mask=0&pos=0");
}
function initComboGOODSNAME2()//货物描述类型
{
if ($("hdEnabled").value == "false" || $("hdEnabled").value == "falses") {
comboGOODSNAME.disable(true);
}
//
comboGOODSNAME.setOptionWidth(200);
comboGOODSNAME.attachEvent("onChange", function () { comboGOODSNAME.setComboText($("hd_comboGOODSNAME").value); });
comboGOODSNAME.attachEvent("onBlur", function () {
var s1 = comboGOODSNAME.getComboText().trim();
var s2 = s1.indexOf("|");
var selVal = "";
if (s1 == "") {
//$("hd_comboGOODSCODE").value = "";
$("hd_comboGOODSNAME").value = "";
comboGOODSNAME.setComboText($("hd_comboGOODSNAME").value);
}
else {
if (s2 > 0) {
s2 = s2 + 2;
}
var s3 = s1.substring(s2);
if (s2 > 0) {
comboGOODSNAME.setComboText(s3);
$("hd_comboGOODSNAME").value = s3;
}
else {
comboGOODSNAME.setComboText($("hd_comboGOODSNAME").value);
}
//
//$("hd_comboGOODSCODE").value = comboGOODSNAME.getSelectedValue();
getFREESTORAGEPERIOD();
}
});
comboGOODSNAME.setComboText($("hd_comboGOODSNAME").value);
comboGOODSNAME.attachEvent("onKeyPressed", function (keyCode) {
if (keyCode != "8") {
var arrayArg = new Array();
setTimeout(function () {
var is = -1;
var ishd = $("hd_comboGOODSNAME").value.trim();
var filterCount = 0;
if ("" != comboGOODSNAME.getComboText().trim()) {
while ("undefined" != typeof comboGOODSNAME.getOptionByIndex(filterCount)) {
var comboValue = comboGOODSNAME.getOptionByIndex(filterCount).text.toUpperCase(); //.value;
var enterValue = comboGOODSNAME.getComboText().trim().toUpperCase();
$("hd_comboGOODSNAME").value = comboGOODSNAME.getComboText().trim().toUpperCase();
if (comboValue.indexOf(enterValue) == 0) {
comboGOODSNAME.selectOption(filterCount, true, true);
is = filterCount;
break;
}
++filterCount;
}
if (is == -1) {
$("hd_comboGOODSNAME").value = ishd;
alert("无此内容,请重新选择!");
}
}
}, 10);
}
});
comboGOODSNAME.attachEvent("onSelectionChange", function () {
$("hd_comboGOODSNAME").value = comboGOODSNAME.getComboText().trim();
});
}
function getFREESTORAGEPERIOD()//获取免仓储期
{
var urlVal = "../FeeCodes/WmsInAdapter.aspx?handle=freestorageperiod&clientname=" + escape($("hd_comboCUSTOMERNAME").value.trim()) + "&goodsname=" + escape($("hd_comboGOODSNAME").value.trim()) + "&dodate=" + escape($("tbWMSDATE").value.trim()) + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
$("tbFREESTORAGEPERIOD").value = loadVal;
}
function getGOODSPACK(hj)//获取件数是否大于剩余件数(业务总件数-入库件数)
{
if (hj.toString().trim() != "" && hj.toString().trim() != "0") {
var fdf = $("hid_associatedno").value.trim();
var fff = $("tbBLNO").value.trim();
var fvf = $("hdGID").value.trim();
if ($("hid_associatedno").value.trim() != "" || $("tbBLNO").value.trim() != "") {
var urlVal = "../FeeCodes/WmsInAdapter.aspx?handle=goodspack&gid=" + $("hdGID").value.trim() + "&associatedno=" + $("hid_associatedno").value.trim() + "&blno=" + $("tbBLNO").value.trim() + "&goodspack=" + escape(hj.toString().trim()) + "&clientname=" + escape($("hd_comboCUSTOMERNAME").value.trim()) + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
if (loadVal.trim() != "") {
alert(loadVal);
return false;
}
}
}
return true;
}
function getGOODSRKSL(hj)//获取重量是否大于剩余重量(毛重-入库重量)
{
if (hj.toString().trim() != "" && hj.toString().trim() != "0") {
if ($("hid_associatedno").value.trim() != "" || $("tbBLNO").value.trim() != "") {
var urlVal = "../FeeCodes/WmsInAdapter.aspx?handle=goodsrksl&gid=" + $("hdGID").value.trim() + "&associatedno=" + $("hid_associatedno").value.trim() + "&blno=" + $("tbBLNO").value.trim() + "&goodsrksl=" + escape(hj.toString().trim()) + "&clientname=" + escape($("hd_comboCUSTOMERNAME").value.trim()) + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
if (loadVal.trim() != "") {
alert(loadVal);
return false;
}
}
}
return true;
}
//是否为数字,且数值格式是否正确
function IsNumFormat(val) {
var re = /^[-\+]?\d+(\.\d+)?$/;
if (!re.test(val)) {
return false;
}
else {
if (val.toString().indexOf(".") > 0) {
val.toString().replace("-", "");
val.toString().replace("+", "");
if (val.toString().substr(0, 1) == "0" && val.toString().substr(0, 2) != "0.") {
return false;
}
}
else {
var re1 = /^[-\+]+[1-9]+[0-9]*]*$/;
if (!re1.test(val)) {
re1 = /^[1-9]+[0-9]*]*$/;
if (!re1.test(val)) {
return false;
}
}
}
return true;
}
}
//是否为整数
function IsIntFormat(val) {
re1 = /^[1-9]+[0-9]*]*$/;
if (!re1.test(val)) {
return false;
}
return true;
}
//
function getIsNum(x) {
var str = x.value.trim();
if (str == "0") {
return;
}
else if (str == "") {
str = 0;
x.value = 0;
}
else {
var bl = IsNumFormat(str);
if (!bl) {
alert("数值格式错误!");
x.focus();
x.select();
}
}
}
function reloadParent(strBSNO, strHandle, strassociatedno) {
var parentObj = window.parent.location;
var oldUrl = parentObj.href;
var idIndex = oldUrl.indexOf("&id");
//
var newUrl = "";
if (strHandle == "add") {
var handleIndex = oldUrl.indexOf("handle=");
newUrl = oldUrl.substring(0, handleIndex);
window.parent.opener.location.href = window.parent.opener.location.href;
parentObj.href = newUrl + "handle=edit&id=" + strBSNO + "&associatedno=" + strassociatedno;
}
else if (strHandle == "addfull") {
var handleIndex = oldUrl.indexOf("handle=");
newUrl = oldUrl.substring(0, handleIndex);
window.parent.opener.location.href = window.parent.opener.location.href;
parentObj.href = newUrl + "handle=edit&id=" + strBSNO + "&associatedno=" + strassociatedno;
}
else if (strHandle == "edit") {
window.parent.opener.location.href = window.parent.opener.location.href;
}
else if (strHandle == "del") {
window.parent.opener.location.href = window.parent.opener.location.href;
parentObj.href = newUrl + strBSNO;
alert("操作成功!");
}
else if (strHandle == "adds") {
window.parent.opener.location.href = window.parent.opener.location.href;
}
//alert("成功提交!");
}
function printAction() {
var strBSNO = "";
strBSNO = $("hdGID").value;
var printUrl = "";
var companyID = "";
var typeName = "WmsInfoReport";
var dbSourceID = "";
var userID = "";
var url = "../Reports/ReportService.aspx?handle=printwmsinfo&bsno=" + strBSNO + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(url);
var reportVal = loader.xmlDoc.responseText;
var reportObj = null;
if (reportVal != "") {
reportObj = eval('(' + reportVal + ')');
if (reportObj.reports.length > 0) {
if (reportObj.reports[0].compid != "") {
companyID = reportObj.reports[0].compid;
}
if (reportObj.reports[0].sourceid != "") {
dbSourceID = reportObj.reports[0].sourceid;
}
if (reportObj.reports[0].compid != "") {
userID = reportObj.reports[0].userid;
}
printUrl = "print://?comp=" + companyID + "&type=" + typeName + "&dbid=" + dbSourceID + "&uid=" + userID; //alert(printUrl);
window.location.href = window.location.href;
location.href = printUrl;
var dfg = "";
}
} else {
alert("没有要打印的报表");
return;
}
}
function setislock() {
var checked = $("hdGID").value;
if (checked != null && checked != "") {
var urlVal = "../SeaiInfoLCL/WmsLCLListGridSource.aspx?handle=getislock&gids=" + checked + "&associatedno=" + $("hid_associatedno").value + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var ls = loader.xmlDoc.responseText;
if (ls.trim() != "0") {
alert("已入账的信息,不允许操作!");
return;
}
//
if (confirm('费用确定入账吗?(入账后将不允许修改删除数据!)')) {
var urlVal = "WmsLCLListGridSource.aspx?handle=islock&gids=" + checked + "&associatedno=" + $("hid_associatedno").value + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var strDel = loader.xmlDoc.responseText;
if (strDel.trim() != "") {
alert(strDel);
}
//
var parentObj = window.parent.location;
var oldUrl = parentObj.href;
var newUrl = oldUrl + "&isenabled=false";
parentObj.href = newUrl;
window.parent.opener.location.href = window.parent.opener.location.href;
}
}
else {
alert('未选中要操作的数据!');
return;
}
}
function setnotlock() {
var checked = $("hdGID").value;
if (checked != null && checked != "") {
var urlVal = "../SeaiInfoLCL/WmsLCLListGridSource.aspx?handle=getislock&gids=" + checked + "&associatedno=" + $("hid_associatedno").value + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var ls = loader.xmlDoc.responseText;
if (ls.trim() == "0") {
alert("未入账的信息,不允许操作!");
return;
}
//
if (confirm('确定取消入账吗?(只有“未做出库、未申请开票、未开发票、未对帐”的入账数据允许取消!)')) {
var urlVal = "WmsLCLListGridSource.aspx?handle=notlock&gids=" + checked + "&associatedno=" + $("hid_associatedno").value + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var strDel = loader.xmlDoc.responseText;
if (strDel.trim() != "") {
alert(strDel);
}
//
var parentObj = window.parent.location;
var oldUrl = parentObj.href;
var newUrl = oldUrl.replace("&isenabled=false", "");
parentObj.href = newUrl;
window.parent.opener.location.href = window.parent.opener.location.href;
}
}
else {
alert('未选中要操作的数据!');
return;
}
}