B2CPurchase.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. Ext.define('erp.view.scm.purchase.B2CPurchase',{
  2. extend: 'Ext.Viewport',
  3. layout: 'anchor',
  4. hideBorders: true,
  5. initComponent : function(){
  6. var me = this;
  7. Ext.apply(me, {
  8. items: [{
  9. xtype: 'form',
  10. anchor: '100% 10%',
  11. defaultType: 'textfield',
  12. layout:'column',
  13. bodyStyle: 'background: #f1f1f1;border:none;',
  14. items:[{
  15. xtype:'tbtext',
  16. text:'排序策略',
  17. style: 'margin-left:10px;margin-top:4px;font-size:15px;border:1;'
  18. },{
  19. xtype: 'button',
  20. text : '交货周期',
  21. id:'deliverySort',
  22. width:85
  23. },{
  24. xtype: 'button',
  25. text : '价格',
  26. iconCls: 'x-button-icon-up',
  27. id:'priceSort',
  28. style:'background:#e3e3e3;',
  29. width:60
  30. },{
  31. columnWidth:.35,
  32. fieldLabel:'请输入购买数量',
  33. labelWidth:115,
  34. xtype:'numberfield',
  35. id:'buyQty',
  36. value :qty,
  37. style: 'margin-left:40px'
  38. },{
  39. columnWidth:.15,
  40. xtype: 'button',
  41. text:'自动分配数量',
  42. iconCls: 'x-button-icon-check',
  43. cls: 'x-btn-gray',
  44. id:'autoBtn'
  45. }]
  46. },{
  47. xtype: 'grid',
  48. anchor: '100% 50%',
  49. id:'reserveGrid',
  50. sortableColumns :false,
  51. store: Ext.create('Ext.data.Store',{
  52. fields: ['gb_b2bbatchcode','gb_price','gb_deliverytime','gb_madedate','gb_onsaleqty','gb_minbuyqty','gb_minpackqty','buyQty','gb_minprice'],
  53. data: [],
  54. autoLoad:true
  55. }),
  56. selType: 'cellmodel',
  57. plugins: [
  58. Ext.create('Ext.grid.plugin.CellEditing', {
  59. clicksToEdit: 1
  60. })
  61. ],
  62. columns: [{
  63. xtype : 'rownumberer',
  64. width : 35,
  65. sortable : false,
  66. text: '#',
  67. align :'center'
  68. },
  69. {
  70. text: '批次',
  71. dataIndex: 'gb_b2bbatchcode',
  72. flex: 1.8
  73. },{
  74. text: '单价',
  75. dataIndex: 'gb_price',
  76. flex: 1.5,
  77. renderer:function(val, meta, record){
  78. meta.style='white-space: normal;height: auto !important;';
  79. var da = new Ext.decode(val);
  80. var html = '';
  81. Ext.Object.each(da,function(key, value){
  82. html +='<div>'+value.start+'~'+value.end+'个:<span style="color:red">¥'+value.price+'</span></div>';
  83. });
  84. return html;
  85. }
  86. },{
  87. text: '交期',
  88. dataIndex: 'gb_deliverytime',
  89. flex: 0.8 ,
  90. renderer:function(val, meta, record){
  91. return val+'天';
  92. }
  93. },{
  94. text: '批次日期',
  95. dataIndex: 'gb_madedate',
  96. flex: 1.0,
  97. xtype: 'datecolumn',
  98. renderer:function(val, meta, record){
  99. return Ext.Date.format(new Date(val),'Y-m-d');
  100. }
  101. },{
  102. text: '库存',
  103. dataIndex: 'gb_onsaleqty',
  104. flex: 0.8
  105. },{
  106. text: '最小起订量',
  107. dataIndex: 'gb_minbuyqty',
  108. flex: 0.8,
  109. listeners:{
  110. afterrender: function(column) {}
  111. }
  112. },{
  113. text: '最小包装数',
  114. dataIndex: 'gb_minpackqty',
  115. flex: 1,
  116. listeners:{
  117. afterrender: function(column) {}
  118. }
  119. },{
  120. text: '购买数量',
  121. dataIndex: 'buyQty',
  122. xtype: 'numbercolumn',
  123. flex: 1,
  124. listeners:{
  125. afterrender: function(column) {}
  126. },
  127. renderer:function(val, meta, record){
  128. var minbuy = record.data['gb_minbuyqty'];
  129. var minpack = record.data['gb_minpackqty'];
  130. if(val!="" && val!=null && val <= 0){
  131. showError('购买数量必须大于0!');
  132. val = "";
  133. }
  134. if((val!="" && val!=null)&&((val>minpack && (val % minpack)) || val < minbuy)){
  135. showError('购买数量必须大于最小起订量并且是最小包装数的整数倍!');
  136. val = "";
  137. }
  138. if(val > record.data['gb_onsaleqty']){
  139. showError('购买数量不允许超过库存!');
  140. val = "";
  141. }
  142. if(record.data['buyQty'] != val) {
  143. record.set('buyQty', val);
  144. }
  145. //统计购买数量
  146. var grid = Ext.getCmp("reserveGrid");
  147. var sum1 = 0;
  148. var gdata = [];
  149. grid.store.each(function(record){
  150. sum1 += Number(record.data.buyQty);
  151. if(Number(record.data.buyQty)>0){
  152. gdata.push(Ext.clone(record.data));
  153. }
  154. });
  155. Ext.getCmp("getGrid").getStore().loadData(gdata);
  156. Ext.getCmp("totalbuyqty").setText('购买数量总计:' + sum1);
  157. return val;
  158. },
  159. editor:{
  160. xtype: 'numberfield',
  161. msgTarget: 'under'
  162. }
  163. },{
  164. xtype : 'numbercolumn',
  165. dataIndex: 'gb_minprice',
  166. sortable : true,
  167. align :'center',
  168. hidden:true
  169. }],
  170. listeners: {//滚动条有时候没反应,添加此监听器
  171. scrollershow: function(scroller) {
  172. if (scroller && scroller.scrollEl) {
  173. scroller.clearManagedListeners();
  174. scroller.mon(scroller.scrollEl, 'scroll', scroller.onElScroll, scroller);
  175. }
  176. }
  177. }
  178. },{
  179. title:'已选择数据',
  180. xtype: 'grid',
  181. anchor: '100% 40%',
  182. id:'getGrid',
  183. collapsible:true,
  184. sortableColumns :false,
  185. store: Ext.create('Ext.data.Store',{
  186. fields: ['gb_b2bbatchcode','gb_price','gb_deliverytime','gb_madedate','gb_onsaleqty','gb_minbuyqty','gb_minpackqty','buyQty'],
  187. data: [],
  188. autoLoad:true
  189. }),
  190. selType: 'cellmodel',
  191. plugins: [
  192. Ext.create('Ext.grid.plugin.CellEditing', {
  193. clicksToEdit: 1
  194. })
  195. ],
  196. columns: [{
  197. xtype : 'rownumberer',
  198. width : 35,
  199. sortable : false,
  200. text: '#',
  201. align :'center'
  202. },
  203. {
  204. text: '批次',
  205. dataIndex: 'gb_b2bbatchcode',
  206. flex: 1.8
  207. },{
  208. text: '单价',
  209. dataIndex: 'gb_price',
  210. flex: 1.5,
  211. renderer:function(val, meta, record){
  212. meta.style='white-space: normal;height: auto !important;';
  213. var da = new Ext.decode(val);
  214. var html = '';
  215. Ext.Object.each(da,function(key, value){
  216. html +='<div>'+value.start+'~'+value.end+'个:<span style="color:red">¥'+value.price+'</span></div>';
  217. });
  218. return html;
  219. }
  220. },{
  221. text: '交期',
  222. dataIndex: 'gb_deliverytime',
  223. flex: 0.8 ,
  224. renderer:function(val, meta, record){
  225. return val+'天';
  226. }
  227. },{
  228. text: '批次日期',
  229. dataIndex: 'gb_madedate',
  230. flex: 1.0,
  231. xtype: 'datecolumn',
  232. renderer:function(val, meta, record){
  233. return Ext.Date.format(new Date(val),'Y-m-d');
  234. }
  235. },{
  236. text: '库存',
  237. dataIndex: 'gb_onsaleqty',
  238. flex: 0.8
  239. },{
  240. text: '最小起订量',
  241. dataIndex: 'gb_minbuyqty',
  242. flex: 0.8
  243. },{
  244. text: '最小包装数',
  245. dataIndex: 'gb_minpackqty',
  246. flex: 1
  247. },{
  248. text: '购买数量',
  249. dataIndex: 'buyQty',
  250. xtype: 'numbercolumn',
  251. flex: 1
  252. }],
  253. bbar : [{
  254. id: 'totalbuyqty',
  255. xtype: 'tbtext',
  256. text: '购买数量总计:'
  257. },'-', '->',{
  258. text: '确 认',
  259. iconCls: 'x-button-icon-confirm',
  260. cls: 'x-btn-gray',
  261. xtype: 'button',
  262. id:'confirmBuyBtn'
  263. },{
  264. text : '关 闭',
  265. iconCls: 'x-button-icon-close',
  266. cls: 'x-btn-gray',
  267. xtype: 'button',
  268. handler : function(){
  269. parent.Ext.getCmp('dlwin').close();
  270. }
  271. },'->'],
  272. listeners: {//滚动条有时候没反应,添加此监听器
  273. scrollershow: function(scroller) {
  274. if (scroller && scroller.scrollEl) {
  275. scroller.clearManagedListeners();
  276. scroller.mon(scroller.scrollEl, 'scroll', scroller.onElScroll, scroller);
  277. }
  278. }
  279. }
  280. }]
  281. });
  282. me.callParent(arguments);
  283. }
  284. });