survey-detail.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. var request = getRequest(),
  2. prescriptionCode = request.prescriptionCode,
  3. fv_id = request.fv_id,
  4. type = request.type,
  5. state = request.state, //问卷状态
  6. project_id = request.projectId;
  7. var project_data = {};
  8. $(function(){
  9. if(state == 2){ //未填写
  10. $("#fvBtn").hide();
  11. }else{
  12. $("#fvBtn").show();
  13. }
  14. //获得模板中的数据显示
  15. var arr = project_id.split(",");
  16. for(i=0; i<arr.length; i++){
  17. $.extend(true, project_data, gTemplate[arr[i]]);
  18. }
  19. getDetail();
  20. bindEvents();
  21. });
  22. function getDetail(){
  23. var params = {
  24. prescriptioncode: prescriptionCode,
  25. followupProject: project_id
  26. };
  27. consultingAPI.getSurveyInfo(params).then(function(res){
  28. if(res.status == 200){
  29. for(key in project_data){
  30. project_data[key].value = res.data?res.data[key]:'';
  31. }
  32. var html = template("item", {
  33. data:project_data
  34. });
  35. $("#question_form .form-info").append(html);
  36. initChosen();
  37. }else{
  38. showErrorMsg(res.msg);
  39. }
  40. })
  41. }
  42. function initChosen(){
  43. $(".my_select_box").chosen({
  44. disable_search: true,
  45. inherit_select_classes: true, //将设定的样式添加到插件的控件中
  46. disable_search_threshold: 10,
  47. no_results_text: "",
  48. width: "100%"
  49. });
  50. }
  51. function bindEvents(){
  52. $("#backBtn").on('click', function(){
  53. history.go(-1);
  54. });
  55. $("#fvBtn").on('click', function(){
  56. var params = {
  57. followupid: fv_id,
  58. prescriptioncode: prescriptionCode,
  59. type: type
  60. };
  61. consultingAPI.importfollowupcontent(params).then(function(res){
  62. if(res.status == 200){
  63. showSuccessMsg("填入随访记录成功");
  64. setTimeout(function(){
  65. history.go(-1);
  66. }, 500);
  67. }else{
  68. showErrorMsg(res.msg);
  69. }
  70. });
  71. })
  72. }