App.tabs.eduHighRiskGravida = (function(){ var limit = 20,tabId = "eduHighRiskGravidaTab",addOrUpdateWin = null, acrWin = null, aclWin = null; function init(){ var curPanel = Ext.getCmp('tabsPanel'); var store = new Ext.data.Store({ autoLoad:false, proxy:new Ext.data.HttpProxy({url:App.baseURL+'/eduHighRiskGravida/findPage'}), reader:new Ext.data.JsonReader({ totalProperty:'totalCount', root:'datas', idProperty:'id', fields:[{name:'id'},{name:'week1'},{name:'week2'},{name:'content'},{name:'statue'},{name:'highRiskName'},{name:'highRiskId'},{name:'highRiskState'}] }), baseParams:{start:0,limit:limit,field:'',keyword:''}, listeners:{ loadexception:function(proxy,type,action,options,response){ App.failureCallback(action); } } }), sm = new Ext.grid.CheckboxSelectionModel({singleSelect:false}), cm = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(),sm, {header : '因 素',dataIndex : 'highRiskName',sortable : true,width : 200}, {header : '时间范围',dataIndex : 'week1',sortable : true,width : 200,renderer:function(value, metaData, record, rowIndex, colIndex, store){ return record.get('week1')+" - "+ record.get('week2') ; }}, {header : '指导内容',dataIndex : 'content',sortable : true,width : 200} ]), grid = new Ext.grid.GridPanel({ id:'eduHighRiskGravidaGrid', border : false, columnLines : true, autoScroll : true, store : store, autoHeight:false, stripeRows:true, cm : cm, sm : sm, loadMask : {msg : CONST.TIP017}, bbar:new Ext.PagingToolbar({ pageSize : limit, store : store, emptyMsg : "<font color='red'>没有记录</font>", displayInfo : true, plugins:new Ext.ux.ComboPageSize({addToItem:true,index:10}) }), tbar:[{text:'添加',iconCls:'add',handler:function(){showAddOrUpdate('add');}}, ' ',{text:'修改',iconCls:'update', handler:function(){showAddOrUpdate('update');}}, ' ',{text:'删除',iconCls:'delete',handler:doDelete}, '->',{ xtype:'combo', id:'searchCombo', typeAhead: true, triggerAction: 'all', lazyRender:true, mode: 'local', value:'选择查询内容', width:80, editable:false, store: new Ext.data.ArrayStore({ fields: ['keytype','keytext'], data: [['week1', '孕周段1'], ['week2', '孕周段2'], ['content', '指导内容']] }), valueField: 'keytype', displayField: 'keytext' },' ',{xtype:'textfield',emptyText:'输入关键字查找',enableKeyEvents:true,id:'searchText',width:180, listeners:{ keydown:{ fn:function(t,e){ if(e.keyCode == 13){ search(); } }, buffer:350, scope:this } } },' ', {text:'查 询',iconCls:'query',handler:search},'-', {text:'刷 新',iconCls:'refresh',handler:function(){ Ext.getCmp('searchCombo').setValue("week1"); Ext.getCmp('searchText').setValue(""); Ext.apply(store.baseParams,{field:'',keyword:''}); store.load(); }}] }), tab = curPanel.add({ title : ' 高危孕产妇 ', id : tabId, closable : true, layout : 'card', iconCls:'userSuit', activeItem :0, listeners:{ activate:function(p){ store.load(); } }, items:[grid] }); curPanel.setActiveTab(tab); } /** 添加或者修改 **/ function showAddOrUpdate(type){ var store = new Ext.data.Store({ autoLoad:false, proxy:new Ext.data.HttpProxy({url:App.baseURL+'/eduHighRiskGravida/findPage'}), reader:new Ext.data.JsonReader({ totalProperty:'totalCount', root:'datas', idProperty:'id', fields:[{name:'id'},{name:'week1'},{name:'week2'},{name:'content'},{name:'statue'},{name:'highRiskName'}] }), baseParams:{start:0,limit:limit,field:'',keyword:''}, listeners:{ loadexception:function(proxy,type,action,options,response){ App.failureCallback(action); } } }); var title='',iconCls='',btnText='',url='',record=null,grid = Ext.getCmp('eduHighRiskGravidaGrid'); if(type == 'add'){ title='添加',iconCls='add',btnText='保存',url=App.baseURL+'/eduHighRiskGravida/add'; }else if(type == 'update'){ title='修改',iconCls='update',btnText='修改',url=App.baseURL+'/eduHighRiskGravida/update'; var selectRocords = grid.getSelectionModel().getSelections(); if(selectRocords.length <= 0){ Ext.UxMsg.alert({msg:CONST.TIP001}); return; }else if(selectRocords.length > 1){ Ext.UxMsg.alert({msg:CONST.TIP002}); return; }else{ record = selectRocords[0]; } } if(!addOrUpdateWin){ addOrUpdateWin = new Ext.Window({ title:title, height:400, width:450, iconCls:iconCls, constrain:true, modal:true, resizable:true, renderTo:tabId, closeAction:'close', bodyStyle:'background-color:white;', listeners:{ close:function(){grid.getStore().reload();addOrUpdateWin.destroy();addOrUpdateWin = null;} }, items:[new Ext.form.FormPanel({ ref:'itemForm', id:'itemForm', url : url, layout:'form', border:false, labelWidth:75, labelAlign:'right', buttonAlign:'center', defaults:{anchor:App.anchor,xtype:'textfield',ctCls:'formMargin',labelStyle:App.labelStyle}, items:[{ fieldLabel:'孕周段1', ref:'../week1', allowBlank:false, name:'week1', maxLength:25 },{ fieldLabel:'孕周期2', ref:'../week2', name:'week2', allowBlank:false, maxLength:8 },{ xtype:'combo', fieldLabel:"高危因素一级分类", id:'highRiskName1', ref:'../highRiskName1', typeAhead: true, triggerAction: 'all', lazyRender:true, mode: 'local', value:'请选择', width:80, editable:false, store: new Ext.data.ArrayStore({ fields: ['keytype','keytext'], data: [['1', '本次妊娠基本情况'], ['2', '不良孕产史'], ['3', '妊娠合并症'], ['4', '妊娠并发症'], ['5', '环境与社会因素']] }), valueField: 'keytype', displayField: 'keytext', listeners: { 'select': function(combo, record, index){ //var value = Ext.get("highRiskName1").dom.value; //alert( combo.getValue()+' '+record.get('keytype') +' '+ index +' ' + value ); var highRiskNameStore = Ext.getCmp('highRiskName').getStore(); highRiskNameStore.removeAll(false); Ext.apply( highRiskNameStore.baseParams,{ state:combo.getValue() }); highRiskNameStore.load(); } } },{ xtype:'combo', id:'highRiskName', ref:'../highRiskName', editable:false, fieldLabel:"高危因素二级分类", triggerAction:"all", mode:"remote", allowBlank:false, enable:false, store:new Ext.data.Store({ id:'highRiskNameStore', //autoLoad:true, proxy:new Ext.data.HttpProxy({url:App.baseURL+"/dicHighrisk/getHighRiskByStatue"}), reader:new Ext.data.JsonReader({fields:[{name:"id"},{name:"name"}]}), baseParams:{state:'0'}, listeners:{ loadexception:function(proxy,type,action,options,response){ App.failureCallback(action); }, 'beforeload':function( store , options ){ //alert( store.baseParams.state ); } } }), displayField:"name", valueField:"id", hiddenName: 'highRiskId', //传到后台的name name:'highRiskId', autoShow:true },{ xtype:'htmleditor', fieldLabel:'指导内容', width:430, height:150, ref:'../content', name:'content', allowBlank:false } ] })], bbar:['->',{ text:btnText, iconCls:'saveBtn', handler:function(){ var myForm = addOrUpdateWin.itemForm.getForm(); if(!myForm.isValid()){return;} /* var week1 = addOrUpdateWin.week1.getValue(), week2 = addOrUpdateWin.week2.getValue(), content = addOrUpdateWin.content.getValue(), highRiskName = addOrUpdateWin.highRiskName.getValue(); */ //App.myMask = new Ext.LoadMask(addOrUpdateWin.el,{msg:CONST.TIP016,removeMask:true}); //App.myMask.show(); myForm.submit( { success : function(form,responseObj){ //var json = App.parseJSON( responseText ); var json = Ext.util.JSON.decode(responseObj.response.responseText); //alert( responseObj.response.responseText +' ' +json.msg ); if(json && json.success){ Ext.UxMsg.alert({msg:CONST[json.msg]}); if(type == 'add' ){ myForm.reset(); } addOrUpdateWin.close(); //myForm.reload(); Ext.getCmp('eduHighRiskGravidaGrid').getStore().reload(); } }, failure : App.failureCallback, waitTitle : '等待', waitMsg : '保存中,请稍后...' }); /* Ext.Ajax.request({ url:url, method:'POST', params:{week1:week1,week2:week2,content:content,highRiskName:highRiskName,id:record?record.data.id:0}, success:function(response){ var json = App.parseJSON(response.responseText); if(json && json.success){ Ext.UxMsg.alert({msg:CONST[json.msg]}); if(type == 'update'){ addOrUpdateWin.close(); }else{ myForm.reset(); } } }, failure:App.failureCallback }); */ } },'-',{text:'重置',iconCls:'resetBtn',handler:function(){addOrUpdateWin.itemForm.getForm().reset();}}, '-',{text:'取消',iconCls:'cancelBtn',handler:function(){addOrUpdateWin.close();} }] }); } addOrUpdateWin.show(); App.modules.changeEnterToTab(); if(type == 'update'){ //alert(addOrUpdateWin.itemForm.items.getCount() ); var id = new Ext.form.Hidden({ xtype : 'hidden', name : 'id', ref:'../id', value:record.data.id }); addOrUpdateWin.itemForm.items.add( id ); //alert(addOrUpdateWin.itemForm.items.getCount() ); Ext.getCmp("itemForm").getForm().loadRecord(record); //var recordHighRisk = new Ext.data.Record.create([{name:"id"},{name:"name"}]); //var recordData = new recordHighRisk({ 'id' : record.get('highRiskId') , 'name':record.get('highRiskName') }); //Ext.getCmp('highRiskName').getStore().add(recordData); //addOrUpdateWin.highRiskName.load(); //Ext.getCmp('highRiskName').getStore().load(); //alert( Ext.getCmp('highRiskName').getStore().getAt(0).get('id') ); //alert(record.get('highRiskId') +' '+record.get('highRiskName') ); //addOrUpdateWin.highRiskName.hiddenValue=record.get('highRiskId'); //重新加载combox ,然后选中某一项 var highRiskNameStore = Ext.getCmp('highRiskName').getStore(); highRiskNameStore.removeAll(false); Ext.apply( highRiskNameStore.baseParams,{ state:record.get('highRiskState') }); highRiskNameStore.load(); Ext.getCmp('highRiskName').setValue(record.get('highRiskId')); Ext.getCmp('highRiskName').setRawValue(record.get('highRiskName')); /* alert(record.data.id ); addOrUpdateWin.id.setValue( record.data.id); addOrUpdateWin.week1.setValue(record.data.week1); addOrUpdateWin.week1.setValue(record.data.week1); addOrUpdateWin.week2.setValue(record.data.week2); addOrUpdateWin.content.setValue(record.data.content); addOrUpdateWin.highRiskName.setValue(record.data.highRiskName); Ext.getCmp('itemForm').load( { url : '/eduHighRiskGravida/queryById/'+record.data.id, method : 'GET' }); */ } } /** 输入框查询 **/ function search(){ var keytype = Ext.getCmp('searchCombo').getValue(), searchtext = Ext.getCmp('searchText').getValue(), _store = Ext.getCmp('eduHighRiskGravidaGrid').getStore(); if(searchtext && searchtext !='输入关键字查找'){ Ext.apply(_store.baseParams,{keyword:searchtext,field:keytype}); _store.load(); }else{ Ext.apply(_store.baseParams,{field:'',keyword:''}); _store.load(); } } function doDelete(){ var ids = '',dids = '',grid = Ext.getCmp('eduHighRiskGravidaGrid'),selects = grid.getSelectionModel().getSelections(); if(selects.length <= 0){ Ext.UxMsg.alert({msg:CONST.TIP003}); return; } for (var i = 0; i < selects.length; i++) { ids += ',' + selects[i].json.id; dids += ',' + selects[i].json.did; } Ext.Msg.confirm("提示",CONST.TIP023,function(val){ if(val=='yes'){ App.myMask = new Ext.LoadMask(grid.el,{msg:CONST.TIP018,removeMask:true}); App.myMask.show(); Ext.Ajax.request({ url:App.baseURL+"/eduHighRiskGravida/delete", method:'POST', params:{ids:ids.substring(1)}, success:function(response){ var json = App.parseJSON(response.responseText); if(json && json.success){ Ext.UxMsg.alert({msg:CONST[json.msg]}); grid.getStore().reload(); } }, failure:App.failureCallback }); } }); } function Cleanup() { window.clearInterval(idTmr); CollectGarbage(); }; /** 激活面板 **/ function active(){ var curPanel = Ext.getCmp('tabsPanel'); curPanel.setActiveTab(tabId); } return { init:init, active:active }; })();
1 grid 中加载的数据
{"totalCount":14,"pageNumber":1,"pageSize":10,"totalPage":2,"datas":[{"content":"指导内容: =========修改后内容","id":18,"highRiskId":127,"statue":0,"week1":1,"highRiskState":2,"week2":2,"highRiskName":"不孕史"},{"content":"5411","id":17,"highRiskId":111,"statue":0,"week1":3411,"highRiskState":4,"week2":4411,"highRiskName":"重度子痫前期"},{"content":"4441","id":16,"highRiskId":95,"statue":0,"week1":21,"highRiskState":2,"week2":31,"highRiskName":"疤痕子宫(2次以上)"},{"content":"555","id":15,"highRiskId":123,"statue":0,"week1":3,"highRiskState":1,"week2":4,"highRiskName":"中度智力低下"},{"content":"555","id":14,"highRiskId":96,"statue":0,"week1":3,"highRiskState":2,"week2":4,"highRiskName":"子宫破裂史"},{"content":"<FONT color=#ff0000>7222</FONT>","id":13,"highRiskId":122,"statue":0,"week1":5,"highRiskState":1,"week2":6,"highRiskName":"辅助生育怀孕者"} ]}
2 修改时加载的数据
[{"id":95,"name":"疤痕子宫(2次以上)"},{"id":96,"name":"子宫破裂史"},{"id":97,"name":"产后出血抢救史"},{"id":127,"name":"不孕史"},{"id":128,"name":"三次自然流产或早产≥2次"},{"id":129,"name":"死胎/死产/新生儿死亡史"},{"id":130,"name":"刮宫手术史≥2次"},{"id":131,"name":"阴道难产史"},{"id":132,"name":"疤痕子宫(剖宫产史、子宫肌瘤剜除史等)"},{"id":177,"name":"产钳/胎吸臀牵引史"},{"id":178,"name":"妇科生殖器手术史"},{"id":179,"name":"早产/先天性异常儿史"},{"id":180,"name":"流产史≥2次"}]