| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711 |
- Ext.define('erp.view.core.button.DbfindButton',{
- extend: 'Ext.Button',
- alias: 'widget.erpDbfindButton',
- //id: 'dbfind',
- text: 'DBfind设置',
- cls: 'x-btn-blue',
- iconCls: 'x-button-icon-query',
- hidden: false,
- disabled:true,
- style: {
- marginLeft: '10px'
- },
- width: 120,
- initComponent : function(){
- this.callParent(arguments);
- },
- dbfindSetUI: function(caller, field){
- var me=this;
- var formData=null,gridData=null,findData=null;
- var arr=new Array();
- Ext.Array.each(Ext.getCmp('grid').data,function(item){
- var obj=new Object();
- //obj.display=item.fd_caption;
- obj.display=item.fd_field;
- obj.value=item.fd_field;
- arr.push(obj);
- });
- var localJson=me.getDbFindSetUI(caller,field);
- if(localJson!=null||localJson.griddata!=null){
- gridData=localJson.griddata;
- formData=localJson.formdata;
- findData=localJson.fields;
- }else {
- gridData=new Array();
- for(var i=0;i<10;i++){
- var o = new Object();
- gridData.push(o);
- }
- }
- function showButton(value,cellmeta){
- var returnStr = "<INPUT align='center' type='button' value='删除' onclick='Delete();'>";
- return returnStr;
- };
- Ext.create('Ext.Window', {
- width: '90%',
- height: '100%',
- autoShow: true,
- layout: 'border',
- title:'<h1>Form查找配置</h1>',
- items: [{
- region:'north',
- xtype: 'form',
- id:'dbform',
- layout: 'column',
- autoScroll:true,
- buttonAlign:'center',
- bodyStyle: 'background:#f1f1f1;',
- fieldDefaults: {
- labelWidth: 70,
- fieldStyle:'background:#FFFAFA;color:#515151;'
- },
- items: [{
- xtype: 'textfield',
- fieldLabel: '描述',
- id:'ds_caption',
- name: 'ds_caption',
- columnWidth: 0.25
- },{
- xtype: 'textfield',
- fieldLabel: '关联表名',
- name: 'ds_whichdbfind',
- id:'ds_whichdbfind',
- allowBlank:false,
- fieldStyle:'background:#fffac0;color:#515151;',
- columnWidth: 0.5,
- },{
- xtype: 'dbfindtrigger',
- fieldLabel: '关联字段',
- name: 'ds_likefield',
- allowBlank:false,
- fieldStyle:'background:#fffac0;color:#515151;',
- columnWidth: 0.25,
- dbKey:'ds_whichdbfind',
- mappingKey:'ddd_tablename',
- dbMessage:'请选择该字段所属表名',
- },{
- xtype:'multidbfindtrigger',
- fieldLabel:'所需表',
- name: 'ds_tables',
- id:'ds_tables',
- allowBlank:false,
- fieldStyle:'background:#fffac0;color:#515151;',
- columnWidth: 0.5,
- listeners:{
- change:function(){
- Ext.getCmp('submitchange').setDisabled(false);
- }
- }
- },{
- xtype: 'textfield',
- fieldLabel: '条件',
- name: 'ds_uifixedcondition',
- columnWidth: 0.5
- },{
- xtype:'hidden',
- name:'ds_id'
- },{
- xtype:'hidden',
- name:'ds_caller'
- },{
- xtype:'hidden',
- name:'ds_whichui'
- }],
- buttons:[{
- xtype:'button',
- text: '确认',
- id:'submitchange',
- iconCls: 'x-button-icon-submit',
- cls: 'x-btn-gray',
- width: 60,
- disabled:true,
- handler:function(btn){
- var newValue=Ext.getCmp('ds_tables').value;
- Ext.Ajax.request({
- url : basePath +'common/getDbFindFields.action',
- params: {
- table:newValue,
- },
- async: false,
- method : 'post',
- callback : function(options,success,response){
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo != null){
- showError(res.exceptionInfo);return;
- }
- if(res.success){
- findData=Ext.decode(res.findfields);
- }
- }
- });
- }
- },{
- xtype:'button',
- text: $I18N.common.button.erpSaveButton,
- iconCls: 'x-button-icon-save',
- cls: 'x-btn-gray',
- formBind: true,//form.isValid() == false时,按钮disabled
- width: 60,
- style: {
- marginLeft: '10px'
- },
- handler:function(){
- me.save(me,caller,field);
- }
- },{
- xtype:'button',
- text: $I18N.common.button.erpCloseButton,
- iconCls: 'x-button-icon-close',
- cls: 'x-btn-gray',
- width: 60,
- style: {
- marginLeft: '10px'
- },
- handler:function(btn){
- btn.ownerCt.ownerCt.ownerCt.close();
- }
- }]
- },{
- region:'center',
- xtype: 'grid',
- id:'dbgrid',
- columnLines:true,
- store:Ext.create('Ext.data.Store',{
- fields:['ds_findtoui_f','ds_findtoui_i','ds_dbcaption',{name:'ds_dbwidth',type:'float'}]
- }),
- emptyText : $I18N.common.grid.emptyText,
- bodyStyle: 'background-color:#f1f1f1;',
- plugins: Ext.create('Ext.grid.plugin.CellEditing', {
- clicksToEdit: 1
- }),
- listeners:{
- itemclick:function(selModel, record,e,index){
- var grid=selModel.ownerCt;
- if(index.toString() == 'NaN'){
- index = '';
- }
- if(index == grid.store.data.items.length-1){//如果选择了最后一行
- var items=grid.store.data.items;
- for(var i=0;i<10;i++){
- var o = new Object();
- grid.store.insert(items.length, o);
- items[items.length-1]['index'] = items.length-1;
- }
- }
- }
- },
- columns: [{
- cls : "x-grid-header-1",
- text: '取值字段',
- xtype: 'combocolumn',
- dataIndex: 'ds_findtoui_f',
- renderer: function(val, meta, record){
- if(!val){
- val="";
- }
- return '<img src="' + basePath + 'resource/images/icon/need.png" title="必填字段">' +
- '<span style="color:blue;padding-left:2px;" title="必填字段">' + val + '</span>';
- },
- flex: 1,
- format:"",
- editor: {
- format:'',
- xtype: 'combo',
- listConfig:{
- maxHeight:180
- },
- store: {
- fields: ['display', 'value'],
- data :[],
- },
- displayField: 'display',
- valueField: 'value',
- queryMode: 'local',
- onTriggerClick:function(trigger){
- var me=this;
- this.getStore().loadData(findData);
- if (!me.readOnly && !me.disabled) {
- if (me.isExpanded) {
- me.collapse();
- } else {
- me.expand();
- }
- me.inputEl.focus();
- }
- }
- }
- },{
- cls : "x-grid-header-1",
- text: '赋值字段',
- xtype: 'combocolumn',
- dataIndex: 'ds_findtoui_i',
- flex: 1,
- renderer: function(val, meta, record){
- return val;
- },
- editor: {
- format:"",
- xtype: 'combo',
- listConfig:{
- maxHeight:180
- },
- store: {
- fields: ['display', 'value'],
- data:arr
- },
- displayField: 'display',
- valueField: 'value',
- queryMode: 'local',
- }
- },{
- cls : "x-grid-header-1",
- text: '描述',
- dataIndex: 'ds_dbcaption',
- flex: 1,
- editor:{
- xtype:'textfield',
- format:""
- },
- },{
- cls : "x-grid-header-1",
- text: '列宽',
- dataIndex: 'ds_dbwidth',
- //format: '0',
- flex:1,
- editor: {
- xtype: 'textfield',
- ///format: '0'
- }
- },{
- cls : "x-grid-header-1",
- text:'操作',
- dataIndex: 'button',
- flex:0.5,
- renderer:showButton,
- }]
- }]
- });
- Ext.getCmp('dbform').getForm().setValues(formData);
- Ext.getCmp('dbgrid').getStore().loadData(gridData);
- },
- dbfindSetGrid:function(caller,grid,field){
- var FindFields=new Array(),me=this,SetFields=new Array(),gridData=new Array(),DBCaller=null,DBKey=null;
- var me=this;
- function showButton(value,cellmeta){
- var returnStr = "<INPUT align='center' type='button' value='删除' onclick='DeleteGrid();'>";
- return returnStr;
- };
- var localJson=me.getDBGridFields(caller,field);
- if(localJson==null||!localJson.data){
- //说明无数据
- for(var i=0;i<10;i++){
- var o = new Object();
- o.ds_caller=caller;
- gridData.push(o);
- }Ext.Array.each(grid.data,function(item){
- var obj=new Object();
- obj.display=item.dg_caption;
- obj.value=item.dg_field;
- SetFields.push(obj);
- });
-
- }else {
- DBCaller=localJson.data.dbcaller;
- DBKey=localJson.data.linkkey;
- Ext.Array.each(localJson.data.details,function(field){
- var o=new Object();
- o.display=field.dd_fieldcaption;
- o.value=field.dd_fieldname;
- FindFields.push(o);
- });
- Ext.Array.each(grid.data,function(item){
- var obj=new Object();
- obj.display=item.dg_caption;
- obj.value=item.dg_field;
- SetFields.push(obj);
- });
- gridData=localJson.data.dbfindsetgrid;
- }
- Ext.create('Ext.Window', {
- width: '90%',
- height: '100%',
- autoShow: true,
- layout: 'border',
- title:'<h1>Grid查找配置</h1>',
- items: [{
- region:'center',
- xtype: 'grid',
- id:'dbGridgrid',
- columnLines:true,
- store:Ext.create('Ext.data.Store',{
- fields:['ds_id','ds_caller','ds_gridfield','ds_dbfindfield']
- }),
- emptyText : $I18N.common.grid.emptyText,
- bodyStyle: 'background-color:#f1f1f1;',
- plugins: Ext.create('Ext.grid.plugin.CellEditing', {
- clicksToEdit: 1
- }),
- tbar:[{
- xtype:'button',
- text: $I18N.common.button.erpSaveButton,
- iconCls: 'x-button-icon-save',
- cls: 'x-btn-gray',
- formBind: true,//form.isValid() == false时,按钮disabled
- width: 60,
- style: {
- margin: '10 5 0 5'
- },
- handler:function(btn){
- me.saveDBFindSetGrid(btn,caller,field);
- }
- },'-',{
- xtype:'button',
- text: $I18N.common.button.erpCloseButton,
- iconCls: 'x-button-icon-close',
- cls: 'x-btn-gray',
- formBind: true,//form.isValid() == false时,按钮disabled
- width: 60,
- handler:function(btn){
- btn.ownerCt.ownerCt.ownerCt.close();
- }
- },'-',{
- xtype:'button',
- text: '维护DBFindSet',
- iconCls: 'x-button-icon-submit',
- cls: 'x-btn-gray',
- width: 120,
- handler:function(btn){
- var value=btn.ownerCt.items.items[6].lastValue;
- if(value){
- openGridUrl(value,"ds_caller", "dd_caller", "jsps/ma/dbFindSet.jsp", "DBFind维护");
-
-
- }
- }
- },'-',{
- xtype:'dbfindtrigger',
- fieldLabel:'<h3>DBFindSetCaller</h3>',
- labelWidth:110,
- labelSeparator:"",
- name:'dbcaller',
- id:'dbcaller',
- allowBlank:false,
- value:DBCaller,
- fieldStyle:'background:#fffac0;color:#515151;',
- listeners:{
- change:function(field,newValue){
- Ext.getCmp('commitchange').setDisabled(false);
- },
- blur:function(){
-
- }
- }
- },{
- xtype:'hidden',
- name:'dbtable',
- id:'dbtablename',
- listeners:{
- change:function(field,newValue){
- var link=Ext.getCmp('linkkey');
- link.dbBaseCondition="ddd_tablename='"+newValue.toUpperCase()+"'";
- link.setDisabled(false);
- Ext.getCmp('linkkey').setValue(null);
- }
- }
- },{
- xtype:'dbfindtrigger',
- labelAlign:'right',
- fieldLabel:'<h3>关联字段名</h3>',
- labelWidth:80,
- labelSeparator:"",
- name:'linkkey',
- id:'linkkey',
- value:DBKey,
- disabled:true,
- allowBlank:false,
- fieldStyle:'background:#fffac0;color:#515151;',
- listeners:{
- afterrender:function(field){
- if(field.value){
- field.setDisabled(false);
- }
- }
- }
-
- },'-',{
- xtype:'button',
- text: '确认',
- id:'commitchange',
- iconCls: 'x-button-icon-submit',
- cls: 'x-btn-gray',
- width: 60,
- disabled:true,
- handler:function(btn){
- var field=Ext.getCmp('dbcaller');
- var table=Ext.getCmp('dbtablename').value;
- if(field.originalValue==field.value||table==undefined){
- Ext.Msg.alert('提示','未作修改!');
- btn.setDisabled(true);
- return;
- }else{
- //更改下拉store 同时 reset 关联字段
- var json=me.getDBGridFields(field.value,null);
- Ext.Array.each(json.data.details,function(field){
- var o=new Object();
- FindFields=new Array();
- o.display=field.dd_fieldcaption;
- o.value=field.dd_fieldname;
- FindFields.push(o);
- });
-
-
- }
-
-
- }
- }],
- listeners:{
- itemclick:function(selModel, record,e,index){
- var grid=selModel.ownerCt;
- if(index.toString() == 'NaN'){
- index = '';
- }
- if(index == grid.store.data.items.length-1){//如果选择了最后一行
- var items=grid.store.data.items;
- for(var i=0;i<10;i++){
- var o = new Object();
- o.ds_caller=caller;
- grid.store.insert(items.length, o);
- items[items.length-1]['index'] = items.length-1;
- }
- }
- }
- },
- columns: [{
- text: 'ID',
- dataIndex: 'ds_id',
- xtype:'numbercolumn',
- width:0,
- },{
- cls : "x-grid-header-1",
- text: 'Caller',
- dataIndex: 'ds_caller',
- flex:1,
- readOnly:true
- },{
- cls : "x-grid-header-1",
- text:'Grid赋值字段',
- dataIndex: 'ds_gridfield',
- flex:1,
- renderer: function(val, meta, record){
- if(!val){
- val="";
- }
- return '<img src="' + basePath + 'resource/images/icon/need.png" title="必填字段">' +
- '<span style="color:blue;padding-left:2px;" title="必填字段">' + val + '</span>';
- },
- editor: {
- format:"",
- xtype: 'combobox',
- listConfig:{
- maxHeight:180
- },
- typeAhead: true,
- triggerAction: 'all',
- selectOnTab: true,
- store: {
- fields: ['display', 'value'],
- data:SetFields,
- },
- displayField: 'display',
- valueField: 'value',
- queryMode: 'local',
- }
- },{
- cls : "x-grid-header-1",
- text:'查找字段',
- dataIndex: 'ds_dbfindfield',
- flex:1,
- renderer: function(val, meta, record){
- if(!val){
- val="";
- }
- return '<img src="' + basePath + 'resource/images/icon/need.png" title="必填字段">' +
- '<span style="color:blue;padding-left:2px;" title="必填字段">' + val + '</span>';
- },
- editor: {
- format:"",
- xtype: 'combo',
- listConfig:{
- maxHeight:180
- },
- store: {
- fields: ['display', 'value'],
- data:[],
- },
- onTriggerClick:function(trigger){
- var me=this;
- this.getStore().loadData(FindFields);
- if (!me.readOnly && !me.disabled) {
- if (me.isExpanded) {
- me.collapse();
- } else {
- me.expand();
- }
- me.inputEl.focus();
- }
- },
- displayField: 'display',
- valueField: 'value',
- queryMode: 'local',
- }
- },{
- cls : "x-grid-header-1",
- text:'操作',
- flex:0.5,
- dataIndex: 'button',
- renderer:showButton,
- }]
- }]
- });
- Ext.getCmp('dbGridgrid').getStore().loadData(gridData);
- },
- save:function(me,caller,field){
- var grid=Ext.getCmp('dbgrid');
- grid.necessaryField='ds_findtoui_f';
- var jsonGridData = new Array();
- var dd;
- var s = grid.getStore().data.items;
- for(var i=0;i<s.length;i++){
- var data = s[i].data;
- dd = new Object();
- if(data[grid.necessaryField] != null && data[grid.necessaryField] != ""){
- Ext.each(grid.columns, function(c){
- dd[c.dataIndex] = s[i].data[c.dataIndex];
- });
- jsonGridData.push(Ext.JSON.encode(dd));
- }
- }
- var param=jsonGridData;
- if(param == null || param == ''){
- showError($I18N.common.grid.emptyDetail);
- }else {
- var r = Ext.getCmp('dbform').getForm().getValues();
- var params = new Object();
- params.formStore = unescape(Ext.JSON.encode(r).replace(/\\/g,"%"));
- params.gridStore = unescape(param.toString().replace(/\\/g,"%"));
- Ext.Ajax.request({
- url : basePath + 'common/saveDbfindSetUI.action',
- params : params,
- method : 'post',
- callback : function(options,success,response){
- var res=new Ext.decode(response.responseText);
- if(res.exceptionInfo != null){
- showError(res.exceptionInfo);return;
- }
- if(res.success){
- Ext.Msg.alert('提示','保存成功!');
- var jsondata=me.getDbFindSetUI(caller,field);
- Ext.getCmp('dbform').getForm().setValues(jsondata.formdata);
- Ext.getCmp('dbgrid').getStore().loadData(jsondata.griddata);
- }
- }
- });
- }
- },
- saveDBFindSetGrid:function(btn,pagecaller,dgfield){
- var bar=btn.ownerCt,grid=btn.ownerCt.ownerCt;
- var caller=bar.items.items[6].value;
- var field=bar.items.items[8].value;
- var me=this;
- var jsonGridData = new Array();
- grid.necessaryField='ds_gridfield';
- var dd;
- var s = grid.getStore().data.items;
- for(var i=0;i<s.length;i++){
- var data = s[i].data;
- dd = new Object();
- if(s[i].dirty&&data[grid.necessaryField] != null && data[grid.necessaryField] != ""){
- Ext.each(grid.columns, function(c){
- dd[c.dataIndex] = s[i].data[c.dataIndex];
- });
- jsonGridData.push(Ext.JSON.encode(dd));
- }
- }
- if(jsonGridData == null || jsonGridData == '')
- showError($I18N.common.grid.emptyDetail);
- if(caller&&caller!=""&&field&&field!=""){
- Ext.Ajax.request({
- url : basePath +'common/saveDbFindSetGrid.action',
- params: {
- caller:caller,
- field:field,
- dgfield:dgfield,
- gridStore:jsonGridData
- },
- method : 'post',
- callback : function(options,success,response){
- var re = new Ext.decode(response.responseText);
- if(re.success){
- var json=me.getDBGridFields(pagecaller,dgfield);
- grid.getStore().loadData(json.data.dbfindsetgrid);
- Ext.Msg.alert('提示','保存成功!');
- }
- else if(re.exceptionInfo == null){
- showError(res.exceptionInfo);return ;
- }
- }
- });
- }
- },
- getDBGridFields:function(caller,field){
- var localJson=null;
- Ext.Ajax.request({
- url : basePath +'common/getDbFindSetGridFields.action',
- params: {
- caller:caller,
- field:field
- },
- async: false,
- method : 'post',
- callback : function(options,success,response){
- var re = new Ext.decode(response.responseText);
- if(re.exceptionInfo == null){
- localJson=re;
- }
- }
- });
- return localJson;
- },
- getDbFindSetUI:function(caller,field){
- var localJson=null;
- Ext.Ajax.request({
- url : basePath +'common/getDbFindSetUI.action',
- params: {
- caller:caller,
- field:field
- },
- async: false,
- method : 'post',
- callback : function(options,success,response){
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo != null){
- showError(res.exceptionInfo);
-
- return;
- }
- if(res.success){
- localJson=res;
- }
- }
- });
- return localJson;
- }
- });
|