ExportDetail.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * 明细行导入excel
  3. */
  4. Ext.define('erp.view.core.button.ExportDetail',{
  5. extend: 'Ext.Button',
  6. alias: 'widget.erpExportDetailButton',
  7. iconCls: 'x-button-icon-excel',
  8. cls: 'x-btn-tb',
  9. disabled: false,
  10. menu: [{
  11. iconCls: 'main-msg',
  12. text: '下载模板',
  13. cls: ' ',
  14. scope: this,
  15. handler: function(btn){
  16. var grid = btn.parentMenu.floatParent.grid;
  17. var condition = grid.condition;
  18. if(!condition){
  19. var urlCondition = grid.BaseUtil.getUrlParam('gridCondition');
  20. urlCondition = urlCondition == null || urlCondition == "null" ? "" : urlCondition;
  21. urlCondition = urlCondition.replace(/IS/g, "=");
  22. condition = urlCondition;
  23. }
  24. condition = grid.gridCondition || condition;
  25. if(Ext.isEmpty(condition)) {
  26. grid.BaseUtil.exportGrid(grid);
  27. } else if(typeof grid.onExport === 'function'){
  28. grid.onExport(grid.caller||caller, 'detailgrid', grid.gridCondition || condition);
  29. } else {
  30. grid.BaseUtil.createExcel(grid.caller||caller, 'detailgrid', grid.gridCondition || condition);
  31. }
  32. }
  33. },{
  34. text: '导入明细数据',
  35. scope: this,
  36. xtype: 'upexcel',
  37. iconCls: 'main-msg',
  38. id: 'upexcel',
  39. cls: ' ',
  40. height: 23,
  41. listeners: {
  42. afterrender: function(btn) {
  43. var b = btn.ownerCt.floatParent, grid = b.grid;
  44. if(grid.readOnly)
  45. btn.hide();
  46. },
  47. beforeimport: function(btn){
  48. var b = btn.ownerCt.floatParent, grid = b.grid;
  49. if(grid.readOnly) {// 可编辑的情况下,允许导入
  50. alert('当前单据不允许编辑,无法导入.');
  51. return false;
  52. }
  53. return true;
  54. }
  55. }
  56. }],
  57. initComponent : function(){
  58. this.callParent(arguments);
  59. },
  60. listeners: {
  61. afterrender: function(){
  62. this.grid = this.ownerCt.ownerCt;
  63. }
  64. }
  65. });