123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- var baseInfo = null,// 基础环境信息(包括当前webview)
- teamCode,// 从缓存取出所选团队
- self,
- selectType,//类型
- teamInfo,
- docInfo;
-
- var $searchbar = $('.searchbar'),// 搜索框
- $searchbarInput = $('.searchbar .search-input'),// 搜索输入框
- $patiList = $('#pati_list'),// 患者分组列表
- $selectedTeamName = $('.demo-comtop h1');// 所选团队的团队名称显示位置
- // 获取登录相关信息
- var getBaseInfo = function() {
- self = plus.webview.currentWebview();
- docInfo = JSON.parse(plus.storage.getItem("docInfo"));
- teamInfo = JSON.parse(plus.storage.getItem("teamInfo"));
- teamCode = self.teamCode;
- selectType = self.selectType;
- },
- // 缓存中的团队
- setCurTeamName = function (){
- template.helper("setChecked", function(id, i) {
- if(teamCode && teamCode==id)
- return "checked";
- return "";
- });
- $('.lin-sel-group').html(template('teams_tmpl',teamInfo));
- $selectedTeamName.html(($('.lin-sel-group li.checked').attr('data-name'))+'慢病居民<label class="lin-down-arrow"></label>');
- },
- showGroupSel = function(e,isShow) {
- isShow = isShow || $('.lin-mask:hidden').length != 0;
- $('.lin-mask').toggle(isShow);
- $('.lin-sel-group').toggle(isShow);
- },
- // 初始化画面患者分组列表
- initPatientGroupsList = function(fun) {
- var url = "doctor/patient_label_info/label_patient_amount";
- plus.nativeUI.showWaiting();
- getReqPromise(url,{labelType: 3, teamCode: teamCode,isSlowDisease:true,diseaseCondition:selectType},'POST',true)
- .then(function(res) {
- plus.nativeUI.closeWaiting();
- if(res.status == 200) {
- var data = _.filter(res.data,function(o) {
- return o.labelCode != 0 || (o.labelCode==0 && o.amount > 0);
- })
- if(data && data.length>0) {
- var html = template("pati_group_tmpl", {list: data});
- $patiList.empty().append(html);
- //判断总数
- var allAmount = 0;
- $.map(data,function(item,i){
- allAmount += item.amount;
- })
- if(allAmount == 0){
- $('#no_result_wrap').show()
- }else{
- $('#no_result_wrap').hide()
- }
- }
- fun&&fun.call(this)
- }
- }).catch(function(e){
- plus.nativeUI.closeWaiting();
- console && console.error(e)
- })
- },
- showLoadMore = function($el) {
- var amount = $el.attr("data-amount"),
- loaded = $el.find('ul.n-list li').length,
- $loadMore = $el.find('.load-more');
- if(amount>loaded) {
- $loadMore.show();
- } else {
- $loadMore.hide();
- }
- },
- initPatientListByGroup = function(code) {
- var url = "doctor/patient_label_info/patients_by_label";
- var $group = $patiList.find('.patient-list[data-group="'+code+'"]');
- plus.nativeUI.showWaiting();
- getReqPromise(url, {labelType:3, teamCode: teamCode, labelCode: code, page: 1, pagesize: 30,isSlowDisease:true,diseaseCondition:selectType},'POST',true).then(function(res) {
- plus.nativeUI.closeWaiting();
- if(res.status == 200) {
- var html = template("pati_list_tmpl", {list: _.map(res.data,function(o) {
- o.jsonStr = JSON.stringify(o);
- return o;
- })});
- $group.find('ul.n-list').empty().append(html);
- showLoadMore($group);
- } else {
- mui.toast(res.msg);
- }
- }).catch(function(e){ console && console.error(e); plus.nativeUI.closeWaiting(); });
- },
- togglePatientListShow = function($el) {
- var isOpen = $el.hasClass("current"),
- $list = $el.find('ul.n-list'),
- $siblings = $el.siblings('.patient-list');
- if(isOpen) {
- $el.removeClass("current");
- $list.hide();
- $el.find('.load-more').hide();
- } else {
- $el.addClass("current");
- showLoadMore($el);
- $siblings.removeClass('current').find("ul.n-list").hide();
- $siblings.find('.load-more').hide();
- $list.show();
- }
- setTimeout(function(){
- mui('.mui-scroll-wrapper').scroll().scrollTo(0,0,0);
- },100)
- return isOpen;
- },
- refreshPage = function(fun){
- queryHeadData()
- initPatientGroupsList(fun);
- },
- // 绑定页面事件
- bindEvents = function () {
- $patiList.on('tap','.load-more',function() {
- plus.nativeUI.showWaiting();
- var $wrap = $(this).closest(".patient-list"),
- code = $wrap.attr("data-group"),
- page = parseInt($wrap.attr("data-page"));
- var url = "doctor/patient_label_info/patients_by_label";
- getReqPromise(url,{labelType: 3,labelCode: code, teamCode: teamCode, page: page + 1, pagesize: 30,isSlowDisease:true,diseaseCondition:selectType},'POST',true)
- .then(function(res) {
- if(res.status == 200) {
- var html = template("pati_list_tmpl", {list: _.map(res.data,function(o) {
- o.jsonStr = JSON.stringify(o);
- return o;
- })});
- $wrap.find('ul.n-list').append(html);
- $wrap.attr("data-page",page+1);
- showLoadMore($wrap);
- }
- plus.nativeUI.closeWaiting();
- }).catch(function(e){ console && console.error(e); plus.nativeUI.closeWaiting(); });
- return false;
- }).on('tap','.patient-list',function() {
- var code = $.trim($(this).attr("data-group")),
- isOpen = togglePatientListShow($(this)),
- isEmpty = !$(this).find('ul.n-list li').length;
- $patiList.find(".patient-type").css({position: "relative", top: "initial", "z-index": "initial"});
- code && !isOpen && isEmpty && initPatientListByGroup(code);
- }).on('tap','li[data-patient-code]',function(e) {
- var patiInfo = $(this).attr("data-json");
- var info = JSON.parse(patiInfo);
- mui.openWindow({
- id: "huanzhexinxi-mb",
- url: "../../huanzhe/html/huanzhexinxi.html",
- extras: {
- teamCode: teamCode,
- patiInfo: patiInfo,
- patiCode: info.code
- }
- })
- return false;
- })
-
-
- $selectedTeamName.on('tap', showGroupSel);
- $('.lin-sel-group').on('tap', 'li', function(){
- showGroupSel(undefined, false);
- if(!$(this).hasClass('checked')){
- $(this).addClass('checked').siblings().removeClass('checked');
- teamCode = $('.lin-sel-group li.checked').attr('data-code');
- refreshPage();
- setCurTeamName();
- }
- })
-
- $searchbarInput.on('tap',function() {
- mui.openWindow({
- id: "manbingjuminsousuo",
- url: "juminsousuo.html",
- extras: {
- teamCode:teamCode
- }
- })
- })
-
- //绿黄红标居民切换
- $('#peopleType li').eq(selectType).addClass('active');
- $('#peopleType').on('tap','li',function(){
- var that = $(this)
- if(!that.hasClass('active')){
- that.addClass('active').siblings().removeClass('active')
- selectType = that.attr('data-type')
- initPatientGroupsList();
- }
- })
- /*刷新事件*/
- window.addEventListener("refresh", function refresh(e) {
- $('.lin-mask').hide();
- $('.lin-sel-group').hide();
- refreshPage();
- })
- }
- function queryHeadData(){
- var params={
- teamCode:teamCode,
- getcolor:1,//是否获取颜色标签
- getstands:0,//是否获取预警人数
- gethealthindex:0,//获取体征数据
- }
- sendPost("doctor/patient_label_info/slowdisease/get/teaminfos",params, function(){
- mui.toast("请求失败");
- }, function(res){
- if(res.status == 200){
- $('#red').text(res.data.redcount)
- $('#yellow').text(res.data.yellowcount)
- $('#green').text(res.data.greencount)
- }else{
- mui.toast('获取数据失败')
- }
- },'get')
- }
- // 页面业务处理流程开始
- new Promise(function(resolve, reject) {
- mui.plusReady(function() {
- resolve(true);
- })
- }).then(function() {
- getBaseInfo();
- mui.init({
- pullRefresh : {
- container:'.mui-scroll-wrapper',
- down : {
- height:50,
- auto: false,
- contentdown : "下拉可以刷新",
- contentover : "释放立即刷新",
- contentrefresh : "正在刷新...",
- callback: function() {
- var self = this;
- refreshPage(function(){
- setTimeout(function(){
- self.endPulldownToRefresh(false);
- },500)
- })
- }
- }
- }
- })
- mui('.mui-scroll-wrapper').scroll()
- }).then(function() {
- setCurTeamName();
- bindEvents();
- queryHeadData()
- initPatientGroupsList()
- }).catch(function(e) {
- plus.nativeUI.closeWaiting();
- console && console.error(e);
- })
|