preview.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. var code,
  2. pre_info,
  3. table_tp_id,
  4. question_info;
  5. mui.init();
  6. mui.plusReady(function(){
  7. var self = plus.webview.currentWebview();
  8. code = self.code;
  9. table_tp_id = self.table_tp_id;
  10. pre_info = self.info; //获取前一个页面修改后的信息
  11. if(self.question_info){
  12. question_info = self.question_info;
  13. for(i=0;i<question_info.length; i++){
  14. var item = question_info[i];
  15. if(!item.optionArr){
  16. question_info[i].optionArr = item.options;
  17. }
  18. }
  19. var html = template("question_tmp", {list: question_info});
  20. $("#question_list").empty().append(html);
  21. $("#group1").hide();
  22. $("#group2").show();
  23. }else{
  24. getDetail();
  25. $("#group1").show();
  26. $("#group2").hide();
  27. }
  28. bindEvents();
  29. });
  30. template.helper("setType", function(str){
  31. if(str == 0){
  32. return "单选";
  33. }
  34. if(str == 1){
  35. return "多选";
  36. }
  37. if(str == 2){
  38. return "填空";
  39. }
  40. return "";
  41. });
  42. function getDetail(){
  43. var url = "/doctor/questionnaire/getTemplateDetail",
  44. params = {code: code};
  45. sendGet(url, params, null, function(res){
  46. if(res.status == 200){
  47. question_info = res.data.questions; //保存当前模板中的问题信息
  48. for(i=0;i<question_info.length; i++){
  49. var item = question_info[i];
  50. if(!item.optionArr){
  51. question_info[i].optionArr = item.options;
  52. }
  53. }
  54. var html = template("question_tmp", {list: question_info});
  55. $("#question_list").empty().append(html);
  56. }else{
  57. mui.toast(res.msg);
  58. }
  59. }, true);
  60. }
  61. function bindEvents(){
  62. $("#edit_btn").on('click', function(){
  63. dialog({
  64. content: "该问卷问题包含逻辑跳转关系,继续修改则将删除所有逻辑跳转关系,且不可新增逻辑跳转。是否继续修改?",
  65. okValue: "继续修改",
  66. ok: function(){
  67. openWebview("edit_questions.html", {
  68. code: code,
  69. table_tp_id: table_tp_id,
  70. info: pre_info,
  71. question_info: question_info
  72. });
  73. },
  74. cancelValue: "我再看看",
  75. cancel:function(){}
  76. }).showModal();
  77. });
  78. $(".next_btn").on('click', function(){
  79. openWebview("choose_respondent.html", {
  80. code: code,
  81. pre_info: pre_info,
  82. question_info: question_info
  83. });
  84. });
  85. }