|
|
@@ -0,0 +1,123 @@
|
|
|
+Ext.apply(Ext.form.VTypes, {
|
|
|
+ confirmPwd: function (value, field) {
|
|
|
+ if (field.confirmPwd) {
|
|
|
+ var first = field.confirmPwd.first;
|
|
|
+ var second = field.confirmPwd.second;
|
|
|
+
|
|
|
+ this.firstField = Ext.getCmp('newpassword');
|
|
|
+ this.seconField = Ext.getCmp('newpassword2');
|
|
|
+ var firstPwd = this.firstField.getValue();
|
|
|
+ var secondPwd = this.seconField.getValue();
|
|
|
+ if (firstPwd == secondPwd) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ confirmPwdText: '两次输入的密码不一致!',
|
|
|
+});
|
|
|
+Ext.define('erp.view.user.UserInfo',{
|
|
|
+ extend:'Ext.window.Window',
|
|
|
+ alias:'widget.userinfo',
|
|
|
+ id:'userinfo',
|
|
|
+ title:'修改密码',
|
|
|
+ layout:'fit',
|
|
|
+ modal:true ,
|
|
|
+ initComponent:function(){
|
|
|
+ var me = this;
|
|
|
+ me.items = [{
|
|
|
+ xtype: 'form',
|
|
|
+ id:'userinfoform',
|
|
|
+ bodyStyle: {
|
|
|
+ border: 'none'
|
|
|
+ },
|
|
|
+ bodyPadding: 10,
|
|
|
+ defaults: {
|
|
|
+ width: 300,
|
|
|
+ labelWidth: 80
|
|
|
+ },
|
|
|
+ items: [{
|
|
|
+ xtype: 'hidden',
|
|
|
+ name: 'code',
|
|
|
+ id:'code'
|
|
|
+ }, {
|
|
|
+ xtype: 'displayfield',
|
|
|
+ name: 'name',
|
|
|
+ readOnly: true,
|
|
|
+ fieldLabel: '名称',
|
|
|
+ value: getCookie('username')
|
|
|
+ }, {
|
|
|
+ xtype: 'textfield',
|
|
|
+ name: 'oldpassword',
|
|
|
+ allowBlank: false,
|
|
|
+ inputType: 'password',
|
|
|
+ blankText: '请输入原密码',
|
|
|
+ fieldLabel: '旧密码'
|
|
|
+ }, {
|
|
|
+ xtype: 'textfield',
|
|
|
+ name: 'newpassword',
|
|
|
+ id: 'newpassword',
|
|
|
+ inputType: 'password',
|
|
|
+ allowBlank: false,
|
|
|
+ blankText: '请输入新密码',
|
|
|
+ fieldLabel: '新密码',
|
|
|
+ regex: /^[\s\S]{0,16}$/,
|
|
|
+ regexText: '密码长度不能超过16个字符',
|
|
|
+ }, {
|
|
|
+ xtype: 'textfield',
|
|
|
+ name: 'newpassword2',
|
|
|
+ id: 'newpassword2',
|
|
|
+ inputType: 'password',
|
|
|
+ allowBlank: false,
|
|
|
+ blankText: '请再次输入新密码',
|
|
|
+ fieldLabel: '确认新密码',
|
|
|
+ regex: /^[\s\S]{0,16}$/,
|
|
|
+ regexText: '密码长度不能超过16个字符',
|
|
|
+ vtype:'confirmPwd',
|
|
|
+ confirmPwd: {
|
|
|
+ first: 'loginPassword',
|
|
|
+ second:'rePassword'
|
|
|
+ }
|
|
|
+ }],
|
|
|
+ buttons: [{
|
|
|
+ xtype: 'button',
|
|
|
+ text: '保存',
|
|
|
+ formBind:true,
|
|
|
+ handler: function() {
|
|
|
+ me.updatePassword();
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ xtype: 'button',
|
|
|
+ text: '取消',
|
|
|
+ handler: function(btn) {
|
|
|
+ btn.ownerCt.ownerCt.ownerCt.ownerCt.close();
|
|
|
+ }
|
|
|
+ }]
|
|
|
+ }];
|
|
|
+ me.callParent(arguments);
|
|
|
+ },
|
|
|
+ updatePassword: function() {
|
|
|
+ var me = this;
|
|
|
+ var form = Ext.getCmp('userinfoform');
|
|
|
+ var values = form.getForm().getValues();
|
|
|
+ me.getEl().mask('loading...');
|
|
|
+ Ext.Ajax.request({
|
|
|
+ url:'user/resetPwd?password='+values.oldpassword+'&newPassword='+values.newpassword,
|
|
|
+ method:'POST',
|
|
|
+ params:{
|
|
|
+ json: Ext.encode(values)
|
|
|
+ },
|
|
|
+ callback:function(options,success,response){
|
|
|
+ me.getEl().unmask();
|
|
|
+ if(response.responseText == '') return;
|
|
|
+ var res = JSON.parse(response.responseText);
|
|
|
+ if(success) {
|
|
|
+ Ext.Msg.alert('成功', '已更新!');
|
|
|
+ }else {
|
|
|
+ Ext.Msg.alert('失败', res.message);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+});
|