Index: ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/dwr/table/GodownEntryTableManager.java =================================================================== diff -u -r12331 -r12766 --- ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/dwr/table/GodownEntryTableManager.java (.../GodownEntryTableManager.java) (revision 12331) +++ ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/dwr/table/GodownEntryTableManager.java (.../GodownEntryTableManager.java) (revision 12766) @@ -100,7 +100,18 @@ GodownEntry.class.getSimpleName(), sql, new String[] { "itemsList" }); } - + /** + * 调拨单 + * @param parameterMap + * @return + */ + public String findAppropriationTableList( + Map> parameterMap){ + String sql = "where po.type='" + GodownEntry.TYPE_APPROPRIATE + "'"; + return gridManager.renderGrid(parameterMap, + GodownEntry.class.getSimpleName(), sql, + new String[] { "itemsList" }); + } // 获取批次的可以退库的价格数量 public List getDiposableGoodsPriceAmountInfoCanOutEntryByBatchID( String batchID) { Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/assestmanagement/GodownEntry.java =================================================================== diff -u -r12728 -r12766 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/assestmanagement/GodownEntry.java (.../GodownEntry.java) (revision 12728) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/assestmanagement/GodownEntry.java (.../GodownEntry.java) (revision 12766) @@ -280,4 +280,12 @@ setTotalPrice(new BigDecimal(totalPrice).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue()); } + public void addItem(GodownEntryItem item){ + if(item != null){ + if(this.itemsList == null){ + this.itemsList = new ArrayList(); + } + this.itemsList.add(item); + } + } } Index: ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/GodownEntryManager.java =================================================================== diff -u -r12687 -r12766 --- ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/GodownEntryManager.java (.../GodownEntryManager.java) (revision 12687) +++ ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/GodownEntryManager.java (.../GodownEntryManager.java) (revision 12766) @@ -42,7 +42,12 @@ // 更新退库单 public void updateGodownOutEntry_TRANS_REQUIRED(GodownEntry original,GodownEntry entry,Map result); public void updateGodownOutEntry_TRANS_MANDATORY(GodownEntry original,GodownEntry entry,Map result); - + /** + * 保存调拨单,从源仓库产生出库单,从目标仓库产生入库单 + * @param entry + * @param result + */ + public void saveAppropriateEntry_TRANS_REQUIRED(GodownEntry entry,Map result); public void loadGodownEntryPrintData(String[] invoiceIds,JSONObject jsonObject); /** * 向入库单\出库单\调拨单添加物品,添加的物品的信息以json对象表示 Index: ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/GodownEntryManagerImpl.java =================================================================== diff -u -r12764 -r12766 --- ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/GodownEntryManagerImpl.java (.../GodownEntryManagerImpl.java) (revision 12764) +++ ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/GodownEntryManagerImpl.java (.../GodownEntryManagerImpl.java) (revision 12766) @@ -407,20 +407,8 @@ Map idToDisposableGoodsMap,Map disposableGoodsIDToDisposableGoodsStockMap,Map idToDisposableGoodsStockMap, Map idToDisposableGoodsBatchMap ,Map idToBatchStockMap, Map idToIdentificationMap) { - // 计算总价 - entry.calculateTotalPrice(); - // 先保存入库单对象,后面需要入库单ID - if(StringUtils.isBlank(entry.getSerialNumber())){// 有可能在其他地方设置了,比如同步入库单/导入入库单 - entry.setSerialNumber(serialNumManager - .getSerialNumberStr(SerialNum.TYPE_INSERT_GODOWN)); - } - + save(entry); List itemList = entry.getItemsList(); - if(itemList.size() > 0){ - entry.setSupplierName(itemList.get(0).getSupplierName()); - } - syncGodownEntryWareHouse(entry); - objectDao.save(entry); for (int i = 0; i < itemList.size(); ++i) { boolean newBatch = false; GodownEntryItem godownEntryItem = itemList.get(i); @@ -516,6 +504,28 @@ objectDao.update(disposableGoodsBatchStock); } } + + /** + * 保存对象到数据库 + * @param entry + * @return + */ + private void save(GodownEntry entry) { + // 计算总价 + entry.calculateTotalPrice(); + // 先保存入库单对象,后面需要入库单ID + if(StringUtils.isBlank(entry.getSerialNumber())){// 有可能在其他地方设置了,比如同步入库单/导入入库单 + entry.setSerialNumber(serialNumManager + .getSerialNumberStr(SerialNum.TYPE_INSERT_GODOWN)); + } + + List itemList = entry.getItemsList(); + if(itemList.size() > 0){ + entry.setSupplierName(itemList.get(0).getSupplierName()); + } + syncGodownEntryWareHouse(entry); + objectDao.save(entry); + } public void updateGodownEntry_TRANS_REQUIRED(GodownEntry original, GodownEntry entry, Map result) { @@ -1232,6 +1242,77 @@ Map result) { saveGodownOutEntry_internal(entry, result); } + /** + * + */ + public void saveAppropriateEntry_TRANS_REQUIRED(GodownEntry entry,Map result){ + if(entry != null){ + entry.setId(null); + entry.setType(GodownEntry.TYPE_APPROPRIATE); + GodownEntry inEntry = clone(entry); + inEntry.setId(null); + inEntry.setType(GodownEntry.TYPE_IN); + inEntry.setSubType(GodownEntry.SUBTYPE_MOVE_IN); + inEntry.setTargetWareHouseId(null); + inEntry.setTargetWareHouseName(null); + inEntry.setWarehouseID(entry.getTargetWareHouseId()); + inEntry.setWarehouseName(entry.getTargetWareHouseName()); + + GodownEntry outEntry = clone(entry); + outEntry.setId(null); + outEntry.setType(GodownEntry.TYPE_OUT); + outEntry.setSubType(GodownEntry.SUBTYPE_MOVE_OUT); + outEntry.setTargetWareHouseId(null); + outEntry.setTargetWareHouseName(null); + outEntry.setWarehouseID(entry.getWarehouseID()); + outEntry.setWarehouseName(entry.getWarehouseName()); + + saveGodownOutEntry_internal(outEntry, null); + saveGodownEntry_internal(inEntry, result); + save(entry); + + //设置单的关系 + inEntry.setSourceId(entry.getId()); + outEntry.setSourceId(entry.getId()); + } + } + /** + * 从源对象中复制一个信息一样的副本,但是修改了引用关系,同时里面的item也是副本 + * @param source + * @return + */ + private GodownEntry clone(GodownEntry source){ + if(source == null){ + return null; + } + GodownEntry newEntry = new GodownEntry(); + newEntry.setInventoryWriteBackEntryId(source.getInventoryWriteBackEntryId()); + newEntry.setOperator(source.getOperator()); + newEntry.setRemark(source.getRemark()); + newEntry.setSerialNumber(serialNumManager.getSerialNumberStr(SerialNum.TYPE_INSERT_GODOWN)); + newEntry.setSourceId(source.getSourceId()); + newEntry.setSupplierName(source.getSupplierName()); + newEntry.setTime(source.getTime()); + newEntry.setTotalPrice(source.getTotalPrice()); + newEntry.setId(null); + newEntry.setSubType(source.getSubType()); + newEntry.setTargetWareHouseId(source.getTargetWareHouseId()); + newEntry.setTargetWareHouseName(source.getTargetWareHouseName()); + newEntry.setType(source.getType()); + newEntry.setWarehouseID(source.getWarehouseID()); + newEntry.setWarehouseName(source.getWarehouseName()); + + //设置item项 + for(GodownEntryItem item : source.getItemsList()){ + GodownEntryItem newItem = godownEntryItemManager.clone(item); + newItem.setGodownEntry(newEntry); + newItem.setId(null); + newItem.setNewBatch(false); + newEntry.addItem(newItem); + } + this.syncGodownEntryWareHouse(newEntry); + return newEntry; + } public void saveGodownOutEntry_TRANS_NEW(GodownEntry entry,Map result){ saveGodownOutEntry_internal(entry, result); } @@ -1805,10 +1886,16 @@ String timeStr = godownEntryInfo.optString("time"); Long wareHouseId = JSONUtil.optLong(godownEntryInfo, "warehouseID", null); String wareHouseName = JSONUtil.optString(godownEntryInfo, "warehouseName", ""); + + Long targetWareHouseId = JSONUtil.optLong(godownEntryInfo, "targetWareHouseId", null); + String targetWareHouseName = JSONUtil.optString(godownEntryInfo, "targetWareHouseName", ""); + entry.setId(id); entry.setRemark(remark); entry.setWarehouseID(wareHouseId); entry.setWarehouseName(wareHouseName); + entry.setTargetWareHouseId(targetWareHouseId); + entry.setTargetWareHouseName(targetWareHouseName); Date time; try { time = GodownEntryItem.DATE_FORMAT.parse(timeStr); Index: ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/GodownEntryItemManagerImpl.java =================================================================== diff -u -r12755 -r12766 --- ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/GodownEntryItemManagerImpl.java (.../GodownEntryItemManagerImpl.java) (revision 12755) +++ ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/GodownEntryItemManagerImpl.java (.../GodownEntryItemManagerImpl.java) (revision 12766) @@ -138,4 +138,37 @@ godownEntryItem.setProducingArea(producingArea); return godownEntryItem; } + + @Override + public GodownEntryItem clone(GodownEntryItem source) { + if(source == null){ + return null; + } + + GodownEntryItem newItem = new GodownEntryItem(); + + newItem.setAmount(source.getAmount()); + newItem.setBatchNumber(source.getBatchNumber()); + newItem.setCertification(source.getCertification()); + newItem.setConclusion(source.getConclusion()); + newItem.setCost(source.getCost()); + newItem.setDiposableGoods(source.getDiposableGoods()); + newItem.setDisposableGoodsBatchID(source.getDisposableGoodsBatchID()); + newItem.setDisposableGoodsBatchStockID(source.getDisposableGoodsBatchStockID()); + newItem.setDisposableGoodsID(source.getDisposableGoodsID()); + newItem.setDisposableGoodsStockID(source.getDisposableGoodsStockID()); + newItem.setExpDate(source.getExpDate()); + newItem.setGodownEntry(source.getGodownEntry()); + newItem.setId(source.getId()); + newItem.setIdentification(source.getIdentification()); + newItem.setIdentificationID(source.getIdentificationID()); + newItem.setManufacturer(source.getManufacturer()); + newItem.setNewBatch(source.getNewBatch()); + newItem.setProducingArea(source.getProducingArea()); + newItem.setSterileBatchNumber(source.getSterileBatchNumber()); + newItem.setSupplierName(source.getSupplierName()); + newItem.setWarehouseID(source.getWarehouseID()); + newItem.setWarehouseName(source.getWarehouseName()); + return newItem; + } } Index: ssts-web/src/main/webapp/disinfectsystem/assestManagement/godownEntry/appropriationView.jsp =================================================================== diff -u --- ssts-web/src/main/webapp/disinfectsystem/assestManagement/godownEntry/appropriationView.jsp (revision 0) +++ ssts-web/src/main/webapp/disinfectsystem/assestManagement/godownEntry/appropriationView.jsp (revision 12766) @@ -0,0 +1,66 @@ +<%@page import="com.forgon.disinfectsystem.entity.assestmanagement.GodownEntry"%> +<%@ page contentType="text/html; charset=UTF-8"%> +<%@ include file="/common/taglibs.jsp"%> +<%@ include file="/common/includeExtJsAndCss.jsp"%> +<%@ page import="com.forgon.tools.SpringBeanManger" %> +<% + String userName = AcegiHelper.getLoginUser().getUserFullName(); + request.setAttribute("userName",userName); +%> + + + +调拨单信息 + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + \ No newline at end of file Index: ssts-web/src/main/webapp/homepage/menuconfigure.js =================================================================== diff -u -r12677 -r12766 --- ssts-web/src/main/webapp/homepage/menuconfigure.js (.../menuconfigure.js) (revision 12677) +++ ssts-web/src/main/webapp/homepage/menuconfigure.js (.../menuconfigure.js) (revision 12766) @@ -254,6 +254,7 @@ {hidden :SSTS_DiposableGoodsNode_Menu,text:"一次性物品管理",href:WWWROOT+'/disinfectsystem/assestManagement/diposableGoods/diposableGoodsView.jsp',hrefTarget:linkTarget,leaf:true}, {hidden :SSTS_godownEntryNode_Menu,text:"入库单管理",href:WWWROOT+'/disinfectsystem/assestManagement/godownEntry/godownEntryView.jsp',hrefTarget:linkTarget,leaf:true}, {hidden :SSTS_WarehouseEntryOut_Menu,text:"退库单管理",href:WWWROOT+'/disinfectsystem/assestManagement/godownEntry/godownOutView.jsp',hrefTarget:linkTarget,leaf:true}, + {hidden :SSTS_WarehouseEntryOut_Menu,text:"调拨单管理",href:WWWROOT+'/disinfectsystem/assestManagement/godownEntry/appropriationView.jsp',hrefTarget:linkTarget,leaf:true}, {hidden :SSTS_stockTakeInfoNode_Menu,text:"一次性物品盘点管理",href:WWWROOT+'/disinfectsystem/stocktakeinfomanager/stockTakeInfoView.jsp?type='+encodeURIComponent('一次性物品'),hrefTarget:linkTarget,leaf:true}, {hidden :SSTS_JJJL_Menu,text:"一次性物品月盘点记录",href:WWWROOT+'/disinfectsystem/stocktakerecordmanager/stocktakerecordView.jsp',hrefTarget:linkTarget,leaf:true}, {hidden :SSTS_godownEntryNode_Menu,text:"一次性物品采购计划",href:WWWROOT+'/disinfectsystem/assestManagement/godownEntry/goodPurchasePlanView.jsp',hrefTarget:linkTarget,leaf:true} Index: ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/action/GodownEntryAction.java =================================================================== diff -u -r12738 -r12766 --- ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/action/GodownEntryAction.java (.../GodownEntryAction.java) (revision 12738) +++ ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/action/GodownEntryAction.java (.../GodownEntryAction.java) (revision 12766) @@ -157,7 +157,50 @@ printMsgToClient(saveResult, out, result.toString(), null); } - + /** + * 保存调拨单 + */ + public void saveAppropriateEntry(){ + HttpServletResponse response = StrutsParamUtils.getResponse(); + PrintWriter out = null; + String result = "保存成功"; + response.setCharacterEncoding("UTF-8"); + Map returnMsg = new HashMap(); + returnMsg.put("success", false); + returnMsg.put("errMsg", "保存失败"); + try { + out = response.getWriter(); + } catch (IOException e) { + e.printStackTrace(); + } + boolean saveResult = false; + try { + String id = StrutsParamUtils.getPraramValue("id", ""); + + //GodownEntry original = new GodownEntry(); + GodownEntry entry = godownEntry; + + if (StringUtils.isNotBlank(id)) { + // 调拨单没有更新操作 + // 更新入库单,里面的item有可能会更新,新建,删除标识号。 + //buildGodownEntryParamsForUpdate(original, entry); + + //godownEntryManager.updateGodownOutEntry_TRANS_REQUIRED(original, entry, returnMsg); + } else { + // 保存入库单,里面的item一定都是新建标识号对象,并且需要更新批次属性。 + entry = godownEntry; + buildGodownEntryParamsForSave(entry); + entry.setTime(new Date()); + godownEntryManager.saveAppropriateEntry_TRANS_REQUIRED(entry, returnMsg); + } + saveResult = true; + } catch (Exception e) { + e.printStackTrace(); + saveResult = false; + result = e.getMessage(); + } + printMsgToClient(saveResult, out, result.toString(), null); + } /** * @param out Index: ssts-web/src/main/webapp/disinfectsystem/assestManagement/godownEntry/appropriationView.js =================================================================== diff -u --- ssts-web/src/main/webapp/disinfectsystem/assestManagement/godownEntry/appropriationView.js (revision 0) +++ ssts-web/src/main/webapp/disinfectsystem/assestManagement/godownEntry/appropriationView.js (revision 12766) @@ -0,0 +1,943 @@ +var entityName = '调拨'; +var grid; +var g_localID = 1;// 为了区分每一个item,增加的ID。 +var entryid = ''; +//单价数据源 +var priceStore = null; +var PriceRecord = null; +// 清除表单数据 +function clearFormData(){ + diposableGoodsBatchNumStore.removeAll(); + priceStore.removeAll(); +} +// 清空批次和价格 +function clearBatchNumberAndPrice() { + clearBatchNumber(); + clearPrice(); +} +function clearBatchNumber() { + clearCombo(diposableGoodsBatchNumStore,'batchNumber1'); +} +// 清空价格 +function clearPrice() { + clearCombo(priceStore,'combo_price'); +} +// 设置批次 +function setBatchNumbers(batches,selectFirst) { + clearBatchNumber(); + if(typeof(batches) == 'undefined' || batches == null){ + return; + } + for(var i = 0;i 0){ + setCmpValue('batchNumber1',batches[0].batchNumber); + + var combo = top.Ext.getCmp("batchNumber1"); + // 触发选中事件 + combo.fireEvent('select', combo,diposableGoodsBatchNumStore.getAt(0),0); + } + } +} +//设置价格 +function setPrices(prices,selectFirst) { + clearPrice() + if(typeof(prices) == 'undefined' || prices == null){ + return; + } + for(var i = 0;i 0){ + setCmpValue('combo_price',prices[0].price); + } + } +} + +var wareHouseStore = new Ext.data.Store({ + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectSystem/baseData/wareHouseAction!getWareHouseData.do', + method : 'POST' + }), + reader : new Ext.data.JsonReader({ + totalProperty : 'totalCount', + root : 'data' + }, [ + {name : 'id',mapping : 'id'}, + {name : 'name',mapping : 'name'}, + {name : 'orgUnitCode',mapping : 'orgUnitCode'}, + ]), + listeners : { + load : function(store,records) { + if(records.length > 0 && (entryid == null || entryid == '')){ + var combo = top.Ext.getCmp("wareHouse"); + // 触发选中事件 + combo.fireEvent('select', combo,records[0],0); + + var combo = top.Ext.getCmp("targetWareHouse"); + var outIndex = (1 % records.length); + // 触发目标仓库选中事件 + combo.fireEvent('select', combo,records[outIndex],outIndex); + } + top.Ext.getCmp("name1").enable(); + } + } +}); + +var diposableGoodsStore = new Ext.data.Store({ + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectSystem/diposableGoodsAction!getDiposableGoodsData.do', + method : 'POST' + }), + reader : new Ext.data.JsonReader({ + totalProperty : 'totalCount', + root : 'data' + }, [ + {name : 'id',mapping : 'id'}, + {name : 'spelling',mapping : 'spelling'}, + {name : 'name',mapping : 'name'}, + {name : 'referencePrice',mapping : 'referencePrice'}, + {name : 'supplierName',mapping : 'supplierName'}, + ]) +}); + +var diposableGoodsBatchNumStore = new Ext.data.Store({ + reader : new Ext.data.JsonReader({ + fields : [ + {name : 'id'}, + {name : 'disposableGoodsID'}, + {name : 'disposableGoodsBatchID'}, + {name : 'batchNumber'}, + {name : 'cost'}, + {name : 'supplierName'}, + {name : 'expDate'} + ] + }) +}); + +var BatchRecord = Ext.data.Record.create([ { + name: 'id', + name: 'disposableGoodsID', + name: 'disposableGoodsBatchID', + name : 'batchNumber', + name : 'cost', + name : 'supplierName', + name : 'expDate' +} ]); + +var GodownEntryItemRecord = Ext.data.Record.create([ + {name : 'disposableGoodsID'}, + {name : 'disposableGoodsStockID'}, + {name : 'disposableGoodsBatchID'}, + {name : 'disposableGoodsBatchStockID'}, + {name : 'localID'}, + {name : 'id'}, + {name : 'name'}, + {name : 'amount'}, + {name : 'canOutAmount'}, + {name : 'cost'}, + {name : 'batchNumber'}, + {name : 'identification'}, + {name : 'identificationID'}, + {name : 'batchID'}, + {name : 'disposableGoodsStockID'}, + {name : 'expDate' ,type : 'date'}, + {name : 'supplierName'} +]); + +/** + * 设置仓库的id和name的隐藏域的内容 + * @param id + * @param name + */ +function setWareHouseInfo(id,name){ + top.Ext.getCmp('warehouseID').setValue(id); + top.Ext.getCmp('warehouseName').setValue(name); +} + +/** + * 设置目标仓库的id和name的隐藏域的内容 + * @param id + * @param name + */ +function setTargetWareHouseInfo(id,name){ + top.Ext.getCmp('targetWareHouseId').setValue(id); + top.Ext.getCmp('targetWareHouseName').setValue(name); +} + +// 获取当前选中的批次 +function getSelectedBatch(){ + var batchNumber = top.Ext.getCmp('batchNumber1').getValue(); + var batch = findRecordDataByNameAndValue(diposableGoodsBatchNumStore,'batchNumber',batchNumber); + return batch; +} +// 获取当前选中的价格 +function getSelectedPriceAmount(){ + return getSelectedDataFromCombo(priceStore,'combo_price','price'); +} +function addItems(disposableGoodsStockID,name,amount,batch,priceAmount){ + if(isUndefinedOrNull(batch)){ + showResult("请填写批次!"); + return false; + } + var batchNumber = batch.batchNumber; + if(top.Ext.getCmp('name1').getValue() == null || top.Ext.getCmp('name1').getValue() == ''){ + showResult("请填写物品名称!"); + return false; + } + + if(top.Ext.getCmp('amount1').getValue() == null || top.Ext.getCmp('amount1').getValue() == ''){ + showResult("请填写数量!"); + return false; + } + + if(!top.Ext.getCmp('amount1').isValid()){ + showResult("请正确填写数量!"); + return false; + } + if(top.Ext.getCmp('batchNumber1').getValue() == null || top.Ext.getCmp('batchNumber1').getValue() == ''){ + showResult("请填写批次!"); + return false; + } + if(isUndefinedOrNull(priceAmount)){ + showResult("请选择价格!"); + return false; + } + // 物品是否重复 + var godownEntryItemGridStore = top.Ext.getCmp('appropriateItemGrid').getStore(); + for(var i = 0;i < godownEntryItemGridStore.getCount();i++){ + var godownEntryItem = godownEntryItemGridStore.getAt(i).data; + if(godownEntryItem.disposableGoodsStockID == disposableGoodsStockID && godownEntryItem.batchNumber == batchNumber && godownEntryItem.cost == priceAmount.price){ + showResult("该物品已经存在,不能重复添加!"); + return false; + } + } +// var cost = top.Ext.getCmp('cost').getValue(); + var expDate = top.Ext.getCmp('expDate').getValue(); + var supplierName = top.Ext.getCmp('supplierName').getValue(); + //添加操作 + var godownEntryItem = new GodownEntryItemRecord({ + disposableGoodsID: batch.disposableGoodsID, + disposableGoodsStockID: batch.disposableGoodsStockID, + disposableGoodsBatchID: batch.disposableGoodsBatchID, + disposableGoodsBatchStockID: batch.id, + localID:g_localID++, + id : "", + disposableGoodsStockID : disposableGoodsStockID, + identificationID : '', + batchID : batch.id, + name : name, + amount : amount, + canOutAmount : priceAmount.amount, +// cost : cost, + cost : priceAmount.price, + batchNumber : batch.batchNumber, + expDate : expDate, + supplierName : supplierName + }); + top.Ext.getCmp('appropriateItemGrid').getStore().add(godownEntryItem); + +// top.Ext.getCmp('name1').setValue(''); +// top.Ext.getCmp('amount1').setValue(''); +// top.Ext.getCmp('batchNumber1').setValue(''); +// top.Ext.getCmp('cost').setValue(''); +// top.Ext.getCmp('disposableGoodsStockID').setValue(''); +// diposableGoodsBatchNumStore.removeAll(); +// top.Ext.getCmp('expDate').setValue(''); +// top.Ext.getCmp('supplierName').setValue(''); +// top.Ext.getCmp('name1').focus(); +} + +function renderDeleteButton(v,p,record){ + return ""; +} + +function deleteItem(localID){ + var godownEntryItemGridStore = top.Ext.getCmp('appropriateItemGrid').getStore(); + for(var i = 0;i 0){ + var godownEntryItem = barcodeStr.split(";"); + for ( var i = 0; i < godownEntryItem.length; i++) { + var resultItem = godownEntryItem[i].split("#&"); + var name =resultItem[0]; + var barcode = resultItem[1]; + var expDate = resultItem[2]; + var supplierName = resultItem[3]; + var batchNumber = resultItem[4]; + printDiposableGoodsInfo(barcode,name,expDate,supplierName,batchNumber,0); + } + } +} + +// 删除 +function deleteGodownEntry(grid) { + var records = grid.getSelectionModel().getSelections(); + + if (records.length == 0) { + showResult("请选择要删除的" + entityName + "单"); + return false; + } + var ids = null; + for ( var i = 0, len = records.length; i < len; i++) { + if (ids == null) { + ids = records[i].data['id']; + } else { + ids = ids + ';' + records[i].data['id']; + } + } + top.Ext.MessageBox.confirm("请确认","是否确定要删除选中的"+entityName+"单信息?", + function(button, text) { + if ("yes" == button){ + Ext.Ajax.request({ + url : WWWROOT + '/disinfectSystem/godownEntryAction!deleteGodownEntryOut.do', + params : {ids : ids}, + success : function(response, options) { + var result = Ext.decode(response.responseText); + if (result.success) { + showResult(result.message); + grid.dwrReload(); + } + }, + failure : function(response, options) { + showResult(response.responseText); + } + }); + } + } + ); +} + +var loadFormData = function(grid) { + var records = grid.getSelectionModel().getSelections(); + if (records.length == 0) { + showResult("请选择要修改的"+entityName+"单!"); + return false; + } + if (records.length > 1) { + showResult("一次只能修改一个"+entityName+"单!"); + return false; + } + id = records[0].data['id']; + editRecord(id); +}; + +function editRecord(id){ + addGodownEntry(); + top.Ext.getCmp("serialNum").show(); + top.Ext.getCmp('appropriationForm').form.load({ + url : WWWROOT + '/disinfectSystem/godownEntryAction!loadGodownEntry.do', + method : 'GET', + waitMsg : '正在加载数据,请稍候', + params : {id : id}, + success : function(form, action) { + var time = action.result.data.time.time; + top.Ext.getCmp("time").setValue(Ext.util.Format.date(new Date(time), 'Y-m-d')); + setWareHouseInfo(action.result.data.warehouseID,action.result.data.warehouseName); + top.Ext.getCmp("wareHouse").setValue(action.result.data.warehouseID); + for(var i = 0 ;i < action.result.data.itemsList.length ;i++){ + var specification = action.result.data.itemsList[i].diposableGoods.specification; + var b = true; + if(specification == null || specification.length <= 0){ + b = false; + } + var expDateStr = ''; + if(!isUndefinedOrNull(action.result.data.itemsList[i].expDate)){ + expDateStr = Ext.util.Format.date(new Date(action.result.data.itemsList[i].expDate.time), 'Y-m-d') + } + var godownEntryItem = new GodownEntryItemRecord({ + localID:g_localID++, + id : action.result.data.itemsList[i].id, + disposableGoodsID : action.result.data.itemsList[i].diposableGoods.id, + identificationID : action.result.data.itemsList[i].identificationID, + batchID : action.result.data.itemsList[i].batchID, + name : action.result.data.itemsList[i].diposableGoods.name + (b == false?"":" ["+specification+"]"), + amount : action.result.data.itemsList[i].amount, + identification : action.result.data.itemsList[i].identification, + cost : action.result.data.itemsList[i].cost, + batchNumber : action.result.data.itemsList[i].batchNumber, + expDate : expDateStr, + supplierName : action.result.data.itemsList[i].supplierName, + identification : action.result.data.itemsList[i].identification + }); + top.Ext.getCmp('appropriateItemGrid').getStore().add(godownEntryItem); + } + // 保存原始数据,只需要保存需要修改的属性 + setOriginalFormParams(form,['id','remark','time','warehouseName','warehouseID','targetWareHouseId','targetWareHouseName']); + var originalItems = buildJSONStringFromStore(top.Ext.getCmp('appropriateItemGrid').getStore()); + //alert(originalItems); + top.Ext.getCmp("originalItems").setValue(originalItems); + }, + failure : function(form, action) { + } + }); +} + +/** + * 修改记录 + * modifyRecord函数 触发modify函数调用,并传入当前列的值以及record.data对象 + * 页面中需要定义 modify(v,data) 函数 + */ +function modify(v,data){ + editRecord(data['id']); +} + +Ext.onReady(function() { + Ext.QuickTips.init(); + //单价数据源 + 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'} + ]); + } + + var sm = new Ext.grid.CheckboxSelectionModel(); + var columns = [sm, + {header : "单号",width : 200,dataIndex : 'serialNumber' , renderer : modifyRecord}, + {header : "操作员",width : 200,dataIndex : 'operator'}, + {header : "操作时间",width : 200,dataIndex : 'time' , renderer : myDateFormat}, + {id : 'operationRemark',header : "备注",width : 120,dataIndex : 'remark'} + ]; + + var readerDetail = [ + {name : 'id'}, + {name : 'serialNumber'}, + {name : 'operator'}, + {name : 'time'}, + {name : 'remark'} + ]; + + var filters = new Ext.grid.GridFilters({ + filters:[ + {type: 'string', dataIndex: 'serialNumber'}, + {type: 'string', dataIndex: 'operator'}, + {type: 'date', dataIndex: 'time'}, + {type: 'string', dataIndex: 'remark'} + ]} + ); + + var tbar = [{ + text : '添加', + hidden : SSTS_WarehouseEntry_Create, + iconCls : 'btn_ext_add', + handler : function() { + addGodownEntry('insert'); + } + },'-',{ + text : '删除', + hidden : SSTS_WarehouseEntry_Delete, + iconCls : 'btn_ext_application_del', + handler : function() { + deleteGodownEntry(grid); + } + },'-',{ + text : '修改', + hidden : SSTS_WarehouseEntry_Update, + iconCls : 'btn_ext_refresh', + id : 'editTbar', + handler : function() { + loadFormData(grid); + } + }]; + + grid = new Ext.ux.ForgonPageGrid( { + tbar : tbar, + pageSize : 20, + defaultSortField : 'id', + title : entityName+'单列表', + defaultSortDirection : 'ASC', + isCheckboxSelectionModel : false, + rememberSelected : false, + isShowSearchField : true, + columns : columns, + plugins: filters, + sm:sm, + autoExpandColumn : 'operationRemark', + renderTo : 'gridDiv', + frame : false + }, readerDetail, + GodownEntryTableManager.findAppropriationTableList, + null + ); + + var viewport = new Ext.Viewport( { + layout : 'border', + items : [{ + region : 'center', + margins : '0 0 0 0', + layout : 'fit', + items : grid + }] + }); +}); \ No newline at end of file Index: ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/GodownEntryItemManager.java =================================================================== diff -u -r12655 -r12766 --- ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/GodownEntryItemManager.java (.../GodownEntryItemManager.java) (revision 12655) +++ ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/GodownEntryItemManager.java (.../GodownEntryItemManager.java) (revision 12766) @@ -36,4 +36,10 @@ * @return 以json对象的信息创建的GodownEntryItem */ public GodownEntryItem parseGodownEntryItem(JSONObject itemObject); + /** + * 从源对象中复制一个信息完全一样的副本 + * @param other + * @return + */ + public GodownEntryItem clone(GodownEntryItem other); }