123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 |
- var self,
- pCodes,//总患者code
- doctorCode,
- type = 1,//血糖类型
- $xtUl = $('#xt-ul'),
- $xyUl = $('#xy-ul'),
- $scroll = $('#iScroll');
- /* 从慢病档案页面跳转过来新增的参数 start */
- var selectedTab,
- xtCode, //从前一个页面带过来的方案的code
- xyCode,
- comeFrom;
- /* 从慢病档案页面跳转过来新增的参数 end */
- mui.plusReady(function(){
- self = plus.webview.currentWebview();
- pCodes = self.pCodes;
- //添加type判断
- selectedTab = self.selectedTab || 1;
- xtCode = self.xtCode;
- xyCode = self.xyCode;
- comeFrom = self.comeFrom;
-
- doctorCode = JSON.parse(plus.storage.getItem("docInfo")).code;
- mui('.mui-scroll-wrapper').scroll({
- deceleration:0.0005
- })
-
- if(selectedTab == 2){
- $('#jc-Type li').removeClass("active");
- $('#jc-Type li:eq(1)').addClass("active");
- type=2
- $xyUl.show();
- $xtUl.hide();
- $('#xt-addBtn').hide()
- $('#xy-addBtn').show()
- }
- queryXTData()
- queryXYData()
- bindEvents()
- })
- function queryXTData(){
- plus.nativeUI.showWaiting();
- sendPost("doctor/scheme/get/bloodsugger/list",{doctorcode:doctorCode}, function(){
- plus.nativeUI.closeWaiting();
- mui.toast("请求失败");
- }, function(res){
- plus.nativeUI.closeWaiting();
- if(res.status == 200){
- //周日放后
- $.map(res.data,function(item,index){
- var list = item.list
- delete item.list
- var sunday =list[0]
- var arr = list.slice(1)
- arr.push(sunday)
- item['list']=arr
- })
- var html = template('xt_tmp',{data:$.map(res.data,function(o,i){
- o.jsonStr = JSON.stringify(o);
- o.canUpdate = true;
- o.isSelected = false;
- if(comeFrom == 'jumindangan'){
- o.canUpdate = false; //从居民慢病档案页面跳转过来的时候,不可以编辑
- }
- if(xtCode){
- if(xtCode == o.code){
- o.isSelected = true;
- }
- }
- return o
- })
- })
- $('#xt-ul').html(html)
- }
- },'get')
- }
- function queryXYData(){
- plus.nativeUI.showWaiting();
- sendPost("doctor/scheme/get/bloodpressure/list",{doctorcode:doctorCode}, function(){
- plus.nativeUI.closeWaiting();
- mui.toast("请求失败");
- }, function(res){
- plus.nativeUI.closeWaiting();
- if(res.status == 200){
- //周日放后
- $.map(res.data,function(item,index){
- var list = item.list
- delete item.list
- var sunday =list[0]
- var arr = list.slice(1)
- arr.push(sunday)
- item['list']=arr
- })
- var html = template('xy_tmp',{data:$.map(res.data,function(o,i){
- o.jsonStr = JSON.stringify(o);
- o.canUpdate = true;
- o.isSelected = false;
- if(comeFrom == 'jumindangan'){
- o.canUpdate = false; //从居民慢病档案页面跳转过来的时候,不可以编辑
- }
- if(xyCode){
- o.canUpdate = false;
- if(xyCode == o.code){
- o.isSelected = true;
- }
- }
- return o
- })
- })
- $('#xy-ul').html(html)
- }
- },'get')
- }
- function bindEvents(){
- //点击跳转
- $('#xt-addBtn').on('tap',function(){
- mui.openWindow({
- id: "jc-addxuetang",
- url: "jc-addxuetang.html",
- waiting:{autoShow:false},
- extras: {
-
- }
- })
- })
- //修改
- $scroll.on('tap','.j-revise',function(){
- var $that = $(this)
- if(type == 1){
- mui.openWindow({
- id: "jc-addxuetang",
- url: "jc-addxuetang.html",
- waiting:{autoShow:false},
- extras: {
- jsonStr:$that.parent().attr('data-json')
- }
- })
- }else{
- mui.openWindow({
- id: "jc-addxueya",
- url: "jc-addxueya.html",
- waiting:{autoShow:false},
- extras: {
- jsonStr:$that.parent().attr('data-json')
- }
- })
- }
- })
- $('#xy-addBtn').on('tap',function(){
- mui.openWindow({
- id: "jc-addxueya",
- url: "jc-addxueya.html",
- waiting:{autoShow:false},
- extras: {
-
- }
- })
- })
- //展开
- $scroll.on('tap','.fa-up',function(){
- var $this = $(this)
- if($this.hasClass('active')){
- $this.removeClass('active')
- $this.siblings('.fa-down').hide()
- }else{
- $this.addClass('active')
- $this.siblings('.fa-down').show()
- }
- })
- //选择
- $scroll.on('tap','.j-select',function(){
- var $this = $(this)
- var params={
- doctorcode:doctorCode,
- schemecode:$this.parent().attr('data-code'),
- type:type,
- patientcodes:pCodes.join(',')
- }
- plus.nativeUI.showWaiting()
- sendPost("doctor/scheme/post/save/patient/scheme",params, function(){
- plus.nativeUI.closeWaiting();
- mui.toast("请求失败");
- }, function(res){
- plus.nativeUI.closeWaiting();
- if(res.status == 200){
- mui.toast('设置成功')
- closePage()
- refreshHz()
- setTimeout(function(){
- mui.back();
- },500)
- }else{
- mui.toast('设置失败')
- }
- })
- })
- //切换类型
- $('#jc-Type').on('tap','li',function(){
- var $this = $(this)
- if(!$this.hasClass('active')){
- $this.addClass('active').siblings().removeClass('active');
- if($this.attr('data-type') == 1){
- type=2
- $xyUl.show();
- $xtUl.hide();
- $('#xt-addBtn').hide()
- $('#xy-addBtn').show()
- }else{
- type=1
- $xyUl.hide();
- $xtUl.show();
- $('#xy-addBtn').hide()
- $('#xt-addBtn').show()
- }
- }
- })
- }
- //刷新事件
- window.addEventListener("refreshData", function(){
- queryXTData()
- queryXYData()
- })
- //页面刷新
- function refreshHz(){
- var page = plus.webview.getWebviewById("manbingguanli");
- if(page){
- mui.fire(page, "refreshManBing")
- }
- //刷新居民档案页面的内容
- var wv = plus.webview.currentWebview().opener();
- if(wv){
- console.log("fire");
- mui.fire(wv, "reloadJiance");
- }
- //刷新页面,如果从重点跟踪页面过来,则需要将选择居民的页面也一起关闭
- var preOpener = wv.opener();
- if(preOpener.id == "zhongdiangenzong"){
- wv.close();
- //不需要刷新页面
- // mui.fire(preOpener);
- }
- }
- //关闭页面
- function closePage(){
- var last = plus.webview.getWebviewById("jc-xuanzejumin");
- if(last){
- last.close()
- }
- }
|