ProdIOCateSet.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. case '用品领用单':
  129. me.getComboData(f.store, 'ProdInOut!GoodsPicking');
  130. break;
  131. case '用品退仓单':
  132. me.getComboData(f.store, 'ProdInOut!GoodsShutout');
  133. break;
  134. case '用品验收单':
  135. me.getComboData(f.store, 'ProdInOut!GoodsIn');
  136. break;
  137. case '用品验退单':
  138. me.getComboData(f.store, 'ProdInOut!GoodsOut');
  139. break;
  140. }
  141. }
  142. },
  143. change: function(m){
  144. var f = Ext.getCmp('pc_type');
  145. if(!Ext.isEmpty(m.value)) {
  146. switch (m.value) {
  147. case '其它入库单':
  148. me.getComboData(f.store, 'ProdInOut!OtherIn');
  149. break;
  150. case '其它出库单':
  151. me.getComboData(f.store, 'ProdInOut!OtherOut');
  152. break;
  153. case '用品领用单':
  154. me.getComboData(f.store, 'ProdInOut!GoodsPicking');
  155. break;
  156. case '用品退仓单':
  157. me.getComboData(f.store, 'ProdInOut!GoodsShutout');
  158. break;
  159. case '用品验收单':
  160. me.getComboData(f.store, 'ProdInOut!GoodsIn');
  161. break;
  162. case '用品验退单':
  163. me.getComboData(f.store, 'ProdInOut!GoodsOut');
  164. break;
  165. }
  166. }
  167. }
  168. }
  169. });
  170. },
  171. getForm: function(btn){
  172. return btn.ownerCt.ownerCt;
  173. },
  174. getComboData: function(store, cal) {
  175. if(this._combodata && this._combodata[cal]) {
  176. store.loadData(this._combodata[cal]);
  177. return;
  178. }
  179. var me = this;
  180. Ext.Ajax.request({
  181. url : basePath + 'common/getFieldsDatas.action',
  182. async: false,
  183. params: {
  184. caller: 'DataListCombo',
  185. fields: 'dlc_value,dlc_display',
  186. condition: 'dlc_caller=\'' + cal + '\' AND dlc_fieldname=\'pi_type\''
  187. },
  188. method : 'post',
  189. callback : function(options,success,response){
  190. var localJson = new Ext.decode(response.responseText);
  191. if(localJson.exceptionInfo){
  192. showError(localJson.exceptionInfo);return;
  193. }
  194. if(localJson.success){
  195. var data = Ext.decode(localJson.data), arr = new Array();
  196. for(var i in data) {
  197. arr.push({
  198. display: data[i].DLC_VALUE,
  199. value: data[i].DLC_DISPLAY
  200. });
  201. }
  202. store.loadData(arr);
  203. if(me._combodata == null) {
  204. me._combodata = {};
  205. }
  206. me._combodata[cal] = arr;
  207. }
  208. }
  209. });
  210. }
  211. });