| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317 | 
							- mui.init();
 
- var scrollers = [],
 
-     page = [1,0,1], //主要存储个人和系统的模板分页信息
 
-     page1 = [], //存储团队模板中,各个团队对应的模板分页信息
 
-     loaded = [],
 
-     patient = null,
 
-     docInfo = null,
 
-     reference,
 
-     pagesize = 20,
 
-     pagesize2 = 10,
 
-     selectedTab = 0; //默认选中第一个tab
 
- mui.plusReady(function(){
 
-     var self = plus.webview.currentWebview();
 
-     var opener = self.opener();
 
-     if(opener.id == "mine.html"){
 
-         reference = "mine";
 
-     }
 
-     patient = self.code; 
 
-     
 
-     initScroller();
 
-     getList(true);
 
-     bindEvents();
 
- });
 
- function getList(isInit){
 
-     if(isInit){
 
-         page[selectedTab] = 1;
 
-     }
 
-     var url = "doctor/guidance_temp/list",
 
-         params = {
 
-             type: selectedTab == 0 ? 2 : 1, //模板类型 1:系统 2:自定义 为空:所有
 
-             pageNo: page[selectedTab],
 
-             pageSize: pagesize
 
-         },
 
-         filter = '';
 
-     if(selectedTab == 0){
 
-         filter = $("#item1 .search-input").val();
 
-     }else{
 
-         filter = $("#item3 .search-input").val();
 
-     }
 
-     params.filter = filter;
 
-     plus.nativeUI.showWaiting();
 
-     sendGet(url, params, null, function(res){
 
-         if(res.status == 200){
 
-             loaded[selectedTab] = true;
 
-             var $controlPanel = $("#item"+(selectedTab + 1)),
 
-                 $ul = $controlPanel.find("ul"),
 
-                 $noResult = $controlPanel.find(".no-result");
 
-             if(isInit){
 
-                 if(res.data.length == 0){
 
-                     $ul.hide();
 
-                     $noResult.show();
 
-                 }else{
 
-                     $ul.show();
 
-                     $noResult.hide();
 
-                     var html = template("guidance_tmp", {list: res.data});
 
-                     $ul.empty().append(html);
 
-                 }
 
-             }else{
 
-                 var html = template("guidance_tmp", {list: res.data});
 
-                 $ul.append(html);
 
-             }
 
-             if(res.data.length < pagesize){
 
-                 scrollers[selectedTab].endPullupToRefresh(true);
 
-             }else{
 
-                 scrollers[selectedTab].endPullupToRefresh(false);
 
-                 page[selectedTab] ++;
 
-             }
 
-         }else{
 
-             mui.toast(res.msg);
 
-         }
 
-         plus.nativeUI.closeWaiting();
 
-     }, true);
 
- }
 
- function getTeamInfo(){
 
-     var url = 'doctor/team/guidance/getDoctorTeams',
 
-         params = {
 
-             filter: $("#item2 .search-input").val()
 
-         }
 
-     plus.nativeUI.showWaiting();
 
-     sendGet(url, params, null, function(res){
 
-         if(res.status == 200){
 
-             var html = template('team-tmp', {list: res.teamList});
 
-             $(".team-group").empty().append(html);
 
-             page1 = [];
 
-             if(res.teamList.length > 0){
 
-                 for(i=0; i<res.teamList.length; i++){
 
-                     page1.push(1);
 
-                 }
 
-                 //展开第一个团队的数据
 
-                 getTeamTemplate(res.teamList[0].teamId, 0, true);
 
-             }
 
-         }else{
 
-             mui.toast(res.msg);
 
-         }
 
-         plus.nativeUI.closeWaiting();
 
-     }, true);
 
-     
 
- }
 
- function getTeamTemplate(teamId, index, isInit){
 
-     var url = "doctor/team/guidance/getTeamGuidanceList",
 
-         params = {
 
-             teamId: teamId,
 
-             pageNo: page1[index],
 
-             pageSize: pagesize2,
 
-             filter: $("#item2 .search-input").val()
 
-         };
 
-     plus.nativeUI.showWaiting();
 
-     sendGet(url, params, null, function(res){
 
-         if(res.status == 200){
 
-             var list = res.templateList,
 
-                 $panel = $(".data-panel").eq(index);
 
-             var html = template("team_guidance_tmp", {list: list});
 
-             if(isInit){
 
-                 if(list.length == 0){
 
-                     $panel.hide();
 
-                 }else{
 
-                     $panel.show();
 
-                     $panel.find("ul").empty().append(html);
 
-                 }
 
-             }else{
 
-                 $panel.find("ul").append(html);
 
-             }
 
-             if(list.length < pagesize2){
 
-                 $panel.find(".add-more").hide();
 
-             }else{
 
-                 $panel.find(".add-more").show();
 
-                 page1[index] ++;
 
-             }
 
-         }else{
 
-             mui.toast(res.msg);
 
-         }
 
-         plus.nativeUI.closeWaiting();
 
-     }, true);
 
- }
 
- //搜索提交请求
 
- function searchModel(type){
 
-     console.log(type);
 
-     if(type == 1 || type == 3){
 
-         getList(true);
 
-     }else{
 
-         getTeamInfo();
 
-     }
 
-     return false;
 
- }
 
