|
|
@@ -190,9 +190,7 @@ Ext.define('saas.view.core.dbfind.DbfindTrigger', {
|
|
|
listeners: {
|
|
|
blur:function(f,e){
|
|
|
var me = f;
|
|
|
- var count = f.store.getCount();
|
|
|
- var searchCount = false;//校验数据库是否有该字段
|
|
|
- var dbfinds = me.dbfinds;
|
|
|
+ var dbfinds = me.dbfinds,data;
|
|
|
if(f.value&&f.value!=''){
|
|
|
//添加默认条件
|
|
|
var searchField = null;
|
|
|
@@ -211,7 +209,7 @@ Ext.define('saas.view.core.dbfind.DbfindTrigger', {
|
|
|
}
|
|
|
dbCondition.push({
|
|
|
type: 'condition',
|
|
|
- value: searchField + "='"+me.value+"'"
|
|
|
+ value: searchField + " like '%"+me.value+"%'"
|
|
|
});
|
|
|
Ext.Ajax.request({
|
|
|
url: me.dataUrl,
|
|
|
@@ -228,14 +226,11 @@ Ext.define('saas.view.core.dbfind.DbfindTrigger', {
|
|
|
success: function(response, opts) {
|
|
|
data = Ext.decode(response.responseText);
|
|
|
data = data.data?data.data.list:[];
|
|
|
- if(data.length>0){
|
|
|
- searchCount = true
|
|
|
- }
|
|
|
},
|
|
|
failure: function(response, opts) {}
|
|
|
});
|
|
|
}
|
|
|
- if(!f.value||f.value==''||!searchCount){
|
|
|
+ if(!f.value||f.value==''||data.length>1||data.length==0){
|
|
|
if(dbfinds&&dbfinds.length>0){
|
|
|
if(me.belong=='grid'){
|
|
|
for (let index = 0; index < dbfinds.length; index++) {
|
|
|
@@ -269,6 +264,37 @@ Ext.define('saas.view.core.dbfind.DbfindTrigger', {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ }else if(data.length==1){
|
|
|
+ var dbfinds = me.dbfinds;
|
|
|
+ if(dbfinds&&dbfinds.length>0){
|
|
|
+ if(me.belong=='grid'){
|
|
|
+ for (let index = 0; index < dbfinds.length; index++) {
|
|
|
+ var item = dbfinds[index];
|
|
|
+ var rec = me.column.ownerCt.ownerCt.selModel.getLastSelected();
|
|
|
+ var nowRec = me.column.ownerCt.ownerCt.store.getData().getByKey(rec.id);
|
|
|
+ nowRec.set(item.to,data[0][item.from]);
|
|
|
+ if(me.name==item.to){
|
|
|
+ me.column.getEditor().setValue(data[0][item.from]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if(me.belong=='form'){
|
|
|
+ for (let index = 0; index < dbfinds.length; index++) {
|
|
|
+ var item = dbfinds[index];
|
|
|
+ var field = me.ownerCt.down('[name='+item.to+']');
|
|
|
+ if(field){
|
|
|
+ var val = data[0][item.from];
|
|
|
+ if(field.xtype=='dbfindtrigger'){
|
|
|
+ field.setRawValue(val);
|
|
|
+ field.setValue(val);
|
|
|
+ field.value = val;
|
|
|
+ field.lastTriggerValue=val;
|
|
|
+ }else{
|
|
|
+ field.setValue(val);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
select:function(combo,record,eOpts){
|