editglt_nf.ftl 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <#setting url_escaping_charset='UTF-8'>
  2. <#-- 提取java枚举类型-->
  3. <#assign GtType={
  4. "LABEL":"01",
  5. "INPUT":"02",
  6. "TEXTAREA":"03",
  7. "COMBOBOX":"05",
  8. "DATEPICKER":"06",
  9. "RADIOBOX":"08",
  10. "CHECKBOX":"09",
  11. "BUTTON":"10",
  12. "LINK":"11",
  13. "IMG":"12",
  14. "SFZ":"18"
  15. }>
  16. <#-- 准备单选控件的值-->
  17. <#assign inputSets= {
  18. <#--子类型:[type类型,class名称,最大长度] -->
  19. "p":["text","postbox",6],<#-- 邮件编码-->
  20. "n":["text","numberbox",50],<#-- 只能输入数字-->
  21. "c":["text","chinessbox",50],<#-- 只能输入中文-->
  22. "f":["text","floatbox",50],<#-- 只能输入浮点数-->
  23. "d":["text","yearmonthbox",6],<#-- 只能输入YYYYMM格式的日期-->
  24. "t":["text","timebox",8],<#-- 只能输入时间格式-->
  25. "s":["text","datetime",19],<#-- 只能输入日期+时间 格式-->
  26. "m":["password","textbox",50],<#-- 密码输入框-->
  27. "x":["text","notpastebox",50],<#-- 不能粘贴的输入框-->
  28. " ":["text","textbox",50],<#-- 默认-->
  29. "b":["text","textbox",50]<#-- 默认-->
  30. }>
  31. <#assign colNames=(parameters.options.data.headers![])>
  32. <#--准备 生成TD所需的表头定义列(过滤多列表头,仅保留最后有效的一列)-->
  33. <#--macro 生成TD-->
  34. <#macro GT_TD v_input_comp v_data_one v_row_pos v_col_pos>
  35. <#assign v_pname=colNames[v_col_pos]!"" >
  36. <td field="${v_pname}" align="${v_input_comp.align!"center"}">
  37. <#assign compValue = v_data_one[("_DIC_"+v_pname)]!""
  38. hiddenValue = v_data_one[v_pname]!"">
  39. <#if compValue=="">
  40. <#assign compValue = hiddenValue>
  41. </#if>
  42. <#if hiddenValue?index_of("href")!=-1>
  43. <#assign hiddenValue = "">
  44. </#if>
  45. <div class=fweditgrid-cell>
  46. <#--全部的控件都不用NAME 用rw来表示行 用nd来表示列名,目的为了减少submit时提交的数据量-->
  47. <#switch v_input_comp.type>
  48. <#case GtType.LABEL>
  49. <label rw="${v_row_pos}" nd="${v_pname}" style="width:100%;" value="${hiddenValue}">${compValue}</label>
  50. <#break>
  51. <#case GtType.INPUT ><#--处理单行输入控件-->
  52. <#assign inputTmp=inputSets[v_input_comp.subtype]>
  53. <#if (compValue?is_sequence)>
  54. <#assign compValue=(compValue[0]?string)!"">
  55. </#if>
  56. <input title="${v_input_comp.tip}" type="${inputTmp[0]}" class="${inputTmp[1]}" maxlength="${v_input_comp.maxlength!inputTmp[2]}" rw="${v_row_pos}" nd="${v_pname}" value="${compValue}" vldStr="${v_input_comp.vld}" ${v_input_comp.cus} />
  57. <#break>
  58. <#case GtType.SFZ ><#--处理身份证 -->
  59. <#if (compValue?is_sequence)>
  60. <#assign compValue=(compValue[0]?string)!"">
  61. </#if>
  62. <input type="text" title="${v_input_comp.tip}" class="idcardbox" maxlength="${v_input_comp.maxlength!19}" rw="${v_row_pos}" nd="${v_pname}" value="${compValue}" vldStr="${v_input_comp.vld}" ${v_input_comp.cus} />
  63. <#break>
  64. <#case GtType.TEXTAREA ><#--处理多行输入控件 -->
  65. <#if (compValue?is_sequence)>
  66. <#assign compValue=(compValue[0]?string)!"">
  67. </#if>
  68. <textarea class="textareabox" title="${v_input_comp.tip}" rows="${v_input_comp.rows!3}" rw="${v_row_pos}" nd="${v_pname}" vldStr="${v_input_comp.vld}" ${v_input_comp.cus} >${compValue}</textarea>
  69. <#break>
  70. <#case GtType.DATEPICKER ><#--处理日期控件 -->
  71. <#if (compValue?is_sequence)>
  72. <#assign compValue=(compValue[0]?string)!"">
  73. </#if>
  74. <input type="text" class="datebox" title="${v_input_comp.tip}" rw="${v_row_pos}" nd="${v_pname}" vldStr="${v_input_comp.vld}" maxlength="${v_input_comp.maxlength!50}" value="${compValue}" ${v_input_comp.cus} />
  75. <#break>
  76. <#case GtType.BUTTON ><#--处理按钮-->
  77. <#if (compValue?is_sequence)>
  78. <#assign compValue=(compValue[0]?string)!"">
  79. </#if>
  80. <a class="buttonlink" ${v_input_comp.cus} rw="${v_row_pos}" nd="${v_pname}" title="${v_input_comp.tip}" >${compValue}</a>
  81. <#break>
  82. <#case GtType.CHECKBOX >
  83. <#-- 取控件的值-->
  84. <#if (hiddenValue?is_sequence)>
  85. <#assign hiddenValue=(hiddenValue[0]?string)!"">
  86. </#if>
  87. <#assign ck="" value=(v_input_comp.value)!"" chk=v_data_one[v_input_comp.chk]!"" >
  88. <#if chk=="1">
  89. <#assign ck="checked">
  90. </#if>
  91. <#-- 单checkbox处理 -->
  92. <input title="${v_input_comp.tip}" type="checkbox" class="checkbox" ${v_input_comp.cus} name="${v_pname}"
  93. rw="${v_row_pos}" nd="${v_pname}" value="${compValue}" vldStr="${v_input_comp.vld}" ${ck} />
  94. <#break>
  95. <#case GtType.RADIOBOX >
  96. <#if (hiddenValue?is_sequence)>
  97. <#assign hiddenValue=(hiddenValue[0]?string)!"">
  98. </#if>
  99. <#if (parameters.glt.dict[v_pname])??>
  100. <#-- 字典项处理 -->
  101. <#assign dicts=parameters.options.data.dicts[v_pname]!{}
  102. v_colNum=(v_input_comp.colNum?number)!10 >
  103. <table border=0 cellspacing=0 cellpadding=0 class="inputSet">
  104. <#list dicts?keys?chunk(v_colNum) as subkeys>
  105. <tr>
  106. <#list subkeys as key>
  107. <td align="right" style="border:0">
  108. <label>${dicts[key]!""}<input title="${v_input_comp.tip}" type="radio" class="radio" ${v_input_comp.cus}
  109. rw="${v_row_pos}" nd="${v_pname}" name="${v_row_pos+(v_pname)}" value="${key}"
  110. ${(hiddenValue=(key))?string("checked","")} /></label>
  111. </td>
  112. </#list>
  113. </tr>
  114. </#list>
  115. </table>
  116. <#else>
  117. <label>${v_input_comp.text!""}<input type="radio" title="${v_input_comp.tip}" class="radio"
  118. ${v_input_comp.cus} rw="${v_row_pos}" nd="${v_pname}" name="${v_pname}" value="${compValue!""}"
  119. vldStr="${v_input_comp.vld}" ${(hiddenValue=(v_input_comp.value!""))?string("checked","")} /></label>
  120. </#if>
  121. <#break>
  122. <#case GtType.COMBOBOX>
  123. <#if v_input_comp.subtype!='b'>
  124. <#assign v_readOnly='readOnly=true'>
  125. </#if>
  126. <#assign inputTmp=inputSets[v_input_comp.subtype]>
  127. <input type="text" class="${inputTmp[1]}" title="${v_input_comp.tip}" cmb="true" rw="${v_row_pos}" nd="${v_pname}_CMB" onfocus="${parameters.id}_combox(this,'${v_pname}');" maxlength="${v_input_comp.maxlength!50}" value="${compValue}" ${v_input_comp.cus} doselect="${v_input_comp.onselect!""}"<#rt>/>
  128. <input type="hidden" class="gltcom" rw="${v_row_pos}" nd="${v_pname}" vldStr="${v_input_comp.vld}" value="${hiddenValue}" />
  129. <#break>
  130. <#default>
  131. </#switch>
  132. </div>
  133. </td>
  134. </#macro>
  135. <#--生成单行记录的函数 -->
  136. <#macro GLT_TR v_rows_arr v_data_one bFixed irow icolOffset>
  137. <#if ((v_rows_arr?size)>0)>
  138. <tr fweditgrid-row-index=${irow} >
  139. <#if bFixed>
  140. <td class=fweditgrid-td-rownumber><div class=fweditgrid-cell-rownumber>${irow+1}</div></td>
  141. <#if parameters.showDelete=="true" >
  142. <td class=fweditgrid-td-opr><div class=fweditgrid-cell-opr><a class="gltlink" href="javascript:void(0)" onclick="${parameters.id}_delRow(this);return false;" >删除</a></div></td>
  143. </#if>
  144. </#if>
  145. <#list v_rows_arr as cols>
  146. <@GT_TD cols v_data_one irow icolOffset+cols_index/>
  147. </#list>
  148. </tr>
  149. <#else>
  150. <tr fweditgrid-row-index=${irow} >
  151. <#if bFixed>
  152. <td class=fweditgrid-td-rownumber><div class=fweditgrid-cell-rownumber>${irow+1}</div></td>
  153. <#if parameters.showDelete=="true" >
  154. <td class=fweditgrid-td-opr><div class=fweditgrid-cell-opr><a class="gltlink" href="javascript:void(0)" onclick="${parameters.id}_delRow(this);return false;" >删除</a></div></td>
  155. </#if>
  156. </#if>
  157. </tr>
  158. </#if>
  159. </#macro>
  160. <#--生成整个表单记录的函数 -->
  161. <#macro GLT_DATA v_data_arr bFixed>
  162. <#if ((v_data_arr?size)>0)>
  163. <#if bFixed>
  164. <#list v_data_arr as rows>
  165. <@GLT_TR parameters.lastHeaderRow rows true rows_index 0/>
  166. </#list>
  167. <#else>
  168. <#list v_data_arr as rows>
  169. <@GLT_TR v_colHead rows false rows_index parameters.options.frozenColumns/>
  170. </#list>
  171. </#if>
  172. <#else>
  173. <#if bFixed>
  174. <@GLT_TR parameters.lastHeaderRow {} true 0 0/>
  175. <#else>
  176. <@GLT_TR v_colHead {} false 0 0/>
  177. </#if>
  178. </#if>
  179. </#macro>
  180. <#macro GLT_HEADER v_head_arr isFixed>
  181. <div class=fweditgrid-header >
  182. <div class=fweditgrid-header-inner >
  183. <table border=0 cellspacing=0 cellpadding=0>
  184. <tbody>
  185. <#assign td_rownumber>
  186. <td rowspan=${v_head_arr?size}><div class=fweditgrid-header-rownumber></div></td>
  187. <#if parameters.showDelete=="true" >
  188. <td rowspan=${v_head_arr?size}><div class=fweditgrid-header-opr>操作</div></td>
  189. </#if>
  190. </#assign>
  191. <#list v_head_arr as row>
  192. <tr>
  193. ${td_rownumber!""}<#assign td_rownumber=""><#--只在第一行生成,其他行输出空 -->
  194. <#list row as col><#--列数据生成 -->
  195. <td rowspan=${col.rowspan!1} colspan=${col.colspan!1}>
  196. <#if !(col.lastRowIndex??)><#--标题组生成方式 -->
  197. <#if col.checkbox??><#--生成checkbox -->
  198. <div class=fweditgrid-cell <#if col.width??>width=${col.width}</#if> >
  199. <input type=checkbox class=fweditgrid-header-check>
  200. </div>
  201. <#else>
  202. <div class=fweditgrid-cell-group <#if col.width??>width=${col.width}</#if> >${col.title!""}</div>
  203. </#if>
  204. <#else><#--非标题组生成方式 -->
  205. <div class=fweditgrid-cell <#if col.width??>style="width=${col.width}"</#if> lastRowIndex="${col.lastRowIndex}">
  206. <#if col.checkbox??><#--生成checkbox -->
  207. <input type=checkbox class=fweditgrid-header-check>${col.title!""}
  208. <#else>
  209. <span>${col.title!""}</span><span>&nbsp;</span>
  210. </#if>
  211. </div>
  212. </#if>
  213. </td>
  214. </#list>
  215. </tr>
  216. </#list>
  217. </tbody>
  218. </table>
  219. </div>
  220. </div>
  221. </#macro>
  222. <#-- 开始生成多记录表脚本-->
  223. <#if parameters.hasTitle!true >
  224. <fieldset class="fieldset2" align="center" style="cursor:default;width:${parameters.width!"100%"}" >
  225. <legend class="legend" style="cursor:hand;" >
  226. <span onclick="_FW.oFtl.fnShowTable('img_${parameters.id}_grid','${parameters.id}')" >
  227. <img id="img_${parameters.id}_grid" src="${request.contextPath}/themes/default/images/query_icon_right.gif">
  228. </span>
  229. <span title="单击展开或收缩" onclick="_FW.oFtl.fnShowTable('img_${parameters.id}_grid','${parameters.id}')">
  230. ${parameters.title!(parameters.glt.title!'')}
  231. </span>
  232. </legend>
  233. </#if>
  234. <div align="left" style="width:100%" id="${parameters.id}" >
  235. <div class="fweditgrid"> <!-- 整个grid的外层 -->
  236. <div class="fweditgrid-wrap"> <!-- 整个grid的覆盖区 -->
  237. <#assign buildPage=(parameters.options.hasPage||(parameters.options.expbtn?length!"")>0) >
  238. <#if (["TOP","BOTH"]?seq_contains(parameters.pageAlign!"BOTTOM"))&&buildPage >
  239. <div class="fwdatagrid-pager"></div><!-- 整个grid的分页区 -->
  240. </#if>
  241. <div class="fweditgrid-view"> <!-- 整个grid的数据区 -->
  242. <@GLT_HEADER parameters.mergeHeader true />
  243. <div class=fweditgrid-body>
  244. <div class=fweditgrid-body-inner>
  245. <table class="gltDataTable" border=0 cellspacing=0 cellpadding=0>
  246. <@GLT_DATA parameters.options.data.rows true/><#---->
  247. </table>
  248. </div>
  249. </div>
  250. </div>
  251. <#if (["BOTTOM","BOTH"]?seq_contains(parameters.pageAlign!"BOTTOM"))&&buildPage >
  252. <div class="fweditgrid-pager"></div><!-- 整个grid的分页区 -->
  253. </#if>
  254. </div>
  255. </div>
  256. <input type="hidden" name="_multiple" />
  257. </div>
  258. <#if parameters.hasTitle!true >
  259. </fieldset>
  260. </#if>
  261. <#-- 生成多记录表对应js脚本的区域-->
  262. <script language="javascript">
  263. $(function(){
  264. if($(${parameters.id}).data('_init')){return;}
  265. //标志已经初始化,无需重新初始化
  266. $(${parameters.id}).data('_init',true);
  267. <#if !(parameters.showContent!true)>
  268. _FW.oFtl.fnShowTable('img_${parameters.id}_grid','${parameters.id}');
  269. </#if>
  270. $("#${parameters.id}").fweditgrid(${tojson(parameters.options)});
  271. });
  272. function ${parameters.id}_combox(input,combox){
  273. //只读的不处理
  274. if(input.className.indexOf('readOnly')!=-1)return;
  275. $("#${parameters.id}").fweditgrid("showComBox",input,"${parameters.id}_"+combox);
  276. }
  277. function ${parameters.id}_delRow(obj){
  278. var tr = $(obj).closest('TR');
  279. var iRow = tr.attr("fweditgrid-row-index");
  280. try {
  281. var callback = eval("${parameters.id}_delRowCallback ;");
  282. //调用自定义回调方法
  283. if (typeof (callback) == 'function'){
  284. try{
  285. flag = callback(iRow);
  286. }catch(ex){
  287. flag = false;
  288. _FW.oFtl.fnAlert(ex.message);
  289. }
  290. }
  291. } catch (e) {
  292. }
  293. if(flag){
  294. $("#${parameters.id}").fweditgrid("removeRows",iRow);
  295. }
  296. }
  297. </script>
  298. <#compress></#compress>