123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- /**
- * grid,tip显示物料分仓库存
- */
- Ext.define('erp.view.core.plugin.ProdOnhand', {
- ptype : 'prodonhand',
- constructor : function(cfg) {
- if (cfg) {
- Ext.apply(this, cfg);
- }
- },
- prodKey: 'pr_code',
- init : function(grid) {
- this.grid = grid;
- var me = this, view = grid.view.normalView || grid.view;
- if (view) {
- view.on({
- scope: me,
- render: me.renderTip
- })
- var views = grid.view.lockedView;
- if(views){
- views.on({
- scope: me,
- render: me.renderTip
- })
- }
- grid.store.on({
- scope: me,
- load: me.getProductWh
- });
- }
- },
- renderTip: function(view) {
- if (!view.tip) {
- var me = this;
- view.tip = me.createTip(view);
- view.tip.on({
- beforeshow : function() {
- me.updateTipBody(view, view.tip);
- }
- });
- }
- },
- createTip : function(view) {
- return Ext.create('Ext.tip.ToolTip', {
- target : view.el,
- delegate : view.itemSelector,
- trackMouse : true,
- renderTo : Ext.getBody(),
- maxWidth :500,
- items : [{
- xtype : 'grid',
- width : 382,
- columns : [ {
- text : '仓库编号',
- cls : 'x-grid-header-1',
- dataIndex : 'PW_WHCODE',
- width : 140
- },{
- text : '仓库名称',
- cls : 'x-grid-header-1',
- dataIndex : 'WH_DESCRIPTION',
- width : 150
- }, {
- text : '库存',
- cls : 'x-grid-header-1',
- xtype : 'numbercolumn',
- dataIndex : 'PW_ONHAND',
- width : 100
- }/*, {
- text : '可用库存',
- cls : 'x-grid-header-1',
- xtype : 'numbercolumn',
- dataIndex : 'FREEONHAND',
- width : 90
- }*/ ],
- columnLines : true,
- title : '物料分仓库存',
- store : new Ext.data.Store({
- fields : [ 'PW_WHCODE', 'WH_DESCRIPTION', 'PW_ONHAND'/*, 'FREEONHAND'*/ ],
- data : [ {} ]
- })
- } ]
- });
- },
- updateTipBody : function(view, tip) {
- var me = this, record = view.getRecord(tip.triggerElement);
- if (record && me.grid.productwh) {
- var c = record.get(me.prodKey), pws = new Array();
- Ext.each(me.grid.productwh, function(d) {
- if (d.PW_PRODCODE == c) {
- pws.push(d);
- }
- });
- tip.down('grid').setTitle(c);
- tip.down('grid').store.loadData(pws);
- }
- },
- getProductWh : function() {
- var me = this, codes = [];
- me.grid.store.each(function(d) {
- var p = d.get(me.prodKey);
- if(!Ext.isEmpty(p))
- codes.push("'" + p + "'");
- });
- if(codes.length > 0) {
- Ext.Ajax.request({
- url : basePath + 'scm/product/getProductwh.action',
- params : {
- codes : codes.join(','),
- useFactory:me.grid.ifOnlyShowUserFactoryWh||false //根据登录用户所属工厂获取对应仓库分仓库存
- },
- callback : function(opt, s, r) {
- if (s) {
- var rs = Ext.decode(r.responseText);
- if (rs.data) {
- me.productWh = rs.data;
- }
- }
- }
- });
- } else {
- me.productWh = [];
- }
- }
- });
|