VendorProduct.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.scm.purchase.VendorProduct', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. GridUtil: Ext.create('erp.util.GridUtil'),
  6. BaseUtil: Ext.create('erp.util.BaseUtil'),
  7. views:[
  8. 'core.form.Panel','scm.purchase.VendorProduct','core.grid.Panel2','core.toolbar.Toolbar',
  9. 'core.button.Save','core.button.Add','core.button.Upload','core.button.Scan',
  10. 'core.button.Close','core.button.Update','core.button.DeleteDetail',
  11. 'core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger','core.form.YnField'
  12. ],
  13. init:function(){
  14. var me = this;
  15. this.control({
  16. 'erpGridPanel2': {
  17. itemclick: this.onGridItemClick
  18. },
  19. 'erpSaveButton': {
  20. click: function(btn){
  21. this.FormUtil.onUpdate(this);
  22. }
  23. },
  24. 'erpUpdateButton': {
  25. click: function(btn){
  26. this.FormUtil.onUpdate(this);
  27. }
  28. },
  29. 'erpAddButton': {
  30. click: function(){
  31. me.FormUtil.onAdd('addVendorProduct', '新增供应商物料', 'jsps/scm/purchase/vendorProduct.jsp');
  32. }
  33. },
  34. 'erpCloseButton': {
  35. click: function(btn){
  36. me.FormUtil.beforeClose(me);
  37. }
  38. },
  39. 'textfield[name=ve_code]':{
  40. aftertrigger : function() {
  41. var id = Ext.getCmp('ve_id').value;
  42. if (id != null & id != '') {
  43. this.getStore('pv_vendid=' + id);
  44. }
  45. }
  46. }
  47. /*'textfield[name=ve_code]':{
  48. change: function(field){
  49. if(field.value != null && field.value != ''){
  50. var grid = Ext.getCmp('grid');
  51. var id = Ext.getCmp('ve_id').value;
  52. var insert = true;//是否需要加入到grid
  53. var num = 0;//grid的有效数据有多少行
  54. Ext.each(grid.getStore().data.items, function(){
  55. if(this.data['pv_vendid'] != null && this.data['pv_vendid'] != '0'){
  56. num++;
  57. if(this.data['pv_vendid'] == id){
  58. insert = false;
  59. }
  60. }
  61. });
  62. if(num == grid.getStore().data.items.length){
  63. me.GridUtil.add10EmptyItems(grid);
  64. }
  65. if(insert){
  66. grid.getStore().data.items[num].set('pv_vendid', id);
  67. grid.getStore().data.items[num].set('pv_vendcode', Ext.getCmp('ve_code').value);
  68. }
  69. }
  70. }
  71. }*/
  72. });
  73. },
  74. onGridItemClick: function(selModel, record){//grid行选择
  75. this.GridUtil.onGridItemClick(selModel, record);
  76. },
  77. getForm: function(btn){
  78. return btn.ownerCt.ownerCt;
  79. },
  80. getStore : function(condition) {
  81. var me = this;
  82. var grid = Ext.getCmp('grid');
  83. grid.store.removeAll(false);
  84. me.BaseUtil.getActiveTab().setLoading(true);// loading...
  85. Ext.Ajax.request({// 拿到grid的columns
  86. url : basePath + "common/singleGridPanel.action",
  87. params : {
  88. caller : "Vendor!ProductVendor",
  89. condition : condition
  90. },
  91. method : 'post',
  92. callback : function(options, success, response) {
  93. me.BaseUtil.getActiveTab().setLoading(false);
  94. var res = new Ext.decode(response.responseText);
  95. if (res.exceptionInfo) {
  96. showError(res.exceptionInfo);
  97. return;
  98. }
  99. var data = [];
  100. if (!res.data || res.data.length == 2) {
  101. me.GridUtil.add10EmptyItems(grid);
  102. } else {
  103. data = Ext.decode(res.data.replace(/,}/g, '}').replace(
  104. /,]/g, ']'));
  105. if (data.length > 0) {
  106. grid.store.loadData(data);
  107. }
  108. }
  109. }
  110. });
  111. }
  112. });