YeardisingQuery.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.crm.marketmgr.annualPlans.YeardisingQuery', {
  3. extend : 'Ext.app.Controller',
  4. views : [ 'common.query.Viewport', 'common.query.GridPanel', 'common.query.Form', 'core.trigger.DbfindTrigger',
  5. 'core.form.FtField', 'core.form.ConDateField', 'core.form.YnField', 'core.form.FtDateField','core.form.YearDateField',
  6. 'core.form.MonthDateField','core.form.FtFindField', 'core.grid.YnColumn', 'core.grid.TfColumn',
  7. 'core.form.ConMonthDateField', 'core.trigger.TextAreaTrigger' ],
  8. init : function() {
  9. var me=this;
  10. this.control({
  11. 'erpQueryFormPanel' : {
  12. alladded : function(form) {
  13. var items = form.items.items, autoQuery = false;
  14. Ext.each(items, function() {
  15. var val = getUrlParam(this.name);
  16. if(!Ext.isEmpty(val)) {
  17. this.setValue(val);
  18. autoQuery = true;
  19. if(this.xtype == 'dbfindtrigger') {
  20. this.autoDbfind('form', caller, this.name, this.name + " like '%" + val + "%'");
  21. }
  22. }
  23. });
  24. if(autoQuery) {
  25. setTimeout(function(){
  26. form.onQuery();
  27. }, 1000);
  28. }
  29. }
  30. },
  31. 'erpQueryGridPanel' : {
  32. itemclick : this.onGridItemClick,
  33. storeloaded: function (grid){
  34. var data=grid.store.prefetchData;
  35. var o=new Object();
  36. for(var i=1;i<13;i++){
  37. o['mhd_total'+i]=0;
  38. o['mhd_qty'+i]=0;
  39. }
  40. o['mhd_sumtotal']=0;
  41. o['mhd_sumqty']=0;
  42. o['mhd_prodcode']='合计';
  43. Ext.Array.each(data.items,function(item,index){
  44. if(item.data.mhd_id){
  45. o['mhd_total1']+=Number(item.data['mhd_total1']);
  46. o['mhd_total2']+=Number(item.data['mhd_total2']);
  47. o['mhd_total3']+=Number(item.data['mhd_total3']);
  48. o['mhd_total4']+=Number(item.data['mhd_total4']);
  49. o['mhd_total5']+=Number(item.data['mhd_total5']);
  50. o['mhd_total6']+=Number(item.data['mhd_total6']);
  51. o['mhd_total7']+=Number(item.data['mhd_total7']);
  52. o['mhd_total8']+=Number(item.data['mhd_total8']);
  53. o['mhd_total9']+=Number(item.data['mhd_total9']);
  54. o['mhd_total10']+=Number(item.data['mhd_total10']);
  55. o['mhd_total11']+=Number(item.data['mhd_total11']);
  56. o['mhd_total12']+=Number(item.data['mhd_total12']);
  57. o['mhd_qty1']+=Number(item.data['mhd_qty1']);
  58. o['mhd_qty2']+=Number(item.data['mhd_qty2']);
  59. o['mhd_qty3']+=Number(item.data['mhd_qty3']);
  60. o['mhd_qty4']+=Number(item.data['mhd_qty4']);
  61. o['mhd_qty5']+=Number(item.data['mhd_qty5']);
  62. o['mhd_qty6']+=Number(item.data['mhd_qty6']);
  63. o['mhd_qty7']+=Number(item.data['mhd_qty7']);
  64. o['mhd_qty8']+=Number(item.data['mhd_qty8']);
  65. o['mhd_qty9']+=Number(item.data['mhd_qty9']);
  66. o['mhd_qty10']+=Number(item.data['mhd_qty10']);
  67. o['mhd_qty11']+=Number(item.data['mhd_qty11']);
  68. o['mhd_qty12']+=Number(item.data['mhd_qty12']);
  69. o['mhd_sumqty']+=Number(item.data['mhd_sumqty']);
  70. o['mhd_sumtotal']+=Number(item.data['mhd_sumtotal']);
  71. }
  72. });
  73. grid.store.insert(0,o);
  74. grid.getView().addRowCls(0,'custom-alt');
  75. }
  76. },
  77. 'monthdatefield': {
  78. afterrender: function(f) {
  79. var type = '';
  80. if(f.name == 'cd_yearmonth') {
  81. type = 'MONTH-T';
  82. }
  83. if(f.name == 'cmc_yearmonth') {
  84. type = 'MONTH-A';
  85. }
  86. if(f.name == 'cm_yearmonth') {
  87. type = 'MONTH-A';
  88. }
  89. if(type != '' && Ext.isEmpty(getUrlParam(f.name))) {
  90. this.getCurrentMonth(f, type);
  91. }
  92. }
  93. }
  94. });
  95. },
  96. onGridItemClick : function(selModel, record) {
  97. if (caller == 'CustMonth!ARLI!Query') {
  98. var cmid = record.data['cm_id'];
  99. if (cmid > 0) {
  100. var panel = Ext.getCmp(caller + "cm_id" + "=" + cmid);
  101. var main = parent.Ext.getCmp("content-panel");
  102. if (!main) {
  103. main = parent.parent.Ext.getCmp("content-panel");
  104. }
  105. if (!panel) {
  106. var title = "";
  107. if (value.toString().length > 4) {
  108. title = value.toString().substring(value.toString().length - 4);
  109. } else {
  110. title = value;
  111. }
  112. var myurl = '';
  113. if (me.BaseUtil.contains(url, '?', true)) {
  114. myurl = url + '&formCondition=' + formCondition + '&gridCondition=' + gridCondition;
  115. } else {
  116. myurl = url + '?formCondition=' + formCondition + '&gridCondition=' + gridCondition;
  117. }
  118. myurl += "&datalistId=" + main.getActiveTab().id;
  119. main.getActiveTab().currentStore = me.getCurrentStore(value);// 用于单据翻页
  120. panel = {
  121. title : me.BaseUtil.getActiveTab().title + '(' + title + ')',
  122. tag : 'iframe',
  123. tabConfig : {
  124. tooltip : me.BaseUtil.getActiveTab().tabConfig.tooltip + '(' + keyField + "=" + value + ')'
  125. },
  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
  131. + '" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>',
  132. closable : true,
  133. listeners : {
  134. close : function() {
  135. if (!main) {
  136. main = parent.parent.Ext.getCmp("content-panel");
  137. }
  138. main.setActiveTab(main.getActiveTab().id);
  139. }
  140. }
  141. };
  142. this.openTab(panel, caller + keyField + "=" + record.data[keyField]);
  143. } else {
  144. main.setActiveTab(panel);
  145. }
  146. }
  147. }
  148. if(caller=='Sale!saledetailDet'){
  149. this.schedule(record);
  150. }
  151. },
  152. schedule: function(record) {
  153. var width = Ext.isIE ? screen.width*0.7*0.9 : '80%',
  154. height = Ext.isIE ? screen.height*0.75 : '100%';
  155. var sd_id = record.get('sd_id');
  156. Ext.Ajax.request({
  157. url : basePath + "scm/sale/checkSaleDetailDet.action",
  158. params: {
  159. whereString: "sd_id="+sd_id
  160. },
  161. method : 'post',
  162. async: false,
  163. callback:function(options,success,response){
  164. var res = new Ext.decode(response.responseText);
  165. if(res.exceptionInfo){
  166. showError(res.exceptionInfo);return;
  167. }
  168. }
  169. });
  170. Ext.create('Ext.Window', {
  171. width: width,
  172. height: height,
  173. autoShow: true,
  174. layout: 'anchor',
  175. items: [{
  176. tag : 'iframe',
  177. frame : true,
  178. anchor : '100% 100%',
  179. layout : 'fit',
  180. html : '<iframe id="iframe_dbfind" src="' + basePath + 'jsps/scm/sale/saleDetail.jsp?formCondition=sd_id='
  181. + sd_id + '&gridCondition=sdd_sdid=' + sd_id + '" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  182. }]
  183. });
  184. },
  185. getCurrentMonth: function(f, type) {
  186. Ext.Ajax.request({
  187. url: basePath + 'fa/getMonth.action',
  188. params: {
  189. type: type
  190. },
  191. callback: function(opt, s, r) {
  192. var rs = Ext.decode(r.responseText);
  193. if(rs.data) {
  194. f.setValue(rs.data.PD_DETNO);
  195. }
  196. }
  197. });
  198. }
  199. });