| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <#include "../function.ftl">
- <#include "../variable.ftl">
- <#assign classVar=class?uncap_first>
- <#assign pkVar=convertUnderLine(pk) >
- <#assign baseurl ="/"+app+"/"+module>
- <#assign url =baseurl+"/"+classVar>
- /**
- * ${comment}
- *
- *
- *<pre>
- <#if vars.company?exists>
- * 开发公司:${vars.company}
- </#if>
- <#if vars.developer?exists>
- * 开发人员:${vars.developer}
- </#if>
- <#if vars.email?exists>
- * 邮箱地址:${vars.email}
- </#if>
- * 创建时间:${date?string("yyyy-MM-dd HH:mm:ss")}
- *</pre>
- */
- $(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()}',</#list>'管理'],
- colModel: [<#list colList as col><#assign colName=convertUnderLine(col.columnName)>{
- name:'${colName}',
- index: '${col.columnName}'<#if (col.colType=="java.util.Date") || (col.isPK) >,</#if>
- <#if (col.colType=="java.util.Date")|| (col.isPK)><#if (col.colType=="java.util.Date")>formatter: 'timestamp'
- <#elseif (col.isPK) >hidden:true,
- key:true</#if>
- </#if>
- }, </#list> {
- 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}');
- </#if>
- // 处理表单保存
- $(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());
- }
- }
- };
- })();
|