GetVendor.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * 请购单批量转采购单界面,获取缺省供应商按钮
  3. */
  4. Ext.define('erp.view.core.button.GetVendor',{
  5. extend: 'Ext.Button',
  6. alias: 'widget.erpGetVendorButton',
  7. iconCls: 'x-button-icon-check',
  8. cls: 'x-btn-gray',
  9. id: 'erpGetVendorButton',
  10. text: $I18N.common.button.erpGetVendorButton,
  11. width: 110,
  12. initComponent : function(){
  13. this.callParent(arguments);
  14. },
  15. handler: function(){
  16. var grid = Ext.getCmp('batchDealGridPanel');
  17. var items = grid.selModel.getSelection();
  18. Ext.each(items, function(item, index){
  19. if(this.data[grid.keyField] != null && this.data[grid.keyField] != ''
  20. && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0){
  21. var bool = true;
  22. Ext.each(grid.multiselected, function(){
  23. if(this.data[grid.keyField] == item.data[grid.keyField]){
  24. bool = false;
  25. }
  26. });
  27. if(bool){
  28. grid.multiselected.push(item);
  29. }
  30. }
  31. });
  32. var records = grid.multiselected;
  33. if(records.length > 0){
  34. if(records.length > 500) {
  35. showMessage('提示', '勾选行数必须小于500条!');
  36. return;
  37. }
  38. var id = new Array();
  39. Ext.each(records, function(record, index){
  40. id.push(record.data['ad_id']);
  41. });
  42. grid.setLoading(true);
  43. Ext.Ajax.request({
  44. url : basePath + 'scm/purchase/getVendor.action',
  45. params: {
  46. id: id
  47. },
  48. method : 'post',
  49. callback : function(options,success,response){
  50. grid.setLoading(false);
  51. var localJson = new Ext.decode(response.responseText);
  52. if(localJson.exceptionInfo){
  53. showError(localJson.exceptionInfo);
  54. } else {
  55. if(localJson.success){
  56. grid.multiselected = new Array();
  57. Ext.getCmp('dealform').onQuery(true);
  58. }
  59. }
  60. }
  61. });
  62. } else {
  63. showError("请勾选需要的明细!");
  64. }
  65. }
  66. });