cgform_jspTemplate_add.ftl 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
  2. <%@include file="/context/mytags.jsp"%>
  3. <#-- update--begin--author:zhangjiaqiang Date:20170509 for:修订生成页面乱 -->
  4. <#include "../../ui/datatype.ftl"/>
  5. <#include "../../ui/dictInfo.ftl"/>
  6. <#-- update--end--author:zhangjiaqiang Date:20170509 for:修订生成页面乱 -->
  7. <!DOCTYPE html>
  8. <#assign callbackFlag = false />
  9. <#assign fileName = "" />
  10. <#list pageColumns as callBackTestPo>
  11. <#-- update--begin--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  12. <#if callBackTestPo.showType=='file' || callBackTestPo.showType == 'image'>
  13. <#assign callbackFlag = true />
  14. <#break>
  15. </#if>
  16. <#-- update--end--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  17. </#list>
  18. <html>
  19. <head>
  20. <title>${ftl_description}</title>
  21. <t:base type="jquery,easyui,tools,DatePicker"></t:base>
  22. <#if callbackFlag == true>
  23. <link rel="stylesheet" href="plug-in/uploadify/css/uploadify.css" type="text/css" />
  24. <script type="text/javascript" src="plug-in/uploadify/jquery.uploadify-3.1.js"></script>
  25. </#if>
  26. <script src="plug-in/layer/layer.js"></script>
  27. <script>
  28. function btn_ok(){
  29. $("#btnsub").click();
  30. }
  31. function callback(data){
  32. <#if callbackFlag == true>
  33. jeecgFormFileCallBack(data);
  34. </#if>
  35. if(data.success){
  36. layer.alert(data.msg, function(index){
  37. window.location.href="${entityName?uncap_first}Controller.do?list"
  38. layer.close(index);
  39. });
  40. }
  41. else{
  42. layer.alert(data.msg);
  43. }
  44. }
  45. </script>
  46. <script type="text/javascript">
  47. //编写自定义JS代码
  48. </script>
  49. </head>
  50. <body>
  51. <#-- update--begin--author:zhangjiaqiang date:20170522 for:ueditor配置文件只加载一次 -->
  52. <#assign ue_widget_count = 0>
  53. <#-- update--end--author:zhangjiaqiang date:20170522 for:ueditor配置文件只加载一次 -->
  54. <t:formvalid formid="formobj" dialog="false" usePlugin="password" layout="table" action="${entityName?uncap_first}Controller.do?doAdd" tiptype="1" callback="callback">
  55. <#list columns as po>
  56. <#if po.isShow == 'N'>
  57. <#-- update--begin--author:zhoujf date:20170622 for:TASK #1967 【代码生成器优化】online生成代码,无用太多,简化代码(1. 系统标准字段,表单页面,添加和修改页面,不生成隐藏字段) -->
  58. <#if po.fieldName == 'id'>
  59. <input id="${po.fieldName}" name="${po.fieldName}" type="hidden" value="${'$'}{${entityName?uncap_first}Page.${po.fieldName} }"/>
  60. </#if>
  61. <#-- update--end--author:zhoujf date:20170622 for:TASK #1967 【代码生成器优化】online生成代码,无用太多,简化代码(1. 系统标准字段,表单页面,添加和修改页面,不生成隐藏字段) -->
  62. </#if>
  63. </#list>
  64. <table style="width: 600px;" cellpadding="0" cellspacing="1" class="formtable">
  65. <#list pageColumns as po>
  66. <#if (pageColumns?size>10)>
  67. <#if po_index%2==0>
  68. <tr>
  69. </#if>
  70. <#else>
  71. <tr>
  72. </#if>
  73. <td align="right">
  74. <label class="Validform_label">
  75. ${po.content}:
  76. </label>
  77. </td>
  78. <td class="value">
  79. <#if po.showType=='text'>
  80. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  81. <input id="${po.fieldName}" name="${po.fieldName}" type="text" style="width: 150px" class="inputxt" <@datatype validType="${po.fieldValidType!''}" isNull="${po.isNull}" type="${po.type}" mustInput="${po.fieldMustInput!''}"/>/>
  82. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  83. <#elseif po.showType=='popup'>
  84. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  85. <input id="${po.fieldName}" name="${po.fieldName}" type="text" style="width: 150px" class="searchbox-inputtext" <@datatype validType="${po.fieldValidType!''}" isNull="${po.isNull}" type="${po.type}" mustInput="${po.fieldMustInput!''}"/><#if po.dictTable?if_exists?html!=""> onclick="inputClick(this,'${po.dictField}','${po.dictTable}')"</#if>/>
  86. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  87. <#elseif po.showType=='textarea'>
  88. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  89. <textarea style="width:600px;" class="inputxt" rows="6" id="${po.fieldName}" name="${po.fieldName}" <@datatype validType="${po.fieldValidType!''}" isNull="${po.isNull}" type="${po.type}" mustInput="${po.fieldMustInput!''}"/>></textarea>
  90. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  91. <#elseif po.showType=='password'>
  92. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  93. <input id="${po.fieldName}" name="${po.fieldName}" type="password" style="width: 150px" class="inputxt" <@datatype validType="${po.fieldValidType!''}" isNull="${po.isNull}" type="${po.type}" mustInput="${po.fieldMustInput!''}"/>/>
  94. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  95. <#elseif po.showType=='radio' || po.showType=='select' || po.showType=='checkbox' || po.showType=='list'>
  96. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  97. <t:dictSelect field="${po.fieldName}" type="${po.showType?if_exists?html}"<@dictInfo dictTable="${po.dictTable}" dictField="${po.dictField}" dictText="${po.dictText}" /> <@datatype validType="${po.fieldValidType!''}" isNull="${po.isNull}" type="${po.type}" inputCheck="2"/> defaultVal="${'$'}{${entityName?uncap_first}Page.${po.fieldName}}" hasLabel="false" title="${po.content}"></t:dictSelect>
  98. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  99. <#elseif po.showType=='date'>
  100. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  101. <input id="${po.fieldName}" name="${po.fieldName}" type="text" style="width: 150px" class="Wdate" onClick="WdatePicker()"<@datatype showType="2" validType="${po.fieldValidType!''}" isNull="${po.isNull}" type="${po.type}" mustInput="${po.fieldMustInput!''}" isNull="${po.isNull}"/>/>
  102. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  103. <#elseif po.showType=='datetime'>
  104. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  105. <input id="${po.fieldName}" name="${po.fieldName}" type="text" style="width: 150px" class="Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" <@datatype showType="2" validType="${po.fieldValidType!''}" isNull="${po.isNull}" type="${po.type}" mustInput="${po.fieldMustInput!''}" isNull="${po.isNull}"/>/>
  106. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  107. <#-- update--begin--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  108. <#elseif po.showType=='file' || po.showType == 'image'>
  109. <#assign fileName = fileName + "${po.fieldName}," />
  110. <#-- update--end--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  111. <table></table>
  112. <div class="form jeecgDetail">
  113. <script type="text/javascript">
  114. var serverMsg="";
  115. $(function(){
  116. $('#${po.fieldName}').uploadify({
  117. <#-- update--begin--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  118. <#if po.showType == 'image'>
  119. buttonText:'添加图片',
  120. <#else>
  121. buttonText:'添加文件',
  122. </#if>
  123. <#-- update--end--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  124. auto:false,
  125. progressData:'speed',
  126. multi:true,
  127. height:25,
  128. overrideEvents:['onDialogClose'],
  129. fileTypeDesc:'文件格式:',
  130. <#-- update--begin--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  131. queueID:'filediv_${po.fieldName}',
  132. <#-- update--end--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  133. <#-- fileTypeExts:'*.rar;*.zip;*.doc;*.docx;*.txt;*.ppt;*.xls;*.xlsx;*.html;*.htm;*.pdf;*.jpg;*.gif;*.png', 页面弹出很慢解决 20170317 scott -->
  134. fileSizeLimit:'15MB',
  135. swf:'plug-in/uploadify/uploadify.swf',
  136. uploader:'cgUploadController.do?saveFiles&jsessionid='+$("#sessionUID").val()+'',
  137. onUploadStart : function(file) {
  138. var cgFormId=$("input[name='id']").val();
  139. $('#${po.fieldName}').uploadify("settings", "formData", {
  140. 'cgFormId':cgFormId,
  141. 'cgFormName':'${tableName}',
  142. 'cgFormField':'${fieldMeta[po.fieldName]}'
  143. });
  144. } ,
  145. onQueueComplete : function(queueData) {
  146. },
  147. onUploadSuccess : function(file, data, response) {
  148. var d=$.parseJSON(data);
  149. if(d.success){
  150. serverMsg = d.msg;
  151. }
  152. },
  153. onFallback: function() {
  154. tip("您未安装FLASH控件,无法上传图片!请安装FLASH控件后再试")
  155. },
  156. onSelectError: function(file, errorCode, errorMsg) {
  157. switch (errorCode) {
  158. case - 100 : tip("上传的文件数量已经超出系统限制的" + $('#file').uploadify('settings', 'queueSizeLimit') + "个文件!");
  159. break;
  160. case - 110 : tip("文件 [" + file.name + "] 大小超出系统限制的" + $('#file').uploadify('settings', 'fileSizeLimit') + "大小!");
  161. break;
  162. case - 120 : tip("文件 [" + file.name + "] 大小异常!");
  163. break;
  164. case - 130 : tip("文件 [" + file.name + "] 类型不正确!");
  165. break;
  166. }
  167. },
  168. onUploadProgress: function(file, bytesUploaded, bytesTotal, totalBytesUploaded, totalBytesTotal) {}
  169. });
  170. });
  171. </script>
  172. <span id="file_uploadspan"><input type="file" name="${po.fieldName}" id="${po.fieldName}" /></span>
  173. </div>
  174. <#-- update--begin--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  175. <div class="form" id="filediv_${po.fieldName}"></div>
  176. <#-- update--end--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  177. <#--update-start--Author: jg_huangxg Date:20160421 for:TASK #1027 【online】代码生成器模板不支持UE编辑器 -->
  178. <#elseif po.showType='umeditor'>
  179. <#-- update--begin--author:zhangjiaqiang date:20170522 for:ueditor配置文件只加载一次 -->
  180. <#assign ue_widget_count = ue_widget_count + 1>
  181. <#if ue_widget_count == 1>
  182. <script type="text/javascript" charset="utf-8" src="plug-in/ueditor/ueditor.config.js"></script>
  183. <script type="text/javascript" charset="utf-8" src="plug-in/ueditor/ueditor.all.min.js"></script>
  184. </#if>
  185. <#-- update--end--author:zhangjiaqiang date:20170522 for:ueditor配置文件只加载一次 -->
  186. <textarea name="${po.fieldName}" id="${po.fieldName}" style="width: 650px;height:300px"></textarea>
  187. <script type="text/javascript">
  188. <#-- update--begin--author:zhangjiaqiang date:20170522 for:editor编辑器变量唯一 -->
  189. var ${po.fieldName}_editor = UE.getEditor('${po.fieldName}');
  190. <#-- update--begin--author:zhangjiaqiang date:20170522 for:editor编辑器变量唯一 -->
  191. </script>
  192. <#--update-end--Author: jg_huangxg Date:20160421 for:TASK #1027 【online】代码生成器模板不支持UE编辑器 -->
  193. <#else>
  194. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  195. <input id="${po.fieldName}" name="${po.fieldName}" type="text" style="width: 150px" class="inputxt" <@datatype validType="${po.fieldValidType!''}" isNull="${po.isNull}" type="${po.type}" mustInput="${po.fieldMustInput!''}" isNull="${po.isNull}"/>/>
  196. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  197. </#if>
  198. <span class="Validform_checktip"></span>
  199. <label class="Validform_label" style="display: none;">${po.content?if_exists?html}</label>
  200. </td>
  201. <#if (pageColumns?size>10)>
  202. <#if (po_index%2==0)&&(!po_has_next)>
  203. <td align="right">
  204. <label class="Validform_label">
  205. </label>
  206. </td>
  207. <td class="value">
  208. </td>
  209. </#if>
  210. <#if (po_index%2!=0)||(!po_has_next)>
  211. </tr>
  212. </#if>
  213. <#else>
  214. </tr>
  215. </#if>
  216. </#list>
  217. <#-- update--begin--author:zhoujf Date:20170523 for:TASK #1961 【代码生成器】一对多富文本编辑器,生成代码格式问题 -->
  218. <#list pageAreatextColumns as po>
  219. <tr>
  220. <td align="right">
  221. <label class="Validform_label">
  222. ${po.content}:
  223. </label>
  224. </td>
  225. <td class="value" <#if (pageColumns?size>10)> colspan="4" <#else> colspan="2" </#if>>
  226. <#if po.showType=='textarea'>
  227. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  228. <textarea style="width:600px;" class="inputxt" rows="6" id="${po.fieldName}" name="${po.fieldName}" <@datatype validType="${po.fieldValidType!''}" isNull="${po.isNull}" type="${po.type}" mustInput="${po.fieldMustInput!''}"/>></textarea>
  229. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  230. <#elseif po.showType='umeditor'>
  231. <#-- update--begin--author:zhangjiaqiang date:20170522 for:ueditor配置文件只加载一次 -->
  232. <#assign ue_widget_count = ue_widget_count + 1>
  233. <#if ue_widget_count == 1>
  234. <script type="text/javascript" charset="utf-8" src="plug-in/ueditor/ueditor.config.js"></script>
  235. <script type="text/javascript" charset="utf-8" src="plug-in/ueditor/ueditor.all.min.js"></script>
  236. </#if>
  237. <#-- update--end--author:zhangjiaqiang date:20170522 for:ueditor配置文件只加载一次 -->
  238. <textarea name="${po.fieldName}" id="${po.fieldName}" style="width: 650px;height:300px"></textarea>
  239. <script type="text/javascript">
  240. <#-- update--begin--author:zhangjiaqiang date:20170522 for:editor编辑器变量唯一 -->
  241. var ${po.fieldName}_editor = UE.getEditor('${po.fieldName}');
  242. <#-- update--begin--author:zhangjiaqiang date:20170522 for:editor编辑器变量唯一 -->
  243. </script>
  244. </#if>
  245. <span class="Validform_checktip"></span>
  246. <label class="Validform_label" style="display: none;">${po.content?if_exists?html}</label>
  247. </td>
  248. </tr>
  249. </#list>
  250. <#-- update--end--author:zhoujf Date:20170523 for:TASK #1961 【代码生成器】一对多富文本编辑器,生成代码格式问题 -->
  251. <tr>
  252. <td height="50px" align="center" colspan="2">
  253. <a style="margin-left:80px" href="#" class="easyui-linkbutton l-btn" plain="true" iconcls="icon-le-back" onclick="history.go(-1)">返回</a>
  254. <div style="display:none"><input type="submit" id ="btnsub" value=""/></div>
  255. <a href="#" class="easyui-linkbutton l-btn" iconcls="icon-le-ok" onclick="btn_ok()">提交</a>
  256. </td>
  257. </tr>
  258. </table>
  259. </t:formvalid>
  260. </body>
  261. <script src = "webpage/${bussiPackage?replace('.','/')}/${entityPackage}/${entityName?uncap_first}.js"></script>
  262. <#if callbackFlag == true>
  263. <script type="text/javascript">
  264. function jeecgFormFileCallBack(data){
  265. if (data.success == true) {
  266. uploadFile(data);
  267. } else {
  268. if (data.responseText == '' || data.responseText == undefined) {
  269. $.messager.alert('错误', data.msg);
  270. $.Hidemsg();
  271. } else {
  272. try {
  273. var emsg = data.responseText.substring(data.responseText.indexOf('错误描述'), data.responseText.indexOf('错误信息'));
  274. $.messager.alert('错误', emsg);
  275. $.Hidemsg();
  276. } catch(ex) {
  277. $.messager.alert('错误', data.responseText + '');
  278. }
  279. }
  280. return false;
  281. }
  282. }
  283. function upload() {
  284. <#-- update--begin--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  285. <#assign subFileName = fileName?substring(0,fileName?length - 1) />
  286. <#list subFileName?split(",") as name>
  287. $('#${name}').uploadify('upload', '*');
  288. </#list>
  289. <#-- update--end--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  290. }
  291. var neibuClickFlag = false;
  292. function neibuClick() {
  293. neibuClickFlag = true;
  294. $('#btn_sub').trigger('click');
  295. }
  296. function cancel() {
  297. <#-- update--begin--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  298. <#assign subFileName = fileName?substring(0,fileName?length - 1) />
  299. <#list subFileName?split(",") as name>
  300. $('#${name}').uploadify('cancel', '*');
  301. </#list>
  302. <#-- update--end--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  303. }
  304. function uploadFile(data){
  305. if(!$("input[name='id']").val()){
  306. if(data.obj!=null && data.obj!='undefined'){
  307. $("input[name='id']").val(data.obj.id);
  308. }
  309. }
  310. if($(".uploadify-queue-item").length>0){
  311. upload();
  312. }else{
  313. if (neibuClickFlag){
  314. alert(data.msg);
  315. neibuClickFlag = false;
  316. }
  317. }
  318. }
  319. </script>
  320. </#if>