Bomlevel.js 8.2 KB

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