|
@@ -218,24 +218,28 @@ Ext.define('saas.view.core.report.ReportPanel', {
|
|
|
type: 'json',
|
|
type: 'json',
|
|
|
// rootProperty: 'data.list',
|
|
// rootProperty: 'data.list',
|
|
|
rootProperty: function(data) {
|
|
rootProperty: function(data) {
|
|
|
- var grid = me.items.items[1],
|
|
|
|
|
- columns = grid.columns,
|
|
|
|
|
- summaryData = data.data.calculate || [];
|
|
|
|
|
-
|
|
|
|
|
- Ext.Array.each(columns, function(c) {
|
|
|
|
|
- var type = c.summaryType,
|
|
|
|
|
- name = c.dataIndex;
|
|
|
|
|
-
|
|
|
|
|
- var d = Ext.Array.findBy(summaryData, function(s) {
|
|
|
|
|
- return s.hasOwnProperty(name);
|
|
|
|
|
- })
|
|
|
|
|
- if(type && d) {
|
|
|
|
|
- c.summaryValue = Ext.util.Format.number(d[name], c.format || '0.00');
|
|
|
|
|
- }else {
|
|
|
|
|
- c.summaryValue = 0;
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- return data.data.list.list;
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ var grid = me.items.items[1],
|
|
|
|
|
+ columns = grid.columns,
|
|
|
|
|
+ summaryData = data.data.calculate || [];
|
|
|
|
|
+
|
|
|
|
|
+ Ext.Array.each(columns, function(c) {
|
|
|
|
|
+ var type = c.summaryType,
|
|
|
|
|
+ name = c.dataIndex;
|
|
|
|
|
+
|
|
|
|
|
+ var d = Ext.Array.findBy(summaryData, function(s) {
|
|
|
|
|
+ return s.hasOwnProperty(name);
|
|
|
|
|
+ })
|
|
|
|
|
+ if(type && d) {
|
|
|
|
|
+ c.summaryValue = Ext.util.Format.number(d[name], c.format || '0.00');
|
|
|
|
|
+ }else {
|
|
|
|
|
+ c.summaryValue = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ return data.data.list.list;
|
|
|
|
|
+ }catch(e) {
|
|
|
|
|
+ saas.util.BaseUtil.showErrorToast(e.message);
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
totalProperty: 'data.list.total',
|
|
totalProperty: 'data.list.total',
|
|
|
},
|
|
},
|
|
@@ -413,7 +417,8 @@ Ext.define('saas.view.core.report.ReportPanel', {
|
|
|
|
|
|
|
|
getConditions: function() {
|
|
getConditions: function() {
|
|
|
var me = this,
|
|
var me = this,
|
|
|
- formItems = me.searchItems,
|
|
|
|
|
|
|
+ form = me.down('form'),
|
|
|
|
|
+ formItems = form.items.items,
|
|
|
viewModel = me.getViewModel(),
|
|
viewModel = me.getViewModel(),
|
|
|
viewModelData = viewModel.getData(),
|
|
viewModelData = viewModel.getData(),
|
|
|
bindItems = viewModelData['form'],
|
|
bindItems = viewModelData['form'],
|
|
@@ -435,10 +440,10 @@ Ext.define('saas.view.core.report.ReportPanel', {
|
|
|
value: func(value)
|
|
value: func(value)
|
|
|
}
|
|
}
|
|
|
}else {
|
|
}else {
|
|
|
- var xtype = item.xtype || 'textfield',
|
|
|
|
|
- type = item.fieldType || me.getDefaultFieldType(xtype),
|
|
|
|
|
- operation = item.operation || me.getDefaultFieldOperation(xtype),
|
|
|
|
|
- conditionValue = me.getConditionValue(xtype, value);
|
|
|
|
|
|
|
+ // var xtype = item.xtype || 'textfield',
|
|
|
|
|
+ type = item.fieldType || me.getDefaultFieldType(item),
|
|
|
|
|
+ operation = item.operation || me.getDefaultFieldOperation(item),
|
|
|
|
|
+ conditionValue = me.getConditionValue(item, value);
|
|
|
|
|
|
|
|
if(!conditionValue) {
|
|
if(!conditionValue) {
|
|
|
continue;
|
|
continue;
|
|
@@ -456,14 +461,16 @@ Ext.define('saas.view.core.report.ReportPanel', {
|
|
|
return conditions;
|
|
return conditions;
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- getDefaultFieldType: function(xtype) {
|
|
|
|
|
- var type;
|
|
|
|
|
|
|
+ getDefaultFieldType: function(field) {
|
|
|
|
|
+ var me = this,
|
|
|
|
|
+ xtypes = field.getXTypes().split('/'),
|
|
|
|
|
+ type;
|
|
|
|
|
|
|
|
- if(Ext.Array.contains(['numberfield'], xtype)) {
|
|
|
|
|
|
|
+ if(me.isContainsAny(xtypes, ['numberfield'])) {
|
|
|
type = 'number';
|
|
type = 'number';
|
|
|
- }else if(Ext.Array.contains(['datefield', 'condatefield'], xtype)) {
|
|
|
|
|
|
|
+ }else if(me.isContainsAny(xtypes, ['datefield', 'condatefield'])) {
|
|
|
type = 'date';
|
|
type = 'date';
|
|
|
- }else if(Ext.Array.contains(['combobox', 'multicombo', 'combo', 'radiofield', 'radio'], xtype)) {
|
|
|
|
|
|
|
+ }else if(me.isContainsAny(xtypes, ['combobox', 'multicombo', 'combo', 'radiofield', 'radio'])) {
|
|
|
type = 'enum';
|
|
type = 'enum';
|
|
|
}else {
|
|
}else {
|
|
|
type = 'string';
|
|
type = 'string';
|
|
@@ -472,16 +479,29 @@ Ext.define('saas.view.core.report.ReportPanel', {
|
|
|
return type;
|
|
return type;
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- getDefaultFieldOperation: function(xtype) {
|
|
|
|
|
- var operation;
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 只要arr1和arr2中存在相同项即返回真
|
|
|
|
|
+ */
|
|
|
|
|
+ isContainsAny: function(arr1, arr2) {
|
|
|
|
|
+ for(var i = 0; i < arr2.length; i++) {
|
|
|
|
|
+ var a2 = arr2[i];
|
|
|
|
|
+ if(!!arr1.find(function(a1) {return a1==a2})) {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
- if(Ext.Array.contains(['numberfield'], xtype)) {
|
|
|
|
|
- operation = '=';
|
|
|
|
|
- }else if(Ext.Array.contains(['datefield'], xtype)) {
|
|
|
|
|
|
|
+ getDefaultFieldOperation: function(field) {
|
|
|
|
|
+ var me = this,
|
|
|
|
|
+ xtypes = field.getXTypes().split('/'),
|
|
|
|
|
+ operation;
|
|
|
|
|
+
|
|
|
|
|
+ if(me.isContainsAny(xtypes, ['numberfield', 'datefield', 'dbfindtrigger'])) {
|
|
|
operation = '=';
|
|
operation = '=';
|
|
|
- }else if(Ext.Array.contains(['condatefield'], xtype)) {
|
|
|
|
|
|
|
+ }else if(me.isContainsAny(xtypes, ['condatefield'])) {
|
|
|
operation = 'between';
|
|
operation = 'between';
|
|
|
- }else if(Ext.Array.contains(['combobox', 'multicombo', 'combo'], xtype)) {
|
|
|
|
|
|
|
+ }else if(me.isContainsAny(xtypes, ['multidbfindtrigger', 'combobox', 'multicombo', 'combo'])) {
|
|
|
operation = 'in';
|
|
operation = 'in';
|
|
|
}else {
|
|
}else {
|
|
|
operation = 'like';
|
|
operation = 'like';
|
|
@@ -493,21 +513,23 @@ Ext.define('saas.view.core.report.ReportPanel', {
|
|
|
/**
|
|
/**
|
|
|
* 处理部分字段值
|
|
* 处理部分字段值
|
|
|
*/
|
|
*/
|
|
|
- getConditionValue: function(xtype, value) {
|
|
|
|
|
- var conditionValue;
|
|
|
|
|
- if(xtype == 'datefield') {
|
|
|
|
|
|
|
+ getConditionValue: function(field, value) {
|
|
|
|
|
+ var me = this,
|
|
|
|
|
+ xtypes = field.getXTypes().split('/'),
|
|
|
|
|
+ conditionValue;
|
|
|
|
|
+ if(me.isContainsAny(xtypes, ['datefield'])) {
|
|
|
conditionValue = Ext.Date.format(new Date(from), 'Y-m-d H:i:s');
|
|
conditionValue = Ext.Date.format(new Date(from), 'Y-m-d H:i:s');
|
|
|
- }else if(xtype == 'condatefield') {
|
|
|
|
|
|
|
+ }else if(me.isContainsAny(xtypes, ['condatefield'])) {
|
|
|
var from = value.from,
|
|
var from = value.from,
|
|
|
to = value.to;
|
|
to = value.to;
|
|
|
|
|
|
|
|
conditionValue = Ext.Date.format(new Date(from), 'Y-m-d 00:00:00') + ',' + Ext.Date.format(new Date(to), 'Y-m-d 23:59:59');
|
|
conditionValue = Ext.Date.format(new Date(from), 'Y-m-d 00:00:00') + ',' + Ext.Date.format(new Date(to), 'Y-m-d 23:59:59');
|
|
|
- }else if(xtype == 'combobox' || xtype == 'combo') {
|
|
|
|
|
|
|
+ }else if(me.isContainsAny(xtypes, ['combobox', 'combo'])) {
|
|
|
conditionValue = '\'' + value + '\'';
|
|
conditionValue = '\'' + value + '\'';
|
|
|
- }else if(xtype == 'multicombo') {
|
|
|
|
|
- conditionValue = value.map(function(v) {
|
|
|
|
|
|
|
+ }else if(me.isContainsAny(xtypes, ['multicombo'])) {
|
|
|
|
|
+ conditionValue = value.map ? value.map(function(v) {
|
|
|
return '\'' + v.value + '\'';
|
|
return '\'' + v.value + '\'';
|
|
|
- }).join(',');
|
|
|
|
|
|
|
+ }).join(',') : '';
|
|
|
}else {
|
|
}else {
|
|
|
conditionValue = value;
|
|
conditionValue = value;
|
|
|
}
|
|
}
|