- function bindEvents(){
 
-     document.querySelector('.mui-slider').addEventListener('slide', function(event) {
 
-         selectedTab = event.detail.slideNumber;
 
-         if(selectedTab != 1 && loaded[selectedTab] == "false"){
 
-             getList(true);
 
-             loaded[selectedTab] = "true";
 
-         }else if(selectedTab == 1 && loaded[selectedTab] == 'false'){
 
-             getTeamInfo();
 
-             loaded[selectedTab] = "true";
 
-         }
 
-     });
 
-     
 
-     //团队列表展开
 
-     $("#item2").on('tap', ".team-info", function(){
 
-         var $this = $(this),
 
-             code = $this.attr("data-code"),
 
-             index = $this.parent().index(),
 
-             $dataPanel = $this.parent().find(".data-panel"),
 
-             $arrow = $this.find(".fa");
 
-         if($arrow.hasClass("fa-caret-down")){
 
-             $arrow.removeClass("fa-caret-down");
 
-             $arrow.addClass("fa-caret-up");
 
-             if($dataPanel.find("li").length == 0){
 
-                 getTeamTemplate(code, index, true);
 
-             }else{
 
-                 $dataPanel.show();
 
-             }
 
-         }else{
 
-             $arrow.removeClass("fa-caret-up");
 
-             $arrow.addClass("fa-caret-down");
 
-             $dataPanel.hide();
 
-         }
 
-     });
 
-     //加载更多
 
-     $("#item2").on('tap', '.add-more', function(){
 
-         var $this = $(this),
 
-             $parent = $this.parent().parent(),
 
-             index = $parent.index(),
 
-             code = $parent.find(".team-info").attr("data-code");
 
-             
 
-         getTeamTemplate(code, index, false);
 
-     });
 
-     
 
-     //新增按钮
 
-     $(".add-icon").on("tap", function(){
 
-         var $this = $(this),
 
-             type = $this.attr("data-val");
 
-         if(type == "gr"){
 
-             openWebview('edit_guidance.html',{
 
-                 action: "add",
 
-                 reference: reference,
 
-                 patiCode: patient
 
-             });
 
-         }else if(type == "team"){
 
-             mui.openWindow('../html/bianjituanduimuban.html', 'bianjituanduimuban', {
 
-                 extras: {
 
-                     reference: reference,
 
-                     action: 'add',
 
-                     patiCode: patient
 
- //                  tName: me.tName,
 
- //                  tId: me.tId,
 
-                 }
 
-             });
 
-         }
 
-     });
 
-     
 
-     //查看文章详情
 
-     $("#item1").on('tap', 'li', function(){
 
-         var code = $(this).attr("data-code");
 
-         openWebview("guidance_detail.html",{
 
-             code: code, 
 
-             reference: reference, 
 
-             patiCode: patient
 
-         });
 
-     });
 
-     
 
-     $("#item2").on('tap', 'li', function(){
 
-         var $this = $(this),
 
-             code = $this.attr("data-code"),
 
-             $grantParent = $this.parent().parent().parent(),
 
-             $team = $grantParent.find(".team-info"),
 
-             tId = $team.attr("data-code"),
 
-             tName = $team.attr("data-name");
 
-         mui.openWindow('../html/chakantuanduimuban.html', 'chakantuanduimuban', {
 
-             extras: {
 
-                 reference: reference,
 
-                 action: 'add',
 
-                 code: code,
 
-                 tId: tId,
 
-                 tName: tName,
 
-                 is_sys: false,
 
-                 patiCode: patient
 
-             }
 
-         });
 
-     });
 
-     
 
-     $("#item3").on('tap', 'li', function(){
 
-         var code = $(this).attr("data-code");
 
-         openWebview("guidance_detail.html", {
 
-             code: code, 
 
-             reference: reference, 
 
-             patiCode: patient, 
 
-             is_sys: true
 
-         });
 
-     });
 
-     
 
-     //搜索功能
 
-     $(".search-input").on('keydown', function(e){
 
-         if (e.which === 13) {
 
-             if(selectedTab == 0 || selectedTab == 2){
 
-                 getList(true);
 
-             }else{
 
-                 getTeamInfo();
 
-             }
 
-         }
 
-     });
 
-     
 
-     //设置页面监听
 
-     window.addEventListener("refresh", function(e){
 
-         if(selectedTab == 0 || selectedTab == 2){
 
-             getList(true);
 
-         }else{
 
-             getTeamInfo();
 
-         }
 
-     })
 
- }
 
- function initScroller(){
 
-     $.each(document.querySelectorAll('.mui-slider-group .mui-scroll-wrapper'), function(index, pullRefreshEl) {
 
-         page.push(1);
 
-         loaded.push("false");
 
-         if(index == 1){
 
-             var pullRefresh = mui(pullRefreshEl).pullRefresh({
 
-                 down:{
 
-                     callback: function(){
 
-                         var self = this;
 
-                         setTimeout(function(){
 
-                             getTeamInfo();
 
-                             self.endPulldownToRefresh();
 
-                         }, 300);
 
-                     }
 
-                 }
 
-         });
 
-         }else{
 
-             var pullRefresh = mui(pullRefreshEl).pullRefresh({
 
-                 down:{
 
-                     callback: function(){
 
-                         var self = this;
 
-                         setTimeout(function(){
 
-                             getList(true);
 
-                             self.endPulldownToRefresh();
 
-                         }, 300);
 
-                     }
 
-                 },
 
-                 up: {
 
-                     callback: function(){
 
-                         var self = this;
 
-                         setTimeout(function(){
 
-                             getList(false);
 
-                         }, 300);
 
-                     }
 
-                 }
 
-             });
 
-         }
 
-         
 
-         scrollers.push(pullRefresh);
 
-     })
 
- }
 
 
  |