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/jsGridCrmKeyCodeSet.js

970 lines
34 KiB
JavaScript

2 years ago
var mygrid_recv;
var page_count = 5;
var column_count;
var jsonFeeObj;
var changeCount = 0;
var authoriyStatus;
var changeFeeRecvCount = 0;
var newFeeRecvCount = 0;
var recv_menu;
var linkgid = "";
var strkeytype = "";
var cknum=0;//出库数量
var pressRecord;
var quantityVal;
var quantityObj;
function $(id){
return document.getElementById(id);
}
function document.onkeydown(){
if(event.keyCode == 8){
if(document.selection){
var range = document.selection.createRange();;
if(range.parentElement().name == null){
return false;
}else{
return true;
}
}
}
}
function initGrid(){
doInitRecvGrid();
}
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_recv\" onclick=\"checkAll()\" />,值");
mygrid_recv.setInitWidths("40,400");
mygrid_recv.setColAlign("center,center");
mygrid_recv.setColSorting("na,str");
mygrid_recv.setColTypes("ch,ed");
//
strkeytype = $("ddlKEYTYPE").value;
//判断委托单有无费用
var urlVal = "CrmKeyCodeSetGridSource.aspx?type=1&handle=exist&keytype=" + escape(strkeytype) + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
loader = null;
if(parseInt(loadVal) == 1){
//获取海运费及附加费信息初始化grid
mygrid_recv.loadXML("CrmKeyCodeSetGridSource.aspx?type=1&handle=init&keytype=" + escape(strkeytype) + "&val=" + newGuid(), function() {
ReShowLabel(mygrid_recv);
});
}
mygrid_recv.init();
mygrid_recv.enableEditEvents(true,false,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;
//初始化状态
if (stage == 0) {
return true;
}
if(stage == 1){
var selectedId = mygrid_recv.getSelectedRowId();
var rowIndex = mygrid_recv.getRowIndex(selectedId);
for(var i = 0; i < document.all.length; i++){
if(document.all(i).tagName == "TEXTAREA" && document.all(i).id != "tbREMARK"){
txtEdit = document.all(i);
txtEdit.focus();
txtEdit.select();
break;
}
}
}
//如果编辑结束
if(stage == 2){
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" && document.all(i).id != "tbREMARK") {
txtEdit = document.all(i);
break;
}
}
if (code == 13) {
//Enter键
return true;
}
//Tab键
if (code == 9) {
//code9 begin
var colCount = mygrid_recv.getColumnsNum();
var rowCount = mygrid_recv.getRowsNum();
if (ind < colCount) {
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, 1, true, true);
mygrid_recv.editCell();
}
else {
return;
}
}
else {
return;
}
}
//cdoe9 end
}
if ((code >= 65 && code <= 90) || (code >= 48 && code <= 57) || (code >= 96 && code <= 105)) {//如果是输入英文字符
return true;
}
//delete
if (code == 8) {
return true;
}
//向下方向键
if (code == 40) {
//code40 begin
var rowCount = mygrid_recv.getRowsNum();
mygrid_recv.clearSelection();
mygrid_recv.editStop();
if (rowIndex == (rowCount - 1)) {
addRecvRow();
} else {
mygrid_recv.selectCell(rowIndex + 1, 1, true, true);
mygrid_recv.editCell();
}
//code40 end
}
//向上箭头
if (code == 38) {
//code38 begin
if (rowIndex > 0) {
mygrid_recv.clearSelection();
mygrid_recv.editStop();
mygrid_recv.selectCell(rowIndex - 1, 1, true, true);
mygrid_recv.editCell();
var rowfeename = mygrid_recv.cellByIndex(rowIndex,1).getValue();
if (rowfeename == 0) {
mygrid_recv.deleteRow(selectedId)
newFeeRecvCount--;
}
}
//code38 end
}
//左箭头
if (code == 37) {
//code37 begin
mygrid_recv.clearSelection();
mygrid_recv.editStop();
mygrid_recv.editCell();
return true;
} //code37 end
//右箭头
if (code == 39) {
//code39 begin
mygrid_recv.clearSelection();
mygrid_recv.editStop();
mygrid_recv.editCell();
return true;
} //code39 end
//键盘输入数字code >= 48 && code <= 57|| code >= 96 && code <= 105 ||
if (code >= 48 && code <= 57 || code >= 96 && code <= 105 || code == 188 || code == 110 || code == 190 || code == 229) {
return true;
}
if (code >= 65 && code <= 90) {//如果是输入英文字符
return true;
}
if (code == 189 || code == 109) {
return true;
}
//onKeyPress end
});
setTimeout(function(){
},460);
}
function isObjNaN(Obj){
if(Obj.toString().toLowerCase() == "nan"){
return 0;
}else{
return Obj;
}
}
function addRecvRow(){
var newId = newGuid();
//获取插入新纪录位置
var rowCount = mygrid_recv.getRowsNum();
mygrid_recv.addRow(newId, [0, ""], rowCount);
mygrid_recv.clearSelection();
setTimeout(function(){
mygrid_recv.editStop(true);
mygrid_recv.selectCell(mygrid_recv.getRowIndex(newId),1,true,true);
mygrid_recv.editCell();
},150);
}
function deleteRecvRow(){
var checked = mygrid_recv.getCheckedRows(0); //所有选中的grid的id编号
if(checked.length > 0){
if(window.confirm("您确定要将所选费用删除")){
var urlVal = "CrmKeyCodeSetGridSource.aspx?gids=" + checked + "&handle=delete&no=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
if (loadVal != 1) {
alert("操作出错!");
}
else {
refreshRecv();
}
}
}else{
alert("未选中要操作的费用项");
}
return;
}
//保存海运费及附加费
function saveRecvChange(){
var jsonFeeObj = null;
for(var i=0;i<mygrid_recv.getRowsNum();i++){
var rowId = mygrid_recv.getRowId(i);
var rowIndex = mygrid_recv.getRowIndex(rowId);
strkeytype = $("ddlKEYTYPE").value;
var keycalue = mygrid_recv.cellByIndex(i, 1).getValue();
if (keycalue.trim() == "") {
$("recvContainer").value="";
alert("值内容不能为空");
return -1;
}
if(jsonFeeObj == null){
var cacheBuffer = "";
cacheBuffer += "{";
cacheBuffer += "\"keyid\":\"" + rowId + "\",";
cacheBuffer += "\"keytype\":\"" + strkeytype + "\",";
cacheBuffer += "\"keycalue\":\"" + keycalue + "\"";
cacheBuffer += "}";
var result = "";
result += "{\"fees\":[";
result += cacheBuffer;
result += "]}";
jsonFeeObj = eval('(' + result + ')');
}else{
var newFeeRow = jsonFeeObj.fees;
newFeeRow = { keyid: rowId, keytype: strkeytype, keycalue: keycalue };
jsonFeeObj.fees.push(newFeeRow);
}
}
$("recvContainer").value = JSON.stringify(jsonFeeObj);
return 1;
}
function saveAction(){
var recvState = 0;
recvState = saveRecvChange();//保存
var dd = $("recvContainer").value.trim();
if($("recvContainer").value.trim() == ""){
return;
}
if(recvState == 1){
msgBox();
//定时发送数据
setTimeout(postEnterFee,200);
newFeeRecvCount = 0;
changeFeeRecvCount = 0;
$("h_post").value = 1;
}
else{
// initGrid();
}
} //saveAction 完成
function doOnRowSelected(rowID,celInd){
alert("Selected row ID is "+rowID+"\nUser clicked cell with index "+celInd);
}
function getValue(){
var colLabel=mygrid_recv.getColumnLabel(0);
var colLabel2=mygrid_recv.getColumnLabel(0,1);
}
//post数据
function postEnterFee(){
var myForm = document.getElementById("form1");
myForm.submit() ;
}
function findRow(){
var colNum = mygrid.getColumnsNum();
var count = mygrid.getRowsNum();
}
//放弃海运费及附加费修改 重新加载页面
function recoverRecvChange(){
var iSuccess = 0;
var iFailure = 0;
var strkeytype = $("ddlKEYTYPE").value;
//验证委托状态是否为退舱状态(op_status和 op_seai)返回json值
var urlVal = "../Shipping/FeeService.aspx?strkeytype="+strkeytype+"&handle=checkopstatus&uid="+newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
var validStatusObj = eval('(' + loadVal + ')');
var opStatus = 0;
var feeStatus = 0;
if(validStatusObj.valid.length > 0){
opStatus = parseInt(validStatusObj.valid[0].opstatus);
feeStatus = parseInt(validStatusObj.valid[0].feestatus);
}
if(feeStatus < 1){
alert("委托业务已锁定,不能编辑费用信息");
return;
}
if(opStatus == 1){
//查看是否有被选中的费用项
var iCount = 0;
var recvArg = new Array();
for(var i=0;i<mygrid_recv.getRowsNum();i++){
var checkState = mygrid_recv.cellByIndex(i,0).getValue();
var feeState = mygrid_recv.cellByIndex(i,1).getValue();
var rowID = mygrid_recv.getRowId(i);
if(checkState == 1){
if(!validOperatePower(rowID,1)){
return;
}
if(feeState != "录入状态"){
alert("只能对状态为录入状态海运费及附加费进行放弃修改操作");
return;
}
recvArg.push(rowID);
iCount++;
}
}
if(iCount > 0){
var delCount = 0;
if(recvArg.length > 0){
if(window.confirm("您确定要将所选海运费及附加费放弃修改")){
while(delCount < recvArg.length){
var rowIndex = mygrid_recv.getRowIndex(recvArg[delCount]);
var tid = mygrid_recv.cellByIndex(rowIndex,19).getValue();
var feeName = mygrid_recv.cellByIndex(rowIndex,2).getValue();
var cusName = mygrid_recv.cellByIndex(rowIndex,3).getValue();
//恢复委托费用通过费用ch_fee.gid获取ch_fee信息返回字符串
var urlVal = "../Shipping/FeeService.aspx?gid="+recvArg[delCount]+"&handle=recover&no="+newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
if(!IsNum(loadVal)){
var recoverArg = new Array();
recoverArg = loadVal.split(",");
var selRowIndex = mygrid_recv.getRowIndex(recvArg[delCount]);
var colCount = mygrid_recv.getColumnsNum();
for(var i=2;i<colCount-5;i++){
mygrid_recv.cellByIndex(selRowIndex,i).setValue(recoverArg[i]);
}
iSuccess++;
}else{
var cacheTemplate = $("h_cachetemplate").value;
var importType = parseInt($("h_importtype").value);
var cacheHistory = $("h_cachehistory").value;
if(cacheTemplate != ""){
var jsonCacheObj = null;
jsonCacheObj = eval('(' + cacheTemplate + ')');
var tempCount = 0;
for(var i=0;i<jsonCacheObj.templates.length;i++){
if(jsonCacheObj.templates[i].tid == tid){
var templateCacheName = $("h_cachename").value;
//从引入费用模板缓存中移除单费用模板返回值1表示移除成功 值2表示未获取到缓存
var RemoveVal = "../Shipping/FeeService.aspx?tid="+tid+"&handle=removeimport&tempcache="+templateCacheName+"&no="+newGuid();
var RemoveLoader = dhtmlxAjax.getSync(RemoveVal);
var RemoveloadVal = RemoveLoader.xmlDoc.responseText;
if(RemoveloadVal >= 1){
jsonCacheObj.templates.splice(i,1);
$("h_cachetemplate").value = JSON.stringify(jsonCacheObj);
mygrid_recv.deleteRow(recvArg[delCount]);
iSuccess++;
tempCount++;
}else{
iFailure++;
}
break;
}
}
if(tempCount == 0){
mygrid_recv.deleteRow(recvArg[delCount]);
iSuccess++;
}
}else if(cacheHistory != ""){
var jsonCacheObj = null;
jsonCacheObj = eval('(' + cacheHistory + ')');
var tempCount = 0;
for(var i=0;i<jsonCacheObj.history.length;i++){
if(jsonCacheObj.history[i].tid == tid){
var templateCacheName = $("h_historycachename").value;
//从引入费用模板缓存中移除单费用模板返回值1表示移除成功 值2表示未获取到缓存
var RemoveVal = "../Shipping/FeeService.aspx?tid="+tid+"&handle=removeimport&tempcache="+templateCacheName+"&no="+newGuid();
var RemoveLoader = dhtmlxAjax.getSync(RemoveVal);
var RemoveloadVal = RemoveLoader.xmlDoc.responseText;
if(RemoveloadVal >= 1){
jsonCacheObj.history.splice(i,1);
$("h_cachehistory").value = JSON.stringify(jsonCacheObj);
mygrid_recv.deleteRow(recvArg[delCount]);
iSuccess++;
tempCount++;
}else{
iFailure++;
}
break;
}
}
if(tempCount == 0){
mygrid_recv.deleteRow(recvArg[delCount]);
iSuccess++;
}
}else{
mygrid_recv.deleteRow(recvArg[delCount]);
iSuccess++;
}
}
delCount++;
}
}
ReShowLabel(mygrid_recv);
alert("提交放弃修改海运费及附加费 共 "+delCount+" 条 成功 "+iSuccess+" 条 失败 "+iFailure+" 条");
}
}else{
alert("未选中要操作的费用项");
}
}else{
alert("委托已退载,费用修改费用");
return;
}
}
function print_recv(){
printMessageBox(event,1);
}
//输出money
function outputMoney(number) {
number= number.replace(/\,/g,"");
if (isNaN(number)||number=="") return "";
number = Math.round( number*10000) /10000;
if (number < 0) {
var sdf = '-' + outputDollars(Math.floor(Math.abs(number) - 0) + '') + outputCents(Math.abs(number) - 0);
return '-' + outputDollars(Math.floor(Math.abs(number) - 0) + '') + outputCents(Math.abs(number) - 0);
}
else {
var sdf = outputDollars(Math.floor(number - 0) + '') + outputCents(number - 0);
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) {
var ls = "";
amount = Math.round(((amount) - Math.floor(amount)) * 10000);
if (amount < 10) {
ls = '.000' + amount;
}
else if (amount < 100) {
ls = '.00' + amount;
}
else if (amount < 1000) {
ls = '.0' + amount;
}
else if (amount < 10000) {
ls = '.' + amount;
}
//return (amount<10 ? '.000' + amount : '.' + amount);
return ls;
}
//获取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()
{
// alert("打开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="费用正在保存中,请稍等……";//"<input type=button onclick='new dialog().close();' value='确定'>";
dg.width=200;
dg.height=100;
dg.title="";
dg.show();
}
//是否为数字
function IsNum(val){
var re = /^[-\+]?\d+(\.\d+)?$/;
if (!re.test(val)){
return false;
}else{
return true;
}
}
//去除“,”
function ConvertToMoney(strObj){
var result = strObj.replace(",","");
return result;
}
//过滤结算单位ComboCustomer的键盘
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){
gridObj.cellByIndex(rowIndex,colIndex).setValue(combo.get(comboArg[i]));
gridObj.selectCell(rowIndex,colIndex,true,true,true,true);
doCount = 1;
break;
}
}
}//end filterComboCustomerPress
//两端去空格函数
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); }
//刷新grid的Label
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 == 2 || j == 3){
var cellCurVal = gridObj.cellByIndex(i,j).getValue();
gridObj.cellByIndex(i,j).setLabel(cellCurVal);
}
}
}
}
}
//刷新grid的Label
function ReShowLabelForEnter(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(/\-{2,}/g,"-");
//保证.只出现一次,而不能出现两次以上
valObj = valObj.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
if(valObj.lastIndexOf("-") > 0){
if(valObj.indexOf("-") == 0){
valObj = "-"+valObj.replace(/-/g,"");
}else{
valObj = valObj.replace(/-/g,"");
}
}
return valObj;
}
//刷新海运费及附加费
function refreshRecv(){
if(newFeeRecvCount > 0 || changeFeeRecvCount > 0){
if(window.confirm("费用未保存,您确定要刷新费用列表,刷新后自动放弃未保存内容")){
doInitRecvGrid();
newFeeRecvCount = 0;
changeFeeRecvCount = 0;
}
}else{
doInitRecvGrid();
}
}
//检查浏览器是否是Ie
var isIe=(document.all)?true:false;
//设置select的可见状态
function setSelectState(state){
var objl=document.getElementsByTagName('select');
for(var i=0;i<objl.length;i++)
{
objl[i].style.visibility=state;
}
}
//获得鼠标位置
function mousePosition(ev){
if(ev.pageX || ev.pageY)
{
return {x:ev.pageX, y:ev.pageY};
}
return {
x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,y:ev.clientY + document.body.scrollTop - document.body.clientTop
};
}
//弹出方法消息提示框
function showMessageBox(wTitle,content,pos,wWidth){
closeWindow();
var bWidth=parseInt(document.documentElement.scrollWidth);
var bHeight=parseInt(document.documentElement.scrollHeight);
if(isIe){
setSelectState('hidden');}
var back=document.createElement("div");
back.id="back";
var styleStr="top:0px;left:0px;position:absolute;background:#666;width:"+bWidth+"px;height:"+bHeight+"px;";
styleStr+=(isIe)?"filter:alpha(opacity=0);":"opacity:0;";
back.style.cssText=styleStr;
document.body.appendChild(back);
showBackground(back,50);
var mesW=document.createElement("div");
mesW.id="mesWindow";
mesW.className="mesWindow";
mesW.innerHTML = "<div class='mesWindowTop'><table width='100%' height='100%'><tr><td>"+wTitle+"</td><td style='width:1px;'>"
+ "<input type='button' onclick='closeWindow();' title='关闭窗口' class='close' value='关闭' style='width:60px;'/></td></tr></table></div>"
+ "<div class='mesWindowContent' id='mesWindowContent'>"+content+"</div><div class='mesWindowBottom'></div>";
var v_top=(document.body.clientHeight-mesW.clientHeight)/2;
v_top+=document.documentElement.scrollTop;
styleStr="top:"+(v_top-180)+"px;left:"+(document.body.clientWidth/2-mesW.clientWidth/2)+"px;position:absolute;width:600px;margin-left:-300px;left:50%;z-index:9999;";
mesW.style.cssText=styleStr;
document.body.appendChild(mesW);
var Container = $("dvGain");
Container.attachEvent("onresize",function(){
$("back").style.width = parseInt(document.documentElement.scrollWidth);
$("back").style.height = parseInt(document.documentElement.scrollHeight);
});
}
//让背景渐渐变暗
function showBackground(obj,endInt){
if(isIe){
obj.filters.alpha.opacity+=5;
if(obj.filters.alpha.opacity<endInt){
setTimeout(function(){showBackground(obj,endInt)},5);
}
}else{
var al=parseFloat(obj.style.opacity);al+=0.05;
obj.style.opacity=al;
if(al<(endInt/100)){
setTimeout(function(){showBackground(obj,endInt)},5);}
}
}
//关闭窗口
function closeWindow(){
if(document.getElementById('back')!=null){
document.getElementById('back').parentNode.removeChild(document.getElementById('back'));
}
if(document.getElementById('mesWindow')!=null){
document.getElementById('mesWindow').parentNode.removeChild(document.getElementById('mesWindow'));
}
if(isIe){
setSelectState('');
}
}
//测试弹出
function printMessageBox(ev,type)
{
var selectCustomerOptions = "";
var feeNameArg = new Array();
for(var j=0;j<mygrid_recv.getRowsNum();j++){
var customerName = mygrid_recv.cellByIndex(j,3).getValue();
var iCount = 0;
for(var i=0;i<feeNameArg.length;i++){
if(feeNameArg[i] == customerName){
iCount++;
break;
}
}
if(iCount == 0){
feeNameArg.push(customerName);
}
}
for(var k=0;k<feeNameArg.length;k++){
selectCustomerOptions += "<option value=\""+feeNameArg[k]+"\">"+feeNameArg[k]+"</options>";
}
var objPos = mousePosition(ev);
messContent = "<div style=\"padding:20px 0 20px 0;text-align:center\">"
+"<div style=\"float:left;width:100%\"><select id=\"reportType\" onchange=\"onReportTypeChange('reportType')\"><option value=\"1\">打印海运费及附加费报表</option><option value=\"2\">打印人民币费用报表</option> "
+"<option value=\"3\">打印利润报表</option></select></div> "
+"<div style=\"float:left;width:100%;padding-left:80px;\"> "
+"<table style=\"width:350px;\"><tr><td><select id=\"sel_customer\" multiple style=\"width:150px; height:60px;\">"+selectCustomerOptions+"</select></td><td> "
+"<table style=\"height:60px; width:20px;\"><tr><td height=\"20px\"><div id=\"dvRemove\"><img src=\"../images/icons/edit_left.gif\" "
+"onmouseover=\"mouseMoveImg(this,1)\" onmouseout=\"mouseMoveImg(this,1)\" title=\"移除\" onclick=\"removeCustomer()\"/></div></td> "
+"</tr><tr><td height=\"20px\"><div id=\"dvAdd\"><img src=\"../images/icons/edit_right.gif\" onmouseover=\"mouseMoveImg(this,2)\" "
+"onmouseout=\"mouseMoveImg(this,2)\" title=\"添加\" onclick=\"addCustomer()\"/></div></td> "
+"</tr></table></td><td><select id=\"sel_print\" multiple style=\"width:150px; height:60px;\" class=\"select\"></select></td></tr></table></div>"
+"<input type=\"button\" id=\"btn_print_report\" value=\"打印\" class=\"btn\" onclick=\"printReport()\"/></div> ";
showMessageBox('费用打印',messContent,objPos,350);
}
//鼠标移过图标变化
function mouseMoveImg(obj,type){
var imgUrl = obj.src;
var urlArg = imgUrl.split("/");
if(type == 1){
if(urlArg[urlArg.length-1] == "edit_left.gif"){
var newUrl = "";
for(var i=0;i<urlArg.length;i++){
if(i == urlArg.length - 1){
newUrl += "edit_lefthover.gif";
}else{
newUrl += urlArg[i]+"/";
}
}
obj.src = newUrl;
}else{
var newUrl = "";
for(var i=0;i<urlArg.length;i++){
if(i == urlArg.length - 1){
newUrl += "edit_left.gif";
}else{
newUrl += urlArg[i]+"/";
}
}
obj.src = newUrl;
}
}else{
if(urlArg[urlArg.length-1] == "edit_right.gif"){
var newUrl = "";
for(var i=0;i<urlArg.length;i++){
if(i == urlArg.length - 1){
newUrl += "edit_righthover.gif";
}else{
newUrl += urlArg[i]+"/";
}
}
obj.src = newUrl;
}else{
var newUrl = "";
for(var i=0;i<urlArg.length;i++){
if(i == urlArg.length - 1){
newUrl += "edit_right.gif";
}else{
newUrl += urlArg[i]+"/";
}
}
obj.src = newUrl;
}
}
}
function checkAll(){//全选
for(var i=0;i<mygrid_recv.getRowsNum();i++){
var rId = mygrid_recv.getRowId(i);
if($("ck_all_recv").checked){
mygrid_recv.cellByIndex(i,0).setValue(1)
}else{
mygrid_recv.cellByIndex(i,0).setValue(0)
}
}
}
function initMenu(){//初始化菜单
initRecvMenu();
}
//-----------------------------------------------------------------------------------------------------------------------------------------