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.
DS7/DSWeb/js/jsGridCwVouchersList_2.js

1342 lines
50 KiB
JavaScript

3 years ago
var mygrid_recv;
var page_count_2 = 5;
var column_count_2;
var jsonCodeCtnSetObj_2;
var changeCount_2 = 0;
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); }
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_container_log").style.height = "200px";
document.getElementById("mygrid_container_recv").style.height = "200px";
}
else if (winScreenWidth >= 1360 && winScreenWidth >= 768) {
document.getElementById("mygrid_container_log").style.height = "150px";
document.getElementById("mygrid_container_recv").style.height = "150px";
}
else if (winScreenWidth >= 1366 && winScreenWidth >= 768) {
document.getElementById("mygrid_container_log").style.height = "150px";
document.getElementById("mygrid_container_recv").style.height = "150px";
}
else if (winScreenWidth >= 1024 && winScreenWidth >= 768) {
document.getElementById("mygrid_container_log").style.height = "150px";
document.getElementById("mygrid_container_recv").style.height = "150px";
}
else if (winScreenWidth >= 1280 && winScreenWidth >= 720) {
document.getElementById("mygrid_container_log").style.height = "120px";
document.getElementById("mygrid_container_recv").style.height = "120px";
}
}
function doInitRecvGrid() {
mygrid_recv = new dhtmlXGridObject('mygrid_container_recv');
mygrid_recv.setImagePath("../images/");
mygrid_recv.setSkin("xp");
mygrid_recv.setHeader("<input type=\"checkbox\" id=\"ck_all_2\" onclick=\"checkall_2()\" />,行号,摘要,科目代码,科目名称,本位币借方,本位币贷方,外币借方,外币贷方,汇率,客户名称,客户财务编码,揽货人,业务编号");
mygrid_recv.setInitWidths("30,30,200,80,240,80,80,80,80,50,100,100,80,120");
mygrid_recv.setColAlign("center,left,left,left,left,right,right,right,right,right,left,left,left,left");
mygrid_recv.setColSorting("na,str,str,str,str,str,str,str,str,str,str,str,str,str");
mygrid_recv.setColTypes("ch,ro,ed,co,ed,ed,ed,ed,ed,ed,co,ed,co,ed");
var urlVal_2 = "CwVouchersListGridSource_2.aspx?read=exist&showcount=1&ordno="+$("hid_ORDNO").value+"&val=" + newGuid();
var loader2 = dhtmlxAjax.getSync(urlVal_2);
var loadVal2 = loader2.xmlDoc.responseText;
loader2 = null;
if (parseInt(loadVal2) == 1) {
mygrid_recv.loadXML("CwVouchersListGridSource_2.aspx?read=init&showcount=1&ordno=" + $("hid_ORDNO").value);
setTimeout(function() {
ReShowLabel(mygrid_recv);
}, 200);
}
mygrid_recv.init();
mygrid_recv.enableEditEvents(false, false, false);
createGrid2();
// 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控件编辑事件,由于免费控件没有提供完整的编辑判断功能,现特此做更改
// mygrid_recv.attachEvent("onEditCell", function(stage, rId, cInd, nValue, oValue) {
// var newCheckValue = false;
// //凭证禁止修改
// var urlVal4 = "CwVouchersListGridSource_2.aspx?read=isvbm&val=" + newGuid();
// var loader4 = dhtmlxAjax.getSync(urlVal4);
// var isvbm = loader4.xmlDoc.responseText;
// //初始化状态
// if (stage == 0) {
// var selectedId = mygrid_recv.getSelectedRowId();
// if (isvbm.trim() == "True") {
// var urlVal3 = "CwVouchersListGridSource_2.aspx?read=isedit&gid=" + selectedId + "&val=" + newGuid();
// var loader3 = dhtmlxAjax.getSync(urlVal3);
// var loadVal3 = loader3.xmlDoc.responseText;
// if (loadVal3.trim() == "True") {
// return false;
// }
// }
// //
// var rowIndex = mygrid_recv.getRowIndex(selectedId);
// var oldVal = mygrid_recv.cellByIndex(rowIndex, 0).getValue().trim();
// return true;
// }
// if (stage == 1) {
// var selectedId = mygrid_recv.getSelectedRowId();
// var rowIndex = mygrid_recv.getRowIndex(selectedId);
// var 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) {
// if (cInd == 3) {
// var rowIndex = mygrid_recv.getRowIndex(rId);
// mygrid_recv.cellByIndex(rowIndex, cInd).setLabel(oValue);
// //
// var urlVal5 = "CwVouchersListGridSource_2.aspx?read=accid&accid=" + oValue + "&val=" + newGuid();
// var loader5 = dhtmlxAjax.getSync(urlVal5);
// var sLabel = loader5.xmlDoc.responseText;
// mygrid_recv.cellByIndex(rowIndex, 4).setLabel(sLabel);
// return true;
// }
// if (cInd == 10 || cInd == 12) {
// var cellVal = mygrid_recv.cellByIndex(rowIndex, cInd).getValue();
// var s1 = mygrid_recv.cellByIndex(rowIndex, cInd).getLabel();
// var s2 = s1.indexOf("|");
// if (s1 == "") {
// mygrid_recv.cellByIndex(rowIndex, cInd).setLabel("");
// }
// else {
// if (s2 > 0) {
// s2 = s2 + 2;
// }
// var s3 = s1.substring(s2);
// if (s2 > 0) {
// mygrid_recv.cellByIndex(rowIndex, cInd).setLabel(s3);
// }
// else {
// mygrid_recv.cellByIndex(rowIndex, cInd).setLabel("");
// }
// }
// 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 == 13) {
// if (ind == 10 || ind == 12) {
// //如果是检索失败,
// if (pressCount == 2) {
// mygrid_recv.editStop();
// //将value写入cell(触发 stage2)
// mygrid_recv.cellByIndex(rowIndex, ind).setValue(oldVal);
// //重新打开cell(触发stage0 stage1)
// mygrid_recv.selectCell(rowIndex, ind, true, true);
// mygrid_recv.cellByIndex(rowIndex, ind).setLabel(oldVal);
// mygrid_recv.editCell();
// }
// //
// var cellVal = mygrid_recv.cellByIndex(rowIndex, cInd).getValue();
// var s1 = mygrid_recv.cellByIndex(rowIndex, cInd).getLabel();
// var s2 = s1.indexOf("|");
// if (s1 == "") {
// mygrid_recv.cellByIndex(rowIndex, cInd).setLabel("");
// }
// else {
// if (s2 > 0) {
// s2 = s2 + 2;
// }
// var s3 = s1.substring(s2);
// if (s2 > 0) {
// mygrid_recv.cellByIndex(rowIndex, cInd).setLabel(s3);
// }
// else {
// mygrid_recv.cellByIndex(rowIndex, cInd).setLabel("");
// }
// }
// return true;
// }
// else if (ind == 3) {
// //如果是检索失败,
// if (pressCount == 2) {
// mygrid_recv.editStop();
// //将value写入cell(触发 stage2)
// mygrid_recv.cellByIndex(rowIndex, ind).setValue(oldVal);
// //重新打开cell(触发stage0 stage1)
// mygrid_recv.selectCell(rowIndex, ind, true, true);
// mygrid_recv.cellByIndex(rowIndex, ind).setLabel(oldVal);
// mygrid_recv.editCell();
// return true;
// }
// //
// var urlVal5 = "CwVouchersListGridSource_2.aspx?read=accid&accid=" + mygrid_recv.cellByIndex(rowIndex, ind).getValue() + "&val=" + newGuid();
// var loader5 = dhtmlxAjax.getSync(urlVal5);
// var sLabel = loader5.xmlDoc.responseText;
// mygrid_recv.cellByIndex(rowIndex, 4).setLabel(sLabel);
// return true;
// }
// else {
// return true;
// }
// }
// else if (code == 9)//Tab键
// {
// var colCount = mygrid_recv.getColumnsNum();
// var rowCount = mygrid_recv.getRowsNum();
// if (ind == 3) {
// var urlVal5 = "CwVouchersListGridSource_2.aspx?read=accid&accid=" + mygrid_recv.cellByIndex(rowIndex, ind).getValue() + "&val=" + newGuid();
// var loader5 = dhtmlxAjax.getSync(urlVal5);
// var sLabel = loader5.xmlDoc.responseText;
// mygrid_recv.cellByIndex(rowIndex, 4).setLabel(sLabel);
// return true;
// }
//
// if (ind < colCount) {
// isExchange = false;
// pressRecord = "";
// pressRowIndex = -1;
// pressCellIndex = -1;
// mygrid_recv.editStop(true);
// mygrid_recv.cellByIndex(rowIndex, ind).setLabel(oldVal);
// 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 if (code >= 65 && code <= 90) {//如果是输入英文字符
// if (ind == 10) {
// //获取键盘输入字符
// var pressVal = String.fromCharCode(code);
// var start = 0;
// var end = 0;
// if (document.selection) {
// var range = document.selection.createRange();
// if (range.parentElement().className == txtEdit.className) {
// // create a selection of the whole textarea
// var range_all = document.body.createTextRange();
// range_all.moveToElementText(txtEdit);
// for (start = 0; range_all.compareEndPoints("StartToStart", range) < 0; start++) {
// range_all.moveStart('character', 1);
// }
// for (var i = 0; i <= start; i++) {
// if (txtEdit.value.charAt(i) == '\n')
// start++;
// }
// var range_all = document.body.createTextRange();
// range_all.moveToElementText(txtEdit);
// for (end = 0; range_all.compareEndPoints('StartToEnd', range) < 0; end++)
// range_all.moveStart('character', 1);
// for (var i = 0; i <= end; i++) {
// if (txtEdit.value.charAt(i) == '\n')
// end++;
// }
// }
// }
// //如果是当前检索位置
// if (rowIndex == pressRowIndex && ind == pressCellIndex) {
// //未选中多个字符
// if (start == end) {
// if (start != pressRecord.length) {
// if (start != 0) {
// var firstVal = pressRecord.substring(0, start - 1);
// var endVal = pressRecord.substring(start + 1, txtEdit.value.length - 1);
// // alert(firstVal);alert(endVal);
// pressRecord = firstVal + pressVal + endVal;
// }
// } else {
// pressRecord = pressRecord + pressVal;
// }
// }
// //选中多个字符
// if (start != end) {
// var firstVal = pressRecord.substring(0, start);
// var endVal = pressRecord.substring(end - 1, txtEdit.value.length - 1);
// // alert(firstVal);alert(endVal);
// pressRecord = firstVal + pressVal + endVal;
// }
// } else {
// pressRecord = pressVal;
// pressRowIndex = rowIndex;
// pressCellIndex = ind;
// }
// // alert(pressRecord);alert(start);alert(end);alert(txtEdit.value);
// //获取combo下拉列表
// var combo = mygrid_recv.getCustomCombo(selectedId, ind);
// var comboArg = combo.getKeys();
// var count = 0;
// //开始遍历检索
// //如果检索成功 状态pressCount=1 如果不成功应为pressCount=2
// for (var i = 0; i < comboArg.length; i++) {
// if (combo.get(comboArg[i]).toUpperCase().trim().indexOf(pressRecord) == 0) {
// //计数
// count++;
// //获取value
// var oldVal = comboArg[i];
// //获取label
// var oldLab = combo.get(comboArg[i]);
// //记录状态值 检索到数据项
// pressCount = 1;
// flagFilter = 1;
// //关闭编辑
// mygrid_recv.editStop();
// //将value写入cell(触发 stage2)
// mygrid_recv.cellByIndex(rowIndex, ind).setValue(oldVal);
// flagFilter = 0;
// //重新打开cell(触发stage0 stage1)
// mygrid_recv.selectCell(rowIndex, ind, true, true);
// mygrid_recv.editCell();
// var old_length = oldLab.length;
// //产生效果将检索字母之后的数据进行选黑
// for (i = 0; i < document.all.length; i++) {
// if (document.all(i).tagName == "TEXTAREA") {
// txtEdit = document.all(i);
// var rt = txtEdit.createTextRange();
// rt.collapse();
// rt.select(); //光标置最前
// var r = document.selection.createRange();
// r.collapse(false);
// r.moveStart("character", pressRecord.length); //从m位开始
// r.moveEnd("character", old_length); //选取n位
// r.select();
// break;
// }
// }
// break;
// }
// }
// //如果检索不能成功 pressCount=2
// if (count == 0) {
// pressCount = 2;
// txtEdit.value = pressRecord;
// for (i = 0; i < document.all.length; i++) {
// if (document.all(i).tagName == "TEXTAREA") {
// txtEdit = document.all(i);
// var rt = txtEdit.createTextRange();
// rt.collapse();
// rt.select(); //光标置最前
// var r = document.selection.createRange();
// r.collapse(true);
// r.moveStart("character", pressRecord.length); //从m位开始
// r.moveEnd("character", pressRecord.length); //选取n位
// r.select();
// break;
// }
// }
// }
// }
// else if (ind == 2 || ind == 4) {
// return true;
// }
// //mygrid_recv.setHeader("<input type=\"checkbox\" id=\"ck_all_2\" onclick=\"checkall_2()\" />,行号,摘要,科目代码,科目名称,本位币借方,本位币贷方,外币借方,外币贷方,汇率,客户名称,客户财务编码,揽货人");
// }
// else if (code == 8)//delete
// {
// //code8 begin
// if (ind == 3 || ind == 10 || ind == 12) {
// var start = 0;
// var end = 0;
// if (document.selection) {
// var range = document.selection.createRange();
// if (range.parentElement().className == txtEdit.className) {
// var range_all = document.body.createTextRange();
// range_all.moveToElementText(txtEdit);
// for (start = 0; range_all.compareEndPoints("StartToStart", range) < 0; start++) {
// range_all.moveStart('character', 1);
// }
// for (var i = 0; i <= start; i++) {
// if (txtEdit.value.charAt(i) == '\n')
// start++;
// }
// var range_all = document.body.createTextRange();
// range_all.moveToElementText(txtEdit);
// for (end = 0; range_all.compareEndPoints('StartToEnd', range) < 0; end++)
// range_all.moveStart('character', 1);
// for (var i = 0; i <= end; i++) {
// if (txtEdit.value.charAt(i) == '\n')
// end++;
// }
// }
// }
// // alert(start);alert(end);
// //未选中多个字符
// if (start == end) {
// if (start != 0) {
// var firstVal = pressRecord.substring(0, start - 1);
// var endVal = pressRecord.substring(start + 1, txtEdit.value.length - 1);
// pressRecord = firstVal;
// // alert(firstVal);alert(endVal);alert(pressRecord);
// }
// }
// //选中多个字符
// if (start != end) {
// var firstVal = pressRecord.substring(0, start);
// var endVal = pressRecord.substring(end - 1, txtEdit.value.length - 1);
// pressRecord = firstVal + endVal;
// }
// setTimeout(function() {
// if (pressRecord.trim().length > 0) {
// var combo = mygrid_recv.getCustomCombo(selectedId, ind);
// var comboArg = combo.getKeys();
// var count = 0;
// for (var i = 0; i < comboArg.length; i++) {
// if (combo.get(comboArg[i]).toUpperCase().trim().indexOf(pressRecord) == 0) {
// count++;
// var oldVal = comboArg[i];
// var oldLab = combo.get(comboArg[i]);
// pressCount = 3;
// mygrid_recv.editStop();
// mygrid_recv.cellByIndex(rowIndex, ind).setValue(oldVal);
// mygrid_recv.selectCell(rowIndex, ind, true, true);
// mygrid_recv.editCell();
// var old_length = oldLab.length;
// for (i = 0; i < document.all.length; i++) {
// if (document.all(i).tagName == "TEXTAREA") {
// txtEdit = document.all(i);
// var rt = txtEdit.createTextRange();
// rt.collapse();
// rt.select(); //光标置最前
// var r = document.selection.createRange();
// r.collapse(false);
// r.moveStart("character", pressRecord.length); //从m位开始
// r.moveEnd("character", old_length); //选取n位
// //txtEdit.focus();
// r.select();
// }
// }
// break;
// }
// }
// }
// }, 500);
// return true;
// }
// else {
// return true;
// }
// //code8 end
// }
// else if (code == 40)//向下方向键
// {
// if (ind == 3 || ind == 10 || ind == 12) {
// return true;
// }
// 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 (ind == 3 || ind == 10 || ind == 12) {
// return true;
// }
// 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 getGridRowArray(arrayRow, gridObj, RowID) {
var arg = new Array();
var columnCount = gridObj.getColumnsNum();
var rowCount = gridObj.getRowsNum();
alert(columnCount); alert(rowCount);
for (var i = 0; i < columnCount; i++) {
alert(i);
var cellObj = gridObj.cellById(RowID, i);
alert(cellObj);
if (i == 5) { alert("kill"); }
var cell = gridObj.cellById(RowID, i);
if (i == 5) { alert("kill"); }
var rowValue = cell.getValue();
if (i == 5) { alert("kill"); }
if (i == columnCount - 1) {
arg.push(rowValue == 1 ? true : false);
break;
}
//校验获取的值是否为数字,如果是数字记录时不加引号,如果是字符增加引号
var re = /^[-\+]?\d+(\.\d+)?$/;
if (!re.test(rowValue)) {
switch (i) {
case 4:
case 5:
case 6:
case 9:
alert("请正确输入数字");
return;
break;
case 8: //如果是币别 则根据value值获取text值
var curCombo = gridObj.getCustomCombo(RowID, i);
arg.push(curCombo.get(rowValue));
break;
default:
arg.push(rowValue);
break;
}
} else {
if (i == 7) {
//获取单价
var unitPrice = isObjNaN(parseFloat(gridObj.cellById(RowID, 4).getValue()));
//获取数量
var quantityCount = isObjNaN(parseFloat(gridObj.cellById(RowID, 5).getValue()));
//金额
var amount = unitPrice * quantityCount;
arg.push(outputMoney(amount.toString()));
} else {
arg.push(outputMoney(isObjNaN(parseFloat(rowValue)).toString()));
}
}
}
//alert(arg);
return arg;
}
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();
var loader = dhtmlxAjax.getSync("CwVouchersListGridSource_2.aspx?read=additemno&ordno=" + $("hid_ORDNO").value);
var strITEMNO = loader.xmlDoc.responseText;
//mygrid_recv.addRow(newId,["",loadrq,loadname,""],rowCount);
mygrid_recv.addRow(newId, [0, strITEMNO, "", "", "", "0", "0", "0", "0", "0", "", "", "",""], rowCount);
mygrid_recv.clearSelection();
var rId = mygrid_recv.getRowId(rowCount - 1);
var combo_customer;
combo_customer = mygrid_recv.getCustomCombo(rId, 0);
combo_customer2 = mygrid_recv.getCustomCombo(rId, 1);
//重新状态类型
setComboByArray(mygrid_recv, combo_customer, newId, 0);
setComboByArray(mygrid_recv, combo_customer2, newId, 1);
mygrid_recv.editStop(true);
mygrid_recv.selectCell(mygrid_recv.getRowIndex(newId), 0, true, true);
mygrid_recv.editCell();
}
else {
mygrid_recv.loadXML("CwVouchersListGridSource_2.aspx?read=add&showcount=1&ordno=" + $("hid_ORDNO").value);
}
}
function deleteRecvRow() {
mygrid_recv.editStop();
var selRowID = mygrid_recv.getSelectedRowId();
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 = "<img src=\"../images/icon/progress.gif\" />";
dg.width = 200;
dg.height = 100;
dg.title = "标题";
dg.show();
while (delCount < selGroup.length) {
var rowIndex = mygrid_recv.getRowIndex(selGroup[delCount]);
var CodeCtnSetName = mygrid_recv.cellByIndex(rowIndex, 1).getValue();
var cusName = mygrid_recv.cellByIndex(rowIndex, 2).getValue();
//var urlVal = "CodeCtnSetService.aspx?gid="+selGroup[delCount]+"&handle=delete"+"&no="+newGuid();
var urlVal = "CwVouchersListGridSource_2.aspx?read=delete&gid=" + selGroup[delCount] + "&ordno=" + $("hid_ORDNO").value;
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) {
var rowIndex = mygrid_recv.getRowIndex(selGroup[delCount]);
var CodeCtnSetName = mygrid_recv.cellByIndex(rowIndex, 1).getValue();
var cusName = mygrid_recv.cellByIndex(rowIndex, 2).getValue();
if (window.confirm("您确定要将(" + CodeCtnSetName + ")删除吗?")) {
var dg = new dialog();
dg.html = "<img src=\"../images/icon/progress.gif\" />";
dg.width = 200;
dg.height = 100;
dg.title = "标题";
dg.show();
//var urlVal = "CodeCtnSetService.aspx?gid="+selGroup[delCount]+"&handle=delete"+"&no="+newGuid();
var urlVal = "CwVouchersListGridSource_2.aspx?read=delete&gid=" + selGroup[delCount] + "&ordno=" + $("hid_ORDNO").value;
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() {
mygrid_recv.editStop();
jsonCodeCtnSetObj_2 = "{\"$type\":\"DSWeb.Models.JsonCodeCtnSetGroupEntity, DSWeb, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\",\"JsonCodeCtnSetEntities\":[";
column_count_2 = mygrid_recv.getColumnsNum();
var tempJson = "";
var rowCount = mygrid_recv.getRowsNum();
for (var i = 0; i < rowCount; i++) {
//获取RowID
tempJson = "";
var rId = mygrid_recv.getRowId(i);
tempJson += "\"$type\":\"DSWeb.Models.JsonCodeCtnSetEntity, DSWeb, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\",";
tempJson += "\"CodeCtnSet1\":\"" + rId + "\","; //gid
for (var j = 0; j < column_count_2; j++) {
var cell = mygrid_recv.cellById(rId, j);
var value = "";
//value = cell.cell.innerText; // .getValue();
value = cell.cell.textContent || cell.cell.innerText;
if (value == "") {
value = "null";
}
if (j == 1 && value != "null") {
var aVvalue = new Array();
if (value.indexOf("/") > 0) {
aVvalue = value.split("/");
value = aVvalue[2] + "-" + aVvalue[0] + "-" + aVvalue[1] + " 00:00:00"
}
}
tempJson += "\"CodeCtnSet" + (j + 2) + "\":\"" + value + "\",";
}
//tempJson += "\"CodeCtnSet6\":\""+BSNO+"\"";
tempJson = "{" + tempJson + "}";
if (i == rowCount - 1) {
jsonCodeCtnSetObj_2 = jsonCodeCtnSetObj_2 + tempJson;
} else {
jsonCodeCtnSetObj_2 = jsonCodeCtnSetObj_2 + tempJson + ",";
}
}
jsonCodeCtnSetObj_2 += "]}";
var txt_name = $("recvContainer");
txt_name.value = jsonCodeCtnSetObj_2;
msgBox();
setTimeout(postEnterCodeCtnSet, 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 postEnterCodeCtnSet() {
var myForm = document.getElementById("form1");
myForm.submit();
}
function findRow() {
var colNum = mygrid.getColumnsNum();
//alert(colNum);
var count = mygrid.getRowsNum();
//alert(count);
//var combo = mygrid.getCombo(1);
//combo.put("abc","abc");
}
function initGrid2() {
doInitRecvGrid();
//setTimeout(doInitPayGrid,200);
//setTimeout(totalDynamicCodeCtnSetGain,700);
}
//放弃应收集装箱修改 重新加载页面
function recoverRecvChange() {
mygrid_recv.editStop();
var selRowID = mygrid_recv.getSelectedRowId();
//查看是否有被选中的集装箱项
if (selRowID != null) {
var rowIndex = mygrid_recv.getRowIndex(selRowID);
var status = mygrid_recv.cellByIndex(rowIndex, 0).getValue();
var CodeCtnSetName = mygrid_recv.cellByIndex(rowIndex, 1).getValue();
var cusName = mygrid_recv.cellByIndex(rowIndex, 2).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 = "CwVouchersListGridSource_2.aspx?read=recover&gid=" + selRowID + "&val=" + newGuid() + "&ordno=" + $("hid_ORDNO").value;
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
if (!IsNum_2(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.cellByIndex(rowIndex,1).setValue("");
// mygrid_recv.cellByIndex(rowIndex,2).setValue("");
// mygrid_recv.cellByIndex(rowIndex,3).setValue("");
// mygrid_recv.cellByIndex(rowIndex,4).setValue("");
// mygrid_recv.cellByIndex(rowIndex,5).setValue("");
// mygrid_recv.cellByIndex(rowIndex,6).setValue("");
// mygrid_recv.cellByIndex(rowIndex,7).setValue("");
// mygrid_recv.cellByIndex(rowIndex,8).setValue("");
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+="<input type=button onclick='new dialog().close();' value='确定'>";
dg.width = 200;
dg.height = 100;
dg.title = "标题";
dg.show();
}
//是否为数字
function IsNum_2(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, ""); }
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_2() {
var checkStatus = $("ck_all_2").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 imgAdd2ChangePic() {
var pic1 = document.getElementById("imgAdd2");
var start = pic1.src.lastIndexOf("/");
var str = pic1.src.substring(start + 1);
if (str == "order_modify.gif") {
pic1.src = "../images/order_cancel.gif";
//pic1.alt="我是B图片";
}
else if (str == "order_cancel.gif") {
pic1.src = "../images/order_modify.gif";
//pic1.alt="我是A图片";
}
}
function imgEdit2ChangePic() {
var pic1 = document.getElementById("imgEdit2");
var start = pic1.src.lastIndexOf("/");
var str = pic1.src.substring(start + 1);
if (str == "audit.gif") {
pic1.src = "../images/order_delete.gif";
//pic1.alt="我是B图片";
}
else if (str == "order_delete.gif") {
pic1.src = "../images/audit.gif";
//pic1.alt="我是A图片";
}
}
function imgDel2ChangePic() {
var pic1 = document.getElementById("imgDel2");
var start = pic1.src.lastIndexOf("/");
var str = pic1.src.substring(start + 1);
if (str == "remove.gif") {
pic1.src = "../images/delete.gif";
//pic1.alt="我是B图片";
}
else if (str == "delete.gif") {
pic1.src = "../images/icons/remove.gif";
//pic1.alt="我是A图片";
}
}
function imgFresh2ChangePic() {
var pic1 = document.getElementById("imgFresh2");
var start = pic1.src.lastIndexOf("/");
var str = pic1.src.substring(start + 1);
if (str == "btnFresh.gif") {
pic1.src = "../images/icons/progress.gif";
//pic1.alt="我是B图片";
}
else if (str == "progress.gif") {
pic1.src = "../images/icons/btnFresh.gif";
//pic1.alt="我是A图片";
}
}
function ShowDetailDel2() {
var checked2 = mygrid_recv.getCheckedRows(0); //所有选中的grid的id编号
if (checked2 != null && checked2 != "") {
// var ii = GetRange();
// if(ii==0)
// {
// return;
// }
//
var gids = "";
var alt = "";
var arrtmp = checked2.split(","); //将各参数分离形成参数数组
for(var i=0;i<arrtmp.length;i++) {
var bl = getisvbm(arrtmp[i]);
if (bl) {
gids += "," + arrtmp[i];
}
else {
alt = "有系统生成的凭证,不允许更改!";
}
}
//
if (gids.trim() != "") {
gids = gids.substr(1);
if (confirm('确定删除吗?')) {
var urlVal = "CwVouchersListGridSource_2.aspx?read=delete2&gids=" + gids + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var strDel = loader.xmlDoc.responseText;
if (strDel.trim() != "") {
alert(strDel + alt);
return;
}
else {
if (alt.trim() != "") {
alert(alt);
}
doInitRecvGrid();
return;
}
}
}
//
if (alt.trim() != "") {
alert(alt);
return;
}
}
else {
alert('未选中要操作的数据!');
return;
}
}
function createGrid2() {
this.mygrid_recv.attachEvent("onRowDblClicked", function(rId, cInd) {
var bl = getisvbm(rId);
if (!bl) {
alert("系统生成的凭证,不允许更改!");
return;
}
//
if ($("hid_ORDNO").value.trim() == "") {
alert("请先选择主表数据!");
return;
}
//
var URLs = "CwVouchersInfo.aspx?ordno=" + $("hid_ORDNO").value + "&handle=edit&id=" + rId;
ret = window.open(URLs, "_blank", "height=250px, width=600px,center:yes,help:no,toolbar=no,menubar=no,scrollbars=no,resizable=0,location=no,status=no,Top= " + (screen.height / 2 - 100) + ",Left= " + (screen.width / 2 - 250));
});
}
function ShowDetailAdd2() {
if ($("hid_ORDNO").value.trim() == "") {
alert("请先选择主表数据!");
return;
}
//
var URLs = "CwVouchersInfo.aspx?ordno=" + $("hid_ORDNO").value + "&handle=add";
ret = window.open(URLs, "添加凭证明细", "height=250px, width=600px,center:yes,help:no,toolbar=no,menubar=no,scrollbars=no,resizable=0,location=no,status=no,Top= " + (screen.height / 2 - 100) + ",Left= " + (screen.width / 2 - 250));
}
function ShowDetailUpdate2() {
if ($("hid_ORDNO").value.trim() == "") {
alert("请先选择主表数据!");
return;
}
//
var selectedId = mygrid_recv.getSelectedRowId();
if (selectedId == null || selectedId == "") {
alert("请先选择要操作的数据!");
}
else {
var bl = getisvbm(rId);
if (!bl) {
alert("系统生成的凭证,不允许更改!");
return;
}
//
var URLs = "CwVouchersInfo.aspx?ordno=" + $("hid_ORDNO").value + "&handle=edit&id=" + selectedId;
ret = window.open(URLs, "_blank", "height=250px, width=600px,center:yes,help:no,toolbar=no,menubar=no,scrollbars=no,resizable=0,location=no,status=no,Top= " + (screen.height / 2 - 100) + ",Left= " + (screen.width / 2 - 250));
}
}
function getisvbm(rId) {
var urlVal3 = "CwVouchersListGridSource_2.aspx?read=isedit&gid=" + rId + "&val=" + newGuid();
var loader3 = dhtmlxAjax.getSync(urlVal3);
var loadVal3 = loader3.xmlDoc.responseText;
if (loadVal3.trim() == "False") {
return false;
}
else {
return true;
}
}
function setITEMNO() {
var dg = new dialog();
dg.html = "<img src=\"../images/icon/progress.gif\" />";
dg.width = 200;
dg.height = 100;
dg.title = "标题";
dg.show();
//
var urlVali = "CwVouchersListGridSource_2.aspx?read=setitemno&ordno=" + $("hid_ORDNO").value.trim() + "&val=" + newGuid();
var loaderi = dhtmlxAjax.getSync(urlVali);
var loadVali = loaderi.xmlDoc.responseText;
// if (loadVali.trim() == "False") {
// return false;
// }
// else {
// return true;
// }
//
dg.close();
refreshRecv();
}