edit.html.vm 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  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="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. <div class="input-group">
  47. #set($BusinessName=$businessName.substring(0,1).toUpperCase() + ${businessName.substring(1)})
  48. <input id="treeId" name="${treeParentCode}" type="hidden" th:field="*{${treeParentCode}}" />
  49. <input class="form-control" type="text" onclick="select${BusinessName}Tree()" id="treeName" readonly="true" th:field="*{parentName}"#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}" th:field="*{${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}" th:field="*{${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" th:field="*{${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}" th:field="*{${field}}"></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}" th:attr="checked=${${className}.${field}.contains(dict.dictValue)?true:false}"#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:field="*{${field}}"#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}" th:value="${#dates.format(${className}.${field}, 'yyyy-MM-dd')}" 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>[[*{${field}}]]</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.edit && !$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}-edit").validate({
  202. focusCleanup: true
  203. });
  204. function submitHandler() {
  205. if ($.validate.form()) {
  206. $.operate.save(prefix + "/edit", $('#form-${businessName}-edit').serialize());
  207. }
  208. }
  209. #foreach($column in $columns)
  210. #if($column.edit && !$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").each(function (i) {
  221. var val = $("input[name='" + this.id + "']").val()
  222. $(this).fileinput({
  223. 'uploadUrl': ctx + 'common/upload',
  224. initialPreviewAsData: true,
  225. initialPreview: [val],
  226. maxFileCount: 1,
  227. autoReplace: true
  228. }).on('fileuploaded', function (event, data, previewId, index) {
  229. $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
  230. }).on('fileremoved', function (event, id, index) {
  231. $("input[name='" + event.currentTarget.id + "']").val('')
  232. })
  233. $(this).fileinput('_initFileActions');
  234. });
  235. #break
  236. #end
  237. #end
  238. #foreach($column in $columns)
  239. #if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "summernote")
  240. $(function() {
  241. $('.summernote').each(function(i) {
  242. $('#' + this.id).summernote({
  243. lang: 'zh-CN',
  244. callbacks: {
  245. onChange: function(contents, $edittable) {
  246. $("input[name='" + this.id + "']").val(contents);
  247. },
  248. onImageUpload: function(files) {
  249. var obj = this;
  250. var data = new FormData();
  251. data.append("file", files[0]);
  252. $.ajax({
  253. type: "post",
  254. url: ctx + "common/upload",
  255. data: data,
  256. cache: false,
  257. contentType: false,
  258. processData: false,
  259. dataType: 'json',
  260. success: function(result) {
  261. if (result.code == web_status.SUCCESS) {
  262. $('#' + obj.id).summernote('insertImage', result.url);
  263. } else {
  264. $.modal.alertError(result.msg);
  265. }
  266. },
  267. error: function(error) {
  268. $.modal.alertWarning("图片上传失败。");
  269. }
  270. });
  271. }
  272. }
  273. });
  274. var content = $("input[name='" + this.id + "']").val();
  275. $('#' + this.id).summernote('code', content);
  276. })
  277. });
  278. #break
  279. #end
  280. #end
  281. #if($table.tree)
  282. /*${functionName}-编辑-选择父${functionName}树*/
  283. function select${BusinessName}Tree() {
  284. var options = {
  285. title: '${functionName}选择',
  286. width: "380",
  287. url: prefix + "/select${BusinessName}Tree/" + $("#treeId").val(),
  288. callBack: doSubmit
  289. };
  290. $.modal.openOptions(options);
  291. }
  292. function doSubmit(index, layero){
  293. var body = layer.getChildFrame('body', index);
  294. $("#treeId").val(body.find('#treeId').val());
  295. $("#treeName").val(body.find('#treeName').val());
  296. layer.close(index);
  297. }
  298. #end
  299. #if($table.sub)
  300. $(function() {
  301. var options = {
  302. data: [[${${className}.${subclassName}List}]],
  303. pagination: false,
  304. showSearch: false,
  305. showRefresh: false,
  306. showToggle: false,
  307. showColumns: false,
  308. sidePagination: "client",
  309. columns: [{
  310. checkbox: true
  311. },
  312. {
  313. field: 'index',
  314. align: 'center',
  315. title: "序号",
  316. formatter: function (value, row, index) {
  317. var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
  318. return columnIndex + $.table.serialNumber(index);
  319. }
  320. },
  321. #foreach($column in $subTable.columns)
  322. #set($dictType=$column.dictType)
  323. #set($javaField=$column.javaField)
  324. #set($parentheseIndex=$column.columnComment.indexOf("("))
  325. #if($parentheseIndex != -1)
  326. #set($comment=$column.columnComment.substring(0, $parentheseIndex))
  327. #else
  328. #set($comment=$column.columnComment)
  329. #end
  330. #if($column.pk || $javaField == ${subTableFkclassName})
  331. #elseif($column.list && "" != $dictType)
  332. {
  333. field: '${javaField}',
  334. align: 'center',
  335. title: '${comment}',
  336. formatter: function(value, row, index) {
  337. var name = $.common.sprintf("${subclassName}List[%s].${javaField}", index);
  338. return $.common.dictToSelect(${javaField}Datas, value, name);
  339. }
  340. #if($velocityCount != $subTable.columns.size())},#end
  341. #else
  342. {
  343. field: '${javaField}',
  344. align: 'center',
  345. title: '${comment}',
  346. formatter: function(value, row, index) {
  347. var html = $.common.sprintf("<input class='form-control' type='text' name='${subclassName}List[%s].${javaField}' value='%s'>", index, value);
  348. return html;
  349. }
  350. #if($velocityCount != $subTable.columns.size())},#end
  351. #end
  352. #end
  353. }]
  354. };
  355. $.table.init(options);
  356. });
  357. function addColumn() {
  358. var count = $("#" + table.options.id).bootstrapTable('getData').length;
  359. sub.editColumn();
  360. $("#" + table.options.id).bootstrapTable('insertRow', {
  361. index: count,
  362. row: {
  363. index: $.table.serialNumber(count),
  364. #foreach($column in $subTable.columns)
  365. #set($javaField=$column.javaField)
  366. #if($column.pk || $javaField == ${subTableFkclassName})
  367. #else
  368. ${javaField}: ""#if($velocityCount != $subTable.columns.size()),#end
  369. #end
  370. #end
  371. }
  372. });
  373. }
  374. #end
  375. </script>
  376. </body>
  377. </html>