survey_info.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. var code,
  2. remind = true; //提醒状态,当反馈人数=调查总人数,提醒状态为false
  3. mui.init();
  4. mui.plusReady(function(){
  5. var self = plus.webview.currentWebview();
  6. code = self.code;
  7. getDetail();
  8. bindEvents();
  9. });
  10. function getDetail(){
  11. var url = "/doctor/questionnaire/getQuestionnaireSummary",
  12. params = {id: code};
  13. sendGet(url, params, null, function(res){
  14. if(res.status == 200){
  15. var status = res.data.status; //问卷状态 1正常 2暂停
  16. if(status == 1){
  17. $("#group1").show();
  18. $("#group2").hide();
  19. }else{
  20. $("#group2").show();
  21. $("#group1").hide();
  22. }
  23. if(res.data.complete == res.data.amount){
  24. remind = false;
  25. }else{
  26. remind = true;
  27. }
  28. $.extend(res.data.surveyTarget, {
  29. sex_text: res.data.surveyTarget.sex?res.data.surveyTarget.sex.join(""):"不限",
  30. healthCondition_text : res.data.surveyTarget.healthCondition?res.data.surveyTarget.healthCondition.join("、"):"不限",
  31. disease_text : res.data.surveyTarget.disease?res.data.surveyTarget.disease.join("、"):"不限",
  32. service_text : res.data.surveyTarget.service?res.data.surveyTarget.service.join("、"):"不限"
  33. });
  34. var html = template("info_tmp", res.data);
  35. $("#info_panel").empty().append(html);
  36. }else{
  37. mui.toast(res.msg);
  38. }
  39. }, true);
  40. }
  41. function changeStatus(status){
  42. plus.nativeUI.showWaiting();
  43. var url = "/doctor/questionnaire/modifyQuestionnaireStatus";
  44. sendGet(url, {id: code}, null, function(res){
  45. if(res.status == 200){
  46. if(status == 0){
  47. //停止调查
  48. $("#group1").hide();
  49. $("#group2").show();
  50. mui.toast("关闭问卷成功");
  51. }else{
  52. //启动调查
  53. $("#group2").hide();
  54. $("#group1").show();
  55. mui.toast("启动问卷成功");
  56. }
  57. }else{
  58. mui.toast(res.msg);
  59. }
  60. plus.nativeUI.closeWaiting();
  61. }, true);
  62. }
  63. function bindEvents(){
  64. $(".view-btn").on('click', function(){
  65. openWebview("survey_result.html", {code: code});
  66. });
  67. $(".remind-btn").on('click', function(){
  68. if(!remind){
  69. dialog({
  70. content: "所有居民均已反馈",
  71. okValue: "我知道了",
  72. ok: function(){},
  73. cancel: false
  74. }).showModal();
  75. }else{
  76. dialog({
  77. content: "是否提醒全部未作答居民?",
  78. okValue: "立即提醒",
  79. ok: function(){
  80. plus.nativeUI.showWaiting();
  81. var url = "/doctor/questionnaire/remindAnswer",
  82. params = {code: code};
  83. sendGet(url, params, null, function(res){
  84. if(res.status == 200){
  85. mui.toast(res.msg);
  86. //将反馈人数设置为调查人数
  87. }else{
  88. mui.toast(res.msg);
  89. }
  90. plus.nativeUI.closeWaiting();
  91. }, true);
  92. },
  93. cancelValue: "不了,谢谢",
  94. cancel: function(){}
  95. }).showModal();
  96. }
  97. });
  98. $(".stop-btn").on('click', function(){
  99. dialog({
  100. content: "是否确认停止调查?暂停后,居民将无法作答",
  101. okValue: "立即停止",
  102. ok: function(){
  103. changeStatus(0);
  104. },
  105. cancelValue: "不了,谢谢",
  106. cancel: function(){}
  107. }).showModal();
  108. });
  109. $(".start-btn").on('click', function(){
  110. dialog({
  111. content: "是否确认重新启动调查?启动后,居民将可继续作答",
  112. okValue: "立即启动",
  113. ok: function(){
  114. changeStatus(1);
  115. },
  116. cancelValue: "不了,谢谢",
  117. cancel: function(){}
  118. }).showModal();
  119. });
  120. $("body").on('click', '.view_detail', function(){
  121. openWebview("survey_detail.html", {code: code});
  122. });
  123. }