弹出的代码样例

/**
 * 编辑用户
 */
mortgage.userManager.edit = function(dataStore,record,roleList) {

 var multiSelect = new Ext.form.MultiSelect({
  width: 140,
  fieldLabel : '下辖行所',
        editable: false,
        hidden : record.get('role') == "sales support"?false:true,
        id : 'befBranch1',
        store:  new Ext.data.JsonStore({
      fields : [ 'branchId', 'branchId', 'isCheck'],
      root:'userList',
      url:getContextPath()+'/selectBranch.htm?befBranch=' + record.get('befBranch'),
      autoLoad:true
     }),
//     value : record.get('befBranch'),
     checkField : 'isCheck',
//        valueField: 'branchId',
        displayField: 'branchId',
        mode: 'local',
        triggerAction: 'all',
        allowBlank: false,
        hiddenName : 'befBranch',
        emptyText: '请选择',
        id : 'befBranch1',
        maxHeight:200 //下拉框的最大高度  
 });
 
 /**
  * 编辑用户基本信息
  */
 var editForm = new Ext.FormPanel({
  
  url : getContextPath()+'/userManagerUpdate.htm',
  frame : true,
  layout : 'column',
  items : [{
     columnWidth : .5,
     
     layout : 'form',
     items : [
       {
        xtype : 'textfield',
        fieldLabel : '员工号',
        name : 'staffId',
        id : 'staffId',
        width : 140,
        value : record.get('staffId'),
        readOnly : false
       },       
       {        
        xtype : 'combo',
        fieldLabel : '行所',
        store : new Ext.data.JsonStore({
         url:getContextPath()+'/selectBranch.htm',
            root:'userList',
            fields:['branchId','branchId'] ,
            autoLoad:true
        }),
        forceSelection : true,
        width : 140,
        emptyText : '请选择',
        valueField : "branchId",
        displayField : "branchId",
        mode : 'remote',
        name : 'branch',
        value : record.get('branch'),
        hiddenName : 'branch',
        triggerAction : 'all'
      },
                  {
        xtype : 'textfield',
        fieldLabel : '手机',
        name : 'mobile',
        id : 'mobile',
        width : 140,
        hidden : false,
        value:record.get('mobile')
        
       },
       {
        xtype : 'combo',
        fieldLabel : '角色',
        store : roleList,
        forceSelection : true,
        width : 140,
        emptyText : '请选择',
        valueField : "roleId",
        displayField : "roleName",
        mode : 'local',
        id : 'role1',
        name : 'role',
        value :record.get('role') ,
        hiddenName : 'role',
        triggerAction : 'all',
        listeners:{
         select:function(){
          if(this.getValue()=='2'){
           Ext.getCmp('befBranch1').allowBlank = false;
           Ext.getCmp('befBranch1').show();
           editForm.doLayout();
          }else{
           Ext.getCmp('befBranch1').allowBlank = true;
           Ext.getCmp('befBranch1').hide();
           editForm.doLayout();
          }
         }         
        }         
       }

     ]
    },
    {
     columnWidth : .5,
     layout : 'form',
     items : [
       {
        xtype : 'textfield',
        fieldLabel : '姓名',
        name : 'name',
        id : 'name',
        width : 140,
        hidden : false,
        value:record.get('name')
       },
       {
        xtype : 'combo',
        fieldLabel : '部门',
        store : new Ext.data.JsonStore({
         fields : [ 'name', 'value' ],
         baseParams:{typeId:'h'},
         root:'CodeBase',
         url:getContextPath()+'/CodeBase.htm',
         autoLoad:true
        }),
        forceSelection : true,
        width : 140,
        emptyText : '请选择',
        valueField : 'value',
        displayField : 'name',
        mode : 'remote',
        name : 'dept',
        id:'dept1',
        value:record.get('dept'),
        hiddenName : 'dept',
        triggerAction : 'all'
        
       }, {
        xtype : 'textfield',
        fieldLabel : '座机',
        name : 'ext',
        id : 'ext',
        width : 140,
        hidden : false,
        value:record.get('ext')
       },multiSelect
//       {
//        xtype : 'multiSelect',
//           width: 140,
//        fieldLabel : '下辖行所',
//                    editable: false,
//                    hidden : record.get('role') == "sales support"?false:true,
//                    id : 'befBranch1',
//                    store:  new Ext.data.JsonStore({
//                  fields : [ 'branchId', 'branchId', 'isCheck'],
//                  root:'userList',
//                  url:getContextPath()+'/selectBranch.htm?befBranch=' + record.get('befBranch'),
//                  autoLoad:true
//                 }),
//                 checkField : 'isCheck',
//                    valueField: 'branchId',
//                    displayField: 'branchId',
//                    mode: 'local',
//                    triggerAction: 'all',
//                    allowBlank: false,
//                    hiddenName : 'befBranch',
//                    emptyText: '请选择',
//                    id : 'befBranch1',
//                    maxHeight:200 //下拉框的最大高度        
//        
//       }

     ]
    }]
 });
 
//    $('#befBranch1').val(record.get('befBranch'));
//    $("input[name='befBranch']").val(record.get('befBranch'));
// alert(Ext.getCmp('befBranch1').getValue());
 /***************************************************************************
  * 定义新 window用来显示编辑页面
  **************************************************************************/
 var editWin = new Ext.Window({
  title : '编辑用户基本信息',
  width : 550,
  height : 220,
  autoScroll : true,
  bodyStyle : 'padding:5px;',
  buttonAlign : 'center',
  items : editForm,
  buttons : [ {
   text : '确定',
   handler : function() {
    var role = Ext.getCmp('role1').getValue();
    var dept= Ext.getCmp('dept1').getValue();
    if(record.get('role') == role){
     if(role == "sales support"){
      Ext.getCmp('role1').setValue('2');
     }
     if(role == "sales"){
      Ext.getCmp('role1').setValue('1');
     }
     if(role == "RCR admin"){
      Ext.getCmp('role1').setValue('4');
     }
     if(role == "RCR"){
      Ext.getCmp('role1').setValue('3');
     }
     if(role == "admin"){
      Ext.getCmp('role1').setValue('6');
     }
     if(role == "PCO"){
      Ext.getCmp('role1').setValue('5');
     }
    }
     if((record.get('role')==role&&role == "sales support")||role == "2"){
      Ext.getCmp('befBranch1').allowBlank = false; 
     }else{
      Ext.getCmp('befBranch1').allowBlank = true; 
     }
    
    if(record.get('dept') == dept){
     if(dept == "PBM"){
      Ext.getCmp('dept1').setValue('101h');
     }
     if(dept == "CSO"){
      Ext.getCmp('dept1').setValue('102h');
     }
     if(dept == "BDR"){
      Ext.getCmp('dept1').setValue('103h');
     }
     if(dept == "MS"){
      Ext.getCmp('dept1').setValue('104h');
     }     
    }
    
    if(editForm.getForm().isValid()){
    editForm.getForm().submit({
      timeout:60000,
         waitMsg:'正在保存,请稍后...',
         failure:function(form,action){        
         Ext.Msg.alert("failure","保存失败!");
         },
         success:function(form,action){        
          if(!action.result.success){          
           Ext.Msg.alert('提示', '用户已存在,插入失败');
          }
                          Ext.Msg.alert('提示', '保存成功');
       editWin.close();
       dataStore.load({
        params : {
         start : 0,
         limit : myPageSize
        }
       });
 
         }       
   });

    /*Ext.MessageBox.alert("提示", "修改失败");
    Ext.getCmp('staffId').setDisabled(true);
    Ext.getCmp('branch').setDisabled(true);
    Ext.getCmp('mobile').setDisabled(true);
    Ext.getCmp('role').setDisabled(true);
    Ext.getCmp('name').setDisabled(true);
    Ext.getCmp('dept').setDisabled(true);
    Ext.getCmp('ext').setDisabled(true);
    Ext.getCmp('befBranch').setDisabled(true);*/
    } 
    else {
     Ext.MessageBox.alert('提示', '请输入必输项!');
    }
  
   }
  }, {
   text : '取消',
   handler : function() {
    editWin.close();
   }
  } ]
 });
 multiSelect.setValue(record.get('befBranch'));
 
 editWin.show();
 multiSelect.valueField = 'branchId';
};

你可能感兴趣的:(弹出的代码样例)