LogicChange.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.ma.logic.LogicChange', {
  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. 'ma.logic.LogicChange','core.form.Panel',
  9. 'core.button.Add','core.button.Save','core.button.Close',
  10. 'core.button.Update', 'core.button.Design','core.button.Submit',
  11. 'core.trigger.DbfindTrigger'
  12. ],
  13. init:function(){
  14. var me = this;
  15. this.control({
  16. 'textarea[name=lc_oldsource]': {
  17. afterrender: function(f){
  18. f.setHeight(300);
  19. }
  20. },
  21. 'textarea[name=lc_newsource]': {
  22. afterrender: function(f){
  23. f.setHeight(300);
  24. if(Ext.isEmpty(f.value) && Ext.getCmp('lc_oldsource') && !Ext.isEmpty(Ext.getCmp('lc_oldsource').value)) {
  25. f.setValue(Ext.getCmp('lc_oldsource').value);
  26. }
  27. }
  28. },
  29. 'field[name=lc_ldcode]': {
  30. afterrender: function(f){
  31. if (!Ext.isEmpty(lc_ldcode) && Ext.isEmpty(f.value) ) {
  32. f.setValue(lc_ldcode);
  33. }
  34. }
  35. },
  36. 'field[name=lc_oldversion]': {
  37. afterrender: function(f){
  38. },
  39. change: function(f){
  40. var form = f.ownerCt,
  41. lc_oldsource = form.down('#lc_oldsource');
  42. if(!lc_oldsource) {
  43. form.insert(form.items.items.length - 3, {
  44. xtype: 'textarea',
  45. columnWidth: 1,
  46. id: 'lc_oldsource',
  47. name: 'lc_oldsource',
  48. fieldLabel: '原代码',
  49. cls: 'form-field-allowBlank',
  50. fieldStyle: 'background:#f1f1f1;',
  51. readOnly: true
  52. });
  53. Ext.getCmp('lc_newsource').show();
  54. }
  55. me.getSource(form.down('#lc_ldcode').value, f.value, 'lc_oldsource');
  56. }
  57. },
  58. 'erpSaveButton': {
  59. click: function(btn){
  60. this.FormUtil.beforeSave(me);
  61. }
  62. },
  63. 'erpUpdateButton': {
  64. afterrender: function(btn){
  65. var f = Ext.getCmp(btn.ownerCt.ownerCt.statuscodeField);
  66. if(f && f.value == 'VALID') {
  67. btn.hide();
  68. }
  69. f = Ext.getCmp('lc_oldversion');
  70. if (Ext.isEmpty(f.value) ) {
  71. if(!Ext.isEmpty(lc_oldversion)) {
  72. f.setValue(lc_oldversion);
  73. }
  74. } else {
  75. var form = f.ownerCt,
  76. lc_oldsource = form.down('#lc_oldsource');
  77. if(!lc_oldsource) {
  78. form.insert(form.items.items.length - 3, {
  79. xtype: 'textarea',
  80. columnWidth: 1,
  81. id: 'lc_oldsource',
  82. name: 'lc_oldsource',
  83. fieldLabel: '原代码',
  84. cls: 'form-field-allowBlank',
  85. fieldStyle: 'background:#f1f1f1;',
  86. readOnly: true
  87. });
  88. Ext.getCmp('lc_newsource').show();
  89. }
  90. me.getSource(form.down('#lc_ldcode').value, f.value, 'lc_oldsource');
  91. }
  92. },
  93. click: function(btn){
  94. this.FormUtil.onUpdate(this);
  95. }
  96. },
  97. 'erpSubmitButton': {
  98. afterrender: function(btn){
  99. var f = Ext.getCmp(btn.ownerCt.ownerCt.statuscodeField);
  100. if(f && f.value == 'VALID') {
  101. btn.hide();
  102. }
  103. },
  104. click: function(btn){
  105. Ext.Ajax.request({
  106. url: basePath + 'ma/logic/submitLogicChange.action',
  107. method: 'post',
  108. params: {
  109. id: Ext.getCmp('lc_id').value
  110. },
  111. callback: function(options, success, response){
  112. var res = Ext.decode(response.responseText);
  113. if(res.id){
  114. id = res.id;
  115. me.FormUtil.onAdd('LogicDesc', '算法设计', 'jsps/ma/logic/logicDesc.jsp?formCondition=ld_idIS' + id +
  116. '&gridCondition=ldf_ldidIS' + id);
  117. window.location.reload();
  118. }
  119. }
  120. });
  121. }
  122. },
  123. 'erpAddButton': {
  124. click: function(){
  125. me.FormUtil.onAdd('addLogicChange', '需求变更', 'jsps/ma/logic/logicChange.jsp');
  126. }
  127. },
  128. 'erpCloseButton': {
  129. click: function(btn){
  130. this.FormUtil.beforeClose(me);
  131. }
  132. }
  133. });
  134. },
  135. getForm: function(btn){
  136. return btn.ownerCt.ownerCt;
  137. },
  138. getSource: function(code, version, field){
  139. this.FormUtil.getFieldValue('LogicDesc', 'ld_source', "ld_code='" + code + "' AND ld_version='" + version + "'",
  140. field);
  141. }
  142. });