将分配仓库默认为第一条合同的送达仓库:Ext.define('erp.master.deliveryNoteManager.view.ContractAllocate', {
extend: 'erp.ux.Panel',
alias: 'widget.contract_allocate',
iconCls: 'page_find',
closable: true,
listeners: {
'close': function (cmp) {
var me = this;
cmp.destroy();
}
},
initComponent: function () {
var me = this;
var login_id = me.login_id;
var ip = me.ip;
me.ckStore = Ext.create('erp.master.deliveryNoteManager.store.QyWareHouse',{autoLoad:true});
Ext.apply(me.ckStore.proxy.extraParams, {
shqybh: me.shqybh
});
me.topStore = Ext.create('erp.master.deliveryNoteManager.store.ContractSumBot');
me.botStore = Ext.create('erp.master.deliveryNoteManager.store.ContractSumTop');
me.topStore.load({params: {login_id: login_id, ip: ip}});
me.botStore.load({params: {login_id: login_id, ip: ip}});
me.topStore.on({ //用于选择第一条记录
load: function (s, recs) {
var grid = me.down('#grid_top');
erp.Util.gridSelect(grid, recs);
}
});
Ext.apply(me, {
layout: {type: 'border', padding: 2},
tbar: [
{labelWidth:60,fieldLabel:erp.i18n.btn_fpck || '分配仓库',
xtype : 'combo',
store : me.ckStore,
queryMode: 'remote',
labelWidth:80,
columnWidth: 0.5,
itemId: 'ckbh',
displayField : 'ckmc',
valueField: 'ckbh'
},
{text: erp.i18n.btn_btn_confirm || '确定', itemId: 'btn_confirm'},
{text: erp.i18n.btn_btn_updateAll || '批量修改', itemId: 'btn_update', hidden: true},
{
text: erp.i18n.btn_btn_out || '退出', itemId: 'btn_exit',
listeners: {
click: function (field, e) {
me.close();
}
}
}
],
items: [{
region: 'center',
flex: 1,
split: true,
itemId: 'grid_top',
xtype: 'grid',
overflowY: 'auto',
overflowX: 'auto',
selModel: Ext.create('Ext.selection.CheckboxModel'),
listeners: {
selectionchange: function (grid, recs) {
if (recs.length > 0) {
me.botStore.clearFilter(true);
me.botStore.filter([Ext.create('Ext.util.Filter', {
filterFn: function (item) {
return item.get('clhh') == recs[0].get('clhh') && item.get('cltx1') == recs[0].get('cltx1');
}, root: 'data'
})]);
}
}
},
features: [{
ftype: 'summary',
summaryType: 'count',
dock: 'bottom'
}],
columns: [
{
header: erp.i18n.bq_clhh || '材料货号', dataIndex: 'clhh', width: 70,
summaryRenderer: function (value, summaryData, dataIndex) {
return erp.i18n.qt_heji || '合计';
}
},
{header: erp.i18n.bq_lbmc || '材料类别', dataIndex: 'lbmc', width: 80},
{header: erp.i18n.bq_clmc || '材料名称', dataIndex: 'clmc', width: 320},
{header: erp.i18n.bq_cltx1 || '规格尺寸', dataIndex: 'cltx1', width: 80},
{header: erp.i18n.bq_jldw || '单位', dataIndex: 'jldw', width: 50},
{
header: erp.i18n.bq_dhsl || '到货数量', dataIndex: 'dhsl', width: 80, align: 'right',
field: {
xtype: 'numberfield',
decimalPrecision: 4,
selectOnFocus: true,
minValue: 0
}, summaryType: 'sum', summaryRenderer: function (value, summaryData, dataIndex) {
return Ext.util.Format.number(value, '0,000');
}
},
{header: erp.i18n.bq_fzdw || '辅助单位', dataIndex: 'fzdw', width: 50},
{
header: erp.i18n.bq_fzsl || '辅助数量', dataIndex: 'fzsl', width: 80, align: 'right',
field: {
xtype: 'numberfield',
decimalPrecision: 4,
selectOnFocus: true,
minValue: 0
}
},
{header: erp.i18n.bq_tmdhsl || '收货数量', dataIndex: 'tmdhsl', width: 80, align: 'right'},
{header: erp.i18n.bq_tmxs || '收货箱数', dataIndex: 'tmxs', width: 80, align: 'right'}
],
store: me.topStore,
plugins: Ext.create('Ext.grid.plugin.CellEditing', {
ptype: 'cellediting',
clicksToEdit: 1,
autoCancel: false,
listeners: {
edit: function (field, e) {
var rec = e.record;
var botRecs = me.botStore.getRange();
switch (e.field) {
case 'dhsl':
var newDhsl = e.value;
var wdsl = rec.get('wdsl');
var fzzbj = rec.get('fzzbj');
var zhxs = rec.get('zhxs');
if (fzzbj != 2 && fzzbj != 4 && fzzbj != 5 && fzzbj != 6) {
if (zhxs != 0) {
rec.set('fzsl', Ext.util.Format.round(newDhsl * zhxs, 3));
} else {
rec.set('fzsl', 0);
}
}
if (newDhsl > wdsl) {
Ext.each(botRecs, function (r) {
r.set('bcdh', Ext.util.Format.round(newDhsl * r.get('dhsl') / wdsl, 3));
if (fzzbj != 2 && fzzbj != 4 && fzzbj != 5 && fzzbj != 6) {
if (zhxs != 0) {
r.set('bcfzsl', Ext.util.Format.round(newDhsl * zhxs * r.get('dhsl') / wdsl, 3))
} else {
r.set('bcfzsl', 0);
}
}
});
} else {
Ext.each(botRecs, function (r) {
var bcdh = r.get('dhsl');
if (bcdh > newDhsl || newDhsl == 0) {
r.set('bcdh', newDhsl);
if (fzzbj != 2 && fzzbj != 4 && fzzbj != 5 && fzzbj != 6) {
if (zhxs != 0) {
r.set('bcfzsl', Ext.util.Format.round(newDhsl * zhxs, 3))
} else {
r.set('bcfzsl', 0);
}
}
} else {
r.set('bcdh', bcdh);
if (fzzbj != 2 && fzzbj != 4 && fzzbj != 5 && fzzbj != 6) {
if (zhxs != 0) {
r.set('bcfzsl', Ext.util.Format.round(bcdh * zhxs, 3))
} else {
r.set('bcfzsl', 0);
}
}
}
newDhsl = Ext.util.Format.round(newDhsl - r.get('bcdh'), 3);
});
}
// me.botStore.sync();
break;
case 'fzsl':
if (rec.get('fzdw') == null || rec.get('fzdw').trim() == '') {
break;
}
var newFzsl = e.value;
var wdsl = rec.get('wdsl');
var fzzbj = rec.get('fzzbj');
var zhxs = rec.get('zhxs');
if (fzzbj != 2 && fzzbj != 4 && fzzbj != 5 && fzzbj != 6) {
if (zhxs != 0) {
rec.set('dhsl', Ext.util.Format.round(newFzsl / zhxs, 3));
} else {
rec.set('fzsl', 0);
}
var dhzs = rec.get('dhsl');
if (dhzs > wdsl) {
Ext.each(botRecs, function (r) {
r.set('bcdh', Ext.util.Format.round(dhzs * r.get('dhsl') / wdsl, 3));
r.set('bcfzsl', Ext.util.Format.round(newFzsl * r.get('dhsl') / wdsl, 3))
});
} else {
Ext.each(botRecs, function (r) {
var bcdh = r.get('dhsl');
if (bcdh > dhzs || dhzs == 0) {
r.set('bcdh', dhzs);
r.set('bcfzsl', Ext.util.Format.round(dhzs * zhxs, 3));
} else {
r.set('bcdh', bcdh);
r.set('bcfzsl', Ext.util.Format.round(bcdh * zhxs, 3));
}
dhzs = Ext.util.Format.round(dhzs - r.get('bcdh'), 3);
});
}
} else {
var wdsl = rec.get('wdsl');
var wrfzsl = rec.get('wrfzsl');
if (newFzsl > wrfzsl) {
Ext.each(botRecs, function (r) {
r.set('bcfzsl', Ext.util.Format.round(newFzsl * r.get('dhsl') / wdsl, 3));
});
} else {
Ext.each(botRecs, function (r) {
var bcfzsl = r.get('fzsl');
if (bcfzsl > newFzsl || newFzsl == 0) {
r.set('bcfzsl', newFzsl);
} else {
r.set('bcfzsl', bcfzsl);
}
newFzsl = Ext.util.Format.round(newFzsl - r.get('bcfzsl'), 3);
});
}
}
// me.botStore.sync();
break;
}
}
}
})
}, {
region: 'south',
split: true,
flex: 1,
itemId: 'grid_bot',
xtype: 'grid',
overflowY: 'auto',
overflowX: 'auto',
selModel: Ext.create('Ext.selection.CheckboxModel'),
features: [{
ftype: 'summary',
summaryType: 'count',
dock: 'bottom'
}],
columns: [
{
header: erp.i18n.bq_hth || '合同号', dataIndex: 'hth', width: 70,
summaryRenderer: function (value, summaryData, dataIndex) {
return erp.i18n.qt_heji || '合计';
}
},
{header: erp.i18n.bq_jhh || '计划号', dataIndex: 'jhh', width: 80},
{
header: erp.i18n.bq_wkjq || '采计交期', dataIndex: 'wkjq', width: 80,
align: 'center', xtype: 'datecolumn', format: 'Y-m-d'
},
{
header: erp.i18n.bq_jhrq || '交货日期', dataIndex: 'jhrq', width: 80,
align: 'center', xtype: 'datecolumn', format: 'Y-m-d'
},
{
header: erp.i18n.bq_sxrq || '上线日期', dataIndex: 'sxrq', width: 80,
align: 'center', xtype: 'datecolumn', format: 'Y-m-d'
},
{header: erp.i18n.bq_clhh || '材料货号', dataIndex: 'clhh', width: 70},
{header: erp.i18n.bq_lbmc || '材料类别', dataIndex: 'lbmc', width: 90},
{header: erp.i18n.bq_clmc || '材料名称', dataIndex: 'clmc', width: 200},
{header: erp.i18n.bq_cltx1 || '规格尺寸', dataIndex: 'cltx1', width: 70},
{header: erp.i18n.bq_jldw || '单位', dataIndex: 'jldw', width: 50},
{
header: erp.i18n.bq_bcdh || '到货数量', dataIndex: 'bcdh', width: 80, align: 'right',
renderer: function (v) {
if (v == 0) {
return ' ';
} else {
return v;
}
}, summaryType: 'sum', summaryRenderer: function (value, summaryData, dataIndex) {
return Ext.util.Format.round(value, 6);
}
},
{header: erp.i18n.bq_fzdw || '辅助单位', dataIndex: 'fzdw', width: 50},
{
header: erp.i18n.bq_bcfzsl || '辅助数量', dataIndex: 'bcfzsl', width: 80, align: 'right',
renderer: function (v) {
if (v == 0) {
return ' ';
} else {
return v;
}
}
},
{header: erp.i18n.bq_ztdwmc || '主体单位', dataIndex: 'ztdwmc', width: 180}
],
store: me.botStore
}]
});
me.callParent(arguments);
}
});
最新发布