DbfindField.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. Gef.ns('Gef.org');
  2. Gef.org.DbfindField = Ext.extend(Ext.form.TriggerField, {
  3. triggerClass : "x-form-search-trigger",
  4. initComponent: function() {
  5. this.readOnly = false;
  6. Gef.org.OrgField.superclass.initComponent.call(this);
  7. this.addEvents('select');
  8. },
  9. onTriggerClick: function() {
  10. this.showWindow();
  11. },
  12. showWindow: function(store) {
  13. var trigger = this, bool = true;// 放大镜所在
  14. bool = trigger.fireEvent('beforetrigger', trigger);
  15. if(bool == false) {
  16. return;
  17. }
  18. var key = this.name,// name属性
  19. dbfind = '',// 需要dbfind的表和字段
  20. dbBaseCondition='',
  21. dbCondition='',
  22. dbGridCondition='',
  23. findConfig=this.findConfig,
  24. dbKey=this.dbKey,
  25. mappingKey=this.mappingKey,
  26. gridKey=this.gridKey,
  27. mappinggirdKey=this.mappinggirdKey;
  28. window.onTriggerClick = this.id;
  29. // 存在查询条件的字段
  30. if(findConfig){
  31. dbCondition = findConfig;
  32. }
  33. if(dbKey){
  34. var dbKeyValue = Ext.getCmp(dbKey).value;
  35. if(dbKeyValue){
  36. dbCondition = mappingKey + " IS '" + dbKeyValue + "'";
  37. } else {
  38. showError(this.dbMessage);
  39. return
  40. }
  41. }
  42. if(gridKey){
  43. var gridKeys = gridKey.split('|');
  44. var mappinggirdKeys = mappinggirdKey.split('|');
  45. var gridErrorMessages = this.gridErrorMessage.split('|');
  46. for(var i=0;i<gridKeys.length;i++){
  47. var gridkeyvalue = Ext.getCmp(gridKeys[i]).value;
  48. if(i==0){
  49. if(gridkeyvalue){
  50. dbGridCondition = mappinggirdKeys[i] + " IS '"+gridkeyvalue+"' ";
  51. }else{
  52. showError(gridErrorMessages[i]);
  53. return
  54. }
  55. }else{
  56. if(gridkeyvalue){
  57. dbGridCondition =dbGridCondition+" AND "+ mappinggirdKeys[i] + " IS '"+gridkeyvalue+"' ";
  58. }else{
  59. showError(gridErrorMessages[i]);
  60. return
  61. }
  62. }
  63. }
  64. }
  65. if(this.dbBaseCondition){
  66. dbBaseCondition = this.dbBaseCondition;
  67. }
  68. if(!trigger.ownerCt){// 如果是grid的dbfind
  69. var grid = Ext.getCmp('grid');
  70. dbfind = trigger.dbfind;
  71. trigger.record=grid.selModel.selection.record;
  72. trigger.owner = grid;
  73. }
  74. var keyValue = this.value;// 当前值
  75. keyValue = keyValue == null ? '' : keyValue;
  76. var caller="Jprocess";
  77. var width = Ext.isIE ? screen.width*0.7*0.9 : '50%';
  78. var dbwin = new Ext.Window({
  79. id : 'dbwin',
  80. title: '查找',
  81. height: 500,
  82. width:width,
  83. x: 60,
  84. frame:true,
  85. buttonAlign : 'center',
  86. layout : 'anchor',
  87. modal: true,
  88. items: [{
  89. tag : 'iframe',
  90. frame : true,
  91. anchor : '100% 100%',
  92. layout : 'fit',
  93. html : '<iframe id="iframe_dbfind" src="'+basePath+'jsps/common/dbfind.jsp?key='+key+"&dbfind="+dbfind+"&dbGridCondition="+dbGridCondition+"&dbCondition="+dbCondition+"&dbBaseCondition="+dbBaseCondition+"&keyValue="+encodeURIComponent(keyValue)+"&trigger="+trigger.id+ "&caller=" + caller + '" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  94. }],
  95. buttons : [{
  96. text : '关 闭',
  97. iconCls: 'x-button-icon-close',
  98. cls: 'x-btn-gray',
  99. handler : function(){
  100. Ext.getCmp('dbwin').close();
  101. }
  102. },{
  103. text: '重置条件',
  104. id: 'reset',
  105. cls: 'x-btn-gray',
  106. hidden: true,
  107. handler: function(){
  108. var grid = Ext.getCmp('dbwin').el.dom.getElementsByTagName('iframe')[0].contentWindow.document.defaultView.Ext.getCmp('dbfindGridPanel');
  109. grid.resetCondition();
  110. grid.getCount();
  111. }
  112. }]
  113. });
  114. dbwin.show();
  115. trigger.lastTriggerId = null;
  116. Gef.activeEditor.disable();
  117. },
  118. hideWindow: function() {
  119. this.getWindow().hide();
  120. Gef.activeEditor.enable();
  121. },
  122. getWindow: function(store) {
  123. if (!this.orgWindow) {
  124. this.orgWindow = this.createWindow(store);
  125. }
  126. return this.orgWindow;
  127. }
  128. });
  129. Ext.reg('dbfindfield', Gef.org.DbfindField);