add.html.vm 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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.insert && !$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}-add">
  21. #if($table.sub)
  22. <h4 class="form-header h4">${functionName}信息</h4>
  23. #end
  24. #foreach($column in $columns)
  25. #set($field=$column.javaField)
  26. #if($column.insert && !$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($dictType=$column.dictType)
  35. #if("" != $treeParentCode && $column.javaField == $treeParentCode)
  36. <div class="form-group">
  37. <label class="col-sm-3 control-label">${comment}:</label>
  38. <div class="col-sm-8">
  39. <div class="input-group">
  40. #set($BusinessName=$businessName.substring(0,1).toUpperCase() + ${businessName.substring(1)})
  41. #set($treeId = "${className}?.${treeCode}")
  42. <input id="treeId" name="${treeParentCode}" type="hidden" th:value="${${treeId}}"/>
  43. <input class="form-control" type="text" onclick="select${BusinessName}Tree()" id="treeName" readonly="true" th:value="${${treeName}}"#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}" 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}">
  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}"></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}"#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:checked="${dict.default}"#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}" 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></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.insert && !$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}-add").validate({
  182. focusCleanup: true
  183. });
  184. function submitHandler() {
  185. if ($.validate.form()) {
  186. $.operate.save(prefix + "/add", $('#form-${businessName}-add').serialize());
  187. }
  188. }
  189. #foreach($column in $columns)
  190. #if($column.insert && !$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").fileinput({
  201. uploadUrl: '/common/upload',
  202. maxFileCount: 1,
  203. autoReplace: true
  204. }).on('fileuploaded', function (event, data, previewId, index) {
  205. $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
  206. }).on('fileremoved', function (event, id, index) {
  207. $("input[name='" + event.currentTarget.id + "']").val('')
  208. })
  209. #break
  210. #end
  211. #end
  212. #if($table.tree)
  213. /*${functionName}-新增-选择父部门树*/
  214. function select${BusinessName}Tree() {
  215. var options = {
  216. title: '${functionName}选择',
  217. width: "380",
  218. url: prefix + "/select${BusinessName}Tree/" + $("#treeId").val(),
  219. callBack: doSubmit
  220. };
  221. $.modal.openOptions(options);
  222. }
  223. function doSubmit(index, layero){
  224. var body = layer.getChildFrame('body', index);
  225. $("#treeId").val(body.find('#treeId').val());
  226. $("#treeName").val(body.find('#treeName').val());
  227. layer.close(index);
  228. }
  229. #end
  230. #if($table.sub)
  231. $(function() {
  232. var options = {
  233. pagination: false,
  234. showSearch: false,
  235. showRefresh: false,
  236. showToggle: false,
  237. showColumns: false,
  238. columns: [{
  239. checkbox: true
  240. },
  241. {
  242. field: 'index',
  243. align: 'center',
  244. title: "序号",
  245. formatter: function (value, row, index) {
  246. var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
  247. return columnIndex + $.table.serialNumber(index);
  248. }
  249. },
  250. #foreach($column in $subTable.columns)
  251. #set($dictType=$column.dictType)
  252. #set($javaField=$column.javaField)
  253. #set($parentheseIndex=$column.columnComment.indexOf("("))
  254. #if($parentheseIndex != -1)
  255. #set($comment=$column.columnComment.substring(0, $parentheseIndex))
  256. #else
  257. #set($comment=$column.columnComment)
  258. #end
  259. #if($column.pk || $javaField == ${subTableFkclassName})
  260. #elseif($column.list && "" != $dictType)
  261. {
  262. field: '${javaField}',
  263. align: 'center',
  264. title: '${comment}',
  265. formatter: function(value, row, index) {
  266. var name = $.common.sprintf("${subclassName}List[%s].${javaField}", index);
  267. return $.common.dictToSelect(${javaField}Datas, value, name);
  268. }
  269. #if($velocityCount != $subTable.columns.size())},#end
  270. #else
  271. {
  272. field: '${javaField}',
  273. align: 'center',
  274. title: '${comment}',
  275. formatter: function(value, row, index) {
  276. var html = $.common.sprintf("<input class='form-control' type='text' name='${subclassName}List[%s].${javaField}' value='%s'>", index, value);
  277. return html;
  278. }
  279. #if($velocityCount != $subTable.columns.size())},#end
  280. #end
  281. #end
  282. }]
  283. };
  284. $.table.init(options);
  285. });
  286. function addColumn() {
  287. var count = $("#" + table.options.id).bootstrapTable('getData').length;
  288. sub.editColumn();
  289. $("#" + table.options.id).bootstrapTable('insertRow', {
  290. index: count,
  291. row: {
  292. index: $.table.serialNumber(count),
  293. #foreach($column in $subTable.columns)
  294. #set($javaField=$column.javaField)
  295. #if($column.pk || $javaField == ${subTableFkclassName})
  296. #else
  297. ${javaField}: ""#if($velocityCount != $subTable.columns.size()),#end
  298. #end
  299. #end
  300. }
  301. });
  302. }
  303. #end
  304. </script>
  305. </body>
  306. </html>