Browse Source

修改制造界面

zhoudw 7 years ago
parent
commit
e9489fb708

+ 49 - 20
frontend/saas-web/app/view/stock/make/FormPanel.js

@@ -19,8 +19,9 @@ Ext.define('saas.view.stock.make.FormPanel', {
      _readUrl:'/api/storage/make/read/',
      _saveUrl:'/api/storage/make/save',
      _auditUrl:'/api/storage/make/audit',
-    _unAuditUrl: '/api/storage/make/unAudit/',
+     _unAuditUrl: '/api/storage/make/unAudit/',
      _deleteUrl:'/api/storage/make/delete/',
+     _getBomUrl:'/api/document/bom/read/',
      initId:0,
  
      toolBtns: [],
@@ -33,7 +34,7 @@ Ext.define('saas.view.stock.make.FormPanel', {
     },{
         xtype: 'combobox',
         name: 'ma_type',
-        columnWidth: 0.2,
+        columnWidth: 0.25,
         fieldLabel: '类型',
         queryMode: 'local',
         displayField: 'name',
@@ -49,67 +50,68 @@ Ext.define('saas.view.stock.make.FormPanel', {
     },{
         xtype: 'hidden',
         name: 'ma_prodid',
-        fieldLabel: '产品id',
-        columnWidth: 0
+        fieldLabel: '产品id'
     },{
-        xtype : "dbfindtrigger", 
+        xtype : "dbfindtrigger",
+        editable:false, 
         name : "ma_prodcode", 
         fieldLabel : "产品编号",
-        columnWidth: 0.2
+        allowBlank : false,
+        columnWidth: 0.25
     },{
         xtype : "textfield", 
         name : "ma_proddetail", 
         fieldLabel : "名称",
-        columnWidth: 0.2
+        columnWidth: 0.25
     },{
         xtype : "textfield", 
         name : "ma_prodspec", 
         fieldLabel : "规格",
-        columnWidth: 0.2
+        columnWidth: 0.25
     },{
         xtype : "textfield", 
         name : "ma_version", 
         fieldLabel : "版本",
-        columnWidth: 0.2
+        columnWidth: 0.25
     },{
         xtype : "textfield", 
         name : "ma_produnit", 
         fieldLabel : "单位",
-        columnWidth: 0.2
+        columnWidth: 0.25
     },
     {
         xtype : "numberfield", 
         name : "ma_qty", 
         fieldLabel : "数量",
-        columnWidth: 0.2,
+        columnWidth: 0.25,
+        allowBlank : false,
         minValue:0
     },{
         xtype : "hidden", 
         name : "ma_whid", 
-        fieldLabel : "仓库id",
-        columnWidth: 0
+        fieldLabel : "仓库id"
     },{
         xtype : "hidden",
         name : "ma_whcode", 
-        fieldLabel : "仓库编号",
-        columnWidth: 0
+        fieldLabel : "仓库编号"
     },{
         xtype : "dbfindtrigger",
         name : "ma_whname",
         fieldLabel : "仓库名称",
-        columnWidth: 0.2
+        allowBlank : false,
+        columnWidth: 0.25
     },{
         xtype : "numberfield", 
         name : "ma_price", 
         fieldLabel : "单位成本",
         decimals:8,
-        columnWidth: 0.2
+        columnWidth: 0.25
     },{
         xtype : "numberfield", 
         name : "ma_total", 
         fieldLabel : "总成本",
         decimals:2,
-        columnWidth: 0.2
+        columnWidth: 0.25
     },
     {
         name : "detailGridField", 
@@ -134,6 +136,7 @@ Ext.define('saas.view.stock.make.FormPanel', {
                 text : "物料编号", 
                 width : 200.0, 
                 dataIndex : "mm_prodcode", 
+                allowBlank : false,
                 xtype : "", 
                 items : null,
                 editor : {
@@ -178,7 +181,7 @@ Ext.define('saas.view.stock.make.FormPanel', {
                 }
             },            
             {
-                text : "数量", 
+                text : "需求数量", 
                 dataIndex : "mm_qty", 
                 width : 120.0,
                 editor : {
@@ -199,7 +202,32 @@ Ext.define('saas.view.stock.make.FormPanel', {
                     var format = '0.' + xr.join();
                     return Ext.util.Format.number(v, format);
                 }
-            },{
+            },
+            {
+                text : "单位用量", 
+                dataIndex : "mm_oneuseqty", 
+                width : 120.0,
+                editor : {
+                    xtype : "numberfield",
+                    decimalPrecision: 8,
+                    editable:false,
+                    minValue:0
+                },
+                renderer : function(v) {
+                    var arr = (v + '.').split('.');
+                    var xr = (new Array(arr[1].length)).fill('0');
+                    var format = '0.' + xr.join();
+                    return Ext.util.Format.number(v, format);
+                },
+                summaryType: 'sum',
+                summaryRenderer: function(v) {
+                    var arr = (v + '.').split('.');
+                    var xr = (new Array(arr[1].length)).fill('0');
+                    var format = '0.' + xr.join();
+                    return Ext.util.Format.number(v, format);
+                }
+            },            
+            {
                 text : "仓库id",
                 dataIndex : "mm_whid",
                 xtype : "numbercolumn",
@@ -215,6 +243,7 @@ Ext.define('saas.view.stock.make.FormPanel', {
                 dataIndex : "mm_whname",
                 width : 120.0,
                 items : null,
+                allowBlank : false,
                 editor : {
                     displayField : "display",
                     editable : true,

+ 91 - 75
frontend/saas-web/app/view/stock/make/FormPanelController.js

@@ -240,38 +240,35 @@ Ext.define('saas.view.stock.make.FormPanelController', {
                 beforerender:function(f){
                     Ext.apply(f,{
                         //数据接口
-                        dataUrl:'/api/document/product/list',
-                        addXtype: 'document-product-formpanel',
-                        addTitle: '物料资料',
+                        dataUrl:'/api/document/bom/list',
+                        addXtype: 'document-bom-formpanel',
+                        addTitle: 'BOM资料',
                         //放大镜赋值设置
                         dbfinds:[{
-                            from:'pr_code',to:'ma_prodcode'
-                        },{
                             from:'id',to:'ma_prodid'
                         },{
-                            from:'pr_detail',to:'ma_proddetail'
-                        },{
-                            from:'pr_spec',to:'ma_prodspec'
+                            from:'bo_mothercode',to:'ma_prodcode'
                         },{
-                            from:'pr_unit',to:'ma_produnit'
+                            from:'bo_mothername',to:'ma_proddetail'
                         }],
                         //联想设置
                         dbtpls:[{
-                            field:'pr_code',width:100
-                        },{
-                            field:'pr_detail',width:100
+                            field:'bo_mothercode',width:100
                         },{
-                            field:'pr_spec',width:100
+                            field:'bo_mothername',width:100
                         }],
-                        defaultCondition:"pr_statuscode='OPEN'",
+                        aftertrigger:function(f,record){
+                            me.getBomData(record.data.id)
+                        },
+                        defaultCondition:"bo_statuscode='OPEN'",
                         //窗口字段设置
                         dbSearchFields:[{
-                            emptyText:'输入物料编号、名称或规格',
+                            emptyText:'输入BOM编号或名称',
                             xtype : "textfield", 
                             name : "search", 
                             width: 200,
                             getCondition: function(v) {
-                                return "(upper(pr_spec) like '%" + v.toUpperCase()+"%' or upper(pr_code) like '%"+v.toUpperCase()+"%' or upper(pr_detail) like '%"+v.toUpperCase()+"%')";
+                                return "(upper(bo_mothercode) like '%"+v.toUpperCase()+"%' or upper(bo_mothername) like '%"+v.toUpperCase()+"%')";
                             },
                             allowBlank : true, 
                             columnWidth : 0.25
@@ -283,63 +280,66 @@ Ext.define('saas.view.stock.make.FormPanelController', {
                             "dataIndex": "id",
                         }, {
                             "text": "物料编号",       
-                            "dataIndex": "pr_code",
+                            "dataIndex": "bo_mothercode",
                             "width": 200,
                         }, {
                             "text": "物料名称",
                             "width": 200,
-                            "dataIndex": "pr_detail",
-                        }, {
-                            "text": "规格",
-                            "dataIndex": "pr_spec",
-                            "width": 100,
-                        }, {
-                            "text": "单位",
-                            "dataIndex": "pr_spec",
-                            "width": 100,
-                        },{
-                            "text": "仓库id",
-                            "dataIndex": "pr_whid",
-                            "hidden": true,
-                        },{
-                            "text": "仓库编号",
-                            "dataIndex": "pr_whcode",
-                            "hidden": true,
-                        },{
-                            "text": "仓库",
-                            "dataIndex": "pr_whname",
-                            "width": 200,
-                        },{
-                            "text": "总库存数",
-                            "dataIndex": "po_onhand",
-                            "width": 100,
-                            align:'right'
-                        },{
-                            "text": "类型",
-                            "dataIndex": "pr_kind",
-                            "width": 100,
-                        },{
-                            "text": "型号",
-                            "dataIndex": "pr_orispeccode",
-                            "width": 100,
-                        },{
-                            "text": "品牌",
-                            "dataIndex": "pr_brand",
-                            "width": 100,
-                        },{
-                            "text": "供应商",
-                            "dataIndex": "pr_vendname",
-                            "width": 100,
-                        },{
-                            "text": "最小包装",
-                            "dataIndex": "pr_zxbzs",
-                            "width": 100,
-                            align:'right'
-                        },{
-                            "text": "L/T",
-                            "dataIndex": "pr_leadtime",
-                            "width": 100,
-                        }]
+                            "dataIndex": "bo_mothername",
+                        }
+                        // ,{
+                        //     "text": "规格",
+                        //     "dataIndex": "pr_spec",
+                        //     "width": 100,
+                        // }, {
+                        //     "text": "单位",
+                        //     "dataIndex": "pr_spec",
+                        //     "width": 100,
+                        // },{
+                        //     "text": "仓库id",
+                        //     "dataIndex": "pr_whid",
+                        //     "hidden": true,
+                        // },{
+                        //     "text": "仓库编号",
+                        //     "dataIndex": "pr_whcode",
+                        //     "hidden": true,
+                        // },{
+                        //     "text": "仓库",
+                        //     "dataIndex": "pr_whname",
+                        //     "width": 200,
+                        // },{
+                        //     "text": "总库存数",
+                        //     "dataIndex": "po_onhand",
+                        //     "width": 100,
+                        //     align:'right'
+                        // },{
+                        //     "text": "类型",
+                        //     "dataIndex": "pr_kind",
+                        //     "width": 100,
+                        // },{
+                        //     "text": "型号",
+                        //     "dataIndex": "pr_orispeccode",
+                        //     "width": 100,
+                        // },{
+                        //     "text": "品牌",
+                        //     "dataIndex": "pr_brand",
+                        //     "width": 100,
+                        // },{
+                        //     "text": "供应商",
+                        //     "dataIndex": "pr_vendname",
+                        //     "width": 100,
+                        // },{
+                        //     "text": "最小包装",
+                        //     "dataIndex": "pr_zxbzs",
+                        //     "width": 100,
+                        //     align:'right'
+                        // },{
+                        //     "text": "L/T",
+                        //     "dataIndex": "pr_leadtime",
+                        //     "width": 100,
+                        // }
+                    
+                    ]
                     }) ;   
 
                 }
@@ -466,23 +466,39 @@ Ext.define('saas.view.stock.make.FormPanelController', {
         viewModel.set('ma_price',sum_qty);
     },
 
-    turnIn: function() {
+
+     getBomData: function(v) {
         var me = this,
         form = me.getView(),
-        id = form.getForm().findField(form._idField);
+        viewModel = me.getViewModel(),
+        store = viewModel.get('detail0').detailStore,
+        loadData = new Array();;
+        //请求bom资料
         form.BaseUtil.request({
-            url: form._turnInUrl+id.value,
+            url: form._getBomUrl+v,
             method: 'GET',
         })
         .then(function(localJson) {
             if(localJson.success){
-                showToast('转单成功');
-              
+                var data = localJson.data.items;
+                Ext.Array.each(data, function(item, i) {
+                    loadData.push({
+                        mm_detno:item.bd_detno,
+                        mm_prodidid:item.bd_sonid,
+                        mm_prodcode:item.bd_soncode,
+                        mm_oneuseqty:item.bd_baseqty,
+                        pr_detail:'',
+                        pr_spec:'',
+                        pr_unit:''
+                    })                
+                });
+                store.loadData(loadData)
+        
             }
         })
         .catch(function(res) {
             console.error(res);
-            showToast('转单失败: ' + res.message);
+            showToast('获取BOM资料失败: ' + res.message);
         });
      }
 });

+ 17 - 0
frontend/saas-web/app/view/stock/make/FormPanelModel.js

@@ -2,4 +2,21 @@ Ext.define('saas.view.stock.make.FormPanelModel', {
     extend: 'saas.view.core.form.FormPanelModel',
     alias: 'viewmodel.stock-make-formpanel',
 
+    formulas: {
+        ma_qty_change: {
+            bind: '{ma_qty}',
+            get: function(v) {
+                var viewModel = this.getView().getViewModel(),
+                store = viewModel.get('detail0').detailStore,
+                items  = store.getData().items,
+                oneuseqty=0;
+                Ext.Array.each(items, function(item, i) {
+                    oneuseqty = item.get('mm_oneuseqty');
+                    item.set('mm_qty', oneuseqty*v);               
+                });
+                return v;
+            }
+        }
+    }
+
 });