123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487 |
- mui.init();
- var scrollers = [],
- page = [1,0,1], //主要存储个人和系统的模板分页信息
- page1 = [], //存储团队模板中,各个团队对应的模板分组信息
- page2 = [], //存储团队模板中,各个团队对应的模板分页信息
- loaded = [],
- patient = null,
- docInfo = null,
- reference,
- pagesize = 20,
- pagesize2 = 10,
- selectedTab = 0; //默认选中第一个tab
- teamID = null,
- searchteamId = '',
- searchIndex = '',
- obj='';
- mui.plusReady(function(){
- var self = plus.webview.currentWebview();
-
- var opener = self.opener();
- if(opener.id == "mine.html"){
- reference = "mine";
- }
- patient = self.code;
- signCode = self.sign;
- obj = init();
- juageAdd();
- initScroller();
- getList(true);
- bindEvents();
- });
- //获取登陆者信息
- function init(){
- //登陆相关信息
- var userAgent = JSON.parse(plus.storage.getItem('userAgent'));
- //获取团队信息
- var teamInfo = JSON.parse(plus.storage.getItem('teamInfo'));
- var doctorInfo = JSON.parse(plus.storage.getItem("docInfo"));
- return{
- userAgent:userAgent,
- teamInfo:teamInfo,
- doctorInfo:doctorInfo
- }
-
- }
- //判断是否显示是否是团队长是否添加模板
- function juageAdd(){
- var docinfo = obj.doctorInfo;
- if (docinfo.isLeader!=1) {
- $('#item2').find('.add-icon').hide();
- return
- }
- }
- 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);
- }
- //展开第一个团队分组的数据
- searchteamId = res.teamList[0].teamId;
- searchIndex = 0;
- getlableGroup(res.teamList[0].teamId, 0, true);
-
- }
- }else{
- mui.toast(res.msg);
- }
- plus.nativeUI.closeWaiting();
- }, true);
-
- }
- //通过查询团队标签签过滤条件获取团队健康指导模板列表
- function getTeamInfoBySearch(index){
- var url = '/doctor/team/guidance/getTeamGuidanceListByLabelWithFilter',
- params = {
- teamId:searchteamId,
- filter: $("#item2 .search-input").val()
- }
- plus.nativeUI.showWaiting();
- sendGet(url, params, null, function(res){
- var arr =[]; var f_obj = {}; var s_obj={}; var name = [];
- if(res.status == 200){
- var data = res.data
- for(k in data) {
- // var obj= {};
- // obj.name = k;
- f_obj ={
- name :k
- }
- name.push(f_obj);
- for(var i = 0;i<data[k].length;i++){
- var fObj = {}
- fObj = $.extend({},data[k][i]);
- arr.push(fObj);
- }
- console.log(arr);
- }
- var html = template('search-lableGroups-tmp', {list: name});
- var htmlson = template('search-lableGroups-son-tmp', {listson: arr});
- $(".Group").eq(index).empty().append(html);
- // $(".Group").eq(index).find('.data-panel').removeClass('c-hide');
- $(".Group").eq(index).find('.data-panel').find('ul').append(htmlson)
-
- // page1 = [];
- // if(res.teamList.length > 0){
- // for(i=0; i<res.teamList.length; i++){
- // page1.push(1);
- // }
- // //展开第一个团队分组的数据
- // getlableGroup(res.teamList[0].teamId, 0, true)
- // }
- }else{
- mui.toast(res.msg);
- }
- plus.nativeUI.closeWaiting();
- }, true);
- }
- function getlableGroup(teamId, index, isInit){
- var url = "/doctor/guidance_temp/lable/findAllListByPage",
- params = {
- teamId: teamId,
- pageNo: page1[index],
- pageSize: pagesize2,
- };
- plus.nativeUI.showWaiting();
- sendGet(url, params, null, function(res){
- if(res.status == 200){
- var list = res.data,
- $panel = $('.team-info').eq(index).parent().find('.data-panel');
- var html = template("lableGroups-tmp", {list: list});
- page2 = [];
- if(res.data.length > 0){
- for(i=0; i<res.data.length; i++){
- page2.push(1);
- }
- }
- 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(".f-add-more").hide();
- }else{
- $panel.find(".f-add-more").show();
- page1[index] ++;
- }
- }else{
- mui.toast(res.msg);
- }
- plus.nativeUI.closeWaiting();
- }, true);
- }
- // 根据单个团队标签获取团队健康指导模板列表
- function getTeamTemplateList(teamId,index,code,elm,isInit){
- var url = "/doctor/team/guidance/getTeamGuidanceLabelList",
- params = {
- teamId: teamId,
- pageNo: page2[index],
- pageSize: pagesize2,
- labelCode:code
- };
- plus.nativeUI.showWaiting();
- sendGet(url, params, null, function(res){
- if(res.status == 200){
- var list = res.data,
- $panel = elm.parent().find(".data-panel");
- var html = template("team_guidance_tmp", {list: list});
- if(isInit){
- if(list.length == 0){
- $panel.hide();
- }else{
- $('.Group').find(".data-panel").hide();
- $('.Group').find(".fa").removeClass('fa-caret-up');
- $('.Group').find(".fa").addClass('fa-caret-right');
- elm.find('.fa').removeClass('fa-caret-right');
- elm.find('.fa').addClass('fa-caret-up');
- $panel.show();
- $panel.find("ul").empty().append(html);
- }
- }else{
- $panel.find("ul").append(html);
- }
- if(list.length < pagesize2){
- $panel.find(".s-add-more").hide();
- }else{
- $panel.find(".s-add-more").show();
- page2[index] ++;
- }
- }else{
- mui.toast(res.msg);
- }
- plus.nativeUI.closeWaiting();
- }, true);
- }
- //搜索提交请求
- function searchModel(type){
- if(type == 1 || type == 3){
- getList(true);
- }else{
- getTeamInfoBySearch(searchIndex);
- }
- 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");
- searchteamId = code;
- searchIndex= index;
- if($arrow.hasClass("fa-caret-down")){
- $arrow.removeClass("fa-caret-down");
- $arrow.addClass("fa-caret-up");
- if($dataPanel.find("li").length == 0){
- getlableGroup(code, index, true);
- }else{
- $dataPanel.show();
- }
- }else{
- $arrow.removeClass("fa-caret-up");
- $arrow.addClass("fa-caret-down");
- $dataPanel.hide();
- }
- });
- //加载更多标签分组
- $("#item2").on('tap', '.f-add-more ', function(){
- var $this = $(this),
- $parent = $this.parent().parent(),
- index = $parent.index(),
- code = $parent.find(".team-info").attr("data-code");
- getlableGroup(code, index, false);
- });
- //加载更多标签 分组对应单个团队模板列表
- $("#item2").on('tap','.Group .s-add-more', function(){
- var $this = $(this),
- $parent = $this.parent().parent(),
- index = $parent.index(),
- code = $parent.find(".lable-info").attr("data-code");
- teamId = $parent.parent().parent().parent().find(".team-info").attr("data-code");
- getTeamTemplateList(teamId,index,code,$parent,false);
- });
- // 根据单个团队标签获取团队健康指导模板列表
- $("#item2").on('tap', '.Group .lable-info', function(event){
- event.stopPropagation();
- var $this = $(this),
- code = $this.attr('data-code'),
- teamId =$this.parent().parent().parent().parent().find('.team-info').attr('data-code');
- index = $this.parent().index(),
- $dataPanel = $this.parent().find(".data-panel"),
- $arrow = $this.find(".fa");
- console.log(teamId);
- if($arrow.hasClass("fa-caret-right")){
- $arrow.removeClass("fa-caret-right");
- $arrow.addClass("fa-caret-up");
- if($dataPanel.find("li").length == 0){
- getTeamTemplateList(teamId,index,code,$this,true);
-
- }else{
- $dataPanel.show();
- }
- }else{
- $arrow.removeClass("fa-caret-up");
- $arrow.addClass("fa-caret-right");
- $dataPanel.hide();
- }
- });
- //新增按钮
- $(".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,
- sign:signCode
- });
- }else if(type == "team"){
- mui.openWindow('../html/bianjituanduimuban.html', 'bianjituanduimuban', {
- extras: {
- reference: reference,
- action: 'add',
- patiCode: patient,
- sign:signCode
-
- // 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,
- sign:signCode
- });
- });
-
- $("#item2").on('tap', 'li', function(){
- var $this = $(this),
- code = $this.attr("data-code"),
- $grantParent = $this.parent().parent().parent().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,
- sign:signCode
- }
- });
- });
-
- $("#item3").on('tap', 'li', function(){
- var code = $(this).attr("data-code");
- openWebview("guidance_detail.html", {
- code: code,
- reference: reference,
- patiCode: patient,
- is_sys: true,
- sign:signCode
-
- });
- });
-
- //搜索功能
- $(".search-input").on('keydown', function(e){
- if (e.which === 13) {
- if(selectedTab == 0 || selectedTab == 2){
- getList(true);
- }else{
- getTeamInfoBySearch(searchIndex);
- }
- }
- });
-
- //设置页面监听
- 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);
- })
- }
|