em.html 16 KB

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