Distribution.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. var $dagou = $('.dagou'),
  2. // $team= $('.team'),
  3. $tuandui = $('.tuandui'),
  4. $msure_btn = $('#msure_btn'),
  5. arr = [],
  6. Arr = [],
  7. ArR,
  8. _name,
  9. sta = false;
  10. //获取登陆者信息;
  11. getBaseInfo = function() {
  12. var userAgent = JSON.parse(plus.storage.getItem("userAgent"));
  13. self = plus.webview.currentWebview();
  14. team_id = self.team_id;
  15. _codes = self.codes;
  16. codes = _codes.join(',');
  17. return {
  18. userAgent: userAgent,
  19. teamInfo: JSON.parse(plus.storage.getItem("teamInfo"))
  20. }
  21. }
  22. mui.plusReady(function() {
  23. var info = getBaseInfo();
  24. initPatientGroupsList();
  25. _Click();
  26. backParent();
  27. })
  28. // 处理页面点击事件
  29. function _Click() {
  30. $tuandui.on('click', '.team', function() {
  31. var id = $(this).attr('data-id');
  32. var currUl = $(this).next();
  33. var that = $(this);
  34. currUl.toggle();
  35. var a = that.find('.state').hasClass('_Photoone')
  36. var b = that.find('.state').hasClass('_photoone')
  37. if(a) {
  38. that.find('.state').removeClass('_Photoone')
  39. that.find('.state').addClass('_photoone')
  40. }
  41. if(b) {
  42. that.find('.state').removeClass('_photoone')
  43. that.find('.state').addClass('_Photoone')
  44. }
  45. //获取指定团队健管师的数目
  46. //url:GET /doctor/admin-teams/{team_id}/jgsmembers
  47. //入参:team_id
  48. var urL = 'doctor/admin-teams/' + id + '/jgsmembers';
  49. sendGet(urL, { team_id: id }, null, function(res) {
  50. if(res.status == 200) {
  51. console.log(res);
  52. arr = res.data; //健管师的数目
  53. var _html = template("qb_list_team", { slist: arr });
  54. currUl.empty().append(_html)
  55. }
  56. })
  57. })
  58. //点击选择打钩按钮
  59. $tuandui.on('click', 'li', function() {
  60. $(this).find('.dagou').toggleClass("photo");
  61. $tuandui.find('.dagou').not($(this).find('.dagou')).removeClass("photo");
  62. ///点击拿到医生的code 以进行确定点击进行传参
  63. ArR = $(this).attr('data-code');
  64. _name = $(this).attr('data-name');
  65. console.log(ArR)
  66. console.log(_name)
  67. })
  68. //确定的点击事件
  69. // 点击确定配置健管师
  70. //url:POST /doctor/prescriptionInfo/distributionHealthDoctor
  71. //入参codes :
  72. // healthdoctor:
  73. $msure_btn.on('click', function() {
  74. if(_name) {
  75. mui.confirm("是否确认将所选订单分配给" + _name + "配送", "", ["取消", "确定"], function(e) {
  76. if(e.index == 0) {
  77. } else if(e.index == 1) {
  78. var _url = 'doctor/prescriptionInfo/distributionHealthDoctor';
  79. sendPost(_url, { codes: codes, healthDoctor: ArR }, null, function(res) {
  80. if(res.status == 200) {
  81. console.log(res);
  82. mui.toast("已将所选订单分配给" + _name + "医生配送");
  83. setTimeout(function(){
  84. var old_back = mui.back;
  85. if(self.opener()){
  86. mui.fire(self.opener(), "refresh");
  87. }
  88. old_back();
  89. },1000)
  90. }
  91. })
  92. }
  93. })
  94. } else {
  95. mui.toast("请至少选择一位配送员");
  96. }
  97. })
  98. }
  99. //初始化页面
  100. function initPatientGroupsList() {
  101. //获取医生同社区底下所有团队建管师数目
  102. //url:GET /doctor/prescriptionInfo/getTeamHealthDoctorCount
  103. //入参 无;
  104. var zurl = 'doctor/prescriptionInfo/getTeamHealthDoctorCount';
  105. sendGet(zurl, {}, null, function(res) {
  106. if(res.status == 200) {
  107. console.log(res)
  108. Arr = res.data; //健管师的数目
  109. var html = template("dq_list_team", { list: Arr });
  110. $('.tuandui').append(html);
  111. if($tuandui.find(".team").length>0){
  112. $tuandui.find(".team").eq(0).trigger("click");
  113. }
  114. }
  115. })
  116. }
  117. // 返回刷新
  118. function backParent(){
  119. var old_back = mui.back;
  120. mui.back = function() {
  121. if(self.opener()){
  122. mui.fire(self.opener(), "refresh");
  123. }
  124. old_back();
  125. }
  126. }
  127. template.helper("setPhoto", function(p) {
  128. return getImgUrl(p);
  129. });