CraftMake.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.pm.mes.CraftMake', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. GridUtil: Ext.create('erp.util.GridUtil'),
  7. views:[
  8. 'pm.mes.CraftMake','core.form.Panel','core.grid.Panel2',
  9. 'core.button.Add','core.button.Save','core.button.Close','core.button.Update',
  10. 'core.form.YnField','core.grid.YnColumn', 'core.grid.TfColumn',
  11. 'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger'
  12. ],
  13. init:function(){
  14. var me = this;
  15. this.control({
  16. 'erpGridPanel2': {
  17. reconfigure: function(grid){
  18. Ext.defer(function(){
  19. grid.readOnly = true;
  20. }, 500);
  21. }
  22. },
  23. 'dbfindtrigger[name=ma_craftcode]' : {
  24. afterrender: function(v) {
  25. var crid = Ext.getCmp('cr_id').value;
  26. if (crid != null & crid != '') {
  27. this.getGridStore('cr_id=' + crid);
  28. }
  29. },
  30. aftertrigger : function(v) {
  31. var crid = Ext.getCmp('cr_id').value;
  32. if (crid != null & crid != '') {
  33. this.getGridStore('cr_id=' + crid);
  34. }
  35. }
  36. },
  37. 'erpSaveButton': {
  38. click: function(btn){
  39. this.FormUtil.onUpdate(this);
  40. this.getGridStore('cr_id=' + Ext.getCmp('cr_id').value);
  41. }
  42. },
  43. 'erpCloseButton': {
  44. click: function(btn){
  45. this.FormUtil.beforeClose(this);
  46. }
  47. },
  48. 'erpUpdateButton': {
  49. click: function(btn){
  50. this.FormUtil.onUpdate(this);
  51. this.getGridStore('cr_id=' + Ext.getCmp('cr_id').value);
  52. }
  53. }
  54. });
  55. },
  56. getForm: function(btn){
  57. return btn.ownerCt.ownerCt;
  58. },
  59. getGridStore : function(condition) {
  60. var me = this;
  61. var grid = Ext.getCmp('grid');
  62. grid.store.removeAll(false);
  63. me.BaseUtil.getActiveTab().setLoading(true);// loading...
  64. Ext.Ajax.request({// 拿到grid的columns
  65. url : basePath + "common/singleGridPanel.action",
  66. params : {
  67. caller : "CraftMake",
  68. condition : condition
  69. },
  70. method : 'post',
  71. callback : function(options, success, response) {
  72. me.BaseUtil.getActiveTab().setLoading(false);
  73. var res = new Ext.decode(response.responseText);
  74. if (res.exceptionInfo) {
  75. showError(res.exceptionInfo);
  76. return;
  77. }
  78. var data = [];
  79. if (!res.data || res.data.length == 2) {
  80. me.GridUtil.add10EmptyItems(grid);
  81. } else {
  82. data = Ext.decode(res.data.replace(/,}/g, '}').replace(
  83. /,]/g, ']'));
  84. if (data.length > 0) {
  85. grid.store.loadData(data);
  86. }
  87. }
  88. }
  89. });
  90. }
  91. });