QueryQ.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.common.QueryQ', {
  3. extend : 'Ext.app.Controller',
  4. views : ['common.query.ViewportQ', 'common.query.GridPanel', 'common.query.CheckForm', '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', 'core.button.Refresh',
  7. 'core.form.ConMonthDateField', 'core.trigger.TextAreaTrigger','core.form.ConDateHourMinuteFieldQ','core.form.ConDateHourMinuteField'],
  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. 'button[name=refresh]':{
  32. click: function(btn){
  33. var form = me.getForm(btn);
  34. if (caller == 'ALMonth!Query'){
  35. var month = Ext.getCmp('am_yearmonth');
  36. var condition=month.secondVal;
  37. Ext.Ajax.request({
  38. url: basePath + 'fa/ars/CmQueryController/refreshQuery.action',
  39. params: {
  40. condition:condition
  41. },
  42. method: 'post',
  43. callback: function(opt, s, r) {
  44. var rs = Ext.decode(r.responseText);
  45. if(rs.success) {
  46. form.onQuery();
  47. }else{
  48. }
  49. }
  50. });
  51. }else{
  52. form.onQuery();
  53. }
  54. }
  55. },
  56. 'erpQueryGridPanel' : {
  57. storeloaded: function(grid){
  58. me.getProductWh(grid);
  59. }
  60. },
  61. 'monthdatefield': {
  62. afterrender: function(f) {
  63. var type = '';
  64. if(f.name == 'cd_yearmonth') {
  65. type = 'MONTH-T';
  66. }
  67. if(f.name == 'cmc_yearmonth') {
  68. type = 'MONTH-A';
  69. }
  70. if(f.name == 'cm_yearmonth') {
  71. type = 'MONTH-A';
  72. }
  73. if(f.name == 'am_yearmonth') {
  74. type = 'MONTH-B';
  75. }
  76. if(type != '' && Ext.isEmpty(getUrlParam(f.name))) {
  77. this.getCurrentMonth(f, type);
  78. }
  79. }
  80. },
  81. 'conmonthdatefield': {
  82. afterrender: function(f) {
  83. var type = '';
  84. if(f.name == 'cd_yearmonth') {
  85. type = 'MONTH-T';
  86. }
  87. if(f.name == 'cmc_yearmonth') {
  88. type = 'MONTH-A';
  89. }
  90. if(f.name == 'cm_yearmonth') {
  91. type = 'MONTH-A';
  92. }
  93. if(f.name == 'am_yearmonth') {
  94. type = 'MONTH-B';
  95. }
  96. if(type != '' && Ext.isEmpty(getUrlParam(f.name))) {
  97. this.getCurrentMonth(f, type);
  98. }
  99. }
  100. }
  101. });
  102. },
  103. onGridItemClick : function(selModel, record) {
  104. if (caller == 'CustMonth!ARLI!Query') {
  105. var cmid = record.data['cm_id'];
  106. if (cmid > 0) {
  107. var panel = Ext.getCmp(caller + "cm_id" + "=" + cmid);
  108. var main = parent.Ext.getCmp("content-panel");
  109. if (!main) {
  110. main = parent.parent.Ext.getCmp("content-panel");
  111. }
  112. if (!panel) {
  113. var title = "";
  114. if (value.toString().length > 4) {
  115. title = value.toString().substring(value.toString().length - 4);
  116. } else {
  117. title = value;
  118. }
  119. var myurl = '';
  120. if (me.BaseUtil.contains(url, '?', true)) {
  121. myurl = url + '&formCondition=' + formCondition + '&gridCondition=' + gridCondition;
  122. } else {
  123. myurl = url + '?formCondition=' + formCondition + '&gridCondition=' + gridCondition;
  124. }
  125. myurl += "&datalistId=" + main.getActiveTab().id;
  126. main.getActiveTab().currentStore = me.getCurrentStore(value);// 用于单据翻页
  127. panel = {
  128. title : me.BaseUtil.getActiveTab().title + '(' + title + ')',
  129. tag : 'iframe',
  130. tabConfig : {
  131. tooltip : me.BaseUtil.getActiveTab().tabConfig.tooltip + '(' + keyField + "=" + value + ')'
  132. },
  133. frame : true,
  134. border : false,
  135. layout : 'fit',
  136. iconCls : 'x-tree-icon-tab-tab1',
  137. html : '<iframe id="iframe_maindetail_' + caller + "_" + value + '" src="' + myurl
  138. + '" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>',
  139. closable : true,
  140. listeners : {
  141. close : function() {
  142. if (!main) {
  143. main = parent.parent.Ext.getCmp("content-panel");
  144. }
  145. main.setActiveTab(main.getActiveTab().id);
  146. }
  147. }
  148. };
  149. this.openTab(panel, caller + keyField + "=" + record.data[keyField]);
  150. } else {
  151. main.setActiveTab(panel);
  152. }
  153. }
  154. }
  155. if(caller=='Sale!saledetailDet'){
  156. this.schedule(record);
  157. }
  158. },
  159. schedule: function(record) {
  160. var width = Ext.isIE ? screen.width*0.7*0.9 : '80%',
  161. height = Ext.isIE ? screen.height*0.75 : '100%';
  162. var sd_id = record.get('sd_id');
  163. Ext.Ajax.request({
  164. url : basePath + "scm/sale/checkSaleDetailDet.action",
  165. params: {
  166. whereString: "sd_id="+sd_id
  167. },
  168. method : 'post',
  169. async: false,
  170. callback:function(options,success,response){
  171. var res = new Ext.decode(response.responseText);
  172. if(res.exceptionInfo){
  173. showError(res.exceptionInfo);return;
  174. }
  175. }
  176. });
  177. Ext.create('Ext.Window', {
  178. width: width,
  179. height: height,
  180. autoShow: true,
  181. layout: 'anchor',
  182. items: [{
  183. tag : 'iframe',
  184. frame : true,
  185. anchor : '100% 100%',
  186. layout : 'fit',
  187. html : '<iframe id="iframe_dbfind" src="' + basePath + 'jsps/scm/sale/saleDetail.jsp?formCondition=sd_id='
  188. + sd_id + '&gridCondition=sdd_sdid=' + sd_id + '" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  189. }]
  190. });
  191. },
  192. getForm: function(btn){
  193. return btn.ownerCt.ownerCt;
  194. },
  195. getCurrentMonth: function(f, type) {
  196. Ext.Ajax.request({
  197. url: basePath + 'fa/getMonth.action',
  198. params: {
  199. type: type
  200. },
  201. callback: function(opt, s, r) {
  202. var rs = Ext.decode(r.responseText);
  203. if(rs.data) {
  204. f.setValue(rs.data.PD_DETNO);
  205. }
  206. }
  207. });
  208. },
  209. getProductWh: function(grid) {
  210. var prodfield = 'pr_code';
  211. if(prodfield) {
  212. var codes = [];
  213. grid.store.each(function(d){
  214. codes.push("'" + d.get(prodfield) + "'");
  215. });
  216. Ext.Ajax.request({
  217. url: basePath + 'scm/product/getProductwh.action',
  218. params: {
  219. codes: codes.join(',')
  220. },
  221. callback: function (opt, s, r) {
  222. if(s) {
  223. var rs = Ext.decode(r.responseText);
  224. if(rs.data) {
  225. grid.productwh = rs.data;
  226. }
  227. }
  228. }
  229. });
  230. }
  231. }
  232. });