Bomlevel.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.pm.bom.Bomlevel', {
  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.bom.Bomlevel','core.form.Panel','core.grid.Panel2','core.toolbar.Toolbar',
  9. 'pm.bom.Maketypegrid','core.button.Add','core.button.Save','core.button.Close',
  10. 'pm.bom.Billtypegrid','core.button.Update','core.button.Delete','core.form.YnField',
  11. 'core.button.DeleteDetail','core.trigger.DbfindTrigger','core.grid.YnColumn',
  12. 'core.form.YnField','core.button.Bomleveldetail','core.button.ResAudit','core.button.Audit',
  13. 'core.button.Submit','core.button.ResSubmit',
  14. ],
  15. init:function(){
  16. var me = this;
  17. this.control({
  18. 'erpGridPanel2': {
  19. itemclick: function(selModel, record){
  20. this.GridUtil.onGridItemClick(selModel, record);
  21. }
  22. },
  23. 'maketypegrid':{
  24. itemclick: function(selModel, record){
  25. this.GridUtil.onGridItemClick(selModel, record, 'maketypegrid');
  26. }
  27. },
  28. 'billtypegrid':{
  29. itemclick: function(selModel, record){
  30. this.GridUtil.onGridItemClick(selModel, record, 'billtypegrid');
  31. }
  32. },
  33. 'erpSaveButton': {
  34. click: function(btn){
  35. this.beforeSave();
  36. }
  37. },
  38. 'field[name=bl_id]': {
  39. afterrender: function(f){
  40. if(f.value != null && f.value != ''){
  41. var position = Ext.getCmp('maketypegrid');
  42. position.getMyData(f.value);
  43. var reandpunish = Ext.getCmp('billtypegrid');
  44. reandpunish.getMyData(f.value);
  45. }
  46. },
  47. change: function(f){
  48. if(f.value != null && f.value != ''){
  49. var position = Ext.getCmp('maketypegrid');
  50. position.getMyData(f.value);
  51. var work = Ext.getCmp('billtypegrid');
  52. work.getMyData(f.value);
  53. }
  54. }
  55. },
  56. 'erpCloseButton': {
  57. click: function(btn){
  58. this.FormUtil.beforeClose(this);
  59. }
  60. },
  61. 'erpUpdateButton': {
  62. click: function(btn){
  63. this.beforeUpdate();
  64. }
  65. },
  66. 'erpDeleteButton': {
  67. click: function(btn){
  68. me.FormUtil.onDelete(Ext.getCmp('bl_id').value);
  69. }
  70. },
  71. 'erpAddButton': {
  72. click: function(){
  73. me.FormUtil.onAdd('addBomlevel', '新增BOM等级定义', 'jsps/pm/bom/Bomlevel.jsp');
  74. }
  75. },'erpSubmitButton': {
  76. afterrender: function(btn){
  77. var status = Ext.getCmp('bl_statuscode');
  78. if(status && status.value != 'ENTERING'){
  79. btn.hide();
  80. }
  81. },
  82. click: function(btn){
  83. me.FormUtil.onSubmit(Ext.getCmp('bl_id').value,true);
  84. }
  85. },
  86. 'erpResSubmitButton': {
  87. afterrender: function(btn){
  88. var status = Ext.getCmp('bl_statuscode');
  89. if(status && status.value != 'COMMITED'){
  90. btn.hide();
  91. }
  92. },
  93. click: function(btn){
  94. me.FormUtil.onResSubmit(Ext.getCmp('bl_id').value);
  95. }
  96. },
  97. 'erpAuditButton': {
  98. afterrender: function(btn){
  99. var status = Ext.getCmp('bl_statuscode');
  100. if(status && status.value != 'COMMITED'){
  101. btn.hide();
  102. }
  103. },
  104. click: function(btn){
  105. me.FormUtil.onAudit(Ext.getCmp('bl_id').value);
  106. }
  107. },
  108. 'erpResAuditButton': {
  109. afterrender: function(btn){
  110. var status = Ext.getCmp('bl_statuscode');
  111. if(status && status.value != 'AUDITED'){
  112. btn.hide();
  113. }
  114. },
  115. click: function(btn){
  116. me.FormUtil.onResAudit(Ext.getCmp('bl_id').value);
  117. }
  118. },
  119. 'erpBomleveldetailButton':{
  120. click: function(){
  121. var detail = Ext.getCmp('grid');
  122. var id = Ext.getCmp('bl_id').value;
  123. var education = Ext.getCmp('maketypegrid');
  124. var position = Ext.getCmp('billtypegrid');
  125. var param1 = me.GridUtil.getAllGridStore(detail);
  126. var param3 = me.GridUtil.getAllGridStore(education);
  127. var param2 = me.GridUtil.getAllGridStore(position);
  128. param1 = "[" + param1.toString() + "]";
  129. param2 = "[" + param2.toString() + "]";
  130. param3 = "[" + param3.toString() + "]";
  131. warnMsg('确定要更新明细行数据么吗?', function(btn){
  132. if (btn == 'yes') {
  133. Ext.Ajax.request({
  134. url:basePath + "pm/bom/updateBomleveldetail.action",
  135. params:{
  136. param1:param1,
  137. param2:param2,
  138. param3:param3,
  139. id:id
  140. },
  141. method:'post',
  142. callback:function(options,success,response){
  143. var res = new Ext.decode(response.responseText);
  144. if(res.success){
  145. Ext.Msg.alert("提示", "更新明细行数据成功!");
  146. }else{
  147. Ext.Msg.alert("提示", "更新明细行数据失败!");
  148. }
  149. }
  150. });
  151. }
  152. });
  153. }
  154. }
  155. });
  156. },
  157. getForm: function(btn){
  158. return btn.ownerCt.ownerCt;
  159. },
  160. beforeSave: function(){
  161. var me = this;
  162. var form = Ext.getCmp('form');
  163. if(! me.FormUtil.checkForm()){
  164. return;
  165. }
  166. if(Ext.getCmp(form.keyField).value == null || Ext.getCmp(form.keyField).value == ''){
  167. me.FormUtil.getSeqId(form);
  168. }
  169. var detail = Ext.getCmp('grid');
  170. var education = Ext.getCmp('maketypegrid');
  171. var position = Ext.getCmp('billtypegrid');
  172. var param1 = me.GridUtil.getGridStore(detail);
  173. var param3 = me.GridUtil.getGridStore(education);
  174. var param2 = me.GridUtil.getGridStore(position);
  175. /*if(detail.necessaryField.length > 0 && (param1.length == 0)){
  176. showError($I18N.common.grid.emptyDetail);
  177. return;
  178. } else {*/
  179. param1 = param1 == null ? [] : "[" + param1.toString().replace(/\\/g,"%") + "]";
  180. param2 = param2 == null ? [] : "[" + param2.toString().replace(/\\/g,"%") + "]";
  181. param3 = param3 == null ? [] : "[" + param3.toString().replace(/\\/g,"%") + "]";
  182. if(form.getForm().isValid()){
  183. Ext.each(form.items.items, function(item){
  184. if(item.xtype == 'numberfield'){
  185. if(item.value == null || item.value == ''){
  186. item.setValue(0);
  187. }
  188. }
  189. });
  190. var r = form.getValues();
  191. me.FormUtil.save(r, param1, param2, param3);
  192. }else{
  193. me.FormUtil.checkForm();
  194. }
  195. //}
  196. },
  197. beforeUpdate: function(){
  198. var me = this;
  199. var form = Ext.getCmp('form');
  200. if(! me.FormUtil.checkForm()){
  201. return;
  202. }
  203. if(Ext.getCmp(form.keyField).value == null || Ext.getCmp(form.keyField).value == ''){
  204. me.FormUtil.getSeqId(form);
  205. }
  206. var detail = Ext.getCmp('grid');
  207. var education = Ext.getCmp('maketypegrid');
  208. var position = Ext.getCmp('billtypegrid');
  209. var param1 = me.GridUtil.getGridStore(detail);
  210. var param3 = me.GridUtil.getGridStore(education);
  211. var param2 = me.GridUtil.getGridStore(position);
  212. /*if(detail.necessaryField.length > 0 && (param1.length == 0)){
  213. showError($I18N.common.grid.emptyDetail);
  214. return;
  215. } else {*/
  216. param1 = param1 == null ? [] : "[" + param1.toString().replace(/\\/g,"%") + "]";
  217. param2 = param2 == null ? [] : "[" + param2.toString().replace(/\\/g,"%") + "]";
  218. param3 = param3 == null ? [] : "[" + param3.toString().replace(/\\/g,"%") + "]";
  219. if(form.getForm().isValid()){
  220. Ext.each(form.items.items, function(item){
  221. if(item.xtype == 'numberfield'){
  222. if(item.value == null || item.value == ''){
  223. item.setValue(0);
  224. }
  225. }
  226. });
  227. var r = form.getValues();
  228. me.FormUtil.update(r, param1, param2, param3);
  229. }else{
  230. me.FormUtil.checkForm();
  231. }
  232. //}
  233. },
  234. add10EmptyItems: function(grid){
  235. var items = grid.store.data.items;
  236. var detno = grid.detno;
  237. if(detno){
  238. var index = items.length == 0 ? 0 : Number(items[items.length-1].data[detno]);
  239. for(var i=0;i<10;i++){
  240. var o = new Object();
  241. o[detno] = index + i + 1;
  242. grid.store.insert(items.length, o);
  243. items[items.length-1]['index'] = items.length-1;
  244. }
  245. } else {
  246. for(var i=0;i<10;i++){
  247. var o = new Object();
  248. grid.store.insert(items.length, o);
  249. items[items.length-1]['index'] = items.length-1;
  250. }
  251. }
  252. },
  253. });