text: Ext.ns('Tomtalk.grid');
  
  Ext.define('Tomtalk.grid.FormUI', {extend: 'Ext.form.Panel',
      constructor: function (config) {
          var me = this;
          config = Ext.apply({
              title: '编辑',
              bodyStyle: 'padding:10px;',
              layout: 'anchor'
          }, config);
  
          me.COMPONENTS = {};
  
          Tomtalk.grid.FormUI.superclass.constructor.call(me, config);
      },
  
      initComponent: function () {
          var me = this;
  
          me.items = [
              {
                  xtype: 'hiddenfield',
                  name: 'id',
                  value: 0
              },
              {
                  xtype: 'textfield',
                  fieldLabel: '登入名',
                  anchor: '50%',
                  name: 'name',
                  allowBlank: false,
                  emptyText: '请输入…'
              },
              {
                  xtype: 'textfield',
                  inputType: 'password',
                  fieldLabel: '密码',
                  anchor: '50%',
                  name: 'password',
                  allowBlank: false,
                  emptyText: '请输入…'
              },
              {
                  xtype: 'button',
                  text: '保存',
                  id: this.id + '_save',
                  width: 100
              },
              {
                  xtype: 'button',
                  text: '返回',
                  id: this.id + '_return',
                  style: 'margin-left: 50px;',
                  width: 100
              }
          ];
  
          Tomtalk.grid.FormUI.superclass.initComponent.call(me);
      }
  });
  
  Ext.define('Tomtalk.grid.FormAction', {extend: 'Tomtalk.grid.FormUI',
      constructor: function (config) {
          Tomtalk.grid.FormAction.superclass.constructor.call(this, config);
      },
  
      initComponent: function () {
          Tomtalk.grid.FormAction.superclass.initComponent.call(this);
  
          Ext.apply(this.COMPONENTS, {
              saveBtn: Ext.getCmp(this.id + '_save'),
              returnBtn: Ext.getCmp(this.id + '_return')
          });
      },
  
      initEvents: function () {
          var me = this;
          var $c = this.COMPONENTS;
  
          Tomtalk.grid.FormAction.superclass.initEvents.call(me);
  
          $c.saveBtn.on('click', me._save, me);
          $c.returnBtn.on('click', me._return, me);
      },
  
      _return: function () {
          this.getForm().reset();
  
          if (this.up()) {
              this.up()._returnFrom();
          }
      },
  
      _save: function () {
          var me = this;
          var form = me;
  
          if (form.isValid()) {
              form.getForm().submit({
                  url: '/' + me.up().module + '/save',//后台处理的页面
                  submitEmptyText: false,
                  success: function (fp, o) {
                      var result = Ext.decode(o.response.responseText);
  
                      if (result.success) {
                          me._return();
                      } else {
                          alert('See error info by console.');
                          console.log(result);
                      }
                  }
              });
          }
      },
  
      _getValue: function () {
          var me = this;
          var $c = this.COMPONENTS;
          var addForm = me.getForm();
          if (!addForm.isValid()) {
              return false;
          }
  
          return addForm.getValues();
      }
  });
  
  Tomtalk.grid.AccountForm = Tomtalk.grid.FormAction;
  
  //end file