build_form.html 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. {extend name="layout/content"}
  2. {block name="content"}
  3. <style type="text/css">
  4. .layui-layer-btn .layui-layer-btn1 {
  5. border-color: #009688;
  6. background-color: #009688;
  7. color: #fff;
  8. }
  9. .base .form-check{float:left;margin:5px;}
  10. </style>
  11. <div class="row">
  12. <div class="col-sm-12">
  13. <div class="ibox float-e-margins">
  14. <div class="ibox-title">
  15. <h5>创建表单模板</h5>
  16. </div>
  17. <div class="ibox-content">
  18. <div class="row row-lg">
  19. <div class="col-sm-12">
  20. <div class="row">
  21. <div class="col-sm-3">
  22. <div class="input-group input-group-sm">
  23. <div class="input-group-btn">
  24. <button data-toggle="dropdown" class="btn btn-white dropdown-toggle" type="button">
  25. 选择表单类型
  26. </button>
  27. </div>
  28. <select class="form-control" name="type">
  29. <option value="1">人才认定申请</option>
  30. </select>
  31. </div>
  32. </div>
  33. <div class="col-sm-3">
  34. <div class="input-group input-group-sm">
  35. <div class="input-group-btn">
  36. <button data-toggle="dropdown" class="btn btn-white dropdown-toggle" type="button">
  37. 针对人才类型
  38. </button>
  39. </div>
  40. <select class="form-control" name="talentType">
  41. <option>全部人才</option>
  42. <option value="1">优秀人才</option>
  43. <option value="2">人才认定申请</option>
  44. </select>
  45. </div>
  46. </div>
  47. </div>
  48. <fieldset>
  49. <legend>个人信息</legend>
  50. <div class="row base">
  51. <div class="col-sm-12">
  52. <div class="form-check">
  53. <label class="form-check-label">
  54. <input type="checkbox" name="name" class="form-check-input" value="" checked="" autocomplete="off">姓名
  55. </label>
  56. </div>
  57. <div class="form-check">
  58. <label class="form-check-label">
  59. <input type="checkbox" name="sex" class="form-check-input" value="" checked="" autocomplete="off">性别
  60. </label>
  61. </div>
  62. <div class="form-check">
  63. <label class="form-check-label">
  64. <input type="checkbox" name="sex" class="form-check-input" value="" checked="" autocomplete="off">单位标签
  65. </label>
  66. </div>
  67. <div class="form-check">
  68. <label class="form-check-label">
  69. <input type="checkbox" name="sex" class="form-check-input" value="" checked="" autocomplete="off">单位名称
  70. </label>
  71. </div>
  72. </div>
  73. </div>
  74. </fieldset>
  75. <div class="hidden-xs" id="TalentInfoTableToolbar" role="group">
  76. <button type="button" class="btn btn-sm btn-primary " onclick="addField()" id="">
  77. <i class="fa fa-plus"></i>&nbsp;添加字典字段
  78. </button>
  79. </div>
  80. <table id="form" class="table-condensed table table-bordered table-hover table-sm table-striped">
  81. <thead>
  82. <tr>
  83. <th>字段</th>
  84. <th>是否必选</th>
  85. <th>选择附件</th>
  86. <th>排序</th>
  87. <th></th>
  88. </tr>
  89. </thead>
  90. <tbody>
  91. </tbody>
  92. </table>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. </div>
  98. </div>
  99. <!--<script src="${ctxPath}/static/modular/gate/talentInfo/talentInfo.js"></script>-->
  100. <script>
  101. var __initialize = function () {
  102. var count = $(".base input[type=checkbox]").length;
  103. for (var i = 0; i < count; i++) {
  104. var chk = $(".base input[type=checkbox]").eq(i);
  105. if (chk.is(":checked")) {
  106. var value = chk.attr("name");
  107. var text = chk.parent().text();
  108. addToTable(value, text);
  109. }
  110. }
  111. }();
  112. function addField() {
  113. layer.open({
  114. type: 2,
  115. title: "添加字段",
  116. fixed: false,
  117. content: "/admin/talent/add_field",
  118. area: ['50%', '50%'],
  119. maxmin: true,
  120. success: function (layero, index) {
  121. }
  122. });
  123. }
  124. function addToTable(value, text) {
  125. if ($("#form").find("input[name='field[]'][value='" + value + "']").length == 0) {
  126. var tr = '<tr><td>' + text + '<input type="hidden" name="field[]" value="' + value + '"></td><td><input type="checkbox" name="need[]" checked=""></td><td><button class="btn btn-sm btn-primary" onclick="chooseFile(this);">选择附件</button><input type="hidden" name="file[]"></td><td><input name="order[]" value="1"></td><td><button class="btn btn-sm btn-primary" onclick="remove(this);">删除</button></td></tr>';
  127. $("#form tbody").append(tr);
  128. }
  129. }
  130. function remove(obj) {
  131. var tr = $(obj).parents("tr");
  132. var name = tr.find("input[type=checkbox]").attr("name");
  133. $(obj).parents("tr").remove();
  134. $(".base input[type=checkbox][name='" + name + "']").prop("checked", false);
  135. }
  136. $(".base input[type=checkbox]").change(function () {
  137. if ($(this).is(":checked")) {
  138. var value = $(this).attr("name");
  139. var text = $(this).parent().text();
  140. addToTable(value, text);
  141. }
  142. })
  143. </script>
  144. <script type="text/javascript">
  145. document.write('<script src="/static/modular/gate/talentInfo/talentInfo.js?v=' + (new Date()).getTime() + '"><\/script>');
  146. document.write('<script src="/static/modular/common/config.js?v=' + (new Date()).getTime() + '"><\/script>');
  147. </script>
  148. {/block}