更新了view页面JS,修改wsn数据交换方式为后台CURL方式

This commit is contained in:
Li Jianxuan 2013-07-26 10:43:30 +00:00
parent 53c820faa0
commit b1abdbf7e9
2 changed files with 122 additions and 27 deletions

View File

@ -714,15 +714,73 @@ class DataController extends Zend_Controller_Action
$dataservice = new \data\DataService(); $dataservice = new \data\DataService();
$info = $dataservice->get($uuid); $info = $dataservice->get($uuid);
//暂时只有wsn //暂时只有wsn
{
$data = array( $data = array(
"type"=>"wsn", //服务类型 "type"=>"wsn", //服务类型
"info"=>$info, //信息 dataservice 表中的字段 "info"=>$info, //信息 dataservice 表中的字段
"callback"=>"" //成功后的js回调函数 "callback"=>"westdc.dataservice.wsn.request()", //成功后的js回调函数
); );
$data['data'] = $dataservice->getWsnData("site",$uuid);
if(empty($data['data']))
{
$this->jsonexit(array("error"=>'数据接口错误,请联系管理员'));
} }
if(!is_array($data['data']))
{
$this->jsonexit(array("error"=>$data['data']));
}
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$this->jsonexit($data);
}
// WSN end
}
public function wsnAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$uuid = $this->_getParam("uuid");
$sites = array("chk"=>$this->_getParam("siteid"));
$dataservice = new \data\DataService();
$info = $dataservice->get($uuid);
$dataservice = new \data\DataService();
$data = array(
"type"=>"wsn", //服务类型
"info"=>$info, //信息 dataservice 表中的字段
"callback"=>"alert('ok')", //成功后的js回调函数
);
$data['data'] = $dataservice->getWsnData("var",$uuid,$sites);
if(empty($data['data']))
{
$this->jsonexit(array("error"=>'数据接口错误,请联系管理员'));
}
if(!is_array($data['data']))
{
$this->jsonexit(array("error"=>$data['data']));
}
$this->jsonexit($data);
return true;
}
/* /*
getversionAction() 获取数据版本 getversionAction() 获取数据版本
*/ */

View File

@ -1,4 +1,5 @@
var dataservice = { var westdc = {};
westdc.dataservice = {
//wsn 选择数据 //wsn 选择数据
choiceData : function(uuid) choiceData : function(uuid)
{ {
@ -23,8 +24,8 @@ var dataservice = {
if(data.type == "wsn") if(data.type == "wsn")
{ {
html = dataservice.wsn.dialog.site(data); html = westdc.dataservice.wsn.dialog.site(data);
methods.creatWindow(id,html); westdc.dataservice.creatWindow(html);
} }
}, },
@ -54,26 +55,29 @@ var dataservice = {
} }
} }
dataservice.wsn = { westdc.dataservice.wsn = {
request : function() request : function()
{ {
$.ajax({ $.ajax({
'type':"POST", 'type':"POST",
'url':'/data/wsn/', 'url':'/data/wsn/',
'data':$('#wsn-form').serialize(), 'data':$('#dataservice-wsn-form').serialize(),
'success':function(data){ 'success':function(data){
if (typeof(data)=='object') if(typeof(data) == 'undefined')
{ {
if(typeof(data.error)!='undefined') alert("数据源错误,请联系管理员");
{alert(data.error);} return false;
if(typeof(data.success)!='undefined') }
if(!$.isEmptyObject(data.error))
{ {
window.location.reload(); alert(data.error);
} return false;
}
else{
alert('出现错误,请稍候再试');
} }
html = westdc.dataservice.wsn.dialog.vars(data);
westdc.dataservice.creatWindow(html);
}, },
'timeout': 30000, 'timeout': 30000,
'error': function(){ 'error': function(){
@ -83,17 +87,50 @@ dataservice.wsn = {
}, },
dialog : { dialog : {
site : function(data){ site : function(data){
this.input = new Array();
this.HTML = '<div class=""><div class="modal-header"><h3>选择观测点</h3></div>' for(i in data.data)
+ '<div class="modal-body"><form id="wsn-form">' {
+ '<div></div>' this.li = '<label class="checkbox">'
+ '<input type="hidden" name="uuid" value="'+data.uuid+'" />' + '<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>' + '</form></div>'
+ '<div class="modal-footer"><a href="javascript:void(0);" class="btn btn-primary confirm_yes" onclick=' + data.callback + '>下一步</a>' + '<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>'; + '<a href="javascript:void(0);" class="btn confirm_no">取消</a></div></div>';
return this.HTML; return this.HTML;
}, },
var : function(data){ vars : function(data){
this.input = new Array();
for(i in data.data)
{
this.li = '<label class="checkbox">'
+ '<input type="checkbox" value="' + data.data[i].varid + '" name="siteid[]" checked="checked" /> '
+ data.data[i].nameview
+ '</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.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;
} }
} }