Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/operationNameManager/action/OperationNameAction.java =================================================================== diff -u -r12331 -r15387 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/operationNameManager/action/OperationNameAction.java (.../OperationNameAction.java) (revision 12331) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/operationNameManager/action/OperationNameAction.java (.../OperationNameAction.java) (revision 15387) @@ -7,6 +7,7 @@ import javax.servlet.http.HttpServletResponse; import net.sf.json.JSONArray; +import net.sf.json.JSONObject; import net.sf.json.JsonConfig; import org.apache.commons.lang.StringUtils; @@ -18,9 +19,11 @@ import com.forgon.disinfectsystem.basedatamanager.operationNameManager.service.OperationNameManager; import com.forgon.disinfectsystem.entity.basedatamanager.operationNameManager.OperationName; import com.forgon.disinfectsystem.entity.basedatamanager.operationNameManager.OperationOrg; +import com.forgon.disinfectsystem.entity.basedatamanager.operationNameManager.OperationUseTousseItem; import com.forgon.tools.GB2Alpha; import com.forgon.tools.GB2WB; import com.forgon.tools.StrutsParamUtils; +import com.forgon.tools.json.JSONUtil; import com.opensymphony.xwork2.ModelDriven; import com.opensymphony.xwork2.Preparable; @@ -99,66 +102,45 @@ * @return * @throws Exception */ - public String saveOperationOrg() throws Exception{ - String treeItemData = StrutsParamUtils.getPraramValue("treeItemData", ""); - List operationOrgList = null; - if(StringUtils.isNotBlank(treeItemData)){ - operationOrgList = jsonStrToJavaList(OperationOrg.class, treeItemData); - } + public void saveOperationOrg() throws Exception{ + String orgUnitCoding = StrutsParamUtils.getPraramValue("orgUnitCoding", ""); + String orgUnitName = StrutsParamUtils.getPraramValue("orgUnitName", ""); String isExistName = ""; boolean isNotExist = true; - if(operationOrgList != null){ - for(OperationOrg operationOrg:operationOrgList){ - if(operationNameManager.isExistOperationOrgByCoding(operationOrg.getOrgUnitCoding())){ - isNotExist = false; - isExistName = operationOrg.getOrgUnitName(); - break; - } + boolean success = true; + String msg = "保存成功!"; + if(StringUtils.isNotBlank(orgUnitCoding)){ + if(operationNameManager.isExistOperationOrgByCoding(orgUnitCoding)){ + isNotExist = false; + isExistName = operationOrg.getOrgUnitName(); } if(isNotExist){ - operationNameManager.saveOrUpdateOperationOrgList(operationOrgList); + OperationOrg org = new OperationOrg(); + org.setOrgUnitCoding(orgUnitCoding); + org.setOrgUnitName(orgUnitName); + operationNameManager.saveOrUpdateOperationOrg(org); + }else{ + success = false; + msg = isExistName + ",已存在!"; } } - String msg = "{success:true,saveSuccess:"+isNotExist+",nameIsExist:\""+isExistName+"\"}"; - responseMsg(msg); - return null; + responseMsg(JSONUtil.buildJsonObject(success, msg).toString()); } /** - * 批量保存手术名称对象 - * @return - * @throws Exception + * 保存手术名称对象 */ - public String saveOperationName() throws Exception{ - String treeItemData = StrutsParamUtils.getPraramValue("treeItemData", ""); - List operationNameList = null; - if(StringUtils.isNotBlank(treeItemData)){ - operationNameList = jsonStrToJavaList(OperationName.class, treeItemData); + public void saveOperationName() throws Exception{ + String data = StrutsParamUtils.getPraramValue("data", ""); + boolean success = true; + String msg = "保存成功!"; + try { + operationNameManager.saveOperationName(data); + } catch (Exception e) { + success = false; + msg = e.getMessage(); } - - String isExistName = ""; - boolean isNotExist = true; - if(operationNameList != null){ - for(OperationName operationName:operationNameList){ - if (operationNameManager.isExistByUnitCodingAndOperationName( - operationOrg.getOrgUnitCoding(), operationName - .getOperationName(), "")) { - isNotExist = false; - isExistName = operationName.getOperationName(); - break; - } - - operationName.setOperationOrg(operationOrg); - initSpellingAndWb(operationName); - } - - if(isNotExist){ - operationNameManager.saveOrUpdateList(operationNameList); - } - } - String msg = "{success:true,saveSuccess:"+isNotExist+",nameIsExist:\""+isExistName+"\"}"; - responseMsg(msg); - return null; + responseMsg(JSONUtil.buildJsonObject(success, msg).toString()); } /** @@ -202,6 +184,31 @@ return null; } + public void loadOperationName(){ + String id = StrutsParamUtils.getPraramValue("id", ""); + OperationName operationNamePo = operationNameManager.getOperationNameById(id); + JSONArray items = new JSONArray(); + JSONObject obj = new JSONObject(); + String operationName = ""; + if(operationNamePo != null){ + operationName = operationNamePo.getOperationName(); + if(operationNamePo.getTousseItems() != null){ + for (OperationUseTousseItem item : operationNamePo.getTousseItems()) { + JSONObject itemJson = new JSONObject(); + itemJson.put("itemId", item.getId()); + itemJson.put("tousseDefinitionId", item.getTousseDefinitionId()); + itemJson.put("name", item.getName()); + itemJson.put("amount", item.getAmount()); + items.add(itemJson); + } + } + } + obj.put("operationName", operationName); + obj.put("tousseItems", items); + obj.put("success", true); + responseMsg(obj.toString()); + } + /** * 删除科室 * @return Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/operationNameManager/service/OperationNameManager.java =================================================================== diff -u -r12331 -r15387 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/operationNameManager/service/OperationNameManager.java (.../OperationNameManager.java) (revision 12331) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/operationNameManager/service/OperationNameManager.java (.../OperationNameManager.java) (revision 15387) @@ -19,6 +19,8 @@ public void saveOrUpdateOperationOrgList(List operationOrgList); + public void saveOperationName(String json); + public void saveOrUpdateList(List operationNameList); public OperationName getOperationNameById(String id); Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/basedatamanager/operationNameManager/OperationName.java =================================================================== diff -u -r12331 -r15387 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/basedatamanager/operationNameManager/OperationName.java (.../OperationName.java) (revision 12331) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/basedatamanager/operationNameManager/OperationName.java (.../OperationName.java) (revision 15387) @@ -1,11 +1,17 @@ package com.forgon.disinfectsystem.entity.basedatamanager.operationNameManager; +import java.util.ArrayList; +import java.util.List; + import javax.persistence.CascadeType; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; import javax.persistence.Table; import org.hibernate.annotations.Cache; @@ -31,6 +37,11 @@ private String wbCode;// 五笔 private OperationOrg operationOrg; // 部门信息 + + /** + * 手术使用到的器械包 + */ + private List tousseItems = new ArrayList(); @Id @GeneratedValue(strategy = GenerationType.AUTO) @@ -74,4 +85,15 @@ public void setOperationOrg(OperationOrg operationOrg) { this.operationOrg = operationOrg; } + + @OneToMany(fetch = FetchType.LAZY, cascade = javax.persistence.CascadeType.ALL) + @JoinColumn(name = "operationName_id") + public List getTousseItems() { + return tousseItems; + } + + public void setTousseItems(List tousseItems) { + this.tousseItems = tousseItems; + } + } Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/basedatamanager/operationNameManager/OperationUseTousseItem.java =================================================================== diff -u --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/basedatamanager/operationNameManager/OperationUseTousseItem.java (revision 0) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/basedatamanager/operationNameManager/OperationUseTousseItem.java (revision 15387) @@ -0,0 +1,73 @@ +package com.forgon.disinfectsystem.entity.basedatamanager.operationNameManager; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +/** + * @author WangYi + * 手术使用器械包明细 + */ + +@Entity +@Table(name = "OperationUseTousseItem") +@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) +public class OperationUseTousseItem { + + private Long id; + + private String name; + + private Integer amount; + + private Long tousseDefinitionId; + + private Long operationNameId; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getAmount() { + return amount; + } + + public void setAmount(Integer amount) { + this.amount = amount; + } + + public Long getTousseDefinitionId() { + return tousseDefinitionId; + } + + public void setTousseDefinitionId(Long tousseDefinitionId) { + this.tousseDefinitionId = tousseDefinitionId; + } + + public Long getOperationNameId() { + return operationNameId; + } + + public void setOperationNameId(Long operationNameId) { + this.operationNameId = operationNameId; + } + +} Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/operationNameManager/service/OperationNameManagerImpl.java =================================================================== diff -u -r12331 -r15387 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/operationNameManager/service/OperationNameManagerImpl.java (.../OperationNameManagerImpl.java) (revision 12331) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/operationNameManager/service/OperationNameManagerImpl.java (.../OperationNameManagerImpl.java) (revision 15387) @@ -1,9 +1,12 @@ package com.forgon.disinfectsystem.basedatamanager.operationNameManager.service; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import net.sf.json.JSONArray; +import net.sf.json.JSONObject; import org.apache.commons.lang.StringUtils; import org.springframework.stereotype.Service; @@ -12,6 +15,11 @@ import com.forgon.disinfectsystem.entity.basedatamanager.operationNameManager.OperationName; import com.forgon.disinfectsystem.entity.basedatamanager.operationNameManager.OperationOrg; +import com.forgon.disinfectsystem.entity.basedatamanager.operationNameManager.OperationUseTousseItem; +import com.forgon.disinfectsystem.entity.washanddisinfectmanager.washanddisinfectrecord.WashAndDisinfectRecordMaterial; +import com.forgon.tools.GB2Alpha; +import com.forgon.tools.GB2WB; +import com.forgon.tools.db.DatabaseUtil; import com.forgon.tools.hibernate.ObjectDao; import com.forgon.treenode.ext.model.ExtTreeNode; @@ -67,7 +75,10 @@ @Transactional(readOnly = true, propagation = Propagation.REQUIRED) public OperationName getOperationNameById(String id) { - return (OperationName) objectDao.getByProperty(OperationName.class.getSimpleName(), "id", Long.parseLong(id)); + if(StringUtils.isNotBlank(id)){ + return (OperationName) objectDao.getByProperty(OperationName.class.getSimpleName(), "id", Long.parseLong(id)); + } + return null; } @Transactional(readOnly = true, propagation = Propagation.REQUIRED) @@ -83,7 +94,7 @@ @Transactional(readOnly = true, propagation = Propagation.REQUIRED) public boolean isExistByUnitCodingAndOperationName(String orgUnitCoding, - String operationName, String operationNamId) { + String operationName, String operationNameId) { String sql = "where 1=1"; if(StringUtils.isNotBlank(orgUnitCoding)){ sql += " and po.operationOrg.orgUnitCoding = '"+orgUnitCoding+"'"; @@ -92,8 +103,8 @@ sql += " and po.operationName='"+operationName+"'"; } - if(StringUtils.isNotBlank(operationNamId)){ - sql += " and po.id<>"+operationNamId+""; + if(StringUtils.isNotBlank(operationNameId)){ + sql += " and po.id<>"+operationNameId+""; } return objectDao.countObjectBySql(OperationName.class.getSimpleName(), sql) > 0; } @@ -136,4 +147,91 @@ return jsonArray.toString(); } + @Override + public void saveOperationName(String json) { + if(StringUtils.isNotBlank(json)){ + JSONObject data = JSONObject.fromObject(json); + String orgUnitCoding = data.optString("orgUnitCoding"); + String orgUnitName = data.optString("orgUnitName"); + String operationName = data.optString("operationName"); + String operationNameId = data.optString("operationNameId"); + if(StringUtils.isBlank(orgUnitCoding) || StringUtils.isBlank(orgUnitName)){ + throw new RuntimeException("手术名称所属科室不能为空!"); + } + OperationOrg ogrPo = getOperationOrgByCoding(orgUnitCoding); + if(ogrPo == null){ + throw new RuntimeException("手术名称所属科室已删除!"); + } + boolean isExistOperationName = isExistByUnitCodingAndOperationName(orgUnitCoding, operationName, operationNameId); + if(isExistOperationName){ + throw new RuntimeException(operationName + ",已存在!"); + } + + OperationName operationPo = getOperationNameById(operationNameId); + if(operationPo == null){ + operationPo = new OperationName(); + } + operationPo.setOperationName(operationName); + operationPo.setOperationOrg(ogrPo); + operationPo.setSpelling(GB2Alpha.string2Alpha(operationName)); + operationPo.setWbCode(GB2WB.getWBCode(operationName)); + + saveOrUpdate(operationPo); + + Map toDeleteMap = new HashMap(); + if(operationPo.getTousseItems() != null){ + for (OperationUseTousseItem item : operationPo.getTousseItems()) { + toDeleteMap.put(item.getId(), item); + } + } + String items = data.optString("items"); + if(StringUtils.isNotBlank(items)){ + JSONArray jsonArray = JSONArray.fromObject(items); + List useTosseItems = new ArrayList(); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonItem = jsonArray.optJSONObject(i); + Long itemId = jsonItem.optLong("itemId"); + Long tousseDefinitionId = jsonItem.optLong("tousseDefinitionId"); + if(!DatabaseUtil.isPoIdValid(tousseDefinitionId)){ + throw new RuntimeException("参数错误!"); + } + String name = jsonItem.optString("name"); + Integer amount = jsonItem.optInt("amount"); + if(amount <= 0){ + throw new RuntimeException(name + ",数量必须大于0!"); + } + OperationUseTousseItem useItem = null; + if(DatabaseUtil.isPoIdValid(itemId)){ + useItem = getOperationUseTousseItem(itemId); + toDeleteMap.remove(itemId); + }else{ + useItem = new OperationUseTousseItem(); + } + useItem.setAmount(amount); + useItem.setName(name); + useItem.setOperationNameId(operationPo.getId()); + useItem.setTousseDefinitionId(tousseDefinitionId); + useTosseItems.add(useItem); + } + operationPo.setTousseItems(useTosseItems); + saveOrUpdate(operationPo); + } + + if(toDeleteMap.size() > 0){ + for (Long itemId : toDeleteMap.keySet()) { + OperationUseTousseItem item = toDeleteMap.get(itemId); + objectDao.delete(item); + } + } + + } + } + + private OperationUseTousseItem getOperationUseTousseItem(Long itemId){ + if(itemId != null){ + return (OperationUseTousseItem)objectDao.getByProperty(OperationUseTousseItem.class.getSimpleName(), "id", itemId); + } + return null; + } + } Index: ssts-web/src/main/webapp/systemmanage/operationNameView.jsp =================================================================== diff -u -r12331 -r15387 --- ssts-web/src/main/webapp/systemmanage/operationNameView.jsp (.../operationNameView.jsp) (revision 12331) +++ ssts-web/src/main/webapp/systemmanage/operationNameView.jsp (.../operationNameView.jsp) (revision 15387) @@ -12,6 +12,7 @@ + <%@ include file="/common/includeExtJsAndCss.jsp"%> Index: ssts-web/src/main/webapp/systemmanage/operationNameView.js =================================================================== diff -u -r12331 -r15387 --- ssts-web/src/main/webapp/systemmanage/operationNameView.js (.../operationNameView.js) (revision 12331) +++ ssts-web/src/main/webapp/systemmanage/operationNameView.js (.../operationNameView.js) (revision 15387) @@ -1,18 +1,6 @@ -//********* 按钮响应函数 *********** -var currentClickType = '';//删除标识字符 -function setClickType(v){ - currentClickType=v; -} -function isClickDel(){ - return (currentClickType=='del'?true:false); -} -function replaceStr(str){ - var replaceV = ""; - if(str){ - replaceV = str.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,"\""); - } - return replaceV; -} +var useTousseStore; +var tousseAndDiposableGoodsStore; +var formWindow; function submitForm(form,window,callMethodAction,callBack){ form.form.submit({ url : WWWROOT + '/disinfectsystem/basedatamanager/operationOrgAction!'+callMethodAction+'.do', @@ -29,335 +17,355 @@ return true; } -function deleteGiveBackColumnTreeItem(clickNode){ - if(clickNode.leaf) { - clickNode.remove(); - } else { - var pNode = clickNode.parentNode; - clickNode.remove(); +var goodsRecord = Ext.data.Record.create([ + {name : 'itemId'}, + {name : 'tousseDefinitionId'}, + {name : 'name'}, + {name : 'amount'} +]); + +function addUseTousseItem(){ + var goodsName = top.Ext.getCmp('goodsSearch').getValue(); + var amount = top.Ext.getCmp('amount').getValue(); + if(goodsName == ""){ + showResult("请选择物品!"); + return ; } -} -function subOrgName(orgunitName){ - var index; - if(orgunitName && (index=orgunitName.lastIndexOf(NODE_PATH_SEPARATOR))!=-1){ - orgunitName = orgunitName.substr(index+1); + if(amount == ""){ + showResult("请输入数量!"); + return ; } - return orgunitName; -} -function getItemTreeDataForOperationOrg(dataTree){ - var rootNode = dataTree.getRootNode(); - var valArr = new Array(); - rootNode.eachChild(function(pNode){ - valArr.push("{id:'"); - valArr.push("'"); - valArr.push(",orgUnitName:'"); - valArr.push(replaceStr(pNode.attributes.text)); - valArr.push("'"); - valArr.push(",orgUnitCoding:'"); - valArr.push(replaceStr(pNode.attributes.keyId)); - valArr.push("'"); - valArr.push("}"); - - if(!pNode.isLast()){ - valArr.push(","); - } - }); - return valArr.join(""); -} -function getItemTreeDataForOperationName(dataTree){ - var rootNode = dataTree.getRootNode(); - var valArr = new Array(); - rootNode.eachChild(function(pNode){ - valArr.push("{id:'"); - valArr.push("'"); - valArr.push(",operationName:'"); - valArr.push(replaceStr(pNode.attributes.text)); - valArr.push("'"); - valArr.push("}"); - if(!pNode.isLast()){ - valArr.push(","); - } - }); - return valArr.join(""); -} -/** - * 创建节点 - */ -function createChildNode(keyId,text){ - //创建子节点 - var node = new top.Ext.tree.TreeNode({ - id:Ext.id(), - //text:'', - iconCls:'task', - uiProvider:top.Ext.tree.ColumnNodeUI, - leaf:true, - expanded:true - }); - //********************** 节点保存的属性值 ****************************// - node.attributes.keyId=keyId; - node.attributes.text=text; - return node; -} - -function addItem(dataTree, isOrgUnitWin){ - var rootNode = dataTree.getRootNode(); var isExist = false; - var templateVal = top.Ext.getCmp("templateName").getValue(); - if(templateVal == '') { - showResult("录入的"+(isOrgUnitWin?"科室":"手术")+"名称不能为空!"); - return false; - } - rootNode.eachChild(function(pNode){ - if(pNode.attributes.keyId == templateVal) { - //showResult("该科室信息已经存在当前列表中!"); + var count = useTousseStore.getCount(); + for(var i = 0 ; i < count ; i++){ + var record = useTousseStore.getAt(i); + if(record.get("name") == goodsName){ isExist = true; + break; } - }); - if(isExist) { - return; } - - var templateName = top.Ext.getCmp("templateName").getRawValue(); - if(isOrgUnitWin){ - templateName = subOrgName(templateName); + if(!isExist){ + var index = tousseAndDiposableGoodsStore.find("name",goodsName); + var id = tousseAndDiposableGoodsStore.getAt(index).data['id']; + var record = new goodsRecord({ + itemId : "", + tousseDefinitionId : id, + name : goodsName, + amount : amount + }); + useTousseStore.add(record); + top.Ext.getCmp('goodsSearch').setValue(); + top.Ext.getCmp('amount').setValue(); + top.Ext.getCmp('goodsSearch').focus(); + }else{ + showResult(goodsName + ",已添加!"); } - - var childNode = createChildNode(templateVal,templateName); - rootNode.appendChild(childNode); } -//添加科室 -function openTreePanalWin(isOrgUnitWin){ - var textName = isOrgUnitWin?'科室名称':'手术名称'; - var dataTree = new top.Ext.tree.ColumnTree({ - rootVisible:false, - autoScroll:true, - bodyStyle : 'border:1px solid #afd7af', - containerScroll : true, -// height:220, - columns:[{ - header:textName, - width:380, - dataIndex:'text' - },{ - header:'科室编码', - width:320, - dataIndex:'keyId', - hidden:true - },{ - header:'删除', - width:40, - dataIndex:'del', - renderer:function(v,p,record){ - return "\"删除\""; - } - }], +function deleteGoodsItem(rowIndex){ + if(rowIndex != null){ + var record = useTousseStore.getAt(rowIndex); + if(record){ + useTousseStore.remove(record); + } + } +} - loader: new top.Ext.tree.TreeLoader({ - uiProviders:{ - 'col': top.Ext.tree.ColumnNodeUI - } - }), +function setOperationUseTousse(id){ + var rd = new Ext.data.JsonReader({ + fields : [{ + id : 'itemId', + tousseDefinitionId : 'tousseDefinitionId', + name : 'name', + amount : 'amount' + }] + }); + useTousseStore = new top.Ext.data.Store({ + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/jasperreports/jasperreportsAction!getGoodsOption.do', + method : 'POST' + }), + baseParams : {id : id}, + reader : rd + }); + useTousseStore.load(); + + var cm = new top.Ext.grid.ColumnModel([new top.Ext.grid.RowNumberer({header:"序号",width:40}),{ + id:'id', + name:'id', + hidden :true, + dataIndex : 'id' + },{ + id : 'name', + header : "物品名称", + width:240, + dataIndex : 'name' + },{ + id : 'amount', + header : "数量", + width:100, + dataIndex : 'amount' + },{ + id : 'deleteItem', + header:'删除', + width :80, + menuDisabled: true, + dataIndex:'button', + renderer: function(v,p,record,rowIndex){ + return ""; + } + }]); - root: new top.Ext.tree.AsyncTreeNode({ - text:'名称' - }) - }); - - var btArr = new Array(); - btArr.push({text:textName+':'},{ - id:'treeItemData', - name:'treeItemData', - xtype:'hidden' - }); + var searchUrl = WWWROOT + '/disinfectSystem/baseData/tousseDefinitionAction!searchComboTousseData.do'; + + tousseAndDiposableGoodsStore = new Ext.data.Store({ + proxy : new Ext.data.HttpProxy({ + url : searchUrl, + method : 'POST' + }), + reader : new Ext.data.JsonReader({ + totalProperty : 'totalCount', + root : 'data' + }, [ + {name : 'id',mapping : 'id'}, + {name : 'spelling',mapping : 'spelling'}, + {name : 'name',mapping : 'name'}, + {name : 'displayName',mapping : 'displayName'}, + {name : 'amount',mapping : 'amount'}] + ) + }); - if(!isOrgUnitWin){ - var treeEditer = new top.Ext.tree.ColumnTreeEditor(dataTree, { - completeOnEnter : true, - autosize : true, - allowBlank: false, - // cancelOnEsc : true, - revertInvalid:true, - ignoreNoChange : true - }); - - treeEditer.on("beforestartedit", function(thiz,el,v){ - var tempNode = thiz.editNode;//将要编辑的节点 - if(tempNode.attributes.text==v ){ - return true; - }else { - return false; - } - }); - - btArr.push({ - xtype : 'textfield', - id : 'templateName', - name : 'templateName', - minChars : 0, - width : 320, - anchor : '97%', - listeners:{ - specialkey : function(field, ee) { - if (ee.getKey() == Ext.EventObject.ENTER) { - addItem(dataTree, isOrgUnitWin); - top.Ext.getCmp('templateName').setValue(""); - } - } + var tbar = [ { + text : '选择物品' + },{ + xtype : 'combo', + id : 'goodsSearch', + name : 'goodsSearch', + queryParam : 'spell', + fieldLabel : '物品名称', + minChars : 0, + valueField : 'id', + displayField : 'displayName', + anchor : '100%', + width:300, + store : tousseAndDiposableGoodsStore, + lazyInit : true, + triggerAction : 'all', + hideTrigger : true, + typeAhead : false, + allowBlank : true, + listeners : { + select : function(combo, record, index) { + top.Ext.getCmp('goodsSearch').setValue(record.data.name); + }, + specialkey : function(field, e) { + if (e.getKey() == Ext.EventObject.ENTER) { + top.Ext.getCmp('amount').focus(); } - }); - }else{ - var departJsonStore = new Ext.data.Store({ - proxy : new Ext.data.HttpProxy({ - url : WWWROOT + '/disinfectSystem/baseData/supplyRoomConfigAction!getAllOrgUnitName.do', - method : 'POST' - }), - reader : new Ext.data.JsonReader({ - root : 'data' - },[ - {name : 'id',mapping : 'id'}, - {name : 'name',mapping : 'name'} - ] - ) - }); - - btArr.push({ - xtype : 'combo', - id : 'templateName', - name : 'templateName', - queryParam : 'spell', - minChars : 0, - valueField : 'id', - displayField : 'name', - store : departJsonStore, - forceSelection : true, - lazyInit : true, - triggerAction : 'all', - hideTrigger : true, - typeAhead : false, - allowBlank : true, - width : 320, - anchor : '97%', - listeners:{ - specialkey : function(field, ee) { - if (ee.getKey() == Ext.EventObject.ENTER) { - addItem(dataTree, isOrgUnitWin); - top.Ext.getCmp('templateName').setValue(""); - } - } + } + } + },{ + text : '数量' + },{ + xtype : 'textfield', + id : 'amount', + name : 'amount', + allowBlank:true, + width : 80, + regex: /^\d+$/, + regexText:'只能输入数字', + anchor : '95%', + tabIndex : 2, + listeners : { + specialkey : function(field, e) { + if (e.getKey() == Ext.EventObject.ENTER) { + addUseTousseItem(); } - }); - } - btArr.push({ - text : '添加', - id:'addButton', - iconCls : 'btn_ext_add', - handler : function() { - addItem(dataTree, isOrgUnitWin); - top.Ext.getCmp('templateName').setValue(""); - } - }); - - var form = new top.Ext.FormPanel({ - id : 'operationForm', + } + } + },{ + text : '添加', + handler:function(){ + addUseTousseItem(); + } + }]; + + formObj = new top.Ext.FormPanel({ + id : 'deviceMaintenanceForm', frame : true, - border : 0, - labelSeparator : ':', - bodyStyle : 'padding:5px 5px 0px 5px', - width : 390, labelAlign:'right', + labelWidth:60, + labelSeparator : ':', + bodyStyle : 'padding:0px 0px 0px 0px', + autoWidth : true, autoHeight : true, - items : [{ - xtype:'hidden', - id:'orgCoding', - name:'orgCoding' - },{ - xtype:"fieldset", - autoScroll:true, - height:335, - tbar:btArr, - items:[ - dataTree - ] + autoScroll : true, + items:[{ + layout : 'column', + items : [ + { + xtype:'hidden', + id:'currentSelectOrgUnitCoding', + name:'currentSelectOrgUnitCoding' + },{ + xtype : 'hidden', + name : 'id', + id : 'id' + },{ + columnWidth : 1, + layout : 'form', + items : [{ + layout : 'form', + items : [{ + xtype:'textfield', + fieldLabel: '手术名称', + width : 298, + id: 'operationNameStr', + name: 'operationNameStr', + allowBlank: false + }] + }] + },{ + columnWidth : 1, + layout: 'form', + items : [ + new top.Ext.grid.GridPanel({ + id : 'configGrid', + store : useTousseStore, + tbar : tbar, + cm : cm, + width : 350, + height: 350, + isCheckboxSelectionModel : true, + frame : false, + viewConfig: { + forceFit:true + }, + bodyStyle : 'border:1px solid #afd7af', + anchor : '100%', + selModel : new top.Ext.grid.RowSelectionModel({ + singleSelect : false + }) + }) + ] + }] }], - buttonAlign :'center', - buttons : [{ + buttons : [{ + id : 'saveBtn', text : '保存', - id :'saveBtn', handler : function(){ - //获取columnTreePanel数据 - var treeData = ""; - var actionMethodName = ""; - if(isOrgUnitWin){ - actionMethodName = "saveOperationOrg"; - treeData = getItemTreeDataForOperationOrg(dataTree); - }else{ - actionMethodName = "saveOperationName"; - treeData = getItemTreeDataForOperationName(dataTree); - top.Ext.getCmp("orgCoding").setValue(currentClickNode.attributes.keyId); - } - if(treeData==""){ - showResult(textName+'列表不能为空!'); + var tempVal = top.Ext.getCmp("operationNameStr").getValue(); + if(tempVal == ""){ + showResult("手术名称不能为空!"); return false; } - top.Ext.getCmp("treeItemData").setValue("["+treeData+"]"); + var count = useTousseStore.getCount(); + var items = new Array(); + var count = useTousseStore.getCount(); + for(var i = 0 ; i < count ; i++){ + var record = useTousseStore.getAt(i); + items.push({ + itemId : record.get("itemId"), + tousseDefinitionId : record.get("tousseDefinitionId"), + name : record.get("name"), + amount : record.get("amount") + }); + } - var b = this; - top.Ext.MessageBox.confirm("请确认","是否提交"+textName+"信息?",function(btn) { - if(btn=='yes') { - b.disable(); - submitForm(form,window,actionMethodName,function(window, action){ - if(isOrgUnitWin){ - root.reload(); - }else{ - reloadGrid(); - } - if(action.result.saveSuccess){ - showResult("保存成功!"); - window.close(); - }else{ - showResult(textName+"【"+action.result.nameIsExist+"】已存在!"); - b.enable(); - } - }); + var data = { + orgUnitCoding : currentClickNode.attributes.keyId, + orgUnitName : currentClickNode.attributes.text, + operationName : tempVal, + operationNameId : id, + items : items + }; + + formObj.form.submit({ + url : WWWROOT + '/disinfectsystem/basedatamanager/operationOrgAction!saveOperationName.do', + method : 'POST', + waitMsg : '正在保存数据,请稍候', + waitTitle : '提交表单', + params : {data : JSON.stringify(data)}, + success : function(form, action) { + var success = action.result.success; + if(success){ + reloadGrid(); + showResult(action.result.message); + formWindow.close(); + }else{ + showResult(action.result.message); + } + }, + failure : function(form, action) { + showResult(action.result.msg); } }); } },{ + id : 'cancleBtn', text : '取消', handler : function() { - window.close(); + formWindow.close(); } }] }); - - var window = new top.Ext.Window( { - id : 'orgunitForOperationApplicationWin', - layout : 'border', - title : '批量录入'+textName+'信息', - width : 510, - height : 425, + + formWindow = new top.Ext.Window( { + id : 'deviceMaintenanceWin', + layout : 'fit', + title : '手术名称信息', + width : 670, + modal : true, + autoHeight : true, border : false, plain : true, - modal :true, - items : [{ - region:'center', - width : 200, - layout :'fit', - items:[form] - }] + items : [formObj] }); + formWindow.show(); - dataTree.on("beforeclick",function(clickNode){ - if(isClickDel()){//删除 - deleteGiveBackColumnTreeItem(clickNode); - } - setClickType(''); - }); - window.show(); + if(id != ""){ + Ext.Ajax.request({ + url:WWWROOT+"/disinfectsystem/basedatamanager/operationOrgAction!loadOperationName.do", + params:{id : id}, + success:function(result){ + if(result != null){ + var operationNameJson = JSON.parse(result.responseText); + top.Ext.getCmp("operationNameStr").setValue(operationNameJson.operationName); + var tousseItems = operationNameJson.tousseItems; + for(var i = 0 ;i < tousseItems.length ; i++){ + var record = new goodsRecord({ + itemId : tousseItems[i].itemId, + tousseDefinitionId : tousseItems[i].tousseDefinitionId, + name : tousseItems[i].name, + amount : tousseItems[i].amount + }); + useTousseStore.add(record); + } + } + }, + failure:function(){ + showResult("加载失败,请联系管理员!"); + } + }); + } } -function showWin(id, tempOperationNameForEdit){ +function addOperationOrg(){ + + var departJsonStore = new Ext.data.Store({ + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectSystem/baseData/supplyRoomConfigAction!getAllOrgUnitName.do', + method : 'POST' + }), + reader : new Ext.data.JsonReader({ + root : 'data' + },[ + {name : 'id',mapping : 'id'}, + {name : 'name',mapping : 'name'} + ] + ) + }); + var form = new top.Ext.form.FormPanel({ id : 'operationNameWinForm', frame : true, @@ -369,41 +377,53 @@ autoHeight : true, labelWidth: 75, items: [{ - xtype:'hidden', - id:'currentSelectOrgUnitCoding', - name:'currentSelectOrgUnitCoding' - },{ - xtype:'hidden', - id:'operationNameId', - name:'operationNameId', - value:id - },{ - xtype:'textfield', - fieldLabel: '手术名称', - width : 250, - id: 'operationNameStr', - name: 'operationNameStr', - value:tempOperationNameForEdit, - allowBlank: false - }], + xtype : 'combo', + id : 'templateName', + name : 'templateName', + queryParam : 'spell', + minChars : 0, + fieldLabel: '科室名称', + valueField : 'id', + displayField : 'name', + store : departJsonStore, + forceSelection : true, + lazyInit : true, + triggerAction : 'all', + hideTrigger : true, + typeAhead : false, + allowBlank : true, + width : 320, + anchor : '97%' + }], buttonAlign :'center', buttons : [{ text : '保存', id :'saveBtn', handler : function(){ - var tempVal = top.Ext.getCmp("operationNameStr").getValue(); - if(tempVal==""){ - showResult("手术名称不能为空!"); + var orgUnitCoding = top.Ext.getCmp("templateName").getValue(); + var orgUnitName = top.Ext.getCmp("templateName").getRawValue(); + if(orgUnitName == ""){ + showResult("科室名称不能为空!"); return false; } - top.Ext.getCmp("currentSelectOrgUnitCoding").setValue(currentClickNode.attributes.keyId); - submitForm(form,window,"updateOperationName",function(window, action){ - reloadGrid(); - if(action.result.saveSuccess){ - showResult("修改成功!"); - window.close(); - }else{ - showResult("修改失败,手术名称【"+action.result.nameIsExist+"】已存在!"); + form.form.submit({ + url : WWWROOT + '/disinfectsystem/basedatamanager/operationOrgAction!saveOperationOrg.do', + method : 'POST', + waitMsg : '正在保存数据,请稍候', + waitTitle : '提交表单', + params : {orgUnitCoding : orgUnitCoding , orgUnitName : orgUnitName}, + success : function(form, action) { + var success = action.result.success; + if(success){ + root.reload(); + showResult(action.result.message); + window.close(); + }else{ + showResult(action.result.message); + } + }, + failure : function(form, action) { + showResult(action.result.msg); } }); } @@ -417,7 +437,7 @@ var window = new top.Ext.Window( { id : 'operationNameWindow', layout : 'border', - title : '手术名称修改', + title : '添加录入科室', width : 410, height : 100, border : false, @@ -565,7 +585,8 @@ //********* 2、ForgonGrid *********** function gotoPage(v, p, record){ ///userForm.mhtml - return "" + v + ""; + var id = record.get("id"); + return "" + v + ""; } @@ -597,7 +618,7 @@ tooltip:'录入科室', iconCls:'btn_ext_add', hidden :false, - handler:function(){openTreePanalWin(true);} + handler:function(){addOperationOrg();} }, '-',{ text:'添加'+entityName, tooltip:'添加'+entityName, @@ -608,15 +629,9 @@ showResult("请先在左边视图选中需要添加手术名称所在的科室!"); return false; } - openTreePanalWin(false); + setOperationUseTousse(""); } }, '-', { - text:'修改'+entityName, - tooltip:'修改'+entityName, - iconCls:'btn_ext_refresh', - hidden :false, - handler:function (){editOperationName();} - }, '-', { text:'删除'+entityName, tooltip:'删除选择'+entityName, iconCls:'btn_remove',