

Ext.onReady(function(){
	Ext.QuickTips.init();//支持tips提示
	Ext.form.Field.prototype.msgTarget='side';//提示的方式，枚举值为"qtip","title","under","side",id(元素id)
	
    var win;
    if(!win){
    
    var loginForm = new Ext.FormPanel({
		el:'x-tabs',
		autoTabs:true,
		activeTab:0,
		deferredRender:false,
		border:false,    	
		items:{
			xtype:'tabpanel',
           	activeTab: 0,
           	defaults:{autoHeight:true, bodyStyle:'padding:10px'}, 
            items:[{
            	title:'系统登录',
            	contentEl: 'loginInfo',
            	layout:'form',            	  	 
            	defaults: {width: 230},
            	defaultType: 'textfield',
            	items: [{
					cls:'user',
                   	xtype: 'textfield',
                   	name: 'lm.userName',
                   	fieldLabel: '系统帐号',
                   	allowBlank:false,//不允许为空
            		blankText:"帐号不能为空",
                   	anchor: '90%'
                },{
                	cls:'key',
					xtype: 'textfield',
                    inputType: 'password',
                    name: 'lm.userPass',
                    fieldLabel: '系统密码',
                    allowBlank:false,
             		blankText:"本系统不支持使用空密码",
                    anchor: '90%'
                },{
                	id: 'companycode',
					xtype: 'textfield',
                    inputType: 'hidden',
                    name: 'companycode'
                }]
            },{
                title:'关于本系统',
                layout:'',
                contentEl: 'kingInfo',
                defaults: {width: 230}
          
            }]
        }
	});
    
    win = new Ext.Window({
                el:'x-login',
                layout:'fit',
                width:400,
                height:245,
                closeAction:'hide',
                plain: true,
                closable: true,
                resizable: false,
                defaultButton:'btnLogin',
                items: loginForm,
                buttons: [{
                	id:'btnLogin',
                    text     : '登录',
                    handler  : function(){
                        if(loginForm.getForm().isValid())
	                	{
	                		win.hide();
	                		loginForm.getForm().getEl().dom.action="/tjcdb/login";
			            	loginForm.getForm().getEl().dom.submit();
			            
			            Ext.MessageBox.show({
			               title: '请稍候...',
				           msg: '正在验证您的登录信息,请稍候...',
				           progressText: '登录信息验证中...',
				           width:300,
				           wait:true,
				           waitConfig: {interval:100},
				           icon:'ext-mb-login'
				       });
				       setTimeout(function(){
				            //This simulates a long-running operation like a database save or XHR call.
				            //In real code, this would be in a callback function.
				            Ext.MessageBox.hide();
				           
				        }, 15000);		
					       
                    	} 
                    }
                },{
                    text     : '取消',
                    handler  : function(){
                        win.hide();
                    }
                }]
            }
           
            );   
     }
     
     win.show();
    	
    	var login_btn = Ext.get('x-login-btn');

	    login_btn.on('click', function(){
	       win.show();        
	    });
	    
	
	
});


