Ext.define('saas.view.stock.make.FormPanelController', { extend: 'saas.view.core.form.FormPanelController', alias: 'controller.stock-make-formpanel', init: function (form) { var me = this; this.control({ //放大镜赋值关系 以及 tpl模板 'dbfindtrigger[name=ma_whname]':{ beforerender:function(f){ Ext.apply(f,{ dbfinds:[{ from:'id',to:'ma_whid',ignore:true },{ from:'wh_code',to:'ma_whcode' },{ from:'wh_description',to:'ma_whname' }], }) ; } }, //放大镜赋值关系 以及 tpl模板 'dbfindtrigger[name=mm_whname]':{ beforerender:function(f){ Ext.apply(f,{ dbfinds:[{ from:'id',to:'mm_whid',ignore:true },{ from:'wh_code',to:'mm_whcode' },{ from:'wh_description',to:'mm_whname' }] }) ; } }, 'multidbfindtrigger[name=mm_prodcode]':{ beforerender:function(f){ Ext.apply(f,{ dbfinds:[{ from:'pr_code',to:'mm_prodcode' },{ from:'id',to:'mm_prodid' },{ from:'pr_detail',to:'pr_detail' },{ from:'pr_spec',to:'pr_spec' },{ from:'pr_unit',to:'pr_unit' }], }) ; } }, 'bomDbfindTrigger[name=ma_prodcode]':{ beforerender:function(f){ Ext.apply(f,{ //放大镜赋值设置 dbfinds:[{ from:'bo_motherid',to:'ma_prodid' },{ from:'bo_mothercode',to:'ma_prodcode' },{ from:'bo_mothername',to:'ma_proddetail' },{ from:'pr_spec',to:'ma_prodspec' },{ from:'pr_unit',to:'ma_produnit' },{ from:'bo_version',to:'ma_version' }], aftertrigger:function(f,record){ me.getBomData(record.data.id) } }) ; } }, }); }, // price_change:function() { // var me = this, // viewModel = me.getViewModel(), // store = viewModel.get('detail0').detailStore; // var sum_qty = store.sum('mm_price'); // viewModel.set('ma_price',sum_qty); // }, getBomData: function(v) { var me = this, form = me.getView(), viewModel = me.getViewModel(), store = viewModel.get('detail0').detailStore, type = viewModel.get('ma_type'), loadData = new Array(); //请求bom资料 saas.util.BaseUtil.request({ url: form._getBomUrl+v, method: 'GET', }) .then(function(localJson) { if(localJson.success){ var data = localJson.data.items; Ext.Array.each(data, function(item, i) { loadData.push({ mm_detno:item.bd_detno, mm_prodid:item.productDTO.id, mm_prodcode:item.productDTO.pr_code, mm_oneuseqty:item.bd_baseqty, pr_detail:item.productDTO.pr_detail, pr_spec:item.productDTO.pr_spec, pr_unit:item.productDTO.pr_unit, mm_repprodcode:item.bd_replace, mm_remark:item.bd_remark, mm_whid:item.productDTO.pr_whid, mm_whcode:item.productDTO.pr_whcode, mm_whname:item.productDTO.pr_whname, mm_price:type=='拆件'?item.productDTO.pr_purcprice:null }) }); store.loadData(loadData); } }) .catch(function(res) { console.error(res); saas.util.BaseUtil.showErrorToast('获取BOM资料失败: ' + res.message); }); } });