AddressQueryForm.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. Ext.define('erp.view.oa.attention.AddressQueryForm',{
  2. extend: 'Ext.form.Panel',
  3. alias: 'widget.erpAddressQueryFormPanel',
  4. frame : true,
  5. layout : 'column',
  6. header: false,
  7. defaultType : 'textfield',
  8. caller:null,
  9. labelSeparator : ':',
  10. buttonAlign : 'center',
  11. fieldDefaults : {
  12. margin : '2 2 2 2',
  13. fieldStyle : "background:#FFFAFA;color:#515151;",
  14. labelAlign : "right",
  15. blankText : $I18N.common.form.blankText
  16. },
  17. buttonAlign:'left',
  18. FormUtil: Ext.create('erp.util.FormUtil'),
  19. BaseUtil: Ext.create('erp.util.BaseUtil'),
  20. buttons: [{
  21. name: 'query',
  22. text: $I18N.common.button.erpQueryButton,
  23. iconCls: 'x-button-icon-query',
  24. cls: 'x-btn-gray',
  25. handler: function(){
  26. var grid = Ext.getCmp('querygrid');
  27. var form = Ext.getCmp('queryform');
  28. var condition = grid.defaultCondition || '';
  29. Ext.each(form.items.items, function(f){
  30. if(f.logic != null && f.logic != ''){
  31. if(f.xtype == 'checkbox' && f.value == true){
  32. if(condition == ''){
  33. condition += f.logic;
  34. } else {
  35. condition += ' AND ' + f.logic;
  36. }
  37. } else if(f.xtype == 'datefield' && f.value != null){
  38. var v = Ext.Date.format(new Date(f.value), 'Y-m-d');
  39. if(condition == ''){
  40. condition += f.logic + "=to_date('" + v + "', 'yyyy-MM-dd')";
  41. } else {
  42. condition += ' AND ' + f.logic + "=to_date('" + v + "', 'yyyy-MM-dd')";
  43. }
  44. } else if(f.xtype == 'datetimefield' && f.value != null){
  45. var v = Ext.Date.format(new Date(f.value), 'Y-m-d H:i:s');
  46. if(condition == ''){
  47. condition += f.logic + "=to_date('" + v + "', 'yyyy-MM-dd HH24:mi:ss')";
  48. } else {
  49. condition += ' AND ' + f.logic + "=to_date('" + v + "', 'yyyy-MM-dd HH24:mi:ss')";
  50. }
  51. } else if(f.xtype == 'numberfield' && f.value != null && f.value != ''){
  52. if(condition == ''){
  53. condition += f.logic + '=' + f.value;
  54. } else {
  55. condition += ' AND ' + f.logic + '=' + f.value;
  56. }
  57. } else {
  58. if(f.value != null && f.value != ''){
  59. if(contains(f.value, 'BETWEEN', true) && contains(f.value, 'AND', true)){
  60. if(condition == ''){
  61. condition += f.logic + " " + f.value;
  62. } else {
  63. condition += ' AND (' + f.logic + " " + f.value + ")";
  64. }
  65. } else if(contains(f.value, '||', true)){
  66. var str = '';
  67. Ext.each(f.value.split('||'), function(v){
  68. if(v != null && v != ''){
  69. if(str == ''){
  70. str += f.logic + "='" + v + "'";
  71. } else {
  72. str += ' OR ' + f.logic + "='" + v + "'";
  73. }
  74. }
  75. });
  76. if(condition == ''){
  77. condition += str;
  78. } else {
  79. condition += ' AND (' + str + ")";
  80. }
  81. } else {
  82. if(condition == ''){
  83. condition += f.logic + "='" + f.value + "'";
  84. } else {
  85. condition += ' AND (' + f.logic + "='" + f.value + "')";
  86. }
  87. }
  88. }
  89. }
  90. }
  91. });
  92. var gridParam = {caller: caller, condition: condition};
  93. grid.GridUtil.getGridColumnsAndStore(grid, 'common/singleGridPanel.action', gridParam, "");
  94. }
  95. }, '-', {
  96. name: 'export',
  97. text: $I18N.common.button.erpExportButton,
  98. iconCls: 'x-button-icon-submit',
  99. cls: 'x-btn-gray',
  100. handler: function(){
  101. var grid = Ext.getCmp('querygrid');
  102. grid.BaseUtil.exportexcel(grid);
  103. }
  104. }, '-', {
  105. text: $I18N.common.button.erpCloseButton,
  106. iconCls: 'x-button-icon-close',
  107. cls: 'x-btn-gray',
  108. handler: function(){
  109. var main = parent.Ext.getCmp("content-panel");
  110. main.getActiveTab().close();
  111. }
  112. }],
  113. listeners:{
  114. show:function(form){
  115. var param = {caller: form.caller, condition: ''};
  116. if(form.items.length<1){
  117. form.FormUtil.getItemsAndButtons(form, 'common/singleFormItems.action', param);
  118. }
  119. }
  120. },
  121. initComponent : function(){
  122. this.callParent(arguments);
  123. }
  124. });