DecomSetting.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.pm.make.DecomSetting', {
  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.make.DecomSetting','core.form.Panel','pm.make.DecomSettingGrid','common.datalist.Toolbar',
  9. 'core.button.DownloadTemp','core.button.SNimport','core.button.ClearSN','core.button.UpExcel',
  10. 'core.button.Close','core.button.LoadParts','core.button.UpdateMaterial','core.form.YnField'
  11. ],
  12. init:function(){
  13. var me = this;
  14. me.BaseUtil = Ext.create('erp.util.BaseUtil');
  15. me.GridUtil = Ext.create('erp.util.GridUtil');
  16. this.control({
  17. 'erpFormPanel': {
  18. afterload: function(form) {
  19. var items = form.items.items;
  20. Ext.each(items, function(item) {
  21. item.setReadOnly(true);
  22. });
  23. }
  24. },
  25. '#re_code': {
  26. afterrender: function(field){
  27. me.loadData(field.value);
  28. }
  29. },
  30. '#ma_screcode': {
  31. afterrender: function(field){
  32. me.loadData(field.value);
  33. }
  34. },
  35. 'erpLoadPartsButton':{
  36. afterrender: function(btn){
  37. var status;
  38. if(caller == 'DecomSetting'){
  39. status = Ext.getCmp('re_statuscode');
  40. if(status && status.value != 'ENTERING' && status.value != 'COMMITED'){
  41. btn.hide();
  42. }
  43. }else{
  44. status = Ext.getCmp('ma_statuscode');
  45. if(status && status.value != 'ENTERING' && status.value != 'COMMITED'){
  46. btn.hide();
  47. }
  48. }
  49. },
  50. click: function(btn){
  51. /*var grid = Ext.getCmp('grid');
  52. var ms_sncode;
  53. var items = grid.getStore().data.items;//获取store里面的数据
  54. if(items[0].data['rd_sncode'] != null && items[0].data['rd_sncode'] != '' ){
  55. ms_sncode = items[0].data['rd_sncode'];
  56. } */
  57. var ma_code ;
  58. var re_code ;
  59. if(caller == 'DecomSetting'){
  60. ma_code = Ext.getCmp('re_rwmo').value;
  61. re_code = Ext.getCmp('re_code').value;
  62. }else{
  63. ma_code = Ext.getCmp('ma_code').value;
  64. re_code = Ext.getCmp('ma_screcode').value;
  65. }
  66. var dbwin = new Ext.window.Window({
  67. id : 'zrbjwin',
  68. title: '载入部件',
  69. height: "100%",
  70. width: "100%",
  71. maximizable : true,
  72. buttonAlign : 'center',
  73. layout : 'anchor',
  74. items: []
  75. });
  76. dbwin.show();
  77. var iframe = dbwin.getEl().down('iframe');
  78. if(!iframe) {
  79. dbwin.add({
  80. tag : 'iframe',
  81. frame : true,
  82. anchor : '100% 100%',
  83. layout : 'fit',
  84. html : '<iframe src="#" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>'
  85. });
  86. iframe = dbwin.getEl().down('iframe');
  87. }
  88. iframe.dom.src = basePath+'jsps/pm/make/loadingParts.jsp?whoami=LoadingParts&gridCondition=msd_recodeIS'+"'"+re_code+"' and ms_makecodeIS'"+ma_code+"'";
  89. }
  90. },
  91. 'erpUpdateMaterialButton':{
  92. afterrender: function(btn){
  93. var status;
  94. if(caller == 'DecomSetting'){
  95. status = Ext.getCmp('re_statuscode');
  96. if(status && status.value != 'ENTERING' && status.value != 'COMMITED'){
  97. btn.hide();
  98. }
  99. }else{
  100. status = Ext.getCmp('ma_statuscode');
  101. if(status && status.value != 'ENTERING' && status.value != 'COMMITED'){
  102. btn.hide();
  103. }
  104. }
  105. },
  106. click: function(btn){
  107. var grids = Ext.ComponentQuery.query('gridpanel');
  108. var s2 = '';
  109. if(grids.length > 0 && !grids[0].ignore){//check所有grid是否已修改
  110. Ext.each(grids, function(grid, index){
  111. if(grid.GridUtil){
  112. var msg = grid.GridUtil.checkGridDirty(grid);
  113. if(msg.length > 0){
  114. s2 = s2 + '<br/>' + msg;
  115. }
  116. }
  117. });
  118. }
  119. if(s2 == '' || s2 == '<br/>'){
  120. showError('还未添加或修改数据.');
  121. return;
  122. }
  123. this.FormUtil.onUpdate(this);
  124. }
  125. },
  126. 'erpCloseButton' : {
  127. click : function(btn) {
  128. me.FormUtil.beforeClose(me);
  129. }
  130. }
  131. });
  132. },
  133. onGridItemClick : function(selModel, record) {//grid行选择
  134. this.GridUtil.onGridItemClick(selModel, record);
  135. },
  136. getForm : function(btn) {
  137. return btn.ownerCt.ownerCt;
  138. },
  139. loadData: function(value) {
  140. var me = this;
  141. me.FormUtil.getFieldsValues("MakeSNDecompose left join product on pr_code=msd_fsoncode",
  142. ' msd_id,msd_fsoncode, pr_detail,pr_spec,msd_stepcode', "msd_recode='" +value+"' order by msd_id asc", [], function(data){
  143. var datas = Ext.JSON.decode(data), _datas = [];
  144. var grid = Ext.getCmp('grid');
  145. if(datas.length > 0) {
  146. var keys = Ext.Object.getKeys(datas[0]);
  147. Ext.Array.each(datas, function(d){
  148. var obj = {};
  149. Ext.Array.each(keys, function(key){
  150. obj[key.toLowerCase()] = d[key];
  151. });
  152. _datas.push(obj);
  153. });
  154. }
  155. store = grid.getStore();
  156. _datas.length > 0 && grid.store.loadData(_datas);
  157. grid.store.each(function(){
  158. this.dirty = true;
  159. });
  160. });
  161. }
  162. });