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_brand', to: 'pr_brand' },{ from: 'pr_orispeccode', to: 'pr_orispeccode' },{ from: 'pr_unit', to: 'pr_unit' }, { from: 'pr_unit', to: 'pr_unit' }, { from: 'po_avprice', to: 'mm_price' }], }); } }, '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' }, { from: 'pr_orispeccode', to: 'ma_prodorispec' }, { from: 'pr_whid', to: 'ma_whid' }, { from: 'pr_whcode', to: 'ma_whcode' }, { from: 'pr_whname', to: 'ma_whname' }], aftertrigger: function (f, record) { if(record.data.id&&record.data.id>0){ me.getBomData(record.data.id) } } }); } }, }); }, price_change: function (v) { var me = this, viewModel = me.getViewModel(), store = viewModel.get('detail0').detailStore, type = viewModel.get('ma_type'); if ('拆件' == type && v == 0) { saas.util.BaseUtil.showErrorToast('成本单价为0!'); } }, 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 }) }); form.setDetailData(loadData); } }) .catch(function (e) { saas.util.BaseUtil.showErrorToast('获取BOM资料失败: ' + e.message); }); } });