as.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  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="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(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: 1.5em;
  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: 60%;
  65. }
  66. .starCon li.on {
  67. width: 1.5em;
  68. height: 3.3em;
  69. background: url(star_choies.png) no-repeat;
  70. background-size: 60%
  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" var="1">确定</button>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. <div id="isShow">
  106. <div id="isrenf">
  107. <div class="row" style="margin-left:1%">
  108. <!--问卷名称-->
  109. <div id="reviewqu" class="col-xs-12 col-md-12"></div>
  110. <!--被调查者-->
  111. <div id="reviename" class="col-xs-12 col-md-12">
  112. 你这次评价的对象是:
  113. </div>
  114. <!--问卷说明-->
  115. <div id="reviedescribed" class="col-xs-12 col-md-12">
  116. </div>
  117. </div>
  118. <hr/>
  119. <div class="row">
  120. <!--问题框-->
  121. <div id="titleDescription" class="col-xs-9 col-md-9">
  122. <!--问题详情-->
  123. <div id="problemVo" class="row" style="margin-left:2%">
  124. </div>
  125. <!--是否可以重复提交-->
  126. <input type="hidden" id="isrepeat">
  127. <button id="onsumit" style='margin-top:2%;margin-left:8%' type="button" class="btn btn-primary" data-toggle="button" aria-pressed="false"
  128. autocomplete="off">
  129. 提交
  130. </button>
  131. </div>
  132. </div>
  133. <div id="isrenf2"></div>
  134. </div>
  135. <script src="answerpage/js/jquery-2.1.4.min.js"></script>
  136. <script src="answerpage/js/bootstrap.min.js"></script>
  137. <script>
  138. $(document).ready(function () {
  139. var domain = location.hostname;
  140. var backDomain = domain + ":";//后端域名
  141. if (domain === 'localhost') { //开发
  142. backDomain = "http://localhost:9090/";
  143. } else if (domain === 'duptest.bgyfw.com') { //测试
  144. backDomain = "http://duptest.bgyfw.com:8002/DPshow_depart/";
  145. } else if (domain === 'duprc.bgyfw.com') { //预生产
  146. backDomain = "http://duprc.bgyfw.com:8012/DPshow_depart/";
  147. } else if (domain === 'dup.bgyfw.com') { //正式
  148. backDomain = "https://dup.bgyfw.com:8443/DPshow_depart/";
  149. }
  150. var url = location.search; //获取url中"?"符后的字串  
  151. var theRequest = new Object();
  152. if (url.indexOf("?") != -1) {
  153. var str = url.substr(1);
  154. strs = str.split("&");
  155. for (var i = 0; i < strs.length; i++) {
  156. theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
  157. }
  158. }
  159. var iid = theRequest.id;//被调查人id
  160. var jid = theRequest.jd;//参与评选人id
  161. var qid = theRequest.qd;//问卷id
  162. var dataObj = "";
  163. var investigatedName = "";
  164. var questionnaireId = "";
  165. var questionnaireName = "";
  166. var questionnaireDescribed = "";
  167. var problemVo = "";
  168. var answerArray = [];
  169. var answerJson = "";
  170. var investigatedIsRepeatVo ="";
  171. var problemjianweVo="";
  172. var answerwenArray=[];
  173. $("#onsumit").click(function () {
  174. var isrepeat = $("#isrepeat").val();
  175. if (isrepeat == 1) {
  176. $.ajax({
  177. type: "post",
  178. url: backDomain + "api/reviewScore/updataflag",
  179. async: true,
  180. data: { id: iid, questionnaireId: qid, judgeId: jid },
  181. dataType: 'json',
  182. success: function (result) { }
  183. })
  184. }
  185. for (var i = 0; i < problemVo.length; i++) {
  186. var answer = { judgeId: "", problemId: "", potionId: "", score: "", type: "" };
  187. answer.judgeId = jid;
  188. answer.type = problemVo[i].type;
  189. answer.problemId = problemVo[i].id;
  190. //type==1为量表题,得到星星数
  191. if (problemVo[i].type == 1) {
  192. answer.score = $("#startProble" + i).val()
  193. if (answer.score == 0) {
  194. $('#buthiden').hide();
  195. $("#modal-body p").html("问题" + (i + 1) + "不能为空,请选择")
  196. $('#myModal').modal('show')
  197. answerArray = []
  198. break;
  199. }
  200. }else if (problemVo[i].type == 3) {//type==3为单选,得到选中的id
  201. var potionId = $("input[name='field_name" + i + "']:checked").val();
  202. if (potionId == undefined) {
  203. $('#buthiden').hide();
  204. $("#modal-body p").html("问题" + (i + 1) + "不能为空,请选择")
  205. $('#myModal').modal('show')
  206. answerArray = []
  207. break;
  208. } else {
  209. var optionStr = problemVo[i].option;
  210. for (var j = 0; j < optionStr.length; j++) {
  211. if (optionStr[j].optionId == potionId) {
  212. answer.score = optionStr[j].optionScore;
  213. answer.potionId = potionId;
  214. }
  215. }
  216. }
  217. }
  218. answerArray.push(answer)
  219. }
  220. for (var i = 0; i < problemjianweVo.length; i++) {
  221. var answer = { judgeId: "", problemId: "", potionId: "", score: "", type: "" };
  222. answer.judgeId = jid;
  223. answer.type = problemjianweVo[i].type;
  224. answer.problemId = problemjianweVo[i].id;
  225. //type==2为问答题,得到输入框值
  226. if (problemjianweVo[i].type == 2) {
  227. answer.score = $("#text" + i).val();
  228. if (answer.score == "" || answer.score == null) {
  229. $('#buthiden').hide();
  230. $("#modal-body p").html("问答题不能为空,请选择")
  231. $('#myModal').modal('show')
  232. answerwenArray = []
  233. break;
  234. }
  235. }
  236. answerwenArray.push(answer);
  237. }
  238. if (answerArray.length != 0||answerwenArray.length!=0) {
  239. $.ajax({
  240. type: "post",
  241. url: backDomain + "api/reviewScore/add",
  242. async: true,
  243. data: { answer: JSON.stringify(answerArray),answenwer: JSON.stringify(answerwenArray) },
  244. dataType: 'json',
  245. success: function (result) {
  246. answerwenArray=[];
  247. answerArray=[];
  248. $(" input[ type='text' ] ").val("");
  249. $("input[ type='radio' ]").attr("checked",false);
  250. $('#buthiden').hide();
  251. $("#modal-body p").html("提交成功")
  252. $('#myModal').modal('show')
  253. $(".btn").click(function () {
  254. window.opener=null;
  255. window.open('','_self');
  256. window.close();
  257. })
  258. }, error: function (XmlHttpRequest, textStatus, errorThrown) {
  259. $('#buthiden').hide();
  260. $("#modal-body p").html("提交失败")
  261. $('#myModal').modal('show')
  262. }
  263. })
  264. }
  265. })
  266. $.ajax({
  267. type: "get",
  268. url:
  269. backDomain + "api/reviewQuestionnaire/getreviewquestionnaireanswer",
  270. async: true,
  271. data: { investigatedId: iid, reviewJudgeId: jid, questionnaireId:qid},
  272. dataType: 'json',
  273. success: function (result) {
  274. // var dataol = JSON.stringify(result.data.flag);
  275. var is_show = true;
  276. dataObj = eval(result).data;
  277. // alert(JSON.stringify(dataObj))
  278. investigatedIsRepeatVo = eval(dataObj).investigatedIsRepeatVo;
  279. if (investigatedIsRepeatVo.flag == 1) {
  280. $("#modal-body p").html("该问卷调查已结束,谢谢你的参与")
  281. $('#myModal').modal('show')
  282. $('#isShow').hide();
  283. $(".btn").click(function () {
  284. window.opener=null;
  285. window.open('','_self');
  286. window.close();
  287. })
  288. }
  289. if(investigatedIsRepeatVo.flag == 0 && investigatedIsRepeatVo.isRepeat==1){
  290. $('#isrepeat').val(1);
  291. }
  292. if (investigatedIsRepeatVo.flag ==0 && investigatedIsRepeatVo.isSubmission == 1 && investigatedIsRepeatVo.isRepeat == 0) {
  293. $("#modal-body p").html("该问卷你已提交,谢谢你的参与")
  294. $('#myModal').modal('show')
  295. $('#isShow').hide();
  296. $(".btn").click(function () {
  297. window.opener=null;
  298. window.open('','_self');
  299. window.close();
  300. })
  301. }
  302. if (investigatedIsRepeatVo.flag == 0 && investigatedIsRepeatVo.isSubmission == 1 && investigatedIsRepeatVo.isRepeat == 1) {
  303. $(".modal-footer").append(
  304. "<button id='buthiden' type='button' data-dismiss='modal' class='btn' var='2'/ >取消</button>"
  305. );
  306. $("#modal-body p").html("该问卷你已提交,再次提交以此份为准,是否继续")
  307. $('#myModal').modal('show')
  308. $(".btn").on("click", function () {
  309. if ($(this).attr("var") == 2) {
  310. $('#isShow').hide();
  311. window.opener=null;
  312. window.open('','_self');
  313. window.close();
  314. }
  315. });
  316. }
  317. investigatedName = eval(dataObj).investigatedName;
  318. questionnaireId = eval(dataObj).questionnaireId;
  319. questionnaireName = eval(dataObj).questionnaireName;
  320. questionnaireDescribed = eval(dataObj).questionnaireDescribed;
  321. problemVo = eval(dataObj).problemVo;
  322. problemjianweVo=eval(dataObj).problemjianweVo;
  323. $("#reviewqu").html(questionnaireName);
  324. $("#reviename").append(investigatedName);
  325. $("#reviedescribed").html(questionnaireDescribed);
  326. $("#problemVo").html("");
  327. if(problemVo.length!=0){
  328. for (var i = 0; i < problemVo.length; i++) {
  329. //type==1为量表题
  330. if (problemVo[i].type == 1) {
  331. var ulStr = "";
  332. for (var j = 0; j < problemVo[i].score; j++) {
  333. ulStr += "<li><a href='javascript:;'>" + (j + 1) + "</li>";
  334. }
  335. $("#problemVo").append(
  336. "<div>&nbsp;&nbsp;</div>"+
  337. "<div style='margin-left:0px' id='starproqc"+(i + 1) + "'>" +"<h4>"+problemVo[i].name +":"+"</h4></div>"+
  338. "<div class='starCon' id='star" + (i + 1) + "'>" +
  339. "<div class='starTitle'>" + (i + 1) + "、" + problemVo[i].title + "</div>" +
  340. "<ul>" + ulStr + "</ul>" + "<input type='hidden' value='0' id='startProble" + i + "' /></div>"+"<div>&nbsp;&nbsp;</div>"
  341. );
  342. starComm('star' + (i + 1));
  343. function starComm(starId) {
  344. var oStar = document.getElementById(starId);
  345. var aLi = oStar.getElementsByTagName("li");
  346. var oUl = oStar.getElementsByTagName("ul")[0];
  347. var oP = oStar.getElementsByTagName("input")[0];
  348. var i = iScore = iStar = 0;
  349. for (i = 1; i <= aLi.length; i++) {
  350. aLi[i - 1].index = i;
  351. //点击后进行评分处理
  352. aLi[i - 1].onclick = function () {
  353. iStar = this.index;
  354. fnPoint(iStar);
  355. oP.value = iStar;
  356. }
  357. }
  358. //评分处理
  359. var fnPoint = function (iArg) {
  360. //分数赋值
  361. iScore = iArg || iStar;
  362. for (i = 0; i < aLi.length; i++) aLi[i].className = i < iScore ? "on" : "";
  363. }
  364. }
  365. }
  366. if (problemVo[i].type == 3) {
  367. var optionStr = "";
  368. for (var j = 0; j < problemVo[i].option.length; j++) {
  369. 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>";
  370. }
  371. $("#problemVo").append(
  372. "<div>&nbsp;&nbsp;</div>"+
  373. "<div style='margin-left:0px' id='starproqc"+(i + 1) + "'>" +"<h4>"+problemVo[i].name +":"+"</h4></div>"+
  374. "<div class='starCon' id='star'>" +
  375. "<div class='starTitle'>" + (i + 1) + "、" + problemVo[i].title + "</div>" +
  376. optionStr + "</div>"+"<div>&nbsp;&nbsp;</div>"
  377. );
  378. }
  379. }
  380. }
  381. if(problemjianweVo.length!=0){
  382. for(var i=0;i<problemjianweVo.length;i++){
  383. if (problemjianweVo[i].type == 2) {
  384. $("#problemVo").append(
  385. "<div>&nbsp;&nbsp;</div>"+
  386. "<div class='starCon' id='star'>" +
  387. "<div class='starTitle'>" + problemjianweVo[i].title + "</div>" +
  388. "<textarea type='text' style='margin-top:2%;margin-left:5%;width:280px;height:100px' id='text" + i + "' placeholder='" + problemjianweVo[i].answerDescription + "'></textarea></div>"+"<div>&nbsp;&nbsp;</div>"
  389. );
  390. }
  391. }
  392. }
  393. }
  394. })
  395. })
  396. </script>
  397. </body>
  398. </html>