ProductWhmonthWarehouse.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.scm.reserve.ProductWhmonthWarehouse', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. views:[
  7. 'scm.reserve.ProductWhmonth','common.datalist.GridPanel','common.datalist.Toolbar','common.batchDeal.Form',
  8. 'core.trigger.DbfindTrigger','core.form.ConDateField','core.form.MonthDateField','core.button.Refresh'
  9. ],
  10. init:function(){
  11. var me = this;
  12. this.control({
  13. 'erpDatalistGridPanel': {
  14. itemclick: this.onGridItemClick,
  15. afterrender:function(grid){
  16. if(Ext.isIE){
  17. document.body.attachEvent('onkeydown', function(){
  18. if(window.event.ctrlKey && window.event.keyCode == 67){//Ctrl + C
  19. var e = window.event;
  20. if(e.srcElement) {
  21. window.clipboardData.setData('text', e.srcElement.innerHTML);
  22. }
  23. }
  24. });
  25. } else {
  26. grid.getEl().dom.addEventListener("mouseover", function(e){
  27. if(e.ctrlKey){
  28. var Contextvalue=e.target.textContent==""?e.target.value:e.target.textContent;
  29. textarea_text = parent.document.getElementById("textarea_text");
  30. textarea_text.value=Contextvalue;
  31. textarea_text.focus();
  32. textarea_text.select();
  33. }
  34. });
  35. }
  36. }
  37. },
  38. 'button[id=export]':{
  39. beforerender:function(btn){
  40. btn.handler=function(){
  41. var grid = Ext.getCmp('grid');
  42. var condition = btn.ownerCt.ownerCt.getCondition(grid),
  43. _con = grid.getCondition();
  44. if(!Ext.isEmpty(_con))
  45. condition += ' and (' + _con + ")";
  46. me.BaseUtil.createExcel(caller, 'datalist', condition, null, null, null, grid);
  47. };
  48. }
  49. },
  50. 'button[id=query]':{
  51. beforerender:function(btn){
  52. btn.handler=function(){
  53. var grid = Ext.getCmp('grid');
  54. var condition = btn.ownerCt.ownerCt.getCondition(grid);
  55. grid.getCount(caller, condition);
  56. };
  57. }
  58. },
  59. 'monthdatefield[name=pwm_yearmonth]':{
  60. beforerender:function(field){
  61. field.autoValue=false;
  62. field.fromnow=false;
  63. me.getCurrentMonth(field);
  64. }
  65. },
  66. 'erpVastDealButton':{
  67. click:function(btn){
  68. var currentMonth= btn.ownerCt.ownerCt.down('monthdatefield').value;
  69. if(!currentMonth) {
  70. showError('期间不能为空!') ;
  71. return
  72. }else{
  73. Ext.Ajax.request({
  74. url:basePath+'scm/product/RefreshProdMonthNew.action',
  75. method:'post',
  76. params:{
  77. currentMonth:currentMonth
  78. },
  79. timeout: 1200000,
  80. callback : function(options,success,response){
  81. me.BaseUtil.getActiveTab().setLoading(false);
  82. var res = new Ext.decode(response.responseText);
  83. if(res.exceptionInfo != null){
  84. showError(res.exceptionInfo);return;
  85. }
  86. Ext.Msg.alert("提示", "刷新成功!", function(){
  87. Ext.getCmp('query').handler();
  88. });
  89. }
  90. });
  91. }
  92. }
  93. }
  94. });
  95. },
  96. onGridItemClick: function(selModel, record){//grid行选择
  97. var me = this;
  98. if(keyField != null && keyField != ''){//有些datalist不需要打开明细表,这些表在datalist表里面不用配dl_keyField
  99. var value = record.data[keyField];
  100. var formCondition = keyField + "IS" + value ;
  101. var gridCondition = pfField + "IS" + value;
  102. var panel = Ext.getCmp(caller + keyField + "=" + value);
  103. var main = parent.Ext.getCmp("content-panel");
  104. if(!main){
  105. main = parent.parent.Ext.getCmp("content-panel");
  106. }
  107. if(!panel){
  108. var title = "";
  109. if (value.toString().length>4) {
  110. title = value.toString().substring(value.toString().length-4);
  111. } else {
  112. title = value;
  113. }
  114. var myurl = '';
  115. if(me.BaseUtil.contains(url, '?', true)){
  116. myurl = url + '&formCondition='+formCondition+'&gridCondition='+gridCondition;
  117. } else {
  118. myurl = url + '?formCondition='+formCondition+'&gridCondition='+gridCondition;
  119. }
  120. myurl += "&datalistId=" + main.getActiveTab().id;
  121. main.getActiveTab().currentStore = me.getCurrentStore(value);//用于单据翻页
  122. panel = {
  123. title : me.BaseUtil.getActiveTab().title+'('+title+')',
  124. tag : 'iframe',
  125. tabConfig:{tooltip:me.BaseUtil.getActiveTab().tabConfig.tooltip+'('+keyField + "=" + value+')'},
  126. frame : true,
  127. border : false,
  128. layout : 'fit',
  129. iconCls : 'x-tree-icon-tab-tab1',
  130. html : '<iframe id="iframe_maindetail_'+caller+"_"+value+'" src="' + myurl + '" height="100%" width="100%" frameborder="0" style="border-width: 0px;padding: 0px;" scrolling="auto"></iframe>',
  131. closable : true,
  132. listeners : {
  133. close : function(){
  134. if(!main){
  135. main = parent.parent.Ext.getCmp("content-panel");
  136. }
  137. main.setActiveTab(main.getActiveTab().id);
  138. }
  139. }
  140. };
  141. this.openTab(panel, caller + keyField + "=" + record.data[keyField]);
  142. }else{
  143. main.setActiveTab(panel);
  144. }
  145. }
  146. },
  147. openTab : function (panel,id){
  148. var o = (typeof panel == "string" ? panel : id || panel.id);
  149. var main = parent.Ext.getCmp("content-panel");
  150. if(!main) {
  151. main =parent.parent.Ext.getCmp("content-panel");
  152. }
  153. var tab = main.getComponent(o);
  154. if (tab) {
  155. main.setActiveTab(tab);
  156. } else if(typeof panel!="string"){
  157. panel.id = o;
  158. var p = main.add(panel);
  159. main.setActiveTab(p);
  160. }
  161. },
  162. getCurrentMonth: function(f) {
  163. Ext.Ajax.request({
  164. url: basePath + 'fa/getMonth.action',
  165. params: {
  166. type: 'MONTH-P'
  167. },
  168. callback: function(opt, s, r) {
  169. var rs = Ext.decode(r.responseText);
  170. if(rs.data) {
  171. f.setValue(rs.data.PD_DETNO);
  172. }
  173. }
  174. });
  175. },
  176. getCurrentStore: function(value){
  177. var grid = Ext.getCmp('grid');
  178. var items = grid.store.data.items;
  179. var array = new Array();
  180. var o = null;
  181. Ext.each(items, function(item, index){
  182. o = new Object();
  183. o.selected = false;
  184. if(index == 0){
  185. o.prev = null;
  186. } else {
  187. o.prev = items[index-1].data[keyField];
  188. }
  189. if(index == items.length - 1){
  190. o.next = null;
  191. } else {
  192. o.next = items[index+1].data[keyField];
  193. }
  194. var v = item.data[keyField];
  195. o.value = v;
  196. if(v == value)
  197. o.selected = true;
  198. array.push(o);
  199. });
  200. return array;
  201. },
  202. });