Index: ssts-web/src/main/webapp/disinfectsystem/invoice/materialInvoiceView.js =================================================================== diff -u -r26064 -r26354 --- ssts-web/src/main/webapp/disinfectsystem/invoice/materialInvoiceView.js (.../materialInvoiceView.js) (revision 26064) +++ ssts-web/src/main/webapp/disinfectsystem/invoice/materialInvoiceView.js (.../materialInvoiceView.js) (revision 26354) @@ -96,6 +96,7 @@ top.Ext.getCmp("sourceWarehouseId").setValue(records[0].data.id); top.Ext.getCmp('sourceWarehouseName').setValue(records[0].data.name); top.Ext.getCmp('name1').setDisabled(false); + top.Ext.getCmp('name2').setDisabled(false); } } //myMask.hide(); @@ -141,6 +142,32 @@ } } }); + + //器械包store + var tousseStore = new Ext.data.Store({ + pageSize : 100, + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectSystem/baseData/materialDefinitionAction!getTousseDefinitionDataForMaterial.do', + method : 'POST' + }), + reader : new Ext.data.JsonReader({ + totalProperty : 'totalCount', + root : 'data' + }, [ + {name : 'id',mapping : 'id'}, + {name : 'name',mapping : 'name'}, + {name : 'cost',mapping : 'cost'}, + {name : 'displayName',mapping : 'displayName'}, + {name : 'spelling',mapping : 'spelling'}, + {name : 'storage',mapping : 'storage'}, + {name : 'type',mapping : 'type'} + ]), + listeners : { + beforeload : function(store,option) { + store.baseParams['wareHouseId'] = top.Ext.getCmp('sourceWarehouseId').getValue(); + } + } + }); //使用记录数据源(高值耗材发货时必须选择使用记录) var userecordStore = new Ext.data.Store({ @@ -164,7 +191,7 @@ } }); - //添加明细 + //添加明细(单一种类材料) function addItems(materialDefinitionId,name,cost,amount,storage,userecordId,userecordName,userecordDepartCoding){ if(name == null || name == ''){ showResult("请填写物品名称!"); @@ -216,6 +243,77 @@ top.Ext.getCmp('name1').focus(); } + //添加明细(器械包材料) + function addItemsByToussedefinitionId(tousseDefinitionId, tousseName, amount, userecordId, userecordName, userecordDepartCoding) { + if(tousseDefinitionId == null || tousseDefinitionId == ''){ + showResult("请填选择器械包!"); + return false; + } + + if(amount == null || amount == ''){ + showResult("请填写数量!"); + return false; + } + + if(!top.Ext.getCmp('amount1').isValid()){ + showResult("请正确填写数量!"); + return false; + } + + for(var i = 0;i < top.Ext.getCmp('materialInvoiceItemGrid').getStore().getCount();i++){ + if(top.Ext.getCmp('materialInvoiceItemGrid').getStore().getAt(i).data.tousseDefinitionId == tousseDefinitionId + && top.Ext.getCmp('materialInvoiceItemGrid').getStore().getAt(i).data.userecordDepartCoding == userecordDepartCoding){ + showResult("该物品以及关联的使用记录已经存在,不能重复添加!"); + return false; + } + } + // 根据“器械包ID”查找“materialInvoiceItem” + Ext.Ajax.request({ + url : WWWROOT + '/disinfectSystem/baseData/materialDefinitionAction!findMaterialDefinitionByTousseDefinitionId.do', + params : {tousseDefinitionId : tousseDefinitionId}, + async : false, + success : function(response, options) { + var result = Ext.decode(response.responseText); + var totalCount = result.totalCount; + if (totalCount == 0) { + showResult("该器械包不包含任何物品!"); + return false; + } + for (var i = 0; i < result.totalCount; i++) { + var data = result.data[i]; + //添加操作 + var materialInvoiceItem = new MaterialInvoiceItemRecord({ + id : "", + tousseDefinitionId : tousseDefinitionId, + materialDefinitionId : data.materialDefinitionId, + materialName : data.materialName, + singlePrice : data.cost, + amount : data.count * amount, + userecordId : userecordId, + userecordName : userecordName, + userecordDepartCoding : userecordDepartCoding, + tousseName : tousseName + }); + top.Ext.getCmp('materialInvoiceItemGrid').getStore().add(materialInvoiceItem); + } + }, + failure : function(form, action) { + showResult("查找器械包材料出错!"); + return false; + } + }); + top.Ext.getCmp('toussedefinitionId').setValue(''); + top.Ext.getCmp('type').setValue(''); + top.Ext.getCmp('name2').setValue(''); + top.Ext.getCmp('cost').setValue(''); + top.Ext.getCmp('amount1').setValue(''); + top.Ext.getCmp('materialDefinitionId').setValue(''); + top.Ext.getCmp('userecordId').setValue(''); + top.Ext.getCmp('userecordName').setValue(''); + top.Ext.getCmp('userecordDepartCoding').setValue(''); + top.Ext.getCmp('name2').focus(); + } + var form = new top.Ext.FormPanel({ id : 'materialInvoiceForm', frame : true, @@ -329,6 +427,7 @@ select : function(combo,record,index){ top.Ext.getCmp("sourceWarehouseId").setValue(record.data.id); top.Ext.getCmp('name1').setDisabled(false); + top.Ext.getCmp('name2').setDisabled(false); } } }] @@ -403,7 +502,9 @@ cm : new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), {header : "id",dataIndex : 'id',hidden : true}, {header : "materialDefinitionId",dataIndex : 'materialDefinitionId',hidden : true}, - {header : "名称",dataIndex : 'materialName',width : 210,menuDisabled : true, + {header : "tousseDefinitionId",dataIndex : 'tousseDefinitionId',hidden : true}, + {header : "器械包名称",dataIndex : 'tousseName',width : 50}, + {header : "材料名称",dataIndex : 'materialName',width : 50,menuDisabled : true, editor : new top.Ext.form.ComboBox({ queryParam : 'spell', minChars : 0, @@ -426,7 +527,7 @@ }, {header : "使用记录id",dataIndex : 'userecordId',hidden : true}, {header : "使用记录的科室编码",dataIndex : 'userecordDepartCoding',hidden : true}, - {header : "使用记录",dataIndex : 'userecordName',width : 120/*,menuDisabled : true, + {header : "使用记录",dataIndex : 'userecordName',width : 60/*,menuDisabled : true, editor : new Ext.form.TextField({ readOnly : true, listeners : { @@ -444,25 +545,37 @@ } })*/ }, - {header : "单价",width : 40,menuDisabled : true,dataIndex : 'singlePrice', id:'singlePrice'}, - {header : " 数量",dataIndex : 'amount',width : 40,menuDisabled : true, + {header : "单价",width : 20,menuDisabled : true,dataIndex : 'singlePrice', id:'singlePrice'}, + {header : " 数量",dataIndex : 'amount',width : 20,menuDisabled : true, editor : new Ext.form.TextField({ regex: /^\d+$/, regexText:'只能输入数字', allowBlank : false }) }, - {header : "删除",width : 40,menuDisabled : true,dataIndex : 'deleteButton', id:'expandColumn', renderer:renderDeleteButton} + {header : "删除",width : 20,menuDisabled : true,dataIndex : 'deleteButton', id:'expandColumn', renderer:renderDeleteButton} ]), - width :735, - height : 250, + width : 950, + height : 400, autoExpandColumn : 'expandColumn', clicksToEdit : 1,// 设置点击几次才可编辑 selModel : new top.Ext.grid.RowSelectionModel({ singleSelect : false }), tbar : [{ xtype : 'hidden', + name : 'toussedefinitionId', + id : 'toussedefinitionId' + },{ + xtype : 'hidden', + name : 'type', + id : 'type' + },{ + xtype : 'hidden', + name : 'tousseName', + id : 'tousseName' + },{ + xtype : 'hidden', name : 'materialDefinitionId', id : 'materialDefinitionId' },{ @@ -474,6 +587,40 @@ name : 'cost', id : 'cost' },{ + text : ' 器械包:' + },{ + xtype : 'combo', + id : 'name2', + name : 'name2', + disabled : true, + queryParam : 'spell', + minChars : 0, + valueField : 'id', + displayField : 'displayName', + store : tousseStore, + pageSize : 100, + forceSelection : true, + lazyInit : false, + triggerAction : 'all', + hideTrigger : true, + typeAhead : false, + allowBlank : true, + width : 150, + listeners : { + select : function(combo, record, index) { + top.Ext.getCmp('type').setValue(record.data.type); + // 器械包 + top.Ext.getCmp('toussedefinitionId').setValue(record.data.id); + top.Ext.getCmp('tousseName').setValue(record.data.name); + top.Ext.getCmp('amount1').focus(false, 100); + }, + specialkey : function(field, ee) { + if (ee.getKey() == Ext.EventObject.ENTER) { + + } + } + } + },{ text : ' 材料:' },{ xtype : 'combo', @@ -492,7 +639,7 @@ hideTrigger : true, typeAhead : false, allowBlank : true, - width : 320, + width : 150, listeners : { select : function(combo, record, index) { top.Ext.getCmp('name1').setValue(record.data.name); @@ -560,16 +707,29 @@ text : '添加', iconCls : 'btn_ext_add', handler : function() { - var materialDefinitionId = top.Ext.getCmp('materialDefinitionId').getValue(); - var name = top.Ext.getCmp('name1').getValue(); - - var amount = top.Ext.getCmp('amount1').getValue(); - var storage = top.Ext.getCmp('storage').getValue(); - var userecordId = top.Ext.getCmp('userecordId').getValue(); - var userecordName = top.Ext.getCmp('userecordName').getValue(); - var userecordDepartCoding = top.Ext.getCmp('departCoding').getValue(); - var cost = top.Ext.getCmp('cost').getValue(); - addItems(materialDefinitionId,name,cost,amount,storage,userecordId,userecordName,userecordDepartCoding); + var type = top.Ext.getCmp('type').getValue(); + if (type !== '') { + // 器械包材料 + var toussedefinitionId = top.Ext.getCmp('toussedefinitionId').getValue(); + var tousseName = top.Ext.getCmp('tousseName').getValue(); + var amount = top.Ext.getCmp('amount1').getValue(); + var userecordId = top.Ext.getCmp('userecordId').getValue(); + var userecordName = top.Ext.getCmp('userecordName').getValue(); + var userecordDepartCoding = top.Ext.getCmp('departCoding').getValue(); + addItemsByToussedefinitionId(toussedefinitionId, tousseName, amount, userecordId, userecordName, userecordDepartCoding); + } else { + // 单一类型材料 + var materialDefinitionId = top.Ext.getCmp('materialDefinitionId').getValue(); + var name = top.Ext.getCmp('name1').getValue(); + + var amount = top.Ext.getCmp('amount1').getValue(); + var storage = top.Ext.getCmp('storage').getValue(); + var userecordId = top.Ext.getCmp('userecordId').getValue(); + var userecordName = top.Ext.getCmp('userecordName').getValue(); + var userecordDepartCoding = top.Ext.getCmp('departCoding').getValue(); + var cost = top.Ext.getCmp('cost').getValue(); + addItems(materialDefinitionId,name,cost,amount,storage,userecordId,userecordName,userecordDepartCoding); + } } }] })], @@ -642,7 +802,7 @@ id : 'materialInvoiceWin', layout : 'fit', title : '材料发货单信息', - width : 810, + width : 950, modal : true, autoHeight : true, border :false,