PropertInqury.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.oa.storage.PropertInqury', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. views:[
  7. 'oa.storage.PropertInqury','common.datalist.GridPanel','common.datalist.Toolbar','common.query.Form',
  8. 'core.trigger.DbfindTrigger','core.form.ConDateField','core.toolbar.Toolbar','oa.publicAdmin.book.bookManage.Form','core.form.YnField'
  9. ],
  10. init:function(){
  11. var me = this;
  12. this.control({
  13. 'erpDatalistGridPanel': {
  14. itemclick: this.onGridItemClick
  15. }
  16. });
  17. },
  18. onGridItemClick: function(selModel, record){//grid行选择
  19. var me = this;
  20. if(keyField != null && keyField != ''){
  21. var value = record.data[keyField];
  22. var formCondition = keyField + "IS" + value ;
  23. var gridCondition = pfField + "IS" + value;
  24. var panel = Ext.getCmp(caller + keyField + "=" + value);
  25. var main = parent.Ext.getCmp("content-panel");
  26. if(!main){
  27. main = parent.parent.Ext.getCmp("content-panel");
  28. }
  29. if(!panel){
  30. var title = "";
  31. if (value.toString().length>4) {
  32. title = value.toString().substring(value.toString().length-4);
  33. } else {
  34. title = value;
  35. }
  36. var myurl = '';
  37. if(contains(url, '?', true)){
  38. myurl = url + '&formCondition='+formCondition+'&gridCondition='+gridCondition;
  39. } else {
  40. myurl = url + '?formCondition='+formCondition+'&gridCondition='+gridCondition;
  41. }
  42. myurl += "&datalistId=" + main.getActiveTab().id;
  43. main.getActiveTab().currentStore = me.getCurrentStore(value);//用于单据翻页
  44. panel = {
  45. title : me.BaseUtil.getActiveTab().title+'('+title+')',
  46. tag : 'iframe',
  47. tabConfig:{tooltip:me.BaseUtil.getActiveTab().tabConfig.tooltip+'('+keyField + "=" + value+')'},
  48. frame : true,
  49. border : false,
  50. layout : 'fit',
  51. iconCls : 'x-tree-icon-tab-tab1',
  52. html : '<iframe id="iframe_maindetail_'+caller+"_"+value+'" src="' + myurl + '" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>',
  53. closable : true,
  54. listeners : {
  55. close : function(){
  56. if(!main){
  57. main = parent.parent.Ext.getCmp("content-panel");
  58. }
  59. main.setActiveTab(main.getActiveTab().id);
  60. }
  61. }
  62. };
  63. this.openTab(panel, caller + keyField + "=" + record.data[keyField]);
  64. }else{
  65. main.setActiveTab(panel);
  66. }
  67. }
  68. },
  69. openTab : function (panel,id){
  70. var o = (typeof panel == "string" ? panel : id || panel.id);
  71. var main = parent.Ext.getCmp("content-panel");
  72. if(!main) {
  73. main =parent.parent.Ext.getCmp("content-panel");
  74. }
  75. var tab = main.getComponent(o);
  76. if (tab) {
  77. main.setActiveTab(tab);
  78. } else if(typeof panel!="string"){
  79. panel.id = o;
  80. var p = main.add(panel);
  81. main.setActiveTab(p);
  82. }
  83. },
  84. getCurrentStore: function(value){
  85. var grid = Ext.getCmp('grid');
  86. var items = grid.store.data.items;
  87. var array = new Array();
  88. var o = null;
  89. Ext.each(items, function(item, index){
  90. o = new Object();
  91. o.selected = false;
  92. if(index == 0){
  93. o.prev = null;
  94. } else {
  95. o.prev = items[index-1].data[keyField];
  96. }
  97. if(index == items.length - 1){
  98. o.next = null;
  99. } else {
  100. o.next = items[index+1].data[keyField];
  101. }
  102. var v = item.data[keyField];
  103. o.value = v;
  104. if(v == value)
  105. o.selected = true;
  106. array.push(o);
  107. });
  108. return array;
  109. }
  110. });