You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

963 lines
38 KiB
JavaScript

var mygrid_recv_2;
var page_count = 5;
var column_count;
var jsonWmsZXInfoObj;
var changeCount = 0;
//两端去空格函数
String.prototype.trim = function () { return this.replace(/(^\s*)|(\s*$)/g, ""); }
function $(id) {
return document.getElementById(id);
}
function initWinScreen2() {
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_2").style.height = "580px";
}
else if (winScreenWidth >= 1366 && winScreenWidth >= 768) {
document.getElementById("mygrid_recv_2").style.height = "340px";
}
else if (winScreenWidth >= 1024 && winScreenWidth >= 768) {
document.getElementById("mygrid_recv_2").style.height = "300px";
}
}
function doInitRecvGrid2() {
mygrid_recv_2 = new dhtmlXGridObject('mygrid_recv_2');
mygrid_recv_2.setImagePath("../images/");
mygrid_recv_2.setSkin("xp");
// 0 1 2 3 4 5 6 7 8 9 10 11 12
//mygrid_recv_2.setHeader("<input type=\"checkbox\" id=\"ck_all\" onclick=\"checkall2()\" />,箱型,箱号,封号,件数,重量,实际件数,实际重量,应计费用,应付费用,备注,剩余件数,库存量");
// 0 1 2 3 4 5 6 7 8 9 10 11 12
mygrid_recv_2.setHeader("<input type=\"checkbox\" id=\"ck_all\" onclick=\"checkall2()\" />,计费等级,费用类别,计费区间,单位,单价,增值价,封顶价,结束计费日期,备注,创建人,创建时间,委托单号");
mygrid_recv_2.setInitWidths("30,80,80,80,80,80,80,80,120,187,80,120,0");
mygrid_recv_2.setColAlign("center,center,center,center,center,center,center,center,center,center,center,center,center");
mygrid_recv_2.setColSorting("na,str,str,str,str,str,str,str,str,str,str,str,str");
mygrid_recv_2.setColTypes("ch,ro,co,ed,co,ed,ed,ed,ed,ed,ro,ro,ro");
// mygrid_recv_2.setColSorting("na,str,str,str,str,str,str,date,str,str,str,str");
// mygrid_recv_2.setColTypes("ch,co,ed,ed,ed,ed,co,calendar,ed,ro,ro,ro");
var urlVal = "../SeaiInfo/WmsRateGridSource.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_2.loadXML("../SeaiInfo/WmsRateGridSource.aspx?read=init&showcount=1&id=" + $("hdGID").value + "&associatedno=" + $("hid_associatedno").value + "&val=" + newGuid());
setTimeout(function() {
//ReShowLabel2(mygrid_recv_2);
}, 200);
}
mygrid_recv_2.init();
mygrid_recv_2.enableEditEvents(true, false, true);
mygrid_recv_2.enableMultiselect(true);
mygrid_recv_2.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控件编辑事件,由于免费控件没有提供完整的编辑判断功能,现特此做更改
mygrid_recv_2.attachEvent("onEditCell", function (stage, rId, cInd, nValue, oValue) {
var newCheckValue = false;
//初始化状态
if (stage == 0) {
var selectedId = mygrid_recv_2.getSelectedRowId();
var rowIndex = mygrid_recv_2.getRowIndex(selectedId);
var oldVal = mygrid_recv_2.cellByIndex(rowIndex, 0).getValue().trim();
return true;
}
if (stage == 1) {
// 1 2 3 4 5 6 7 8 9 10 11
//计费等级,费用类别,计费区间,单价,增值价,单位,结束计费日期,备注,创建人,创建时间,委托单号
var rowIndex = mygrid_recv_2.getRowIndex(rId);
var txtEdit;
for (i = 0; i < document.all.length; i++) {
if (document.all(i).tagName == "TEXTAREA") {
txtEdit = document.all(i);
//
if (cInd == 8) {
var sFEETYPE = mygrid_recv_2.cellByIndex(rowIndex, 2).getValue();
if (txtEdit.value.toString().trim() == "") {
var sdate;
if (rowIndex == 0) {
if (sFEETYPE.trim() == "收" || sFEETYPE.trim() == "1") {
sdate = $("tbSTARTBILLINGDATE").value.trim();
}
else {
sdate = $("tbSTARTBILLINGDATEAP").value.trim();
}
}
else {
var k = 0;
if (sFEETYPE.trim() == "收" || sFEETYPE.trim() == "1") {
sdate = $("tbSTARTBILLINGDATE").value.trim();
for (var n = 0; n <= rowIndex; n++) {
var sFEETYPE2 = mygrid_recv_2.cellByIndex(n, 2).getValue();
var sdate2 = mygrid_recv_2.cellByIndex(n, cInd).getValue();
if ((sFEETYPE2.trim() == "收" || sFEETYPE2.trim() == "1") && n != rowIndex) {
sdate = sdate2;
k++;
}
}
}
else {
sdate = $("tbSTARTBILLINGDATEAP").value.trim();
for (var n = 0; n <= rowIndex; n++) {
var sFEETYPE2 = mygrid_recv_2.cellByIndex(n, 2).getValue();
var sdate2 = mygrid_recv_2.cellByIndex(n, cInd).getValue();
if ((sFEETYPE2.trim() == "付" || sFEETYPE2.trim() == "2") && n != rowIndex) {
sdate = sdate2;
k++;
}
}
}
if (k > 0) {
//sdate = mygrid_recv_2.cellByIndex(rowIndex - 1, cInd).getValue();
var myDate = new Date(Date.parse(sdate.replace("-", "/")));
myDate.setDate(myDate.getDate() + 1);
var year = myDate.getFullYear(); //获取完整的年份(4位,1970)
var moonth = myDate.getMonth(); //获取当前月份(0-11,0代表1月)
var days = myDate.getDate(); //获取当前日(1-31)
var ert = curDateTime(year + "-" + (moonth + 1) + "-" + days);
sdate = ert.toString();
}
}
//
if (sdate.trim() != "") {
var s3 = mygrid_recv_2.cellByIndex(rowIndex, 3).getValue();
var s4 = mygrid_recv_2.cellByIndex(rowIndex, 4).getValue();
//
if (s4.indexOf("月") > -1) {
var myDate = new Date(Date.parse(sdate.replace("-", "/")));
myDate.setMonth(myDate.getMonth() + parseInt(s3.trim()));
myDate.setDate(myDate.getDate() - 1);
var year = myDate.getFullYear(); //获取完整的年份(4位,1970)
var moonth = myDate.getMonth(); //获取当前月份(0-11,0代表1月)
var days = myDate.getDate(); //获取当前日(1-31)
var ert = curDateTime(year + "-" + (moonth + 1) + "-" + days);
var isint = CheckDate(ert);
if (isint) {
txtEdit.value = ert;
}
}
else if (s4.indexOf("天") > -1) {
var myDate = new Date(Date.parse(sdate.replace("-", "/")));
myDate.setDate(myDate.getDate() + parseInt(s3.trim()) - 1);
var year = myDate.getFullYear(); //获取完整的年份(4位,1970)
var moonth = myDate.getMonth(); //获取当前月份(0-11,0代表1月)
var days = myDate.getDate(); //获取当前日(1-31)
var ert = curDateTime(year + "-" + (moonth + 1) + "-" + days);
var isint = CheckDate(ert);
if (isint) {
txtEdit.value = ert;
}
}
}
}
}
//
txtEdit.focus();
txtEdit.select();
break;
}
}
}
//如果编辑结束
if (stage == 2) {
//获取当前RowID
var selectedId = mygrid_recv_2.getSelectedRowId();
//获取当前RowIndex
var rowIndex = mygrid_recv_2.getRowIndex(selectedId);
//获取当前CellIndex(ind)
var ind = mygrid_recv_2.getSelectedCellIndex();
//触发操作事件前获取单元值
var oldVal = mygrid_recv_2.cellByIndex(rowIndex, ind).getValue();
// 1 2 3 4 5 6 7 8 9 10 11
//计费等级,费用类别,计费区间,单价,增值价,单位,结束计费日期,备注,创建人,创建时间,委托单号
if (cInd == 3) {
var cellVal = mygrid_recv_2.cellByIndex(rowIndex, cInd).getValue();
if (cellVal.trim() != "") {
var isint = parseInt(cellVal);
if (isint.toString().trim() == "NaN") {
mygrid_recv_2.cellByIndex(rowIndex, cInd).setLabel("");
//alert("入库应计费用格式有误!");
return true;
}
else if (isint == 0) {
mygrid_recv_2.cellByIndex(rowIndex, cInd).setLabel("");
//alert("入库应计费用格式有误!");
return true;
}
else {
mygrid_recv_2.cellByIndex(rowIndex, cInd).setLabel(isint);
return true;
}
}
return true;
}
else if (cInd == 5 || cInd == 6) {
var cellVal = mygrid_recv_2.cellByIndex(rowIndex, cInd).getValue();
if (cellVal.trim() != "") {
var isint = IsNum(cellVal);
if (!isint) {
mygrid_recv_2.cellByIndex(rowIndex, cInd).setLabel("0.00");
//alert("入库应付费用格式有误!");
return true;
}
}
return true;
}
else if (cInd == 7) {
var cellVal = mygrid_recv_2.cellByIndex(rowIndex, cInd).getValue();
if (cellVal.trim() != "") {
var isint = IsNum(cellVal);
if (!isint) {
mygrid_recv_2.cellByIndex(rowIndex, cInd).setLabel("0.00");
//alert("入库应付费用格式有误!");
return true;
}
}
else {
cellVal = 0;
}
//
var cellVal5 = mygrid_recv_2.cellByIndex(rowIndex, 5).getValue();
if (cellVal5.trim() != "") {
var isint = IsNum(cellVal);
if (!isint) {
cellVal5 = 0;
}
}
//
if (cellVal < cellVal5) {
mygrid_recv_2.cellByIndex(rowIndex, cInd).setLabel("0.00");
return true;
}
return true;
}
else if (cInd == 8) {
var cellVal = mygrid_recv_2.cellByIndex(rowIndex, cInd).getValue();
//日期完整检查
if (cellVal.trim() != "") {
var isint = CheckDate(cellVal);
if (!isint) {
mygrid_recv_2.cellByIndex(rowIndex, cInd).setLabel("");
alert("日期格式有误!");
return true;
}
//
var sdate;
var sFEETYPE = mygrid_recv_2.cellByIndex(rowIndex, 2).getValue();
if (rowIndex == 0) {
if (sFEETYPE.trim() == "收" || sFEETYPE.trim() == "1") {
sdate = $("tbSTARTBILLINGDATE").value.trim();
}
else {
sdate = $("tbSTARTBILLINGDATEAP").value.trim();
}
}
else {
var k = 0;
if (sFEETYPE.trim() == "收" || sFEETYPE.trim() == "1") {
sdate = $("tbSTARTBILLINGDATE").value.trim();
for (var n = 0; n <= rowIndex; n++) {
var sFEETYPE2 = mygrid_recv_2.cellByIndex(n, 2).getValue();
var sdate2 = mygrid_recv_2.cellByIndex(n, cInd).getValue();
if ((sFEETYPE2.trim() == "收" || sFEETYPE2.trim() == "1") && n != rowIndex) {
sdate = sdate2;
k++;
}
}
}
else {
sdate = $("tbSTARTBILLINGDATEAP").value.trim();
for (var n = 0; n <= rowIndex; n++) {
var sFEETYPE2 = mygrid_recv_2.cellByIndex(n, 2).getValue();
var sdate2 = mygrid_recv_2.cellByIndex(n, cInd).getValue();
if ((sFEETYPE2.trim() == "付" || sFEETYPE2.trim() == "2") && n != rowIndex) {
sdate = sdate2;
k++;
}
}
}
if (k > 0) {
//sdate = mygrid_recv_2.cellByIndex(rowIndex - 1, cInd).getValue();
var myDate = new Date(Date.parse(sdate.replace("-", "/")));
myDate.setDate(myDate.getDate() + 1);
var year = myDate.getFullYear(); //获取完整的年份(4位,1970)
var moonth = myDate.getMonth(); //获取当前月份(0-11,0代表1月)
var days = myDate.getDate(); //获取当前日(1-31)
var ert = curDateTime(year + "-" + (moonth + 1) + "-" + days);
var isint = CheckDate(ert);
if (isint) {
sdate = ert;
}
}
}
//
if (sdate.trim() != "") {
var s3 = mygrid_recv_2.cellByIndex(rowIndex, 3).getValue();
var s4 = mygrid_recv_2.cellByIndex(rowIndex, 4).getValue();
//
if (s4.indexOf("月") > -1) {
var myDate = new Date(Date.parse(sdate.replace("-", "/")));
myDate.setMonth(myDate.getMonth() + parseInt(s3.trim()));
myDate.setDate(myDate.getDate() - 1);
var year = myDate.getFullYear(); //获取完整的年份(4位,1970)
var moonth = myDate.getMonth(); //获取当前月份(0-11,0代表1月)
var days = myDate.getDate(); //获取当前日(1-31)
var ert = curDateTime(year + "-" + (moonth + 1) + "-" + days);
var isint = CheckDate(ert);
if (isint) {
sdate = ert;
}
}
else if (s4.indexOf("天") > -1) {
var myDate = new Date(Date.parse(sdate.replace("-", "/")));
myDate.setDate(myDate.getDate() + parseInt(s3.trim()) - 1);
var year = myDate.getFullYear(); //获取完整的年份(4位,1970)
var moonth = myDate.getMonth(); //获取当前月份(0-11,0代表1月)
var days = myDate.getDate(); //获取当前日(1-31)
var ert = curDateTime(year + "-" + (moonth + 1) + "-" + days);
var isint = CheckDate(ert);
if (isint) {
sdate = ert;
}
}
}
//
if (cellVal < sdate) {
mygrid_recv_2.cellByIndex(rowIndex, cInd).setLabel(sdate);
alert("日期不能小于" + sdate + "");
return true;
}
}
return true;
}
else {
return true;
}
}
});
//键盘操作事件
mygrid_recv_2.attachEvent("onKeyPress", function (code, cFlag, sFlag) {
// if ($("hdEnabled").value.trim() == "false") {
// return false;
// }
//
//onKeyPress begin
//获取当前RowID
var selectedId = mygrid_recv_2.getSelectedRowId();
//获取当前RowIndex
var rowIndex = mygrid_recv_2.getRowIndex(selectedId);
//获取当前CellIndex(ind)
var ind = mygrid_recv_2.getSelectedCellIndex();
//触发操作事件前获取单元值
var oldVal = mygrid_recv_2.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_2.getColumnsNum();
var rowCount = mygrid_recv_2.getRowsNum();
if (ind == 3) {
var cellVal = mygrid_recv_2.cellByIndex(rowIndex, ind).getValue();
if (cellVal.trim() != "") {
var isint = parseInt(cellVal);
if (isint.toString().trim() == "NaN") {
mygrid_recv_2.cellByIndex(rowIndex, ind).setLabel("");
//alert("入库应计费用格式有误!");
return true;
}
else if (isint == 0) {
mygrid_recv_2.cellByIndex(rowIndex, ind).setLabel("");
//alert("入库应计费用格式有误!");
return true;
}
else {
//mygrid_recv_2.cellByIndex(rowIndex, ind).setLabel(isint);
}
}
}
else if (ind == 5 || ind == 6) {
var cellVal = mygrid_recv_2.cellByIndex(rowIndex, ind).getValue();
if (cellVal.trim() != "") {
var isint = IsNum(cellVal);
if (!isint) {
mygrid_recv_2.cellByIndex(rowIndex, ind).setLabel("0.00");
//alert("计费重量格式有误!");
return true;
}
}
}
else if (ind == 7) {
var cellVal = mygrid_recv_2.cellByIndex(rowIndex, ind).getValue();
if (cellVal.trim() != "") {
var isint = IsNum(cellVal);
if (!isint) {
mygrid_recv_2.cellByIndex(rowIndex, ind).setLabel("0.00");
//alert("计费重量格式有误!");
return true;
}
}
else {
cellVal = 0;
}
//
var cellVal5 = mygrid_recv_2.cellByIndex(rowIndex, 5).getValue();
if (cellVal5.trim() != "") {
var isint = IsNum(cellVal);
if (!isint) {
cellVal5 = 0;
}
}
//
if (cellVal < cellVal5) {
mygrid_recv_2.cellByIndex(rowIndex, ind).setLabel("0.00");
return true;
}
}
else if (ind == 8) {
var cellVal = mygrid_recv_2.cellByIndex(rowIndex, ind).getValue();
if (cellVal.trim() != "") {
//日期完整检查
var isint = CheckDate(cellVal);
if (!isint) {
mygrid_recv_2.cellByIndex(rowIndex, ind).setLabel("");
//alert("日期格式有误!");
return true;
}
}
return true;
}
if (ind < colCount) {
isExchange = false;
pressRecord = "";
pressRowIndex = -1;
pressCellIndex = -1;
var cInd = ind;
var rId = selectedId;
mygrid_recv_2.selectCell(rowIndex, ind + 1, true, true);
mygrid_recv_2.editCell();
if (ind == colCount - 1) {
if (rowIndex < rowCount) {
mygrid_recv_2.editStop(true);
mygrid_recv_2.clearSelection();
mygrid_recv_2.selectCell(rowIndex + 1, 2, true, true);
mygrid_recv_2.editCell();
}
else {
return;
}
}
else {
return;
}
}
}
else if (code >= 65 && code <= 90) {//如果是输入英文字符
if (ind == 8) {
return true;
}
}
else if (code == 8)//delete
{
return true;
}
else if (code == 40)//向下方向键
{
if (ind == 2 || ind == 4) {
return true;
}
var rowCount = mygrid_recv_2.getRowsNum();
mygrid_recv_2.clearSelection();
mygrid_recv_2.editStop();
if (rowIndex == (rowCount - 1)) {
addRecvRow2();
}
else {
mygrid_recv_2.selectCell(rowIndex + 1, 2, true, true);
mygrid_recv_2.editCell();
}
}
else if (code == 38)//向上箭头
{
if (ind == 2 || ind == 4) {
return true;
}
if (rowIndex > 0) {
mygrid_recv_2.clearSelection();
mygrid_recv_2.editStop();
mygrid_recv_2.selectCell(rowIndex - 1, 2, true, true);
mygrid_recv_2.editCell();
}
}
else {
return true;
}
});
setTimeout(function() {
markStatusColor2(mygrid_recv_2);
}, 400);
}
//讲下拉列表Combo所有生成Array数组
function setComboByArray2(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 addRecvRow2() {
if (mygrid_recv_2.getRowsNum() > 0) {
var newId = newGuid();
//获取插入新纪录位置
var rowCount = mygrid_recv_2.getRowsNum();
// 0 1 2 3 4 5 6 7 8 9 10 11
//mygrid_recv_2.setHeader("<input type=\"checkbox\" id=\"ck_all\" onclick=\"checkall2()\" />,费用等级,费用类别,计费区间,单价,增值价,单位,结束计费日期,备注,创建人,创建时间,委托单号");
//
var fylb = "收";
var dw = "吨天";
if (rowCount > 0) {
fylb = mygrid_recv_2.cellByIndex(rowCount - 1, 2).getValue();
if (fylb == 1) {
fylb = "收"; //费用类别
}
else if (fylb == 2) {
fylb = "付"; //费用类别
}
dw = mygrid_recv_2.cellByIndex(rowCount - 1, 4).getValue();
}
mygrid_recv_2.addRow(newId, [0, rowCount + 1, fylb, "", dw, "0.00", "0.00", "0.00", "", "", "", "", ""], rowCount);
//
mygrid_recv_2.clearSelection();
var rId = mygrid_recv_2.getRowId(rowCount - 1);
var combo_customer;
combo_customer = mygrid_recv_2.getCustomCombo(rId, 2);
setComboByArray2(mygrid_recv_2, combo_customer, newId, 2);
combo_customer = mygrid_recv_2.getCustomCombo(rId, 4);
setComboByArray2(mygrid_recv_2, combo_customer, newId, 4);
//
mygrid_recv_2.editStop(true);
mygrid_recv_2.selectCell(mygrid_recv_2.getRowIndex(newId), 2, true, true);
mygrid_recv_2.editCell();
}
else
{
var sdfsd= $("hid_associatedno").value;
mygrid_recv_2.loadXML("../SeaiInfo/WmsRateGridSource.aspx?read=add&showcount=1&id=" + $("hdGID").value + "&associatedno=" + $("hid_associatedno").value + "&val=" + newGuid());
}
}
function deleteRecvRow2() {
mygrid_recv_2.editStop();
//
var selRowID = mygrid_recv_2.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 (window.confirm("您确定要将所选的删除吗?")) {
var dg = new dialog();
dg.html = "<img src=\"../images/icon/progress.gif\" />";
dg.width = 200;
dg.height = 100;
dg.title = "标题";
dg.show();
for (var i = 0; i < selGroup.length; i++)
{
var rowIndex = mygrid_recv_2.getRowIndex(selGroup[i]);
var cusName = mygrid_recv_2.cellByIndex(rowIndex, 1).getValue();
var urlVal = "../SeaiInfo/WmsRateGridSource.aspx?read=delete&gid=" + selGroup[i] + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
if (loadVal > 0) {
mygrid_recv_2.deleteRow(selGroup[i]);
}
else {
mygrid_recv_2.deleteSelectedRows();
}
}
dg.close();
}
}
else {
alert("未选中要操作的币别项");
}
}
function saveRecvChange2() {
var BSNO = "";
BSNO = $("hdGID").value.trim();
// if (BSNO == "") {
// alert("请先保存入库信息!");
// return;
// }
//
var cus = "";
if ($("hd_comboCUSTOMERNAME").value != null) {
cus = $("hd_comboCUSTOMERNAME").value;
}
if (cus == "") {
alert("委托单位不能为空");
return -1;
}
//
var cus2 = "";
if ($("hd_comboSTORAGENAME").value != null) {
cus2 = $("hd_comboSTORAGENAME").value;
}
//
mygrid_recv_2.editStop();
var jsonRateObj = null;
for (var i = 0; i < mygrid_recv_2.getRowsNum(); i++) {
var rowId = mygrid_recv_2.getRowId(i);
//var FEEGRADE = mygrid_recv_2.cellByIndex(i, 1).getValue(); //计费等级
var FEEGRADE = i+1; //计费等级
var FEETYPE = mygrid_recv_2.cellByIndex(i, 2).getValue(); //费用类别
if (FEETYPE == "收") {
FEETYPE = 1; //费用类别
}
else if (FEETYPE == "付") {
FEETYPE = 2; //费用类别
}
var FEESCALE = mygrid_recv_2.cellByIndex(i, 3).getValue(); //计费区间
var FEEUNIT = mygrid_recv_2.cellByIndex(i, 4).getValue(); //计费单位
var FEEPRICE = mygrid_recv_2.cellByIndex(i, 5).getValue(); //计费单价
var ADDPRICE = mygrid_recv_2.cellByIndex(i, 6).getValue(); //增值价
var CAPPRICE = mygrid_recv_2.cellByIndex(i, 7).getValue(); //封顶价
var ENDBILLINGDATE = mygrid_recv_2.cellByIndex(i, 8).getValue(); //结束计费日期
var REMARK = mygrid_recv_2.cellByIndex(i, 9).getValue(); //备注
if (FEEUNIT.trim() == "") {
$("recvContainer_2").value = "";
alert("费用类别不能为空");
return -1;
}
if (i == 0 && FEEPRICE == "") {
FEEPRICE = 0;
}
if (parseInt(FEESCALE) == 0) {
$("recvContainer_2").value = "";
alert("计费区间不能为零");
return -1;
}
if (i != 0 && parseFloat(FEEPRICE) == 0) {
$("recvContainer_2").value = "";
alert("单价不能为零");
return -1;
}
// if (i != 0 && parseFloat(ADDPRICE) == 0) {
// $("recvContainer_2").value = "";
// alert("增值价不能为零");
// return -1;
// }
if (FEEUNIT.trim() == "") {
$("recvContainer_2").value = "";
alert("计费单位不能为空");
return -1;
}
if (ENDBILLINGDATE.trim() == "") {
$("recvContainer_2").value = "";
alert("结束计费日期不能为空");
return -1;
}
//
if (jsonRateObj == null) {
var cacheBuffer = "";
cacheBuffer += "{";
cacheBuffer += "\"id\":\"" + rowId + "\",";
if (FEETYPE == 2) {
cacheBuffer += "\"cus\":\"" + cus2 + "\",";
}
else {
cacheBuffer += "\"cus\":\"" + cus + "\",";
}
cacheBuffer += "\"bsno\":\"" + BSNO + "\",";
cacheBuffer += "\"feetype\":\"" + FEETYPE + "\",";
cacheBuffer += "\"fgrade\":\"" + FEEGRADE + "\",";
cacheBuffer += "\"fscale\":\"" + FEESCALE + "\",";
cacheBuffer += "\"funit\":\"" + FEEUNIT + "\",";
cacheBuffer += "\"fprice\":\"" + FEEPRICE + "\",";
cacheBuffer += "\"addprice\":\"" + ADDPRICE + "\",";
cacheBuffer += "\"capprice\":\"" + CAPPRICE + "\",";
cacheBuffer += "\"endbillingdate\":\"" + ENDBILLINGDATE + "\",";
cacheBuffer += "\"remark\":\"" + REMARK + "\"";
cacheBuffer += "}";
var result = "";
result += "{\"rates\":[";
result += cacheBuffer;
result += "]}";
jsonRateObj = eval('(' + result + ')');
} else {
var newRateRow = jsonRateObj.rates;
newRateRow = { id: rowId, cus: cus, bsno: BSNO, feetype: FEETYPE, fgrade: FEEGRADE, fscale: FEESCALE, funit: FEEUNIT, fprice: FEEPRICE, addprice: ADDPRICE, capprice: CAPPRICE, endbillingdate: ENDBILLINGDATE, remark: REMARK };
jsonRateObj.rates.push(newRateRow);
}
}
$("recvContainer_2").value = JSON.stringify(jsonRateObj);
return 1;
}
function saveRecvChange3() {
$("recvContainer").value = "";
var fhz = saveRecvChange2();
if (fhz > -1) {
msgBox();
setTimeout(postEnter, 200);
}
}
//post数据
function postEnter() {
var myForm = document.getElementById("form1");
myForm.submit();
}
function initGrid2() {
doInitRecvGrid2();
}
//放弃应收币别修改 重新加载页面
function recoverRecvChange2() {
mygrid_recv_2.editStop();
var selRowID = mygrid_recv_2.getSelectedRowId();
//查看是否有被选中的项
if (selRowID != null) {
var rowIndex = mygrid_recv_2.getRowIndex(selRowID);
var status = mygrid_recv_2.cellByIndex(rowIndex, 0).getValue();
var cusName = mygrid_recv_2.cellByIndex(rowIndex, 1).getValue();
if (window.confirm("您确定放弃当前行的修改吗?")) {
var dg = new dialog();
dg.html = "<img src=\"../../images/icon/progress.gif\" />";
dg.width = 200;
dg.height = 100;
dg.title = "标题";
dg.show();
var urlVal = "../SeaiInfo/WmsRateGridSource.aspx?read=recovergid=" + selRowID + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
//if (!IsNum(loadVal)) {
if (loadVal > 0) {
var recvArg = new Array();
recvArg = loadVal.split(",");
var selRowIndex = mygrid_recv_2.getRowIndex(recvArg[0]);
var colCount = mygrid_recv_2.getColumnsNum();
for (var i = 0; i < colCount; i++) {
mygrid_recv_2.cellByIndex(selRowIndex, i).setValue(recvArg[i + 1]);
}
dg.close();
//alert("恢复成功");
//refreshRecv2();//刷新
}
else {
if (parseInt(loadVal) == -3) {
mygrid_recv_2.deleteSelectedRows();
}
dg.close();
}
//ReShowLabel2(mygrid_recv_2);
} else {
return;
}
} else {
alert("未选中要操作的币别项");
}
}
//下拉框内容显示value的值
function ReShowLabel2(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 markStatusColor2(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 refreshRecv2() {
doInitRecvGrid2();
}
//全选框
function checkall2() {
var checkStatus = $("ck_all").checked;
if (checkStatus == 1) {
var iCount = mygrid_recv_2.getRowsNum();
for (var i = 0; i < iCount; i++) {
mygrid_recv_2.cellByIndex(i, 0).setValue(1);
}
}
else {
var iCount = mygrid_recv_2.getRowsNum();
for (var i = 0; i < iCount; i++) {
mygrid_recv_2.cellByIndex(i, 0).setValue(0);
}
}
}
//获取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 clearNoNum2(valObj) {
//先把非数字的都替换掉,除了数字和.
valObj = valObj.replace(/[^\d.]/g, "");
//必须保证第一个为数字而不是.
valObj = valObj.replace(/^\./g, "");
//保证只有出现一个.而没有多个.
valObj = valObj.replace(/\.{2,}/g, ".");
//保证.只出现一次,而不能出现两次以上
valObj = valObj.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
return valObj;
}
//是否为数字
function IsNum(val) {
var re = /^[-\+]?\d+(\.\d+)?$/;
if (!re.test(val)) {
return false;
} else {
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();
}
}
}