function doWirelessEnterprise(actionType, id, usertype, flag) {
	var title = '';
	var categoryDisabled = false;
	var userTypeDisabled = true;
	var useridDisabled = true;
	var url = 'enterprises_update.action';
	var gridReflesh = false;
	var idReadOnly = true;
	if(actionType == 'updateInfo'){
		categoryDisabled = true;
		title = '企业信息维护';
	}
	if(actionType == 'register'){
		url = '/enterprises_register.action';
		title = '用户注册';
		idReadOnly = false;
		userTypeDisabled = false;
		useridDisabled = false;
	}
	if(actionType == 'Operator'){
		title = '申报用户查看与审查';
		gridReflesh = true;
		userTypeDisabled = true;
		useridDisabled = false;
	}
	if(actionType == 'administrator'){
		title = '申报用户查看与审查';
		gridReflesh = true;
		userTypeDisabled = false;
		useridDisabled = false;
	}
	
	function field(name, fieldLabel, inputType) {
		return { fieldLabel: fieldLabel, inputType: inputType, name: name };
	}
	
	function twoColumnedPanel(leftColumnItems, rightColumnItems) {
		return {
			baseCls: 'x-plain',
			defaults: {
				baseCls: 'x-plain',
//				columnWidth: 0.5,
				defaults: { anchor: '94%'},
				layout: 'form'
			},
			items: [
				{ defaultType: 'textfield',	items: leftColumnItems, columnWidth: 0.5 },
				{ defaultType: 'textfield', items: rightColumnItems, columnWidth: 0.5 }
			],
			layout: 'table'
		};
	}
	function certainLengthTextField(name, fieldLabel, anchors, maxLength, allowBlank, enabled) {
		return new Ext.form.TextField({maxLength: maxLength, allowBlank: false||allowBlank, anchor: anchors, name: name, fieldLabel: fieldLabel ,disabled:false||enabled });
	};
	
	var utype_store = new Ext.data.Store({
		autoLoad: true,
		reader: new Ext.data.JsonReader({ id: 'id'}, [ 'id', 'typeName' ]),
		url: '/wirelessUserType.action'
	});
	
	
	var utypeCombo = new Ext.form.ComboBox({
		mode: 'local',
		hiddenName:'rscId.id',
		allowBlank: false,
		disabled: userTypeDisabled,
		valueField:'id',
		store: utype_store,
		fieldLabel:'用户类型（必填）',
		displayField: 'typeName'
	});
	
	var tasterCombo = new Ext.form.ComboBox({
//		id: 'tasterCombo',
		hiddenName: 'managId',
		valueField: 'id',
		allowBlank: false,
		disabled: userTypeDisabled,
		store: Ext.StoreMgr.add('store-taster', new Ext.data.Store({
			autoLoad: true,
			reader: new Ext.data.JsonReader({ id: 'id', root: 'testers' }, [ 'id','room']),
			url: 'tasters_list.action'
		})),
		fieldLabel:'对应审批机构（必填）',
		displayField: 'room'
//		anchor: '60%',
	})

	var roomCombo = new Ext.form.ComboBox({
		mode: 'local',
		anchor: '95%',
		allowBlank: false,
		listWidth: 350,
		displayField: 'description',
		disabled: userTypeDisabled,
		hiddenName: 'room',
		store: new Ext.data.SimpleStore({
			data: [
			//下拉框的第二个值必须和window-operator.js对应的处室的值的字母相对应
			//如’无线电频率指配‘属于无线电管理处的，他的值A1 的第一个字母’A' 对应于window-operator.js中处室——无线电管理处的值是 ‘A’，第二个字母不要紧，只要不重复就可以了
				['无线电频率指配','A1'], 
				['研制、生产无线电发射设备时进行实效发射试验的审批','A2'], 
				['无线电台（站）的设置及变更审批','A3'], 
				['研制或生产无线电发射设备的型号','A4'], 
				['无线电发射设备进关核准--进口申请','A5'], 
				['无线电发射设备进关核准--进关申请','A6'], 
				['无线电台（站）呼号审批','A7'],
				['建立卫星通信网和设置卫星地球站审批','A8'],
				['“三高”地点接纳设置无线寻呼发射基站的“三高”产权单位备案','A9']
				],
			fields: ['description','value' ]
		}),
		valueField: 'value',
		fieldLabel: '申报类型（必填）'
	});
	var user_store = new Ext.data.Store({
		autoLoad: false,
		baseParams: { type: 'Enterprise' },
		reader: new Ext.data.JsonReader({ id: 'id', root: 'records' }, [ 'id', 'region' ]),
		url: 'users_list.action'
	});
	function setFieldDisabled(i){
		Ext.each(i, function(item, index) {
			if(Ext.getCmp(item)){
				Ext.getCmp(item).setDisabled(true);
			}
		});
	}
	function setFieldEnabled(i){
		Ext.each(i, function(item, index) {
			if(Ext.getCmp(item)){
				Ext.getCmp(item).setDisabled(false);
			} 
		});
	}
	
	function removeFields(i){
		Ext.each(i, function(item, index) {
			if(Ext.getCmp(item)){
				Ext.WindowMgr.getActive().items.get(0).form.remove(Ext.getCmp(item));
			} 
		});
	}
	
	function addFields(i){
		Ext.each(i, function(item, index) {
			if(Ext.getCmp(item)){
				Ext.WindowMgr.getActive().items.get(0).form.add(Ext.getCmp(item));
			} 
		});
	}
	function addFieldSet(name){
		if(Ext.getCmp(name)){
			Ext.WindowMgr.getActive().items.get(0).form.add(Ext.getCmp(name));
		} 
	}
	function removeFieldSet(name){ 
		if(Ext.getCmp(name)){
			Ext.WindowMgr.getActive().items.get(0).form.remove(Ext.getCmp(name));
		} 
	}
	function setFieldSetEnabled(name){
		if(Ext.getCmp(name)){
				Ext.getCmp(name).setDisabled(false);
		} 
	}
	function setFieldSetDisabled(name){
		if(Ext.getCmp(name)){
			Ext.getCmp(name).setDisabled(true);
		} 
	}
	var basicField = {
	    items: [
	   	 	{
	    		items:new Ext.form.TextField({allowBlank: false, regex:/^[A-Za-z0-9_\-\u4e00-\u9fa5]{2,20}$/,regexText:'用户名为2-20位的字母、中文、数字、中划线、下划线或其组合',
					name: 'id', fieldLabel: '用户名（必填）', readOnly:idReadOnly, anchor:'47%'}),
	   	 		baseCls: 'x-plain',
				labelWidth: 130,
				layout: 'form'
	   	 	},
			{
				baseCls: 'x-plain',
				defaults: {
					baseCls: 'x-plain',
					columnWidth: 0.5,
					defaults: { anchor: '94%'},
					layout: 'form'
				},
				items: [
					{ defaultType: 'textfield',	items: utypeCombo, columnWidth: 0.9,labelWidth:130 },
					{ items: tasterCombo, columnWidth: 0.9,labelWidth:130 },
					{ items:{xtype:'hidden', name:'room', value:'A1'},columnWidth: 0.1 }
//					{ defaultType: 'textfield', items: roomCombo, columnWidth: 0.5 }
				],
				layout: 'column'
			}
		],
		title: '帐户信息',
		xtype: 'fieldset',
		id: 'basicField'
	};
	var enterpriseField = {
	    items: [
	    
	    	{xtype:'hidden', id:'wirelessFlag',name:'wirelessFlag',value:'2'},
	    	{xtype:'hidden', id:'utype',name:'utype',value:'B'},
	    	new Ext.form.TextField({maxLength: 50, allowBlank: false,anchor:'97%', name: 'name',readOnly: userTypeDisabled, fieldLabel: '单位名称或姓名（必填）', id:'enterpriseName'}),
			new Ext.form.TextField({maxLength: 50, allowBlank: false,anchor:'97%', name: 'address', fieldLabel: '单位地址或住址（必填）',id:'enterpriseAddress'}),
			{items:new Ext.form.TextField({allowBlank: true, anchor: '97%', name: 'code',readOnly: userTypeDisabled&&!flag, fieldLabel: '组织机构代码（非个人账户必填，如无，请在下方填写无组织机构代码原因）',id:'enterpriseCode',regex:/^[A-Za-z0-9]{8}-[A-Za-z0-9]{1}$/,regexText:'组织机构代码为8位数字（或字母）+中划线+1位数字（或字母），且必须为半角符'}),
				baseCls: 'x-plain',
				labelWidth: 420,
				layout: 'form'
			},
			
			
			{	items: new Ext.form.TextField({
					maxLength: 150, anchor:'97%', name: 'codeReason', 
					fieldLabel: '无组织机构代码的原因',id:'enterpriseCodeReason', 
					allowBlank: true
				}),
				baseCls: 'x-plain',
				labelWidth: 150,
				layout: 'form'
			},
			{	labelWidth: 150,
				items:[twoColumnedPanel(
					[ new Ext.form.TextField({maxLength: 30, allowBlank: false, anchor: '90%', name: 'commercialId',readOnly: userTypeDisabled&&!flag, fieldLabel: '工商注册号（企业类必填）',
						 id: 'commercialId', width:200}), 
					  new Ext.form.TextField({maxLength: 16, allowBlank: false, name: 'representitive', fieldLabel: '法定代表人（企业类必填）',id:'representitive'}),	
						new Ext.form.TextField({maxLength: 25, allowBlank: false, anchor: '90%', minLength:6, id: 'enterprisePhone',
							name: 'phone', fieldLabel: '电  话（必填）', regex:/^\d+-?\d+$/, regexText: '电话号码只能是纯数字或数字-数字'}) ],
					[ new Ext.form.NumberField({maxLength: 6,minLength: 6,maxLengthText: '邮政编码为6位数字',maxLengthText:'邮政编码为6位数字', allowBlank: false, anchor: '90%', name: 'zip', fieldLabel: '邮政编码（必填）',id:'enterpriseZip', width:200}),
						new Ext.form.TextField({maxLength: 16, allowBlank: false, name: 'contact', fieldLabel: '工作联系人（必填）',id:'enterpriseContact'}),
						new Ext.form.TextField({maxLength: 25, allowBlank: true, anchor: '90%', minLength:6, id: 'enterpriseFax',
							name: 'fax', fieldLabel: '传  真', regex:/^\d+-?\d+$/, regexText: '传真只能是纯数字或数字+中划线+数字'})
					]
				),
				twoColumnedPanel(
					new Ext.form.TextField({allowBlank: true, anchor: '90%',name: 'email',
						 vtype: 'email', fieldLabel: 'E-mail',maxLength: 40, id:'enterpriseEmail', width:200 }),
					new Ext.form.TextField({ name: 'url',   vtype: 'url'  , fieldLabel: '网  址',
						maxLength: 30, id:'enterpriseUrl', width:200 })
				)]
			},
			
//			twoColumnedPanel(
//				[ new Ext.form.TextField({maxLength: 30, allowBlank: false, anchor: '90%', name: 'commercialId',readOnly: userTypeDisabled&&!flag, fieldLabel: '工商注册号（企业类必填）',
//					 id: 'commercialId', width:280,labelWidth:200}), 
//				  new Ext.form.TextField({maxLength: 16, allowBlank: false, name: 'representitive', fieldLabel: '法定代表人（企业类必填）',id:'representitive'}),	
//					new Ext.form.TextField({maxLength: 25, allowBlank: false, anchor: '90%', minLength:6, id: 'enterprisePhone',
//						name: 'phone', fieldLabel: '电  话（必填）', regex:/^\d+-?\d+$/, regexText: '电话号码只能是纯数字或数字-数字'}) ],
//				[ new Ext.form.NumberField({maxLength: 6,minLength: 6,maxLengthText: '邮政编码为6位数字',maxLengthText:'邮政编码为6位数字', allowBlank: false, anchor: '90%', name: 'zip', fieldLabel: '邮政编码（必填）',id:'enterpriseZip', width:280}),
//					new Ext.form.TextField({maxLength: 16, allowBlank: false, name: 'contact', fieldLabel: '工作联系人（必填）',id:'enterpriseContact'}),
//					new Ext.form.TextField({maxLength: 25, allowBlank: true, anchor: '90%', minLength:6, id: 'enterpriseFax',
//						name: 'fax', fieldLabel: '传  真', regex:/^\d+-?\d+$/, regexText: '传真只能是纯数字或数字+中划线+数字'})
//				]
//			),
//			twoColumnedPanel(
//				new Ext.form.TextField({allowBlank: true, anchor: '90%',name: 'email',
//					 vtype: 'email', fieldLabel: 'E-mail',maxLength: 40, id:'enterpriseEmail', width:280 }),
//				new Ext.form.TextField({ name: 'url',   vtype: 'url'  , fieldLabel: '网  址',
//					maxLength: 30, id:'enterpriseUrl', width:280 })
//			),
			new Ext.form.TextArea({ anchor: '97% 30%', fieldLabel: '简介（必填）', name:'remark',maxLength:500, grow:true, preventScrollbars :true,allowBlank: false, id: 'enterpriseRemark'})
		], 
		title: '详细信息',
		xtype:'fieldset',
		id: 'enterpriseField'
	};

//	Ext.getCmp('province').on('select', function(combo, record) {
//		Ext.getCmp('area').clearValue();
//		Ext.getCmp('city').clearValue();
//		
//		Ext.StoreMgr.get('store-area').baseParams = { areaId: record.get('id') };
//		Ext.StoreMgr.get('store-area').load();
//	});
//	Ext.getCmp('area').on('select', function(combo, record) {
//		Ext.getCmp('city').clearValue();
//		
//		Ext.StoreMgr.get('store-city').baseParams = { areaId: record.get('id') };
//		Ext.StoreMgr.get('store-city').load();
//	});
	
	if(Ext.getCmp('enterpriseCode')){
		Ext.getCmp('enterpriseCode').on('blur', function(){
			if(Ext.getCmp('enterpriseCode').getValue() == '' || Ext.getCmp('enterpriseCode').getValue() == null){
				Ext.getCmp('enterpriseCodeReason').setDisabled(false);
				if(actionType == 'Operator' || actionType == 'administrator'){  //审核员进入
					Ext.getCmp('enterpriseCodeReason').allowBlank = true;
				} else {
					Ext.getCmp('enterpriseCodeReason').allowBlank = false;
				}
			} else {
				Ext.getCmp('enterpriseCodeReason').allowBlank = true;
				Ext.getCmp('enterpriseCodeReason').setValue();
				Ext.getCmp('enterpriseCodeReason').setDisabled(true);
			}
		});
	}
	
	var items = [basicField, enterpriseField];
	
	if(actionType == 'register'){
		items.push({
				title:'安全信息',
				xtype:'fieldset',
				items:twoColumnedPanel(
					[new Ext.form.TextField({maxLength: 16, allowBlank: false, anchor: '90%', minLength:6,
						name: 'password', fieldLabel: '密  码（必填）', inputType:'password'})], 
					[new Ext.form.TextField({maxLength: 16, allowBlank: false, anchor: '90%',minLength:6, 
						name: 'confirm', fieldLabel: '确认密码（必填）', inputType:'password'})]
				)
			});
	}
	
	function pushCombobox(comboboxDisabled){
		items.push({
			items: [
				new Ext.form.ComboBox({
					allowBlank: true,
					mode: 'local',
					hiddenName:'enabled',
					valueField:'value',
					disabled: comboboxDisabled,
					store: new Ext.data.SimpleStore({
						data: [['通过',true], ['不通过',false] ],
						fields: ['description','value' ]
					}),
					fieldLabel:'<span style="color:red">审核结果</span>',
					displayField: 'description'
				})
			],
			xtype:'fieldset',
			title: '<span style="color:red">用户审核</span>'
		});
	};
	
	
	
	if(actionType == 'Operator' || actionType == 'administrator'){
		pushCombobox(false);
		//省经信委无线电审核员和管理员
		Ext.getCmp('enterpriseAddress').allowBlank = true;
		Ext.getCmp('enterpriseCodeReason').allowBlank = true;
		Ext.getCmp('commercialId').allowBlank = true;
		Ext.getCmp('representitive').allowBlank = true;
		Ext.getCmp('enterprisePhone').allowBlank = true;
		Ext.getCmp('enterpriseZip').allowBlank = true;
		Ext.getCmp('enterpriseContact').allowBlank = true;
		Ext.getCmp('enterpriseEmail').allowBlank = true;
		Ext.getCmp('enterpriseRemark').allowBlank = true;
		
			
			
	}else if(actionType == 'updateInfo'){
		pushCombobox(true);
	}
	
	
	var viewport = new Ext.Viewport({
		layout:'fit',
		items:{	
			buttons : [{
				handler:  function() {
					Ext.getCmp('wirelessEnterpriseForm').getForm().submit({
						failure: function(form, action) {
//							alert("提交失败，请检查输入项格式是否正确!");
							if(action.failureType == 'client' ){
								alert('输入项有误，请查看红色感叹号处！');
							} else if(action.failureType == 'server') {
								var application = action.result;
								if (null!=application.errors.name) {
									alert('单位名称已存在，说明你单位已注册过账户，不可重复注册，请向你单位内相关工作人员索取账户信息！');
								} else if (null!=application.errors.id){
									alert('用户名已存在，说明该用户名已被使用，不可重复注册，请改用其他用户名！');
								} else if (null!=application.errors.commercialId){
									alert('工商注册号已存在，说明你单位已注册过账户，不可重复注册，请向你单位内相关工作人员索取账户信息！');
								} else if (null!=application.errors.code){
									alert('组织机构代码已存在，说明你单位已注册过账户，不可重复注册，请向你单位内相关工作人员索取账户信息！');
								} else {
									alert('提交失败，请检查输入项格式是否正确！');
								}
							}
						},
						success: function() {
							if(gridReflesh){ 
								window.opener.Ext.StoreMgr.get('store-wirelessenterprise').load();
							}
							Ext.Msg.show({
								buttons: Ext.MessageBox.OK,
								fn: function(){ 
									window.close();
									if(actionType == 'register') {
										window.open('/wirelessjihuo.html','', 'height=680,width=1000,left=0,top=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
									}
									if(flag) {
										window.location.href = '/wireless/logout.action';
									}
								},
								icon: Ext.MessageBox.INFO,
								msg: '操作成功',
								title: '信息'
							});
							
						},
						url: url
					});
				},
				text: '提交'
			},{
			 	handler: function(){ 
					window.close();
					if (flag)
						window.opener.location.href = '/wireless/logout.action';
			 	}, text: '取消'
			}],
			items: {
				bodyStyle: 'margin-bottom: 10px',
				defaults: { autoHeight: true },
//				title:'基本信息',
				items :items
			},
			id: 'wirelessEnterpriseForm',
			xtype: 'userform'
			
//			items:[{
//				bodyStyle : 'padding: 15px 10px 10px',
//				items : new Ext.form.FormPanel({
//					autoScroll:true,
//					id: 'wirelessEnterpriseForm',
//					defaults: { labelWidth: 150 },
//					defaultType: 'fieldset',
//					items: items,
//					listeners: {
//						add: function(container, component) {
//							this.doLayout();
//							this.doLayout();
//							Ext.each(component.findBy(function(component) { return component.isXType('field'); }), function(item) { container.form.add(item); });
//						},
//						remove: function(container, component) {
//							Ext.each(component.findBy(function(component) { return component.isXType('field'); }), function(item) { container.form.remove(item); });
//						}
//					}
//				})
//			}]
		}
	});
	
	
//	var entWindow = new Ext.Window({
//		bbar: ['->', {
//			handler:  function() {
//						Ext.WindowMgr.getActive().items.first().getForm().submit({
//							failure: function(form, action) {
//								alert("提交失败，请检查输入项格式是否正确!");
//							},
//							success: function() {
//								Ext.Msg.show({
//									buttons: Ext.MessageBox.OK,
//									fn: function(){ 
//										Ext.WindowMgr.getActive().close();
//										if(actionType == 'register') {
//											window.open('/jihuo.html','', 'height=680,width=1000,left=0,top=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
//										}
//										if(flag) {
//											window.location.href = '/wireless/logout.action';
//										}
//									},
//									icon: Ext.MessageBox.INFO,
//									msg: '操作成功',
//									title: '信息'
//								});
//								
//								if(gridReflesh){ 
//									Ext.StoreMgr.get('store-wirelessenterprise').load();
//								}
//							},
//							url: url
//						});
//				},text: '提交'
//			},'-', {
//			 handler: function(){ 
//				Ext.WindowMgr.getActive().close();
//				if (flag)
//					window.location.href = '/wireless/logout.action';
//			 }, text: '取消'
//			}],
//		closable :false,
//		height:590, 
//		autoScroll: true,
//		items: new Ext.form.FormPanel({
//			id: 'form',
//			defaults: { labelWidth: 75 },
//			defaultType: 'fieldset',
//			items: items,
//			listeners: {
//			add: function(container, component) {
//				this.doLayout();
//				this.doLayout();
//				Ext.each(component.findBy(function(component) { return component.isXType('field'); }), function(item) { container.form.add(item); });
//			},
//			remove: function(container, component) {
//				Ext.each(component.findBy(function(component) { return component.isXType('field'); }), function(item) { container.form.remove(item); });
//			}
//		}
//			
//		}),
//		maximizable: false,
//		id: 'window-enterprise',
//		title: title,
//		width: 680
//	});
	
	

	utypeCombo.on('select',function(combo, record, index) {
		if(actionType == 'Operator' || actionType == 'administrator'){  //审核员进入
			setFieldEnabled(['representitive','commercialId']);
			Ext.getCmp('representitive').allowBlank = true;
			Ext.getCmp('commercialId').allowBlank = true;
		} else {
			if (this.value.indexOf('4') == 0 || this.value.indexOf('5') == 0 ) {
				setFieldEnabled(['representitive','commercialId']);
				Ext.getCmp('representitive').allowBlank = false;
				Ext.getCmp('commercialId').allowBlank = false;
			} else {
				setFieldDisabled(['representitive','commercialId']);
				Ext.getCmp('representitive').clearInvalid();
				Ext.getCmp('commercialId').clearInvalid();
				Ext.getCmp('representitive').allowBlank = true;
				Ext.getCmp('commercialId').allowBlank = true;
			}
		}
		

	});
	if(id){
//		entWindow.show(null,function(){
			Ext.getCmp('wirelessEnterpriseForm').getForm().load({
				method: 'POST',
				params:  { 'id': id },
				success:function(form, action){
					if(Ext.getCmp('enterpriseCode')){
						Ext.getCmp('enterpriseCode').fireEvent('blur', Ext.getCmp('enterpriseCode'));
					}
					var theUtype = action.result.data.utype;
					var rscId = action.result.data.rscId.id;
					var managId = action.result.data.managId;
					utypeCombo.setValue(rscId);
					utypeCombo.fireEvent('select', utypeCombo);
					tasterCombo.setValue(managId)
				},
				url: '/users_view.action'
			})

//			doAction('load', 'post','/users_view.action',function(form, action){
//				if(Ext.getCmp('enterpriseCode')){
//					Ext.getCmp('enterpriseCode').fireEvent('blur', Ext.getCmp('enterpriseCode'));
//				}
//				var theUtype = action.result.data.utype;
//				var rscId = action.result.data.rscId.id;
//				utypeCombo.setValue(rscId);
//				utypeCombo.fireEvent('select', utypeCombo);
//			}, {'id':id });

//		});
	}else{

	}
} 
