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.

409 lines
15 KiB
JavaScript

12 months ago
function $(id){
return document.getElementById(id);
}
function initSelectName(idName){
var optionJsonObj = null;
if(optionJson != ""){
optionJsonObj = eval('(' + optionJson + ')');
}
var selObj = $(idName);
for(var i=0;i<optionJsonObj.searchs.length;i++){
var newOptionItem = null;
if(optionJsonObj.searchs[i].value == -1){
newOptionItem = new Option("","");
}else{
newOptionItem = new Option(optionJsonObj.searchs[i].title,optionJsonObj.searchs[i].value);
}
selObj.options.add(newOptionItem);
}
}
function initSelectEqual(obj,equalType){
var equalJsonObj = null;
obj.options.length = 0;
//var selObj = $(idName);
var equalName = "";
var equalValue = "";
if(equalJson != ""){
equalJsonObj = JSON.parse(equalJson,function(key,value){
if(key == "name"){
equalName = value;
}
if(key == "value"){
equalValue = value;
}
if(key == equalType){
if(value == 1){
var newOptionItem = new Option(equalName,equalValue);
obj.options.add(newOptionItem);
//alert(equalName);alert(equalValue);
equalName = "";
equalValue = "";
}else{
equalName = "";
equalValue = "";
}
}
return value;
});
}
obj.value = obj.options[0].value;
obj.disabled = false;
}
function initAllSelect(){
initSelectName("sel_name1");
initSelectName("sel_name2");
initSelectName("sel_name3");
initSelectName("sel_name4");
initSelectName("sel_name5");
initSelectName("sel_name6");
}
function initSelectChange(objName,objValue,txtObjName,selOptionNum,dvName){
var selectObj = null;
selectObj = $(objName);
var optionJsonObj = null;
if(optionJson != ""){
optionJsonObj = eval('(' + optionJson + ')');
}
var typeName = "";
var remark = "";
for(var i=0;i<optionJsonObj.searchs.length;i++){
if(objValue == optionJsonObj.searchs[i].value){
typeName = optionJsonObj.searchs[i].type;
remark = optionJsonObj.searchs[i].remark;
initSelectEqual(selectObj,optionJsonObj.searchs[i].type);
break;
}
}
if(typeName == "bool"){
var dvObj = $(dvName);
dvObj.innerHTML = "<div style=\"width:50px;float:left;padding-top:3px;margin-right:7px;\">"+remark+"</div><div style=\"width:30px;float:left;\"><input type=\"checkbox\" name=\"ck_true\" id=\"ck_true"+(selOptionNum-1)+"\" onclick=\"switchCheckBox('ck_true"+(selOptionNum-1)+"','ck_false"+(selOptionNum-1)+"')\" checked=1/></div><div style=\"width:30px;float:left;padding-top:3px;\">是</div>"
+ "<div style=\"width:30px;float:left;\"><input type=\"checkbox\" name=\"ck_false\" id=\"ck_false"+(selOptionNum-1)+"\" onclick=\"switchCheckBox('ck_false"+(selOptionNum-1)+"','ck_true"+(selOptionNum-1)+"')\"/></div><div style=\"width:30px;float:left;padding-top:3px;\">否</div>"
}else if(typeName == "str"){
var dvObj = $(dvName);
dvObj.innerHTML = "<input type=\"text\" id=\""+txtObjName+"\" runat=\"server\" class=\"txtTab\" style=\"width:100%;\" />";
}else if(typeName == "int"){
var dvObj = $(dvName);
dvObj.innerHTML = "<input type=\"text\" id=\""+txtObjName+"\" runat=\"server\" class=\"txtTab\" style=\"width:100%;\" />";
}else if(typeName == "sdate"){
var dvObj = $(dvName);
dvObj.innerHTML = "<input type=\"text\" id=\""+txtObjName+"\" runat=\"server\" class=\"txtTab\" style=\"width:100%;\" onclick=\"WdatePicker()\" />";
}
//
// var txtValueObj = $(txtObjName);
//txtValueObj.disabled = false;
if(selOptionNum != 0){
var selectOptionObj = $("sel_option"+selOptionNum);
selectOptionObj.value = selectOptionObj.options[1].value;
selectOptionObj.disabled = false;
var selectNameObj = $("sel_name"+selOptionNum);
//selectNameObj.value = selectNameObj.options[1].value;
selectNameObj.disabled = false;
}
}
function searchAction(){
var searchJson = "";
//begin
searchJson +="{";
searchJson += "[";
var optionJsonObj = null;
if(optionJson != ""){
optionJsonObj = eval('(' + optionJson + ')');
}
var equalJsonObj = null;
if(equalJson != ""){
equalJsonObj = eval('(' + equalJson + ')');
}
var totalCount = 6;
for(var i=0;i<totalCount;i++){
var tempNum = (i+1);
if($("sel_name"+tempNum).value.trim() != ""){
for(var j=0;j<optionJsonObj.searchs.length;j++){
if($("sel_name"+tempNum).value == optionJsonObj.searchs[j].value){
var typeName = optionJsonObj.searchs[j].type;
if($(("sel_option"+tempNum)).value != ""){
searchJson += "\"option"+tempNum+"\":\""+($(("sel_option"+tempNum)).value)+"\",";
}
searchJson += "\"search"+tempNum+"\":\""+(optionJsonObj.searchs[j].name)+"\",";
var equalStr = "";
for(var k=0;k<equalJsonObj.equals.length;k++){
if(equalJsonObj.equals[k].value == $("sel_equal"+tempNum).value){
equalStr = equalJsonObj.equals[k].code;
searchJson += "\"equal"+tempNum+"\":\""+(equalJsonObj.equals[k].code)+"\",";
break;
}
}
searchJson += "\"type"+tempNum+"\":\""+(optionJsonObj.searchs[j].type)+"\",";
if(equalStr == "in" || equalStr == "notin"){
searchJson += "\"value"+tempNum+"\":\"%"+($("txt_value"+tempNum).value)+"%\",";
}else{
if(typeName == "bool"){
if($("ck_true"+tempNum).checked){
searchJson += "\"value"+tempNum+"\":\"1\",";
}else{
searchJson += "\"value"+tempNum+"\":\"0\",";
}
}else{
searchJson += "\"value"+tempNum+"\":\""+($("txt_value"+tempNum).value)+"\",";
}
}
break;
}
}
}
}
searchJson += "\"end\":0";
searchJson += "]";
searchJson +="}";//alert(searchJson);
//alert(searchJson);
var requestName = "";
requestName = $("h_handle").value;
var url = "";
var cacheName = "";
if($("h_searchcache").value.trim() != ""){
cacheName = "&searchcachename="+$("h_searchcache").value.trim();
}else{
$("h_searchcache").value = newGuid();
cacheName = "&searchcachename="+$("h_searchcache").value.trim();
}
//if(requestName == "opseae"){
url = "MultipleSearchService.aspx?handle=cachesearch&searchtype=1&search="+escape(searchJson)+cacheName+"&guid="+newGuid();
var loader = dhtmlxAjax.getSync(url);
var cacheTotal = "";
var cacheTotalObj = null;
var cacheVal = loader.xmlDoc.responseText;//alert(opInfo);
var cacheState = parseInt(cacheVal);
var parentObj = null;
if($("h_opentype").value.trim() == "frame"){
parentObj = parent.document.location;
}else{
parentObj = window.parent.opener.location;//alert(parentObj);
}
var oldUrl = parentObj.href;
if(oldUrl.indexOf("&searchcachename") >= 0 || oldUrl.indexOf("?searchcachename") >= 0){
if(oldUrl.indexOf("&searchcachename=") >= 0){
var requeststring = "";
var beginNum = oldUrl.indexOf("&searchcachename=");
var beginString = oldUrl.substr(0,oldUrl.indexOf("&searchcachename="));
var endString = oldUrl.substr((oldUrl.indexOf("&searchcachename=")),(oldUrl.length - oldUrl.indexOf("&searchcachename=")));
var midString = endString.substr(1,endString.length - 1);
var midSecondStr = "";
if(midString.indexOf("&") >= 0){
midSecondStr = midString.substr(midString.indexOf("&"),midString.length-midString.indexOf("&"));
}
requeststring = beginString+cacheName+midSecondStr;
}else if(oldUrl.indexOf("?searchcachename=") >= 0){
var requeststring = "";
var beginNum = oldUrl.indexOf("?searchcachename=");
var beginString = oldUrl.substr(0,oldUrl.indexOf("?searchcachename="));
var endString = oldUrl.substr((oldUrl.indexOf("?searchcachename=")),(oldUrl.length - oldUrl.indexOf("?searchcachename=")));
var midString = endString.substr(1,endString.length - 1);
var midSecondStr = "";
if(midString.indexOf("?") >= 0){
midSecondStr = midString.substr(midString.indexOf("?"),midString.length-midString.indexOf("?"));
}
cacheName = "?searchcachename="+$("h_searchcache").value.trim();
requeststring = beginString+cacheName+midSecondStr;
}
newUrl = requeststring;
//document.write(newUrl);return;
}else{
if(oldUrl.indexOf("?") >= 0){
newUrl = oldUrl+"&searchcachename="+$("h_searchcache").value.trim()+"&guid="+newGuid();
}else{
newUrl = oldUrl+"?searchcachename="+$("h_searchcache").value.trim()+"&guid="+newGuid();
}
}
if(cacheState == 1){
if($("h_opentype").value.trim() == "frame"){
parentObj = parent.document.location;
parent.document.location.href = parent.document.location.href;
parentObj.href = newUrl;
}else{
window.parent.opener.location.href = window.parent.opener.location.href;
parentObj.href = newUrl;
//finishLoading();
window.close();
}
}
//}
}
function cancelAction(){
if(window.confirm("您确定要关闭综合查询页面")){
window.closed();
}
}
function initSearchAction(){
if(window.confirm("您确定要初始化查询信息")){
window.location.href=window.location.href;
}
}
//两端去空格函数
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); }
//获取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 switchCheckBox(pushObjName,otherObjName){
if($(pushObjName).checked){
$(otherObjName).checked = false;
}else{
$(pushObjName).checked = true;
$(otherObjName).checked = false;
}
}
function initJson(){
if($("h_handle").value.trim() == "opseae"){
if(document.getElementById("opseae") == null){
var url = "../js/MultipleSearchOpSeaeSource.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 = "opseae";
oScript.defer = true;
oScript.text = jsVal;
oHead.appendChild(oScript);
}
}
else if ($("h_handle").value.trim() == "opseai") {
if (document.getElementById("opseae") == null) {
var url = "../js/MultipleSearchOpSeaiSource.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 = "opseae";
oScript.defer = true;
oScript.text = jsVal;
oHead.appendChild(oScript);
}
}
else if ($("h_handle").value.trim() == "opseailcl") {
if (document.getElementById("opseae") == null) {
var url = "../js/MultipleSearchOpSeaiLCLSource.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 = "opseaelcl";
oScript.defer = true;
oScript.text = jsVal;
oHead.appendChild(oScript);
}
}
else if($("h_handle").value.trim() == "multiplebusiness"){
if(document.getElementById("multiplebusiness") == null){
var url = "../js/MultipleSearchMultipleBusinessSource.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 = "multiplebusiness";
oScript.defer = true;
oScript.text = jsVal;
oHead.appendChild(oScript);
}
}
else if($("h_handle").value.trim() == "opseaetotalchart"){
if(document.getElementById("opseaetotalchart") == null){
var url = "../js/MultipleSearchOpSeaeTotalChartSource.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 = "opseaetotalchart";
oScript.defer = true;
oScript.text = jsVal;
oHead.appendChild(oScript);
}
}
}