ExportDetail.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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) || grid.exportType == 'static') {
  26. grid.BaseUtil.exportGrid(grid);
  27. } else {
  28. grid.BaseUtil.createExcel(grid.caller||caller, 'detailgrid', grid.gridCondition || condition, null, null, null, grid);
  29. }
  30. }
  31. },{
  32. text: '导入明细数据',
  33. scope: this,
  34. xtype: 'upexcel',
  35. iconCls: 'main-msg',
  36. id: 'upexcel',
  37. cls: ' ',
  38. height: 23,
  39. listeners: {
  40. beforeimport: function(btn){
  41. var b = btn.ownerCt.floatParent, grid = b.grid;
  42. if(grid.readOnly) {// 可编辑的情况下,允许导入
  43. alert('当前单据不允许编辑,无法导入.');
  44. return false;
  45. }
  46. return true;
  47. }
  48. }
  49. }],
  50. initComponent : function(){
  51. this.callParent(arguments);
  52. },
  53. listeners: {
  54. afterrender: function(){
  55. this.grid = this.ownerCt.ownerCt;
  56. }
  57. }
  58. });