answer.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>答题</title>
  8. <!-- Bootstrap -->
  9. <link href="/static/answerpage/demo/css/bootstrap.min.css" rel="stylesheet">
  10. <style type="text/css">
  11. #reviewqu {
  12. font-weight: bold;
  13. color: rgb(69, 189, 245);
  14. text-align: center;
  15. margin: 0 auto;
  16. }
  17. #reviename {
  18. font-weight: bold;
  19. }
  20. .starCon {
  21. margin-bottom: 5em;
  22. clear: both;
  23. }
  24. body {
  25. /* background-color:azure */
  26. background-image: url(/static/img/zzpic12840.jpg);
  27. }
  28. .starCon {
  29. position: relative;
  30. margin: 0 auto;
  31. }
  32. .starTitle {
  33. margin-top: 0.8em;
  34. }
  35. .starCon ul {
  36. float: left;
  37. display: inline;
  38. height: 20px;
  39. line-height: 300px;
  40. margin-top: 0.8em;
  41. margin-left: -5%;
  42. }
  43. #reviewqu {
  44. margin-top: 1%;
  45. font-size: 1.5em;
  46. }
  47. #reviename {
  48. margin-top: 1%;
  49. }
  50. #reviedescribed {
  51. margin-top: 1%;
  52. }
  53. /* .starCon ul {
  54. margin:0 0 0em;
  55. } */
  56. .starCon li {
  57. float: left;
  58. width: 3.3em;
  59. height: 3.3em;
  60. cursor: pointer;
  61. text-indent: -9999px;
  62. display: inline-block;
  63. background: url(/static/answerpage/img/star-off.png) no-repeat;
  64. background-size: 40%;
  65. }
  66. .starCon li.on {
  67. width: 3.3em;
  68. height: 3.3em;
  69. background: url(star_choies.png) no-repeat;
  70. background-size: 40%
  71. }
  72. @media screen and (min-width:400px) {
  73. .modal-dialog {
  74. width: 250px;
  75. margin: auto;
  76. padding-top: 50%;
  77. }
  78. .modal-content {
  79. -webkit-box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
  80. box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
  81. }
  82. }
  83. </style>
  84. </head>
  85. <body>
  86. <!--弹窗提示-->
  87. <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  88. <div class="modal-dialog" role="document">
  89. <div class="modal-content">
  90. <div class="modal-header">
  91. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  92. <span aria-hidden="true">×</span>
  93. </button>
  94. <h4 class="modal-title" id="myModalLabel">提示</h4>
  95. </div>
  96. <div class="modal-body" id="modal-body">
  97. <p></p>
  98. </div>
  99. <div class="modal-footer">
  100. <button type="button" data-dismiss="modal" class="btn">确定</button>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. <div id="isrenf">
  106. <div class="row" style="margin-left:1%">
  107. <!--问卷名称-->
  108. <div id="reviewqu" class="col-xs-12 col-md-12"></div>
  109. <!--被调查者-->
  110. <div id="reviename" class="col-xs-12 col-md-12">
  111. 你这次评价的对象是:
  112. </div>
  113. <!--问卷说明-->
  114. <div id="reviedescribed" class="col-xs-12 col-md-12">
  115. </div>
  116. </div>
  117. <hr/>
  118. <div class="row">
  119. <!--问题框-->
  120. <div id="titleDescription" class="col-xs-9 col-md-9">
  121. <!--问题详情-->
  122. <div id="problemVo" class="row" style="margin-left:2%">
  123. </div>
  124. <!--是否可以重复提交-->
  125. <input type="hidden" id="isrepeat">
  126. <button id="onsumit" style='margin-top:2%;margin-left:8%' type="button" class="btn btn-primary" data-toggle="button" aria-pressed="false"
  127. autocomplete="off">
  128. 提交
  129. </button>
  130. </div>
  131. </div>
  132. <div id="isrenf2"></div>
  133. <script src="/static/answerpage/js/jquery-2.1.4.min.js"></script>
  134. <script src="/static/answerpage/js/bootstrap.min.js"></script>
  135. <script>
  136. $(document).ready(function () {
  137. var domain = location.hostname;
  138. var backDomain = domain + ":";//后端域名
  139. if (domain === 'localhost') { //开发
  140. backDomain += "6062/DPshow_depart/";
  141. } else if (domain === 'duptest.bgyfw.com') { //测试
  142. backDomain += "8002/DPshow_depart/";
  143. } else if (domain === 'duprc.bgyfw.com') { //预生产
  144. backDomain += "8002/DPshow_depart/";
  145. } else if (domain === 'dup.bgyfw.com') { //正式
  146. backDomain += "8002/DPshow_depart/";
  147. }
  148. var url = location.search; //获取url中"?"符后的字串  
  149. var theRequest = new Object();
  150. if (url.indexOf("?") != -1) {
  151. var str = url.substr(1);
  152. strs = str.split("&");
  153. for (var i = 0; i < strs.length; i++) {
  154. theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
  155. }
  156. }
  157. var iid = theRequest.iid;//被调查人id
  158. var jid = theRequest.jid;//参与评选人id
  159. var qid = theRequest.qid;//问卷id
  160. var dataObj = "";
  161. var investigatedName = "";
  162. var questionnaireId = "";
  163. var questionnaireName = "";
  164. var questionnaireDescribed = "";
  165. var problemVo = "";
  166. var answerArray = [];
  167. var answerJson = "";
  168. $("#onsumit").click(function () {
  169. var isrepeat = $("#isrepeat").val();
  170. if (isrepeat == 1) {
  171. $.ajax({
  172. type: "post",
  173. url: "http://" + backDomain + "api/reviewScore/updataflag",
  174. async: true,
  175. data: { id: iid, questionnaireId: qid, judgeId: jid },
  176. dataType: 'json',
  177. success: function (result) { }
  178. })
  179. }
  180. for (var i = 0; i < problemVo.length; i++) {
  181. var answer = { judgeId: "", problemId: "", potionId: "", score: "", type: "" };
  182. answer.judgeId = jid;
  183. answer.type = problemVo[i].type;
  184. answer.problemId = problemVo[i].id;
  185. //type==1为量表题,得到星星数
  186. if (problemVo[i].type == 1) {
  187. answer.score = $("#startProble" + i).val()
  188. if (answer.score == 0) {
  189. $("#modal-body p").html("问题" + (i + 1) + "不能为空,请选择")
  190. $('#myModal').modal('show')
  191. answerArray = []
  192. break;
  193. }
  194. //type==2为问答题,得到输入框值
  195. } else if (problemVo[i].type == 2) {
  196. answer.score = $("#text" + i).val();
  197. if (answer.score == "" || answer.score == null) {
  198. $("#modal-body p").html("问题" + (i + 1) + "不能为空,请选择")
  199. $('#myModal').modal('show')
  200. answerArray = []
  201. break;
  202. }
  203. //type==1为单选,得到选中的id
  204. } else if (problemVo[i].type == 3) {
  205. var potionId = $("input[name='field_name" + i + "']:checked").val();
  206. if (potionId == undefined) {
  207. $("#modal-body p").html("问题" + (i + 1) + "不能为空,请选择")
  208. $('#myModal').modal('show')
  209. answerArray = []
  210. break;
  211. } else {
  212. debugger
  213. var optionStr = problemVo[i].option;
  214. for (var j = 0; j < optionStr.length; j++) {
  215. if (optionStr[j].optionId == potionId) {
  216. answer.score = optionStr[j].optionScore;
  217. answer.potionId = potionId;
  218. }
  219. }
  220. }
  221. }
  222. answerArray.push(answer)
  223. }
  224. if (answerArray.length != 0) {
  225. $.ajax({
  226. type: "post",
  227. url: "http://" + backDomain + "api/reviewScore/add",
  228. async: true,
  229. data: { answer: JSON.stringify(answerArray) },
  230. dataType: 'json',
  231. success: function (result) {
  232. if (isrepeat == 0) {
  233. $("#onsumit").css("display", "none");
  234. }
  235. $("#modal-body p").html("提交成功")
  236. $('#myModal').modal('show')
  237. // alert('提交成功')
  238. }, error: function (XmlHttpRequest, textStatus, errorThrown) {
  239. $("#modal-body p").html("提交失败")
  240. $('#myModal').modal('show')
  241. // alert('提交失败');
  242. }
  243. })
  244. }
  245. })
  246. $.ajax({
  247. type: "get",
  248. url: "http://" + backDomain + "api/reviewQuestionnaire/getreviewquestionnaireanswer",
  249. async: true,
  250. data: { investigatedId: iid },
  251. dataType: 'json',
  252. success: function (result) {
  253. var dataol = JSON.stringify(result.data);
  254. if (dataol == 'null') {
  255. $("#isrenf").css("display", "none");
  256. $("#isrenf2").append("<p>该问卷调查已结束或者你已提交过</p>");
  257. } else {
  258. dataObj = eval(result).data;
  259. investigatedName = eval(dataObj).investigatedName;
  260. questionnaireId = eval(dataObj).questionnaireId;
  261. questionnaireName = eval(dataObj).questionnaireName;
  262. questionnaireDescribed = eval(dataObj).questionnaireDescribed;
  263. problemVo = eval(dataObj).problemVo;
  264. $("#reviewqu").html(questionnaireName);
  265. $("#reviename").append(investigatedName);
  266. $("#reviedescribed").html(questionnaireDescribed);
  267. $("#problemVo").html("");
  268. for (var i = 0; i < problemVo.length; i++) {
  269. //type==1为量表题
  270. if (problemVo[i].type == 1) {
  271. var ulStr = "";
  272. for (var j = 0; j < problemVo[i].score; j++) {
  273. ulStr += "<li><a href='javascript:;'>" + (j + 1) + "</li>";
  274. }
  275. $("#problemVo").append(
  276. "<div class='starCon' id='star" + (i + 1) + "'>" +
  277. "<div class='starTitle'>" + (i + 1) + "、" + problemVo[i].title + "</div>" +
  278. "<ul>" + ulStr + "</ul>" + "<input type='hidden' value='0' id='startProble" + i + "' /></div>"
  279. );
  280. starComm('star' + (i + 1));
  281. function starComm(starId) {
  282. var oStar = document.getElementById(starId);
  283. var aLi = oStar.getElementsByTagName("li");
  284. var oUl = oStar.getElementsByTagName("ul")[0];
  285. var oP = oStar.getElementsByTagName("input")[0];
  286. var i = iScore = iStar = 0;
  287. for (i = 1; i <= aLi.length; i++) {
  288. aLi[i - 1].index = i;
  289. //点击后进行评分处理
  290. aLi[i - 1].onclick = function () {
  291. iStar = this.index;
  292. fnPoint(iStar);
  293. oP.value = iStar;
  294. }
  295. }
  296. //评分处理
  297. var fnPoint = function (iArg) {
  298. //分数赋值
  299. iScore = iArg || iStar;
  300. for (i = 0; i < aLi.length; i++) aLi[i].className = i < iScore ? "on" : "";
  301. }
  302. }
  303. }
  304. if (problemVo[i].type == 2) {
  305. $("#problemVo").append(
  306. "<div class='starCon' id='star3'>" +
  307. "<div class='starTitle'>" + (i + 1) + "、" + problemVo[i].title + "</div>" +
  308. // " <textarea placeholder='是的' style='margin-top:2%;margin-left:5%' rows='4' cols='30' id='text" + i + "'" + ">" + " </textarea></div>"
  309. "<textarea type='text' style='margin-top:2%;margin-left:5%;width:280px;height:100px' id='text" + i + "' placeholder='" + problemVo[i].answerDescription + "'></textarea></div>"
  310. );
  311. }
  312. if (problemVo[i].type == 3) {
  313. var optionStr = "";
  314. for (var j = 0; j < problemVo[i].option.length; j++) {
  315. optionStr += "<input type='radio' style='margin-top:1.5%;margin-left:5%' name='field_name" + i + "'" + "value='" + problemVo[i].option[j].optionId + "'/>" + problemVo[i].option[j].name + "<br>";
  316. }
  317. $("#problemVo").append(
  318. "<div class='starCon' id='star'>" +
  319. "<div class='starTitle'>" + (i + 1) + "、" + problemVo[i].title + "</div>" +
  320. optionStr + "</div>"
  321. );
  322. }
  323. }
  324. }
  325. }
  326. })
  327. })
  328. </script>
  329. </body>
  330. </html>