Index: ssts-web/src/main/webapp/disinfectsystem/materialmanager/materialOutView.js =================================================================== diff -u -r15581 -r16861 --- ssts-web/src/main/webapp/disinfectsystem/materialmanager/materialOutView.js (.../materialOutView.js) (revision 15581) +++ ssts-web/src/main/webapp/disinfectsystem/materialmanager/materialOutView.js (.../materialOutView.js) (revision 16861) @@ -36,7 +36,7 @@ var supplierStore = new Ext.data.Store({ proxy : new Ext.data.HttpProxy({ - url : WWWROOT + '/disinfectSystem/baseData/supplierAction!getSupplierData.do?supplierType='+encodeURI(supplier), + url : WWWROOT + '/disinfectSystem/materialSupplierAction!getSupplierData.do', method : 'POST' }), reader : new Ext.data.JsonReader({ @@ -48,7 +48,10 @@ }, { name : 'name', mapping : 'name' - }]) + }]), + beforeload : function(store,option) { + store.baseParams['materialId'] = top.Ext.getCmp('materialId').getValue(); + } }); var GodownEntryItemRecord = Ext.data.Record.create([ @@ -114,6 +117,7 @@ top.Ext.getCmp('cost1').setValue(''); top.Ext.getCmp('materialId').setValue(''); top.Ext.getCmp('supplier1').setValue(''); + top.Ext.getCmp('supplierId').setValue(''); top.Ext.getCmp('name1').focus(); } @@ -138,6 +142,62 @@ }); function addGodownEntry(type) { + + //单价数据源 + var priceStore = null; + var PriceRecord = null; + + //单价数据源 + if(priceStore == null){ + priceStore = new Ext.data.Store({ + reader : new Ext.data.JsonReader({ + fields : [ + {name : 'price'}, + {name : 'fluctuationPrice'}, + {name : 'amount'} + ] + }) + }); + } + if(PriceRecord == null){ + PriceRecord = Ext.data.Record.create([ + {name : 'price'}, + {name : 'fluctuationPrice'}, + {name : 'amount'} + ]); + } + + // 清除表单数据 + function clearFormData(){ + priceStore.removeAll(); + } + // 清空批次和价格 + function clearBatchNumberAndPrice() { + clearPrice(); + } + // 清空价格 + function clearPrice() { + clearCombo(priceStore,'cost1'); + } + //设置价格 + function setPrices(prices,selectFirst) { + clearPrice() + if(typeof(prices) == 'undefined' || prices == null){ + return; + } + for(var i = 0;i 0){ + setCmpValue('cost1',prices[0].price); + } + } + } + var wareHouseStore = new Ext.data.JsonStore({ url : WWWROOT + '/disinfectSystem/baseData/wareHouseAction!getWareHouseData.do', root: 'data', @@ -378,6 +438,10 @@ name : 'materialId', id : 'materialId' },{ + xtype : 'hidden', + name : 'supplierId', + id : 'supplierId' + },{ text : '名称:' },{ xtype : 'combo', @@ -399,7 +463,7 @@ select : function(combo, record, index) { top.Ext.getCmp('name1').setValue(record.data.name); top.Ext.getCmp('materialId').setValue(record.data.id); - top.Ext.getCmp('cost1').setValue(record.data.cost); +// top.Ext.getCmp('cost1').setValue(record.data.cost); }, specialkey : function(field, ee) { if (ee.getKey() == Ext.EventObject.ENTER) { @@ -428,7 +492,15 @@ width : 150, listeners : { select : function(combo, record, index) { + top.Ext.getCmp('supplierId').setValue(record.data.id); combo.setValue(record.data.name); + var materialId = top.Ext.getCmp('materialId').getValue(); + // 清空价格 + clearPrice(); + // 填充价格 + MaterialEntryTableManager.getPriceAmountInfo(record.data.id,materialId,top.Ext.getCmp('wareHouseId').getValue(),function(priceAmounts){ + setPrices(priceAmounts,true); + }); }, specialkey : function(field, e) { if (e.getKey() == Ext.EventObject.ENTER) { @@ -457,26 +529,20 @@ },{ text : '单价:' },{ - xtype : 'textfield', - maxLength : '16', + xtype : 'combo', id : 'cost1', name : 'cost1', + valueField : 'price', + displayField : 'priceForDisplay', + store : priceStore, + editable : false, + forceSelection : true, + mode : 'local', + triggerAction : 'all', + typeAhead : false, + allowBlank : false, width : 50, - regex: /^(([1-9]+[0-9]*.{1}[0-9]+)|([0].{1}[1-9]+[0-9]*)|([1-9][0-9]*)|([0][.][0-9]+[1-9]*))$/, - regexText:'只能输入正数', - anchor : '95%', - listeners : { - specialkey : function(field, e) { - if (e.getKey() == Ext.EventObject.ENTER) { - var materialId = top.Ext.getCmp('materialId').getValue(); - var name = top.Ext.getCmp('name1').getValue(); - var count = top.Ext.getCmp('amount1').getValue(); - var cost = top.Ext.getCmp('cost1').getValue(); - var supplierName = top.Ext.getCmp('supplier1').getValue(); - addItems(materialId,name,count,cost,supplierName); - } - } - } + anchor : '95%' },{ text : '添加', iconCls : 'btn_ext_add', @@ -492,6 +558,55 @@ ] })], buttons : [{ + id : 'btnSave', + text : '保存', + handler : function() { + + var itemGrid = top.Ext.getCmp('materialEntryItemGrid'); + var store = itemGrid.getStore(); + if(store.getCount()<=0){ + showResult('请添加材料。'); + return false; + } + + var jsonArray = new Array(); + for(var i = 0;i < store.getCount();i++){ + var record = store.getAt(i); + var len = jsonArray.length; + jsonArray[len] = {}; + jsonArray[len].id = record.data.id; + jsonArray[len].materialId = record.data.materialId; + jsonArray[len].amount = record.data.amount; + jsonArray[len].cost = record.data.cost; + jsonArray[len].supplierName = record.data.supplierName; + jsonArray[len].certification = record.data.certification; + jsonArray[len].hasInvoice = record.data.hasInvoice; + jsonArray[len].goodsType = record.data.goodsType; + } + top.Ext.getCmp("items").setValue(Ext.encode(jsonArray)); + +// top.Ext.getCmp("wareHouseId").setValue(top.Ext.getCmp("wareHouseName").getValue()); + + form.form.submit({ + url : WWWROOT + '/disinfectSystem/MaterialEntryAction!saveMaterialEntryAction.do', + method : 'POST', + waitMsg : '正在保存数据,请稍候', + waitTitle : '提交表单', + success : function(form, action) { + showResult(action.result.message); + grid.dwrReload(); + window.close(); + }, + failure : function(form, action) { + if(action.result && action.result.message){ + showResult(action.result.message); + }else{ + showResult("提交失败"); + } + } + }); + } + },{ text : '取消', handler : function() { window.close(); @@ -574,8 +689,7 @@ function editRecord(id){ addGodownEntry(); - //这个js会报错,暂时屏蔽 - // top.Ext.getCmp('btnSave').setDisabled(true); + top.Ext.getCmp('btnSave').setDisabled(true); top.Ext.getCmp("serialNum").show(); top.Ext.getCmp('godownEntryForm').form.load({ url : WWWROOT + '/disinfectSystem/MaterialEntryAction!loadMaterialEntry.do', @@ -653,7 +767,7 @@ } },{ text : '删除', - hidden : SSTS_WarehouseEntry_Delete, + hidden : true,//SSTS_WarehouseEntry_Delete, iconCls : 'btn_ext_application_del', handler : function() { deleteGodownEntry(grid);