SourceForm.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. Ext.define('erp.view.pm.source.SourceForm',{
  2. extend: 'Ext.form.Panel',
  3. alias: 'widget.SourceFormPanel',
  4. id: 'sourceform',
  5. region: 'north',
  6. frame : true,
  7. layout : 'column',
  8. autoScroll : true,
  9. defaultType : 'textfield',
  10. labelSeparator : ':',
  11. buttonAlign : 'center',
  12. GridUtil: Ext.create('erp.util.GridUtil'),
  13. BaseUtil:Ext.create('erp.util.BaseUtil'),
  14. layout:'column',
  15. defaults:{
  16. columnWidth:'0.2'
  17. },
  18. items: [
  19. {
  20. xtype: 'combo',
  21. fieldLabel: '来源类型',
  22. labelAlign:'right',
  23. //labelWidth:80,
  24. id:'type',
  25. allowBlank:false,
  26. fieldStyle:{
  27. background:'#fffac0',
  28. color:'#515151'
  29. },
  30. listConfig:{
  31. emptyText: "未找到匹配值",
  32. maxHeight: 80},
  33. displayField:'type',
  34. valueField:'caller',
  35. editable : false,
  36. queryMode : "local",
  37. value:'MRPSSaleM',
  38. store:{
  39. fields:['type','caller'],
  40. data:[
  41. {type:'销售订单',caller:'MRPSSaleM'},
  42. {type:'销售预测',caller:'MRPSForeCastM'}
  43. ]
  44. },
  45. },
  46. {
  47. xtype:'condatefield',
  48. labelAlign:'right',
  49. fieldLabel:'需求时间',
  50. name:'condate',
  51. id:'condate',
  52. columnWidth:'0.5',
  53. fieldStyle:'background:#FFFAFA;color:#515151;'
  54. },{
  55. xtype:'checkbox',
  56. labelAlign:'right',
  57. columnWidth:'0.3',
  58. name:'detail',
  59. id:'detail',
  60. fieldLabel:'显示物料明细',
  61. },
  62. {
  63. columnWidth:'0.2',
  64. labelAlign:'right',
  65. fieldLabel:'记录条数',
  66. id:'datacount',
  67. labelStyle:'font-size:16px;font-weight: bold;',
  68. fieldStyle : 'background:#f0f0f0 ;border-bottom-style:1px solid;padding:2px 2px;vertical-align:middle;border-top:none;border-right:none;color:#CD661D;border-bottom-style:1px solid;border-left:none;font-weight: bold; ',
  69. }
  70. ],
  71. tbar: [{
  72. name: 'query',
  73. text: $I18N.common.button.erpQueryButton,
  74. iconCls: 'x-button-icon-query',
  75. cls: 'x-btn-gray',
  76. id:'querybutton'
  77. }, '->', {
  78. xtype: 'erpLoadButton',
  79. text: $I18N.common.button.erpLoadButton,
  80. listeners:{
  81. afterrender:function(btn){
  82. var value=getUrlParam('keyValue');
  83. if(value==null){
  84. btn.hide();
  85. }
  86. }
  87. }
  88. },'-',{
  89. name: 'export',
  90. text: $I18N.common.button.erpExportButton,
  91. iconCls: 'x-button-icon-submit',
  92. cls: 'x-btn-gray',
  93. handler: function(b){
  94. var form = b.ownerCt.ownerCt, grid = form.ownerCt.down('grid');
  95. grid.BaseUtil.createExcel(caller, 'datalist', form.getCondition());
  96. }
  97. },'-',{
  98. text: $I18N.common.button.erpCloseButton,
  99. iconCls: 'x-button-icon-close',
  100. cls: 'x-btn-gray',
  101. handler: function(){
  102. var main = parent.Ext.getCmp("content-panel");
  103. main.getActiveTab().close();
  104. }
  105. }],
  106. initComponent : function(){
  107. this.callParent(arguments);
  108. },
  109. ChangeGridByCaller:function(caller){
  110. },
  111. getFields: function(tn, fields, con){
  112. var des = '';
  113. Ext.Ajax.request({//拿到grid的columns
  114. url : basePath + "pm/bom/getFields.action",
  115. params: {
  116. tablename: tn,
  117. field: fields,
  118. condition: con
  119. },
  120. method : 'post',
  121. async: false,
  122. callback : function(options,success,response){
  123. var res = new Ext.decode(response.responseText);
  124. if(res.exceptionInfo){
  125. showError(res.exceptionInfo);return;
  126. }
  127. if(res.success && res.data != null){
  128. des = res.data;
  129. }
  130. }
  131. });
  132. return des;
  133. },
  134. getCondition: function() {
  135. var rang = this.down('#condate').value, condition = '';
  136. if( !Ext.isEmpty(rang) ){
  137. if (caller.indexOf('ForeCast') > 0)
  138. condition = " ( sd_startdate " + rang + ") AND ";
  139. else
  140. condition = "( sd_delivery " + rang + " ) AND ";
  141. }
  142. var orderKind = caller.indexOf("Sale") > 0 ? 'SALE' : 'FORECAST';
  143. var sourcecode = this.getFields("MPSMain","mm_sourcecode","mm_id="+keyValue);
  144. if (sourcecode && sourcecode!='' && sourcecode!=' ' && sourcecode!='ALL' && sourcecode!='全部' ){
  145. if(OrderKind=='SALE'){
  146. condition=condition+" and sa_cop='"+sourcecode+"' ";
  147. }else if(OrderKind=='FORECAST'){
  148. condition=condition+" and sf_cop='"+sourcecode+"' ";
  149. }
  150. }
  151. if ( kind == 'MDS' ) {
  152. condition += " sd_id not in (select mdd_sdid from mdsdetail where mdd_orderkind='"
  153. + orderKind + "' AND mdd_mainid=" + keyValue + ") ";
  154. } else {
  155. condition += " sd_id not in (select md_sdid from mpsdetail where md_orderkind='"
  156. + orderKind + "' AND md_mainid=" + keyValue + ") ";
  157. }
  158. return condition;
  159. }
  160. });