|
|
@@ -12,11 +12,35 @@ Ext.define('saas.view.sys.maxnumbers.DataList', {
|
|
|
deleteUrl:'http://192.168.253.31:8920/number/delete/',
|
|
|
|
|
|
tbar: [{
|
|
|
+ width: 150,
|
|
|
+ name: 'mn_caller',
|
|
|
+ xtype: 'textfield',
|
|
|
+ emptyText : '单据Caller'
|
|
|
+ },{
|
|
|
+ width: 150,
|
|
|
+ name: 'mn_leadcode',
|
|
|
+ xtype: 'textfield',
|
|
|
+ emptyText : '单据前缀'
|
|
|
+ },{
|
|
|
cls:'x-formpanel-btn-orange',
|
|
|
xtype:'button',
|
|
|
text:'查询',
|
|
|
listeners: {
|
|
|
- click: 'onQuery'
|
|
|
+ click:function(b){
|
|
|
+ var grid = b.ownerCt.ownerCt;
|
|
|
+ var tbar = b.ownerCt;
|
|
|
+ grid.condition = '';
|
|
|
+ var items = [];
|
|
|
+ var fields = tbar.items.items.map(f => f.name);
|
|
|
+ Ext.each(fields, function(f, index){
|
|
|
+ var field = tbar.down('[name='+f+']');
|
|
|
+ if(field){
|
|
|
+ items.push(field);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ grid.condition = grid.getCondition(items);
|
|
|
+ grid.store.loadPage(1);
|
|
|
+ }
|
|
|
}
|
|
|
},'->',{
|
|
|
cls:'x-formpanel-btn-blue',
|
|
|
@@ -67,7 +91,7 @@ Ext.define('saas.view.sys.maxnumbers.DataList', {
|
|
|
me.store = Ext.create('Ext.data.Store',{
|
|
|
fields:fields,
|
|
|
autoLoad: true,
|
|
|
- pageSize: 10,
|
|
|
+ pageSize: 11,
|
|
|
data: [],
|
|
|
proxy: {
|
|
|
timeout:8000,
|
|
|
@@ -172,19 +196,6 @@ Ext.define('saas.view.sys.maxnumbers.DataList', {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- getCondition: function(f,conditionExpression){
|
|
|
- var condition = '';
|
|
|
- if((f.xtype == 'checkbox' || f.xtype == 'radio')&&f.logic){
|
|
|
-
|
|
|
- }else if(f.xtype=='textfield'&&f.value!=''){
|
|
|
- condition=conditionExpression.replace(new RegExp("\\{0}","g"), f.value);
|
|
|
- }
|
|
|
- if(condition.length>0){
|
|
|
- condition+= ' AND ';
|
|
|
- }
|
|
|
- return condition;
|
|
|
- },
|
|
|
-
|
|
|
insertFirstColumn:function(columns){
|
|
|
var me=this;
|
|
|
if(columns.length>0 && columns[0].xtype!='actioncolumn'){
|
|
|
@@ -233,6 +244,109 @@ Ext.define('saas.view.sys.maxnumbers.DataList', {
|
|
|
return false;
|
|
|
}
|
|
|
return data;
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获得过滤条件
|
|
|
+ */
|
|
|
+ getCondition: function(items) {
|
|
|
+ var me = this,
|
|
|
+ conditions = [];
|
|
|
+
|
|
|
+ for(var i = 0; i < items.length; i++) {
|
|
|
+ var item = items[i];
|
|
|
+ var field = item.name,
|
|
|
+ func = item.getCondition,
|
|
|
+ value = item.value,
|
|
|
+ condition;
|
|
|
+
|
|
|
+ if(typeof func == 'function') {
|
|
|
+ condition = {
|
|
|
+ type: 'condition',
|
|
|
+ value: func(value)
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ var xtype = item.xtype || 'textfield',
|
|
|
+ type = item.fieldType || me.getDefaultFieldType(xtype),
|
|
|
+ operation = item.operation || me.getDefaultFieldOperation(xtype),
|
|
|
+ conditionValue = me.getConditionValue(xtype, value);
|
|
|
+
|
|
|
+ if(!conditionValue) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ condition = {
|
|
|
+ type: type,
|
|
|
+ field: field,
|
|
|
+ operation: operation,
|
|
|
+ value: conditionValue
|
|
|
+ }
|
|
|
+ }
|
|
|
+ conditions.push(condition);
|
|
|
+ };
|
|
|
+ return conditions;
|
|
|
+ },
|
|
|
+
|
|
|
+ getDefaultFieldType: function(xtype) {
|
|
|
+ var type;
|
|
|
+
|
|
|
+ if(Ext.Array.contains(['numberfield'], xtype)) {
|
|
|
+ type = 'number';
|
|
|
+ }else if(Ext.Array.contains(['datefield', 'condatefield'], xtype)) {
|
|
|
+ type = 'date';
|
|
|
+ }else if(Ext.Array.contains(['combobox', 'multicombo', 'combo', 'radiofield', 'radio'], xtype)) {
|
|
|
+ type = 'enum';
|
|
|
+ }else {
|
|
|
+ type = 'string';
|
|
|
+ }
|
|
|
+
|
|
|
+ return type;
|
|
|
+ },
|
|
|
+
|
|
|
+ getDefaultFieldOperation: function(xtype) {
|
|
|
+ var operation;
|
|
|
+
|
|
|
+ if(Ext.Array.contains(['numberfield'], xtype)) {
|
|
|
+ operation = '=';
|
|
|
+ }else if(Ext.Array.contains(['datefield'], xtype)) {
|
|
|
+ operation = '=';
|
|
|
+ }else if(Ext.Array.contains(['condatefield'], xtype)) {
|
|
|
+ operation = 'between';
|
|
|
+ }else if(Ext.Array.contains(['combobox', 'multicombo', 'combo'], xtype)) {
|
|
|
+ operation = 'in';
|
|
|
+ }else {
|
|
|
+ operation = 'like';
|
|
|
+ }
|
|
|
+
|
|
|
+ return operation;
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理部分字段值
|
|
|
+ */
|
|
|
+ getConditionValue: function(xtype, value) {
|
|
|
+ var conditionValue;
|
|
|
+ if(xtype == 'datefield') {
|
|
|
+ conditionValue = Ext.Date.format(new Date(from), 'Y-m-d h:i:s');
|
|
|
+ }else if(xtype == 'condatefield') {
|
|
|
+ var from = value.from,
|
|
|
+ to = value.to;
|
|
|
+
|
|
|
+ conditionValue = Ext.Date.format(new Date(from), 'Y-m-d h:i:s') + ',' + Ext.Date.format(new Date(to), 'Y-m-d h:i:s');
|
|
|
+ }else if(xtype == 'combobox' || xtype == 'combo') {
|
|
|
+ conditionValue = '\'' + value + '\'';
|
|
|
+ }else if(xtype == 'multicombo') {
|
|
|
+ conditionValue = value.map(function(v) {
|
|
|
+ return '\'' + v.value + '\'';
|
|
|
+ }).join(',');
|
|
|
+ }else {
|
|
|
+ conditionValue = value;
|
|
|
+ }
|
|
|
+
|
|
|
+ return conditionValue;
|
|
|
+ },
|
|
|
+
|
|
|
+ refresh:function(){
|
|
|
+ //debugger
|
|
|
}
|
|
|
|
|
|
})
|