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.

950 lines
32 KiB
JavaScript

10 months ago
var strbsno="";
var changeRateCount = 0;
var newRateCount;//
var pressCount=0;
var mygrid_recv_2;
var page_count_2 = 5;
var column_count;
var jsonOpSeaiTruckObj_2;
var changeCount_2 = 0;
var BSNO="";//委托单号
var pressRecord;
var newRateCount=0;//新增行数
//两端去空格函数
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); }
function $(id) {
return document.getElementById(id);
}
function initGrid_2(){
doInitRecvGrid_2();
}
function doInitRecvGrid_2(){
//header
var headerArgs_fee = new Array("<input type=\"checkbox\" id=\"ck_all\" onclick=\"checkAll('ck_all')\" />","级别","计费区间","单价","单位","备注","创建人","创建时间","委托单号");
//width
var widthArgs_fee= new Array("40","40","60","100","80","264","80","120","0");
//column align
var colAlignArgs_fee = new Array("center","center","center","center","center","center","center","center","center");
//column sort
var colSortArgs_fee = new Array("na","str","str","str","str","str","str","str","str");
//column type
var colTypeArgs_fee = new Array("ch","ro","ed","ed","ro","ed","ro","ro","ro");
mygrid_recv_2 = new TGridCommon("mygrid_container_recv_2","form1",headerArgs_fee,widthArgs_fee,colAlignArgs_fee,colSortArgs_fee,colTypeArgs_fee);
mygrid_recv_2.setResponseUrl("../SeaiInfoLCL/WmsRateLCLGridSource.aspx");
BSNO = $("hdGID").value.trim();
mygrid_recv_2.setRequest("../SeaiInfoLCL/WmsRateLCLGridSource.aspx?handle=getrate&bsno="+BSNO+"&cus="+escape($("hd_comboCUSTOMERNAME").value)+"&show_page=15&cur_page=1");
mygrid_recv_2.setSourceType("json");
mygrid_recv_2.setSkin("xp");
mygrid_recv_2.setImageUrl("../images/");
mygrid_recv_2.initGrid();
mygrid_recv_2.bind();
mygrid_recv_2.getGridObj().enableEditEvents(true, false, true);
mygrid_recv_2.getGridObj().enableMultiselect(true);
mygrid_recv_2.getGridObj().enableKeyboardSupport(true);
mygrid_recv_2.getGridObj().attachEvent("onEditCell",function(stage,rId,cInd,nValue,oValue){
var newCheckValue = false;
//初始化状态
if(stage == 0){
return true;
}//stage == 0
var txtEdit;
if(stage == 1){
for(i = 0; i < document.all.length; i++){
if(document.all(i).tagName == "TEXTAREA"){
txtEdit = document.all(i);
txtEdit.focus();
txtEdit.select();
break;
}
}
} //stage == 1
if(stage == 2){
if(oValue==null || oValue=="" || oValue=="0"){
return true;
}
if( cInd == 2 || cInd == 3 ){ //
mygrid_recv_2.getGridObj().cellById(rId,cInd).setLabel(oValue);
}
else if( cInd == 5 ){
mygrid_recv_2.getGridObj().cellById(rId,cInd).setValue(oValue);
}
}//stage == 2
}); //onEditCell end
//键盘操作事件
mygrid_recv_2.getGridObj().attachEvent("onKeyPress", function(code,cFlag,sFlag){
//onKeyPress begin
//获取当前RowID
var selectedId = mygrid_recv_2.getGridObj().getSelectedRowId();
//获取当前RowIndex
var rowIndex = mygrid_recv_2.getGridObj().getRowIndex(selectedId);
//获取当前CellIndex(ind)
var ind = mygrid_recv_2.getGridObj().getSelectedCellIndex();
//触发操作事件前获取单元值
var oldVal = mygrid_recv_2.getGridObj().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;
}
}
//enter 键
if(code == 13){
if(ind == 2 || ind == 3 || ind == 5){
return true;
}
}//enter 键 end
//Tab键
if(code == 9){
//code9 begin
mygrid_recv_2.getGridObj().editStop(true);
if(ind==2){
mygrid_recv_2.getGridObj().cellByIndex(rowIndex,ind).setLabel(oldVal);
mygrid_recv_2.getGridObj().selectCell(rowIndex,3,true,true);
mygrid_recv_2.getGridObj().editCell();
}
else if(ind==3){
mygrid_recv_2.getGridObj().cellByIndex(rowIndex,ind).setLabel(oldVal);
mygrid_recv_2.getGridObj().selectCell(rowIndex,5,true,true);
mygrid_recv_2.getGridObj().editCell();
}
else if(ind==5){
mygrid_recv_2.getGridObj().cellByIndex(rowIndex,ind).setValue(oldVal);
mygrid_recv_2.getGridObj().selectCell(rowIndex,2,true,true);
mygrid_recv_2.getGridObj().editCell();
}
} //cdoe9 end
//向下方向键
if(code == 40){
//code40 begin
if(ind == 0 || ind == 2 || ind == 3 || ind == 5){
var rowCount = mygrid_recv_2.getGridObj().getRowsNum();
mygrid_recv_2.getGridObj().editStop(true);
if(ind == 2 || ind==3){
mygrid_recv_2.getGridObj().cellByIndex(rowIndex,ind).setLabel(oldVal);
}
else if(ind == 5){
mygrid_recv_2.getGridObj().cellByIndex(rowIndex,ind).setValue(oldVal);
}
var grade=mygrid_recv_2.getGridObj().cellByIndex(rowIndex,1).getValue();
var rownum=mygrid_recv_2.getGridObj().cellByIndex(rowIndex,3).getValue();
if(rowIndex == rowCount-1){
if( rownum!=0 || grade==1){
addRecvRow_2();
}
}else{
mygrid_recv_2.getGridObj().selectCell(rowIndex+1,2,true,true);
mygrid_recv_2.getGridObj().editCell();
}
}
return true;
}//code40 end
//向上箭头
if(code == 38){
//code38 begin
if(ind == 0 || ind == 2 || ind == 3 || ind == 5){
if(rowIndex > 0){
mygrid_recv_2.getGridObj().editStop(true);
if(ind == 2 || ind==3){
mygrid_recv_2.getGridObj().cellByIndex(rowIndex,ind).setLabel(oldVal);
mygrid_recv_2.getGridObj().selectCell(rowIndex-1,2,true,true);
mygrid_recv_2.getGridObj().editCell();
}
else if(ind == 5){
mygrid_recv_2.getGridObj().cellByIndex(rowIndex,ind).setValue(oldVal);
mygrid_recv_2.getGridObj().selectCell(rowIndex-1,2,true,true);
mygrid_recv_2.getGridObj().editCell();
}
var rownum=mygrid_recv_2.getGridObj().cellByIndex(rowIndex,3).getValue();
if(rownum==0)
{
mygrid_recv_2.getGridObj().deleteRow(selectedId)
newRateCount--;
}
}
}
return true;
}//code38 end
//左箭头
if(code == 37){
//code37 begin
mygrid_recv_2.getGridObj().editStop(true);
if(ind == 2){
mygrid_recv_2.getGridObj().cellByIndex(rowIndex,ind).setLabel(oldVal);
mygrid_recv_2.getGridObj().selectCell(rowIndex,5,true,true);
mygrid_recv_2.getGridObj().editCell();
}
else if(ind == 3){
mygrid_recv_2.getGridObj().cellByIndex(rowIndex,ind).setLabel(oldVal);
mygrid_recv_2.getGridObj().selectCell(rowIndex,2,true,true);
mygrid_recv_2.getGridObj().editCell();
}
else if(ind == 5){
mygrid_recv_2.getGridObj().cellByIndex(rowIndex,ind).setValue(oldVal);
mygrid_recv_2.getGridObj().selectCell(rowIndex,3,true,true);
mygrid_recv_2.getGridObj().editCell();
}
}//code37 end
//右箭头
if(code == 39){
//code39 begin
mygrid_recv_2.getGridObj().editStop(true);
if(ind == 2){
mygrid_recv_2.getGridObj().cellByIndex(rowIndex,ind).setLabel(oldVal);
mygrid_recv_2.getGridObj().selectCell(rowIndex,3,true,true);
mygrid_recv_2.getGridObj().editCell();
}
else if(ind == 3){
mygrid_recv_2.getGridObj().cellByIndex(rowIndex,ind).setLabel(oldVal);
mygrid_recv_2.getGridObj().selectCell(rowIndex,5,true,true);
mygrid_recv_2.getGridObj().editCell();
}
else if(ind == 5){
mygrid_recv_2.getGridObj().cellByIndex(rowIndex,ind).setValue(oldVal);
mygrid_recv_2.getGridObj().selectCell(rowIndex,2,true,true);
mygrid_recv_2.getGridObj().editCell();
}
}//code39 end
//键盘输入数字
if(code >= 48 && code <= 57|| code >= 96 && code <= 105 || code == 188|| code == 110|| code == 190 || code == 229){
if( ind == 2 || ind == 3 || ind == 5){
return true;
}
}
if (code >= 65 && code <= 90) {//如果是输入英文字符
if( ind == 2 || ind==3 || ind==5 ){
return true;
}
}
if(code == 8){
//code8 begin
if(ind == 2 || ind == 3 || ind == 5){
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){
if(pressRecord!=null){
var firstVal = pressRecord.substring(0,start - 1);
var endVal = pressRecord.substring(start + 1,txtEdit.value.length - 1);
pressRecord = firstVal;
}
}
}
//选中多个字符
if(start != end){
if(pressRecord!=null){
var firstVal = pressRecord.substring(0,start);
var endVal = pressRecord.substring(end - 1,txtEdit.value.length - 1);
pressRecord = firstVal+endVal;
}
}
setTimeout(function(){
if(pressRecord!=null){
if(pressRecord.trim().length > 0){
var combo = mygrid_recv_2.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_2.editStop(true);
mygrid_recv_2.cellByIndex(rowIndex,ind).setValue(oldVal);
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位
//txtEdit.focus();
r.select();
}
}
break;
}
}
}}
},1000);
return true;
}else{
return true;
}
//code8 end
}
});
}
//讲下拉列表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(){ //添加费率
var newId = newGuid();
//获取插入新纪录位置
var rowCount = mygrid_recv_2.getGridObj().getRowsNum();
var preindex = 0;
var FEEGRADE = 0;
if(rowCount>0)
{
preindex=rowCount-1;
FEEGRADE = parseInt(mygrid_recv_2.getGridObj().cellByIndex(preindex,1).getValue());
FEEGRADE=FEEGRADE+1;
mygrid_recv_2.getGridObj().addRow(newId,[0,FEEGRADE,0,0,"吨天","","","",BSNO],rowCount);
}
else
{
mygrid_recv_2.getGridObj().addRow(newId,[0,1,0,0,"吨天","","","",BSNO],rowCount);
}
newRateCount++;
setTimeout(function(){
mygrid_recv_2.getGridObj().editStop(true);
mygrid_recv_2.getGridObj().selectCell(mygrid_recv_2.getGridObj().getRowIndex(newId),2,true,true);
mygrid_recv_2.getGridObj().editCell();
},150);
}
function deleteRecvRow_2() {
var createname="";
var iCount = 0;
var iDelCount = 0;
var iFailure = 0;
if (newRateCount!=0)
{
alert("仓储费率未保存,先保存仓储费率-再进行删除操作");
return;
}
if(mygrid_recv_2 != null){
if(window.confirm("您确定要将选中的仓储费率删除")){
for(var i=0;i<mygrid_recv_2.getGridObj().getRowsNum();i++){
var gID = mygrid_recv_2.getGridObj().getRowId(i);
createname=mygrid_recv_2.getGridObj().cellByIndex(i,6).getValue();
var isCheckState = mygrid_recv_2.getGridObj().cellByIndex(i,0).getValue();
if(isCheckState == 1){
if(createname!="")
{
var url = "../SeaiInfoLCL/WmsRateLCLGridSource.aspx?handle=deleterate&gid="+gID;
var loader = dhtmlxAjax.getSync(url);
var deleteState = parseInt(loader.xmlDoc.responseText);
if(deleteState == 1){
iDelCount++;
}
else{
iFailure++;
}
}
else{
mygrid_recv_2.getGridObj().deleteRow(gID);
newRateCount--;
iDelCount++;
}
iCount++;
}
}
if (iCount>0){
alert("提交费率删除 "+iCount+" 条 成功 "+iDelCount+" 条 失败 "+iFailure+" 条");
}
}
doInitRecvGrid_2();
}
}
function saveRecvChange_2(){
var RateState = 0;
RateState = saveRateChange();//保存应收费用
if($("recvContainer_2").value.trim() == "" ){
return;
}
if(RateState == 1){
newRateCount = 0;
changeRateCount = 0;
if ($("hdEnabled").value != "false") {
//msgBox_2();
//setTimeout(postEnterOpSeaiTruck_2, 200);
}
}
}
function saveRateChange()//将费率信息打包为json格式存入变量recvContainer_2
{
var jsonRateObj = null;
var cus="";
if($("hd_comboCUSTOMERNAME").value!=null){
cus=$("hd_comboCUSTOMERNAME").value ;
}
if(cus==""){
alert("委托单位不能为空");
return ;
}
for(var i=0;i<mygrid_recv_2.getGridObj().getRowsNum();i++){
var rowId=mygrid_recv_2.getGridObj().getRowId(i);
var REMARK = mygrid_recv_2.getGridObj().cellByIndex(i,5).getValue();
var FEEGRADE = mygrid_recv_2.getGridObj().cellByIndex(i,1).getValue();
var FEESCALE = mygrid_recv_2.getGridObj().cellByIndex(i,2).getValue();
var FEEPRICE = mygrid_recv_2.getGridObj().cellByIndex(i,3).getValue();
var FEEUNIT = mygrid_recv_2.getGridObj().cellByIndex(i,4).getValue();
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(FEEUNIT.trim() == ""){
$("recvContainer_2").value="";
alert("计费单位不能为空");
return -1;
}
if(jsonRateObj == null){
var cacheBuffer = "";
cacheBuffer += "{";
cacheBuffer += "\"id\":\""+rowId+"\",";
cacheBuffer += "\"cus\":\""+cus+"\",";
cacheBuffer += "\"bsno\":\""+BSNO+"\",";
cacheBuffer += "\"fgrade\":\""+FEEGRADE+"\",";
cacheBuffer += "\"fscale\":\""+FEESCALE+"\",";
cacheBuffer += "\"fprice\":\""+FEEPRICE+"\",";
cacheBuffer += "\"funit\":\""+FEEUNIT+"\",";
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,
fgrade:FEEGRADE,fscale:FEESCALE,fprice:FEEPRICE,
funit:FEEUNIT,remark:REMARK};
jsonRateObj.rates.push(newRateRow);
}
}
$("recvContainer_2").value = JSON.stringify(jsonRateObj);
return 1;
}
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.getGridObj().getColumnLabel(0);
alert(colLabel);
var colLabel2 = mygrid_recv_2.getGridObj().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 recoverRecvChange_2() {
// mygrid_recv_2.getGridObj().editStop(true);
var selRowID = mygrid_recv_2.getGridObj().getSelectedRowId();
//查看是否有被选中的费用项
if (selRowID != null) {
var rowIndex = mygrid_recv_2.getGridObj().getRowIndex(selRowID);
var status = mygrid_recv_2.getGridObj().cellByIndex(rowIndex, 0).getValue();
var OpSeaiTruckName = mygrid_recv_2.getGridObj().cellByIndex(rowIndex, 1).getValue();
var cusName = mygrid_recv_2.getGridObj().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.getGridObj().getRowIndex(recvArg[0]);
var colCount = mygrid_recv_2.getGridObj().getColumnsNum();
for (var i = 0; i < colCount; i++) {
mygrid_recv_2.getGridObj().cellByIndex(selRowIndex, i).setValue(recvArg[i + 1]);
}
dg.close();
//alert("恢复成功");
//refreshRecv_2();//刷新
}
else {
if (parseInt(loadVal) == -3) {
// mygrid_recv_2.getGridObj().cellByIndex(rowIndex,1).setValue("");
// mygrid_recv_2.getGridObj().cellByIndex(rowIndex,2).setValue("");
// mygrid_recv_2.getGridObj().cellByIndex(rowIndex,3).setValue("");
mygrid_recv_2.getGridObj().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;
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 = "<input type=button onclick='new dialog_2().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 = "";
}