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