diff --git a/application/default/controllers/DataController.php b/application/default/controllers/DataController.php index 422fdee2..2c5a5d6d 100755 --- a/application/default/controllers/DataController.php +++ b/application/default/controllers/DataController.php @@ -714,15 +714,73 @@ class DataController extends Zend_Controller_Action $dataservice = new \data\DataService(); $info = $dataservice->get($uuid); + //暂时只有wsn + { + $data = array( + "type"=>"wsn", //服务类型 + "info"=>$info, //信息 dataservice 表中的字段 + "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"=>"" //成功后的js回调函数 + "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() 获取数据版本 */ diff --git a/htdocs/js/lib/custom/models/dataservice.js b/htdocs/js/lib/custom/models/dataservice.js index 139fa790..99441dfc 100644 --- a/htdocs/js/lib/custom/models/dataservice.js +++ b/htdocs/js/lib/custom/models/dataservice.js @@ -1,4 +1,5 @@ -var dataservice = { +var westdc = {}; +westdc.dataservice = { //wsn 选择数据 choiceData : function(uuid) { @@ -23,8 +24,8 @@ var dataservice = { if(data.type == "wsn") { - html = dataservice.wsn.dialog.site(data); - methods.creatWindow(id,html); + html = westdc.dataservice.wsn.dialog.site(data); + westdc.dataservice.creatWindow(html); } }, @@ -54,26 +55,29 @@ var dataservice = { } } -dataservice.wsn = { +westdc.dataservice.wsn = { request : function() { $.ajax({ 'type':"POST", 'url':'/data/wsn/', - 'data':$('#wsn-form').serialize(), + 'data':$('#dataservice-wsn-form').serialize(), 'success':function(data){ - if (typeof(data)=='object') + if(typeof(data) == 'undefined') { - if(typeof(data.error)!='undefined') - {alert(data.error);} - if(typeof(data.success)!='undefined') - { - window.location.reload(); - } + alert("数据源错误,请联系管理员"); + return false; } - else{ - alert('出现错误,请稍候再试'); + + if(!$.isEmptyObject(data.error)) + { + alert(data.error); + return false; } + + html = westdc.dataservice.wsn.dialog.vars(data); + westdc.dataservice.creatWindow(html); + }, 'timeout': 30000, 'error': function(){ @@ -83,18 +87,51 @@ dataservice.wsn = { }, dialog : { site : function(data){ - - this.HTML = '