From b1abdbf7e9e6753662301816df1eb3ee0df69b9f Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Fri, 26 Jul 2013 10:43:30 +0000 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=86view=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2JS=EF=BC=8C=E4=BF=AE=E6=94=B9wsn=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=BA=A4=E6=8D=A2=E6=96=B9=E5=BC=8F=E4=B8=BA=E5=90=8E=E5=8F=B0?= =?UTF-8?q?CURL=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../default/controllers/DataController.php | 60 ++++++++++++- htdocs/js/lib/custom/models/dataservice.js | 89 +++++++++++++------ 2 files changed, 122 insertions(+), 27 deletions(-) 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 = '
' - + '' - + '
'; - return this.HTML; - }, - var : function(data){ - + this.input = new Array(); + for(i in data.data) + { + this.li = ''; + this.input.push(this.li); + } + this.HTML = '
' + + '' + + '
'; + return this.HTML; + }, + vars : function(data){ + this.input = new Array(); + for(i in data.data) + { + this.li = ''; + this.input.push(this.li); + } + this.HTML = '
' + + '' + + '
'; + return this.HTML; + } } } \ No newline at end of file