BomDetailPanelImp.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. Ext.define('erp.view.core.button.BomDetailPanelImp', {
  2. extend : 'Ext.form.Panel',
  3. alias : 'widget.erpBomDetailPanelImpButton',
  4. id : 'BomDetailPanelImp',
  5. hidden : true,
  6. initComponent : function() {
  7. if (this.iconCls) {
  8. this.items[0].buttonConfig.iconCls = this.iconCls;
  9. }
  10. if (this.cls) {
  11. this.items[0].buttonConfig.cls = this.cls;
  12. }
  13. if (this.itemCls) {
  14. this.items[0].buttonConfig.cls = this.itemCls;
  15. }
  16. if (this.iconCls) {
  17. this.items[0].buttonConfig.text = this.text;
  18. }
  19. this.callParent(arguments);
  20. },
  21. items : [ {
  22. xtype : 'filefield',
  23. name : 'file',
  24. buttonOnly : true,
  25. hideLabel : true,
  26. buttonConfig : {
  27. width : 150,
  28. height : 26,
  29. iconCls : 'x-button-icon-excel',
  30. cls : 'x-btn-gray',
  31. id:'filefieldBtn',
  32. enableKeyEvents : true,
  33. text : $I18N.common.button.erpBomDetailPanelImpButton
  34. },
  35. listeners : {
  36. change : function(field) {
  37. field.ownerCt.upexcel(field);
  38. }
  39. }
  40. } ],
  41. upexcel : function(field) {
  42. var me=this;
  43. var form = Ext.getCmp('form'), keyValue=Ext.getCmp(form.keyField).value;
  44. if(!keyValue){
  45. showError("请选择需要匹配的BOM!");
  46. return;
  47. }
  48. me.getForm().submit({
  49. url : basePath + 'scm/product/uploadBomDetailPanelImp.action?caller=' + caller+'&keyValue='+keyValue,
  50. waitMsg : "正在解析Excel",
  51. timeout:100000,
  52. success : function(fp, o) {
  53. field.reset();
  54. var bomDetailPanelGrid = Ext.getCmp('bomDetailPanelGrid'),
  55. grid = Ext.getCmp('grid'),
  56. tab = Ext.getCmp('BOMDetailPanelTab');
  57. if(bomDetailPanelGrid && o.result.remark && o.result.remark != "[]"){
  58. showError("匹配失败!");
  59. bomDetailPanelGrid.store.loadData(eval(o.result.remark));
  60. tab.setActiveTab('bomDetailPanelGrid');
  61. }else{
  62. bomDetailPanelGrid.store.loadData([]);
  63. tab.setActiveTab('grid');
  64. showMessage('提示', '匹配成功!');
  65. }
  66. if(grid){
  67. var param={
  68. caller:caller,
  69. condition:'bdi_bomid ='+keyValue
  70. };
  71. grid.GridUtil.loadNewStore(grid,param);
  72. }
  73. },
  74. failure : function(fp, o) {
  75. if (o.result.size) {
  76. showError(o.result.error + " " + Ext.util.Format.fileSize(o.result.size));
  77. field.reset();
  78. } else {
  79. showError(o.result.error);
  80. field.reset();
  81. }
  82. }
  83. });
  84. }
  85. });