editglt.ftl 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  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. <#if (parameters.options.frozenColumns > 0) >
  34. <#assign v_fixHead = parameters.lastHeaderRow[0..(parameters.options.frozenColumns-1)] >
  35. <#assign v_colHead = parameters.lastHeaderRow[(parameters.options.frozenColumns)..]![] >
  36. <#else>
  37. <#assign v_fixHead = [] >
  38. <#assign v_colHead = parameters.lastHeaderRow >
  39. </#if>
  40. <#--macro 生成TD-->
  41. <#macro GT_TD v_input_comp v_data_one v_row_pos v_col_pos bFixed>
  42. <#assign v_pname=colNames[v_col_pos]!"" >
  43. <td field="${v_pname}" align="${v_input_comp.align!"center"}" <#if bFixed>class=fweditgrid-td-fixed<#else>class=fweditgrid-td</#if>>
  44. <#assign compValue = v_data_one[("_DIC_"+v_pname)]!""
  45. hiddenValue = v_data_one[v_pname]!"">
  46. <#if compValue=="">
  47. <#assign compValue = hiddenValue>
  48. </#if>
  49. <#if hiddenValue?index_of("href")!=-1>
  50. <#assign hiddenValue = "">
  51. </#if>
  52. <#--全部的控件都不用NAME 用rw来表示行 用nd来表示列名,目的为了减少submit时提交的数据量-->
  53. <#switch v_input_comp.type>
  54. <#case GtType.LABEL>
  55. <label rw="${v_row_pos}" nd="${v_pname}" style="width:100%;" value="${hiddenValue}">${compValue}</label>
  56. <#break>
  57. <#case GtType.LINK> <#--用于配置超链接的情况 不能用VALUE来保存因为双引号重复-->
  58. <label rw="${v_row_pos}" nd="${v_pname}" style="width:100%;" >${compValue}</label>
  59. <#break>
  60. <#case GtType.INPUT ><#--处理单行输入控件-->
  61. <#assign inputTmp=inputSets[v_input_comp.subtype]>
  62. <#if (compValue?is_sequence)>
  63. <#assign compValue=(compValue[0]?string)!"">
  64. </#if>
  65. <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} />
  66. <#break>
  67. <#case GtType.SFZ ><#--处理身份证 -->
  68. <#if (compValue?is_sequence)>
  69. <#assign compValue=(compValue[0]?string)!"">
  70. </#if>
  71. <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} />
  72. <#break>
  73. <#case GtType.TEXTAREA ><#--处理多行输入控件 -->
  74. <#if (compValue?is_sequence)>
  75. <#assign compValue=(compValue[0]?string)!"">
  76. </#if>
  77. <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>
  78. <#break>
  79. <#case GtType.DATEPICKER ><#--处理日期控件 -->
  80. <#if (compValue?is_sequence)>
  81. <#assign compValue=(compValue[0]?string)!"">
  82. </#if>
  83. <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} />
  84. <#break>
  85. <#case GtType.BUTTON ><#--处理按钮-->
  86. <#if (compValue?is_sequence)>
  87. <#assign compValue=(compValue[0]?string)!"">
  88. </#if>
  89. <a class="buttonlink" ${v_input_comp.cus} rw="${v_row_pos}" nd="${v_pname}" title="${v_input_comp.tip}" >${compValue}</a>
  90. <#break>
  91. <#case GtType.CHECKBOX >
  92. <#-- 取控件的值-->
  93. <#if (hiddenValue?is_sequence)>
  94. <#assign hiddenValue=(hiddenValue[0]?string)!"">
  95. </#if>
  96. <#assign ck="" value=(v_input_comp.value)!"" chk=v_data_one[v_input_comp.chk]!"" >
  97. <#if chk=="1">
  98. <#assign ck="checked">
  99. </#if>
  100. <#-- 单checkbox处理 -->
  101. <input title="${v_input_comp.tip}" type="checkbox" class="checkbox" ${v_input_comp.cus} name="${v_pname}"
  102. rw="${v_row_pos}" nd="${v_pname}" value="${compValue}" vldStr="${v_input_comp.vld}" ${ck} />
  103. <#break>
  104. <#case GtType.RADIOBOX >
  105. <#if (hiddenValue?is_sequence)>
  106. <#assign hiddenValue=(hiddenValue[0]?string)!"">
  107. </#if>
  108. <#if (parameters.glt.dict[v_pname])??>
  109. <#-- 字典项处理 -->
  110. <#assign dicts=parameters.options.data.dicts[v_pname]!{}
  111. v_colNum=(v_input_comp.colNum?number)!10 >
  112. <table border=0 cellspacing=0 cellpadding=0 class="inputSet">
  113. <#list dicts?keys?chunk(v_colNum) as subkeys>
  114. <tr>
  115. <#list subkeys as key>
  116. <td align="right" style="border:0">
  117. ${dicts[key]!""}<input title="${v_input_comp.tip}" type="radio" class="radio" ${v_input_comp.cus}
  118. rw="${v_row_pos}" nd="${v_pname}" name="${v_row_pos+(v_pname)}" value="${key}"
  119. ${(hiddenValue=(key))?string("checked","")} />
  120. </td>
  121. </#list>
  122. </tr>
  123. </#list>
  124. </table>
  125. <#else>
  126. ${v_input_comp.text!""}<input type="radio" title="${v_input_comp.tip}" class="radio"
  127. ${v_input_comp.cus} rw="${v_row_pos}" nd="${v_pname}" name="${v_pname}" value="${compValue!""}"
  128. vldStr="${v_input_comp.vld}" ${(hiddenValue=(v_input_comp.value!""))?string("checked","")} />
  129. </#if>
  130. <#break>
  131. <#case GtType.COMBOBOX>
  132. <#if v_input_comp.subtype!='b'>
  133. <#assign v_readOnly='readOnly=true'>
  134. </#if>
  135. <#assign inputTmp=inputSets[v_input_comp.subtype]>
  136. <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>/>
  137. <input type="hidden" class="gltcom" rw="${v_row_pos}" nd="${v_pname}" vldStr="${v_input_comp.vld}" value="${hiddenValue}" />
  138. <#break>
  139. <#default>
  140. </#switch>
  141. </td>
  142. </#macro>
  143. <#--生成单行记录的函数 -->
  144. <#macro GLT_TR v_fix_arr v_col_arr v_data_one irow icolOffset>
  145. <#if ((v_col_arr?size)>0)>
  146. <tr fweditgrid-row-index=${irow} >
  147. <td class=fweditgrid-td-rownumber>${irow+1}</td>
  148. <#if parameters.showDelete=="true" >
  149. <td class=fweditgrid-td-opr><a class="gltlink" href="javascript:void(0)" onclick="${parameters.id}_delRow(this);return false;" >删除</a></td>
  150. </#if>
  151. <#list v_fix_arr as cols>
  152. <@GT_TD cols v_data_one irow cols_index true/>
  153. </#list>
  154. <#list v_col_arr as cols>
  155. <@GT_TD cols v_data_one irow icolOffset+cols_index false/>
  156. </#list>
  157. </tr>
  158. <#else>
  159. <tr fweditgrid-row-index=${irow} >
  160. <#if bFixed>
  161. <td class=fweditgrid-td-rownumber>${irow+1}</td>
  162. <#if parameters.showDelete=="true" >
  163. <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>
  164. </#if>
  165. </#if>
  166. </tr>
  167. </#if>
  168. </#macro>
  169. <#--生成整个表单记录的函数 -->
  170. <#macro GLT_DATA v_data_arr >
  171. <#if ((v_data_arr?size)>0)>
  172. <#list v_data_arr as rows>
  173. <@GLT_TR v_fixHead v_colHead rows rows_index parameters.options.frozenColumns/>
  174. </#list>
  175. <#else>
  176. <@GLT_TR v_fixHead v_colHead {} 0 parameters.options.frozenColumns/>
  177. </#if>
  178. </#macro>
  179. <#-- 输出列标题 函数-->
  180. <#macro GLT_COL v_head_row isFixed>
  181. <#list v_head_row as col><#--列数据生成 -->
  182. <th nowrap="nowrap" rowspan=${col.rowspan!1} colspan=${col.colspan!1} <#if col.align??> _al=${col.align}</#if> sortable=${col.sortable!'true'}
  183. <#if col.width??>style="width=${col.width}"</#if> <#if (col.lastRowIndex??)>lastRowIndex="${col.lastRowIndex}" </#if>
  184. <#if isFixed>class=fweditgrid-th-fixed<#else>class=fweditgrid-th</#if> >
  185. <#if !(col.lastRowIndex??)><#--标题组生成方式 -->
  186. <#if col.checkbox??><#--生成checkbox -->
  187. <input type=checkbox class=fweditgrid-header-check>
  188. <#else>
  189. ${col.title!""}
  190. </#if>
  191. <#else><#--非标题组生成方式 -->
  192. <#if col.checkbox??><#--生成checkbox -->
  193. <input type=checkbox class=fweditgrid-header-check>
  194. <#else>
  195. <div class=fweditgrid-div onMouseDown="_FW.oFtl.fnMouseDownToResize(this,'${parameters.id}_table');" onMouseMove="_FW.oFtl.fnMouseMoveToResize(this,'${parameters.id}_table');" onMouseUp="_FW.oFtl.fnMouseUpToResize(this);">
  196. ${col.title!""}
  197. <span class=fweditgrid-sort-icon>&nbsp;</span>
  198. </div>
  199. </#if>
  200. </#if>
  201. </th>
  202. </#list>
  203. </#macro>
  204. <#macro GLT_HEADER v_head_fixed,v_head_colHead>
  205. <#if ((v_head_fixed?size) > 1 || (v_head_colHead?size) > 1)>
  206. <#-- 含有分组标题的情形先要拼第一行 -->
  207. <tr class=fweditgrid-header-group >
  208. <th nowrap="nowrap" rowspan=1 class=fweditgrid-th-rownum-top>&nbsp;</th>
  209. <#if parameters.showDelete=="true" >
  210. <th nowrap="nowrap" rowspan=1 class=fweditgrid-th-opr>&nbsp;</th>
  211. </#if>
  212. <#list v_head_fixed as row>
  213. <@GLT_COL row true />
  214. <#break>
  215. </#list>
  216. <#list v_head_colHead as row>
  217. <@GLT_COL row false/>
  218. <#break>
  219. </#list>
  220. </tr>
  221. <#-- 拼第二行 -->
  222. <tr class=fweditgrid-header-tr>
  223. <th nowrap="nowrap" rowspan=1 class=fweditgrid-th-rownum-bottom>&nbsp;</th>
  224. <#if parameters.showDelete=="true" >
  225. <th nowrap="nowrap" rowspan=1 class=fweditgrid-th-opr>操作</th>
  226. </#if>
  227. <#list v_head_fixed as row>
  228. <#if (row_index >0) >
  229. <@GLT_COL row true/>
  230. </#if>
  231. </#list>
  232. <#list v_head_colHead as row>
  233. <#if (row_index >0) >
  234. <@GLT_COL row false />
  235. </#if>
  236. </#list>
  237. </tr>
  238. <#else>
  239. <tr class=fweditgrid-header-tr>
  240. <th nowrap="nowrap" class=fweditgrid-th-rownum>&nbsp;</th>
  241. <#if parameters.showDelete=="true" >
  242. <th nowrap="nowrap" class=fweditgrid-th-opr>操作</th>
  243. </#if>
  244. <#list v_head_fixed as row>
  245. <@GLT_COL row true/>
  246. <#break>
  247. </#list>
  248. <#list v_head_colHead as row>
  249. <@GLT_COL row false/>
  250. <#break>
  251. </#list>
  252. </tr>
  253. </#if>
  254. </#macro>
  255. <#-- 开始生成多记录表脚本-->
  256. <#if parameters.hasTitle!true >
  257. <fieldset class="fieldset2" align="center" style="cursor:default;width:${parameters.width!"100%"}" >
  258. <legend class="legend" style="cursor:hand;" >
  259. <span onclick="_FW.oFtl.fnShowTable('img_${parameters.id}_grid','${parameters.id}')" >
  260. <img id="img_${parameters.id}_grid" src="${request.contextPath}/themes/default/images/query_icon_right.gif">
  261. </span>
  262. <span title="单击展开或收缩" onclick="_FW.oFtl.fnShowTable('img_${parameters.id}_grid','${parameters.id}')">
  263. ${parameters.title!(parameters.glt.title!'')}
  264. </span>
  265. </legend>
  266. </#if>
  267. <div align="left" style="width:100%" id="${parameters.id}" >
  268. <div class="fweditgrid"> <!-- 整个grid的外层 -->
  269. <div class="fweditgrid-wrap"> <!-- 整个grid的覆盖区 -->
  270. <#assign buildPage=(parameters.options.hasPage||(parameters.options.expbtn?length!"")>0) >
  271. <#if (["TOP","BOTH"]?seq_contains(parameters.pageAlign!"BOTTOM"))&&buildPage >
  272. <div class="fweditgrid-pager"></div><!-- 整个grid的分页区 -->
  273. </#if>
  274. <div class="fweditgrid-view"> <!-- 整个grid的数据区 -->
  275. <table border=0 cellspacing=0 cellpadding=0 width=100% id="${parameters.id}_table">
  276. <thead>
  277. <@GLT_HEADER parameters.glt.fixHead![] parameters.glt.colHead![] />
  278. </thead>
  279. <tbody>
  280. <@GLT_DATA parameters.options.data.rows />
  281. </tbody>
  282. </table>
  283. <div class="fweditgrid-resize-proxy"> </div>
  284. </div>
  285. <#if (["BOTTOM","BOTH"]?seq_contains(parameters.pageAlign!"BOTTOM"))&&buildPage >
  286. <div class="fweditgrid-pager"></div><!-- 整个grid的分页区 -->
  287. </#if>
  288. </div>
  289. </div>
  290. <input type="hidden" name="_multiple" />
  291. </div>
  292. <#if parameters.hasTitle!true >
  293. </fieldset>
  294. </#if>
  295. <br/>
  296. <#-- 生成多记录表对应js脚本的区域-->
  297. <script language="javascript">
  298. $(function(){
  299. if($(${parameters.id}).data('_init')){return;}
  300. //标志已经初始化,无需重新初始化
  301. $(${parameters.id}).data('_init',true);
  302. <#if !(parameters.showContent!true)>
  303. _FW.oFtl.fnShowTable('img_${parameters.id}_grid','${parameters.id}');
  304. </#if>
  305. $("#${parameters.id}").fweditgrid(${tojson(parameters.options)});
  306. });
  307. function ${parameters.id}_combox(input,combox){
  308. //只读的不处理
  309. if(input.className.indexOf('readOnly')!=-1)return;
  310. $("#${parameters.id}").fweditgrid("showComBox",input,"${parameters.id}_"+combox);
  311. }
  312. function ${parameters.id}_delRow(obj){
  313. var flag = true;
  314. var tr = $(obj).closest('TR');
  315. var iRow = tr.attr("fweditgrid-row-index");
  316. try {
  317. var callback = eval("${parameters.id}_delRowCallback ;");
  318. //调用自定义回调方法
  319. if (typeof (callback) == 'function'){
  320. try{
  321. flag = callback(iRow);
  322. }catch(ex){
  323. flag = false;
  324. _FW.oFtl.fnAlert(ex.message);
  325. }
  326. }
  327. } catch (e) {
  328. }
  329. if(flag){
  330. $("#${parameters.id}").fweditgrid("removeRows",iRow);
  331. }
  332. }
  333. </script>
  334. <#compress></#compress>