⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 login.js

📁 一个简单ssh+extjs的人力资源管理系统(转载)
💻 JS
字号:
var adminLoginForm = null;
var adminLoginWin = null;
function openLoginWindow() {
	adminLoginForm = new Ext.FormPanel({
				id : 'operationInf',
				name : 'OperationInf',
				frame : true,
				labelWidth : 70,
				labelAlign : 'right',
				bodyStyle : 'padding:5px 5px 0',
				width : 350,
				items : [new Ext.form.ComboBox({
					fieldLabel : '登录类型',
					hiddenName : 'usertype',
					//必须是hiddenName而非name,代表隐藏字段的名字,它动态产生,用来存储combo数据。
					//可以得出,有一个显示的字段是Dom element,而隐藏字段存放数据
					allowBlank : false,
					anchor : '80%',
					mode : 'local',
					store : new Ext.data.SimpleStore({
								fields : ['value', 'name'],
								data : [['superadmin', '超级管理员'],
										['sysadmin', '人力资源部'], ['emp', '单位职员']]
							}),
					displayField : 'name',
					valueField : 'value',
					emptyText : '请选择登录类型..',
					blankText : '必须选择登录类型!',
					forceSelection : true,
					typeAhead : true,
					selectOnFocus : true,
					triggerAction : 'all'
				}), {
					xtype : 'textfield',
					fieldLabel : '用户名',
					name : 'username',
					allowBlank : false,
					vtype : 'alphanum',
					vtypeText : '请您输入A-Z,a-z,0-9的字母数字组合!',
					/*minLength : 4,
					minLengthText : '请您输入最少4个字符',
					maxLength : 20,
					maxLengthText : '请您输入最多20个字符!',*/
					anchor : '80%'
				}, {
					xtype : 'textfield',
					fieldLabel : '密码',
					name : 'pwd',
					inputType : 'password',
					/*minLength : 6,
					minLengthText : '请您输入最少6个字符!',
					maxLength : 20,
					maxLengthText : '请您输入最多20个字符!',*/
					allowBlank : false,
					vtype : 'alphanum',
					vtypeText : '请您输入A-Z,a-z,0-9的字母数字组合!',
					anchor : '80%'
				}],
				buttons : [{
							text : '登录',
							handler : doSubmit
						}, {
							text : '重置',
							handler : function() {
								Ext.MessageBox.confirm('提示信息',
										'当前数据将不会保存,您确定要取消吗?', function(btn) {
											if (btn == "yes") {
												adminLoginForm.getForm()
														.reset();
											}
										});
							}
						}],
				keys : [{
							key : Ext.EventObject.ENTER,
							fn : doSubmit,
							scope : this
						}]
			});
	adminLoginWin = new Ext.Window({
		id : 'adminLoginWin',
		name : 'adminLoginWin',
		title : '<h2><div style="width:100%"><marquee behavior="scroll" scrollamount="2">'
				+ '<font color="black">Welcome to eHR System</font></marquee></div></h2>',
		iconCls : 'icon-lock-s',
		width : adminLoginForm.width,
		height : adminLoginForm.height,
		closable : false,
		collapsible : false,
		draggable : false,
		resizable : false,
		maximizable : false,
		modal : false,
		border : true,
		items : [adminLoginForm]
	});
	adminLoginWin.show();
}
function doSubmit() {
	if (adminLoginWin.getComponent('operationInf').form.isValid()) {
		adminLoginWin.getComponent('operationInf').form.submit({
			url : 'logon.do',
			method : 'POST',
			waitTitle : '提示',
			waitMsg : '正在处理您的请求,请稍候...',
			success : function(form, action) {
				try {
					/*
					 * 候选方法:手动解析Json数据 var jsonobject =
					 * Ext.util.JSON.decode(action.response.responseText);//将返回的JSON数据转换成JSON对象,转换失败即报错.
					 * Ext.Msg.alert("msg,oject",jsonobject.message);//用JSON对象获取JSON数据的值
					 */
					var flag = action.result.success;
					if (flag === false) {
						Ext.Msg.alert('提示', action.result.message);
					} else if (flag === true) {
						adminLoginForm.getForm().reset();
						Ext.Msg.alert('提示',action.result.message);
						window.location.href = "index.jsp";
					}
				} catch (e) {
					Ext.MessageBox.alert('提示', '对不起,您无法连接系统,如果您的网络正常,请联系系统管理员!'
									+ '\n' + e.toString());
				}
			},
			failure : function(form, action) {
				try {
					Ext.MessageBox.alert('提示', action.result.message);
				} catch (e) {
					Ext.MessageBox.alert('提示', '对不起,您无法连接系统,如果您的网络正常,请联系系统管理员');
				}
			}
		});
	}
}
Ext.onReady(function() {
			Ext.QuickTips.init();
			Ext.form.Field.prototype.msgTarget = 'side';
			openLoginWindow();
		});

// 你采用的这种方式不是很好,用store来登录,这样不好
/*
 * store.load(); if (store.getAt(0) != null) { Ext.Msg.alert('Info', '共获得' +
 * store.getCount() + '条数据'); window.open(store.getAt(0).get('topage'),
 * '_blank'); } //load()在执行的过程中,下面的方法也在执行,这样你往往获得不了值,明白吗,所以,要这样处理 store.load({
 * callback : function(r, options, success) { if (success == false) {
 * alert("加载数据失败,无对应数据或者系统出现异常!"); } else { if (store.getAt(0) != null) {
 * Ext.Msg.alert('Info', '共获得' + store.getCount() + '条数据');
 * window.open(store.getAt(0).get('topage'), '_blank'); } } } });
 */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -