DeptDetail.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.fa.gla.DeptDetail', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. views: ['core.trigger.DbfindTrigger', 'fa.gla.DeptDetail', 'fa.gla.LedgerDeptDetail', 'core.form.MonthDateField', 'core.trigger.CateTreeDbfindTrigger',
  7. 'core.form.ConMonthDateField', 'core.form.ConDateField', 'core.form.YearDateField', 'core.trigger.MultiDbfindTrigger'],
  8. init:function(){
  9. var me = this;
  10. this.control({
  11. 'button[id=query]': {
  12. afterrender: function(btn) {
  13. setTimeout(function(){
  14. me.showFilterPanel(btn);
  15. me.getCateSetting();
  16. var fl = Ext.getCmp('query-filter'),
  17. con = me.getCondition(fl);
  18. con.querytype = 'current';
  19. me.query(con);
  20. }, 200);
  21. },
  22. click: function(btn) {
  23. me.showFilterPanel(btn);
  24. }
  25. },
  26. 'ledgerdeptdetail': {
  27. itemclick: function(selModel, record) {
  28. me.loadVoucher(record);
  29. }
  30. },
  31. 'button[name=export]': {
  32. click: function() {
  33. var grid = Ext.getCmp('ledgerdept');
  34. me.BaseUtil.exportGrid(grid, '部门明细账');
  35. }
  36. }
  37. });
  38. },
  39. getCateSetting : function() {
  40. var me = this;
  41. Ext.Ajax.request({
  42. url : basePath + 'common/getFieldData.action',
  43. params: {
  44. caller: 'Setting',
  45. field: 'se_value',
  46. condition: 'se_what=\'CateTreeSearch\''
  47. },
  48. method : 'post',
  49. async : false,
  50. callback : function(opt, s, res){
  51. var r = new Ext.decode(res.responseText);
  52. if(r.exceptionInfo){
  53. showError(r.exceptionInfo);
  54. } else if(r.success && r.data == 'true' ){
  55. me.CateTreeSearch = true;
  56. }
  57. }
  58. });
  59. },
  60. showFilterPanel: function(btn, ym, caCode, dpCode , un) {
  61. var filter = Ext.getCmp(btn.getId() + '-filter');
  62. if(!filter) {
  63. filter = this.createFilterPanel(btn);
  64. }
  65. filter.show();
  66. if(ym && ym != 'undefined') {
  67. filter.down('#asl_yearmonth').setValue(ym);
  68. filter.hide();
  69. }
  70. if(caCode && caCode != 'undefined') {
  71. filter.down('#ca_code').setValue(caCode);
  72. this.catecode = caCode;//当前科目
  73. }
  74. if(dpCode && dpCode != 'undefined') {
  75. filter.down('#dp_code').setValue(dpCode);
  76. this.deptcode = dpCode;//当前部门
  77. }
  78. if(un && un != 'undefined') {
  79. filter.down('#chkhaveun').setValue(un);
  80. }
  81. },
  82. hideFilterPanel: function(btn) {
  83. var filter = Ext.getCmp(btn.getId() + '-filter');
  84. if(filter) {
  85. filter.hide();
  86. }
  87. },
  88. query: function(cond) {
  89. console.log(cond);
  90. var me = this,
  91. grid = Ext.getCmp('ledgerdept');
  92. grid.setLoading(true);
  93. Ext.Ajax.request({
  94. url: basePath + 'fa/ars/getDeptDetail.action',
  95. params: {
  96. condition: Ext.encode(cond)
  97. },
  98. callback: function(opt, s, r) {
  99. var res = Ext.decode(r.responseText);
  100. if(grid && res.data) {
  101. grid.store.loadData(res.data);
  102. }
  103. grid.setLoading(false);
  104. }
  105. });
  106. },
  107. getCondition: function(pl) {
  108. console.log(pl);
  109. var r = new Object(),v;
  110. Ext.each(pl.items.items, function(item){
  111. if(item.getValue !== undefined) {
  112. v = item.getValue();
  113. if(!Ext.isEmpty(v)) {
  114. r[item.id] = v;
  115. }
  116. }
  117. });
  118. if(this.catecode) {
  119. r.catecode = this.catecode;
  120. }
  121. return r;
  122. },
  123. _updateInfo: function(r) {
  124. var tb = Ext.getCmp('gl_info_ym');
  125. if(tb)
  126. tb.updateInfo(r);
  127. tb = Ext.getCmp('gl_info_c');
  128. if(tb)
  129. tb.updateInfo(r);
  130. tb = Ext.getCmp('gl_info_ass');
  131. if(tb)
  132. tb.updateInfo(r);
  133. },
  134. loadVoucher: function(record) {
  135. var me = this, vc = record.get('dp_vocode');
  136. Ext.Ajax.request({
  137. url : basePath + 'common/getFieldData.action',
  138. params: {
  139. caller: 'Voucher',
  140. field: 'vo_id',
  141. condition: 'vo_code=\'' + vc + '\''
  142. },
  143. method : 'post',
  144. callback : function(options,success,response){
  145. var rs = new Ext.decode(response.responseText);
  146. if(rs.exceptionInfo){
  147. showError(rs.exceptionInfo);return null;
  148. }
  149. if(rs.success){
  150. if(rs.data != null){
  151. me.BaseUtil.onAdd('Voucher_' + vc, '凭证', 'jsps/fa/ars/voucher.jsp?formCondition=vo_idIS' + rs.data +
  152. '&gridCondition=vd_voidIS' + rs.data);
  153. }
  154. }
  155. }
  156. });
  157. },
  158. createYearmonthField : function() {
  159. return Ext.create('Ext.form.FieldContainer', {
  160. margin: '10 2 2 10',
  161. columnWidth: 1,
  162. height: 70,
  163. layout: 'column',
  164. items: [{
  165. xtype: 'radio',
  166. boxLabel: '按期间查询',
  167. name: 'dateorym',
  168. columnWidth: 0.3,
  169. checked: true,
  170. listeners: {
  171. change: function(f) {
  172. var s = Ext.getCmp('asl_yearmonth');
  173. if(f.checked) {
  174. s.setDisabled(false);
  175. } else {
  176. s.setDisabled(true);
  177. }
  178. }
  179. }
  180. },{
  181. id: 'asl_yearmonth',
  182. name: 'asl_yearmonth',
  183. xtype: 'conmonthdatefield',
  184. columnWidth: .7,
  185. height: 30,
  186. getValue: function() {
  187. if(!Ext.isEmpty(this.value)) {
  188. return {begin: this.firstVal, end: this.secondVal};
  189. }
  190. return null;
  191. }
  192. },{
  193. xtype: 'radio',
  194. boxLabel: '按日期查询',
  195. name: 'dateorym',
  196. columnWidth: 0.3,
  197. listeners: {
  198. change: function(f) {
  199. var s = Ext.getCmp('asl_date');
  200. if(f.checked) {
  201. s.setDisabled(false);
  202. } else {
  203. s.setDisabled(true);
  204. }
  205. }
  206. }
  207. },{
  208. id: 'asl_date',
  209. name: 'asl_date',
  210. xtype: 'condatefield',
  211. disabled: true,
  212. columnWidth: .7,
  213. height: 30,
  214. getValue: function() {
  215. if(!Ext.isEmpty(this.value)) {
  216. return {begin: Ext.Date.toString(this.firstVal), end: Ext.Date.toString(this.secondVal)};
  217. }
  218. return null;
  219. }
  220. }],
  221. getValue: function() {
  222. var a = Ext.getCmp('asl_yearmonth'),b = Ext.getCmp('asl_date');
  223. this.id = b.disabled ? 'asl_yearmonth' : 'asl_date';
  224. return b.disabled ? a.getValue() : b.getValue();
  225. }
  226. });
  227. },
  228. createCateField : function() {
  229. var me = this, t, t1;
  230. if (me.CateTreeSearch) {
  231. t = Ext.create('erp.view.core.trigger.CateTreeDbfindTrigger', {
  232. name: 'vd_catecode',
  233. id: 'vd_catecode',
  234. autoDbfind: false,
  235. columnWidth: 0.4,
  236. listeners: {
  237. change: function() {
  238. me.catecode = null;
  239. },
  240. aftertrigger: function(t, d) {
  241. t.ownerCt.down('#vd_catename').setValue(d[0].raw.data.ca_name);
  242. }
  243. }
  244. });
  245. t1 = Ext.create('erp.view.core.trigger.CateTreeDbfindTrigger', {
  246. name: 'vd_catecode1',
  247. id: 'vd_catecode1',
  248. autoDbfind: false,
  249. columnWidth: 0.4,
  250. listeners: {
  251. change: function() {
  252. me.catecode = null;
  253. },
  254. aftertrigger: function(t, d) {
  255. t.ownerCt.down('#vd_catename1').setValue(d[0].raw.data.ca_name);
  256. }
  257. }
  258. });
  259. } else {
  260. t = Ext.create('erp.view.core.trigger.DbfindTrigger', {
  261. id: 'vd_catecode',
  262. name: 'vd_catecode',
  263. columnWidth: 0.4,
  264. listeners: {
  265. aftertrigger: function(t, d) {
  266. t.setValue(d.data.ca_code);
  267. t.ownerCt.down('#vd_catename').setValue(d.data.ca_name);
  268. }
  269. }
  270. });
  271. t1 = Ext.create('erp.view.core.trigger.DbfindTrigger', {
  272. id: 'vd_catecode1',
  273. name: 'vd_catecode1',
  274. columnWidth: 0.4,
  275. listeners: {
  276. aftertrigger: function(t, d) {
  277. t.setValue(d.data.ca_code);
  278. t.ownerCt.down('#vd_catename1').setValue(d.data.ca_name);
  279. }
  280. }
  281. });
  282. }
  283. return Ext.create('Ext.form.FieldContainer', {
  284. id: 'ca_code',
  285. margin: '2 2 2 10',
  286. columnWidth: 1,
  287. height: 100,
  288. layout: 'column',
  289. items: [{
  290. xtype: 'radio',
  291. boxLabel: '连续科目范围',
  292. columnWidth: 0.3,
  293. checked: true,
  294. name: 'continueornot',
  295. listeners: {
  296. change: function(f) {
  297. var s = Ext.getCmp('con_vd_catecode');
  298. if(f.checked) {
  299. s.setDisabled(false);
  300. } else {
  301. s.setDisabled(true);
  302. }
  303. }
  304. }
  305. },{
  306. labelWidth: 80,
  307. layout: 'column',
  308. columnWidth: 0.7,
  309. height: 56,
  310. xtype: 'fieldcontainer',
  311. id: 'con_vd_catecode',
  312. defaults: {
  313. fieldStyle : "background:#FFFAFA;color:#515151;"
  314. },
  315. items: [t, {
  316. xtype: 'textfield',
  317. name: 'vd_catename',
  318. id: 'vd_catename',
  319. columnWidth: 0.6,
  320. readOnly: true,
  321. fieldStyle: 'background:#f1f1f1;'
  322. },t1 ,{
  323. xtype: 'textfield',
  324. name: 'vd_catename1',
  325. id: 'vd_catename1',
  326. columnWidth: 0.6,
  327. readOnly: true,
  328. fieldStyle: 'background:#f1f1f1;'
  329. }],
  330. getValue: function() {
  331. var a = this.down('#vd_catecode').value,b = this.down('#vd_catecode1').value,
  332. x = Ext.isEmpty(a), y = Ext.isEmpty(b);
  333. if(x && y) {
  334. return null;
  335. } else if(x && !y) {
  336. a = b;
  337. } else if(!x && y){
  338. b = a;
  339. }
  340. return {begin: a, end: b};
  341. }
  342. },{
  343. xtype: 'radio',
  344. boxLabel: '非连续科目范围',
  345. columnWidth: 0.3,
  346. name: 'continueornot',
  347. listeners: {
  348. change: function(f) {
  349. var s = Ext.getCmp('un_vd_catecode');
  350. if(f.checked) {
  351. s.setDisabled(false);
  352. } else {
  353. s.setDisabled(true);
  354. }
  355. }
  356. }
  357. },{
  358. xtype: 'cateTreeDbfindTrigger',
  359. mode: 'MULTI',
  360. id: 'un_vd_catecode',
  361. name: 'un_vd_catecode',
  362. disabled: true,
  363. columnWidth: 0.7
  364. }],
  365. getValue: function() {
  366. var a = Ext.getCmp('con_vd_catecode'),b = Ext.getCmp('un_vd_catecode');
  367. var val = b.disabled ? a.getValue() : b.value;
  368. if(val) {
  369. if(!b.disabled) {
  370. var arr = val.split('#');
  371. if(me.catecode != null && !Ext.Array.contains(arr, me.catecode)) {
  372. me.catecode = null;
  373. }
  374. } else {
  375. if(me.catecode == null) {
  376. me.catecode = val.begin;
  377. }
  378. }
  379. return b.disabled ? {continuous: true,value: val} : {continuous: false, value: val};
  380. }
  381. return null;
  382. },
  383. setValue: function(v) {
  384. Ext.getCmp('vd_catecode').setValue(v);
  385. Ext.getCmp('vd_catecode1').setValue(v);
  386. }
  387. });
  388. },
  389. createDeptField : function() {
  390. var me = this, t, t1;
  391. t = Ext.create('erp.view.core.trigger.DbfindTrigger', {
  392. id: 'vd_deptcode',
  393. name: 'vd_deptcode',
  394. columnWidth: 0.4,
  395. listeners: {
  396. aftertrigger: function(t, d) {
  397. t.setValue(d.data.dp_code);
  398. t.ownerCt.down('#vd_deptname').setValue(d.data.dp_name);
  399. }
  400. }
  401. });
  402. t1 = Ext.create('erp.view.core.trigger.DbfindTrigger', {
  403. id: 'vd_deptcode1',
  404. name: 'vd_deptcode1',
  405. columnWidth: 0.4,
  406. listeners: {
  407. aftertrigger: function(t, d) {
  408. t.setValue(d.data.dp_code);
  409. t.ownerCt.down('#vd_deptname1').setValue(d.data.dp_name);
  410. }
  411. }
  412. });
  413. return Ext.create('Ext.form.FieldContainer', {
  414. id: 'dp_code',
  415. margin: '2 2 2 10',
  416. columnWidth: 1,
  417. height: 100,
  418. layout: 'column',
  419. items: [{
  420. xtype: 'label',
  421. text: '部门范围',
  422. columnWidth: 0.3
  423. },{
  424. labelWidth: 80,
  425. layout: 'column',
  426. columnWidth: 0.7,
  427. height: 56,
  428. xtype: 'fieldcontainer',
  429. id: 'con_vd_deptcode',
  430. defaults: {
  431. fieldStyle : "background:#FFFAFA;color:#515151;"
  432. },
  433. items: [t, {
  434. xtype: 'textfield',
  435. name: 'vd_deptname',
  436. id: 'vd_deptname',
  437. columnWidth: 0.6,
  438. readOnly: true,
  439. fieldStyle: 'background:#f1f1f1;'
  440. },t1 ,{
  441. xtype: 'textfield',
  442. name: 'vd_deptname1',
  443. id: 'vd_deptname1',
  444. columnWidth: 0.6,
  445. readOnly: true,
  446. fieldStyle: 'background:#f1f1f1;'
  447. }],
  448. getValue: function() {
  449. var a = this.down('#vd_deptcode').value,b = this.down('#vd_deptcode1').value,
  450. x = Ext.isEmpty(a), y = Ext.isEmpty(b);
  451. if(x && y) {
  452. return null;
  453. } else if(x && !y) {
  454. a = b;
  455. } else if(!x && y){
  456. b = a;
  457. }
  458. return {begin: a, end: b};
  459. }
  460. }],
  461. getValue: function() {
  462. var a = Ext.getCmp('con_vd_deptcode');
  463. var val = a.getValue();
  464. if(val) {
  465. if(me.deptcode == null) {
  466. me.deptcode = val.begin;
  467. }
  468. return {continuous: true,value: val};
  469. }
  470. return null;
  471. },
  472. setValue: function(v) {
  473. Ext.getCmp('vd_deptcode').setValue(v);
  474. Ext.getCmp('vd_deptcode1').setValue(v);
  475. }
  476. });
  477. },
  478. createFilterPanel: function(btn) {
  479. var me = this;
  480. var filter = Ext.create('Ext.Window', {
  481. id: btn.getId() + '-filter',
  482. style: 'background:#f1f1f1',
  483. title: '筛选条件',
  484. width: 500,
  485. height: 500,
  486. layout: 'column',
  487. defaults: {
  488. margin: '2 2 2 10'
  489. },
  490. items: [me.createYearmonthField(), me.createCateField(),
  491. me.createDeptField(),
  492. {
  493. xtype: 'checkbox',
  494. id: 'chkhaveun',
  495. name: 'chkhaveun',
  496. columnWidth: .5,
  497. boxLabel: '包括未过账凭证'
  498. }],
  499. buttonAlign: 'center',
  500. buttons: [{
  501. text: '确定',
  502. width: 60,
  503. cls: 'x-btn-blue',
  504. handler: function(btn) {
  505. var fl = Ext.getCmp('query-filter'),
  506. con = me.getCondition(fl);
  507. con.querytype = 'current';
  508. me.query(con);
  509. fl.hide();
  510. }
  511. },{
  512. text: '关闭',
  513. width: 60,
  514. cls: 'x-btn-blue',
  515. handler: function(btn) {
  516. var fl = btn.ownerCt.ownerCt;
  517. fl.hide();
  518. }
  519. }]
  520. });
  521. this.getCurrentMonth(filter.down('#asl_yearmonth'));
  522. return filter;
  523. },
  524. getCurrency: function(f) {
  525. Ext.Ajax.request({
  526. url : basePath + 'common/getFieldDatas.action',
  527. async: false,
  528. params: {
  529. caller: 'Currencys',
  530. field: 'cr_name',
  531. condition: 'cr_statuscode=\'CANUSE\''
  532. },
  533. method : 'post',
  534. callback : function(options,success,response){
  535. var rs = new Ext.decode(response.responseText);
  536. if(rs.exceptionInfo){
  537. showError(rs.exceptionInfo);return null;
  538. }
  539. if(rs.success && rs.data){
  540. var cr = rs.data.split('#'),c = new Array();
  541. Ext.each(cr, function(r){
  542. c.push({display: r, value: r});
  543. });
  544. f.store.add(c);
  545. }
  546. }
  547. });
  548. },
  549. getCurrentMonth: function(f) {
  550. Ext.Ajax.request({
  551. url: basePath + 'fa/getMonth.action',
  552. params: {
  553. type: 'MONTH-A'
  554. },
  555. callback: function(opt, s, r) {
  556. var rs = Ext.decode(r.responseText);
  557. if(rs.data) {
  558. f.setValue(rs.data.PD_DETNO);
  559. }
  560. }
  561. });
  562. }
  563. });