eduQuestionnaireQuestionForm.jsp 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <%@ page contentType="text/html;charset=UTF-8" %>
  2. <%@ include file="/webpage/include/taglib.jsp"%>
  3. <html>
  4. <head>
  5. <title>调查问卷管理</title>
  6. <meta name="decorator" content="ani"/>
  7. <script type="text/javascript">
  8. $(document).ready(function() {
  9. changeType();
  10. });
  11. function save() {
  12. var isValidate = jp.validateForm('#inputForm');//校验表单
  13. if(!isValidate){
  14. return false;
  15. }else{
  16. jp.loading();
  17. jp.post("${ctx}/questionnaire/eduQuestionnaireQuestion/save",$('#inputForm').serialize(),function(data){
  18. if(data.success){
  19. jp.getParent().refresh();
  20. var dialogIndex = parent.layer.getFrameIndex(window.name); // 获取窗口索引
  21. parent.layer.close(dialogIndex);
  22. jp.success(data.msg)
  23. }else{
  24. jp.error(data.msg);
  25. }
  26. })
  27. }
  28. }
  29. function addRow(list, idx, tpl, row){
  30. $(list).append(Mustache.render(tpl, {
  31. idx: idx, delBtn: true, row: row
  32. }));
  33. $(list+idx).find("select").each(function(){
  34. $(this).val($(this).attr("data-value"));
  35. });
  36. $(list+idx).find("input[type='checkbox'], input[type='radio']").each(function(){
  37. var ss = $(this).attr("data-value").split(',');
  38. for (var i=0; i<ss.length; i++){
  39. if($(this).val() == ss[i]){
  40. $(this).attr("checked","checked");
  41. }
  42. }
  43. });
  44. $(list+idx).find(".form_datetime").each(function(){
  45. $(this).datetimepicker({
  46. format: "YYYY-MM-DD HH:mm:ss"
  47. });
  48. });
  49. }
  50. function delRow(obj, prefix){
  51. var id = $(prefix+"_id");
  52. var delFlag = $(prefix+"_delFlag");
  53. if (id.val() == ""){
  54. $(obj).parent().parent().remove();
  55. }else if(delFlag.val() == "0"){
  56. delFlag.val("1");
  57. $(obj).html("&divide;").attr("title", "撤销删除");
  58. $(obj).parent().parent().addClass("error");
  59. }else if(delFlag.val() == "1"){
  60. delFlag.val("0");
  61. $(obj).html("&times;").attr("title", "删除");
  62. $(obj).parent().parent().removeClass("error");
  63. }
  64. }
  65. function changeType() {
  66. var type = $("#types").val();
  67. if(type == "1" || type == "2"){
  68. $(".tabs-container").css("display","block");
  69. }else if(type == "3") {
  70. $(".tabs-container").css("display","none");
  71. }
  72. }
  73. </script>
  74. </head>
  75. <body class="bg-white">
  76. <form:form id="inputForm" modelAttribute="eduQuestionnaireQuestion" action="${ctx}/questionnaire/eduQuestionnaireQuestion/save" method="post" class="form-horizontal">
  77. <form:hidden path="id"/>
  78. <form:hidden path="questionnaire.id"/>
  79. <table class="table table-bordered">
  80. <tbody>
  81. <tr>
  82. <td class="width-15 active"><label class="pull-right"><font color="red">*</font>题号:</label></td>
  83. <td class="width-35">
  84. <form:input path="num" htmlEscape="false" min="1" class="form-control digits "/>
  85. </td>
  86. <td class="width-15 active"><label class="pull-right" ><font color="red">*</font>题目类型:</label></td>
  87. <td class="width-35">
  88. <form:select path="types" class="form-control required" onchange="changeType()">
  89. <form:option value="1" label="单选题"/>
  90. <form:option value="2" label="多选题"/>
  91. <form:option value="3" label="简答题"/>
  92. </form:select>
  93. </td>
  94. </tr>
  95. <tr>
  96. <td class="width-15 active"><label class="pull-right"><font color="red">*</font>题目内容:</label></td>
  97. <td class="width-35" colspan="3">
  98. <form:input path="title" htmlEscape="false" maxlength="100" class="form-control required"/>
  99. </td>
  100. </tr>
  101. <%--<tr>
  102. <td class="width-15 active"><label class="pull-right"><font color="red">*</font>是否必答:</label></td>
  103. <td class="width-35">
  104. <form:radiobuttons path="mustAnswer" items="${fns:getDictList('yes_no')}" itemLabel="label" itemValue="value" htmlEscape="false" class="required i-checks "/>
  105. </td>
  106. </tr>--%>
  107. </tbody>
  108. </table>
  109. <div class="tabs-container">
  110. <ul class="nav nav-tabs">
  111. <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true">调查问卷:</a>
  112. </li>
  113. </ul>
  114. <div class="tab-content">
  115. <div id="tab-1" class="tab-pane fade in active">
  116. <a class="btn btn-white btn-sm" onclick="addRow('#eduQuestionnaireOptionList', eduQuestionnaireOptionRowIdx, eduQuestionnaireOptionTpl);eduQuestionnaireOptionRowIdx = eduQuestionnaireOptionRowIdx + 1;" title="新增"><i class="fa fa-plus"></i> 新增</a>
  117. <table class="table table-striped table-bordered table-condensed">
  118. <thead>
  119. <tr>
  120. <th class="hide"></th>
  121. <th><font color="red">*</font>选项内容</th>
  122. <th>排序</th>
  123. <th width="10">&nbsp;</th>
  124. </tr>
  125. </thead>
  126. <tbody id="eduQuestionnaireOptionList">
  127. </tbody>
  128. </table>
  129. <script type="text/template" id="eduQuestionnaireOptionTpl">//<!--
  130. <tr id="eduQuestionnaireOptionList{{idx}}">
  131. <td class="hide">
  132. <input id="eduQuestionnaireOptionList{{idx}}_id" name="eduQuestionnaireOptionList[{{idx}}].id" type="hidden" value="{{row.id}}"/>
  133. <input id="eduQuestionnaireOptionList{{idx}}_delFlag" name="eduQuestionnaireOptionList[{{idx}}].delFlag" type="hidden" value="0"/>
  134. </td>
  135. <td>
  136. <input id="eduQuestionnaireOptionList{{idx}}_title" name="eduQuestionnaireOptionList[{{idx}}].title" type="text" value="{{row.title}}" class="form-control required"/>
  137. </td>
  138. <td>
  139. <input id="eduQuestionnaireOptionList{{idx}}_seq" name="eduQuestionnaireOptionList[{{idx}}].seq" type="text" value="{{row.seq}}" class="form-control digits "/>
  140. </td>
  141. <td class="text-center" width="10">
  142. {{#delBtn}}<span class="close" onclick="delRow(this, '#eduQuestionnaireOptionList{{idx}}')" title="删除">&times;</span>{{/delBtn}}
  143. </td>
  144. </tr>//-->
  145. </script>
  146. <script type="text/javascript">
  147. var eduQuestionnaireOptionRowIdx = 0, eduQuestionnaireOptionTpl = $("#eduQuestionnaireOptionTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
  148. $(document).ready(function() {
  149. var data = ${fns:toJson(eduQuestionnaireQuestion.eduQuestionnaireOptionList)};
  150. for (var i=0; i<data.length; i++){
  151. addRow('#eduQuestionnaireOptionList', eduQuestionnaireOptionRowIdx, eduQuestionnaireOptionTpl, data[i]);
  152. eduQuestionnaireOptionRowIdx = eduQuestionnaireOptionRowIdx + 1;
  153. }
  154. });
  155. </script>
  156. </div>
  157. </div>
  158. </div>
  159. </form:form>
  160. </body>
  161. </html>