edit.html.vm 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <!DOCTYPE html>
  2. <html lang="zh" xmlns:th="http://www.thymeleaf.org" >
  3. <head>
  4. <th:block th:include="include :: header('修改${functionName}')" />
  5. #foreach($column in $columns)
  6. #if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
  7. <th:block th:include="include :: datetimepicker-css" />
  8. #break
  9. #end
  10. #end
  11. </head>
  12. <body class="white-bg">
  13. <div class="wrapper wrapper-content animated fadeInRight ibox-content">
  14. <form class="form-horizontal m" id="form-${businessName}-edit" th:object="${${className}}">
  15. #if($table.sub)
  16. <h4 class="form-header h4">${functionName}信息</h4>
  17. #end
  18. <input name="${pkColumn.javaField}" th:field="*{${pkColumn.javaField}}" type="hidden">
  19. #foreach($column in $columns)
  20. #if($column.edit && !$column.pk)
  21. #if(($column.usableColumn) || (!$column.superColumn))
  22. #set($parentheseIndex=$column.columnComment.indexOf("("))
  23. #if($parentheseIndex != -1)
  24. #set($comment=$column.columnComment.substring(0, $parentheseIndex))
  25. #else
  26. #set($comment=$column.columnComment)
  27. #end
  28. #set($field=$column.javaField)
  29. #set($dictType=$column.dictType)
  30. #if("" != $treeParentCode && $column.javaField == $treeParentCode)
  31. <div class="form-group">
  32. <label class="col-sm-3 control-label">${comment}:</label>
  33. <div class="col-sm-8">
  34. <div class="input-group">
  35. #set($BusinessName=$businessName.substring(0,1).toUpperCase() + ${businessName.substring(1)})
  36. <input id="treeId" name="${treeParentCode}" type="hidden" th:field="*{${treeParentCode}}" />
  37. <input class="form-control" type="text" onclick="select${BusinessName}Tree()" id="treeName" readonly="true" th:field="*{parentName}"#if($column.required) required#end>
  38. <span class="input-group-addon"><i class="fa fa-search"></i></span>
  39. </div>
  40. </div>
  41. </div>
  42. #elseif($column.htmlType == "input")
  43. <div class="form-group">
  44. <label class="col-sm-3 control-label#if($column.required) is-required#end">${comment}:</label>
  45. <div class="col-sm-8">
  46. <input name="${field}" th:field="*{${field}}" class="form-control" type="text"#if($column.required) required#end>
  47. </div>
  48. </div>
  49. #elseif($column.htmlType == "select" && "" != $dictType)
  50. <div class="form-group">
  51. <label class="col-sm-3 control-label">${comment}:</label>
  52. <div class="col-sm-8">
  53. <select name="${field}" class="form-control m-b" th:with="type=${@dict.getType('${dictType}')}"#if($column.required) required#end>
  54. <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{${field}}"></option>
  55. </select>
  56. </div>
  57. </div>
  58. #elseif($column.htmlType == "select" && $dictType)
  59. <div class="form-group">
  60. <label class="col-sm-3 control-label">${comment}:</label>
  61. <div class="col-sm-8">
  62. <select name="${field}" class="form-control m-b"#if($column.required) required#end>
  63. <option value="">所有</option>
  64. </select>
  65. <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
  66. </div>
  67. </div>
  68. #elseif($column.htmlType == "checkbox" && "" != $dictType)
  69. <div class="form-group">
  70. <label class="col-sm-3 control-label">${comment}:</label>
  71. <div class="col-sm-8" th:with="type=${@dict.getType('${dictType}')}">
  72. <label th:each="dict : ${type}" class="check-box">
  73. <input name="${field}" type="checkbox" th:value="${dict.dictValue}" th:text="${dict.dictLabel}" th:attr="checked=${${className}.${field}.contains(dict.dictValue)?true:false}"#if($column.required) required#end>
  74. </label>
  75. </div>
  76. </div>
  77. #elseif($column.htmlType == "checkbox" && $dictType)
  78. <div class="form-group">
  79. <label class="col-sm-3 control-label">${comment}:</label>
  80. <div class="col-sm-8">
  81. <label class="check-box">
  82. <input name="${field}" type="checkbox"#if($column.required) required#end> 无
  83. </label>
  84. <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
  85. </div>
  86. </div>
  87. #elseif($column.htmlType == "radio" && "" != $dictType)
  88. <div class="form-group">
  89. <label class="col-sm-3 control-label">${comment}:</label>
  90. <div class="col-sm-8">
  91. <div class="radio-box" th:each="dict : ${@dict.getType('${dictType}')}">
  92. <input type="radio" th:id="${'${field}_' + dict.dictCode}" name="${field}" th:value="${dict.dictValue}" th:field="*{${field}}"#if($column.required) required#end>
  93. <label th:for="${'${field}_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
  94. </div>
  95. </div>
  96. </div>
  97. #elseif($column.htmlType == "radio" && $dictType)
  98. <div class="form-group">
  99. <label class="col-sm-3 control-label">${comment}:</label>
  100. <div class="col-sm-8">
  101. <div class="radio-box">
  102. <input type="radio" name="${field}" value=""#if($column.required) required#end>
  103. <label th:for="${field}" th:text="未知"></label>
  104. </div>
  105. <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
  106. </div>
  107. </div>
  108. #elseif($column.htmlType == "datetime")
  109. <div class="form-group">
  110. <label class="col-sm-3 control-label">${comment}:</label>
  111. <div class="col-sm-8">
  112. <div class="input-group date">
  113. <input name="${field}" th:value="${#dates.format(${className}.${field}, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text"#if($column.required) required#end>
  114. <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
  115. </div>
  116. </div>
  117. </div>
  118. #elseif($column.htmlType == "textarea")
  119. <div class="form-group">
  120. <label class="col-sm-3 control-label">${comment}:</label>
  121. <div class="col-sm-8">
  122. <textarea name="${field}" class="form-control"#if($column.required) required#end>[[*{${field}}]]</textarea>
  123. </div>
  124. </div>
  125. #end
  126. #end
  127. #end
  128. #end
  129. #if($table.sub)
  130. <h4 class="form-header h4">${subTable.functionName}信息</h4>
  131. <div class="row">
  132. <div class="col-sm-12">
  133. <button type="button" class="btn btn-white btn-sm" onclick="addColumn()"><i class="fa fa-plus"> 增加</i></button>
  134. <button type="button" class="btn btn-white btn-sm" onclick="sub.delColumn()"><i class="fa fa-minus"> 删除</i></button>
  135. <div class="col-sm-12 select-table table-striped">
  136. <table id="bootstrap-table"></table>
  137. </div>
  138. </div>
  139. </div>
  140. #end
  141. </form>
  142. </div>
  143. <th:block th:include="include :: footer" />
  144. #foreach($column in $columns)
  145. #if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
  146. <th:block th:include="include :: datetimepicker-js" />
  147. #break
  148. #end
  149. #end
  150. <script th:inline="javascript">
  151. var prefix = ctx + "${moduleName}/${businessName}";
  152. #if($table.sub)
  153. #foreach($column in $subTable.columns)
  154. #if(${column.dictType} != '')
  155. var ${column.javaField}Datas = [[${@dict.getType('${column.dictType}')}]];
  156. #end
  157. #end
  158. #end
  159. $("#form-${businessName}-edit").validate({
  160. focusCleanup: true
  161. });
  162. function submitHandler() {
  163. if ($.validate.form()) {
  164. $.operate.save(prefix + "/edit", $('#form-${businessName}-edit').serialize());
  165. }
  166. }
  167. #foreach($column in $columns)
  168. #if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
  169. $("input[name='$column.javaField']").datetimepicker({
  170. format: "yyyy-mm-dd",
  171. minView: "month",
  172. autoclose: true
  173. });
  174. #end
  175. #end
  176. #if($table.tree)
  177. /*${functionName}-新增-选择父部门树*/
  178. function select${BusinessName}Tree() {
  179. var options = {
  180. title: '${functionName}选择',
  181. width: "380",
  182. url: prefix + "/select${BusinessName}Tree/" + $("#treeId").val(),
  183. callBack: doSubmit
  184. };
  185. $.modal.openOptions(options);
  186. }
  187. function doSubmit(index, layero){
  188. var body = layer.getChildFrame('body', index);
  189. $("#treeId").val(body.find('#treeId').val());
  190. $("#treeName").val(body.find('#treeName').val());
  191. layer.close(index);
  192. }
  193. #end
  194. #if($table.sub)
  195. $(function() {
  196. var options = {
  197. data: [[${${className}.${subclassName}List}]],
  198. pagination: false,
  199. showSearch: false,
  200. showRefresh: false,
  201. showToggle: false,
  202. showColumns: false,
  203. columns: [{
  204. checkbox: true
  205. },
  206. {
  207. field: 'index',
  208. align: 'center',
  209. title: "序号"
  210. },
  211. #foreach($column in $subTable.columns)
  212. #set($dictType=$column.dictType)
  213. #set($javaField=$column.javaField)
  214. #set($parentheseIndex=$column.columnComment.indexOf("("))
  215. #if($parentheseIndex != -1)
  216. #set($comment=$column.columnComment.substring(0, $parentheseIndex))
  217. #else
  218. #set($comment=$column.columnComment)
  219. #end
  220. #if($column.pk || $javaField == ${subTableFkclassName})
  221. #elseif($column.list && "" != $dictType)
  222. {
  223. field: '${javaField}',
  224. align: 'center',
  225. title: '${comment}',
  226. formatter: function(value, row, index) {
  227. var name = $.common.sprintf("${subclassName}List[%s].${javaField}", index);
  228. return $.common.dictToSelect(${javaField}Datas, value, name);
  229. }
  230. #if($velocityCount != $subTable.columns.size())},#end
  231. #else
  232. {
  233. field: '${javaField}',
  234. align: 'center',
  235. title: '${comment}',
  236. formatter: function(value, row, index) {
  237. var html = $.common.sprintf("<input class='form-control' type='text' name='${subclassName}List[%s].${javaField}' value='%s'>", index, value);
  238. return html;
  239. }
  240. #if($velocityCount != $subTable.columns.size())},#end
  241. #end
  242. #end
  243. }]
  244. };
  245. $.table.init(options);
  246. sub.resetIndex();
  247. });
  248. function addColumn() {
  249. var count = $("#" + table.options.id).bootstrapTable('getData').length;
  250. sub.editColumn();
  251. $("#" + table.options.id).bootstrapTable('insertRow', {
  252. index: count,
  253. row: {
  254. index: $.table.serialNumber(count),
  255. #foreach($column in $subTable.columns)
  256. #set($javaField=$column.javaField)
  257. #if($column.pk || $javaField == ${subTableFkclassName})
  258. #else
  259. ${javaField}: ""#if($velocityCount != $subTable.columns.size()),#end
  260. #end
  261. #end
  262. }
  263. });
  264. sub.resetIndex();
  265. }
  266. #end
  267. </script>
  268. </body>
  269. </html>