DbfindTrigger2.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /**
  2. * dbfind trigger
  3. * 支持带条件dbfind
  4. */
  5. Ext.define('erp.view.core.trigger.DbfindTrigger2', {
  6. extend: 'Ext.form.field.Trigger',
  7. alias: 'widget.dbfindtrigger2',
  8. triggerCls: 'x-form-search-trigger',
  9. editable: false,
  10. initComponent: function() {
  11. this.addEvents({
  12. aftertrigger: true
  13. });
  14. this.callParent(arguments);
  15. },
  16. onTriggerClick: function() {
  17. this.setFieldStyle('background:#C6E2FF;');
  18. var trigger = this;// 放大镜所在
  19. // key = this.name,// name属性
  20. // dbfind = '',// 需要dbfind的表和字段
  21. // dbBaseCondition='',
  22. // dbCondition='',
  23. // dbGridCondition='',
  24. // dbKey=this.dbKey,
  25. // mappingKey=this.mappingKey,
  26. // gridKey=this.gridKey,
  27. // mappinggirdKey=this.mappinggirdKey;
  28. // window.onTriggerClick = this.id;
  29. // // 存在查询条件的字段
  30. // if(dbKey){
  31. // var dbKeyValue = Ext.getCmp(dbKey).value;
  32. // if(dbKeyValue){
  33. // dbCondition = mappingKey + " IS '" + dbKeyValue + "'";
  34. // } else {
  35. // showError(this.dbMessage);
  36. // return
  37. // }
  38. // }
  39. // if(gridKey){
  40. // var gridkeyvalue = Ext.getCmp(gridKey).value;
  41. // if(gridkeyvalue){
  42. // dbGridCondition = this.mappinggirdKey + " IS '" + gridkeyvalue + "'";
  43. // } else {
  44. // showError(this.gridErrorMessage);
  45. // return
  46. // }
  47. // }
  48. // if(this.dbBaseCondition){
  49. // dbBaseCondition = this.dbBaseCondition;
  50. // }
  51. // if(!trigger.ownerCt){// 如果是grid的dbfind
  52. // var grid = Ext.ComponentQuery.query('gridpanel');
  53. // Ext.Array.each(grid, function(g, index){
  54. // Ext.Array.each(g.columns,function(column){
  55. // if(column.dataIndex == key) {
  56. // dbfind = column.dbfind;
  57. // trigger.owner = g;
  58. // }
  59. // });
  60. // });
  61. //
  62. // }
  63. // var keyValue = this.value;// 当前值
  64. // keyValue = keyValue == null ? '' : keyValue;
  65. var dbwin = new Ext.window.Window({
  66. id : 'dbwin',
  67. title: '选择目录',
  68. height: "100%",
  69. width: "30%",
  70. maximizable : true,
  71. buttonAlign : 'center',
  72. layout : 'anchor',
  73. items: [{
  74. tag : 'iframe',
  75. frame : true,
  76. anchor : '100% 100%',
  77. layout : 'fit',
  78. html : '<iframe id="iframe_dbfind" src="'+basePath+'jsps/oa/document/dbfind2.jsp?trigger=' + trigger.id + '" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  79. }],
  80. buttons : [{
  81. iconCls: 'tree-add',
  82. text: '确定',
  83. handler: function(btn){
  84. var tree = btn.ownerCt.ownerCt.items.items[0].el.dom.getElementsByTagName('iframe')[0].contentWindow.document.defaultView.Ext.getCmp("treegrid");
  85. var url = '';
  86. if(tree.expandedNodes.length == 0){
  87. showError('亲,请选择路径');
  88. } else {
  89. Ext.each(tree.expandedNodes, function(){
  90. if(this.data['dc_isfile'] == 'F'){
  91. url += '/' + this.data['qtip'];
  92. }
  93. });
  94. trigger.setValue(tree.expandedNodes.pop().data['dc_id'] + ':' + url);
  95. // trigger.fireEvent('aftertrigger', trigger);
  96. Ext.getCmp('dbwin').close();
  97. }
  98. }
  99. },{
  100. text : '关 闭',
  101. iconCls: 'x-button-icon-close',
  102. cls: 'x-btn-gray',
  103. handler : function(){
  104. Ext.getCmp('dbwin').close();
  105. }
  106. }]
  107. });
  108. dbwin.show();
  109. }
  110. });