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.

555 lines
24 KiB
JavaScript

var commonGridObj_muliple;
var commonGridObj_total;
var sortName = "";
var sortIndex = "";
var newHeaderArgs;
var newWidthArgs;
var newColAlignArgs;
var newColSortArgs;
var newColTypeArgs;
var s0="";
var comboOperator;
var comboVessel;
var comboVoyno;
var comboCustomer;
function $(id){
return document.getElementById(id);
}
function createGrid(type) {
//获取自定义列表样式
//if(document.getElementById("origmultiplebusinessgrid") == null){
var url = "../UserSettings/UserGridSource/OrigMultipleBusinessGrid.js?uid="+newGuid();
var loader = dhtmlxAjax.getSync(url);
var jsVal = loader.xmlDoc.responseText;
var oHead = document.getElementsByTagName('head').item(0);
var oScript = document.createElement( "script" );
oScript.language = "javascript";
oScript.type = "text/javascript";
oScript.id = "origmultiplebusiness";
oScript.defer = true;
oScript.text = jsVal;
oHead.appendChild(oScript);
//}
//
var searchJson = "";
if(type == 2){
var _begintime = $("txt_beginetd").value.trim();
if(_begintime.trim() != ""){
if(!validateDateTime(_begintime)){
alert("起始时间格式错误");
return;
}
}
var _endtime = $("txt_endetd").value.trim();
if(_endtime.trim() != ""){
if(!validateDateTime(_endtime)){
alert("结束时间格式错误");
return;
}
}
var _customer = $("h_customer").value.trim();
var _vessel = $("h_vessel").value.trim();
var _voyno = $("h_voyno").value.trim();
var _op = $("h_operator").value.trim();
var _checkno = $("txt_no").value.trim();
var _bstype = comboBsType.getSelectedValue();//业务类型
//begin
searchJson +="{";
searchJson += "[";
//如果查询条件设置了起始时间和结束时间则判断结束时间是否大于起始时间
if(_begintime != "" && _endtime != ""){
if(_begintime.length > 9 && _endtime.length > 9){
var status = DateTimeEqual(_begintime,_endtime);
if(status == 0){
searchJson += "\"btime\":\""+_begintime+"\","
searchJson += "\"etime\":\""+_endtime+"\","
}else if(status == -1){
alert("时间设置错误,起始时间不能大于结束时间,请修改!");
return;
}
// else if(status == -2){
// alert("时间设置错误,起始时间不能等于结束时间,请修改!");
// return;
// }
}
else{
alert("时间格式有问题,长度应大于9个字符,请修改!");
return;
}
}else{
searchJson += "\"btime\":\""+_begintime+"\","
searchJson += "\"etime\":\""+_endtime+"\","
}
searchJson += "\"cus\":\""+_customer+"\",";
searchJson += "\"vessel\":\""+_vessel+"\",";
searchJson += "\"voyno\":\""+_voyno+"\",";
searchJson += "\"op\":\""+_op+"\",";
searchJson += "\"bty\":\""+_bstype+"\",";
searchJson += "\"no\":\""+_checkno+"\"";
searchJson += "]";
searchJson +="}";
}
commonGridObj_muliple = new TGridCommon("mygrid_container_report","form1",headerArgs_orderlist,widthArgs_orderlist,colAlignArgs_orderlist,colSortArgs_orderlist,colTypeArgs_orderlist);
commonGridObj_muliple.setResponseUrl("ReportGridSource.aspx");
commonGridObj_muliple.setSortValue("etd","desc");
var searchcacheName = $("h_searchcache").value;//alert(searchcacheName);
if(commonGridObj_muliple.sortValue.length > 1 && commonGridObj_muliple.sortType.length > 1){
if(searchcacheName != ""){
commonGridObj_muliple.setRequest("ReportGridSource.aspx?handle=multiplebusiness&show_page=15&cur_page=1&uid="+commonGridObj_muliple.newGuid()+"&sort="+commonGridObj_muliple.sortValue+"&sortindex="+commonGridObj_muliple.sortType+"&cntr="+s0+"&searchcachename="+searchcacheName);
}else{
if(searchJson.trim() != ""){
commonGridObj_muliple.setRequest("ReportGridSource.aspx?handle=multiplebusiness&show_page=15&cur_page=1&search="+escape(searchJson)+"&uid="+commonGridObj_muliple.newGuid()+"&sort=etd&sortindex=desc"+"&cntr="+s0);
}else{
commonGridObj_muliple.setRequest("ReportGridSource.aspx?handle=multiplebusiness&show_page=15&cur_page=1&uid="+commonGridObj_muliple.newGuid()+"&sort="+commonGridObj_muliple.sortValue+"&sortindex="+commonGridObj_muliple.sortType+"&cntr="+s0);
}
}
}else{
if(searchcacheName != ""){
commonGridObj_muliple.setRequest("ReportGridSource.aspx?handle=multiplebusiness&show_page=15&cur_page=1&uid="+commonGridObj_muliple.newGuid()+"&sort=etd&sortindex=desc"+"&cntr="+s0+"&searchcachename="+searchcacheName);
}else{
if(searchJson.trim() != ""){
commonGridObj_muliple.setRequest("ReportGridSource.aspx?handle=multiplebusiness&show_page=15&cur_page=1&search="+escape(searchJson)+"&uid="+commonGridObj_muliple.newGuid()+"&sort=etd&sortindex=desc"+"&cntr="+s0);
}else{
commonGridObj_muliple.setRequest("ReportGridSource.aspx?handle=multiplebusiness&show_page=15&cur_page=1&uid="+commonGridObj_muliple.newGuid()+"&sort=etd&sortindex=desc"+"&cntr="+s0);
}
}
}
if(searchcacheName != ""){
commonGridObj_muliple.setMultiple("&searchcachename="+searchcacheName);
}
if(searchJson.trim() != ""){
commonGridObj_muliple.setSearch(searchJson);
}
commonGridObj_muliple.setSourceType("json");
commonGridObj_muliple.setSkin("xp");
commonGridObj_muliple.setImageUrl("../images/");
commonGridObj_muliple.loadafter = true;
commonGridObj_muliple.after = function () {
var url = "../UserSettings/UserGridSource/OrigMultipleBusinessGrid.js?uid=" + newGuid();
var loader = dhtmlxAjax.getSync(url);
var jsVal = loader.xmlDoc.responseText;
var oHead = document.getElementsByTagName('head').item(0);
var oScript = document.createElement("script");
oScript.language = "javascript";
oScript.type = "text/javascript";
oScript.id = "origmultiplebusiness";
oScript.defer = true;
oScript.text = jsVal;
oHead.appendChild(oScript);
//
var arg = new Array();
if(newColSortArgs.length == colSortArgs_orderlist.length){
for(var i=0;i<colSortArgs_orderlist.length;i++){
var oIndex = i;
var nIndex = 0;
var iCount = 0;
if(colSortArgs_orderlist[i] != newColSortArgs[i]){
for(var k=0;k<colSortArgs_orderlist.length;k++){
if(colSortArgs_orderlist[k] == newColSortArgs[i]){
nIndex = k;
//arg.push(nIndex+"#"+oIndex);
//alert(commonGridObj_muliple.getGridObj().getColumnLabel(nIndex)+"#"+commonGridObj_muliple.getGridObj().getColumnLabel(oIndex));
commonGridObj_muliple.getGridObj().moveColumn(nIndex,oIndex);
var title = headerArgs_orderlist[nIndex];
var width = widthArgs_orderlist[nIndex];
var sort = colSortArgs_orderlist[nIndex];
var colType = colTypeArgs_orderlist[nIndex];
var align = colAlignArgs_orderlist[nIndex];
//var index = i;
headerArgs_orderlist[nIndex] = headerArgs_orderlist[oIndex];
widthArgs_orderlist[nIndex] = widthArgs_orderlist[oIndex];
colSortArgs_orderlist[nIndex] = colSortArgs_orderlist[oIndex];
colTypeArgs_orderlist[nIndex] = colTypeArgs_orderlist[oIndex];
colAlignArgs_orderlist[nIndex] = colAlignArgs_orderlist[oIndex];
headerArgs_orderlist[oIndex] = title;
widthArgs_orderlist[oIndex] = width;
colSortArgs_orderlist[oIndex] = sort;
colTypeArgs_orderlist[oIndex] = colType;
colAlignArgs_orderlist[oIndex] = align;
//alert(commonGridObj_muliple.getGridObj().getColumnLabel(nIndex)+"#"+commonGridObj_muliple.getGridObj().getColumnLabel(oIndex));
commonGridObj_muliple.getGridObj().moveColumn(oIndex+1,nIndex+1);
// alert(commonGridObj_muliple.getGridObj().getColumnLabel(oIndex)+"##"+oIndex+"##wd:"+widthArgs_orderlist[oIndex])
//Set AllCheckBox
if(headerArgs_orderlist[nIndex] == "checkboxs"){
commonGridObj_muliple.getGridObj().setColLabel(nIndex,"<input type=\"checkbox\" id=\"ck_all\" onclick=\"checkAll('ck_all')\" />");
}
var tempWidth = widthArgs_orderlist[nIndex];
commonGridObj_muliple.getGridObj().setColWidth(nIndex,tempWidth);
iCount++;//alert(headerArgs_orderlist);
break;
}
}
}else{
if(headerArgs_orderlist[i] == "checkboxs"){
commonGridObj_muliple.getGridObj().setColLabel(i,"<input type=\"checkbox\" id=\"ck_all\" onclick=\"checkAll('ck_all')\" />");
}
var tempWidth = newWidthArgs[i];
commonGridObj_muliple.getGridObj().setColWidth(i,tempWidth);
}
}
}
};
commonGridObj_muliple.initGrid();
commonGridObj_muliple.bind();
commonGridObj_muliple.isSort = true;
commonGridObj_muliple.initPageByHandle("multiplebusiness");
commonGridObj_muliple.sortEventFun = function(){
commonGridObj_muliple.getGridObj().attachEvent("onBeforeSorting", function(ind,type,direction){
if(type == "na" || type == "checkboxs"){
return false;
}else{
//alert(type);alert(direction);alert(ind);
commonGridObj_muliple.setSortValue(type,direction);
commonGridObj_muliple.getGridObj().clearAll();
commonGridObj_muliple.setRequest("SeaExportGridSource.aspx?handle=list&show_page=15&cur_page=1&uid="+commonGridObj_muliple.newGuid()+"&sort="+type+"&sortindex="+direction+"&cntr="+s0);
if(commonGridObj_muliple.loadafter){
commonGridObj_muliple.loadafter = false;
commonGridObj_muliple.after = function(){
}
}
commonGridObj_muliple.bind();
return true;
}
});
}
commonGridObj_muliple.getGridObj().attachEvent("onBeforeSorting", function(ind,type,direction){
if(type == "na" || type == "checkboxs"){
return false;
}else{
//alert(type);alert(direction);alert(ind);
commonGridObj_muliple.setSortValue(type,direction);
commonGridObj_muliple.getGridObj().clearAll();
commonGridObj_muliple.setRequest("SeaExportGridSource.aspx?handle=list&show_page=15&cur_page=1&uid="+commonGridObj_muliple.newGuid()+"&sort="+type+"&sortindex="+direction+"&cntr="+s0);
if(commonGridObj_muliple.loadafter){
commonGridObj_muliple.loadafter = false;
commonGridObj_muliple.after = function(){
}
}
commonGridObj_muliple.bind();
return true;
}
});
}
function createTotalGrid(){
//header
var headerArgs_total = new Array("业务类型","票数","应收USD","已收USD","未收USD","应收RMB","已收RMB","未收RMB","合计应收","合计已收","合计未收","应付USD","已付USD","未付USD","应付RMB","已付RMB","未付RMB","合计应付","合计已付","合计为付","利润USD","利润RMB","毛利润");
//width
var widthArgs_total = new Array("120","120","120","120","120","120","120","120","120","120","120","120","120","120","120","120","120","120","120","120","120","120","120");
//column align
var colAlignArgs_total = new Array("center","center","center","center","center","center","center","center","center","center","center","center","center","center","center","center","center","center","center","center","center","center","center");
//column sort
var colSortArgs_total = new Array("str","str","str","str","str","str","str","str","str","str","str","str","str","str","str","str","str","str","str","str","str","str","str");
//column type
var colTypeArgs_total = new Array("ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro");
commonGridObj_total = new TGridCommon("mygrid_container_total","form1",headerArgs_total,widthArgs_total,colAlignArgs_total,colSortArgs_total,colTypeArgs_total);
commonGridObj_total.setResponseUrl("ReportGridSource.aspx");
var searchcacheName = $("h_searchcache").value;
var searchStr = "";
if(searchcacheName.trim() != ""){
searchStr = "&searchcachename="+searchcacheName;
}
commonGridObj_total.setRequest("ReportGridSource.aspx?handle=opseaemultipletotal"+searchStr+"&uid="+commonGridObj_total.newGuid());
commonGridObj_total.setSourceType("json");
commonGridObj_total.setSkin("xp");
commonGridObj_total.setImageUrl("../images/");
commonGridObj_total.initGrid();
commonGridObj_total.bind();
}
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:700px;margin-left:-300px;left:50%;z-index:9999;";
mesW.style.cssText=styleStr;
document.body.appendChild(mesW);
}
//让背景渐渐变暗
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)
{
var messContent = "";
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%;text-align:center;display:none;\" id=\"dvGainCheck\"><div style=\"float:left\"><input type=\"radio\" id=\"ra_recv\" name=\"gain\" title=\"打印应收利润\"/>应收利润</div> "
//// +"<div style=\"float:left\"><input type=\"radio\" id=\"ra_recv\" name=\"gain\" title=\"打印应付利润\"/>应付利润</div><div style=\"float:left\"> "
//// +"<input type=\"radio\" id=\"ra_recv\" name=\"gain\" title=\"打印利润\"/>利润</div></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> ";
messContent += "<div style=\"padding:20px 0 20px 0;text-align:center\">"
+ "<iframe frameborder=\"0\" src=\"../search/multiplesearch.aspx?handle=multiplebusiness&opentype=frame\" width=\"100%\" height=\"230px;\" scrolling=\"no\">";
+ "</div> ";
showMessageBox('综合查询',messContent,objPos,350);
}
function reInitJs(){
if(document.getElementById("origmultiplebusinessgrid") == null){
var url = "../UserSettings/UserGridSource/OrigMultipleBusinessGrid.js?uid="+newGuid();
var loader = dhtmlxAjax.getSync(url);
var jsVal = loader.xmlDoc.responseText;
var oHead = document.getElementsByTagName('head').item(0);
var oScript = document.createElement( "script" );
oScript.language = "javascript";
oScript.type = "text/javascript";
oScript.id = "origmultiplebusiness";
oScript.defer = true;
oScript.text = jsVal;
oHead.appendChild(oScript);
}
if(document.getElementById("defaultsource") == null){
var url = "../js/DefaultSource.js?uid="+newGuid();
var loader = dhtmlxAjax.getSync(url);
var jsVal = loader.xmlDoc.responseText;
var oHead = document.getElementsByTagName('head').item(0);
var oScript = document.createElement( "script" );
oScript.language = "javascript";
oScript.type = "text/javascript";
oScript.id = "defaultsource";
oScript.defer = true;
oScript.text = jsVal;
oHead.appendChild(oScript);
}
if(document.getElementById("multiplebusiness") == null){
var url = "../UserSettings/UserGridSource/" + $("h_uid").value + "gridmultiplebusiness.js?uid="+newGuid();
var loader = dhtmlxAjax.getSync(url);
var jsVal = loader.xmlDoc.responseText;
if(jsVal.indexOf("newHeaderArgs") >= 0){
var oHead = document.getElementsByTagName('head').item(0);
var oScript = document.createElement( "script" );
oScript.language = "javascript";
oScript.type = "text/javascript";
oScript.id = "multiplebusiness";
oScript.defer = true;
oScript.text = jsVal;
oHead.appendChild(oScript);
}
}
createGrid(1);createTotalGrid();
}
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 editGridSetting(){
var openSet = "height=500, width=800, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-500)/2 + ",Left= "+(screen.width-800)/2
var openType = "_blank";
var openUrl = "../UserSettings/UserGridEdit.aspx?handle=usergrid&templatetype=multiplebusiness";
window.open (openUrl,openType,openSet);
}
function searchMultiple(){
printMessageBox(event);
}
function initSearch(){
$("h_customer").value = "";
comboCustomer.setText($("h_customer").value);
$("h_vessel").value = "";
comboVessel.setText($("h_vessel").value);
$("h_voyno").value = "";
comboVoyno.setText($("h_voyno").value);
$("h_operator").value = "";
comboOperator.setText($("h_operator").value);
$("txt_beginetd").value = "";
$("txt_endetd").value = "";
$("txt_no").value = "";
if($("h_searchcache").value != ""){
$("h_searchcache").value = "";
}
if(comboBsType != null){ //清空业务类型
comboBsType.setComboText("全部");
}
createGrid();
}
function initCombo(){
CustomerCombo();
OperatorCombo();
VesselCombo();
VoynoCombo();
createComboBsType();//业务类型
}
function createComboBsType(){//业务类型
comboBsType = dhtmlXComboFromSelect("sel_bstype");
}
function CustomerCombo(){
comboCustomer = new TCombo("sel_customer","../FeeCodes/WebCrmClientAdapter.aspx?mask=0&pos=0&strIS=ISCONTROLLER",true,true,false,true,"h_customer");
comboCustomer.initComboEvent();
comboCustomer.bind();
}
function OperatorCombo(){
var strUserID = $("h_uid").value.trim();
comboOperator = new TCombo("sel_op","../FeeCodes/OPAdapter.aspx?mask=0&pos=0&rName=isOperator&userID="+strUserID,true,true,false,true,"h_operator");
comboOperator.initComboEvent();
comboOperator.bind();
}
function VesselCombo(){
comboVessel = new TCombo("sel_vessel","../FeeCodes/TCodeVesselAdapter.aspx?mask=0&pos=0",true,false,false,true,"h_vessel");
comboVessel.initComboEvent();
comboVessel.bind();
}
function VoynoCombo(){
var strVessel = $("h_vessel").value;
comboVoyno = new TCombo("sel_voyno","../FeeCodes/TCodeVoynoAdapter.aspx?mask=0&pos=0&strVESSEL="+strVessel,true,true,false,true,"h_voyno");
comboVoyno.initComboEvent();
if(strVessel.trim() != ""){
comboVoyno.bind();
}
}
//根据条件查询付费申请信息
function search(){
createGrid(2);
}