Index: ssts-web/src/main/webapp/disinfectsystem/assestManagement/expensiveGoods/expensiveGoodsGodownEntryView.js =================================================================== diff -u -r21781 -r21797 --- ssts-web/src/main/webapp/disinfectsystem/assestManagement/expensiveGoods/expensiveGoodsGodownEntryView.js (.../expensiveGoodsGodownEntryView.js) (revision 21781) +++ ssts-web/src/main/webapp/disinfectsystem/assestManagement/expensiveGoods/expensiveGoodsGodownEntryView.js (.../expensiveGoodsGodownEntryView.js) (revision 21797) @@ -196,6 +196,7 @@ {name : 'invoicePlanId'}, {name : 'expensiveGoodsId'}, {name : 'expensiveGoodsName'}, + {name : 'expensiveGoodsdisplayName'}, {name : 'certification'}, {name : 'batchNumber'}, {name : 'model'}, @@ -233,6 +234,7 @@ * @param batchNumber 批次号 * @param manufacturerId 生产厂家id * @param manufacturerName 生产厂家名字 + * @param invoicePlanId 申请单id * @param expensiveGoodsId 高值耗材定义id * @param name 高值耗材名称 * @param cost 单价 @@ -244,12 +246,19 @@ * @param grade 类别 * @returns {Boolean} */ -function addItems(model,modelId,batchNumber,manufacturerId,manufacturerName,expensiveGoodsId,expensiveGoodsName,cost,expDate,certification,firstBodyCode,secondBodyCode,thirdBodyCode,grade){ +function addItems(model,modelId,batchNumber,manufacturerId,manufacturerName,invoicePlanId,expensiveGoodsId, + expensiveGoodsName,expensiveGoodsdisplayName,cost,expDate,certification,firstBodyCode,secondBodyCode,thirdBodyCode,grade){ + if(top.Ext.getCmp('name1').getValue() == null || top.Ext.getCmp('name1').getValue() == ''){ showResult("请填写物品名称!"); return false; } +/* if(top.Ext.getCmp('expensiveGoodsName1').getValue() == null || top.Ext.getCmp('expensiveGoodsName1').getValue() == ''){ + showResult("物品名称获取不到!"); + return false; + } +*/ if(top.Ext.getCmp('cost1').getValue() == null || top.Ext.getCmp('cost1').getValue() == ''){ showResult("请填写单价!"); return false; @@ -265,6 +274,11 @@ return false; } + if(invoicePlanId == null || invoicePlanId == ''){ + showResult("请选择要绑定的申请单!"); + return false; + } + if(top.Ext.getCmp('manufacturer1').getValue() == null || top.Ext.getCmp('manufacturer1').getValue() == ''){ showResult("请填写生产厂家商!"); return false; @@ -274,18 +288,23 @@ // showResult("请填写生产厂家商!"); // return false; // } - - for(var i = 0;i < top.Ext.getCmp('expensiveGoodsGodownEntryItemGrid').getStore().getCount();i++){ - var expensiveGoodsGodownEntryItemData = top.Ext.getCmp('expensiveGoodsGodownEntryItemGrid').getStore().getAt(i).data; - if(expensiveGoodsGodownEntryItemData.expensiveGoodsId == expensiveGoodsId - && (expensiveGoodsGodownEntryItemData.firstBodyCode && firstBodyCode && expensiveGoodsGodownEntryItemData.firstBodyCode == firstBodyCode) - && (expensiveGoodsGodownEntryItemData.secondBodyCode && secondBodyCode && expensiveGoodsGodownEntryItemData.secondBodyCode == secondBodyCode) - && (expensiveGoodsGodownEntryItemData.thirdBodyCode && thirdBodyCode && expensiveGoodsGodownEntryItemData.thirdBodyCode == thirdBodyCode)){ - showResult("该物品已经存在,不能重复添加!"); - return false; - } - } - + +// for(var i = 0;i < top.Ext.getCmp('expensiveGoodsGodownEntryItemGrid').getStore().getCount();i++){ +// var expensiveGoodsGodownEntryItemData = top.Ext.getCmp('expensiveGoodsGodownEntryItemGrid').getStore().getAt(i).data; +// if(expensiveGoodsGodownEntryItemData.expensiveGoodsId == expensiveGoodsId +// && (expensiveGoodsGodownEntryItemData.firstBodyCode && firstBodyCode && expensiveGoodsGodownEntryItemData.firstBodyCode == firstBodyCode) +// && (expensiveGoodsGodownEntryItemData.secondBodyCode && secondBodyCode && expensiveGoodsGodownEntryItemData.secondBodyCode == secondBodyCode) +// && (expensiveGoodsGodownEntryItemData.thirdBodyCode && thirdBodyCode && expensiveGoodsGodownEntryItemData.thirdBodyCode == thirdBodyCode)){ +// showResult("该物品已经存在,不能重复添加!"); +// return false; +// } +// } + + //填写的高值耗材名称是否存在于绑定的申请单里面 + if(!matchingInvoicePlan(expensiveGoodsId)){ + showResult("填写的高值耗材物品不存在于绑定的申请单里面!"); + return false; + }; //添加操作 var expensiveGoodsGodownEntryItem = new ExpensiveGoodsGodownEntryItemRecord({ localID:g_localID++, @@ -294,6 +313,7 @@ manufacturerName : manufacturerName, expensiveGoodsId : expensiveGoodsId, expensiveGoodsName : expensiveGoodsName, + expensiveGoodsdisplayName : expensiveGoodsdisplayName, certification:certification, batchNumber : batchNumber, model : model, @@ -423,8 +443,9 @@ return false; } var expensiveGoodsId = top.Ext.getCmp('expensiveGoodsId1').getValue(); - var expensiveGoodsName = top.Ext.getCmp('name1').getValue(); - if(expensiveGoodsName.length==0){ + var expensiveGoodsName = top.Ext.getCmp('expensiveGoodsName1').getValue(); + var expensiveGoodsdisplayName = top.Ext.getCmp('name1').getValue(); + if(expensiveGoodsdisplayName.length==0){ showResult('请填写物品名称!'); top.Ext.getCmp('name1').focus(false,100); return false; @@ -435,6 +456,12 @@ top.Ext.getCmp('cost1').focus(false,100); return false; } + var invoicePlanId = top.Ext.getCmp('invoicePlanId').getValue() + if(!invoicePlanId||invoicePlanId.length==0){ + showResult('请选择要绑定的申请单!'); + return false; + } + var expDate = top.Ext.getCmp('expDate1').getValue(); var manufacturerName = top.Ext.getCmp('manufacturer1').getValue(); var manufacturerId = top.Ext.getCmp('manufacturer1Id').getValue(); @@ -457,15 +484,17 @@ if(dateCompare(expDateStr,nextYearDate) != 1){ top.Ext.MessageBox.confirm("请确认","添加的物品失效日期在一年之内,确定要添加吗?",function(button, text){ if("yes" == button){ - addItems(model,"",batchNumber, manufacturerId , manufacturerName , expensiveGoodsId,expensiveGoodsName,cost,expDate,certification,firstBodyCode,secondBodyCode,thirdBodyCode,grade); + addItems(model,"",batchNumber, manufacturerId , manufacturerName ,invoicePlanId, expensiveGoodsId,expensiveGoodsName, + expensiveGoodsdisplayName,cost,expDate,certification,firstBodyCode,secondBodyCode,thirdBodyCode,grade); var grid = top.Ext.getCmp('expensiveGoodsGodownEntryItemGrid'); setTotalMoney(grid); top.Ext.getCmp('manufacturer1').focus(); top.Ext.getCmp('manufacturer1').selectText(); } }); }else{ - addItems(model,"",batchNumber,manufacturerId , manufacturerName , expensiveGoodsId,expensiveGoodsName,cost,expDate,certification,firstBodyCode,secondBodyCode,thirdBodyCode,grade); + addItems(model,"",batchNumber,manufacturerId , manufacturerName ,invoicePlanId, expensiveGoodsId,expensiveGoodsName, + expensiveGoodsdisplayName,cost,expDate,certification,firstBodyCode,secondBodyCode,thirdBodyCode,grade); var grid = top.Ext.getCmp('expensiveGoodsGodownEntryItemGrid'); setTotalMoney(grid); } @@ -565,7 +594,8 @@ id : resultEntryItem[i].id, expensiveGoodsId : resultEntryItem[i].expensiveGoodsId, //name : resultEntryItem[i].expensiveGoods.name + (b == false?"":" ["+specification+"]"), - expensiveGoodsName : resultEntryItem[i].expensiveGoods.name + (b == false?"":" ["+specification+"]"), + expensiveGoodsName : resultEntryItem[i].expensiveGoods.name, + expensiveGoodsdisplayName : resultEntryItem[i].expensiveGoods.name + (b == false?"":" ["+specification+"]"), cost : cost, certification : resultEntryItem[i].certification, batchNumber : resultEntryItem[i].batchNumber, Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManagerImpl.java =================================================================== diff -u -r21779 -r21797 --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManagerImpl.java (.../InvoicePlanManagerImpl.java) (revision 21779) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManagerImpl.java (.../InvoicePlanManagerImpl.java) (revision 21797) @@ -2702,31 +2702,34 @@ if(!DatabaseUtil.isPoIdValid(id)){ return null; } - List invoiceItemList = tousseItemManager.getByProperty("invoicePlanID", id); - if(CollectionUtils.isNotEmpty(invoiceItemList)){ - JSONArray jsonArray = new JSONArray(); - for (TousseItem tousseItem : invoiceItemList) { - JSONObject jsonObject = new JSONObject(); - Long expensiveGoodsId = tousseItem.getExpensiveGoodsId(); - ExpensiveGoods expensiveGoods = expensiveGoodsManager.get(expensiveGoodsId); - if(expensiveGoods!=null){ - RegistrationCertification certification = expensiveGoods.getRegistrationCertification(objectDao); - if(certification!=null){ - ExpensiveGoodsSupplier expensiveGoodsSupplier = certification.getExpensiveGoodsSupplier(); - if(expensiveGoodsSupplier!=null){ - jsonObject.put("invoicePlanManufacturerName", expensiveGoodsSupplier.getCompanyName());//生产厂家名字 - jsonObject.put("invoicePlanManufacturerId", expensiveGoodsSupplier.getId());//生产厂家id + InvoicePlan invoicePlan = this.get(id); + if(invoicePlan!=null){ + List invoiceItemList = invoicePlan.getApplicationItems(); + if(CollectionUtils.isNotEmpty(invoiceItemList)){ + JSONArray jsonArray = new JSONArray(); + for (TousseItem tousseItem : invoiceItemList) { + JSONObject jsonObject = new JSONObject(); + Long expensiveGoodsId = tousseItem.getExpensiveGoodsId(); + ExpensiveGoods expensiveGoods = expensiveGoodsManager.get(expensiveGoodsId); + if(expensiveGoods!=null){ + RegistrationCertification certification = expensiveGoods.getRegistrationCertification(objectDao); + if(certification!=null){ + ExpensiveGoodsSupplier expensiveGoodsSupplier = certification.getExpensiveGoodsSupplier(); + if(expensiveGoodsSupplier!=null){ + jsonObject.put("invoicePlanManufacturerName", expensiveGoodsSupplier.getCompanyName());//生产厂家名字 + jsonObject.put("invoicePlanManufacturerId", expensiveGoodsSupplier.getId());//生产厂家id + } } } + jsonObject.put("expensiveGoodsId", tousseItem.getExpensiveGoodsId()); + jsonObject.put("amount", tousseItem.getAmount()); + jsonObject.put("price", tousseItem.getPrice()); + jsonObject.put("showName", expensiveGoods.getShowName()); + jsonObject.put("name", expensiveGoods.getName()); + jsonArray.add(jsonObject); } - jsonObject.put("expensiveGoodsId", tousseItem.getExpensiveGoodsId()); - jsonObject.put("amount", tousseItem.getAmount()); - jsonObject.put("showName", expensiveGoods.getShowName()); - jsonObject.put("name", expensiveGoods.getName()); - jsonArray.add(jsonObject); + return jsonArray; } - - return jsonArray; } return null; } Index: ssts-web/src/main/webapp/disinfectsystem/assestManagement/expensiveGoods/expensiveGoodsGodownEntryForm.js =================================================================== diff -u -r21782 -r21797 --- ssts-web/src/main/webapp/disinfectsystem/assestManagement/expensiveGoods/expensiveGoodsGodownEntryForm.js (.../expensiveGoodsGodownEntryForm.js) (revision 21782) +++ ssts-web/src/main/webapp/disinfectsystem/assestManagement/expensiveGoods/expensiveGoodsGodownEntryForm.js (.../expensiveGoodsGodownEntryForm.js) (revision 21797) @@ -45,6 +45,7 @@ {name : 'showName',mapping : 'showName'}, {name : 'name',mapping : 'name'}, {name : 'amount',mapping : 'amount'}, + {name : 'price',mapping : 'price'}, {name : 'name',mapping : 'name'}, {name : 'invoicePlanManufacturerName',mapping : 'invoicePlanManufacturerName'}, {name : 'invoicePlanManufacturerId',mapping : 'invoicePlanManufacturerId'} @@ -61,10 +62,10 @@ var expensiveGoodsApplicationDetailCm = new Ext.grid.ColumnModel([ {header : "申请的物品Id",dataIndex : 'expensiveGoodsId',hidden : true,menuDisabled: true}, - {header : "申请的物品",dataIndex : 'showName',width : 180,menuDisabled: true}, - {header : "name",dataIndex : 'name',hidden : true,menuDisabled: true}, - {header : "申请数量",dataIndex : 'amount',menuDisabled: true}, - {header : "生产厂家",dataIndex : 'invoicePlanManufacturerName',menuDisabled: true}, + {header : "申请的物品",dataIndex : 'name',width : 100,menuDisabled: true}, + {header : "数量",dataIndex : 'amount',width : 50,menuDisabled: true}, + {header : "价格",dataIndex : 'price' ,width : 50,menuDisabled: true}, + {header : "生产厂家",dataIndex : 'invoicePlanManufacturerName',width : 100,menuDisabled: true}, {header : "生产厂家id",dataIndex : 'invoicePlanManufacturerId',hidden : true,menuDisabled: true} ]); @@ -516,6 +517,7 @@ {name : 'manufacturerName'}, {name : 'expensiveGoodsId'}, {name : 'expensiveGoodsName'}, + {name : 'expensiveGoodsdisplayName'}, {name : 'firstBodyCode'}, {name : 'secondBodyCode'}, {name : 'thirdBodyCode'}, @@ -535,9 +537,10 @@ cm : new top.Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), selectModel, {header : "id",dataIndex : 'id',hidden : true}, {header : "生产厂家id",dataIndex : 'manufacturerId',width : 130,hidden : true}, - {header : "生产厂家",dataIndex : 'manufacturerName',width : 100,menuDisabled : true}, {header : "expensiveGoodsId",dataIndex : 'expensiveGoodsId',hidden : true}, - {header : "物品名称",dataIndex : 'expensiveGoodsName',width : 130,menuDisabled : true}, + {header : "expensiveGoodsName",dataIndex : 'expensiveGoodsName',width : 130,hidden : true}, + {header : "生产厂家",dataIndex : 'manufacturerName',width : 100,menuDisabled : true}, + {header : "物品名称",dataIndex : 'expensiveGoodsdisplayName',width : 130,menuDisabled : true}, {header : "物品型号",dataIndex : 'model',width : 100,menuDisabled : true}, {header : "注册证号",width : 100,dataIndex : 'certification',menuDisabled : true, editor : new top.Ext.form.TextField({ @@ -633,6 +636,10 @@ name : 'barcode', id : 'barcode' },{ + xtype : 'hidden', + name : 'expensiveGoodsName1', + id : 'expensiveGoodsName1' + },{ text : '物品名称:' },{ xtype : 'combo', @@ -661,6 +668,7 @@ top.Ext.getCmp('name1').setValue(record.data.displayName); top.Ext.getCmp('name1').selectText(); top.Ext.getCmp('expensiveGoodsId1').setValue(record.data.id); + top.Ext.getCmp('expensiveGoodsName1').setValue(record.data.name); top.Ext.getCmp('cost1').setValue(record.data.referencePrice); top.Ext.getCmp('certification1').setValue(record.data.certification); top.Ext.getCmp('manufacturer1').setValue(record.data.madeCompanyName); @@ -803,7 +811,7 @@ columnWidth : 0.3, items:[ new top.Ext.grid.EditorGridPanel({ - id : 'invoicePlanDetail', + id : 'invoicePlanDetailGrid', title : '申请单明细', store : expensiveGoodsApplicationDetailStore, cm : expensiveGoodsApplicationDetailCm, @@ -917,7 +925,7 @@ for ( var i = 0, len = records.length; i < len; i++) { if(isUndefinedOrNullOrEmpty(records[i].data.id)){ - showResult(records[i].data.expensiveGoodsName + "未保存!请先保存再打印"); + showResult(records[i].data.expensiveGoodsdisplayName + "未保存!请先保存再打印"); return false; } items.push(records[i].data); @@ -947,8 +955,8 @@ }); } },/*{ - text : '打印验收单' - hidden:saveButton || (commonEntry.isOpen() ? true:false), + text : '打印验收单', + hidden:saveButton || (commonEntry.isOpen() ? false:true), handler: function(){ form.form.submit({ url : WWWROOT + '/disinfectSystem/expensiveGoodsGodownEntryAction!printSomeExpensiveGoodsGodownEntryItem.do', @@ -1003,6 +1011,7 @@ manufacturerName : record.data.manufacturerName, expensiveGoodsId : record.data.expensiveGoodsId, expensiveGoodsName : record.data.expensiveGoodsName, + expensiveGoodsdisplayName : record.data.expensiveGoodsdisplayName, certification : record.data.certification , cost : record.data.cost, expDate : record.data.expDate.format('Y-m-d'), @@ -1023,6 +1032,9 @@ showResult('请正确填写表单各值'); return false; } + if(!matchingInvoicePlanAmount(items)){ + return false; + } // var items = buildJSONStringFromStore(top.Ext.getCmp('expensiveGoodsGodownEntryItemGrid').getStore()); // top.Ext.getCmp("items").setValue(items); form.form.submit({ @@ -1128,6 +1140,7 @@ manufacturerName : record.data.manufacturerName, expensiveGoodsId : record.data.expensiveGoodsId, expensiveGoodsName : record.data.expensiveGoodsName, + expensiveGoodsdisplayName : record.data.expensiveGoodsdisplayName, certification : record.data.certification , cost : record.data.cost, expDate : record.data.expDate.format('Y-m-d'), @@ -1149,6 +1162,9 @@ showResult('请正确填写表单各值'); return false; } + if(!matchingInvoicePlanAmount(items)){ + return false; + } form.form.submit({ url : WWWROOT + '/disinfectSystem/expensiveGoodsGodownEntryAction!saveExpensiveGoodsGodownEntry.do', method : 'POST', @@ -1216,3 +1232,107 @@ expensiveGoodsGodownEntryWin.show(); top.Ext.getCmp('name1').focus(false, 100); } + +/** + * 检查入库物品是否存在于绑定的申请单里 + * @param expensiveGoodsId + * @returns {Boolean} + */ +function matchingInvoicePlan(expensiveGoodsId){ + console.log(expensiveGoodsId); + for(var i = 0;i < top.Ext.getCmp('invoicePlanDetailGrid').getStore().getCount();i++){ + var invoicePlanDetailData = top.Ext.getCmp('invoicePlanDetailGrid').getStore().getAt(i).data; +// console.log(invoicePlanDetailData.expensiveGoodsId); + if(invoicePlanDetailData.expensiveGoodsId == expensiveGoodsId){ + return true; + } + } + return false; +} + +////////////检查物品的入库数量是否大于等于申请单物品的申请数量 + +/** + * 检查物品的入库数量是否大于等于申请单物品的申请数量 + * @param items + * @returns {Boolean} + */ +function matchingInvoicePlanAmount(items){ + //console.log(items); + var itemsAmountArray = [];//要提交的入库单的物品数量数组 + var iPAmountArray = [];//绑定申请单的物品数量数组 + for (var i = 0;i < items.length; i++) { + collectItemsAmount(itemsAmountArray,items[i]); + } + for(var i = 0;i < top.Ext.getCmp('invoicePlanDetailGrid').getStore().getCount();i++){ + var iPDetailData = top.Ext.getCmp('invoicePlanDetailGrid').getStore().getAt(i).data; + collectInvoicePlanAmount(iPAmountArray,iPDetailData); + } + if(itemsAmountArray.length>0){ + for (var i = 0; i < itemsAmountArray.length; i++) { +// debugger; + if(!checkAmount(itemsAmountArray[i],iPAmountArray)){//若返回false:物品的入库数量小于申请单物品的申请数量 + return false; + } + } + return true; + }else{ + showResult('入库明细单不能为空'); + return false; + } +} + +function collectItemsAmount(itemsAmountArray,item){ + var expensiveGoodsId = parseInt(item.expensiveGoodsId); + var amount = item.amount; + var displayName = item.expensiveGoodsdisplayName; + for(var i = 0;i < itemsAmountArray.length; i++){ + if(expensiveGoodsId == itemsAmountArray[i].expensiveGoodsId){ + var amount = itemsAmountArray[i].amount+1; + itemsAmountArray[i].amount = amount; + return; + } + } + var object = { + expensiveGoodsId:expensiveGoodsId, + amount: 1, + displayName : displayName + } + itemsAmountArray.push(object); +} + +function collectInvoicePlanAmount(iPAmountArray,iPDetailData){ + var expensiveGoodsId = iPDetailData.expensiveGoodsId; + var amount = iPDetailData.amount; + var name = iPDetailData.name; + for(var i = 0;i < iPAmountArray.length; i++){ + if(expensiveGoodsId == iPAmountArray[i].expensiveGoodsId){ + return; + } + } + var object = { + expensiveGoodsId:expensiveGoodsId, + amount: amount, + name : name + } + iPAmountArray.push(object); +} + +function checkAmount(item,iPAmountArray){ + var expensiveGoodsId = item.expensiveGoodsId; + var amount = item.amount; + var displayName = item.displayName; + for (var i = 0; i < iPAmountArray.length; i++) { + if(expensiveGoodsId == iPAmountArray[i].expensiveGoodsId){ + if(amount >= iPAmountArray[i].amount){ + return true; + }else{ + showResult('物品'+displayName+"的入库数量:"+amount+"小于"+"绑定申请的申请单数量:"+iPAmountArray[i].amount); + return false; + } + } + } + showResult('物品'+displayName+"不存在于绑定的申请单里面!"); + return false; +} +