|
@@ -20,80 +20,127 @@ Ext.define('saas.view.core.query.QueryFormPanel', {
|
|
|
labelWidth: 90,
|
|
labelWidth: 90,
|
|
|
columnWidth: 0.25,
|
|
columnWidth: 0.25,
|
|
|
blankText: '该字段不能为空',
|
|
blankText: '该字段不能为空',
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
- dockedItems: [{
|
|
|
|
|
- width:140,
|
|
|
|
|
- height: 70,
|
|
|
|
|
- xtype: 'toolbar',
|
|
|
|
|
- dock: 'right',
|
|
|
|
|
- items: [{
|
|
|
|
|
- margin:'8 0 0 0',
|
|
|
|
|
- xtype: 'buttongroup',
|
|
|
|
|
- cls:'x-query-buttongroup',
|
|
|
|
|
- items:[{
|
|
|
|
|
- height:32,
|
|
|
|
|
- width:70,
|
|
|
|
|
- style:'min-width: 0px;min-height: 0px;',
|
|
|
|
|
- xtype: 'button',
|
|
|
|
|
- name:'query',
|
|
|
|
|
- text: '查询',
|
|
|
|
|
- handler: 'onQuery',
|
|
|
|
|
- },{
|
|
|
|
|
- style:'min-width: 0px;min-height: 0px;border-color: #fff;background-color: #fff;padding: 0px;margin-top: -1px;margin-left: -2px;',
|
|
|
|
|
- xtype: 'button',
|
|
|
|
|
- iconCls:'x-btn-show',
|
|
|
|
|
- handler: 'showMore',
|
|
|
|
|
- name:'showMore',
|
|
|
|
|
- tooltip:'更多',
|
|
|
|
|
- listeners:{
|
|
|
|
|
- afterrender:function(b){
|
|
|
|
|
- var count = window.innerHeight - 110>=800?2:1;
|
|
|
|
|
- var columnWidthCount = 0;
|
|
|
|
|
- var items = b.ownerCt.ownerCt.ownerCt.items.items;
|
|
|
|
|
- Ext.each(items, function(item, index){
|
|
|
|
|
- if(item.xtype != 'hidden'){
|
|
|
|
|
- columnWidthCount+= item.columnWidth
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- columnWidthCount = Math.ceil(columnWidthCount);
|
|
|
|
|
- if(columnWidthCount<=count){
|
|
|
|
|
- b.hide();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- },{
|
|
|
|
|
- name:'hideMore',
|
|
|
|
|
- hidden:true,
|
|
|
|
|
- tooltip:'隐藏',
|
|
|
|
|
- style:'min-width: 0px;min-height: 0px;border-color: #fff;background-color: #fff;padding: 0px;margin-top: -1px;margin-left: -2px;',
|
|
|
|
|
- xtype: 'button',
|
|
|
|
|
- iconCls:'x-btn-hide',
|
|
|
|
|
- handler: 'hideMore'
|
|
|
|
|
- }]
|
|
|
|
|
- },'->']
|
|
|
|
|
- }],
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ toggleConfig: {
|
|
|
|
|
+ showMoreIconCls: 'x-btn-show',
|
|
|
|
|
+ shwoMoreTooltip: '更多',
|
|
|
|
|
+ hideMoreIconCls: 'x-btn-hide',
|
|
|
|
|
+ hideMoreTooltip: '隐藏'
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ initComponent: function() {
|
|
|
|
|
+ var me = this,
|
|
|
|
|
+ config = me.toggleConfig;
|
|
|
|
|
+
|
|
|
|
|
+ Ext.apply(me, {
|
|
|
|
|
+ dockedItems: [{
|
|
|
|
|
+ width:140,
|
|
|
|
|
+ height: 70,
|
|
|
|
|
+ xtype: 'toolbar',
|
|
|
|
|
+ dock: 'right',
|
|
|
|
|
+ items: [{
|
|
|
|
|
+ margin:'8 0 0 0',
|
|
|
|
|
+ xtype: 'buttongroup',
|
|
|
|
|
+ cls:'x-query-buttongroup',
|
|
|
|
|
+ items:[{
|
|
|
|
|
+ height:32,
|
|
|
|
|
+ width:70,
|
|
|
|
|
+ style:'min-width: 0px;min-height: 0px;',
|
|
|
|
|
+ xtype: 'button',
|
|
|
|
|
+ name:'query',
|
|
|
|
|
+ text: '查询',
|
|
|
|
|
+ handler: 'onQuery',
|
|
|
|
|
+ },{
|
|
|
|
|
+ style:'min-width: 0px;min-height: 0px;border-color: #fff;background-color: #fff;padding: 0px;margin-top: -1px;margin-left: -2px;',
|
|
|
|
|
+ xtype: 'button',
|
|
|
|
|
+ handler: function(b) {
|
|
|
|
|
+ var form = b.up('core-query-queryformpanel');
|
|
|
|
|
+ form.toggleShowMore();
|
|
|
|
|
+ },
|
|
|
|
|
+ name:'toggle',
|
|
|
|
|
+ iconCls: config.hideMoreIconCls,
|
|
|
|
|
+ tooltip: config.hideMoreTooltip,
|
|
|
|
|
+ }]
|
|
|
|
|
+ },'->']
|
|
|
|
|
+ }],
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ me.callParent(arguments);
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
listeners: {
|
|
listeners: {
|
|
|
- boxReady:function(form){
|
|
|
|
|
|
|
+ boxready:function(form){
|
|
|
if(window.innerHeight - 110 >= 800){
|
|
if(window.innerHeight - 110 >= 800){
|
|
|
- form.setHeight(96);
|
|
|
|
|
|
|
+ form.setFormItemRows(null, true);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ form.setFormItemRows(1, true);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
beforerender: function(form) {
|
|
beforerender: function(form) {
|
|
|
- var fiels = form.getForm().getFields();
|
|
|
|
|
- fiels.each(function(f) {
|
|
|
|
|
- f.enableKeyEvents = true;
|
|
|
|
|
- f.on && f.on({
|
|
|
|
|
- keydown: {
|
|
|
|
|
- fn: function(th, e, eOpts) {
|
|
|
|
|
- if(e.keyCode == 13) {
|
|
|
|
|
- form.up('core-query-querypanel').getController().onQuery()
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ form.addItemEvenListeners();
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ addItemEvenListeners: function() {
|
|
|
|
|
+ var me = this,
|
|
|
|
|
+ queryPanel = me.up('core-query-querypanel'),
|
|
|
|
|
+ fiels = me.getForm().getFields();
|
|
|
|
|
+
|
|
|
|
|
+ fiels.each(function(f) {
|
|
|
|
|
+ f.enableKeyEvents = true;
|
|
|
|
|
+ f.on && f.on({
|
|
|
|
|
+ keydown: {
|
|
|
|
|
+ fn: function(th, e, eOpts) {
|
|
|
|
|
+ if(e.keyCode == 13) {
|
|
|
|
|
+ queryPanel.getController().onQuery()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- });
|
|
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ toggleShowMore: function(unanimate) {
|
|
|
|
|
+ var me = this,
|
|
|
|
|
+ showMore = typeof me.showMore != undefined ? !me.showMore : true,
|
|
|
|
|
+ rowItems = me.rowItems,
|
|
|
|
|
+ allRows = rowItems.length,
|
|
|
|
|
+ rows = showMore ? allRows : 1;
|
|
|
|
|
+
|
|
|
|
|
+ me.setFormItemRows(rows, unanimate);
|
|
|
|
|
+
|
|
|
|
|
+ var b = me.dockedItems.items[0].down('[name=query]');
|
|
|
|
|
+ b.removeFocusCls();
|
|
|
|
|
+ me.updateLayout();
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ setFormItemRows: function(rows, unanimate) {
|
|
|
|
|
+ var me = this,
|
|
|
|
|
+ rowItems = me.rowItems,
|
|
|
|
|
+ allRows = rowItems.length,
|
|
|
|
|
+ rows = rows ? rows : allRows,
|
|
|
|
|
+ showMore = rows == allRows;
|
|
|
|
|
+
|
|
|
|
|
+ var n_height = 14 + rows * ( 32 + 10 );
|
|
|
|
|
+
|
|
|
|
|
+ unanimate ? me.setHeight(n_height) : me.animate({dynamic: true, duration: 500, to: {height: n_height + 'px'}});
|
|
|
|
|
+ me.setToggleBtn(showMore);
|
|
|
|
|
+ me.showMore = showMore;
|
|
|
|
|
+ return rows;
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ setToggleBtn: function(showMore) {
|
|
|
|
|
+ var me = this,
|
|
|
|
|
+ config = me.toggleConfig,
|
|
|
|
|
+ toggleBtn = me.dockedItems.items[0].down('[name=toggle]');
|
|
|
|
|
+
|
|
|
|
|
+ if(showMore) {
|
|
|
|
|
+ toggleBtn.setIconCls(config.hideMoreIconCls);
|
|
|
|
|
+ toggleBtn.setTooltip(config.hideMoreTooltip);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ toggleBtn.setIconCls(config.showMoreIconCls);
|
|
|
|
|
+ toggleBtn.setTooltip(config.shwoMoreTooltip);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|