Query.js 6.6 KB

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