Нет описания

accessRegister.js 9.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. var custelid = helper.request.queryString("custelid"); //随访记录id
  2. var name = decodeURI(helper.request.queryString("name")); //姓名
  3. var phone = helper.request.queryString("phone"); //联系人电话
  4. var address = decodeURI(helper.request.queryString("address")); //地址
  5. var ans = []; //问题答案
  6. $(document).ready(function() {
  7. $("#order_details ul li").click(function() {
  8. $(this).addClass("Active").siblings().removeClass("Active");
  9. var tabindex = $(this).index();
  10. $(".gdxq").hide();
  11. $(".gdxq").eq(tabindex).show();
  12. if(tabindex === 0) {
  13. } else if(tabindex > 0 && tabindex < 4) {
  14. } else if(tabindex === 4) {
  15. }
  16. });
  17. // 随访结果id
  18. getAccessResult();
  19. $(".search-questionnaire-detail").on("click", function(){
  20. getQuestionnaireDetail();
  21. })
  22. getQuestionnaireInformation();
  23. // XQ();
  24. // if(wid != null && wid != undefined && wid != "") {
  25. // XQ();
  26. // }
  27. })
  28. // 获取问卷信息
  29. function getQuestionnaireInformation(){
  30. $.ajax({
  31. type: "get",
  32. dataType: "json",
  33. url: huayi.config.callcenter_url + "Questionnaire/GetPagerInfoList",
  34. data: {
  35. PageIndex: 1,
  36. PageSize: 300,
  37. },
  38. asnyc: true,
  39. success: function(result) {
  40. var data = result.rows;
  41. $(data).each(function(i, n) {
  42. $("#selectQuesInformation").append("<option value='"+ n.F_PagerId +"'>"+ n.F_Title +"</option>")
  43. })
  44. }
  45. })
  46. }
  47. // 获取问卷详情
  48. function getQuestionnaireDetail() {
  49. $(".questionnaire-detail").show();
  50. $(".Qus_box").empty();
  51. // $(".tbody").empty();
  52. $.ajax({
  53. type: "get",
  54. url: huayi.config.callcenter_url + "/Questionnaire/GetPagerInfoQ",
  55. async: true,
  56. dataType: "json",
  57. data: {
  58. pid: $("#selectQuesInformation").val(),
  59. token: $.cookie("token"),
  60. },
  61. success: function(data) {
  62. if(data.state.toLowerCase() == 'success') {
  63. $('.Title').text(data.data.F_Title);
  64. $("#F_Remark").text(data.data.F_Remark);
  65. $("#startText").text(data.data.F_StartText);
  66. $("#endText").text(data.data.F_EndText);
  67. var Questions = data.data.F_Questions;
  68. var html = '';
  69. for(var i = 0; i < Questions.length; i++) {
  70. var questype = Questions[i].questype;
  71. var Quesid = Questions[i].quesid;
  72. var quesremark = Questions[i].quesremark; //试题说明
  73. if(quesremark) {
  74. quesremark = ' 【' + quesremark + '】';
  75. } else {
  76. quesremark = "";
  77. }
  78. html += '<li class="" name="ltype' + Quesid + '" >';
  79. html += '<div class="Back ">';
  80. html += '<h3 class="size-14 QuesTitle" indexs="' + Questions[i].quesid + '">' + Questions[i].questitle + quesremark + ' </h3>';
  81. html += '</div>';
  82. //判断类型
  83. if(questype == 2) {
  84. //选项
  85. if(Questions[i].quesitems.length > 0) { //单选
  86. html += '<div class="radio clearfix" name="ltype' + Quesid + '" indexs="' + Questions[i].quesid + '">';
  87. var quesitems = Questions[i].quesitems;
  88. html += '<ul class="Ul">'
  89. for(var j = 0; j < quesitems.length; j++) {
  90. html += '<li>'
  91. html += '<label style="font-weight: normal;">'
  92. html += '' + (j + 1) + '.';
  93. html += '<input type="radio" index_="' + quesitems[j].itemid + '" value="' + quesitems[j].itemid + '" name="ltype' + Quesid + '" style="margin-left:5px;"> <span>' + quesitems[j].itemname + '</span></label>'
  94. html += '</li>'
  95. }
  96. html += '</ul>'
  97. html += '</div>'
  98. html += '</li>'
  99. }
  100. } else if(questype == 1) {
  101. //问答题
  102. html += '<div class="Wd" indexs="' + Questions[i].quesid + '">';
  103. html += '<textarea class="Wds" index="' + Questions[i].quesid + '"name="" rows="" cols="" style="width: 100%;"></textarea>'
  104. html += '</div>'
  105. } else {
  106. if(Questions[i].quesitems.length > 0) { //多选
  107. html += '<div class="checkbox clearfix" name="ltype' + Quesid + '" indexs="' + Questions[i].quesid + '">';
  108. html += '<ul class="Ul">'
  109. var quesitems = Questions[i].quesitems;
  110. for(var j = 0; j < quesitems.length; j++) {
  111. html += '<li>'
  112. html += '<label style="font-weight: normal;">'
  113. html += '' + (j + 1) + '.';
  114. html += '<input type="checkbox" index_="' + quesitems[j].itemid + '" value="' + quesitems[j].itemid + '" name="ltype' + Quesid + '" ><span> ' + quesitems[j].itemname + '</span></label>'
  115. //html += '<input type="checkbox" index_="' + quesitems[j].itemid + '" value="' + quesitems[j].itemid + '" name="ltype' + Quesid + '" > ' + quesitems[j].itemname + '</label>'
  116. html += '</li>'
  117. }
  118. html += '</ul>';
  119. html += '</div>'
  120. html += '</li >';
  121. }
  122. }
  123. }
  124. $(html).appendTo(".Qus_box");
  125. // autosize($('textarea'));
  126. }
  127. }
  128. });
  129. }
  130. // 获取问卷详情
  131. // function getQuestionnaireDetail() {
  132. // $(".questionnaire-detail").show();
  133. // $(".Qus_box").empty();
  134. // $.ajax({
  135. // type: "get",
  136. // url: huayi.config.callcenter_url + "/Questionnaire/GetPagerInfoQ",
  137. // async: true,
  138. // dataType: "json",
  139. // data: {
  140. // pid: $("#selectQuesInformation").val(),
  141. // token: $.cookie("token"),
  142. // },
  143. // success: function(data) {
  144. // if(data.state.toLowerCase() == 'success') {
  145. // $('.Title').text(data.data.F_Title);
  146. // $("#F_Remark").text(data.data.F_Remark);
  147. // $("#startText").text(data.data.F_StartText);
  148. // $("#endText").text(data.data.F_EndText);
  149. // var Questions = data.data.F_Questions;
  150. // var html = '';
  151. // for(var i = 0; i < Questions.length; i++) {
  152. // var questype = Questions[i].questype;
  153. // var Quesid = Questions[i].quesid;
  154. // var quesremark = Questions[i].quesremark;//试题说明
  155. // if(quesremark){
  156. // quesremark = ' 【' + quesremark +'】';
  157. // }else{
  158. // quesremark = "";
  159. // }
  160. // html += '<li >';
  161. // html += '<div class="Back">';
  162. // html += '<h3 class="size-14 QuesTitle" indexs="' + Questions[i].quesid + '">' + Questions[i].questitle + quesremark + ' </h3>';
  163. // html += '</div>';
  164. // //判断类型
  165. // if(questype == 2) { //问答题
  166. // //选项
  167. // if(Questions[i].quesitems.length > 0) {
  168. // html += '<div>';
  169. // var quesitems = Questions[i].quesitems;
  170. // for(var j = 0; j < quesitems.length; j++) {
  171. // html += '<label style="font-weight: normal;">'
  172. // html += '' + (j + 1) + '.';
  173. // html += '<input type="radio" index_="' + quesitems[j].itemid + '" value="' + quesitems[j].itemname + '" name="ltype' + Quesid + '" style="margin-left:5px;"> ' + quesitems[j].itemname + '</label>'
  174. // }
  175. // html += '</div>'
  176. // html += '</li>'
  177. // }
  178. // } else if(questype == 1) {
  179. // html += '<div>';
  180. // html += '<textarea index="' + Questions[i].quesid + '"name="" rows="" cols="" style="width: 100%;"></textarea>'
  181. // html += '</div>'
  182. // } else {
  183. // if(Questions[i].quesitems.length > 0) {
  184. // html += '<div>';
  185. // var quesitems = Questions[i].quesitems;
  186. // for(var j = 0; j < quesitems.length; j++) {
  187. // html += '<label style="font-weight: normal;">'
  188. // html += '' + (j + 1) + '.';
  189. // html += '<input type="checkbox" value="' + quesitems[j].itemname + '" name="checks" > ' + quesitems[j].itemname + '</label>'
  190. // }
  191. // html += '</div>'
  192. // html += '</li >';
  193. // }
  194. // }
  195. // }
  196. // $(html).appendTo(".Qus_box");
  197. // }
  198. // }
  199. // });
  200. // }
  201. // 提交
  202. $(".access-complete").click(function() {
  203. $(".radio").each(function(j, k) {
  204. str = '';
  205. var nameRadio = $(k).attr("name");
  206. var index = $(k).attr("indexs");
  207. var val = $('input[name="' + nameRadio + '"]:checked').val();
  208. var valText = $('input[name="' + nameRadio + '"]:checked').next().text();
  209. if(val != null) {
  210. str = index + '_' + val + '_' + valText;
  211. ans.push(str);
  212. }
  213. })
  214. $(".checkbox").each(function(j, k) {
  215. strs = '';
  216. var nameCheckbox = $(k).attr("name");
  217. var index = $(k).attr("indexs");
  218. var check = "";
  219. var text = "";
  220. var VAl = $('input[name="' + nameCheckbox + '"]:checked');
  221. $(VAl).each(function(i, n) {
  222. text += $(this).next().text() + "|";
  223. check += $(this).val() + "|";
  224. })
  225. if(check != "") {
  226. str = index + '_' + check + '_' + text;
  227. ans.push(str);
  228. }
  229. })
  230. $(".Wd").each(function(j, k) {
  231. strs = '';
  232. var nameWd = $(k).attr("name");
  233. var index = $(k).attr("indexs");
  234. var val = $(k).find(".Wds").val();
  235. if(val) {
  236. str = index + '_0_' + val;
  237. ans.push(str);
  238. }
  239. })
  240. addSatisfactionAnswer()
  241. })
  242. //添加满意度答案
  243. function addSatisfactionAnswer() {
  244. console.log("ans",ans);
  245. console.log("name", name);
  246. console.log("ans",ans);
  247. $.ajax({
  248. type: "post",
  249. url: huayi.config.callcenter_url + "FollowUp/Answers",
  250. async: true,
  251. dataType: "json",
  252. data: {
  253. token: $.cookie("token"),
  254. custelid: custelid, //随访记录id
  255. ans: ans, //问题答案
  256. hjjgid: $("#selectQuesInformation").val(), //随访结果id
  257. name: name, //姓名
  258. phone: phone, //联系人电话
  259. address: address, //地址
  260. advise: $("#satisfactionAdvise").val(), //建议
  261. satisfied: $("#selectSatisfaction").val(), //满意度
  262. praise: $("#satisfactionPraise").val(), //表扬
  263. criticism: $("#satisfactionCriticism").val(), //批评
  264. },
  265. success: function(result){
  266. layer.msg("添加成功")
  267. }
  268. })
  269. }
  270. //获取随访结果id
  271. function getAccessResult(){
  272. $.ajax({
  273. type: "get",
  274. url: huayi.config.callcenter_url + "Questionnaire/GetPagerList",
  275. async: true,
  276. dataType: "json",
  277. data: {
  278. token: $.cookie("token"),
  279. },
  280. success: function(result) {
  281. }
  282. })
  283. }