var TABLE_SEARCH_LIST={}; #在这里订单一个对象。所有方法都封装他内部。 obj.trader
TABLE_SEARCH_LIST.InstanceUrl = “/ops/hbase/table/manage/v2/list_instances.ajax”;
/**
* 点击事件
* @private
*/
TABLE_SEARCH_LIST._bind_event = function(){
/**
* 提交查询
*/
(‘#search-btn’).click(function(){
$(‘#searchForm’).submit();
});
/**
* 重置按钮
*/
(‘#search-btn’).click(function(){ $(‘#searchForm’).submit(); }); /** * 重置按钮 */
(‘#reset-btn’).click(function(){
("#tableName").val(
("#tableName").val(
(‘#DeftableName’).val());
tableNameSelect();
(“#rowKeyType”).select2(“val”, {
name : “string”,
value : “string”
});
(“#rowKeyType”).select2(“val”, { name : “string”, value : “string” });
(‘#startRowKey’).val(“”);
(‘#instanceId’).select2(“data”,null);
(‘#instanceId’).select2(“data”,null);
(‘#endRowKey’).val(“”);
(‘#startTime’).val(“”);
(‘#startTime’).val(“”);
(‘#endTime’).val(“”);
$(“#limit”).select2(“val”, {
name : “10”,
value : “10”
});
});
};
TABLE_SEARCH_LIST._init_form = function(){
function isEmptyObjectOPS(e) {
var t;
for (t in e)
return !1;
return !0
}
//$("#searchResult").attr("style", "height:400px !important;overflow:auto;");
$('#searchForm').validate({
errorElement: 'span',
errorClass: 'bdp-help-block',
focusInvalid: true,
invalidHandler: function (event, validator) {
$('.alert-danger', $('.login-form')).show();
},
highlight: function (e) {
//$(e).closest('.form-group').removeClass('bdp-has-info').addClass('bdp-has-error');
$(e).closest('.bdp-form-group').find(".bdp-form-control").removeClass('bdp-wrong').addClass('bdp-wrong');
},
success: function (e) {
//$(e).closest('.form-group').removeClass('bdp-has-error').addClass('bdp-has-info');
$(e).closest('.bdp-form-group').find(".bdp-form-control").removeClass('bdp-wrong');
$(e).remove();
},
submitHandler: function (form) {
if($("#tableName").val() == ""){
$("#tableName").get(0).focus();
$.bdpUtil.alertDialog($("#searchForm"), "表名不能为空");
return false;
}
var va = $("#startRowKey").val();
if(va == ""){
$("#startRowKey").focus();
$.bdpUtil.alertDialog($("#searchForm"), "StartKey不能为空");
return false;
}
$('#search-btn').addClass('disabled');
$('#searchForm').ajaxSubmit({
url: '/ops/hbase/table/manage/search/v2/search.ajax',
type: 'post',
dataType: 'json',
data:{
id:$("#tableIdForQuery").val()
},
success: function (json, statusText, xhr, $form) {
if(json.success){
$('#search-btn').removeClass('disabled');
$("#searchResult").empty();
if(isEmptyObjectOPS(json.data)){
$("#searchResult").append("未查到当前表数据");
}else{
$("#searchResult").append(json.data.result);
}
//$('#searchResult').html(json.data.result);
}else{
$.bdpUtil.alertDialog($("#searchForm"), json._msg);
$('#search-btn').removeClass('disabled');
}
$('#operPDIV').css('cursor', 'default');
},
error: function () {
$.bdpUtil.alertDialog($("#searchForm"), "表信息查询失败,请重试");
$('#search-btn').removeClass('disabled');
}
});
}
});
}
/**
* 初始化
* @private
*/
TABLE_SEARCH_LIST._init_base = function(){
tableNameSelect();
(‘#rowKeyType’).select2();
(‘#rowKeyType’).select2();
(‘#limit’).select2();
/**
* 日期控件
*/
(‘.date−picker′).datetimepicker(format:‘yyyy−mm−ddhh:ii:00′,language:‘zh−CN′,autoclose:true);
(
‘
.
d
a
t
e
−
p
i
c
k
e
r
′
)
.
d
a
t
e
t
i
m
e
p
i
c
k
e
r
(
f
o
r
m
a
t
:
‘
y
y
y
y
−
m
m
−
d
d
h
h
:
i
i
:
00
′
,
l
a
n
g
u
a
g
e
:
‘
z
h
−
C
N
′
,
a
u
t
o
c
l
o
s
e
:
t
r
u
e
)
;
(‘#startTime’).datetimepicker().on(‘changeDate’, function () {
var jobTimeBegin = (“#startTime”).val();
(“#startTime”).val();
(“#endTime”).datetimepicker(‘setStartDate’, jobTimeBegin);
(“#startTime”).datetimepicker(‘hide’);
});
var instanceId = “instanceId”;
var erp =
(“#startTime”).datetimepicker(‘hide’); }); var instanceId = “instanceId”; var erp =
(“#erp”).val();
var selectInstance = new SelectItem(instanceId);
selectInstance.init(TABLE_SEARCH_LIST.InstanceUrl,false,function(key){
var res ={};
if(!(key == null || key ==”“)){
res[‘key’] = key
}
if(!(erp == null || erp == “”)){
res[‘erp’] = erp
}
return JSON.stringify(res);
});
}
$(document).ready(function(){
TABLE_SEARCH_LIST._init_base();
TABLE_SEARCH_LIST._init_form();
TABLE_SEARCH_LIST._bind_event();
});