Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/action/CustomRecyclingApplicationAction.java =================================================================== diff -u -r25408 -r25800 --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/action/CustomRecyclingApplicationAction.java (.../CustomRecyclingApplicationAction.java) (revision 25408) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/action/CustomRecyclingApplicationAction.java (.../CustomRecyclingApplicationAction.java) (revision 25800) @@ -2,13 +2,15 @@ import java.io.IOException; import java.io.PrintWriter; +import java.sql.ResultSet; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; +import net.sf.json.JSONArray; import net.sf.json.JSONObject; import net.sf.json.JsonConfig; import net.sf.json.util.CycleDetectionStrategy; @@ -35,6 +37,8 @@ import com.forgon.tools.GB2Alpha; import com.forgon.tools.GB2WB; import com.forgon.tools.StrutsParamUtils; +import com.forgon.tools.db.DatabaseUtil; +import com.forgon.tools.hibernate.ObjectDao; import com.forgon.tools.json.JsonPropertyFilter; import com.opensymphony.xwork2.ModelDriven; import com.opensymphony.xwork2.Preparable; @@ -63,6 +67,8 @@ //用于临时缓存applicationTime,因为struts2设置date参数只会截取到年月日 private Date tempApplicationTime; + private ObjectDao objectDao; + public void setSupplyRoomConfigManager( SupplyRoomConfigManager supplyRoomConfigManager) { this.supplyRoomConfigManager = supplyRoomConfigManager; @@ -89,7 +95,9 @@ public void setTaskGroupManager(TaskGroupManager taskGroupManager) { this.taskGroupManager = taskGroupManager; } - + public void setObjectDao(ObjectDao objectDao) { + this.objectDao = objectDao; + } private RecyclingApplicationManager recyclingApplicationManager; public void setRecyclingApplicationManager( @@ -103,15 +111,14 @@ * @return */ public String saveCustomRecyclingApplication() { - String customTousseInstanceIds = StrutsParamUtils.getPraramValue( - "customTousseInstanceIds", ""); - String name = StrutsParamUtils.getPraramValue("name", ""); + String customTousseInfo = StrutsParamUtils.getPraramValue("customTousseInfo", ""); + JSONArray jsonArray = JSONArray.fromObject(customTousseInfo); SupplyRoomConfig config = supplyRoomConfigManager.getSystemParamsObj(); Double price = config.getCustomToussePrice(); TaskGroup taskGroup = taskGroupManager.getTaskGroup(config.getCustomTousseDefaultTaskGroup()); - + PrintWriter printWriter = null; try { StrutsParamUtils.getResponse().setCharacterEncoding("UTF-8"); @@ -132,129 +139,144 @@ recyclingApplication.setSequence(supplyRoomConfigManager.getOrgUnitSequence(recyclingApplication.getDepartCoding())); recyclingApplicationManager.saveOrUpdate(recyclingApplication); } - if(StringUtils.isBlank(name)){ - throw new RuntimeException("器械包名字不能为空!"); - } - - Long appid = recyclingApplication.getId(); - String tousseName = name; -// TousseDefinition tousseDefinition = tousseDefinitionManager -// .getTousseDefinitionByName(tousseName); - - TousseDefinition tousseDefinition = tousseDefinitionManager.getTousseDefinitionByNameTypeAndAPPID(tousseName, TousseDefinition.PACKAGE_TYPE_CUSTOM, appid.toString()); - if (tousseDefinition == null) { - tousseDefinition = new TousseDefinition(); - tousseDefinition.setForDisplay(true); - } - - tousseDefinition.setName(tousseName); - tousseDefinition.setInvoicePlanID(appid); - tousseDefinition.setSpelling(GB2Alpha.string2Alpha(name)); - tousseDefinition.setWbCode(GB2WB.getWBCode(name)); - tousseDefinition.setTousseType(TousseDefinition.PACKAGE_TYPE_CUSTOM); - tousseDefinition.setIsTraceable(TousseDefinition.STR_YES); - String isCustomTousseCleanEntirely = config.getIsCustomTousseCleanEntirely(); - if(TousseDefinition.STR_NO.equals(isCustomTousseCleanEntirely)){ - tousseDefinition.setIsCleanedEntirely("否"); - }else{ - tousseDefinition.setIsCleanedEntirely("是"); - } - tousseDefinition.setWorkLoadStatisticalMethod(TousseDefinition.WORKLOAD_STATISTICAL_METHOD_MATERIAL_AND_DIPOSABLES); - tousseDefinition.setTaskGroup(supplyRoomConfigManager.getCustomTousseDefaultTaskGroup()); - if(taskGroup != null){ - tousseDefinition.setHandlerDepartCode(taskGroup.getDepartCode()); - tousseDefinition.setHandlerDepartName(taskGroup.getDepartName()); - } - if (price != null) { - tousseDefinition.setPrice(price); - tousseDefinition.setDiscountPrice(price); - } - try{ - String materialDefinitionConfigResult = StrutsParamUtils.getPraramValue( - "materialDefinitionConfigResult", ""); - tousseDefinitionManager - .saveTousseDefinition(tousseDefinition,materialDefinitionConfigResult,null); - } - catch(Exception e){ - e.printStackTrace(); - } - - // 设置申请时间 - if (recyclingApplication.getSubmitTime() == null) { - // if (recyclingApplication.getId() == null) { - recyclingApplication.setApplicationTime(Calendar.getInstance().getTime()); - } - else { - recyclingApplication.setApplicationTime(tempApplicationTime); - } - List items = new ArrayList(); - if (StringUtils.isNotBlank(customTousseInstanceIds)) { - String[] tousseInstance = customTousseInstanceIds.split(";"); - int len = tousseInstance.length; - SupplyRoomConfig cfg = supplyRoomConfigManager.getSystemParamsObj(); - Double costomToussePrice = 0.0; - if(cfg != null){ - costomToussePrice = cfg.getCustomToussePrice(); - } - for (int i = 0; i < len; i++) { - String[] value = tousseInstance[i].split(","); + if (jsonArray != null) { + Long appid = recyclingApplication.getId(); + List items = new ArrayList(); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject json = jsonArray.getJSONObject(i); + String tousseId = json.getString("id"); + String tousseName = json.getString("tousseName"); + if(StringUtils.isBlank(tousseName)){ + throw new RuntimeException("器械包名字不能为空!"); + } + String isImplant = json.getString("isImplant"); + Integer amount = json.getInt("amount"); + String materialsStr = json.getString("materials"); + TousseDefinition tousseDefinition = tousseDefinitionManager.getTousseDefinitionByNameTypeAndAPPID(tousseName, TousseDefinition.PACKAGE_TYPE_CUSTOM, appid.toString()); + if (tousseDefinition == null) { + tousseDefinition = new TousseDefinition(); + tousseDefinition.setForDisplay(true); + } + if(appid == 0 || appid == null){ + throw new RuntimeException("申请单id不能为空!"); + } + if("是".equals(isImplant)){ + tousseDefinition.setIncludeImplant(TousseDefinition.INCLUDE_IMPLANT); + }else{ + tousseDefinition.setIncludeImplant(TousseDefinition.UNINCLUDE_IMPLANT); + } + tousseDefinition.setName(tousseName); + tousseDefinition.setInvoicePlanID(appid); + tousseDefinition.setSpelling(GB2Alpha.string2Alpha(tousseName)); + tousseDefinition.setWbCode(GB2WB.getWBCode(tousseName)); + tousseDefinition.setTousseType(TousseDefinition.PACKAGE_TYPE_CUSTOM); + tousseDefinition.setIsTraceable(TousseDefinition.STR_YES); + + tousseDefinition.setPackageType(config.getCtDefaultPackageType()); + tousseDefinition.setSterilingMethod(config.getCtDefaultSterilingMethod()); + String isReview = config.getCustomTousseNeedReview(); + if(StringUtils.isNotBlank(isReview)){ + tousseDefinition.setIsReview(isReview); + } + String barcodePaperType = config.getCtBarcodePaperType(); + if(StringUtils.isNotBlank(barcodePaperType)){ + tousseDefinition.setBarcodePaperType(barcodePaperType);; + } + String isRecycling = config.getCustomTousseNeedRecycle(); + if(StringUtils.isNotBlank(isRecycling)){ + tousseDefinition.setIsRecycling(isRecycling); + } + tousseDefinition.setPrintOrgSource(config.getCtPrintOrgSource()); + String isCustomTousseCleanEntirely = config.getIsCustomTousseCleanEntirely(); + if(TousseDefinition.STR_NO.equals(isCustomTousseCleanEntirely)){ + tousseDefinition.setIsCleanedEntirely("否"); + }else{ + tousseDefinition.setIsCleanedEntirely("是"); + } + tousseDefinition.setWorkLoadStatisticalMethod(TousseDefinition.WORKLOAD_STATISTICAL_METHOD_MATERIAL_AND_DIPOSABLES); + tousseDefinition.setTaskGroup(supplyRoomConfigManager.getCustomTousseDefaultTaskGroup()); + if(taskGroup != null){ + tousseDefinition.setHandlerDepartCode(taskGroup.getDepartCode()); + tousseDefinition.setHandlerDepartName(taskGroup.getDepartName()); + }else{ + tousseDefinition.setHandlerDepartCode(recyclingApplication.getDepartCoding()); + tousseDefinition.setHandlerDepartName(recyclingApplication.getDepart()); + } + if (price != null) { + tousseDefinition.setPrice(price); + tousseDefinition.setDiscountPrice(price); + } + try{ + tousseDefinitionManager.saveTousseDefinition(tousseDefinition,materialsStr,null); + } + catch(Exception e){ + e.printStackTrace(); + } TousseItem tousseItem; // 新添加的 - if ("0".equals(value[0])) { + if ("0".equals(tousseId)) { tousseItem = new TousseItem(); } else { - tousseItem = tousseItemManager.get(value[0]); + tousseItem = tousseItemManager.get(tousseId); } Integer alreadyAppliedAmount = tousseItem.getAmount(); if (alreadyAppliedAmount == null) { alreadyAppliedAmount = 0; } - - tousseItem.setTousseName(value[1]); + tousseItem.setTousseName(tousseName); tousseItem.setInvoicePlanID(appid); tousseItem.setIsInvoice(tousseDefinition.getIsInvoice()); - tousseItem.setEditAmount(Integer.valueOf(value[2])); - tousseItem.setDiposable(value[3]); + tousseItem.setEditAmount(amount); + tousseItem.setDiposable("否"); tousseItem.setInvoicePlan(recyclingApplication); tousseItem.setTousseType(TousseDefinition.PACKAGE_TYPE_CUSTOM); - tousseItem.setPrice(costomToussePrice); - tousseItem.setRowPrice(costomToussePrice); + tousseItem.setPrice(price); + tousseItem.setRowPrice(price); tousseItem.setIsCleanedEntirely(tousseDefinition.getIsCleanedEntirely()); tousseItem.setTousseDefinitionId(tousseDefinition.getId()); tousseItem.setAncestorID(tousseDefinition.getAncestorID()); //设置发货数量依据(取包定义的发货数量依据) tousseItem.setInvoiceAmountMode(tousseDefinition.getInvoiceAmountMode()); tousseItem.setHideRecycling(tousseDefinition.getHideRecycling()); tousseItem.setIsInvoice(tousseDefinition.getIsInvoice()); - tousseItem.setIsRecycling(TousseDefinition.STR_YES); + tousseItem.setIsRecycling(tousseDefinition.getIsRecycling()); tousseItem.setIsThereIdentificationCard("否"); items.add(tousseItem); - } - } - recyclingApplication.setIncludeRecyclingItems(InvoicePlan.SIGNED_TRUE); - recyclingApplication.setIncludeInvoiceItems(InvoicePlan.SIGNED_FALSE); - recyclingApplication.setType(RecyclingApplication.TYPE_CUSTOM_TOUSSE_APPLIACTION_FORM);// 申请单 - recyclingApplication.setApplicationItems(items); - recyclingApplication.setRecyclingStatus(InvoicePlan.RECYCLINGSTATUS_AWAITRECYCLE); - recyclingApplication.setDeliverStatus(InvoicePlan.DELIVERSTATUS_AWAITDELIVER); - recyclingApplication.setOrderByFiled(InvoicePlan.RECYCLING_AWAITRECYCLE); - if(taskGroup != null){ - recyclingApplication.setHandleDepart(taskGroup.getDepartName()); - recyclingApplication.setHandleDepartCoding(taskGroup.getDepartCode()); - } - - recyclingApplication.setReaders(";ORGUNIT_" - + recyclingApplication.getDepartCoding() + ";"); - recyclingApplication.setSubmitTime(new Date()); - try { - recyclingApplicationManager - .saveOrUpdateRecyclingApplication(recyclingApplication,true); - } catch (Exception e) { - e.printStackTrace(); - } - printWriter.print("{success:true,message:'保存成功'}"); - printWriter.close(); - return null; + } + // 设置申请时间 + if (recyclingApplication.getSubmitTime() == null) { + recyclingApplication.setApplicationTime(Calendar.getInstance().getTime()); + } else { + recyclingApplication.setApplicationTime(tempApplicationTime); + } + recyclingApplication.setIncludeRecyclingItems(InvoicePlan.SIGNED_TRUE); + recyclingApplication.setIncludeInvoiceItems(InvoicePlan.SIGNED_FALSE); + recyclingApplication.setType(RecyclingApplication.TYPE_CUSTOM_TOUSSE_APPLIACTION_FORM);// 申请单 + recyclingApplication.setApplicationItems(items); + recyclingApplication.setRecyclingStatus(InvoicePlan.RECYCLINGSTATUS_AWAITRECYCLE); + recyclingApplication.setDeliverStatus(InvoicePlan.DELIVERSTATUS_AWAITDELIVER); + recyclingApplication.setOrderByFiled(InvoicePlan.RECYCLING_AWAITRECYCLE); + if(taskGroup != null){ + recyclingApplication.setHandleDepart(taskGroup.getDepartName()); + recyclingApplication.setHandleDepartCoding(taskGroup.getDepartCode()); + }else{ + recyclingApplication.setHandleDepart(recyclingApplication.getDepart()); + recyclingApplication.setHandleDepartCoding(recyclingApplication.getDepartCoding()); + } + + recyclingApplication.setReaders(";ORGUNIT_" + + recyclingApplication.getDepartCoding() + ";"); + recyclingApplication.setSubmitTime(new Date()); + try { + recyclingApplicationManager + .saveOrUpdateRecyclingApplication(recyclingApplication,true); + } catch (Exception e) { + e.printStackTrace(); + } + printWriter.print("{success:true,message:'保存成功'}"); + printWriter.close(); + } + return null; } /** Index: ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/service/TousseDefinitionManagerImpl.java =================================================================== diff -u -r25767 -r25800 --- ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/service/TousseDefinitionManagerImpl.java (.../TousseDefinitionManagerImpl.java) (revision 25767) +++ ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/service/TousseDefinitionManagerImpl.java (.../TousseDefinitionManagerImpl.java) (revision 25800) @@ -483,6 +483,12 @@ if(materialDefinition == null){ //1、怕并发问题 2、他在定义材料是的材料名字就带有规格如出现(一次性针头[4F])那么这里就有可能查不出来 throw new RuntimeException(name + "已经不存在了!"); } + if(td.isCustomTousse()){ + String includeImplant = obj.optString("includeImplant"); + if(StringUtils.isNotBlank(includeImplant)){ + materialDefinition.setIsImplant(includeImplant); + } + } } //如果材料为外来器械材料并且数量大于0,才算是包含植入物 Index: ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/service/TousseDefinitionManager.java =================================================================== diff -u -r25765 -r25800 --- ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/service/TousseDefinitionManager.java (.../TousseDefinitionManager.java) (revision 25765) +++ ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/service/TousseDefinitionManager.java (.../TousseDefinitionManager.java) (revision 25800) @@ -65,7 +65,12 @@ */ public boolean isExistDuplicateForeignTousseDefinition(String id, String name, String supplierName); - + /** + * 判断自定义器械包是否存在同名包(自定义器械包不能同名,其他包可以) + * @param id + * @param name + * @return ture:存在 + */ public boolean isExistDuplicateCustomTousseDefinition(String id, String name); /** Index: ssts-web/src/main/webapp/disinfectsystem/basedatamanager/tousse/customTousseForm.js =================================================================== diff -u -r23772 -r25800 --- ssts-web/src/main/webapp/disinfectsystem/basedatamanager/tousse/customTousseForm.js (.../customTousseForm.js) (revision 23772) +++ ssts-web/src/main/webapp/disinfectsystem/basedatamanager/tousse/customTousseForm.js (.../customTousseForm.js) (revision 25800) @@ -46,70 +46,36 @@ //是否是填充价格 var fillPrice; -var materialDefinitionConfig = Ext.data.Record.create([ - {name : 'id'}, - {name : 'name'}, - {name : 'type'}, - {name : 'isImplant'}, - {name : 'count'} -]); - - -var configStore = new Ext.data.Store({ - proxy : new Ext.data.HttpProxy({ - url : WWWROOT + '/disinfectSystem/baseData/tousseDefinitionAction!getCustomTousseMaterials.do', - method : "POST" - }), - reader : new Ext.data.JsonReader({ - fields : [ - {name : 'id'}, - {name : 'name'}, - {name : 'type'}, - {name : 'count'}, - {name : 'isImplant'} - ] - }) -}); - - function addMaterial(id,name,type,isImplant){ + var count1 = top.Ext.getCmp('count1').getValue(); if(name == ''){ showResult("请先选择材料。"); return false; - }else if(top.Ext.getCmp('count1').getValue() == ''){ + }else if(count1 == ''){ showResult("请输入数量。"); return false; } - var currentCount = configStore.getCount(); - for(var i = 0; i< currentCount;i++){ - if(configStore.getAt(i).get('name') == name){ + var node = top.Ext.getCmp('tousseLeaseColumnTree').getSelectionModel().getSelectedNode(); + if(node == null){//未选择器械包 + showResult("请选择要添加材料的器械包。"); + return false; + } + var nodeType = node.attributes.type; + if(nodeType != "自定义器械包"){ + node = node.parentNode; + } + var added = false; + node.eachChild(function(childNode){ + if(childNode.attributes.material == name){ showResult("该材料已经在列表中,不能重复添加。"); - return false; + added = true; } - } - - var p = new materialDefinitionConfig({ - id : id, - name : name, - type : type, - isImplant : isImplant, - count : top.Ext.getCmp('count1').getValue() }); - configStore.add(p);// 插入到最后一行 - top.Ext.getCmp('materialId').setValue(''); - top.Ext.getCmp('material').setValue(''); - top.Ext.getCmp('count1').setValue(''); - top.Ext.getCmp('existTousseDefinitionId').setValue(''); -} - - -function removeCustomApplicationGridItem(id){ - var rows = top.Ext.getCmp('configGrid').getSelectionModel().getSelections();// 返回值为 - if (rows) { - for ( var i = 0; i < rows.length; i++) { - configStore.remove(rows[i]); - } + if(added){ + return false; } + //创建子节点 + createChildNode(node, id, name, isImplant, count1, type); } @@ -121,6 +87,94 @@ * @returns */ function addAndEditCustomTousse(appId,tousseDefId,authority,callback) { + var tousseLeaseColumnTree = new top.Ext.tree.ColumnTree({ + id : 'tousseLeaseColumnTree', + rootVisible:false, + autoScroll:true, + height : 250, + bodyStyle : 'border:1px solid #afd7af', + containerScroll : true, + columns:[{ + header:'器械包名称', + width:205, + dataIndex:'tousseName' + },{ + header:'材料名称', + width:170, + dataIndex:'material' + },{ + header:'是否植入物', + width:100, + dataIndex:'isImplant' + },{ + header:'数量', + width:90, + dataIndex:'amount' + },{ + header:'类型', + width:90, + hidden: true, + dataIndex:'type' + },{ + header:'删除', + width:95, + dataIndex:'deleteButton', + renderer:function(v,p,record){ + var str = ""; + return str; + } + },{ + header:'器械包隐藏名称', + hidden:true, + dataIndex:'fromTousse' + }], + root: new top.Ext.tree.AsyncTreeNode({ + text:'器械包' + }) + }); + + var treeEditer = new top.Ext.tree.ColumnTreeEditor(tousseLeaseColumnTree, { + completeOnEnter : true, + autosize : true, + allowBlank: false, + selectOnFocus : true, + revertInvalid:true, + ignoreNoChange : true, + clicksToEdit:1 + }); + + treeEditer.on("beforestartedit", function(thiz,el,v){ + var tempNode = thiz.editNode;//将要编辑的节点 + var editCell = thiz.editColIndex; + if(editCell =="isImplant" || editCell == "material"){//限制编辑单元格 + return false; + } + return true; + }); + + treeEditer.on("complete",function(thiz,newValue,oldValue){ + var editNode = thiz.editNode;//将要编辑的节点 + var attr = editNode.attributes;//将要编辑的节点属性 + var re = /^[1-9]+[0-9]*$/; + var editCell = thiz.editColIndex; + if(re.test(oldValue)) {//通过匹配oldvalue确定编辑的单元格是数量列 + if(!re.test(newValue)){ + return false; + } + } +/* if(editCell == 'isImplant'){ + if(newValue != '是' && newValue != '否'){ + return false; + }else if(newValue != '是' && newValue != oldValue && typeof(attr.tousseName) == undefined){ + editNode.parentNode.attributes.isImplant = '是'; + } + + }*/ + if(editCell == 'tousseName' && newValue != oldValue && !checkAddedTousseName(newValue)){ + return false; + } + }); + var btSaveDisabledStatus = false; this.tousseId = tousseDefId; if (appId) {// 申请单 @@ -134,9 +188,6 @@ }); DWREngine.setAsync(true); } - configStore.removeAll(); - configStore.baseParams['tousseId'] = tousseId; - configStore.reload(); this.callback = callback; this.appId = appId; if(authority == "00") { @@ -153,28 +204,7 @@ this.fillPrice = false; } - var cm = new top.Ext.grid.ColumnModel([ - {header : "材料名称",dataIndex : 'name',width : 250}, - {header : "数量",dataIndex : 'count',editor : new top.Ext.form.NumberField({ - allowDecimals: false, - allowBlank: false, - listeners : { - 'focus':function(){ - this.selectText(); - } - } - }) - }, - {header : "是否植入物",dataIndex : 'isImplant',width : 80}, - {header : '删除',dataIndex : 'button',width : 80,menuDisabled : true,renderer : function(v, p, record){ - return ""; - } - } - ]); - + var tousseAndDiposableGoodsStoreForBorrowing; formAppObj = new top.Ext.FormPanel({ id : 'applicationForm', frame : true, @@ -402,10 +432,22 @@ id : 'tousseType' },{ xtype : 'hidden', - name : 'materialDefinitionConfigResult', - id : 'materialDefinitionConfigResult' + name : 'customTousseInfo', + id : 'customTousseInfo' },{ - columnWidth : .62, + xtype : 'hidden', + name : 'materialId', + id : 'materialId' + },{ + xtype : 'hidden', + name : 'materialType', + id : 'materialType' + },{ + xtype : 'hidden', + name : 'isImplant', + id : 'isImplant' + },{ + columnWidth : .5, layout : 'form', labelWidth : 70, items : [{ @@ -423,67 +465,22 @@ triggerAction : 'all', hideTrigger : true, typeAhead : false, - allowBlank : false, + allowBlank : true, anchor : '100%', listeners:{ - select:function(combo, record, index){ - Ext.Ajax.request({ - url : WWWROOT + '/disinfectSystem/customRecyclingApplicationAction!loadLatestMaterialInstanceListByTousseName.do', - params : {customTousseName : record.data.name}, - success : function(response, options) { - var tousseDefinition = Ext.decode(response.responseText); - top.Ext.getCmp('existTousseDefinitionId').setValue(''); - configStore.removeAll(); - if(tousseDefinition != null){ - top.Ext.getCmp('existTousseDefinitionId').setValue(tousseDefinition.id); - for(var i = 0 ;i < tousseDefinition.materialInstances.length;i++){ - var materialDefinition = tousseDefinition.materialInstances[i].materialDefinition; - - var materialName = materialDefinition.name; - var specification = materialDefinition.specification; - if(specification != null && specification != ''){ - materialName = materialName+"["+specification+"]"; - } - - var p = new materialDefinitionConfig({ - id : materialDefinition.id, - name : materialName, - count : tousseDefinition.materialInstances[i].applyAmount, - isImplant : materialDefinition.isImplant, - type : '器械' - }); - configStore.add(p); - } - - for(var i = 0 ; i < tousseDefinition.diposableGoodsItems.length ; i++){ - var diposableGoods = tousseDefinition.diposableGoodsItems[i].diposableGoods; - var p = new materialDefinitionConfig({ - id : diposableGoods.id, - name : diposableGoods.name, - isImplant : '', - count : tousseDefinition.diposableGoodsItems[i].amount, - type : '一次性物品' - }); - configStore.add(p); - } - } - }, - failure : function(form, action) { - } - }); - }, focus : function(thiz){ thiz.selectText(); } } }] },{ - columnWidth : .38, + columnWidth : .2, layout : 'form', items:[{ xtype : 'numberfield', fieldLabel : "申请数量", - allowBlank : appId!=null?false:true, +// allowBlank : appId!=null?false:true, + allowBlank : true, allowNegative : false, allowDecimals : false, blankText : '请输入数量!', @@ -494,101 +491,104 @@ hideLabel : appId==null, anchor : '100%' }] - }] - },new top.Ext.grid.EditorGridPanel({ - id : 'configGrid', - name : 'configGrid', - store : configStore, - cm : cm, - height : 250, - width : '100%', - frame : false, - viewConfig: {forceFit: true}, - bodyStyle : 'border:1px solid #afd7af', - autoExpandColumn : 'count', - clicksToEdit : 1,//设置点击几次才可编辑 - selModel : new top.Ext.grid.RowSelectionModel({ - singleSelect : false - }), - tbar : [{ - xtype : 'hidden', - name : 'materialId', - id : 'materialId' - },{ - xtype : 'hidden', - name : 'type', - id : 'type' - },{ - xtype : 'hidden', - name : 'isImplant', - id : 'isImplant' - },{ - text : ' ' - },{ - text : '材料名称:' - },{ - xtype : 'combo', - id : 'material', - name : 'material', - queryParam : 'spell', - minChars : 0, - valueField : 'name', - displayField : 'name', - store : customMaterialDefinitionStore, - forceSelection : true, - lazyInit : false, - triggerAction : 'all', - disabled : !fillTousseName, - hideTrigger : true, - typeAhead : false, - allowBlank : true, - width : 340, - listeners : { - select : function(combo, record, index) { - combo.setValue(record.data.name); - top.Ext.getCmp('materialId').setValue(record.data.id); - top.Ext.getCmp('type').setValue(record.data.type); - top.Ext.getCmp('isImplant').setValue(record.data.isImplant); - }, - specialkey : function(field, ee) { - if (ee.getKey() == Ext.EventObject.ENTER) { - top.Ext.getCmp('count1').focus(); - } - } + },{ + columnWidth : .3, + layout : 'form', + items:[{ + xtype : 'button', + text : '添加到器械包列表', +// iconCls : 'btn_ext_add', + disabled : !fillTousseName, + handler : function() { + addTousseLeaseItemCu(); + } + }] + },{ + columnWidth : .5, + layout : 'form', + labelWidth : 70, + items : [{ + xtype : 'combo', + fieldLabel : '材料名称', + id : 'material', + name : 'material', + queryParam : 'spell', + minChars : 0, + valueField : 'name', + displayField : 'name', + store : customMaterialDefinitionStore, + forceSelection : true, + lazyInit : false, + triggerAction : 'all', + disabled : !fillTousseName, + hideTrigger : true, + typeAhead : false, + allowBlank : true, + anchor : '100%', + listeners : { + select : function(combo, record, index) { + combo.setValue(record.data.name); + top.Ext.getCmp('materialId').setValue(record.data.id); + top.Ext.getCmp('materialType').setValue(record.data.type); + top.Ext.getCmp('isImplant').setValue(record.data.isImplant); + }, + specialkey : function(field, ee) { + if (ee.getKey() == Ext.EventObject.ENTER) { + top.Ext.getCmp('count1').focus(); + } + } - } - },{ - text : ' ' - },{ - text : '数量:' - },{ - xtype : 'numberfield', - maxLength : '16', - id : 'count1', - name : 'count1', - disabled : !fillTousseName, - width : 120, - style : 'text-align: left', - allowDecimals:false, - allowNegative:false, - listeners : { - specialkey : function(field, e) { - if (e.getKey() == Ext.EventObject.ENTER) { - addMaterial(top.Ext.getCmp("materialId").getValue(),top.Ext.getCmp("material").getValue(),top.Ext.getCmp("type").getValue(),top.Ext.getCmp("isImplant").getValue()); - top.Ext.getCmp("material").focus(); - } - } - } - },'->',{ - text : '添加', - iconCls : 'btn_ext_add', - disabled : !fillTousseName, - handler : function() { - addMaterial(top.Ext.getCmp("materialId").getValue(),top.Ext.getCmp("material").getValue(),top.Ext.getCmp("type").getValue(),top.Ext.getCmp("isImplant").getValue()); - top.Ext.getCmp("material").focus(); - } - }] - })], + } + }] + },{ + columnWidth : .2, + layout : 'form', + items:[{ + xtype : 'numberfield', + fieldLabel : "材料数量", + maxLength : '16', + id : 'count1', + name : 'count1', + disabled : !fillTousseName, + anchor : '100%', + style : 'text-align: left', + allowDecimals:false, + allowNegative:false, + listeners : { + specialkey : function(field, e) { + if (e.getKey() == Ext.EventObject.ENTER) { + addMaterial(top.Ext.getCmp("materialId").getValue(),top.Ext.getCmp("material").getValue(),top.Ext.getCmp("materialType").getValue(),top.Ext.getCmp("isImplant").getValue()); + top.Ext.getCmp("material").focus(); + } + } + } + }] + },{ + columnWidth : .3, + layout : 'form', + items:[{ + xtype : 'button', + text : '添加', + disabled : !fillTousseName, + handler : function() { + addMaterial(top.Ext.getCmp("materialId").getValue(),top.Ext.getCmp("material").getValue(),top.Ext.getCmp("materialType").getValue(),top.Ext.getCmp("isImplant").getValue()); + top.Ext.getCmp("material").focus(); + + } + }] + }] + },{ + xtype:"fieldset", + autoScroll:true, + id : 'tousseDefinitionList', + title :'器械包列表', + height:250, +// height : top.screen.height > 1000 ? 210 : 230, + layout:'fit', + items:[ + tousseLeaseColumnTree + ] + }], buttons : [{ text : '打印预览', hidden:false, @@ -634,13 +634,13 @@ modal : true, width : 720, // height : appId==null?400:575, - height :500, + height :600, plain : true, items : winItems }); tousseWin.show(); - if(appId != null && appId > 0) { + if(appId != null && appId > 0 && !isNaN(appId)) { formAppObj.form.load({ url : WWWROOT + '/disinfectSystem/recyclingApplicationAction!loadRecyclingApplication.do', method : 'GET', @@ -712,74 +712,28 @@ DWREngine.setAsync(true); }); } - configStore.load({ params: {tousseId : tousseId} }); } -//获取申请器械包的数据 -function getCustomTousseGridData() { - var tousseIds = null; - var tousseItemId = top.Ext.getCmp('tousseItemId').getValue(); - if(tousseItemId == ""){ - tousseItemId = 0; - } - tousseIds = tousseItemId + "," +top.Ext.getCmp('name').getValue() + "," + top.Ext.getCmp('count').getValue() + ',否'; - top.Ext.getCmp('customTousseInstanceIds').setValue(tousseIds); -} function validateAndSubmitCustom(){ - var rowIndex = top.Ext.getCmp('configGrid').getStore().getCount();//grid的行数 - var materialDefinitionConfigResult = []; - for(var i =0 ;i < rowIndex ; i++ ){ - var name = top.Ext.getCmp('configGrid').getStore().getAt(i).get('name'); - var type = top.Ext.getCmp('configGrid').getStore().getAt(i).get('type'); - var count = top.Ext.getCmp('configGrid').getStore().getAt(i).get('count'); - var rs = {'name': name , 'tousseType' : type, 'count': count }; - materialDefinitionConfigResult.push(rs); - } - var isSupplyRoomUser = validateIsSupplyRoomUser(); - if(!isSupplyRoomUser){ - top.Ext.getCmp("depart").enable(); - } - Ext.Ajax.request({ - url : WWWROOT + '/disinfectSystem/baseData/tousseDefinitionAction!validateCustomTousseDefinitionName.do', - params : {validateId : tousseId,valifateName:top.Ext.getCmp('name').getValue()}, - success : function(response, options) { - var result = Ext.decode(response.responseText); - var existTousseDefinitionId = top.Ext.getCmp('existTousseDefinitionId').getValue(); - if(result.stauts==1){ - top.Ext.getCmp('isCleanedEntirely').setValue('是'); - top.Ext.getCmp('tousseType').setValue('自定义器械包'); - top.Ext.getCmp('materialDefinitionConfigResult').setValue(JSON.stringify(materialDefinitionConfigResult)); - getCustomTousseGridData(); - formAppObj.form.submit({ - url : WWWROOT + '/disinfectSystem/customRecyclingApplicationAction!saveCustomRecyclingApplication.do?customType=true', - method : 'POST', - waitMsg : '正在提交数据,请稍候', - waitTitle : '提交表单', - params : {id : parseInt(appId)}, - success : function(form, action) { - tousseWin.destroy(); - showResult(action.result.message); - grid.dwrReload(); - }, - failure : function(form, action) { - showResult(action.failureType); - } - }); - }else{ - showResult(result.message); - top.Ext.getCmp('saveBtn').enable(); - } + formAppObj.form.submit({ + url : WWWROOT + '/disinfectSystem/customRecyclingApplicationAction!saveCustomRecyclingApplication.do?customType=true', + method : 'POST', + waitMsg : '正在提交数据,请稍候', + waitTitle : '提交表单', + params : {id : parseInt(appId)}, + success : function(form, action) { + tousseWin.destroy(); + showResult(action.result.message); + grid.dwrReload(); }, - failure : function(response, options) { - var result = Ext.decode(response.responseText); - showResult(result.cause); + failure : function(form, action) { + showResult(action.failureType); } }); } - function updatePrice() { var price = top.Ext.getCmp('price').getValue(); Ext.Ajax.request({ @@ -803,42 +757,254 @@ this.enable(); return false; } - if (top.Ext.getCmp('configGrid').getStore().getCount() == 0) { - showResult('请完成组装成器械包的材料!'); - this.enable(); + this.enable(); + if(getCustomTousseInfo()){ + if (!fillTousseName && fillPrice) { + updatePrice(); + } else { + validateAndSubmitCustom(); + } + callback(); + } +} + +function cancel() { + tousseWin.close(); +} + +/** + * 添加物品到“器械包列表”中. + */ +function addTousseLeaseItemCu(){ + var tousseName = top.Ext.getCmp('name').getValue().trim(); + var count = top.Ext.getCmp('count').getValue(); + if(tousseName == ""){ + showResult("请输入器械包!"); + top.Ext.getCmp('name').setValue(""); + top.Ext.getCmp('name').focus(); return false; + }else if(count == ""){ + showResult("请输入数量,数量必须大于0!"); + return false; } - var materilaStore = top.Ext.getCmp('configGrid').getStore(); - for(var i = 0 ;i < materilaStore.getCount();i++){ - var record = materilaStore.getAt(i); - if(record.get('name') == ""){ - showResult('请填写材料名称!'); - this.enable(); - return false; + //数据库有非自定义同名包或列表有同名包或验证失败,则不添加 + var result; + Ext.Ajax.request({ + url : WWWROOT + '/disinfectSystem/baseData/tousseDefinitionAction!validateCustomTousseDefinitionName.do', + params : {validateId : "",valifateName:tousseName}, + success : function(response, options) { + result = Ext.decode(response.responseText); + if(result.stauts!=1){//存在相同的器械包名 + showResult(result.message); + }else{ + var rootNode = top.Ext.getCmp('tousseLeaseColumnTree').getRootNode(); + if(checkAddedTousseName(tousseName)){ + //创建父节点 + var node = new top.Ext.tree.TreeNode({ + id:Ext.id(), + text:"", + cls:'master-task', + iconCls:'task-folder', + uiProvider:top.Ext.tree.ColumnNodeUI, + leaf:false, + expanded:true + }); + node.attributes.id = '0'; + node.attributes.tousseName = tousseName; + node.attributes.amount = count; + node.attributes.type = "自定义器械包"; + node.attributes.isImplant = "否"; + //加0为了解决改器械包列表包名页面正常显示,但其是改fromTousse的值,而tousseName其实不会被修改的问题fromTousse + node.attributes.fromTousse = '0'+tousseName; + //如果添加的器械包有材料就创建子节点 + Ext.Ajax.request({ + url : WWWROOT + '/disinfectSystem/customRecyclingApplicationAction!loadLatestMaterialInstanceListByTousseName.do', + params : {customTousseName : tousseName}, + success : function(response, options) { + var tousseDefinition = Ext.decode(response.responseText); + top.Ext.getCmp('existTousseDefinitionId').setValue(''); + var includeImplantStr; + if(tousseDefinition != null){ + top.Ext.getCmp('existTousseDefinitionId').setValue(tousseDefinition.id); + for(var i = 0 ;i < tousseDefinition.materialInstances.length;i++){ + var materialDefinition = tousseDefinition.materialInstances[i].materialDefinition; + var materialName = materialDefinition.name; + var specification = materialDefinition.specification; + if(specification != null && specification != ''){ + materialName = materialName+"["+specification+"]"; + } + createChildNode(node, materialDefinition.id, materialName, materialDefinition.isImplant, tousseDefinition.materialInstances[i].applyAmount, '器械'); + } + + for(var i = 0 ; i < tousseDefinition.diposableGoodsItems.length ; i++){ + var diposableGoods = tousseDefinition.diposableGoodsItems[i].diposableGoods; + createChildNode(node, diposableGoods.id, diposableGoods.name, '', tousseDefinition.diposableGoodsItems[i].amount, '一次性物品'); + } + } + + }, + failure : function(form, action) { + } + }); + rootNode.appendChild(node); + top.Ext.getCmp('name').setValue(""); + top.Ext.getCmp('count').setValue(""); + top.Ext.getCmp('name').focus(); + } + } + }, + failure : function(response, options) { + result = Ext.decode(response.responseText); + showResult(result.cause); } - if(record.get('count') <= 0){ - showResult('材料数量必须大于0!'); - this.enable(); - return false; + }); +} + +/** + * 获取自定义器械包列表信息 + * return 验证合法返回true,并且获取信息设置到隐藏域customTousseInfo,否则返回false + */ +function getCustomTousseInfo(){ + var customTousseInfo = []; + var nodes = top.Ext.getCmp('tousseLeaseColumnTree').getRootNode().childNodes; + var msg = ""; + if(nodes.length == 0){ + showResult("未添加自定义器械包!"); + return false; + } + //遍历每一个自定义械包 + for (var i = 0; i < nodes.length; i++){ + var n = nodes[i]; + var tousseName = n.attributes.tousseName.trim(); + var isImplant = n.attributes.isImplant.trim(); + var amount = n.attributes.amount; + if(!tousseName){ + msg = "自定义器械包名称不能为空!"; + break; } + if(amount <= 0){ + msg = "自定义器械包数量必须大于0!"; + break; + } + var materialNodes = n.childNodes; + var materialInfo = []; + var materialNameJson = {}; + var materialAmountPass = false; + //遍历外来器械包下的每一个材料(如果材料名称有重复,则进行提示不予提交) + for (var j=0; j < materialNodes.length; j++){ + var materialNode = materialNodes[j]; + var materialName = materialNode.attributes.material.trim(); + var count = materialNode.attributes.amount; + var materialIsImplant = materialNode.attributes.isImplant.trim(); + if(!materialName){ + msg = "材料必须填写名称!"; + break; + } + if(count > 0){ + materialAmountPass = true; + } + materialInfo.push({ + id : materialNode.attributes.id, + name : materialName, + count : count, + includeImplant : materialIsImplant, + tousseType : materialNode.attributes.type + }); + materialNameJson[materialName] = materialName; + } + if(!materialAmountPass && msg == ""){ + msg = "材料数量不能都为0!"; + break; + } + customTousseInfo.push({ + id : n.attributes.id, + tousseName : tousseName, + amount : amount, + isImplant : isImplant, + materials : materialInfo + }); } - var count = top.Ext.getCmp('count').getValue(); - if(count <= 0){ - showResult('申请数量必须大于1!'); + if(msg == ""){ + top.Ext.getCmp('customTousseInfo').setValue(JSON.stringify(customTousseInfo)); + return true; + }else{ + showResult(msg); return false; } - - if (!fillTousseName && fillPrice) { - updatePrice(); - } else { - validateAndSubmitCustom(); +} +/** + * 删除器械包列表选择项 + * @param tousseName + * 选择材料:fromTousse:自定义测试包6,material:尖形整形镊[无钩12cm],tousseName:undefined + * 选择器械包:fromTousse:自定义测试包6,material:undefined,tousseName:自定义测试包6 + */ +function removeTousseLeaseItem2(fromTousse,material,tousseName){ + var rootNode = top.Ext.getCmp('tousseLeaseColumnTree').getRootNode();; + rootNode.eachChild(function(childNode){ + if(fromTousse == childNode.attributes.fromTousse){ + if(tousseName != 'undefined'){ + childNode.remove(); + return false; + }else{ + childNode.eachChild(function(grandsonNode){ + if(material == grandsonNode.attributes.material){ + grandsonNode.remove(); + return false; + } + }); + } + } + }); +} +/** + * 检验器械包名是否已经存在于列表 + * @param rootNode + * @param tousseName + * @returns {Boolean} + */ +function checkAddedTousseName(tousseName){ + var rootNode = top.Ext.getCmp('tousseLeaseColumnTree').getRootNode(); + var isTousseAlreadyAdded = false; + rootNode.eachChild(function(pNode){ + if(pNode.attributes.tousseName == tousseName){ + isTousseAlreadyAdded = true; + return false; + } + }); + if(isTousseAlreadyAdded){ + showResult("该器械包已经在列表中!"); + return false; } -// fillPriceReturnValue = top.Ext.get('price').getValue(); - callback(); + return true; } - -function cancel() { - tousseWin.close(); - tousseWin.destroy(); +/** + * 创建材料节点 + * @param parentNode + * @param id + * @param materialName + * @param isImplant + * @param count + * @param type + */ +function createChildNode(parentNode, id, materialName, isImplant, count, type){ + //创建子节点 + var childNode = new top.Ext.tree.TreeNode({ + id:Ext.id(), + text:"", + iconCls:'task', + uiProvider:top.Ext.tree.ColumnNodeUI, + leaf:true, + expanded:true + }); + if(isImplant == "是"){ + parentNode.attributes.isImplant = isImplant; + } + childNode.attributes.id = id; + childNode.attributes.material = materialName; + childNode.attributes.amount = count; + childNode.attributes.type = type; + childNode.attributes.isImplant = isImplant; + //加0为了解决改器械包列表包名页面正常显示,但其是改fromTousse的值,而tousseName其实不会被修改的问题fromTousse + childNode.attributes.fromTousse = "0"+parentNode.attributes.tousseName; + parentNode.insertBefore(childNode,parentNode.firstChild); } -