cgform_jspTemplate_add.ftl 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
  2. <%@include file="/context/mytags.jsp"%>
  3. <!DOCTYPE html>
  4. <#assign callbackFlag = false />
  5. <#assign fileName = "" />
  6. <#list pageColumns as callBackTestPo>
  7. <#-- update--begin--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  8. <#if callBackTestPo.showType=='file' || callBackTestPo.showType=='image' >
  9. <#assign callbackFlag = true />
  10. <#break>
  11. </#if>
  12. <#-- update--end--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  13. </#list>
  14. <#-- update--begin--author:zhangjiaqiang Date:20170509 for:修订生成页面乱 -->
  15. <#include "../../ui/datatype.ftl"/>
  16. <#include "../../ui/dictInfo.ftl"/>
  17. <#-- update--end--author:zhangjiaqiang Date:20170509 for:修订生成页面乱 -->
  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. <#if cgformConfig.cgFormHead.isTree == 'Y'>
  27. <style type="text/css">
  28. .combo_self{height: 22px !important;width: 150px !important;}
  29. .layout-header .btn {
  30. margin:0;
  31. float: none !important;
  32. }
  33. .btn-default {
  34. height: 35px;
  35. line-height: 35px;
  36. font-size:14px;
  37. }
  38. </style>
  39. <script type="text/javascript">
  40. $(function(){
  41. $(".combo").removeClass("combo").addClass("combo combo_self");
  42. $(".combo").each(function(){
  43. $(this).parent().css("line-height","0px");
  44. });
  45. });
  46. /**树形列表数据转换**/
  47. function convertTreeData(rows, textField) {
  48. for(var i = 0; i < rows.length; i++) {
  49. var row = rows[i];
  50. row.text = row[textField];
  51. if(row.children) {
  52. row.state = "open";
  53. convertTreeData(row.children, textField);
  54. }
  55. }
  56. }
  57. /**树形列表加入子元素**/
  58. function joinTreeChildren(arr1, arr2) {
  59. for(var i = 0; i < arr1.length; i++) {
  60. var row1 = arr1[i];
  61. for(var j = 0; j < arr2.length; j++) {
  62. if(row1.id == arr2[j].id) {
  63. var children = arr2[j].children;
  64. if(children) {
  65. row1.children = children;
  66. }
  67. }
  68. }
  69. }
  70. }
  71. </script>
  72. </#if>
  73. <script type="text/javascript">
  74. //编写自定义JS代码
  75. </script>
  76. </head>
  77. <body>
  78. <#-- update--begin--author:zhangjiaqiang date:20170522 for:ueditor配置文件只加载一次 -->
  79. <#assign ue_widget_count = 0>
  80. <#-- update--end--author:zhangjiaqiang date:20170522 for:ueditor配置文件只加载一次 -->
  81. <t:formvalid formid="formobj" dialog="true" usePlugin="password" layout="table" action="${entityName?uncap_first}Controller.do?doAdd" ${callbackFlag?string("callback=\"jeecgFormFileCallBack@Override\"", "")}>
  82. <#list columns as po>
  83. <#if po.isShow == 'N'>
  84. <#-- update--begin--author:zhoujf date:20170622 for:TASK #1967 【代码生成器优化】online生成代码,无用太多,简化代码(1. 系统标准字段,表单页面,添加和修改页面,不生成隐藏字段) -->
  85. <#if po.fieldName == 'id'>
  86. <input id="${po.fieldName}" name="${po.fieldName}" type="hidden" value="${'$'}{${entityName?uncap_first}Page.${po.fieldName} }"/>
  87. </#if>
  88. <#-- update--end--author:zhoujf date:20170622 for:TASK #1967 【代码生成器优化】online生成代码,无用太多,简化代码(1. 系统标准字段,表单页面,添加和修改页面,不生成隐藏字段) -->
  89. </#if>
  90. </#list>
  91. <table style="width: 600px;" cellpadding="0" cellspacing="1" class="formtable">
  92. <#list pageColumns as po>
  93. <#if (pageColumns?size>10)>
  94. <#if po_index%2==0>
  95. <tr>
  96. </#if>
  97. <#else>
  98. <tr>
  99. </#if>
  100. <td align="right">
  101. <label class="Validform_label">
  102. ${po.content}:
  103. </label>
  104. </td>
  105. <td class="value">
  106. <#if cgformConfig.cgFormHead.isTree=='Y' && cgformConfig.cgFormHead.treeParentIdFieldNamePage==po.fieldName>
  107. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  108. <input id="${po.fieldName}" name="${po.fieldName}" type="text" style="width: 150px" class="inputxt easyui-combotree" <@datatype validType="${po.fieldValidType!''}" isNull="${po.isNull}" type="${po.type}" mustInput="${po.fieldMustInput!''}"/>
  109. <#-- update--end--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  110. data-options="panelHeight:'220',
  111. url: '${entityName?uncap_first}Controller.do?datagrid&field=id,${cgformConfig.cgFormHead.treeFieldnamePage}',
  112. loadFilter: function(data) {
  113. var rows = data.rows || data;
  114. var win = frameElement.api.opener;
  115. var listRows = win.getDataGrid().treegrid('getData');
  116. joinTreeChildren(rows, listRows);
  117. convertTreeData(rows, '${cgformConfig.cgFormHead.treeFieldnamePage}');
  118. return rows;
  119. },
  120. <#-- update--begin--author:zhangjiaqiang Date:20170518 for:修订树形菜单选择必填项问题-->
  121. onSelect:function(node){
  122. $('#${po.fieldName}').val(node.id);
  123. },
  124. <#-- update--end--author:zhangjiaqiang Date:20170518 for:修订树形菜单选择必填项问题 -->
  125. onLoadSuccess: function() {
  126. var win = frameElement.api.opener;
  127. var currRow = win.getDataGrid().treegrid('getSelected');
  128. if(!'${'$'}{${entityName?uncap_first}Page.id}') {
  129. //增加时,选择当前父菜单
  130. if(currRow) {
  131. $('#${po.fieldName}').combotree('setValue', currRow.id);
  132. }
  133. }else {
  134. //编辑时,选择当前父菜单
  135. if(currRow) {
  136. $('#${po.fieldName}').combotree('setValue', currRow.${po.fieldName});
  137. }
  138. }
  139. }"/>
  140. <#elseif po.showType=='text'>
  141. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  142. <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!''}" />/>
  143. <#-- update--end--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  144. <#elseif po.showType=='popup'>
  145. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  146. <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> />
  147. <#-- update--end--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  148. <#elseif po.showType=='textarea'>
  149. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  150. <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>
  151. <#-- update--end--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  152. <#elseif po.showType=='password'>
  153. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  154. <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!''}" />/>
  155. <#-- update--end--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  156. <#elseif po.showType=='radio' || po.showType=='select' || po.showType=='checkbox' || po.showType=='list'>
  157. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  158. <t:dictSelect field="${po.fieldName}" type="${po.showType?if_exists?html}" <@datatype inputCheck="2" validType="${po.fieldValidType!''}" isNull="${po.isNull}" type="${po.type}" mustInput="${po.fieldMustInput!''}" isNull="${po.isNull}"/><@dictInfo dictTable="${po.dictTable}" dictField="${po.dictField}" dictText="${po.dictText}" /> defaultVal="${'$'}{${entityName?uncap_first}Page.${po.fieldName}}" hasLabel="false" title="${po.content}" ></t:dictSelect>
  159. <#-- update--end--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  160. <#elseif po.showType=='date'>
  161. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  162. <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}"/>/>
  163. <#-- update--end--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  164. <#elseif po.showType=='datetime'>
  165. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  166. <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!''}" />/>
  167. <#-- update--end--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  168. <#elseif po.showType=='file' || po.showType == 'image'>
  169. <#-- update--begin--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  170. <#assign fileName = fileName + "${po.fieldName}," />
  171. <#-- update--end--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  172. <table></table>
  173. <div class="form jeecgDetail">
  174. <script type="text/javascript">
  175. var serverMsg="";
  176. $(function(){
  177. $('#${po.fieldName}').uploadify({
  178. <#-- update--begin--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  179. <#if po.showType == 'image'>
  180. buttonText:'添加图片',
  181. <#else>
  182. buttonText:'添加文件',
  183. </#if>
  184. <#-- update--end--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  185. auto:false,
  186. progressData:'speed',
  187. multi:true,
  188. height:25,
  189. overrideEvents:['onDialogClose'],
  190. fileTypeDesc:'文件格式:',
  191. <#-- update--begin--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  192. queueID:'filediv_${po.fieldName}',
  193. <#-- update--end--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  194. <#-- fileTypeExts:'*.rar;*.zip;*.doc;*.docx;*.txt;*.ppt;*.xls;*.xlsx;*.html;*.htm;*.pdf;*.jpg;*.gif;*.png', 页面弹出很慢解决 20170317 scott -->
  195. fileSizeLimit:'15MB',
  196. swf:'plug-in/uploadify/uploadify.swf',
  197. uploader:'cgUploadController.do?saveFiles&jsessionid='+$("#sessionUID").val()+'',
  198. onUploadStart : function(file) {
  199. var cgFormId=$("input[name='id']").val();
  200. $('#${po.fieldName}').uploadify("settings", "formData", {
  201. 'cgFormId':cgFormId,
  202. 'cgFormName':'${tableName}',
  203. 'cgFormField':'${fieldMeta[po.fieldName]}'
  204. });
  205. } ,
  206. onQueueComplete : function(queueData) {
  207. var win = frameElement.api.opener;
  208. win.reloadTable();
  209. win.tip(serverMsg);
  210. frameElement.api.close();
  211. },
  212. onUploadSuccess : function(file, data, response) {
  213. var d=$.parseJSON(data);
  214. if(d.success){
  215. var win = frameElement.api.opener;
  216. serverMsg = d.msg;
  217. }
  218. },
  219. onFallback: function() {
  220. tip("您未安装FLASH控件,无法上传图片!请安装FLASH控件后再试")
  221. },
  222. onSelectError: function(file, errorCode, errorMsg) {
  223. switch (errorCode) {
  224. case - 100 : tip("上传的文件数量已经超出系统限制的" + $('#file').uploadify('settings', 'queueSizeLimit') + "个文件!");
  225. break;
  226. case - 110 : tip("文件 [" + file.name + "] 大小超出系统限制的" + $('#file').uploadify('settings', 'fileSizeLimit') + "大小!");
  227. break;
  228. case - 120 : tip("文件 [" + file.name + "] 大小异常!");
  229. break;
  230. case - 130 : tip("文件 [" + file.name + "] 类型不正确!");
  231. break;
  232. }
  233. },
  234. onUploadProgress: function(file, bytesUploaded, bytesTotal, totalBytesUploaded, totalBytesTotal) {}
  235. });
  236. });
  237. </script>
  238. <span id="file_uploadspan"><input type="file" name="${po.fieldName}" id="${po.fieldName}" /></span>
  239. </div>
  240. <#-- update--begin--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  241. <div class="form" id="filediv_${po.fieldName}"></div>
  242. <#-- update--end--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  243. <#--update-start--Author: jg_huangxg Date:20160421 for:TASK #1027 【online】代码生成器模板不支持UE编辑器 -->
  244. <#elseif po.showType='umeditor'>
  245. <#-- update--begin--author:zhangjiaqiang date:20170522 for:ueditor配置文件只加载一次 -->
  246. <#assign ue_widget_count = ue_widget_count + 1>
  247. <#if ue_widget_count == 1>
  248. <script type="text/javascript" charset="utf-8" src="plug-in/ueditor/ueditor.config.js"></script>
  249. <script type="text/javascript" charset="utf-8" src="plug-in/ueditor/ueditor.all.min.js"></script>
  250. </#if>
  251. <#-- update--end--author:zhangjiaqiang date:20170522 for:ueditor配置文件只加载一次 -->
  252. <textarea name="${po.fieldName}" id="${po.fieldName}" style="width: 650px;height:300px"></textarea>
  253. <script type="text/javascript">
  254. <#-- update--begin--author:zhangjiaqiang date:20170522 for:editor编辑器变量唯一 -->
  255. var ${po.fieldName}_editor = UE.getEditor('${po.fieldName}');
  256. <#-- update--begin--author:zhangjiaqiang date:20170522 for:editor编辑器变量唯一 -->
  257. </script>
  258. <#--update-end--Author: jg_huangxg Date:20160421 for:TASK #1027 【online】代码生成器模板不支持UE编辑器 -->
  259. <#else>
  260. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  261. <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!''}" />/>
  262. <#-- update--end--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  263. </#if>
  264. <span class="Validform_checktip"></span>
  265. <label class="Validform_label" style="display: none;">${po.content?if_exists?html}</label>
  266. </td>
  267. <#-- update--begin--author:zhoujf Date:20170601 for:table表单生成验收乱问题 -->
  268. <#if (pageColumns?size>10)>
  269. <#-- update--end--author:zhoujf Date:20170601 for:table表单生成验收乱问题 -->
  270. <#if (po_index%2==0)&&(!po_has_next)>
  271. <td align="right">
  272. <label class="Validform_label">
  273. </label>
  274. </td>
  275. <td class="value">
  276. </td>
  277. </#if>
  278. <#if (po_index%2!=0)||(!po_has_next)>
  279. </tr>
  280. </#if>
  281. <#else>
  282. </tr>
  283. </#if>
  284. </#list>
  285. <#-- update--begin--author:zhoujf Date:20170523 for:TASK #1961 【代码生成器】一对多富文本编辑器,生成代码格式问题 -->
  286. <#list pageAreatextColumns as po>
  287. <tr>
  288. <td align="right">
  289. <label class="Validform_label">
  290. ${po.content}:
  291. </label>
  292. </td>
  293. <td class="value" <#if (pageColumns?size>10)> colspan="3" </#if>>
  294. <#if po.showType=='textarea'>
  295. <#-- update--begin--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  296. <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>
  297. <#-- update--end--author:zhangjiaqiangDate:20170509 for:修订生成代码不美观 -->
  298. <#elseif po.showType='umeditor'>
  299. <#-- update--begin--author:zhangjiaqiang date:20170522 for:ueditor配置文件只加载一次 -->
  300. <#assign ue_widget_count = ue_widget_count + 1>
  301. <#if ue_widget_count == 1>
  302. <script type="text/javascript" charset="utf-8" src="plug-in/ueditor/ueditor.config.js"></script>
  303. <script type="text/javascript" charset="utf-8" src="plug-in/ueditor/ueditor.all.min.js"></script>
  304. </#if>
  305. <#-- update--end--author:zhangjiaqiang date:20170522 for:ueditor配置文件只加载一次 -->
  306. <textarea name="${po.fieldName}" id="${po.fieldName}" style="width: 650px;height:300px"></textarea>
  307. <script type="text/javascript">
  308. <#-- update--begin--author:zhangjiaqiang date:20170522 for:editor编辑器变量唯一 -->
  309. var ${po.fieldName}_editor = UE.getEditor('${po.fieldName}');
  310. <#-- update--begin--author:zhangjiaqiang date:20170522 for:editor编辑器变量唯一 -->
  311. </script>
  312. </#if>
  313. <span class="Validform_checktip"></span>
  314. <label class="Validform_label" style="display: none;">${po.content?if_exists?html}</label>
  315. </td>
  316. </tr>
  317. </#list>
  318. <#-- update--end--author:zhoujf Date:20170523 for:TASK #1961 【代码生成器】一对多富文本编辑器,生成代码格式问题 -->
  319. </table>
  320. </t:formvalid>
  321. </body>
  322. <script src = "webpage/${bussiPackage?replace('.','/')}/${entityPackage}/${entityName?uncap_first}.js"></script>
  323. <#if callbackFlag == true>
  324. <script type="text/javascript">
  325. function jeecgFormFileCallBack(data){
  326. if (data.success == true) {
  327. uploadFile(data);
  328. } else {
  329. if (data.responseText == '' || data.responseText == undefined) {
  330. $.messager.alert('错误', data.msg);
  331. $.Hidemsg();
  332. } else {
  333. try {
  334. var emsg = data.responseText.substring(data.responseText.indexOf('错误描述'), data.responseText.indexOf('错误信息'));
  335. $.messager.alert('错误', emsg);
  336. $.Hidemsg();
  337. } catch(ex) {
  338. $.messager.alert('错误', data.responseText + '');
  339. }
  340. }
  341. return false;
  342. }
  343. if (!neibuClickFlag) {
  344. var win = frameElement.api.opener;
  345. win.reloadTable();
  346. }
  347. }
  348. function upload() {
  349. <#-- update--begin--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  350. <#assign subFileName = fileName?substring(0,fileName?length - 1) />
  351. <#list subFileName?split(",") as name>
  352. $('#${name}').uploadify('upload', '*');
  353. </#list>
  354. <#-- update--end--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  355. }
  356. var neibuClickFlag = false;
  357. function neibuClick() {
  358. neibuClickFlag = true;
  359. $('#btn_sub').trigger('click');
  360. }
  361. function cancel() {
  362. <#-- update--begin--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  363. <#assign subFileName = fileName?substring(0,fileName?length - 1) />
  364. <#list subFileName?split(",") as name>
  365. $('#${name}').uploadify('cancel', '*');
  366. </#list>
  367. <#-- update--end--author:zhangjiaqiang date:20170531 for:增加图片和文件的支持 -->
  368. }
  369. function uploadFile(data){
  370. if(!$("input[name='id']").val()){
  371. if(data.obj!=null && data.obj!='undefined'){
  372. $("input[name='id']").val(data.obj.id);
  373. }
  374. }
  375. if($(".uploadify-queue-item").length>0){
  376. upload();
  377. }else{
  378. if (neibuClickFlag){
  379. alert(data.msg);
  380. neibuClickFlag = false;
  381. }else {
  382. var win = frameElement.api.opener;
  383. win.reloadTable();
  384. win.tip(data.msg);
  385. frameElement.api.close();
  386. }
  387. }
  388. }
  389. </script>
  390. </#if>