function dmaThermalsearch() {
//DMA 查询条件 DMA NO实时搜索
$("#area-type-name").bind('input propertychange', function () {
var type = $("#area-type-name").attr('name');
var value = $("#area-type-name").val();
$("#dmaNo-list1").empty();//置空
//模糊搜索DmaNo
var td = "";
var oneRegion = $("#one_region").val();
var twoSection = $("#two_section").val();
if( oneRegion != "" && oneRegion != null){
td = oneRegion;
}
if(twoSection != "" && twoSection != null){
td = twoSection;
}
getDmaNoList({
'zoneNo': td,
'zoneType': 3
}, 1);
var isHasChild = $("#dmaNo-list1").children(".dmaNo-list-dd1");
if (isHasChild.length > 0) {
$("#dmaNo-list1").show();
} else {
$("#dmaNo-list1").hide();
}
});
$("#dmaNo-list1").delegate(".dmaNo-list-dd1", "click", function () {
var n = $(this).index();
var name = $(".dmaNo-list-dd1").eq(n).html();
var v = $(".dmaNo-list-dd1").eq(n).attr("value");
$("#area-type-name").val(name);//显示选中的结果
$("#area-type-name").attr("data-val",v);//显示选中的结果
$("#dmaNo-list1").hide();
});
/* $("#icon-search-map").unbind('click').click((evt)=>{
getDmaNoMapLayerData('#input-search-id',[])
}) */
//点击页面收起热搜索下拉框
$(document).click(function () {
$("#dmaNo-list1").hide();
$("#dmaNo-list2").hide();
});
}
/**
* 模糊搜索DmaNo接口
*/
function getDmaNoList(param, id) {
request({
url: baseUrl + 'commonController/queryFuzzyZoneInfo.htm',
data: JSON.stringify(param),
method: "POST",
dataType: "JSON",
isJson: true,
async: false,
success: function (data) {
console.log(data)
if (!data) {
return
}
if(data.data){
var dataInfo = data.data;
console.log(dataInfo)
for (var i = 0; i < dataInfo.length; i++) {
$("#dmaNo-list" + id).append('<dd class="dmaNo-list-dd' + id + '" value="' + dataInfo[i].zoneNo + '">' + dataInfo[i].zoneName + '</dd>');
}
}
}
});
}
/**
* ajax调用
*
* @param url
* 链接地址
* @param data
* 数据
* @param success
* 请求成功回调函数
* @param error
* 请求失败回调函数
* @param method
* 调用方法,默认为post
* @param isJson
* 是否发送json格式
* @param dataType
* 返回参数类型,默认为json
* @param async
* 同步/异步类型
*/
function request(_ref) {
var url = _ref.url,
data = _ref.data,
_success = _ref.success,
error = _ref.error,
method = _ref.method,
dataType = _ref.dataType,
isJson = _ref.isJson,
async = _ref.async,
timeout = _ref.timeout;
if (method == null) {
// 默认post方式
method = "post";
}
if (dataType == null) {
// 默认json数据类型
dataType = "json";
}
if (async == null) {
// 默认同步
async = true;
}
if (error == null) {
// 默认输出错误日志
error = ajaxError;
}
var defaultOpt = {
url: url,
// dataType: dataType,
type: method,
data: data,
async: async,
contentType: isJson ? 'application/json; charset=UTF-8' : 'application/x-www-form-urlencoded; charset=UTF-8',
traditional: true,
timeout: timeout ? timeout : 20000,
xhrFields: {
withCredentials: true
},
headers: {
'X-Requested-With': 'XMLHttpRequest'
},
success: function success(data) {
if (data.code >= 10000 && data.code < 11000) {
// 未登录,则返回登录界面
var backLogin = sessionStorage.getItem('tId');
if (data.code == 10000) {
top.location.href = top.location.href.replace('layout/index.html', 'login.html?tenantID=' + backLogin);
return;
}
}
if (_success) _success(data);
},
complete: function complete(XMLHttpRequest, status) {
if (status == 'timeout') {
layer.msg(getString('comn_request_overtime'), {
icon: 2,
time: 2000 //2秒关闭(如果不配置,默认是3秒)
}, function () {//do something
});
}
updateHtml();
},
error: error
};
if (window.sessionKey != null) {
defaultOpt.headers['Authorization'] = window.sessionKey;
}
$.ajax(defaultOpt);
}
网友评论