edit.html.vm 18 KB

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