eduVoteQuestionForm.jsp 6.0 KB

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