|
|
@@ -111,7 +111,7 @@ Ext.define('saas.view.core.dbfind.MultiDbfindTrigger', {
|
|
|
method: 'GET',
|
|
|
success: function(response, opts) {
|
|
|
data = Ext.decode(response.responseText);
|
|
|
- data = data.data.list;
|
|
|
+ data = data.data?data.data.list:[];
|
|
|
if(data!=null && data.length>0 && me.store && field.length>0){
|
|
|
me.store.loadData(data,false);
|
|
|
me.expand();
|
|
|
@@ -129,6 +129,7 @@ Ext.define('saas.view.core.dbfind.MultiDbfindTrigger', {
|
|
|
}
|
|
|
},
|
|
|
onTriggerClick:function(f){
|
|
|
+ f.blur(f);
|
|
|
//判断dbfindtrigger归属
|
|
|
f.judge(f);
|
|
|
var panel = f.up('core-tab-panel'),panelEl;
|
|
|
@@ -170,46 +171,60 @@ Ext.define('saas.view.core.dbfind.MultiDbfindTrigger', {
|
|
|
blur:function(f,e){
|
|
|
var me = f;
|
|
|
var count = f.store.getCount();
|
|
|
+ var searchCount = false;//校验数据库是否有该字段
|
|
|
var dbfinds = me.dbfinds;
|
|
|
- // if(count==1){
|
|
|
- // record = f.store.data.items[0];
|
|
|
- // 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,record.get(item.from));
|
|
|
- // if(me.name==item.to){
|
|
|
- // me.column.getEditor().setValue(record.get(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 = record.get(item.from);
|
|
|
- // if(field.xtype=='dbfindtrigger'){
|
|
|
- // field.setRawValue(val);
|
|
|
- // field.value = val;
|
|
|
- // field.lastTriggerValue=val;
|
|
|
- // }else{
|
|
|
- // field.setValue(val);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }else
|
|
|
- if(!f.value||f.value==''){
|
|
|
+ if(count>0){
|
|
|
+ //添加默认条件
|
|
|
+ var searchField = null;
|
|
|
+ var dbCondition = [];
|
|
|
+ if(me.defaultCondition) {
|
|
|
+ dbCondition.push({
|
|
|
+ type: 'condition',
|
|
|
+ value: me.defaultCondition
|
|
|
+ });
|
|
|
+ }
|
|
|
+ for (let index = 0; index < dbfinds.length; index++) {
|
|
|
+ var item = dbfinds[index].to;
|
|
|
+ if(item==me.name){
|
|
|
+ searchField = dbfinds[index].from;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dbCondition.push({
|
|
|
+ type: 'condition',
|
|
|
+ value: searchField + "='"+me.value+"'"
|
|
|
+ });
|
|
|
+ Ext.Ajax.request({
|
|
|
+ url: me.dataUrl,
|
|
|
+ async:false,
|
|
|
+ params: {
|
|
|
+ number: 1,
|
|
|
+ size: 1,
|
|
|
+ condition:JSON.stringify(dbCondition),
|
|
|
+ page: 1,
|
|
|
+ start: 0,
|
|
|
+ limit: 10
|
|
|
+ },
|
|
|
+ method: 'GET',
|
|
|
+ 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==''||count==0||!searchCount){
|
|
|
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,'');
|
|
|
+ if(nowRec.get(item.to)&&nowRec.get(item.to)!=""){
|
|
|
+ nowRec.set(item.to,'');
|
|
|
+ }
|
|
|
if(me.name==item.to){
|
|
|
me.column.getEditor().setValue('');
|
|
|
}
|