fenpeijianguanshi.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. //创建全局变量
  2. var obj ,p_aggregate, arr =[],singlepatiCode,docName;
  3. //创建节点变量并且赋值
  4. var $n_list = $('.n-list'),
  5. $makeSure = $('#makeSure');
  6. //mui 初始化
  7. mui.init();
  8. //文档就绪函数执行函数
  9. mui.plusReady(function(){
  10. //获取基本信息
  11. obj = pageInfo();
  12. //获取页面信息
  13. var self = plus.webview.currentWebview();
  14. //获取病人集合
  15. p_aggregate = self.residentArr;
  16. //获取单个病人
  17. singlepatiCode = self.patiCode;
  18. healthCode = self.healthAssistant;
  19. //初始化页面
  20. initpage();
  21. //事件执行函数
  22. bindEvent();
  23. })
  24. function pageInfo (){
  25. userInfo = JSON.parse(plus.storage.getItem('userAgent'));
  26. accountInfo = JSON.parse(plus.storage.getItem('docInfo'));
  27. return {
  28. dlxx :userInfo,
  29. docxx:accountInfo
  30. }
  31. }
  32. function initpage(){
  33. //获取所有健管师
  34. var url = '/doctor/specialist/findHealthAssistantPatientCount';
  35. var params = {
  36. doctor :obj.docxx.code
  37. }
  38. sendGet(url,params,null,function(res){
  39. if (res.status == 200) {
  40. for (var i in res.data){
  41. res.data[i].photo = getImgUrl(res.data[i].photo);
  42. }
  43. $n_list.html(template('health_care_manager',{list :res.data}))
  44. //遍历健管师的code 看看是否已经授权
  45. var nodeArr = $('.n-list').find('li');
  46. nodeArr.each(function(){
  47. var jgCode = $(this).attr('data-code');
  48. if(jgCode == healthCode){
  49. $(this).find('input[name=care_manager]').attr('checked','checked');
  50. docName = $(this).attr('data-name')
  51. }
  52. })
  53. } else{
  54. mui.toast(res.msg)
  55. }
  56. },'GET','',true)
  57. }
  58. function bindEvent(){
  59. $('#makeSure').on('tap', function(){
  60. //点击确定的时候判断是否选择了健管师
  61. var careManagerSum = $(".n-list input[name=care_manager]:checked");
  62. if(!(careManagerSum.length!=0)){
  63. dialog({
  64. contentType: 'tipsbox',
  65. skin: 'bk-popup',
  66. content: '请选择健管师!',
  67. closeTime: 2000
  68. }).showModal();
  69. return false
  70. }
  71. var manageUrl = '/doctor/specialist/saveHealthAssistant';
  72. var params = {
  73. json:JSON.stringify(arr)
  74. };
  75. plus.nativeUI.showWaiting();
  76. sendPost(manageUrl, params, null, function(res){
  77. if (res.status == 200) {
  78. plus.nativeUI.closeWaiting();
  79. var wv = plus.webview.getWebviewById('huanzhe-specal.html');
  80. if (wv) {
  81. mui.fire(wv,'refresh');
  82. }
  83. mui.toast("分配健管师成功");
  84. var lastWeb = plus.webview.getWebviewById("dingyibiaoqian");
  85. if(lastWeb) {
  86. lastWeb.close()
  87. }
  88. mui.back()
  89. } else{
  90. mui.toast(res.msg);
  91. }
  92. })
  93. })
  94. //点击选择健管师
  95. $('.n-list').on('tap', '.n-list-link input' , function(){
  96. var $that = $(this);
  97. var codeMiddle = $that.parent().parent().attr('data-code');
  98. var nameMiddle = $that.parent().parent().attr('data-name');
  99. if(p_aggregate){
  100. for(var i = 0;i<p_aggregate.length;i++){
  101. var changeObj = {};
  102. var code = p_aggregate[i].patient ;
  103. changeObj.doctor = obj.docxx.code;
  104. changeObj.patient = code ;
  105. changeObj.healthAssistant = codeMiddle ;
  106. changeObj.healthAssistantName = nameMiddle ;
  107. arr.push(changeObj);
  108. }
  109. return arr
  110. }else{
  111. //判断之前是否已经授权
  112. if(healthCode && codeMiddle!= healthCode){
  113. mui.confirm('您移除了'+docName+'居民管理权限,授予了'+nameMiddle+'居民管理权限,是否继续?','提示',["继续","不了"],function(e){
  114. if(e.index == 0){
  115. var changeObj = {};
  116. changeObj.doctor = obj.docxx.code;
  117. changeObj.patient = singlepatiCode;
  118. changeObj.healthAssistant = codeMiddle;
  119. changeObj.healthAssistantName = nameMiddle;
  120. arr.push(changeObj);
  121. return arr
  122. }else{
  123. $(".n-list input[name=care_manager]").removeAttr('checked');
  124. }
  125. })
  126. }else{
  127. var changeObj = {};
  128. changeObj.doctor = obj.docxx.code;
  129. changeObj.patient = singlepatiCode;
  130. changeObj.healthAssistant = codeMiddle;
  131. changeObj.healthAssistantName = nameMiddle;
  132. arr.push(changeObj);
  133. return arr
  134. }
  135. }
  136. })
  137. }