Form.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. Ext.define('erp.view.oa.officialDocument.instruction.query.Form',{
  2. extend: 'Ext.form.Panel',
  3. alias: 'widget.erpInstructionQueryFormPanel',
  4. id: 'form',
  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 grid = Ext.getCmp('grid');
  27. var form = Ext.getCmp('form');
  28. var condition = '';
  29. Ext.each(form.items.items, function(f){
  30. if(f.logic != null && f.logic != '' && f.value != null && f.value != ''){
  31. if(contains(f.value, 'BETWEEN', true) && contains(f.value, 'AND', true)){
  32. if(condition == ''){
  33. condition += f.logic + " " + f.value;
  34. } else {
  35. condition += ' AND ' + f.logic + " " + f.value;
  36. }
  37. } else {
  38. if(condition == ''){
  39. condition += f.logic + "='" + f.value + "'";
  40. } else {
  41. condition += ' AND ' + f.logic + "='" + f.value + "'";
  42. }
  43. }
  44. }
  45. });
  46. if(condition != ''){
  47. grid.getCount('Instruction!Query', condition);
  48. // url = "oa/officialDocument/instruction/search.action";
  49. // form.getGroupDa(condition);
  50. } else {
  51. showError('请填写筛选条件');return;
  52. }
  53. console.log(condition);
  54. }
  55. }, '-', {
  56. text: $I18N.common.button.erpCloseButton,
  57. iconCls: 'x-button-icon-close',
  58. cls: 'x-btn-gray',
  59. handler: function(){
  60. var main = parent.Ext.getCmp("content-panel");
  61. main.getActiveTab().close();
  62. }
  63. }],
  64. initComponent : function(){
  65. // alert(em_uu + caller);
  66. var param = {caller: caller, condition: ''};
  67. this.FormUtil.getItemsAndButtons(this, 'common/singleFormItems.action', param);
  68. this.callParent(arguments);
  69. },
  70. getGroupDa : function(condition, page, pageSize){
  71. var me = Ext.getCmp('grid');
  72. if(!page){
  73. page = 1;
  74. }
  75. if(!pageSize){
  76. pageSize = 15;
  77. }
  78. parent.Ext.getCmp("content-panel").getActiveTab().setLoading(true);//loading...
  79. Ext.Ajax.request({//拿到grid的columns
  80. url : basePath + url,
  81. params: {
  82. page: page,
  83. pageSize: pageSize,
  84. condition: condition
  85. },
  86. method : 'post',
  87. async: false,
  88. callback : function(options, success, response){
  89. // console.log(response);
  90. parent.Ext.getCmp("content-panel").getActiveTab().setLoading(false);
  91. var res = new Ext.decode(response.responseText);
  92. if(res.exceptionInfo){
  93. showError(res.exceptionInfo);return;
  94. }
  95. if(!res.success){
  96. return;
  97. } else {
  98. console.log(res.success);
  99. dataCount = res.count;
  100. me.store.loadData(res.success);
  101. }
  102. }
  103. });
  104. }
  105. });