ATPOpDetailForm.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. Ext.define('erp.view.pm.atp.ATPOpDetailForm',{
  2. extend: 'Ext.form.Panel',
  3. alias: 'widget.erpATPOpDetailFormPanel',
  4. id: 'queryform',
  5. region: 'north',
  6. frame : true,
  7. layout : 'column',
  8. autoScroll : true,
  9. defaultType : 'textfield',
  10. labelSeparator : ':',
  11. buttonAlign : 'center',
  12. fieldDefaults : {
  13. margin : '4 2 4 2',
  14. fieldStyle : "background:#FFFAFA;color:#515151;",
  15. labelAlign : "right",
  16. blankText : $I18N.common.form.blankText
  17. },
  18. FormUtil: Ext.create('erp.util.FormUtil'),
  19. BaseUtil: Ext.create('erp.util.BaseUtil'),
  20. tbar: [{
  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 tab = Ext.getCmp('tabpanel');
  27. var grid=tab.getActiveTab().items.items[0];
  28. var form =Ext.getCmp('queryform');
  29. BaseQueryCondition='';
  30. Ext.each(form.items.items, function(f){
  31. if(f.logic != null && f.logic != ''){
  32. if(f.xtype == 'checkbox' && f.value == true){
  33. if(BaseQueryCondition == ''){
  34. BaseQueryCondition += f.logic;
  35. } else {
  36. BaseQueryCondition += ' AND ' + f.logic;
  37. }
  38. } else if(f.xtype == 'datefield' && f.value != null){
  39. var v = Ext.Date.format(new Date(f.value), 'Y-m-d');
  40. if(BaseQueryCondition == ''){
  41. BaseQueryCondition += f.logic + "=to_date('" + v + "', 'yyyy-MM-dd')";
  42. } else {
  43. BaseQueryCondition += ' AND ' + f.logic + "=to_date('" + v + "', 'yyyy-MM-dd')";
  44. }
  45. } else if(f.xtype == 'datetimefield' && f.value != null){
  46. var v = Ext.Date.format(new Date(f.value), 'Y-m-d H:i:s');
  47. if(BaseQueryCondition == ''){
  48. BaseQueryCondition += f.logic + "=to_date('" + v + "', 'yyyy-MM-dd HH24:mi:ss')";
  49. } else {
  50. BaseQueryCondition += ' AND ' + f.logic + "=to_date('" + v + "', 'yyyy-MM-dd HH24:mi:ss')";
  51. }
  52. } else if(f.xtype == 'numberfield' && f.value != null && f.value != ''){
  53. if(BaseQueryCondition == ''){
  54. BaseQueryCondition += f.logic + '=' + f.value;
  55. } else {
  56. BaseQueryCondition += ' AND ' + f.logic + '=' + f.value;
  57. }
  58. } else {
  59. if(f.value != null && f.value != ''){
  60. if(contains(f.value, 'BETWEEN', true) && contains(f.value, 'AND', true)){
  61. if(BaseQueryCondition == ''){
  62. BaseQueryCondition += f.logic + " " + f.value;
  63. } else {
  64. BaseQueryCondition += ' AND (' + f.logic + " " + f.value + ")";
  65. }
  66. } else if(contains(f.value, '||', true)){
  67. var str = '';
  68. Ext.each(f.value.split('||'), function(v){
  69. if(v != null && v != ''){
  70. if(str == ''){
  71. str += f.logic + "='" + v + "'";
  72. } else {
  73. str += ' OR ' + f.logic + "='" + v + "'";
  74. }
  75. }
  76. });
  77. if(BaseQueryCondition == ''){
  78. BaseQueryCondition += str;
  79. } else {
  80. BaseQueryCondition += ' AND (' + str + ")";
  81. }
  82. } else {
  83. if(BaseQueryCondition == ''){
  84. BaseQueryCondition += f.logic + "='" + f.value + "'";
  85. } else {
  86. BaseQueryCondition += ' AND (' + f.logic + "='" + f.value + "')";
  87. }
  88. }
  89. }
  90. }
  91. }
  92. });
  93. //BaseQueryCondition=BaseQueryCondition==""?"pr_code=''":BaseQueryCondition;
  94. grid.getCount(caller,BaseQueryCondition,grid.id);
  95. }
  96. }, '->', {
  97. name: 'export',
  98. text: $I18N.common.button.erpExportButton,
  99. iconCls: 'x-button-icon-submit',
  100. cls: 'x-btn-gray',
  101. handler: function(b){
  102. var form = b.ownerCt.ownerCt,
  103. tab = form.ownerCt.down('tabpanel'),
  104. ac = tab.getActiveTab(),
  105. grid = ac.down('grid');
  106. if(grid) {
  107. if(grid.exportAction) {
  108. grid.BaseUtil.customExport(caller, grid, ac.title, grid.exportAction,
  109. grid.gridcondition);
  110. } else {
  111. grid.BaseUtil.createExcel(caller, 'datalist', grid.gridcondition);
  112. }
  113. }
  114. }
  115. }, '-', {
  116. text: $I18N.common.button.erpCloseButton,
  117. iconCls: 'x-button-icon-close',
  118. cls: 'x-btn-gray',
  119. handler: function(){
  120. var main = parent.Ext.getCmp("content-panel");
  121. main.getActiveTab().close();
  122. }
  123. }],
  124. initComponent : function(){
  125. var param = {caller: caller, condition: '',_noc:1};
  126. this.FormUtil.getItemsAndButtons(this, 'common/singleFormItems.action', param);
  127. this.callParent(arguments);
  128. }
  129. });