MultiDbfindPaging.js 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. Ext.define('uas.view.trigger.MultiDbfindPaging', {
  2. extend: 'Ext.toolbar.Paging',
  3. xtype: 'multidbfindPaging',
  4. cls:'x-dataListPaging',
  5. height: 36,
  6. dock: 'bottom',
  7. displayInfo: false,
  8. emptyMsg: "无数据",
  9. items:[{
  10. xtype:'checkbox',
  11. cls:'x-paging-checkbox',
  12. name:'showSelectRecord',
  13. boxLabel:'已选中数据',
  14. handler:function(b){
  15. var grid = b.up('multidbfindtriggerpanel');
  16. if(b.checked){
  17. grid.store.loadData(grid.selectRecordArr);
  18. grid.selModel.noChange = true;
  19. grid.selModel.deselectAll();
  20. grid.selModel.select(grid.selectRecordArr);
  21. grid.selModel.noChange = false;
  22. //刷新展示数据
  23. var dataCount = grid.selectRecordArr.length,msg;
  24. var display = b.ownerCt.child('#displayItem');
  25. if (dataCount === 0) {
  26. msg = b.ownerCt.emptyMsg;
  27. } else {
  28. msg = Ext.String.format(
  29. b.ownerCt.displayMsg,
  30. 1,
  31. dataCount,
  32. dataCount
  33. );
  34. }
  35. display.setText(msg);
  36. b.ownerCt.child('#inputItem').setValue(1);
  37. b.ownerCt.child("#afterTextItem").setText('页,共'+dataCount+'页');
  38. }else{
  39. grid.selModel.noChange = true;
  40. grid.selModel.deselectAll();
  41. grid.selModel.select(grid.selectRecordArr);
  42. grid.selModel.noChange = false;
  43. grid.store.loadPage(1);
  44. }
  45. }
  46. },'->',{
  47. itemId: 'pageSizeItem',
  48. cls:'x-dl-paging-combo',
  49. labelWidth:60,
  50. width:124,
  51. value:10,
  52. labelAlgin:'right',
  53. xtype:'combo',
  54. editable:false,
  55. fieldLabel:'每页显示',
  56. store:[[
  57. '10',10
  58. ],[
  59. '20',20
  60. ],[
  61. '50',50
  62. ],[
  63. '100',100
  64. ],[
  65. '200',200
  66. ],[
  67. '500',500
  68. ],[
  69. '1000',1000
  70. ]],
  71. listeners:{
  72. change:function(me,newValue,oldValue){
  73. const paging = me.ownerCt;
  74. const grid = paging.ownerCt;
  75. const { store } = grid;
  76. const pageCountItem = paging.down('#pageCountItem');
  77. const dataCount = paging.down('#dataCountItem');
  78. if(newValue!==oldValue){
  79. store.setPageSize(newValue);
  80. pageCountItem.update(Ext.String.format(paging.afterPageText,'*'));
  81. dataCount.setValue("行/共*行");
  82. store.loadPage(1)
  83. }
  84. }
  85. }
  86. },{
  87. itemId: 'dataCountItem',
  88. cls:'x-dl-paging-display',
  89. xtype:'displayfield',
  90. value:'行/共*行'
  91. }],
  92. getPagingItems: function() {
  93. var me = this,
  94. inputListeners = {
  95. scope: me,
  96. blur: me.onPagingBlur
  97. };
  98. inputListeners[Ext.supports.SpecialKeyDownRepeat ? 'keydown' : 'keypress'] = me.onPagingKeyDown;
  99. return [
  100. {
  101. itemId: 'first',
  102. tooltip: me.firstText,
  103. overflowText: me.firstText,
  104. iconCls: Ext.baseCSSPrefix + 'tbar-page-first',
  105. disabled: true,
  106. handler: me.moveFirst,
  107. scope: me
  108. },
  109. {
  110. itemId: 'prev',
  111. tooltip: me.prevText,
  112. overflowText: me.prevText,
  113. iconCls: Ext.baseCSSPrefix + 'tbar-page-prev',
  114. disabled: true,
  115. handler: me.movePrevious,
  116. scope: me
  117. },
  118. '-',
  119. me.beforePageText,
  120. {
  121. xtype: 'numberfield',
  122. itemId: 'inputItem',
  123. name: 'inputItem',
  124. cls: Ext.baseCSSPrefix + 'tbar-page-number',
  125. allowDecimals: false,
  126. minValue: 1,
  127. hideTrigger: true,
  128. enableKeyEvents: true,
  129. keyNavEnabled: false,
  130. selectOnFocus: true,
  131. submitValue: false,
  132. // mark it as not a field so the form will not catch it when getting fields
  133. isFormField: false,
  134. width: me.inputItemWidth,
  135. margin: '-1 2 3 2',
  136. listeners: inputListeners
  137. },
  138. {
  139. xtype: 'tbtext',
  140. itemId: 'pageCountItem',
  141. html: Ext.String.format(me.afterPageText, '*')
  142. },
  143. '-',
  144. {
  145. itemId: 'next',
  146. tooltip: me.nextText,
  147. overflowText: me.nextText,
  148. iconCls: Ext.baseCSSPrefix + 'tbar-page-next',
  149. disabled: true,
  150. handler: me.moveNext,
  151. scope: me
  152. },
  153. {
  154. itemId: 'last',
  155. tooltip: me.lastText,
  156. overflowText: me.lastText,
  157. iconCls: Ext.baseCSSPrefix + 'tbar-page-last',
  158. disabled: true,
  159. handler: me.moveLast,
  160. scope: me
  161. },
  162. '-',
  163. {
  164. itemId: 'refresh',
  165. tooltip: me.refreshText,
  166. overflowText: me.refreshText,
  167. iconCls: Ext.baseCSSPrefix + 'tbar-loading',
  168. disabled: me.store.isLoading(),
  169. handler: me.doRefresh,
  170. scope: me
  171. }
  172. ];
  173. },
  174. moveLast: function() {
  175. var me = this,
  176. last = me.getPageData().pageCount;
  177. if(me.down('[name=showSelectRecord]').checked==false){
  178. if (me.fireEvent('beforechange', me, last) !== false) {
  179. me.store.loadPage(Number.MAX_SAFE_INTEGER);
  180. this.ownerCt.selModel.noChange = true;
  181. this.ownerCt.selModel.deselectAll();
  182. this.ownerCt.selModel.select(this.ownerCt.selectRecordArr);
  183. this.ownerCt.selModel.noChange = false;
  184. return true;
  185. }
  186. }
  187. return false;
  188. },
  189. moveFirst: function() {
  190. if(me.down('[name=showSelectRecord]').checked==false){
  191. if (this.fireEvent('beforechange', this, 1) !== false) {
  192. this.store.loadPage(1);
  193. this.ownerCt.selModel.noChange = true;
  194. this.ownerCt.selModel.deselectAll();
  195. this.ownerCt.selModel.select(this.ownerCt.selectRecordArr);
  196. this.ownerCt.selModel.noChange = false;
  197. return true;
  198. }
  199. }
  200. return false;
  201. },
  202. movePrevious: function() {
  203. var me = this,
  204. store = me.store,
  205. prev = store.currentPage - 1;
  206. if(me.down('[name=showSelectRecord]').checked==false){
  207. if (prev > 0) {
  208. if (me.fireEvent('beforechange', me, prev) !== false) {
  209. store.previousPage();
  210. this.ownerCt.selModel.noChange = true;
  211. this.ownerCt.selModel.deselectAll();
  212. this.ownerCt.selModel.select(this.ownerCt.selectRecordArr);
  213. this.ownerCt.selModel.noChange = false;
  214. return true;
  215. }
  216. }
  217. }
  218. return false;
  219. },
  220. moveNext: function() {
  221. var me = this,
  222. store = me.store,
  223. total = me.getPageData().pageCount,
  224. next = store.currentPage + 1;
  225. if(me.down('[name=showSelectRecord]').checked==false){
  226. if (next <= total) {
  227. if (me.fireEvent('beforechange', me, next) !== false) {
  228. store.nextPage();
  229. this.ownerCt.selModel.noChange = true;
  230. this.ownerCt.selModel.deselectAll();
  231. this.ownerCt.selModel.select(this.ownerCt.selectRecordArr);
  232. this.ownerCt.selModel.noChange = false;
  233. return true;
  234. }
  235. }
  236. }
  237. return false;
  238. },
  239. doRefresh: function() {
  240. var me = this,
  241. store = me.store,
  242. current = store.currentPage;
  243. if(me.down('[name=showSelectRecord]').checked==false){
  244. if (me.fireEvent('beforechange', me, current) !== false) {
  245. store.loadPage(current);
  246. this.ownerCt.selModel.noChange = true;
  247. this.ownerCt.selModel.deselectAll();
  248. this.ownerCt.selModel.select(this.ownerCt.selectRecordArr);
  249. this.ownerCt.selModel.noChange = false;
  250. return true;
  251. }
  252. }
  253. return false;
  254. },
  255. updateInfo: function() {
  256. var me = this,
  257. displayItem = me.child('#displayItem'),
  258. store = me.store,
  259. pageData = me.getPageData(),
  260. count, msg;
  261. if (displayItem) {
  262. count = store.getCount();
  263. if (count === 0) {
  264. msg = me.emptyMsg;
  265. } else {
  266. msg = Ext.String.format(me.displayMsg, pageData.fromRecord, pageData.toRecord, pageData.total);
  267. }
  268. displayItem.setText(msg);
  269. }
  270. }
  271. });