SmQuery.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.fa.ars.SmQuery', {
  3. extend: 'Ext.app.Controller',
  4. requires: ['erp.util.BaseUtil'],
  5. GridUtil: Ext.create('erp.util.GridUtil'),
  6. condition:'',
  7. views:[
  8. 'fa.ars.SmQuery', 'core.grid.Panel2', 'core.trigger.DbfindTrigger','core.form.FtField','core.form.ConDateField','core.form.YnField',
  9. 'core.form.FtDateField','core.form.FtFindField','core.grid.YnColumn','core.grid.TfColumn','core.form.ConMonthDateField'
  10. ],
  11. refs : [ {
  12. selector : 'tbtext[name=info]',
  13. ref : 'info'
  14. } , {
  15. selector : '#grid',
  16. ref : 'grid'
  17. }],
  18. init:function(){
  19. var me = this;
  20. me.BaseUtil = Ext.create('erp.util.BaseUtil');
  21. this.control({
  22. '#grid': {
  23. itemclick: function() {
  24. }
  25. },
  26. 'button[name=query]' : {
  27. delay: 200,
  28. afterrender : function(btn) {
  29. me.createFilterPanel(btn).show();
  30. },
  31. click: function() {
  32. var f = me.filter;
  33. if(f) {
  34. f[f.hidden ? 'show' : 'hide'].call(f);
  35. }
  36. }
  37. },
  38. 'button[name=export]' : {
  39. click : function() {
  40. this.BaseUtil.exportGrid(this.getGrid());
  41. }
  42. },
  43. 'button[name=print]' : {
  44. click : function() {
  45. }
  46. },
  47. 'button[name=refresh]' : {
  48. click: function(btn){
  49. me.getGrid().setLoading(true);
  50. Ext.Ajax.request({
  51. url: basePath + 'fa/ars/CmQueryController/refreshCmQuery.action',
  52. method: 'GET',
  53. callback: function(opt, s, r) {
  54. me.getGrid().setLoading(false);
  55. me.query(me.getCondition());
  56. }
  57. });
  58. }
  59. }
  60. });
  61. },
  62. createYearmonthField: function() {
  63. var me = this;
  64. return Ext.create('erp.view.core.form.ConMonthDateField', {
  65. id: 'cm_yearmonth',
  66. name: 'cm_yearmonth',
  67. fieldLabel: '期间',
  68. labelWidth: 80,
  69. getValue: function() {
  70. if(!Ext.isEmpty(this.value)) {
  71. return {begin: this.firstVal, end: this.secondVal};
  72. }
  73. return null;
  74. },
  75. listeners:{
  76. afterrender:function(cmd){
  77. me.getCurrentYearmonth(cmd);
  78. }
  79. }
  80. });
  81. },
  82. createCurrencyField: function() {
  83. return Ext.create('erp.view.core.trigger.DbfindTrigger', {
  84. fieldLabel: '币别',
  85. labelWidth: 80,
  86. id: 'cm_currency',
  87. name:'cm_currency'
  88. });
  89. },
  90. createCustomerField: function() {
  91. return Ext.create('Ext.form.FieldContainer', {
  92. fieldLabel: '客户编码',
  93. labelWidth: 80,
  94. height: 23,
  95. layout: 'hbox',
  96. columnWidth: 1,
  97. xtype: 'fieldcontainer',
  98. id: 'cmq_custcode',
  99. defaults: {
  100. fieldStyle : "background:#FFFAFA;color:#515151;"
  101. },
  102. items: [{
  103. labelWidth: 35,
  104. xtype: 'dbfindtrigger',
  105. flex: 0.32,
  106. id: 'cm_custcode',
  107. name: 'cm_custcode'
  108. },{
  109. xtype: 'textfield',
  110. id: 'cm_custname',
  111. name: 'cm_custname',
  112. flex:0.32,
  113. readOnly: true,
  114. fieldStyle: 'background:#f1f1f1;'
  115. }],
  116. getValue: function() {
  117. var a = Ext.getCmp('cm_custcode');
  118. if(!Ext.isEmpty(a.value)) {
  119. return {cm_custcode: a.value};
  120. }
  121. return null;
  122. }
  123. });
  124. },
  125. createDeptField: function() {
  126. return Ext.create('Ext.form.FieldContainer', {
  127. fieldLabel: '部门',
  128. labelWidth: 80,
  129. height: 23,
  130. layout: 'hbox',
  131. columnWidth: 1,
  132. xtype: 'fieldcontainer',
  133. defaults: {
  134. fieldStyle : "background:#FFFAFA;color:#515151;"
  135. },
  136. id: 'em_depart',
  137. items: [{
  138. labelWidth: 35,
  139. xtype: 'dbfindtrigger',
  140. flex: 0.32,
  141. id: 'dp_code',
  142. name: 'dp_code'
  143. },{
  144. xtype: 'textfield',
  145. id: 'dp_name',
  146. name: 'dp_name',
  147. flex:0.32,
  148. readOnly: true,
  149. fieldStyle: 'background:#f1f1f1;'
  150. }],
  151. getValue: function() {
  152. var a = Ext.getCmp('dp_code');
  153. if(!Ext.isEmpty(a.value)) {
  154. return a.value;
  155. }
  156. return null;
  157. }
  158. });
  159. },
  160. createSellerField: function() {
  161. return Ext.create('Ext.form.FieldContainer', {
  162. fieldLabel: '业务员编码',
  163. labelWidth: 80,
  164. height: 23,
  165. layout: 'hbox',
  166. columnWidth: 1,
  167. xtype: 'fieldcontainer',
  168. id: 'cmq_sellercode',
  169. defaults: {
  170. fieldStyle : "background:#FFFAFA;color:#515151;"
  171. },
  172. items: [{
  173. labelWidth: 35,
  174. xtype: 'dbfindtrigger',
  175. flex: 0.32,
  176. id: 'sa_sellercode',
  177. name: 'sa_sellercode'
  178. },{
  179. xtype: 'textfield',
  180. id: 'sa_seller',
  181. name: 'sa_seller',
  182. flex:0.32,
  183. readOnly: true,
  184. fieldStyle: 'background:#f1f1f1;'
  185. }],
  186. getValue: function() {
  187. var a = Ext.getCmp('sa_sellercode');
  188. if(!Ext.isEmpty(a.value)) {
  189. return {sa_sellercode: a.value};
  190. }
  191. return null;
  192. }
  193. });
  194. },
  195. createFilterPanel:function(btn){
  196. var me = this;
  197. me.filter = Ext.create('Ext.window.Window', {
  198. id: btn.getId() + '-filter',
  199. style: 'background:#f1f1f1',
  200. title: '筛选条件',
  201. closeAction: 'hide',
  202. width: 500,
  203. height: 385,
  204. layout: 'column',
  205. defaults: {
  206. columnWidth: .51,
  207. margin: '10 2 2 10'
  208. },
  209. items: [me.createYearmonthField(), me.createCurrencyField(), me.createCustomerField(),
  210. me.createDeptField(), me.createSellerField(), {
  211. xtype: 'checkbox',
  212. id: 'chkumio',
  213. boxLabel: '包含未开票未转发出商品出货'
  214. },{
  215. xtype: 'checkbox',
  216. id: 'chkzerobalance',
  217. boxLabel: '余额为零的不显示'
  218. },{
  219. xtype: 'checkbox',
  220. id: 'chknoamount',
  221. boxLabel: '无发生额的不显示'
  222. },{
  223. xtype: 'checkbox',
  224. id: 'chkstatis',
  225. checked: true,
  226. boxLabel: '是否显示汇总数'
  227. }],
  228. buttonAlign: 'center',
  229. buttons: [{
  230. text: '确定',
  231. width: 60,
  232. cls: 'x-btn-blue',
  233. handler: function(btn) {
  234. var w = btn.ownerCt.ownerCt;
  235. me.query(me.getCondition(w));
  236. w.hide();
  237. }
  238. },{
  239. text: '关闭',
  240. width: 60,
  241. cls: 'x-btn-blue',
  242. handler: function(b) {
  243. b.ownerCt.ownerCt.hide();
  244. }
  245. }]
  246. });
  247. return me.filter;
  248. },
  249. getCondition: function(w) {
  250. w = w || this.filter;
  251. var r = new Object(),v;
  252. Ext.each(w.items.items, function(item){
  253. if(typeof item.getValue === 'function') {
  254. v = item.getValue();
  255. if(!Ext.isEmpty(v)) {
  256. r[item.id] = v;
  257. }
  258. }
  259. });
  260. this.getInfo().update(r);
  261. return r;
  262. },
  263. query: function(cond) {
  264. var grid = this.getGrid();
  265. grid.setLoading(true);
  266. Ext.Ajax.request({
  267. url: basePath + 'fa/ars/CmQueryController/getSmQuery.action',
  268. params: {
  269. condition: Ext.encode(cond)
  270. },
  271. callback : function(o, s, r){
  272. grid.setLoading(false);
  273. var rs = new Ext.decode(r.responseText);
  274. if(rs.exceptionInfo){
  275. showError(rs.exceptionInfo);return;
  276. }
  277. if (rs.data) {
  278. grid.store.loadData(rs.data);
  279. }
  280. }
  281. });
  282. },
  283. getCurrentYearmonth: function(f) {
  284. Ext.Ajax.request({
  285. url: basePath + 'fa/getMonth.action',
  286. params: {
  287. type: 'MONTH-C'
  288. },
  289. callback: function(opt, s, r) {
  290. var rs = Ext.decode(r.responseText);
  291. if(rs.data) {
  292. f.setValue(rs.data.PD_DETNO);
  293. }
  294. }
  295. });
  296. }
  297. });