JprocessAbnormal.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.common.JprocessAbnormal', {
  3. extend: 'Ext.app.Controller',
  4. BaseUtil: Ext.create('erp.util.BaseUtil'),
  5. FormUtil: Ext.create('erp.util.FormUtil'),
  6. //RenderUtil:Ext.create('erp.util.RenderUtil'),
  7. views:[
  8. 'scm.product.datalist.Viewport','scm.product.datalist.GridPanel','scm.product.datalist.Toolbar','core.button.VastAudit','core.button.VastDelete',
  9. 'core.button.VastPrint','core.button.VastReply','core.button.VastSubmit','core.button.ResAudit','core.button.Add','core.grid.YnColumn'
  10. ],
  11. init:function(){
  12. this.control({
  13. 'erpDatalistGridPanel': {
  14. itemclick: this.onGridItemClick
  15. },
  16. 'erpAddButton':{
  17. afterrender: function(btn){
  18. btn.ownerCt.insert(11,{
  19. fieldLabel:'制单日期',
  20. xtype:'datefield',
  21. labelAlign:'right',
  22. id:'recorddate',
  23. fieldStyle:'background:#FFFAFA;color:#515151;'
  24. });
  25. btn.setText('生成数据');
  26. btn.setWidth(100);
  27. },
  28. click:function(btn){
  29. var date=Ext.getCmp('recorddate').getValue();
  30. Ext.Ajax.request({
  31. params:{
  32. date:date
  33. },
  34. url:basePath+'process/createAbnormalData.action',
  35. method:'post',
  36. callback:function(success,options,response){
  37. var local=Ext.decode(response.responseText);
  38. if(local.success){
  39. Ext.Msg.alert('提示','数据生成成功!',function(){
  40. Ext.getCmp('grid').getCount(caller,condition);
  41. });
  42. }else if(local.exceptionInfo){
  43. showError(local.exceptionInfo);
  44. }else Ext.Msg.alert('提示','数据生成失败!');
  45. }
  46. });
  47. }
  48. },
  49. 'erpVastDeleteButton': {
  50. click: function(btn){
  51. var dlwin = new Ext.window.Window({
  52. id : 'dlwin',
  53. title: btn.text,
  54. height: "100%",
  55. width: "80%",
  56. maximizable : true,
  57. buttonAlign : 'center',
  58. layout : 'anchor',
  59. items: [{
  60. tag : 'iframe',
  61. frame : true,
  62. anchor : '100% 100%',
  63. layout : 'fit',
  64. html : '<iframe id="iframe_dl_'+caller+'" src="'+basePath+'jsps/common/vastDatalist.jsp?urlcondition='+condition+'&whoami='+caller+'" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>'
  65. }],
  66. buttons : [{
  67. text: btn.text,
  68. iconCls: btn.iconCls,
  69. cls: 'x-btn-gray-1',
  70. handler: function(){
  71. }
  72. },{
  73. text : '关 闭',
  74. iconCls: 'x-button-icon-close',
  75. cls: 'x-btn-gray',
  76. handler : function(){
  77. Ext.getCmp('dlwin').close();
  78. }
  79. }]
  80. });
  81. dlwin.show();
  82. }
  83. }
  84. });
  85. },
  86. onGridItemClick: function(selModel, record){//grid行选择
  87. var me = this;
  88. if(keyField != null && keyField != ''){//有些datalist不需要打开明细表,这些表在datalist表里面不用配dl_keyField
  89. var value = record.data[keyField];
  90. var formCondition = keyField + "IS" + value ;
  91. var gridCondition = pfField + "IS" + value;
  92. var panel = Ext.getCmp(caller + keyField + "=" + value);
  93. var main = parent.Ext.getCmp("content-panel");
  94. if(!panel){
  95. var title = "";
  96. if (value.toString().length>4) {
  97. title = value.toString().substring(value.toString().length-4);
  98. } else {
  99. title = value;
  100. }
  101. var myurl = '';
  102. if(me.BaseUtil.contains(url, '?', true)){
  103. myurl = url + '&formCondition='+formCondition+'&gridCondition='+gridCondition;
  104. } else {
  105. myurl = url + '?formCondition='+formCondition+'&gridCondition='+gridCondition;
  106. }
  107. myurl += "&datalistId=" + main.getActiveTab().id;
  108. main.getActiveTab().currentStore = me.getCurrentStore(value);//用于单据翻页
  109. panel = {
  110. title : me.BaseUtil.getActiveTab().title+'('+title+')',
  111. tag : 'iframe',
  112. tabConfig:{tooltip:me.BaseUtil.getActiveTab().tabConfig.tooltip+'('+keyField + "=" + value+')'},
  113. frame : true,
  114. border : false,
  115. layout : 'fit',
  116. iconCls : 'x-tree-icon-tab-tab1',
  117. html : '<iframe id="iframe_maindetail_'+caller+"_"+value+'" src="' + myurl + '" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>',
  118. closable : true,
  119. listeners : {
  120. close : function(){
  121. main.setActiveTab(main.getActiveTab().id);
  122. }
  123. }
  124. };
  125. this.openTab(panel, caller + keyField + "=" + record.data[keyField]);
  126. }else{
  127. main.setActiveTab(panel);
  128. }
  129. }
  130. },
  131. openTab : function (panel,id){
  132. var o = (typeof panel == "string" ? panel : id || panel.id);
  133. var main = parent.Ext.getCmp("content-panel");
  134. /*var tab = main.getComponent(o); */
  135. if(!main) {
  136. main =parent.parent.Ext.getCmp("content-panel");
  137. }
  138. var tab = main.getComponent(o);
  139. if (tab) {
  140. main.setActiveTab(tab);
  141. } else if(typeof panel!="string"){
  142. panel.id = o;
  143. var p = main.add(panel);
  144. main.setActiveTab(p);
  145. }
  146. },
  147. getCurrentStore: function(value){
  148. var grid = Ext.getCmp('grid');
  149. var items = grid.store.data.items;
  150. var array = new Array();
  151. var o = null;
  152. Ext.each(items, function(item, index){
  153. o = new Object();
  154. o.selected = false;
  155. if(index == 0){
  156. o.prev = null;
  157. } else {
  158. o.prev = items[index-1].data[keyField];
  159. }
  160. if(index == items.length - 1){
  161. o.next = null;
  162. } else {
  163. o.next = items[index+1].data[keyField];
  164. }
  165. var v = item.data[keyField];
  166. o.value = v;
  167. if(v == value)
  168. o.selected = true;
  169. array.push(o);
  170. });
  171. return array;
  172. }
  173. });