BorrowManage.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.oa.publicAdmin.book.borrowManage.BorrowManage', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. GridUtil: Ext.create('erp.util.GridUtil'),
  6. BaseUtil: Ext.create('erp.util.BaseUtil'),
  7. views:[
  8. 'oa.publicAdmin.book.borrowManage.BorrowManage','oa.publicAdmin.book.borrowManage.BookTreePanel','common.datalist.GridPanel','common.datalist.Toolbar',
  9. 'core.button.Add','core.button.Submit','core.button.Audit','core.button.Save','core.button.Close','core.button.Print',
  10. 'core.button.Upload','core.button.Update','core.button.Delete','core.button.ResAudit','core.button.DeleteDetail',
  11. 'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger'
  12. ],
  13. init:function(){
  14. this.control({
  15. 'erpBookTreePanel': {
  16. itemmousedown: function(selModel, record){
  17. if(record.get('leaf')){
  18. var id=record.get('id');
  19. condition="bl_borrowercode="+id;
  20. Ext.getCmp('pagingtoolbar').child('#inputItem').setValue(1);
  21. page=1;
  22. Ext.getCmp('grid').getCount(caller,condition);
  23. }
  24. }
  25. },
  26. 'erpDatalistGridPanel': {
  27. itemclick: this.onGridItemClick
  28. }
  29. });
  30. },
  31. onGridItemClick: function(selModel, record){//grid行选择
  32. var me = this;
  33. if(keyField != null && keyField != ''){//有些datalist不需要打开明细表,这些表在datalist表里面不用配dl_keyField
  34. var value = record.data[keyField];
  35. var formCondition = keyField + "IS" + value ;
  36. var gridCondition = pfField + "IS" + value;
  37. var panel = Ext.getCmp(caller + keyField + "=" + value);
  38. var main = parent.Ext.getCmp("content-panel");
  39. if(!panel){
  40. var title = "";
  41. if (value.toString().length>4) {
  42. title = value.toString().substring(value.toString().length-4);
  43. } else {
  44. title = value;
  45. }
  46. var myurl = '';
  47. if(me.BaseUtil.contains(url, '?', true)){
  48. myurl = url + '&formCondition='+formCondition+'&gridCondition='+gridCondition;
  49. } else {
  50. myurl = url + '?formCondition='+formCondition+'&gridCondition='+gridCondition;
  51. }
  52. myurl += "&datalistId=" + main.getActiveTab().id;
  53. main.getActiveTab().currentStore = me.getCurrentStore(value);//用于单据翻页
  54. panel = {
  55. title : '借阅申请单('+title+')',
  56. tag : 'iframe',
  57. tabConfig:{tooltip:me.BaseUtil.getActiveTab().tabConfig.tooltip+'('+keyField + "=" + value+')'},
  58. frame : true,
  59. border : false,
  60. layout : 'fit',
  61. iconCls : 'x-tree-icon-tab-tab1',
  62. html : '<iframe id="iframe_maindetail_'+caller+"_"+value+'" src="' + myurl + '" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>',
  63. closable : true,
  64. listeners : {
  65. close : function(){
  66. if(!main){
  67. main = parent.parent.Ext.getCmp("content-panel");
  68. }
  69. main.setActiveTab(main.getActiveTab().id);
  70. }
  71. }
  72. };
  73. this.openTab(panel, caller + keyField + "=" + record.data[keyField]);
  74. }else{
  75. main.setActiveTab(panel);
  76. }
  77. }
  78. },
  79. openTab : function (panel,id){
  80. var o = (typeof panel == "string" ? panel : id || panel.id);
  81. var main = parent.Ext.getCmp("content-panel");
  82. /*var tab = main.getComponent(o); */
  83. if(!main) {
  84. main =parent.parent.Ext.getCmp("content-panel");
  85. }
  86. var tab = main.getComponent(o);
  87. if (tab) {
  88. main.setActiveTab(tab);
  89. } else if(typeof panel!="string"){
  90. panel.id = o;
  91. var p = main.add(panel);
  92. main.setActiveTab(p);
  93. }
  94. }, getCurrentStore: function(value){
  95. var grid = Ext.getCmp('grid');
  96. var items = grid.store.data.items;
  97. var array = new Array();
  98. var o = null;
  99. Ext.each(items, function(item, index){
  100. o = new Object();
  101. o.selected = false;
  102. if(index == 0){
  103. o.prev = null;
  104. } else {
  105. o.prev = items[index-1].data[keyField];
  106. }
  107. if(index == items.length - 1){
  108. o.next = null;
  109. } else {
  110. o.next = items[index+1].data[keyField];
  111. }
  112. var v = item.data[keyField];
  113. o.value = v;
  114. if(v == value)
  115. o.selected = true;
  116. array.push(o);
  117. });
  118. return array;
  119. }
  120. });