(function(){JUI.Class("PageForm",{OPTS:{grid:null,win:null,crudUrl:null,errorHandler:function(a){JUI.Msg.alert("提示",a.success)}},init:function(a){this._super(a)},add:function(){this.setUrl(this.getCrudUrl().add);this.clear();this.getWin().setTitle("添加");this.getWin().show()},update:function(a){this.getWin().setTitle("修改");this.setUrl(this.getCrudUrl().update);this.clear();this.loadData(a);this.getWin().show()},fireError:function(a){this.opt("errorHandler")(a)},del:function(c,b){var a=this;b=b||function(d){if(d.success){a.getGrid().reload()}else{a.fireError(d)}};JUI.Msg.confirm("确认","确定删除这条记录?",function(e){if(e){var d=a.getCrudUrl().del;a.submit({url:d,data:c,onSubmit:function(){},success:function(f){b(f)}})}})},save:function(c){c=c||{};var a=this;var b=this.getUrl();this.submit({url:b,onSubmit:function(d){if(c.onSubmit){return c.onSubmit.call(a,d)}else{return this.validate()}},success:function(d){if(d.success){if(c.success){return c.success.call(a,d)}else{a.getGrid().reload();a.getWin().close()}}else{a.fireError(d)}}})},setUrl:function(a){this.opt("url",a)},getUrl:function(){return this.opts.url},getCrudUrl:function(){return this.opts.crudUrl},getWin:function(){return this.opts.win},getGrid:function(){return this.opts.grid}},JUI.Form)})();