PwdWindow.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. Ext.define('erp.view.core.window.PwdWindow', {
  2. extend: 'Ext.window.Window',
  3. alias: 'widget.pwdwindow',
  4. width: 440,
  5. height: 260,
  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. padding: '10 10 20 10',
  23. defaults: {
  24. margin: '10 10 10 20'
  25. },
  26. items: [{
  27. xtype: 'displayfield',
  28. fieldLabel: '账号',
  29. value: em_name
  30. },{
  31. xtype: 'textfield',
  32. name: 'em_oldpassword',
  33. fieldLabel: '原密码',
  34. allowBlank : false,
  35. inputType: 'password'
  36. },{
  37. xtype: 'textfield',
  38. name: 'em_newpassword',
  39. id: 'em_newpassword',
  40. fieldLabel: '新密码',
  41. inputType: 'password',
  42. allowBlank : false,
  43. blankText : '密码不能为空',
  44. regex : /^[\s\S]{0,20}$/,
  45. regexText : '密码长度不能超过20个字符'
  46. },{
  47. xtype: 'textfield',
  48. name: 'em_reput',
  49. id: 'em_reput',
  50. fieldLabel: '新密码确认',
  51. inputType: 'password',
  52. allowBlank : false,
  53. vtype : 'confirmPwd',
  54. confirmPwd : {
  55. first : 'em_newpassword',
  56. second : 'em_reput'
  57. },
  58. blankText : '确认密码不能为空',
  59. regex : /^[\s\S]{0,20}$/,
  60. regexText : '确认密码长度不能超过20个字符'
  61. },{
  62. xtype: 'checkbox',
  63. boxLabel: '同时修改到其它帐套',
  64. name: 'sync',
  65. checked: true
  66. }],
  67. buttonAlign: 'center',
  68. buttons: [{
  69. text: '确认',
  70. cls: 'x-btn-blue',
  71. handler: function(btn) {
  72. var win = btn.up('window');
  73. win.updatePwd();
  74. }
  75. },{
  76. text: '关闭',
  77. cls: 'x-btn-blue',
  78. handler: function(btn) {
  79. var win = btn.up('window');
  80. win.close();
  81. }
  82. }]
  83. }],
  84. updatePwd: function() {
  85. var win = this;
  86. var form = win.down('form').getForm();
  87. if (form.isValid()) {
  88. form.submit({
  89. success: function(form, action) {
  90. Ext.Msg.alert('修改成功!', '请牢记您的新密码:' + win.down('#em_newpassword').value);
  91. win.close();
  92. },
  93. failure: function(form, action) {
  94. Ext.Msg.alert('修改失败!', action.result.result);
  95. }
  96. });
  97. }
  98. }
  99. });
  100. Ext.apply(Ext.form.VTypes, {
  101. confirmPwd : function(val, field) {
  102. if (field.confirmPwd) {
  103. var firstPwdId = field.confirmPwd.first;
  104. var secondPwdId = field.confirmPwd.second;
  105. this.firstField = Ext.getCmp(firstPwdId);
  106. this.secondField = Ext.getCmp(secondPwdId);
  107. var firstPwd = this.firstField.getValue();
  108. var secondPwd = this.secondField.getValue();
  109. if (firstPwd == secondPwd) {
  110. return true;
  111. } else {
  112. return false;
  113. }
  114. }
  115. },
  116. confirmPwdText : '两次输入的密码不一致!'
  117. });