CheckQuery.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.common.CheckQuery', {
  3. extend : 'Ext.app.Controller',
  4. views : ['common.query.Viewport', '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' ],
  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. itemclick : this.onGridItemClick
  58. },
  59. 'monthdatefield': {
  60. afterrender: function(f) {
  61. var type = '';
  62. if(f.name == 'cd_yearmonth') {
  63. type = 'MONTH-T';
  64. }
  65. if(f.name == 'cmc_yearmonth') {
  66. type = 'MONTH-A';
  67. }
  68. if(f.name == 'cm_yearmonth') {
  69. type = 'MONTH-A';
  70. }
  71. if(f.name == 'am_yearmonth') {
  72. type = 'MONTH-B';
  73. }
  74. if(type != '' && Ext.isEmpty(getUrlParam(f.name))) {
  75. this.getCurrentMonth(f, type);
  76. }
  77. }
  78. },
  79. 'conmonthdatefield': {
  80. afterrender: function(f) {
  81. var type = '';
  82. if(f.name == 'cd_yearmonth') {
  83. type = 'MONTH-T';
  84. }
  85. if(f.name == 'cmc_yearmonth') {
  86. type = 'MONTH-A';
  87. }
  88. if(f.name == 'cm_yearmonth') {
  89. type = 'MONTH-A';
  90. }
  91. if(f.name == 'am_yearmonth') {
  92. type = 'MONTH-B';
  93. }
  94. if(type != '' && Ext.isEmpty(getUrlParam(f.name))) {
  95. this.getCurrentMonth(f, type);
  96. }
  97. }
  98. }
  99. });
  100. },
  101. onGridItemClick : function(selModel, record) {
  102. if (caller == 'CustMonth!ARLI!Query') {
  103. var cmid = record.data['cm_id'];
  104. if (cmid > 0) {
  105. var panel = Ext.getCmp(caller + "cm_id" + "=" + cmid);
  106. var main = parent.Ext.getCmp("content-panel");
  107. if (!main) {
  108. main = parent.parent.Ext.getCmp("content-panel");
  109. }
  110. if (!panel) {
  111. var title = "";
  112. if (value.toString().length > 4) {
  113. title = value.toString().substring(value.toString().length - 4);
  114. } else {
  115. title = value;
  116. }
  117. var myurl = '';
  118. if (me.BaseUtil.contains(url, '?', true)) {
  119. myurl = url + '&formCondition=' + formCondition + '&gridCondition=' + gridCondition;
  120. } else {
  121. myurl = url + '?formCondition=' + formCondition + '&gridCondition=' + gridCondition;
  122. }
  123. myurl += "&datalistId=" + main.getActiveTab().id;
  124. main.getActiveTab().currentStore = me.getCurrentStore(value);// 用于单据翻页
  125. panel = {
  126. title : me.BaseUtil.getActiveTab().title + '(' + title + ')',
  127. tag : 'iframe',
  128. tabConfig : {
  129. tooltip : me.BaseUtil.getActiveTab().tabConfig.tooltip + '(' + keyField + "=" + value + ')'
  130. },
  131. frame : true,
  132. border : false,
  133. layout : 'fit',
  134. iconCls : 'x-tree-icon-tab-tab1',
  135. html : '<iframe id="iframe_maindetail_' + caller + "_" + value + '" src="' + myurl
  136. + '" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>',
  137. closable : true,
  138. listeners : {
  139. close : function() {
  140. if (!main) {
  141. main = parent.parent.Ext.getCmp("content-panel");
  142. }
  143. main.setActiveTab(main.getActiveTab().id);
  144. }
  145. }
  146. };
  147. this.openTab(panel, caller + keyField + "=" + record.data[keyField]);
  148. } else {
  149. main.setActiveTab(panel);
  150. }
  151. }
  152. }
  153. if(caller=='Sale!saledetailDet'){
  154. this.schedule(record);
  155. }
  156. },
  157. schedule: function(record) {
  158. var width = Ext.isIE ? screen.width*0.7*0.9 : '80%',
  159. height = Ext.isIE ? screen.height*0.75 : '100%';
  160. var sd_id = record.get('sd_id');
  161. Ext.Ajax.request({
  162. url : basePath + "scm/sale/checkSaleDetailDet.action",
  163. params: {
  164. whereString: "sd_id="+sd_id
  165. },
  166. method : 'post',
  167. async: false,
  168. callback:function(options,success,response){
  169. var res = new Ext.decode(response.responseText);
  170. if(res.exceptionInfo){
  171. showError(res.exceptionInfo);return;
  172. }
  173. }
  174. });
  175. Ext.create('Ext.Window', {
  176. width: width,
  177. height: height,
  178. autoShow: true,
  179. layout: 'anchor',
  180. items: [{
  181. tag : 'iframe',
  182. frame : true,
  183. anchor : '100% 100%',
  184. layout : 'fit',
  185. html : '<iframe id="iframe_dbfind" src="' + basePath + 'jsps/scm/sale/saleDetail.jsp?formCondition=sd_id='
  186. + sd_id + '&gridCondition=sdd_sdid=' + sd_id + '" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  187. }]
  188. });
  189. },
  190. getForm: function(btn){
  191. return btn.ownerCt.ownerCt;
  192. },
  193. getCurrentMonth: function(f, type) {
  194. Ext.Ajax.request({
  195. url: basePath + 'fa/getMonth.action',
  196. params: {
  197. type: type
  198. },
  199. callback: function(opt, s, r) {
  200. var rs = Ext.decode(r.responseText);
  201. if(rs.data) {
  202. f.setValue(rs.data.PD_DETNO);
  203. }
  204. }
  205. });
  206. }
  207. });