PwdWindow.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. Ext.define('erp.view.core.window.PwdWindow', {
  2. extend: 'Ext.window.Window',
  3. alias: 'widget.pwdwindow',
  4. width: 440,
  5. height: 240,
  6. frame: true,
  7. modal: true,
  8. bodyStyle: 'background: #E0EEEE;',
  9. layout: 'anchor',
  10. title: '修改密码',
  11. initComponent: function() {
  12. this.title = '<div style="height:25;padding-top:5px;color:blue;font-size:14px;background: #E0EEEE url(' +
  13. basePath + 'resource/ext/resources/themes/images/default/grid/grid-blue-hd.gif) repeat center center">&nbsp;&nbsp;' + this.title + '</div>';
  14. this.callParent(arguments);
  15. this.show();
  16. },
  17. items: [{
  18. xtype: 'form',
  19. anchor: '100% 100%',
  20. bodyStyle: 'background: #E0EEEE;',
  21. url: basePath + 'hr/employee/updatePwd.action',
  22. defaults: {
  23. margin: '10 10 10 20'
  24. },
  25. items: [{
  26. xtype: 'displayfield',
  27. fieldLabel: '账号',
  28. value: em_name
  29. },{
  30. xtype: 'textfield',
  31. name: 'em_oldpassword',
  32. fieldLabel: '原密码',
  33. allowBlank : false,
  34. inputType: 'password'
  35. },{
  36. xtype: 'textfield',
  37. name: 'em_newpassword',
  38. id: 'em_newpassword',
  39. fieldLabel: '新密码',
  40. inputType: 'password',
  41. allowBlank : false,
  42. blankText : '密码不能为空',
  43. regex : /^[\s\S]{0,20}$/,
  44. regexText : '密码长度不能超过20个字符'
  45. },{
  46. xtype: 'textfield',
  47. name: 'em_reput',
  48. id: 'em_reput',
  49. fieldLabel: '新密码确认',
  50. inputType: 'password',
  51. allowBlank : false,
  52. vtype : 'confirmPwd',
  53. confirmPwd : {
  54. first : 'em_newpassword',
  55. second : 'em_reput'
  56. },
  57. blankText : '确认密码不能为空',
  58. regex : /^[\s\S]{0,20}$/,
  59. regexText : '确认密码长度不能超过20个字符'
  60. }],
  61. buttonAlign: 'center',
  62. buttons: [{
  63. text: '确认',
  64. cls: 'x-btn-blue',
  65. handler: function(btn) {
  66. var win = btn.up('window');
  67. win.updatePwd();
  68. }
  69. },{
  70. text: '关闭',
  71. cls: 'x-btn-blue',
  72. handler: function(btn) {
  73. var win = btn.up('window');
  74. win.close();
  75. }
  76. }]
  77. }],
  78. updatePwd: function() {
  79. var win = this;
  80. var form = win.down('form').getForm();
  81. if (form.isValid()) {
  82. form.submit({
  83. success: function(form, action) {
  84. Ext.Msg.alert('修改成功!', '请牢记您的新密码:' + win.down('#em_newpassword').value);
  85. win.close();
  86. },
  87. failure: function(form, action) {
  88. Ext.Msg.alert('修改失败!', action.result.result);
  89. }
  90. });
  91. }
  92. }
  93. });
  94. Ext.apply(Ext.form.VTypes, {
  95. confirmPwd : function(val, field) {
  96. if (field.confirmPwd) {
  97. var firstPwdId = field.confirmPwd.first;
  98. var secondPwdId = field.confirmPwd.second;
  99. this.firstField = Ext.getCmp(firstPwdId);
  100. this.secondField = Ext.getCmp(secondPwdId);
  101. var firstPwd = this.firstField.getValue();
  102. var secondPwd = this.secondField.getValue();
  103. if (firstPwd == secondPwd) {
  104. return true;
  105. } else {
  106. return false;
  107. }
  108. }
  109. },
  110. confirmPwdText : '两次输入的密码不一致!'
  111. });