add.html.vm 16 KB

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