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.
JiCangHai/PingTai/DSWeb/js/jsGridSeaImportInfoTruck.js

973 lines
34 KiB
JavaScript

var mygrid_recv_2;
var page_count_2 = 5;
var column_count;
var jsonOpSeaiTruckObj_2;
var changeCount_2 = 0;
//两端去空格函数
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); }
function $(id) {
return document.getElementById(id);
}
function doInitRecvGrid_2() {
mygrid_recv_2 = new dhtmlXGridObject('mygrid_container_recv_2');
mygrid_recv_2.setImagePath("../images/");
mygrid_recv_2.setSkin("xp");
mygrid_recv_2.setHeader("承运车队,车牌号,拖货日期");
mygrid_recv_2.setInitWidths("120,120,120");
mygrid_recv_2.setColAlign("left,left,left");
mygrid_recv_2.setColSorting("str,str,date");
mygrid_recv_2.setColTypes("co,ed,calendar");
var BSNO = $("dvOrderNumVal_2").value.trim();
var urlVal = "SeaImportInfoTruckGridSource.aspx?read=exist&showcount=1&BSNO=" + BSNO + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
loader = null;
if (parseInt(loadVal) == 1) {
mygrid_recv_2.loadXML("SeaImportInfoTruckGridSource.aspx?read=init&showcount=1&BSNO=" + BSNO);
setTimeout(function() {
ReShowLabel_2(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) {
return true;
}
//如果编辑结束
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();
if (ind == 0) {
oldVal = oldVal.toUpperCase();
var loader = dhtmlxAjax.getSync("../FeeCodes/OpSeaiTruckAdapter.aspx?truckgid=" + oldVal + "&val=" + newGuid());
oldVal = loader.xmlDoc.responseText;
//将value写入cell(触发 stage2)
mygrid_recv_2.cellByIndex(rowIndex, ind).setValue(oldVal);
}
return true;
}
});
//键盘操作事件
mygrid_recv_2.attachEvent("onKeyPress", function(code, cFlag, sFlag) {
//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;
//Tab键
if (code == 9) {
var colCount = mygrid_recv_2.getColumnsNum();
var rowCount = mygrid_recv_2.getRowsNum();
if (ind < colCount) {
isExchange = false;
pressRecord = "";
pressRowIndex = -1;
pressCellIndex = -1;
mygrid_recv_2.editStop(true);
if (ind==0)
{
oldVal = oldVal.toUpperCase();
var loader = dhtmlxAjax.getSync("../FeeCodes/OpSeaiTruckAdapter.aspx?truckgid=" + oldVal + "&val=" + newGuid());
oldVal = loader.xmlDoc.responseText;
}
mygrid_recv_2.cellByIndex(rowIndex, ind).setLabel(oldVal);
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, 0, true, true);
mygrid_recv_2.editCell();
}
else {
return;
}
}
}
}
else if (code == 40)//向下方向键
{
var rowCount = mygrid_recv_2.getRowsNum();
mygrid_recv_2.clearSelection();
mygrid_recv_2.editStop();
if (rowIndex == (rowCount - 1)) {
addRecvRow_2();
}
else {
mygrid_recv_2.selectCell(rowIndex + 1, 0, true, true);
mygrid_recv_2.editCell();
}
}
else if (code == 38)//向上箭头
{
if (rowIndex > 0) {
mygrid_recv_2.clearSelection();
mygrid_recv_2.editStop();
mygrid_recv_2.selectCell(rowIndex - 1, 0, true, true);
mygrid_recv_2.editCell();
}
}
else {
if (ind == 0) {
for (i = 0; i < document.all.length; i++) {
if (document.all(i).tagName == "TEXTAREA") {
txtEdit = document.all(i);
break;
}
}
if (code >= 65 && code <= 90) {//如果是输入英文字符
if (ind == 0) {
//获取键盘输入字符
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) {
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);
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);
pressRecord = firstVal + pressVal + endVal;
}
} else {
pressRecord = pressVal;
pressRowIndex = rowIndex;
pressCellIndex = ind;
}
//获取combo下拉列表
var combo = mygrid_recv_2.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_2.editStop();
//将value写入cell(触发 stage2)
mygrid_recv_2.cellByIndex(rowIndex, ind).setValue(oldVal);
flagFilter = 0;
//重新打开cell(触发stage0 stage1)
mygrid_recv_2.selectCell(rowIndex, ind, true, true);
mygrid_recv_2.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 {
return true;
}
}
else {
return true;
}
}
});
}
//讲下拉列表Combo所有生成Array数组
function setComboByArray_2(gridNewObj, comboObj, rowGID, colIndex) {
//var comboTxt_arg = new Array();
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_2(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_2(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:
case 8: //如果是币别 则根据value值获取text值
default:
arg.push(rowValue);
break;
}
} else
{
arg.push(outputMoney_2(isObjNaN_2(parseFloat(rowValue)).toString()));
}
}
//alert(arg);
return arg;
}
function isObjNaN_2(Obj) {
if (Obj.toString().toLowerCase() == "nan") {
return 0;
} else {
return Obj;
}
}
function addRecvRow_2() {
if (mygrid_recv_2.getRowsNum() > 0) {
var newId = newGuid();
//获取插入新纪录位置
var rowCount = mygrid_recv_2.getRowsNum();
mygrid_recv_2.addRow(newId, ["", "", ""], rowCount);
mygrid_recv_2.clearSelection();
var rId = mygrid_recv_2.getRowId(rowCount - 1);
var combo_frt;
combo_frt = mygrid_recv_2.getCustomCombo(rId, 0);
//重新加载FRT
setComboByArray_2(mygrid_recv_2, combo_frt, newId, 0);
mygrid_recv_2.editStop(true);
mygrid_recv_2.selectCell(mygrid_recv_2.getRowIndex(newId), 0, true, true);
mygrid_recv_2.editCell();
}
else {
var BSNO = $("dvOrderNumVal_2").value.trim();
mygrid_recv_2.loadXML("SeaImportInfoTruckGridSource.aspx?read=add&showcount=1&BSNO=" + BSNO);
}
}
function deleteRecvRow_2() {
mygrid_recv_2.editStop();
var selRowID = mygrid_recv_2.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_2();
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_2.getRowIndex(selGroup[delCount]);
var OpSeaiTruckName = mygrid_recv_2.cellByIndex(rowIndex, 0).getValue();
var cusName = mygrid_recv_2.cellByIndex(rowIndex, 1).getValue();
var urlVal = "SeaImportInfoTruckGridSource.aspx?read=delete&GID=" + selGroup[delCount];
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
if (loadVal > 0) {
mygrid_recv_2.deleteRow(selGroup[delCount]);
}
else {
mygrid_recv_2.deleteSelectedRows();
}
delCount++;
}
dg.close();
}
}
else {
var delCount = 0;
while (delCount < selGroup.length) {
var rowIndex = mygrid_recv_2.getRowIndex(selGroup[delCount]);
var OpSeaiTruckName = mygrid_recv_2.cellByIndex(rowIndex, 0).getValue();
var cusName = mygrid_recv_2.cellByIndex(rowIndex, 1).getValue();
if (window.confirm("您确定要将数据(" + OpSeaiTruckName + ")删除吗?")) {
var dg = new dialog_2();
dg.html = "<img src=\"../images/icon/progress.gif\" />";
dg.width = 200;
dg.height = 100;
dg.title = "标题";
dg.show();
var urlVal = "SeaImportInfoTruckGridSource.aspx?read=delete&GID=" + selGroup[delCount];
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
if (loadVal > 0) {
mygrid_recv_2.deleteRow(selGroup[delCount]);
dg.close();
//alert("删除成功");
}
else {
mygrid_recv_2.deleteSelectedRows();
dg.close();
}
}
delCount++;
}
}
}
else {
alert("未选中要操作的费用项");
}
}
function saveRecvChange_2() {
mygrid_recv_2.editStop();
var strError = "";
var strError2 = "";
var strError3 = "";
var BSNO = $("dvOrderNumVal_2").value.trim();
jsonOpSeaiTruckObj_2 = "{\"$type\":\"DSWeb.Models.JsonOpSeaiTruckGroupEntity, DSWeb, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\",\"JsonOpSeaiTruckEntities\":[";
column_count = mygrid_recv_2.getColumnsNum();
var tempJson = "";
var rowCount = mygrid_recv_2.getRowsNum();
for (var i = 0; i < rowCount; i++) {
//获取RowID
tempJson = "";
var rId = mygrid_recv_2.getRowId(i);
tempJson += "\"$type\":\"DSWeb.Models.JsonOpSeaiTruckEntity, DSWeb, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\",";
tempJson += "\"OpSeaiTruck1\":\"" + rId + "\","; //gid
strError = "";
for (var j = 0; j < column_count; j++) {
var cell = mygrid_recv_2.cellById(rId, j);
var value = "";
//value = cell.cell.innerText; // .getValue();
value = cell.cell.textContent || cell.cell.innerText;
if ((j + 2) == 2) {
if (value.trim() == "") {
value = "";
strError = "派车列表中有承运车队为空的数据,不能保存信息!"
continue;
//value = "null";
}
}
else if ((j + 2) == 4)
{
if (value == "null" || value.trim() == "") {
value = "0001-01-01 00:00:00";
}
else
{
var aVvalue = new Array();
if (value.indexOf("/") > 0) {
aVvalue = value.split("/");
value = aVvalue[2] + "-" + aVvalue[0] + "-" + aVvalue[1] + " 00:00:00"
}
}
}
else {
if (value.trim() == "") {
value = "";
//value = "null";
}
}
tempJson += "\"OpSeaiTruck" + (j + 2) + "\":\"" + value.trim() + "\",";
}
tempJson += "\"OpSeaiTruck5\":\"" + BSNO + "\"";
tempJson = "{" + tempJson + "}";
//
if (strError != "") {
strError2 = strError;
continue;
}
else {
strError3 += "," + BSNO
}
//
if (i == rowCount - 1) {
jsonOpSeaiTruckObj_2 = jsonOpSeaiTruckObj_2 + tempJson;
}
else {
jsonOpSeaiTruckObj_2 = jsonOpSeaiTruckObj_2 + tempJson + ",";
}
}
//
if (strError2 != "") {
alert(strError2);
strError2 = "";
var dg = new dialog_2();
dg.close();
return;
}
//
// if(strError3=="")
// {
// var dg=new dialog_2();
// dg.close();
// return;
// }
jsonOpSeaiTruckObj_2 += "]}";
$("recvContainer_2").value = jsonOpSeaiTruckObj_2;
if ($("hdEnter").value != "0") {
msgBox_2();
setTimeout(postEnterOpSeaiTruck_2, 200);
}
}
function doOnRowSelected_2(rowID, celInd) {
alert("Selected row ID is " + rowID + "\nUser clicked cell with index " + celInd);
}
function getValue_2() {
var colLabel = mygrid_recv_2.getColumnLabel(0);
alert(colLabel);
var colLabel2 = mygrid_recv_2.getColumnLabel(0, 1);
alert(colLabel2);
}
//post数据
function postEnterOpSeaiTruck_2() {
var myForm = document.getElementById("form1");
myForm.submit();
}
function findRow_2() {
var colNum = mygrid.getColumnsNum();
//alert(colNum);
var count = mygrid.getRowsNum();
//alert(count);
//var combo = mygrid.getCombo(1);
//combo.put("abc","abc");
}
function initGrid_2() {
doInitRecvGrid_2();
//setTimeout(doInitPayGrid,200);
//setTimeout(totalDynamicOpSeaiTruckGain,700);
}
//放弃应收费用修改 重新加载页面
function recoverRecvChange_2() {
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 OpSeaiTruckName = mygrid_recv_2.cellByIndex(rowIndex, 1).getValue();
var cusName = mygrid_recv_2.cellByIndex(rowIndex, 2).getValue();
if (window.confirm("您确定放弃当前行的修改吗?")) {
var dg = new dialog_2();
dg.html = "<img src=\"../../images/icon/progress.gif\" />";
dg.width = 200;
dg.height = 100;
dg.title = "标题";
dg.show();
var urlVal = "SeaImportInfoTruckGridSource.aspx?read=recover&GID=" + selRowID + "&val=" + newGuid();
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_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("恢复成功");
//refreshRecv_2();//刷新
}
else {
if (parseInt(loadVal) == -3) {
// mygrid_recv_2.cellByIndex(rowIndex,1).setValue("");
// mygrid_recv_2.cellByIndex(rowIndex,2).setValue("");
// mygrid_recv_2.cellByIndex(rowIndex,3).setValue("");
mygrid_recv_2.deleteSelectedRows();
}
dg.close();
}
ReShowLabel_2(mygrid_recv_2);
}
else {
return;
}
}
else {
alert("未选中要操作的费用项");
}
}
function print_recv_2() {
alert("正在打印");
}
function amountSum_2(gridName) {
if (gridName == "recv") {
//计算应收
mygrid_recv_2
} else {
//计算应付
}
}
function outputMoney_2(number) {
number = number.replace(/\,/g, "");
if (isNaN(number) || number == "") return "";
number = Math.round(number * 100) / 100;
if (number < 0)
return '-' + outputDollars_2(Math.floor(Math.abs(number) - 0) + '') + outputCents_2(Math.abs(number) - 0);
else
return outputDollars_2(Math.floor(number - 0) + '') + outputCents_2(number - 0);
}
function outputDollars_2(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_2(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_2() {
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_2() {
var dg = new dialog_2();
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 isInt_2OrNull_2(str) {
if (!isObj(str))//判断对象是否存在
return 'undefined';
return isNull(str) || isInt_2(str);
}
//必需是整数
function isInt_2(str) {
var reg = /^(-|\+)?\d+$/;
return reg.test(str);
}
//1.2 小数
//小数或者为空
function isFloat_2OrNull_2(str) {
if (!isObj(str))//判 断对象是否存在
return 'undefined';
if (isInt_2(str))
return true;
return isNull(str) || isFloat_2(str);
}
//必需是小数
function isFloat_2(str) {
if (isInt_2(str))
return true;
var reg = /^(-|\+)?\d+\.\d*$/;
return reg.test(str);
}
//1.3 数字大小判断
//数i不能大于数y
function iMinY_2(i, y) {
if (!isObj(i) || !isObj(y))// 判断对象是否存在
return 'undefined';
if (!(isFloat_2(i) && isFloat_2(y)))
return '比较的必须是数字类型'
if (i <= y)
return true;
return false;
}
// 数i不能小于数y
function iMaxY_2(i, y) {
if (!isObj(i) || !isObj(y))//判断对象是 否存在
return 'undefined';
if (!(isFloat_2(i) && isFloat_2(y)))
return '比较的必须是数字类型'
if (i >= y)
return true;
return false;
}
function ConvertToMoney_2(strObj) {
var result = strObj.replace(",", "");
return result;
}
function filterComboCustomerPress_2(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_2(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 == 1 || j == 2) {
var cellCurVal = gridObj.cellByIndex(i, j).getValue();
gridObj.cellByIndex(i, j).setLabel(cellCurVal);
}
}
}
}
}
function clearNoNum_2(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_2(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_2() {
doInitRecvGrid_2();
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------
function divdadd_2() {
document.getElementById('divadd_2').style.display = "";
//document.getElementById('divsave_2').style.display = "";
document.getElementById('divrefresh_2').style.display = "";
document.getElementById('divdel_2').style.display = "none";
document.getElementById('divrollback_2').style.display = "none";
}
function divdisplay_2() {
document.getElementById('divadd_2').style.display = "";
//document.getElementById('divsave_2').style.display = "";
document.getElementById('divrefresh_2').style.display = "";
document.getElementById('divdel_2').style.display = "";
document.getElementById('divrollback_2').style.display = "";
}