CustomerProduct.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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','core.button.Scan',
  10. 'core.button.Close','core.button.Update','core.button.DeleteDetail','core.button.Sync',
  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. aftertrigger : function() {
  41. var id = Ext.getCmp('cu_id').value;
  42. if (id != null & id != '') {
  43. this.getStore('pc_custid=' + id);
  44. }
  45. }/*,
  46. change: function(field){
  47. if(field.value != null && field.value != ''){
  48. var grid = Ext.getCmp('grid');
  49. var id = Ext.getCmp('cu_id').value;
  50. var insert = true;//是否需要加入到grid
  51. var num = 0;//grid的有效数据有多少行
  52. Ext.each(grid.getStore().data.items, function(){
  53. if(this.data['pc_custid'] != null && this.data['pc_custid'] != '0'){
  54. num++;
  55. if(this.data['pc_custid'] == id){
  56. insert = false;
  57. }
  58. }
  59. });
  60. if(num == grid.getStore().data.items.length){
  61. me.GridUtil.add10EmptyItems(grid);
  62. }
  63. if(insert){
  64. grid.getStore().data.items[num].set('pc_custid', id);
  65. }
  66. }
  67. }*/
  68. }
  69. });
  70. },
  71. onGridItemClick: function(selModel, record){//grid行选择
  72. this.GridUtil.onGridItemClick(selModel, record);
  73. },
  74. getForm: function(btn){
  75. return btn.ownerCt.ownerCt;
  76. },
  77. getStore : function(condition) {
  78. var me = this;
  79. var grid = Ext.getCmp('grid');
  80. grid.store.removeAll(false);
  81. me.BaseUtil.getActiveTab().setLoading(true);// loading...
  82. Ext.Ajax.request({// 拿到grid的columns
  83. url : basePath + "common/singleGridPanel.action",
  84. params : {
  85. caller : "Customer!ProductCustomer",
  86. condition : condition
  87. },
  88. method : 'post',
  89. callback : function(options, success, response) {
  90. me.BaseUtil.getActiveTab().setLoading(false);
  91. var res = new Ext.decode(response.responseText);
  92. if (res.exceptionInfo) {
  93. showError(res.exceptionInfo);
  94. return;
  95. }
  96. var data = [];
  97. if (!res.data || res.data.length == 2) {
  98. me.GridUtil.add10EmptyItems(grid);
  99. } else {
  100. data = Ext.decode(res.data.replace(/,}/g, '}').replace(
  101. /,]/g, ']'));
  102. if (data.length > 0) {
  103. grid.store.loadData(data);
  104. }
  105. }
  106. }
  107. });
  108. }
  109. });