fp-xuanzejumin.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. var myScroll, searchIscroll, checked= {},
  2. docCode, teamCode, self, num = 0, curDocCode, isSearch;
  3. mui.plusReady(function(){
  4. self = plus.webview.currentWebview();
  5. docCode = self.docCode;
  6. teamCode = self.teamCode;
  7. curDocCode = getUid();
  8. myScroll = $('#lscroller .doc-list').lscroll({style: "top: 105px;bottom: 48px",
  9. pullUpAction: function(g){
  10. getDfpPatiLs(g.options.page);
  11. }
  12. });
  13. searchIscroll = $('#search_scroller').lscroll(
  14. {style: "top: 105px;bottom: 48px"});
  15. if(!teamCode){
  16. sendGet("/doctor/admin-teams/team/"+ curDocCode +"/team", {}, null, function(res){
  17. console.log(JSON.stringify(res))
  18. if(res.status == 200){
  19. teamCode = res.data.id;
  20. getDfpPatiLs(1);
  21. } else {
  22. mui.toast("获取团队长团队出错!");
  23. }
  24. })
  25. } else
  26. getDfpPatiLs(1);
  27. })
  28. template.helper("isChecked", function(code){
  29. if(checked[code])
  30. return "checked";
  31. })
  32. function getDfpPatiLs(page){
  33. plus.nativeUI.showWaiting();
  34. sendGet("/doctor/family_contract/findNoHealthSignFamilyHealth",
  35. {doctor: curDocCode, page: page, pageSize: 50}, null, function(res){
  36. if(res.status == 200){
  37. console.log(JSON.stringify(res))
  38. if(page==1 && (!res.data.list || res.data.list.length==0)){
  39. $('.checked-num').addClass('disabled');
  40. $('#wushuju').show();
  41. $('.lin-footer').hide();
  42. $('#lscroller').hide();
  43. } else {
  44. $('.checked-num').removeClass('disabled');
  45. $('#allSel').removeClass("checked").next().html("全选");
  46. var allPage = res.data.count;
  47. res.data = res.data.list;
  48. $('#lscroller .doc-list').append(template('pati_tmpl', res));
  49. myScroll.refresh(page >= allPage);
  50. }
  51. plus.nativeUI.closeWaiting();
  52. } else
  53. mui.toast(res.msg)
  54. })
  55. }
  56. function searchPatiLs(val){
  57. var url = "/doctor/family_contract/findNoHealthSignFamilyHealth";
  58. getReqPromises(
  59. [{url: url,data: {doctor: curDocCode, page: 1, pageSize: 3, patientName: val}},
  60. {url: url,data: {doctor: curDocCode, page: 1, pageSize: 3, patientAddr: val}}]
  61. ).then(function(data){
  62. if(data[0].status==200 && data[1].status==200){
  63. var rs = data[0].data;
  64. var hasRs = false;
  65. searchVal = val;
  66. var html = "";
  67. if(rs.list && rs.list.length>0){
  68. html = template("pati_tmpl", {data: rs.list, type: "sx"});
  69. $('#s-xm .doc-list').html(html_encode(html));
  70. $('#s-xm .jm-more').toggle(rs.count>1);
  71. $('#s-xm').show();
  72. hasRs = true;
  73. } else{
  74. $('#s-xm').hide();
  75. }
  76. rs = data[1].data;
  77. if(rs.list && rs.list.length>0){
  78. html = template("pati_tmpl", {data: rs.list, type: "sa"});
  79. $('#s-addr .doc-list').html(html_encode(html));
  80. $('#s-addr .jm-more').toggle(rs.count>1);
  81. $('#s-addr').show();
  82. hasRs = true;
  83. } else{
  84. $('#s-addr').hide();
  85. }
  86. $('.loading').hide();
  87. if(hasRs){
  88. $('#search_scroller').show();
  89. $('#wushuju1').hide();
  90. } else {
  91. $('#search_scroller').hide();
  92. $('#wushuju1').show();
  93. }
  94. searchIscroll.refresh();
  95. } else {
  96. mui.toast("查询数据失败!");
  97. }
  98. }).catch(function(e){
  99. mui.toast("查询数据失败!");
  100. console && console.error(e);
  101. })
  102. }
  103. function resetSearch(){
  104. isSearch = false;
  105. $delBtn.hide();
  106. $('#searchDiv').hide();
  107. $('#listDiv').show();
  108. $('.lin-footer').show();
  109. // $('#allSel').show().next().show();
  110. }
  111. var $delBtn = $('.u-icon-delete');
  112. var $searchIpt = $('.search-box input');
  113. $delBtn.on('tap', function(){
  114. $(this).hide();
  115. $searchIpt.val("");
  116. resetSearch()
  117. })
  118. $searchIpt.on('input', function(){
  119. var val = $.trim($(this).val()).replace(/\'/g,"");
  120. if(val.length==0){
  121. resetSearch();
  122. } else {
  123. isSearch = true;
  124. $delBtn.show();
  125. $('.lin-footer').hide();
  126. // $('#allSel').hide().next().hide();
  127. $('#wushuju1').hide();
  128. $('#listDiv').hide();
  129. $('#search_scroller').hide();
  130. $('.loading').show();
  131. $('#searchDiv').show();
  132. searchPatiLs(val);
  133. }
  134. })
  135. $('.jm-more').on('tap', function(){
  136. var type1 = $(this).attr('data-type');
  137. mui.openWindow({
  138. id: "fp-search-more.html",
  139. url: "fp-search-more.html",
  140. extras: {
  141. docCode: docCode,
  142. teamCode: teamCode,
  143. type: type1,
  144. num: num,
  145. checked: checked,
  146. val: $.trim($('.search-box input').val())
  147. }
  148. });
  149. })
  150. window.addEventListener("updateCheck", function(e){
  151. checked = e.detail.checked;
  152. num = e.detail.num;
  153. refreshTotal();
  154. $('.doc-item.checked').removeClass('checked')
  155. for(var k in checked){
  156. $('.doc-item[data-code="'+ k +'"]').addClass('checked');
  157. }
  158. })