Stencil.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. Ext.define('erp.view.pm.mes.Stencil',{
  2. extend: 'Ext.Viewport',
  3. layout: 'fit',
  4. hideBorders: true,
  5. initComponent : function(){
  6. var me = this;
  7. Ext.apply(me, {
  8. items: [{
  9. id:'StencilViewport',
  10. layout: 'anchor',
  11. items: [{
  12. xtype: 'erpFormPanel',
  13. anchor: '100% 40%',
  14. saveUrl: 'pm/mes/saveStencil.action',
  15. deleteUrl: 'pm/mes/deleteStencil.action',
  16. updateUrl: 'pm/mes/updateStencil.action',
  17. getIdUrl: 'common/getId.action?seq=Stencil_SEQ',
  18. submitUrl: 'pm/mes/submitStencil.action',
  19. auditUrl: 'pm/mes/auditStencil.action',
  20. resAuditUrl: 'pm/mes/resAuditStencil.action',
  21. resSubmitUrl: 'pm/mes/resSubmitStencil.action',
  22. keyField: 'st_id',
  23. codeField: 'st_code',
  24. statusField: 'st_status',
  25. statuscodeField: 'st_statuscode'
  26. },{
  27. title:'使用登记',
  28. xtype : 'erpGridPanel2',
  29. anchor : '100% 60%',
  30. keyField : 'su_id',
  31. mainField : 'su_stid',
  32. headerCt: Ext.create("Ext.grid.header.Container",{
  33. forceFit: false,
  34. sortable: true,
  35. enableColumnMove:true,
  36. enableColumnResize:true,
  37. enableColumnHide: true
  38. }),
  39. plugins: [Ext.create('erp.view.core.plugin.CopyPasteMenu'),Ext.create('erp.view.core.grid.HeaderFilter')],
  40. invalidateScrollerOnRefresh: false,
  41. listeners: {
  42. 'headerfiltersapply': function(grid, filters) {
  43. if(this.allowFilter){
  44. var condition = null;
  45. for(var fn in filters){
  46. var value = filters[fn],f = grid.getHeaderFilterField(fn);
  47. if(!Ext.isEmpty(value)){
  48. if(f.filtertype) {
  49. if (f.filtertype == 'numberfield') {
  50. value = fn + "=" + value + " ";
  51. }
  52. } else {
  53. if(Ext.isDate(value)){
  54. value = Ext.Date.toString(value);
  55. value = "to_char(" + fn + ",'yyyy-MM-dd')='" + value + "' ";
  56. } else {
  57. var exp_t = /^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/,
  58. exp_d = /^(\d{4})\-(\d{2})\-(\d{2})$/;
  59. if(exp_d.test(value)){
  60. value = "to_char(" + fn + ",'yyyy-MM-dd')='" + value + "' ";
  61. } else if(exp_t.test(value)){
  62. value = "to_char(" + fn + ",'yyyy-MM-dd')='" + value.substr(0, 10) + "' ";
  63. } else{
  64. if (f.xtype == 'combo' || f.xtype == 'combofield') {
  65. if (value == '-所有-') {
  66. continue;
  67. } else if (value == '-无-') {
  68. value = 'nvl(' + fn + ',\' \')=\' \'';
  69. } else {
  70. value = fn + " LIKE '" + value + "%' ";
  71. }
  72. } else {
  73. //**字符串转换下简体*//*
  74. var SimplizedValue=this.BaseUtil.Simplized(value);
  75. //可能就是按繁体筛选
  76. if(f.ignoreCase) {// 忽略大小写
  77. fn = 'upper(' + fn + ')';
  78. value = value.toUpperCase();
  79. }
  80. if(!f.autoDim) {
  81. if(SimplizedValue!=value){
  82. value = "("+fn + " LIKE '" + value + "%' or "+fn+" LIKE '"+SimplizedValue+"%')";
  83. }else value = fn + " LIKE '" + value + "%' ";
  84. } else if(f.exactSearch){
  85. value=fn+"='"+value+"'";
  86. }else {
  87. if(SimplizedValue!=value){
  88. value = "("+fn + " LIKE '%" + value + "%' or "+fn+" LIKE '%"+SimplizedValue+"%')";
  89. }else value = fn + " LIKE '%" + value + "%' ";
  90. }
  91. }
  92. }
  93. }
  94. }
  95. if(condition == null){
  96. condition = value;
  97. } else {
  98. condition = condition + " AND " + value;
  99. }
  100. }
  101. }
  102. this.filterCondition = condition;
  103. var grid=Ext.getCmp('grid');
  104. if(grid.store.data!=grid.store.prefetchData){
  105. grid.store.loadData(grid.store.prefetchData.items);
  106. }
  107. } else {
  108. this.allowFilter = true;
  109. }
  110. return false;
  111. }
  112. },
  113. viewConfig: {
  114. trackOver: false
  115. },
  116. buffered: true,
  117. sync: true
  118. }]
  119. }]
  120. });
  121. me.callParent(arguments);
  122. }
  123. });