<#include "../function.ftl"> <#include "../variable.ftl"> <#assign classVar=class?uncap_first> <#assign pkVar=convertUnderLine(pk) > <#assign baseurl ="/"+app+"/"+module> <#assign url =baseurl+"/"+classVar> /** * ${comment} * * *
 
 <#if vars.company?exists>
 * 开发公司:${vars.company}
 
 <#if vars.developer?exists>
 * 开发人员:${vars.developer}
 
 <#if vars.email?exists>
 * 邮箱地址:${vars.email}
 
 * 创建时间:${date?string("yyyy-MM-dd HH:mm:ss")}
 *
*/ $(function() { ${classVar} = new ${class}(); ${classVar}.init(); formUrl = ${classVar}.formUrl; }); (function() { //定义常量 var _consts = { GRID : "#${classVar}Grid",// 列表对象 PAGER : "#${classVar}Pager",// 列表分页 FORM : '#${classVar}Form'// 表单form }; /** * ${comment} 对象 * @returns {${class}} */ ${class} = function() { //定义属性 }; /** * 方法 */ ${class}.prototype = { consts: _consts, /** * 初始化 */ init : function() { if (this.hasInit) // 是否已初始化 return false; this.hasInit = true; if ($(this.consts.GRID).length > 0)//列表 this._initGridList(); if ($(this.consts.FORM).length > 0)//表单 this._initForm(); }, /** * 初始列表 */ _initGridList : function() { var me = this; $(this.consts.GRID).GridList( { url : __ctx+'${url}/listJson.htm', pager :this.consts.PAGER, colNames: [<#list colList as col>'${col.getComment()}','管理'], colModel: [<#list colList as col><#assign colName=convertUnderLine(col.columnName)>{ name:'${colName}', index: '${col.columnName}'<#if (col.colType=="java.util.Date") || (col.isPK) >, <#if (col.colType=="java.util.Date")|| (col.isPK)><#if (col.colType=="java.util.Date")>formatter: 'timestamp' <#elseif (col.isPK) >hidden:true, key:true }, { name : '__manage', width : 30, sortable:false, classes:'rowOps', formatter : 'manage', formatoptions :[{ label:'编辑', classes:'btn btn-primary fa fa-edit', action:__ctx+'${url}/edit.htm?id={id}' },{ label:'删除', classes:'btn btn-primary fa fa-remove', action:__ctx+'${url}/remove.htm?id={id}' },{ label:'明细', classes:'btn btn-primary fa fa-detail', action: __ctx+'${url}/get.htm?id={id}' }] } ] }); }, /** * 初始化表单 */ _initForm : function() { var me = this, form = $(this.consts.FORM), frm = form.form(); me.formUrl = new com.lc.form.FormData(form); // 触发表单验证 frm.valid(); <#if hasSub?exists && hasSub==true> me.formUrl.initSub('${baseurl}'); // 处理表单保存 $(document).on('click', 'a.fa-save', function() { formUrl.submit(me._showResponse); }); }, /** * 表单成功返回信息 * * @param responseText */ _showResponse : function(responseText) { var msg = new com.lc.form.ResultMessage(responseText); if (msg.isSuccess()) { DialogUtil.confirmAction(msg.getMessage() + ',是否继续操作', function(rtn) { if(rtn) window.location.reload(true); else window.location.href = __ctx+'${url}/list.htm'; }); } else { DialogUtil.error(msg.getMessage()); } } }; })();