123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291 |
- var myScroll, self, isSearch, cachePage, num = 0, checkeds = {},
- dataBack, tagInfo, teamCode, type,
- searchIscroll;
-
- mui.plusReady(function(){
- self = plus.webview.currentWebview();
- teamCode = self.teamCode;
- type = self.type;
- tagInfo = self.tagInfo;
- checkeds = self.checkeds;
- dataBack = self.dataBack;
- num = self.num || 0;
-
- $('.link').toggleClass('c-ccc', num<=0).find('label').html(num);
- $('h1').html(type == 'add'? "新增标签成员" : "删除标签成员");
- $('.header-link').toggle(type == 'add');
-
- myScroll = $('#tags_scroller').lscroll({
- top: 106,
- id: "tags_iscroll",
- pullUpAction: pullUpAction
- });
-
- searchIscroll = $('#search_scroller').lscroll({
- style: "top: 106px; display: none;",
- id: "search_iscroll",
- pullUpAction: pullUpAction
- });
-
- pullUpAction({options: {page: 1}})
- })
-
- var old_back = mui.back;
- mui.back = function(data) {
- if(dataBack){
- mui.fire(self.opener(), "updateTeamMember", {data: checkeds, num: num});
- old_back();
- } else if(!$('.link').hasClass('c-ccc')){
- mui.confirm("您有未保存的变动,是否保存?", "提示", ["不了", "保存"], function(e) {
- if(e.index == 0) {
- old_back();
- } else {
- submit(1);
- }
- })
- }else{
- old_back();
- }
- }
-
- template.helper("setChecked", function(code){
- if(checkeds[code])
- return "checked";
- return "";
- })
-
- template.helper("setDiseases", function(d, t){
- return setDiseases(d, t);
- })
-
- /**
- * 滚动翻页 (自定义实现此方法)
- */
- function pullUpAction (g) {
- if(isSearch){
- search(g.options.page);
- }else if(type == 'add')
- getPatiLs(g.options.page);
- else if(type == 'del')
- getTagPatiLs(g.options.page);
- }
-
- function search(page){
- var p = {teamCode: teamCode, pagesize: 50, page: page}
- p.filter = $.trim($('.search-box input').val());
-
- if(type == 'add' && !dataBack){
- p.exLabelCode = tagInfo.code;
- p.exLabelType = "4";
- }
- else if(type == 'del'){
- p.labelCode = tagInfo.code;
- p.labelType = "4";
- }
-
- sendPost("/doctor/patient_label_info/patient_search",
- p , null,
- function(res){
- $('.loading').hide();
- if(res.status==200){
- if(!res.data || res.data.length==0){
- if(page == 1){
- $('#wushuju1').show();
- $('#seachRs').hide().parent().next().hide();
- }
- else{
- searchIscroll.refresh(true);
- }
- }
- else{
- $('#wushuju1').hide();
- res.type = type;
- var html = template("pati_tmpl", res);
- if(page==1)
- $('#seachRs').html(html);
- else
- $('#seachRs').append(html);
- $('#seachRs').show().next().show();
- searchIscroll.refresh(false);
- }
- } else
- mui.toast(res.msg);
- })
-
- }
-
- function getPatiLs(page){
- plus.nativeUI.showWaiting();
- var p = {teamCode: teamCode, pagesize: 50, page: page}
- if(!dataBack){
- p.exLabelCode = tagInfo.code,
- p.exLabelType = "4"
- }
-
- sendPost("/doctor/patient_label_info/patients_by_team",
- p , null,
- function(res){
- if(res.status==200){
- if(!res.data || res.data.length==0){
- if(page == 1)
- $('#wushuju').show();
- else{
- myScroll.refresh(true);
- }
- }
- else{
- res.type = type;
- $('#list').append(template("pati_tmpl", res));
- myScroll.refresh(false);
- }
- } else
- mui.toast(res.msg);
- plus.nativeUI.closeWaiting();
- })
- }
-
- function getTagPatiLs(page){
- plus.nativeUI.showWaiting();
- var p = {
- teamCode: teamCode, pagesize: 50, page: page,
- labelCode: tagInfo.code, labelType: "4"
- }
-
- sendPost("/doctor/patient_label_info/patients_by_label",
- p , null,
- function(res){
- if(res.status==200){
- if(!res.data || res.data.length==0){
- if(page == 1)
- $('#wushuju').show();
- else{
- myScroll.refresh(true);
- }
- }
- else{
- res.type = type;
- $('#list').append(template("pati_tmpl", res));
- myScroll.refresh(false);
- }
- } else
- mui.toast(res.msg);
- plus.nativeUI.closeWaiting();
- })
- }
-
- /**
- * 完成
- */
- function submit(){
- if(num<=0)
- return;
-
- if(dataBack){
- mui.fire(self.opener(), "updateTeamMember", {data: checkeds, num: num});
- old_back();
- } else{
- plus.nativeUI.showWaiting();
- var patients = [];
- for(var k in checkeds){
- patients.push(k);
- }
-
- sendPost("/doctor/patient_label_info/patient_label_add", {
- labelCode: tagInfo.code,
- labelType: "4",
- patient: patients.join(",")
- }, null, function(res){
- if(res.status==200){
- mui.toast("保存成功!");
- old_back();
- } else
- mui.toast(res.msg);
- plus.nativeUI.closeWaiting();
- })
- }
- }
-
- $('.doc-list').on('tap', '.doc-item', function(){
- $(this).toggleClass('checked');
- var hasChecked = $(this).hasClass('checked');
- if(hasChecked){
- checkeds[$(this).attr('data-code')] = JSON.parse($(this).attr('data-info'));
- ++num;
- } else {
- delete checkeds[$(this).attr('data-code')];
- --num;
- }
- $('.link').toggleClass('c-ccc', num<=0).find('label').html(num);
-
- if(isSearch){
- var code = $(this).attr('data-code');
- $('#tags_iscroll .doc-item[data-code="'+ code +'"]').toggleClass('checked', hasChecked);
- }
- })
-
- var $tanLi, speed = 200;
- $('.doc-list').on('tap', '.lin-del-ico', function(){
-
- if($tanLi){
- $tanLi.animate({
- left: "0px"
- }, speed )
- }
-
- $(this).parent().parent().animate({
- left: "-70px"
- }, {speed: speed, step: function(){
- $('.l-scroller').css('left', '0');
- }, complete: function(){
- $tanLi = $(this);
- }})
-
- return false;
- })
-
- $('.doc-list').on('tap', '.list-del-box div', function(){
- var $li = $(this).closest("li");
- var code = $li.find(".doc-item ").attr('data-code');
- sendPost("/doctor/patient_label_info/patient_label_delete", {
- patient: code,
- labelCode: tagInfo.code,
- labelType: "4"
- }, null, function(res){
- if(res.status == 200){
- mui.toast("删除成功!");
- $li.remove();
- if(isSearch){
- $('#tags_iscroll .doc-item[data-code="'+ code +'"]').remove();
- }
- } else {
- mui.toast(res.msg);
- }
- })
- return false;
- })
-
- $(document).on('tap', function(){
- if($tanLi){
- $tanLi.animate({
- left: "0px"
- }, speed )
- }
- })
-
- $('.search-box input').on('input', function(){
- if($(this).val().length==0){
- isSearch = false;
- $('#tags_iscroll').show();
- $('#search_iscroll').hide();
- } else {
- $('#search_iscroll .pullUpLabel').html("上拉加载更多...").parent()
- .addClass('l-pullUp').removeClass('noMoreData');
- $('#wushuju1').hide();
- isSearch = true;
- $('#tags_iscroll').hide();
- $('.loading').show();
- $('#search_iscroll').show();
- searchIscroll.options.page = 1;
- pullUpAction({options: {page: 1}});
- }
- })
|