choose_doctor.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. var myScroll, jgs, docCode, self,teamId,typeId,group,sendCount,patients,type;
  2. var timeOut,timeOut1;
  3. mui.plusReady(function(){
  4. loaded();
  5. self = plus.webview.currentWebview();
  6. teamId = self.teamCode;
  7. typeId = self.typeId;//类型
  8. group = self.group;//分组
  9. sendCount = self.sendCount;//发送数
  10. patients = self.patients;//居民code集合
  11. type = self.type;//分配或转移
  12. docCode = self.docCode;//医生code
  13. $('.demo-comtop h1').html(type == "转移" ? "选择接收医生" : "分配居民-选择健管师");
  14. getJgs();
  15. })
  16. function getJgs(){
  17. plus.nativeUI.showWaiting();
  18. getReqPromises(
  19. [
  20. {url: "/doctor/admin-teams/"+ teamId +"/members", reqType: "GET"},
  21. {url: "/doctor/admin-teams/teams/"+ teamId +"/signing/count", reqType: "GET"}
  22. ]
  23. ).then(function(datas) {
  24. if(datas[0].status==200 && datas[1].status==200){
  25. jgs= [];
  26. $.each(datas[0].data, function(i, v) {
  27. v.qyzs = datas[1].data[v.code];
  28. if(self.level==2){
  29. if(v.level == 2){
  30. jgs.push(v);
  31. }
  32. } else {
  33. if(v.level == 3 || v.level == 2)
  34. jgs.push(v);
  35. }
  36. })
  37. initDocList();
  38. }else{
  39. mui.toast("获取成员数据失败!");
  40. }
  41. plus.nativeUI.closeWaiting();
  42. }).catch(function(e){
  43. mui.toast(e.msg);
  44. })
  45. }
  46. template.helper('isNotZyDoc', function(c){
  47. return c!=docCode;
  48. })
  49. function initDocList(){
  50. $('.doc-list').html(template('docs_tmpl', {data: jgs, code: docCode}));
  51. myScroll.refresh();
  52. }
  53. function loaded () {
  54. document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
  55. myScroll = new IScroll('#wrapper', { mouseWheel: true });
  56. }
  57. $('.doc-list').on('tap', '.doc-item', function(){
  58. if($(this).hasClass('checked'))
  59. return;
  60. $('.doc-item.checked').removeClass('checked');
  61. $(this).addClass('checked');
  62. $('.link').removeClass('c-ccc');
  63. })
  64. function submit(){
  65. var $dom = $('.doc-item.checked');
  66. if($dom.length<=0)
  67. return;
  68. var url = self.level==2? '/doctor/updateTeamDoctors' : '/doctor/allotOrMoveHealth';//2为全科
  69. var docName = $dom.attr('data-name');
  70. var tip = "是否确认将"+sendCount+"个居民"+type+"给"+ docName +"医生管理?";
  71. mui.confirm(tip, "提示", ["确定"+type, "不了,谢谢"], function(e){
  72. if(e.index == 0){
  73. plus.nativeUI.showWaiting();
  74. //搜索居民,分组选择居民方式
  75. if(patients){
  76. var p = {
  77. teamId: teamId,
  78. oldDoctorCode: docCode || "",
  79. newDoctorCode: $dom.attr('data-code'),
  80. patients: patients
  81. }
  82. sendMsg(url,p);
  83. }else{
  84. //分组选择居民方式(废弃)
  85. var p = {
  86. teamId: teamId,
  87. typeId:typeId,
  88. group:group,
  89. sendCount:sendCount*1,
  90. oldDoctorCode: docCode || "",
  91. newDoctorCode: $dom.attr('data-code'),
  92. }
  93. sendMsg(url,p);
  94. }
  95. }
  96. })
  97. }
  98. function backIndex(){
  99. refreshHz();
  100. var last = plus.webview.getWebviewById("zhuanyijumin_search"); //删掉搜索页面
  101. if(last){
  102. last.close('none');
  103. }
  104. var last1 = plus.webview.getWebviewById("zhuanyijumin");
  105. if(last1){
  106. last1.close('none');
  107. }
  108. var lay = plus.webview.getWebviewById("zyjm-layer.html");
  109. if(lay){
  110. lay.close('none');
  111. }
  112. var last2 = plus.webview.getWebviewById("qianyuejumin");
  113. if(last2){
  114. last2.close('none');
  115. }
  116. var last3 = plus.webview.getWebviewById("zuyuanziliao");
  117. if(last3){
  118. last3.close('none');
  119. }
  120. mui.back();
  121. }
  122. function sendMsg(url,p){
  123. sendPost(url, p, function(res){
  124. plus.nativeUI.closeWaiting();
  125. window.clearTimeout(timeOut);
  126. window.clearTimeout(timeOut1);
  127. mui.toast(res.msg);
  128. }, function(res){
  129. plus.nativeUI.closeWaiting();
  130. window.clearTimeout(timeOut);
  131. window.clearTimeout(timeOut1);
  132. if(res.status==200){
  133. mui.toast("成功"+type+"居民");
  134. backIndex();
  135. }else{
  136. mui.toast(res.msg);
  137. }
  138. }, "POST", 600000)
  139. //如果是观察者模式,则不开始计时器的计算
  140. var userAgent = JSON.parse(plus.storage.getItem("userAgent"));
  141. if(!userAgent.observer){
  142. timeOut = setTimeout(function(){
  143. plus.nativeUI.closeWaiting();
  144. dialog({
  145. content: '<div class="c-f16 c-323232">后台正在处理您的请求,结束后将自动跳转,您可先处理其他事宜</div>',
  146. okValue: '继续等待',
  147. cancelValue: '返回首页',
  148. cancel: function () {
  149. backIndex();
  150. },
  151. ok: function() {
  152. plus.nativeUI.showWaiting();
  153. againLoad();
  154. }
  155. }).showModal();
  156. },30000)
  157. }
  158. }
  159. function againLoad(){
  160. timeOut1 = setTimeout(function(){
  161. plus.nativeUI.closeWaiting();
  162. dialog({
  163. content: '<div class="c-f16 c-323232">后台正在处理</div>',
  164. okValue: '继续等待',
  165. cancelValue: '返回首页',
  166. cancel: function () {
  167. backIndex();
  168. },
  169. ok: function() {
  170. plus.nativeUI.showWaiting();
  171. againLoad()
  172. }
  173. }).showModal();
  174. },30000)
  175. }
  176. function refreshHz(){
  177. var page1 = plus.webview.getWebviewById("huanzhe.html");
  178. if(page1){
  179. mui.fire(page1, "refreshWfp");
  180. }
  181. }