editglt_mh.ftl 13 KB

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