edit.html.vm 14 KB

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