231 lines
7.1 KiB
JavaScript
231 lines
7.1 KiB
JavaScript
var westdc = {};
|
|
westdc.dataservice = {
|
|
//wsn 选择数据
|
|
choiceData : function(uuid,btn)
|
|
{
|
|
this.uuid = uuid;
|
|
_btn = {
|
|
html : $(btn).html(),
|
|
onclick : $(btn).attr('onclick')
|
|
};
|
|
|
|
$.ajax({
|
|
'type':"POST",
|
|
'url':'/data/dataservice',
|
|
'data':'uuid=' + this.uuid,
|
|
'success':function(data){
|
|
if(typeof(data) == 'undefined')
|
|
{
|
|
alert("数据源错误,请联系管理员");
|
|
return false;
|
|
}
|
|
|
|
if(!$.isEmptyObject(data.error))
|
|
{
|
|
alert(data.error);
|
|
return false;
|
|
}
|
|
|
|
if(data.type == "wsn")
|
|
{
|
|
html = westdc.dataservice.wsn.dialog.site(data);
|
|
westdc.dataservice.creatWindow(html);
|
|
}
|
|
|
|
},
|
|
'timeout': 30000,
|
|
'beforeSend': function(){
|
|
$(btn).attr('onclick','');
|
|
$(btn).html("加载中...");
|
|
$(btn).addClass('disabled');
|
|
},
|
|
'complete': function(){
|
|
$(btn).attr('onclick', _btn.onclick);
|
|
$(btn).html(_btn.html);
|
|
$(btn).removeClass('disabled');
|
|
},
|
|
'error': function(){
|
|
alert('出现错误,请刷新后重试');
|
|
}
|
|
});
|
|
|
|
},
|
|
creatWindow : function(html){
|
|
$.colorbox({
|
|
initialHeight: '0',
|
|
initialWidth: '0',
|
|
maxWidth : '80%',
|
|
html: html,
|
|
opacity: '0.3',
|
|
onComplete: function(){
|
|
$('.confirm_yes').click(function(e){
|
|
e.preventDefault();
|
|
});
|
|
$('.confirm_no').click(function(e){
|
|
e.preventDefault();
|
|
$.colorbox.close();
|
|
});
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
westdc.dataservice.wsn = {
|
|
request : function()
|
|
{
|
|
$.ajax({
|
|
'type':"POST",
|
|
'url':'/data/wsn/',
|
|
'data':$('#dataservice-wsn-form').serialize(),
|
|
'success':function(data){
|
|
if(typeof(data) == 'undefined')
|
|
{
|
|
alert("数据源错误,请联系管理员");
|
|
return false;
|
|
}
|
|
|
|
if(!$.isEmptyObject(data.error))
|
|
{
|
|
alert(data.error);
|
|
return false;
|
|
}
|
|
|
|
html = westdc.dataservice.wsn.dialog.vars(data);
|
|
westdc.dataservice.creatWindow(html);
|
|
westdc.dataservice.wsn._init.vars();
|
|
|
|
},
|
|
'timeout': 30000,
|
|
'error': function(){
|
|
alert('出现错误,请刷新后重试');
|
|
}
|
|
});
|
|
},
|
|
Submit : function(){
|
|
$.ajax({
|
|
'type':"POST",
|
|
'url':'/data/wsn/',
|
|
'data':$('#dataservice-wsn-form').serialize(),
|
|
'success':function(data){
|
|
if(typeof(data) == 'undefined')
|
|
{
|
|
alert("数据源错误,请联系管理员");
|
|
return false;
|
|
}
|
|
|
|
if(!$.isEmptyObject(data.error))
|
|
{
|
|
alert(data.error);
|
|
return false;
|
|
}
|
|
|
|
if($.isEmptyObject(data.data))
|
|
{
|
|
alert("提交失败,可能是服务器通信错误,请联系管理员");
|
|
return false;
|
|
}
|
|
|
|
if(data.data.success == 1)
|
|
{
|
|
window.location = '/data/order/ac/offline1';
|
|
return true;
|
|
}else{
|
|
alert('提交失败,请重试');
|
|
return false;
|
|
}
|
|
},
|
|
'timeout': 30000,
|
|
'error': function(){
|
|
alert('出现错误,请刷新后重试');
|
|
}
|
|
});
|
|
},
|
|
dialog : {
|
|
site : function(data){
|
|
this.input = new Array();
|
|
for(i in data.data)
|
|
{
|
|
this.li = '<label class="checkbox">'
|
|
+ '<input type="checkbox" value="' + data.data[i].siteid + '" name="siteid[]" checked="checked" /> '
|
|
+ data.data[i].sitename
|
|
+ '</label>';
|
|
this.input.push(this.li);
|
|
}
|
|
this.HTML = '<div class=""><div class="modal-header"><h3>'+data.info.service_title+'</h3></div>'
|
|
+ '<div class="modal-body"><form id="dataservice-wsn-form">'
|
|
+ '<div>请选择要下载数据的观测点</div>'
|
|
+ '<div>'
|
|
+ this.input.join("")
|
|
+ '</div>'
|
|
+ '<input type="hidden" name="uuid" value="'+data.info.uuid+'" />'
|
|
+ '<input type="hidden" name="type" value="var" />'
|
|
+ '</form></div>'
|
|
+ '<div class="modal-footer"><a href="javascript:void(0);" class="btn btn-primary confirm_yes" onclick=' + data.callback + '>下一步</a>'
|
|
+ '<a href="javascript:void(0);" class="btn confirm_no">取消</a></div></div>';
|
|
return this.HTML;
|
|
},
|
|
vars : function(data){
|
|
this.selects = "";
|
|
|
|
this.uls = new Array();
|
|
for(i in data.data)
|
|
{
|
|
this.input = new Array();
|
|
this.input.push('<label class="checkbox inline"><input type="checkbox" class="wsnctl-select-all" value="-1" name="site['+i+'][var]" checked="checked" /> 全选</label>');
|
|
for(x in data.data[i].var)
|
|
{
|
|
this.li = '<label class="checkbox inline">'
|
|
+ '<input class="wsnctl-select" type="checkbox" value="' + data.data[i].var[x]['varid'] + '" name="site['+i+'][var][]" checked="checked" disabled="disabled" /> '
|
|
+ data.data[i].var[x]['nameview']
|
|
+ '</label>';
|
|
this.input.push(this.li);
|
|
}
|
|
this.timemap = '<div class="wsnctl-time">数据时间范围: '
|
|
+ '<input class="wsnctl-timestart" type="text" name="site['+i+'][starttime]" value="' + data.data[i].starttime + '" /> - '
|
|
+ '<input class="wsnctl-timeend" type="text" name="site['+i+'][endtime]" value="' + data.data[i].endtime + '" />'
|
|
+ '</div>';
|
|
this.uls.push('<div class="wsnctl" rel="'+i+'" style="float:left"><h4>观测点:'+data.data[i].name+'</h4>可下载的变量: '+ this.input.join("") + this.timemap + '<hr /></div>');
|
|
}
|
|
|
|
this.selects = this.uls.join("");
|
|
|
|
this.HTML = '<div class=""><div class="modal-header"><h3>'+data.info.service_title+'</h3></div>'
|
|
+ '<div class="modal-body"><form id="dataservice-wsn-form">'
|
|
+ '<div>'
|
|
+ this.selects
|
|
+ '</div>'
|
|
+ '<input type="hidden" name="uuid" value="'+data.info.uuid+'" />'
|
|
+ '<input type="hidden" name="type" value="submit" />'
|
|
+ '</form></div>'
|
|
+ '<div class="modal-footer"><a href="javascript:void(0);" class="btn btn-primary confirm_yes" onclick=' + data.callback + '>提交</a>'
|
|
+ '<a href="javascript:void(0);" class="btn confirm_no">取消</a></div></div>';
|
|
return this.HTML;
|
|
}
|
|
},
|
|
_init : {
|
|
vars : function(){
|
|
$('.wsnctl').each(function(index, element) {
|
|
_this = $(this);
|
|
siteid = $(this).attr('rel');
|
|
timestart = $(this).children('.wsnctl-time').children('.wsnctl-timestart');
|
|
timeend = $(this).children('.wsnctl-time').children('.wsnctl-timeend');
|
|
year_start=(timestart).val().substr(0,4);
|
|
month_start=parseInt((timestart).val().substr(5,2))-1;
|
|
day_start=parseInt((timestart).val().substr(8,2));
|
|
year_end=(timeend.val()).substr(0,4);
|
|
month_end=parseInt((timeend.val()).substr(5,2))-1;
|
|
day_end=parseInt((timeend.val()).substr(8,2))
|
|
timestart.datepicker({ minDate: new Date(year_start, month_start, day_start), maxDate: new Date(year_end, month_end, day_end) });
|
|
timeend.datepicker({ minDate: new Date(year_start, month_start, day_start), maxDate: new Date(year_end, month_end, day_end) });
|
|
$(this).find('.wsnctl-select-all').click(function(e) {
|
|
if($(this).attr('checked') == 'checked')
|
|
{
|
|
$(this).parent('label').parent('div').find('.wsnctl-select').attr('disabled','disabled');
|
|
}else{
|
|
$(this).parent('label').parent('div').find('.wsnctl-select').removeAttr('disabled');
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
} |