ProdIOCateSet.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.co.cost.ProdIOCateSet', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. views:[
  7. 'core.form.Panel','co.cost.ProdIOCateSet','core.toolbar.Toolbar','core.form.MultiField',
  8. 'core.button.Save','core.button.Add','core.button.Submit','core.button.ResAudit',
  9. 'core.button.Audit','core.button.Close','core.button.Delete','core.button.Update',
  10. 'core.button.ResSubmit','core.button.Scan','core.button.Banned','core.button.ResBanned',
  11. 'core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger','core.form.YnField','core.form.StatusField'
  12. ],
  13. init:function(){
  14. var me = this;
  15. this.control({
  16. 'erpSaveButton': {
  17. click: function(btn){
  18. var form = me.getForm(btn);
  19. if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
  20. me.BaseUtil.getRandomNumber();//自动添加编号
  21. }
  22. this.FormUtil.beforeSave(this);
  23. }
  24. },
  25. 'erpDeleteButton' : {
  26. click: function(btn){
  27. me.FormUtil.onDelete(Ext.getCmp('pc_id').value);
  28. }
  29. },
  30. 'erpUpdateButton': {
  31. afterrender: function(btn){
  32. var status = Ext.getCmp('pc_statuscode');
  33. if(status && status.value != 'ENTERING'){
  34. btn.hide();
  35. }
  36. },
  37. click: function(btn){
  38. this.FormUtil.onUpdate(this);
  39. }
  40. },
  41. 'erpAddButton': {
  42. click: function(){
  43. me.FormUtil.onAdd('addProdIOCateSet', '新增其它出入库科目', 'jsps/co/cost/prodIOCateSet.jsp');
  44. }
  45. },
  46. 'erpCloseButton': {
  47. click: function(btn){
  48. me.FormUtil.beforeClose(me);
  49. }
  50. },
  51. 'erpSubmitButton': {
  52. afterrender: function(btn){
  53. var status = Ext.getCmp('pc_statuscode');
  54. if(status && status.value != 'ENTERING'){
  55. btn.hide();
  56. }
  57. },
  58. click: function(btn){
  59. me.FormUtil.onSubmit(Ext.getCmp('pc_id').value);
  60. }
  61. },
  62. 'erpResSubmitButton': {
  63. afterrender: function(btn){
  64. var status = Ext.getCmp('pc_statuscode');
  65. if(status && status.value != 'COMMITED'){
  66. btn.hide();
  67. }
  68. },
  69. click: function(btn){
  70. me.FormUtil.onResSubmit(Ext.getCmp('pc_id').value);
  71. }
  72. },
  73. 'erpAuditButton': {
  74. afterrender: function(btn){
  75. var status = Ext.getCmp('pc_statuscode');
  76. if(status && status.value != 'COMMITED'){
  77. btn.hide();
  78. }
  79. },
  80. click: function(btn){
  81. me.FormUtil.onAudit(Ext.getCmp('pc_id').value);
  82. }
  83. },
  84. 'erpResAuditButton': {
  85. afterrender: function(btn){
  86. var status = Ext.getCmp('pc_statuscode');
  87. if(status && status.value != 'AUDITED'){
  88. btn.hide();
  89. }
  90. },
  91. click: function(btn){
  92. me.FormUtil.onResAudit(Ext.getCmp('pc_id').value);
  93. }
  94. },
  95. 'erpBannedButton': {
  96. afterrender: function(btn){
  97. var status = Ext.getCmp('pc_statuscode');
  98. if(status && status.value == 'DISABLE'){
  99. btn.hide();
  100. }
  101. },
  102. click: function(btn){
  103. this.FormUtil.onBanned(Ext.getCmp('pc_id').value);
  104. }
  105. },
  106. 'erpResBannedButton': {
  107. afterrender: function(btn){
  108. var status = Ext.getCmp('pc_statuscode');
  109. if(status && status.value != 'DISABLE'){
  110. btn.hide();
  111. }
  112. },
  113. click: function(btn){
  114. this.FormUtil.onResBanned(Ext.getCmp('pc_id').value);
  115. }
  116. },
  117. 'textfield[name=pc_class]': {
  118. afterrender: function(m) {
  119. var f = Ext.getCmp('pc_type');
  120. if(!Ext.isEmpty(m.value)) {
  121. switch (m.value) {
  122. case '其它入库单':
  123. me.getComboData(f.store, 'ProdInOut!OtherIn');
  124. break;
  125. case '其它出库单':
  126. me.getComboData(f.store, 'ProdInOut!OtherOut');
  127. break;
  128. }
  129. }
  130. },
  131. change: function(m){
  132. var f = Ext.getCmp('pc_type');
  133. if(!Ext.isEmpty(m.value)) {
  134. switch (m.value) {
  135. case '其它入库单':
  136. me.getComboData(f.store, 'ProdInOut!OtherIn');
  137. break;
  138. case '其它出库单':
  139. me.getComboData(f.store, 'ProdInOut!OtherOut');
  140. break;
  141. }
  142. }
  143. }
  144. }
  145. });
  146. },
  147. getForm: function(btn){
  148. return btn.ownerCt.ownerCt;
  149. },
  150. getComboData: function(store, cal) {
  151. if(this._combodata && this._combodata[cal]) {
  152. store.loadData(this._combodata[cal]);
  153. return;
  154. }
  155. var me = this;
  156. Ext.Ajax.request({
  157. url : basePath + 'common/getFieldsDatas.action',
  158. async: false,
  159. params: {
  160. caller: 'DataListCombo',
  161. fields: 'dlc_value,dlc_display',
  162. condition: 'dlc_caller=\'' + cal + '\' AND dlc_fieldname=\'pi_type\''
  163. },
  164. method : 'post',
  165. callback : function(options,success,response){
  166. var localJson = new Ext.decode(response.responseText);
  167. if(localJson.exceptionInfo){
  168. showError(localJson.exceptionInfo);return;
  169. }
  170. if(localJson.success){
  171. var data = Ext.decode(localJson.data), arr = new Array();
  172. for(var i in data) {
  173. arr.push({
  174. display: data[i].DLC_VALUE,
  175. value: data[i].DLC_DISPLAY
  176. });
  177. }
  178. store.loadData(arr);
  179. if(me._combodata == null) {
  180. me._combodata = {};
  181. }
  182. me._combodata[cal] = arr;
  183. }
  184. }
  185. });
  186. }
  187. });