123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293 |
- mui.init();
- var teamCode,
- docInfo,
- selectedType, //选中的总居民或近一周居民
- page1 = [], //总居民数分组中的分页信息
- page2 = [], //近一周新增居民中分组的分页信息
- pagesize = 10;
- var sdate = new Date(),
- edate = new Date();
- sdate.setDate(edate.getDate() - 6);
- sdate = sdate.format("yyyy-MM-dd");
- edate = edate.format('yyyy-MM-dd');
-
- mui.plusReady(function(){
- var self = plus.webview.currentWebview();
- docInfo = JSON.parse(plus.storage.getItem("docInfo"));
-
- teamCode = self.teamCode || docInfo.adminTeamCode;
- selectedType = self.selectType;
-
- if(selectedType == '0'){
- $(".all-people").addClass("active");
- $(".new-people").removeClass("active");
- }else{
- $(".new-people").addClass("active");
- $(".all-people").removeClass("active");
- }
- initScroller();
- initTeamInfo();
- getPeopleSum();
- getGroupInfo();
- bindEvents();
- });
- function initTeamInfo(){
- //设置团队
- var teamInfo = JSON.parse(plus.storage.getItem("teamInfo"));
-
- $('.lin-sel-group').html(template('teams_tmpl', teamInfo));
- var index =0;
- if(teamCode){
- for(var i=0;i<teamInfo.data.length;i++){
- if(teamInfo.data[i].id == teamCode){
- index = i;
- }
- }
- }
- $('.lin-sel-group li').eq(index).addClass('checked');
- setCurTeamName()
- }
- function getPeopleSum(){
- var url = "/doctor/scheme/getTrackPatientCountTitle",
- params = {
- teamCode: teamCode,
- startDate: sdate,
- endDate: edate
- };
- plus.nativeUI.showWaiting();
- sendGet(url, params, null, function(res){
- if(res.status == 200){
- $(".all-people .num").text(res.data.trackPatientCount);
- $(".new-people .num").text(res.data.trackPatientAddCount);
- }else{
- mui.toast(res.msg);
- }
- plus.nativeUI.closeWaiting();
- }, true);
- }
- function getGroupInfo(){
- var url = "doctor/patient_label_info/label_patient_amount",
- params = {
- labelType: 3,
- teamCode: teamCode,
- isSlowDisease: true,
- diseaseCondition: '',
- trackFlag: 1 // 重点关注居民
- };
- if(selectedType == '1'){
- params.startDate = sdate,
- params.endDate = edate;
- var $panel = $("#item2 .pati-list");
- }else{
- var $panel = $("#item1 .pati-list");
- }
- plus.nativeUI.showWaiting();
- sendGet(url, params, null, function(res){
- if(res.status == 200){
- page2 = [];
- page1 = [];
- for(i=0; i<res.data.length; i++){
- if(selectedType == '1'){
- page2.push(1);
- }else{
- page1.push(1);
- }
- }
- var html = template('pati_group_tmpl', {list: res.data});
- $panel.empty().append(html);
- if(selectedType == '1'){
- mui(".mui-slider").slider().gotoPage(1);
- }
- }else{
- mui.toast(res.msg);
- }
- plus.nativeUI.closeWaiting();
- }, true);
- }
- function getPatientListByGroup(index, code){
- var url = "doctor/patient_label_info/patients_by_label",
- params = {
- teamCode: teamCode,
- labelType: 3,
- labelCode: code,
- page: '',
- pagesize: pagesize,
- isSlowDisease:true,
- trackFlag: 1
- };
- if(selectedType == '1'){
- params.page = page2[index];
- params.startDate = sdate,
- params.endDate = edate;
- var $panel = $("#item2 .pati-list"),
- $group = $panel.find('.patient-list:eq('+index+')');
- }else{
- params.page = page1[index];
- var $panel = $("#item1 .pati-list"),
- $group = $panel.find('.patient-list:eq('+index+')');
- }
- sendGet(url, params, null, function(res){
- if(res.status == 200){
- if(res.data.length < pagesize){
- if(params.page == 1){
- $group.find(".load-more").hide();
- }else{
- $group.find(".load-more").attr("noMore", 'true').text("没有更多了");
- }
- }else{
- if(selectedType == '1'){
- page2[index] ++;
- }else{
- page1[index] ++;
- }
- $group.find(".load-more").show();
- }
- var html = template('pati_list_tmpl', {list: res.data});
- $group.find(".n-list").append(html);
- }else{
- mui.toast(res.msg);
- }
- plus.nativeUI.closeWaiting();
- }, true);
- }
- function setCurTeamName(){
- teamCode = $('.lin-sel-group li.checked').attr('data-code');
- $('.demo-comtop h1').html(($('.lin-sel-group li.checked').attr('data-name'))+'跟踪居民列表 <label class="lin-down-arrow"></label>');
- }
- /**
- * 显示团队选择
- */
- function showGroupSel(e, isShow){
- isShow = isShow || $('.lin-mask:hidden').length != 0;
- $('.lin-mask').toggle(isShow);
- $('.lin-sel-group').toggle(isShow);
- }
- function bindEvents(){
- $('.demo-comtop h1').on('tap', showGroupSel);
-
- $(".lin-sel-group").on('click', 'li', function(){
- showGroupSel(undefined, false);
- if(!$(this).hasClass('checked')){
- $(this).addClass('checked').siblings().removeClass('checked');
- setCurTeamName();
- }
- getPeopleSum();
- getGroupInfo();
- });
-
- //点击搜索跳转去搜索居民页面
- $(".search-input").on('click', function(){
- mui.openWindow({
- id: "manbingjuminsousuo",
- url: "juminsousuo.html",
- extras: {
- teamCode:teamCode,
- isTrack: true
- }
- })
- })
-
- //顶部切换
- $(".people").on('click', function(){
- var $this = $(this);
- if($this.hasClass("active")){
- return false;
- }
- if($this.hasClass("all-people")){
- selectedType = '0';
- $(".new-people").removeClass("active");
- $this.addClass("active");
- mui(".mui-slider").slider().gotoPage(0,100);
-
- }else{
- selectedType = '1';
- $(".all-people").removeClass("active");
- $this.addClass("active");
- mui(".mui-slider").slider().gotoPage(1, 100);
- }
- });
-
- document.querySelector('.mui-slider').addEventListener('slide', function(event) {
- var index = event.detail.slideNumber;
- if(index == 0){
- selectedType = '0';
- $(".all-people").addClass("active");
- $(".new-people").removeClass("active");
- }else if(index == 1){
- selectedType = '1';
- $(".new-people").addClass("active");
- $(".all-people").removeClass("active");
- }
- if($("#item"+(index+1)+" .patient-list").length == 0){
- getGroupInfo();
- }
- });
-
- $(".mui-slider").on('tap','.load-more',function(e) {
- e.stopPropagation();
- var $parent = $(this).parent(),
- group = $parent.data("group"),
- index = $parent.index();
- if($(this).attr("noMore") == 'true'){
- return false;
- }
- getPatientListByGroup(index, group);
-
- }).on('tap','.patient-type',function() {
- var $this = $(this),
- $parent = $this.parent(),
- group = $parent.data("group"),
- index = $parent.index(),
- $ul = $parent.find("ul"),
- $arrow = $this.find(".ui-arrow");
-
- if($arrow.hasClass("ui-arrow-b")){
- if($ul.find("li").length == 0){
- getPatientListByGroup(index, group);
- }
- $ul.show();
- $arrow.addClass("ui-arrow-t");
- $arrow.removeClass("ui-arrow-b");
- }else{
- $ul.hide();
- $arrow.addClass("ui-arrow-b");
- $arrow.removeClass("ui-arrow-t");
- }
-
- }).on('tap','li[data-patient-code]',function(e) {
- var patiCode = $(this).attr("data-patient-code");
- mui.openWindow({
- id: "jumin-manbingdangan",
- url: "jumin-manbingdangan.html",
- extras: {
- patient: patiCode
- }
- });
- return false;
- });
- }
- function initScroller(){
- //阻尼系数
- var deceleration = mui.os.ios?0.003:0.0009;
- mui('.mui-scroll-wrapper').scroll({
- bounce: false,
- indicators: true, //是否显示滚动条
- deceleration:deceleration
- });
- mui('.mui-scroll-wrapper').pullRefresh({
- down: {
- callback: function(){
-
- this.endPulldownToRefresh();
- }
- }
- });
- }
|