Ext.define('erp.view.core.window.PwdWindow', { extend: 'Ext.window.Window', alias: 'widget.pwdwindow', width: 440, height: 240, frame: true, modal: true, bodyStyle: 'background: #E0EEEE;', layout: 'anchor', title: '修改密码', initComponent: function() { this.title = '
  ' + this.title + '
'; this.callParent(arguments); this.show(); }, items: [{ xtype: 'form', anchor: '100% 100%', bodyStyle: 'background: #E0EEEE;', url: basePath + 'hr/employee/updatePwd.action', defaults: { margin: '10 10 10 20' }, items: [{ xtype: 'displayfield', fieldLabel: '账号', value: em_name },{ xtype: 'textfield', name: 'em_oldpassword', fieldLabel: '原密码', allowBlank : false, inputType: 'password' },{ xtype: 'textfield', name: 'em_newpassword', id: 'em_newpassword', fieldLabel: '新密码', inputType: 'password', allowBlank : false, blankText : '密码不能为空', regex : /^[\s\S]{0,20}$/, regexText : '密码长度不能超过20个字符' },{ xtype: 'textfield', name: 'em_reput', id: 'em_reput', fieldLabel: '新密码确认', inputType: 'password', allowBlank : false, vtype : 'confirmPwd', confirmPwd : { first : 'em_newpassword', second : 'em_reput' }, blankText : '确认密码不能为空', regex : /^[\s\S]{0,20}$/, regexText : '确认密码长度不能超过20个字符' }], buttonAlign: 'center', buttons: [{ text: '确认', cls: 'x-btn-blue', handler: function(btn) { var win = btn.up('window'); win.updatePwd(); } },{ text: '关闭', cls: 'x-btn-blue', handler: function(btn) { var win = btn.up('window'); win.close(); } }] }], updatePwd: function() { var win = this; var form = win.down('form').getForm(); if (form.isValid()) { form.submit({ success: function(form, action) { Ext.Msg.alert('修改成功!', '请牢记您的新密码:' + win.down('#em_newpassword').value); win.close(); }, failure: function(form, action) { Ext.Msg.alert('修改失败!', action.result.result); } }); } } }); Ext.apply(Ext.form.VTypes, { confirmPwd : function(val, field) { if (field.confirmPwd) { var firstPwdId = field.confirmPwd.first; var secondPwdId = field.confirmPwd.second; this.firstField = Ext.getCmp(firstPwdId); this.secondField = Ext.getCmp(secondPwdId); var firstPwd = this.firstField.getValue(); var secondPwd = this.secondField.getValue(); if (firstPwd == secondPwd) { return true; } else { return false; } } }, confirmPwdText : '两次输入的密码不一致!' });