CustomerProduct.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.scm.sale.CustomerProduct', {
  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. 'scm.sale.CustomerProduct','core.form.Panel','core.grid.Panel2','core.toolbar.Toolbar',
  9. 'core.button.Save','core.button.Add','core.button.Upload',
  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('addCustomerProduct', '新增客户物料', 'jsps/scm/sale/customerProduct.jsp');
  32. }
  33. },
  34. 'erpCloseButton': {
  35. click: function(btn){
  36. me.FormUtil.beforeClose(me);
  37. }
  38. },
  39. 'textfield[name=cu_code]':{
  40. change: function(field){
  41. if(field.value != null && field.value != ''){
  42. var grid = Ext.getCmp('grid');
  43. var id = Ext.getCmp('cu_id').value;
  44. var insert = true;//是否需要加入到grid
  45. var num = 0;//grid的有效数据有多少行
  46. Ext.each(grid.getStore().data.items, function(){
  47. if(this.data['pc_custid'] != null && this.data['pc_custid'] != '0'){
  48. num++;
  49. if(this.data['pc_custid'] == id){
  50. insert = false;
  51. }
  52. }
  53. });
  54. if(num == grid.getStore().data.items.length){
  55. me.GridUtil.add10EmptyItems(grid);
  56. }
  57. if(insert){
  58. grid.getStore().data.items[num].set('pc_custid', id);
  59. }
  60. }
  61. }
  62. }
  63. });
  64. },
  65. onGridItemClick: function(selModel, record){//grid行选择
  66. this.GridUtil.onGridItemClick(selModel, record);
  67. },
  68. getForm: function(btn){
  69. return btn.ownerCt.ownerCt;
  70. }
  71. });