Index: ssts-web/src/main/webapp/disinfectsystem/returnGoodsRecord/returnTousseByInvoicePlan.jsp =================================================================== diff -u --- ssts-web/src/main/webapp/disinfectsystem/returnGoodsRecord/returnTousseByInvoicePlan.jsp (revision 0) +++ ssts-web/src/main/webapp/disinfectsystem/returnGoodsRecord/returnTousseByInvoicePlan.jsp (revision 17711) @@ -0,0 +1,108 @@ +<%@ page contentType="text/html; charset=UTF-8"%> +<%@ include file="/common/taglibs.jsp"%> +<%@ page import="com.forgon.directory.vo.LoginUserData,com.forgon.tools.SpringBeanManger,com.forgon.disinfectsystem.entity.returngoodsrecord.ReturnGoodsRecord,java.util.Date,com.forgon.disinfectsystem.basedatamanager.supplyroomconfig.service.SupplyRoomConfigManager" %> +<% + LoginUserData userData = AcegiHelper.getLoginUser(); + String userName = userData.getUserFullName(); + request.setAttribute("userName",userName); + + Integer fontSize = userData.getFontSize(); + if (fontSize == null){ + fontSize = 12; + } + request.setAttribute("fontSize", fontSize); + + String currentOrgUnitName = userData.getCurrentOrgUnitName(); + String currentOrgUnitCode = userData.getCurrentOrgUnitCode(); + + if(currentOrgUnitName!=null && currentOrgUnitCode!=null){ + request.setAttribute("depart",currentOrgUnitName); + request.setAttribute("departCoding",currentOrgUnitCode); + } + + SupplyRoomConfigManager supplyRoomConfigManager = (SupplyRoomConfigManager)SpringBeanManger.getBean("supplyRoomConfigManager"); + String orgUnitCoding = userData.getOrgUnitCodingFromSupplyRoomConfig(); + int supplyRoomType = supplyRoomConfigManager.getSupplyRoomTypeByOrgUnitCoding(orgUnitCoding); + request.setAttribute("supplyRoomType", supplyRoomType); +%> + + + +<%@ include file="/common/includeExtJsAndCss.jsp"%> + + + + + + + + + + + + + + + + + + + + + + + + + +退货记录 + + + + + + + + +
+ + + + + +
+ + + + + +
+
+
+ + \ No newline at end of file Index: ssts-web/src/main/webapp/disinfectsystem/returnGoodsRecord/returnDisposableGoodsByInvoicePlan.jsp =================================================================== diff -u --- ssts-web/src/main/webapp/disinfectsystem/returnGoodsRecord/returnDisposableGoodsByInvoicePlan.jsp (revision 0) +++ ssts-web/src/main/webapp/disinfectsystem/returnGoodsRecord/returnDisposableGoodsByInvoicePlan.jsp (revision 17711) @@ -0,0 +1,108 @@ +<%@ page contentType="text/html; charset=UTF-8"%> +<%@ include file="/common/taglibs.jsp"%> +<%@ page import="com.forgon.directory.vo.LoginUserData,com.forgon.tools.SpringBeanManger,com.forgon.disinfectsystem.entity.returngoodsrecord.ReturnGoodsRecord,java.util.Date,com.forgon.disinfectsystem.basedatamanager.supplyroomconfig.service.SupplyRoomConfigManager" %> +<% + LoginUserData userData = AcegiHelper.getLoginUser(); + String userName = userData.getUserFullName(); + request.setAttribute("userName",userName); + + Integer fontSize = userData.getFontSize(); + if (fontSize == null){ + fontSize = 12; + } + request.setAttribute("fontSize", fontSize); + + String currentOrgUnitName = userData.getCurrentOrgUnitName(); + String currentOrgUnitCode = userData.getCurrentOrgUnitCode(); + + if(currentOrgUnitName!=null && currentOrgUnitCode!=null){ + request.setAttribute("depart",currentOrgUnitName); + request.setAttribute("departCoding",currentOrgUnitCode); + } + + SupplyRoomConfigManager supplyRoomConfigManager = (SupplyRoomConfigManager)SpringBeanManger.getBean("supplyRoomConfigManager"); + String orgUnitCoding = userData.getOrgUnitCodingFromSupplyRoomConfig(); + int supplyRoomType = supplyRoomConfigManager.getSupplyRoomTypeByOrgUnitCoding(orgUnitCoding); + request.setAttribute("supplyRoomType", supplyRoomType); +%> + + + +<%@ include file="/common/includeExtJsAndCss.jsp"%> + + + + + + + + + + + + + + + + + + + + + + + + + +退货记录 + + + + + + + + +
+ + + + + +
+ + + + + +
+
+
+ + \ No newline at end of file Index: ssts-web/src/main/webapp/disinfectsystem/returnGoodsRecord/returnTousseByInvoicePlan.js =================================================================== diff -u --- ssts-web/src/main/webapp/disinfectsystem/returnGoodsRecord/returnTousseByInvoicePlan.js (revision 0) +++ ssts-web/src/main/webapp/disinfectsystem/returnGoodsRecord/returnTousseByInvoicePlan.js (revision 17711) @@ -0,0 +1,2173 @@ +var entityName = "退货记录"; +var grid; + +var returnGoodsItemStore = null; +var returnTousseItemStore = null; +var isClickDel = false; +var form = null; +var editableConfig = {editable:false}; + +var returnGoodsItemStore = null; +var returnTousseItemStore = null; +var isClickDel = false; +var form = null; +var editableConfig = {editable:false}; +var curDiposableGood = null;// 当前扫描的一次性物品 +var curBatch = null; +var haveScannedDiposableGoods = false;// 已扫描过一次性物品条码 +var loadDiposableGoodsByBarcode = false; + + +var wareHouseStore = new Ext.data.Store({ + reader : new Ext.data.JsonReader({ + fields : [ + {name : 'id',mapping : 'id'}, + {name : 'name',mapping : 'name'}, + {name : 'orgUnitCode',mapping : 'orgUnitCode'} + ] + }), + listeners : { + load : function(store,records) { + var id = top.Ext.getCmp('warehouseID').getValue(); + var name = top.Ext.getCmp('warehouseName').getValue(); + if(records.length > 0 && (id == null || id == '')){ + id=records[0].data.id; + name = records[0].data.name; + } + top.Ext.getCmp('warehouse').setValue(id); + top.Ext.getCmp('warehouseID').setValue(id); + top.Ext.getCmp('warehouseName').setValue(name); + } + } +}); +var wareHouseFields = [ + {name : 'id'}, + {name : 'name'}, + {name : 'orgUnitCode'} + ]; +var WareHouseRecord = Ext.data.Record.create(wareHouseFields); +function removeGridItem(){ + var totalMoney = 0.0; + var rows = top.Ext.getCmp('returnGoodsItemGrid').getSelectionModel().getSelections();// 返回值为 + if (rows) { + for ( var i = 0; i < rows.length; i++) { + returnGoodsItemStore.remove(rows[i]); +// totalMoney = top.Ext.getCmp("totalMoney").getValue(); +// top.Ext.getCmp("totalMoney").setValue(accSubtr(totalMoney,accMul(rows[i].data.price,rows[i].data.amount))); + } + } + setTotalMoney(); +} + +var addReturnGoodsItem = Ext.data.Record.create([ + {name : 'id'}, + {name : 'tousseName'}, + {name : 'unit'}, + {name : 'batchID'}, + {name : 'disposableGoodsID'}, + {name : 'disposableGoodsStockID'}, + {name : 'disposableGoodsBatchID'}, + {name : 'disposableGoodsBatchStockID'}, + {name : 'identificationID'}, + {name : 'expensiveDisposablegoodsId'}, + {name : 'amount'}, + {name : 'amountCanReturn'}, + {name : 'barcode'}, + {name : 'batchNumber'}, + {name : 'isDelivery'}, + {name : 'price'}, + {name : 'fluctuationPrice'}, + {name : 'expDate'} +]); +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 diposableGoodsBatchNumStore = null; +var BatchRecord = null; +//单价数据源 +var priceStore = null; +var PriceRecord = null; + +//校验退货人科室是否有问题 +function isDepartValid(r){ + var v = true; + var departs = []; + var rootNode = top.Ext.getCmp('returnGoodsColumnTree').getRootNode(); + + rootNode.eachChild(function(tousseNode) { + // 有且只有二层节点(不包括根节点rootNode) + tousseNode.eachChild(function(tousseInstanceNode) { + var depart = tousseInstanceNode.attributes.settleAccountsDepartCode; + if(isUndefinedOrNullOrEmpty(depart)){ + depart = tousseInstanceNode.attributes.location; + } + //alert('depart='+depart); + departs.push(depart); +// if(typeof(departs[depart]) == 'undefined'){ +// ++departs.departCount; +// departs[depart] = depart; +// itemDepart = depart; +// }else{ +// +// } + + // 包实例节点 +// if (tousseInstanceNode.attributes.barcode != '') { +// exist = true; +// } + }); + }); + if(departs.length == 0){ + return true; + }else{ + var firstDepart = departs[0]; + for(var d=1;d 0){ + top.Ext.getCmp("batchNumber").setValue(batches[0].batchNumber); + curBatch = batches[0]; + // 出发选中事件 + if(fireSelect){ + combo.fireEvent('select', combo,diposableGoodsBatchNumStore.getAt(0),0); + } + } +} +// 设置价格 +function setPrices(prices) { + priceStore.removeAll(); + top.Ext.getCmp("combo_price").setValue(''); + if(typeof(prices) == 'undefined' || prices == null){ + return; + } + for(var i = 0;i 0){ + top.Ext.getCmp("combo_price").setValue(prices[0].fluctuationPrice); + } +} +//验证条码是否重复扫描 +function isBarcodeRepeat(barcode){ + if(barcode != null && barcode.length > 0){ + for ( var i = 0; i < returnGoodsItemStore.getCount(); i++) { + var record = returnGoodsItemStore.getAt(i); + var tempBarcode =record.get('barcode'); + if(barcode == tempBarcode){ + return true; + break; + } + } + } + return false; +} +//验证一次性物品是否重复 +function isDiposableGoodsRepeat(diposableGood,batch,priceAmount){ + for ( var i = 0; i < returnGoodsItemStore.getCount(); i++) { + var record = returnGoodsItemStore.getAt(i); + var price = record.get('price'); + var fluctuationPrice = record.get('fluctuationPrice'); + var barcode = record.get('barcode'); + + //alert('price='+price+',barcode='+barcode+',newprice='+priceAmount.price+',newbarcode='+batch.barcode); + if(barcode == batch.barcode && fluctuationPrice == priceAmount.fluctuationPrice){ + return true; + break; + } + } + return false; +} +//验证一次性物品是否重复 +function isExpensiveDisposablegoodsRepeat(diposableGood){ + for ( var i = 0; i < returnGoodsItemStore.getCount(); i++) { + var record = returnGoodsItemStore.getAt(i); + var price = record.get('price'); + var fluctuationPrice = record.get('fluctuationPrice'); + var barcode = record.get('barcode'); + + if(barcode == diposableGood.barcode){ + return true; + break; + } + } + return false; +} + +// 添加一次性物品 +function onAddDiposableGoodsClick(){ + // 判断批次和价格是否已选择 + var batchNumber = top.Ext.getCmp("batchNumber").getValue(); + var fluctuationPrice = top.Ext.getCmp("combo_price").getValue(); + if(batchNumber == ''){ + showResult('请选择批次!'); + return false; + } + if(fluctuationPrice+'' == ''){ + showResult('请选择价格!'); + return false; + } + var priceAmount = null; + var index = priceStore.find('fluctuationPrice', fluctuationPrice); + if(index == -1){ + showResult('请选择价格!'); + return false; + } + priceAmount = priceStore.getAt(index).data; + addDiposableGoodsItems(curDiposableGood,curBatch,priceAmount); + //top.Ext.getCmp("count1").getValue()); + +} +// +function addAndEditReturnDisposableGoodsByInvoicePlan(invoicePlanId){ + addAndEditReturnGoodsRecord('',true); +} +function addAndEditReturnTousseRecord(id, enableBtn) { + editableConfig.editable = enableBtn; + //普通器械包 + var tousseStore = returnTousseItemStore = new Ext.data.Store({ + pageSize: 100, + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectSystem/baseData/tousseDefinitionAction!searchComboTousseDataForReturnGoods.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 : 'displayName',mapping : 'displayName'}, + {name : 'amount',mapping : 'amount'}] + ) + }); + + //退货器械包列表 columns + var columnsArr = new Array({ + id : 'tousseName', + header : '名称', + width : 200, + dataIndex : 'tousseName' + }, { + header : '单价', + width : 50, + dataIndex : 'price' + }, { + header : '数量', + width : 50, + dataIndex : 'amount' + }, { + header : '条码', + width : 80, + dataIndex : 'barcode' + }, { + header : '是否重发', + width : 70, + dataIndex : 'isDelivery', + renderer: function(v,p,record){ + var str = v; + if(!record.recordId){ + var id = record.id; + var yesChecked = " "; + var noChecked = " checked='true' "; + + if(record.isDelivery == '是'){ + yesChecked = " checked='true' "; + noChecked = " "; + } + if (record.isDelivery == '是' || record.isDelivery == '否'){ + str = "是 否"; + } + } + return str; + } + }, { + header : '是否重装', + width : 70, + dataIndex : 'isPacking', + renderer: function(v,p,record){ + var str = v; + if(!record.recordId){ + var id = record.id; + if(record.isPacking == '否'){ + str = "是 否"; + }else if(record.isPacking == '是'){ + str = "是 否"; + } + } + return str; + } + }, { + header : '操作', + width : 70, + dataIndex : 'button', + renderer: function(v,p,record){ + var str = ''; + if(editableConfig.editable){ + str = "";//isClickDel=true + } + return str; + } + }); + + var returnGoodsColumnTree = new top.Ext.tree.ColumnTree({ + id : 'returnGoodsColumnTree', + height : 270, + rootVisible : false, + autoExpandColumn : 'tousseName', + autoScroll : true, + containerScroll : true, + columns : columnsArr, + bodyStyle : 'border:1px solid #afd7af', + loader : new top.Ext.tree.TreeLoader({ + url : WWWROOT + + '/disinfectSystem/returnGoodsRecordAction!loadReturnedTousseItems.do', + baseParams : { + id : id + }, + uiProviders : { + 'col' : top.Ext.tree.ColumnNodeUI + } + }), + root : new top.Ext.tree.AsyncTreeNode({ + text : '器械包' + }), + tbar : new top.Ext.Panel({ + border: false, + items:[{ + xtype: 'toolbar', + items: [{ + text : '扫描条码 :' + },{ + xtype : 'textfield', + id : 'barcode', + name : 'barcode', + width :200, + enableKeyEvents : true, + disabled:!enableBtn, + listeners : { + render : function(c) { + c.getEl().on('keypress',function(e) { + if (e.getKey() == 13) {// 输入;号键,grid重新加载 + loadReturnGoodsItem(true); + } + }); + } + } + }] + }, { + xtype: 'toolbar', + items: [{ + text : '物品名称 :' + },{ + xtype : 'combo', + id : 'package1', + name : 'package1', + queryParam : 'spell', + minChars : 0, + valueField : 'id', + displayField : 'name', + width : 350, + store : tousseStore, + pageSize : 100, + listConfig: {width: 300}, + forceSelection : true, + disabled:!enableBtn, + lazyInit : true, + triggerAction : 'all', + hideTrigger : true, + emptyText : '器械包的拼音、五笔码或者名称', + typeAhead : false, + allowBlank : true, + anchor : '97%', + listeners : { + select : function(combo, record, index) { + top.Ext.getCmp('package1').setValue(record.data.name); + }, + specialkey : function(field, ee) { + if (ee.getKey() == Ext.EventObject.ENTER) { + top.Ext.getCmp('count1').focus(); + } + } + } + },{ + text : '数量 :' + },{ + xtype : 'numberfield', + id : 'count1', + name : 'count1', + style : 'text-align: left', + anchor : '95%', + width : 50, + disabled:!enableBtn, + allowNegative : false, + allowDecimals : false, + listeners : { + specialkey : function(field, ee) { + if (ee.getKey() == Ext.EventObject.ENTER) { + var tousseName = top.Ext.getCmp("package1").getValue(); + var toussePrice = 0.00; + DWREngine.setAsync(false); + ReturnGoodsRecordTableManager.getToussePrice(tousseName,function(price){ + if(price != null){ + toussePrice = price; + } + }); + DWREngine.setAsync(true); + if(addReturnTousseItemToTree('',tousseName,top.Ext.getCmp("count1").getValue(),toussePrice)){ + top.Ext.getCmp("package1").setValue(''); + top.Ext.getCmp("count1").setValue(''); + } + } + } + } + },{ + text : '添加', + disabled:!enableBtn, + iconCls : 'btn_ext_add', + handler : function() { + var tousseName = top.Ext.getCmp("package1").getValue(); + var toussePrice = 0.00; + DWREngine.setAsync(false); + ReturnGoodsRecordTableManager.getToussePrice(tousseName,function(price){ + if(price != null){ + toussePrice = price; + } + }); + DWREngine.setAsync(true); + if(addReturnTousseItemToTree('',tousseName,top.Ext.getCmp("count1").getValue(),toussePrice)){ + top.Ext.getCmp("package1").setValue(''); + top.Ext.getCmp("count1").setValue(''); + } + } + }] + }] + }) + }); + returnGoodsColumnTree.on('load', function(store,node,response){ + returnGoodsColumnTree.expandAll(); + }); + + var treeEditer = new top.Ext.tree.ColumnTreeEditor(returnGoodsColumnTree,{ +// completeOnEnter : true, + autosize : true, + allowBlank : false, + // cancelOnEsc : true, + revertInvalid : true, + ignoreNoChange : true + }); + + returnGoodsColumnTree.on("beforeclick", function(clickNode, eObj) { + if(!enableBtn)return false; + if (isClickDel) { + //alert('isClickDel='+isClickDel); + setIsClickDel(0);// isClickDel = false; + deleteReturnedGoodsColumnTreeItem(clickNode); + }else if(!clickNode.isLeaf()){ + var obj = eObj.target; + if(obj){ + if(obj.name == 'divName_amount') {//只有数量能编辑 divName_ + dataIndex + return true; + } + } + } + return false; + }); + + treeEditer.on("complete", function(thiz, newValue, oldValue) { + var editNode = thiz.editNode;// + var attr = editNode.attributes; + if (!isPositiveInteger(newValue)) + return false; + newValue = parseToInt(newValue); + if(newValue <= 0 || newValue < getChildNodesAmountOrBarcode(editNode, false))return false; + }); + + form = new top.Ext.FormPanel({ + id : 'returnGoodsRecordForm', + frame : true, + border : 0, + labelSeparator : ':', + bodyStyle : 'padding:5px 5px 0px 5px', + width : 750, + labelAlign:'right', + autoHeight : true, + autoScroll : true, + items : [{ + xtype:"fieldset", + layout:'column', + title :'退货记录信息', + autoHeight:true, + items:[{ + layout : 'column', + items : [{ + xtype : 'hidden', + name : 'id', + id : 'id' + },{ + xtype : 'hidden', + name : 'returnTousseItemStr', + id : 'returnTousseItemStr' + },{ + xtype : 'hidden', + name : 'departCoding', + id : 'departCoding' + },{ + columnWidth : .5, + layout : 'form', + labelWidth : 80, + items : [{ + xtype : 'textfield', + fieldLabel : '操作人', + maxLength : '16', + id : 'operator', + name : 'operator', + allowBlank : false, + value : $Id('userName').value, + anchor : '80%', + readOnly : true, + cls:'fieldReadOnlyNoRemove' + }] + }, { + columnWidth : .5, + layout : 'form', + labelWidth : 70, + items : [{ + xtype : 'datefieldWithMin', + fieldLabel : '时间', + id : 'returnTime', + name : 'returnTime', + editable:false, + disabled:!editableConfig.editable, + allowBlank: false, + format:'Y-m-d H:i', +// value: new Date(), + anchor : '80%', + listeners : { + render : function() {//器械包的退货时间,取服务器时间 (cjr) + (!id) ? setStartDate(top.Ext, 'yyyy/MM/dd HH:mm', 'returnTime') : (function(){})(); + } + } + + }] + }, { + columnWidth : .5, + layout : 'form', + labelWidth : 80, + items : [{ + xtype : 'textfield', + fieldLabel : '退货人员工号', + id : 'returnOfPeopleBarcode', + name : 'returnOfPeopleBarcode', + disabled:!editableConfig.editable, + allowBlank : true, + listeners : { + specialkey : function(field,e){ + if(e.getKey() == 13){ + loadPeopleByStaffNum(field); + } + } + }, + anchor : '80%' + }] + } ,{ + columnWidth : .5, + layout : 'form', + labelWidth : 70, + items : [{ + xtype : 'textfield', + fieldLabel : '退货人', + id : 'returnOfPeople', + name : 'returnOfPeople', + disabled:!editableConfig.editable, + allowBlank : true, + anchor : '80%', + readOnly : true, + cls:'x-item-disabled' + }] + } , { + columnWidth : .5, + layout : 'form', + labelWidth : 80, + items : [{ + xtype : 'combo', + id : 'depart', + name : 'depart', + disabled:!editableConfig.editable, + queryParam : 'spell', + fieldLabel : '退货人科室', + queryParam : 'spell', + minChars : 0, + valueField : 'id', + displayField : 'name', + anchor : '80%', + store : departJsonStore, + forceSelection : true, + lazyInit : true, + triggerAction : 'all', + hideTrigger : true, + typeAhead : false, + allowBlank : false, + //readOnly : true, + //cls:'fieldReadOnlyNoRemove', + listeners :{ + select:function(combo, record, index ){ + var tem = record.data.id; + top.Ext.getCmp('departCoding').setValue(tem); + } + } + }] + }/* ,{ + columnWidth : .5, + layout : 'form', + labelWidth : 70, + items : [{ + xtype : 'textfield', + fieldLabel : '总金额', + maxLength : '16', + id : 'totalMoney', + name : 'totalMoney', + anchor : '80%', + disabled : true + }] + }*/,{ + columnWidth : 1, + layout : 'form', + labelWidth : 80, + items : [{ + xtype : 'textarea', + height : 45, + fieldLabel : '备注', + id : 'remark', + name : 'remark', + disabled:!editableConfig.editable, + allowBlank : true, + anchor : '90%' + }] + }] + }] + },{ + xtype:"fieldset", + layout:'column', + title :'退货记录明细', + autoHeight:true, + items:[{ + layout : 'form', + columnWidth : 1, + items :[returnGoodsColumnTree] + }] + }], + buttonAlign :'center', + buttons : [{ + text : '打印', + handler : function() { + var title = ""; + DWREngine.setAsync(false); + SupplyRoomConfigTableManager.getStartTimeObject(function(config){ + if(config != null){ + title = config.unitName; + } + }); + DWREngine.setAsync(true); + var operator = top.Ext.getCmp('operator').getValue(); + var returnTime = new Date(top.Ext.getCmp('returnTime').getValue()).format('Y-m-d'); + var depart = top.Ext.getCmp('depart').getValue(); + var remark = top.Ext.getCmp('remark').getValue(); + var returnTousseItems = getReturnTousseDetailGridData(false); + printReturnTousseRecord(title,operator,returnTime,depart,remark,returnTousseItems,0); + } + },{ + text : '保存', + id : 'saveBtn', + hidden:SSTS_ReturnGoodsRecord_Create && SSTS_ReturnGoodsRecord_Update, + disabled:!enableBtn, + handler : function(){ + top.Ext.MessageBox.confirm("请确认","是否保存"+ entityName + "信息?",function(btn) { + if(btn=='yes') { + if(!form.getForm().isValid()){ + showResult('请正确填写表单各值'); + return false; + } + // 校验退货人科室是否有问题 + if(!isDepartValid()){ + showResult('退货人科室不一致!'); + return false; + } +// if(top.Ext.getCmp('returnOfPeople').getValue().length<1){ +// showResult('退货人信息不能为空'); +// return false; +// } + + //获取tree columns数据 + var returnTousseItemStr = getReturnTousseDetailGridData(true); + if(!returnTousseItemStr){ + showResult('退货详细信息列表不能为空'); + return false; + } + top.Ext.getCmp('returnTousseItemStr').setValue(returnTousseItemStr); + /*top.Ext.getCmp('returnOfPeople').setDisabled(false); + top.Ext.getCmp('depart').setDisabled(false);*/ +// return false; + form.form.submit({ + url : WWWROOT + '/disinfectSystem/returnGoodsRecordAction!saveReturnTousseRecord.do', + method : 'POST', + waitMsg : '正在保存数据,请稍候', + waitTitle : '提交表单', + success : function(form, action) { + if(action.result.success){ + grid.dwrReload(); + window.close(); + } else if (action.result.message){ + showResult(action.result.message); + } else { + showResult('保存失败'); + } + }, + failure : function(form, action) { + if (action.result.error){ + showResult(action.result.error); + } else if (action.result.message){ + showResult(action.result.message); + } else { + showResult('保存失败'); + } + } + }); + } + }); + } + },{ + text : '取消', + handler : function() { + window.close(); + } + }] + }); + + var window = new top.Ext.Window({ + id : 'returnTousseRecordWin', + layout : 'fit', + title : entityName + '信息', + width : 660, + modal : true, +// autoHeight : true, + border : false, + height:550, + plain : true, + items : [ form ] + }); + window.show(); +} +function addAndEditReturnGoodsRecord(id, enableBtn) { + editableConfig.editable = enableBtn; + var diposableGoodsStore = new Ext.data.Store({ + pageSize: 100, + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectSystem/diposableGoodsAction!getDiposableGoodsData.do?allItems=yes', + 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(diposableGoodsBatchNumStore == null){ + diposableGoodsBatchNumStore = new Ext.data.Store({ + reader : new Ext.data.JsonReader({ + fields : [ + {name : 'batchNumber'}, + {name : 'batchID'}, + {name : 'barcode'}, + {name : 'cost'}, + {name : 'expDate'} + ] + }) + }); + } + + if(BatchRecord == null){ + BatchRecord = Ext.data.Record.create([ + {name : 'batchNumber'}, + {name : 'disposableGoodsId'}, + {name : 'disposableGoodsStockId'}, + {name : 'disposableGoodsBatchId'}, + {name : 'disposableGoodsBatchStockId'}, + {name : 'barcode'}, + {name : 'cost'}, + {name : 'expDate'} + ]); + } + //单价数据源 + if(priceStore == null){ + priceStore = new Ext.data.Store({ + reader : new Ext.data.JsonReader({ + fields : [ + {name : 'price'}, + {name : 'fluctuationPrice'}, + {name : 'sentAmount'}, + {name : 'returnedAmount'}, + ] + }) + }); + } + if(PriceRecord == null){ + PriceRecord = Ext.data.Record.create([ + {name : 'price'}, + {name : 'fluctuationPrice'}, + {name : 'sentAmount'}, + {name : 'returnedAmount'}, + ]); + } + //该退货记录已经录入的退货详细信息 + var dataReader = new Ext.data.JsonReader({ + fields : [ + {name : 'id'}, + {name : 'tousseName'}, + {name : 'unit'}, + {name : 'disposableGoodsID'}, + {name : 'disposableGoodsStockID'}, + {name : 'disposableGoodsBatchID'}, + {name : 'disposableGoodsBatchStockID'}, + {name : 'identificationID'}, + {name : 'expensiveDisposablegoodsId'}, + {name : 'amount'}, + {name : 'amountCanReturn'}, + {name : 'barcode'}, + {name : 'batchNumber'}, + {name : 'price'}, + {name : 'fluctuationPrice'}, + {name : 'isDelivery'}, + {name : 'expDate'} + ] + }); + + //初始化加载器械包 + returnGoodsItemStore = new Ext.data.Store({ + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectSystem/returnGoodsRecordAction!loadReturnGoodsItemByInvoicePlanId.do', + method : 'POST' + }), + reader : dataReader, + listeners : { + load : function() { + setTotalMoney(); + } + } + }); + + function rowTotalRender(value, cellmeta, record, rowIndex, columnIndex, store) { + return accMul(record.data.fluctuationPrice,record.data.amount); + } + var isToDeliveryStore = new top.Ext.data.SimpleStore( { + fields : [ 'value'], + data : [['是'],['否']] + }); + + var cmArr = new Array(new Ext.grid.RowNumberer(), + {header : "条码",width : 80,dataIndex : 'barcode',menuDisabled:true}, + {id : 'autoWidth',header : "物品",dataIndex : 'tousseName',width : 180,menuDisabled:true}, + {header : "退货数量",width : 70,dataIndex : 'amount',menuDisabled:true, + editor : new top.Ext.form.NumberField({ + allowBlank : false, + disabled:!enableBtn, + allowNegative : false, + style : 'text-align: left', + allowDecimals : false + }) + }, + {header : "单位",width : 50,dataIndex : 'unit',menuDisabled:true}, + {header : "可退货数量",width : 70,dataIndex : 'amountCanReturn',menuDisabled:true}, + {header : "批次",width : 100,dataIndex : 'batchNumber',menuDisabled:true}, + {header : "单价",width : 50,dataIndex : 'fluctuationPrice',menuDisabled:true}, + {header : "失效日期",width : 80,dataIndex : 'expDate',menuDisabled:true}, + {header : "金额",width : 60,dataIndex : 'rowTotal',renderer:rowTotalRender,menuDisabled:true}, + {header : '删除',dataIndex:'button',width:60,menuDisabled:true, + renderer: function(v,p,record){ + var str = ''; + if(editableConfig.editable){ + str = ""; + } + + return str; + } + }); + + if(id){ + cmArr.splice(2,0,{header : "是否重发",dataIndex : 'isDelivery',width : 60,menuDisabled:true}); + }else{ + cmArr.splice(2,0,{header : "是否重发",dataIndex : 'isDelivery',width : 60,menuDisabled:true, + editor : new top.Ext.form.ComboBox({ + id : 'isDeliveryComboBox', + name : 'isDeliveryComboBox', + valueField : 'value', + displayField : 'value', + store : isToDeliveryStore, + forceSelection : true, + mode : 'local', + triggerAction : 'all' + }) + }); + } + + var cm = new top.Ext.grid.ColumnModel(cmArr); + + + returnGoodsItemStore.on("beforeload", function(thiz, options) { + thiz.baseParams["invoicePlanId"] = invoicePlanId; + thiz.baseParams["warehouseId"] = top.Ext.getCmp('warehouseID').getValue(); + }); + + /*var deptStore = new Ext.data.SimpleStore({ + fields : [ 'departName','departCoding' ], + url : WWWROOT + '/disinfectSystem/baseData/supplyRoomConfigAction!getAllOrgUnitName.do' + });*/ + + form = new top.Ext.FormPanel({ + id : 'returnGoodsRecordForm', + frame : true, + border : 0, + labelSeparator : ':', + bodyStyle : 'padding:5px 5px 0px 5px', + width : 950, + labelAlign:'right', + autoHeight : true, + autoScroll : true, + items : [{ + xtype:"fieldset", + layout:'column', + title :'退货记录信息', + autoHeight:true, + items:[{ + layout : 'column', + items : [{ + xtype : 'hidden', + name : 'id', + id : 'id' + },{ + xtype : 'hidden', + name : 'returnGoodsItemIds', + id : 'returnGoodsItemIds' + },{ + xtype : 'hidden', + name : 'departCoding', + id : 'departCoding' + },{ + xtype : 'hidden', + name : 'warehouseID', + id : 'warehouseID' + },{ + xtype : 'hidden', + name : 'warehouseName', + id : 'warehouseName' + },{ + xtype : 'hidden', + name : 'invoicePlanId', + id : 'invoicePlanId', + value:invoicePlanId + },{ + columnWidth : .5, + layout : 'form', + labelWidth : 80, + items : [{ + xtype : 'textfield', + fieldLabel : '操作人', + maxLength : '16', + id : 'operator', + name : 'operator', + allowBlank : false, + value : $Id('userName').value, + anchor : '80%', + readOnly : true, + cls:'fieldReadOnlyNoRemove' + }] + }, { + columnWidth : .5, + layout : 'form', + labelWidth : 70, + items : [{ + xtype : 'datefieldWithMin', + fieldLabel : '时间', + id : 'returnTime', + name : 'returnTime', + editable:false, + disabled:!editableConfig.editable, + allowBlank: false, + format:'Y-m-d H:i', +// value: new Date(), + anchor : '80%', + listeners : { + render : function() { //一次性物品的的退货时间,取服务器时间 cjr) + (!id) ? setStartDate(top.Ext, 'yyyy/MM/dd HH:mm', 'returnTime') : (function(){})(); + } + } + + }] + }, { + columnWidth : .5, + layout : 'form', + labelWidth : 80, + items : [{ + xtype : 'textfield', + fieldLabel : '退货人员工号', + id : 'returnOfPeopleBarcode', + name : 'returnOfPeopleBarcode', + disabled:!editableConfig.editable, + allowBlank : true, + listeners : { + specialkey : function(field,e){ + if(e.getKey() == 13){ + loadPeopleByStaffNum_forDiposableGoods(field); + } + } + }, + anchor : '80%' + }] + } ,{ + columnWidth : .5, + layout : 'form', + labelWidth : 70, + items : [{ + xtype : 'textfield', + fieldLabel : '退货人', + id : 'returnOfPeople', + name : 'returnOfPeople', + allowBlank : true, + anchor : '80%', + readOnly : true, + cls:'x-item-disabled' + }] + } , { + columnWidth : .5, + layout : 'form', + labelWidth : 80, + items : [{ + xtype : 'combo', + id : 'depart', + name : 'depart', + disabled:!editableConfig.editable, + queryParam : 'spell', + fieldLabel : '退货人科室', + queryParam : 'spell', + minChars : 0, + valueField : 'name', + displayField : 'name', + anchor : '80%', + store : departJsonStore, + forceSelection : true, + lazyInit : true, + triggerAction : 'all', + hideTrigger : true, + typeAhead : false, + allowBlank : false, + listeners :{ + select:function(combo, record, index ){ + var tem = record.data.id; + top.Ext.getCmp('departCoding').setValue(tem); + } + } + }] + } ,{ + columnWidth : .5, + layout : 'form', + labelWidth : 70, + items:[{ + xtype : 'combo', + fieldLabel : '退货仓库', + id : 'warehouse', + name : 'warehouse', + minChars : 0, + valueField : 'id', + displayField : 'name', + store : wareHouseStore, + forceSelection : true, + lazyInit : false, + mode : 'local', + triggerAction : 'all', + hideTrigger : true, + typeAhead : false, + allowBlank : false, + width : 100, + listeners : { + select : function(combo, record, index) { +// top.Ext.getCmp('warehouse').setValue(record.data.name); + top.Ext.getCmp('warehouseID').setValue(record.data.id); + top.Ext.getCmp('warehouseName').setValue(record.data.name); + + returnGoodsItemStore.removeAll(); + returnGoodsItemStore.load(); + setTotalMoney(); + }, + specialkey : function(field, ee) { + if (ee.getKey() == Ext.EventObject.ENTER) { + top.Ext.getCmp('remark').focus(); + } + } + } + }] + },{ + columnWidth : .5, + layout : 'form', + labelWidth : 80, + items : [{ + xtype : 'textfield', + fieldLabel : '总金额', + maxLength : '16', + id : 'totalMoney', + name : 'totalMoney', + anchor : '80%', + readOnly : true, + cls:'x-item-disabled' + }] + },{ + columnWidth : 1, + layout : 'form', + labelWidth : 80, + items : [{ + xtype : 'textarea', + height : 45, + fieldLabel : '备注', + id : 'remark', + name : 'remark', + disabled:!editableConfig.editable, + allowBlank : true, + anchor : '90%' + }] + }] + }] + },{ + xtype:"fieldset", + layout:'column', + title :'退货记录明细', + autoHeight:true, + items:[{ + layout : 'form', + columnWidth : 1, + items :[new top.Ext.grid.EditorGridPanel({ + id : 'returnGoodsItemGrid', + store : returnGoodsItemStore, + bodyStyle : 'border:1px solid #afd7af', + cm : cm, + width :920, + height : 270, + autoExpandColumn : 'autoWidth', + border : true, + frame : false, + viewConfig: { + forceFit:true + }, + clicksToEdit : 1,// 设置点击几次才可编辑 + selModel : new top.Ext.grid.RowSelectionModel({ + singleSelect : false + }), + listeners:{ + afteredit : function() { + setTotalMoney(); + } + } + })] + }] + }], + buttonAlign :'center', + buttons : [{ + text : '打印', + handler : function() { + var title = ""; + DWREngine.setAsync(false); + SupplyRoomConfigTableManager.getStartTimeObject(function(config){ + if(config != null){ + title = config.unitName; + } + }); + DWREngine.setAsync(true); + var operator = top.Ext.getCmp('operator').getValue(); + var returnTime = new Date(top.Ext.getCmp('returnTime').getValue()).format('Y-m-d'); + var depart = top.Ext.getCmp('depart').getValue(); + var totalMoney = top.Ext.getCmp('totalMoney').getValue(); + var remark = top.Ext.getCmp('remark').getValue(); + var returnGoodsItems = getReturnGoodsDetailGridDataToPrint(); + printReturnGoodsRecord(title,operator,returnTime,depart,totalMoney,remark,returnGoodsItems,0); + } + },{ + text : '保存', + id : 'saveBtn', + hidden:SSTS_ReturnGoodsRecord_Create && SSTS_ReturnGoodsRecord_Update, + disabled:!enableBtn, + handler : function(){ + top.Ext.MessageBox.confirm("请确认","是否保存"+ entityName + "信息?",function(btn) { + if(btn=='yes') { + if(!form.getForm().isValid()){ + showResult('请正确填写表单各值'); + return false; + } +// if(top.Ext.getCmp('returnOfPeople').getValue().length<1){ +// showResult('退货人信息不能为空'); +// return false; +// } + + if(returnGoodsItemStore.getCount()<1){ + showResult('退货详细信息列表不能为空'); + return false; + } + + //获取grid数据 + getReturnGoodsDetailGridData(); + top.Ext.getCmp("depart").enable(); + /*top.Ext.getCmp('returnOfPeople').setDisabled(false); + top.Ext.getCmp('depart').setDisabled(false);*/ +// return false; + form.form.submit({ + url : WWWROOT + '/disinfectSystem/returnGoodsRecordAction!saveReturnGoodsRecord.do', + method : 'POST', + waitMsg : '正在保存数据,请稍候', + waitTitle : '提交表单', + success : function(form, action) { + if(action.result.success){ + showResult('保存成功'); + } else if (action.result.error){ + showResult(action.result.error); + } else if(action.result.errMsg){ + showResult(action.result.errMsg); + } else { + showResult('保存失败'); + } +// grid.dwrReload(); + top.Ext.getCmp('returnGoodsRecordWin').close(); + document.location.href = WWWROOT+'/disinfectsystem/returnGoodsRecord/returnGoodsRecordView.jsp'; + }, + failure : function(form, action) { + top.Ext.getCmp("depart").disable();// 禁止修改科室 + if (action.result.error){ + showResult(action.result.error); + } else if(action.result.errMsg){ + showResult(action.result.errMsg); + } else { + showResult('保存失败'); + } + } + }); + } + }); + } + },{ + text : '取消', + handler : function() { + top.Ext.getCmp('returnGoodsRecordWin').close(); + } + }] + }); + + var win = new top.Ext.Window({ + id : 'returnGoodsRecordWin', + layout : 'fit', + title : entityName + '信息', + width : 930, + modal : true, +// autoHeight : true, + border : false, + height:580, + plain : true, + items : [ form ] + }); + win.show(); + + DWREngine.setAsync(false); + ReturnGoodsRecordTableManager.getInvoicePlanInfo(invoicePlanId,function(batchesStr){ + var invoicePlanInfo = top.Ext4.JSON.decode(batchesStr); + var warehouses = invoicePlanInfo.warehouses; + wareHouseStore.removeAll(); + for(var i=0;i 0){ + // 选中第一个 + var combo = top.Ext.getCmp("warehouse"); + combo.setValue(warehouses[0].id); + // 触发选中事件 + combo.fireEvent('select', combo,wareHouseStore.getAt(0),0); + } + top.Ext.getCmp('depart').setValue(invoicePlanInfo.depart); + top.Ext.getCmp('departCoding').setValue(invoicePlanInfo.departCoding); + + }); + DWREngine.setAsync(true); +} + +// 器械包,科室退货人为空时才能更改退货人科室 +function loadPeopleByStaffNum(staffNumField){ + var staffNum = staffNumField.getValue(); + if(staffNum){ + UserTableManager.getUserObjByName(staffNum,function(user){ + if(user){ + var fullName = user.split(",")[0]; + var orgUnitNames = user.split(",")[1]; + var orgUnitCodes = user.split(",")[2]; + top.Ext.getCmp('returnOfPeople').setValue(fullName);//设置退货人 + var currentDepart = getCurrentDepart(); + var currentDepartCoding = getCurrentDepartCoding(); + var resetDepart = true; + if(currentDepart != '' || currentDepartCoding != ''){ + resetDepart = false; + } + if(resetDepart){ + if(orgUnitNames){ + var orgUnitName = orgUnitNames.split(';')[0];//如果有多个,默认拿第一个,当前系统只有一个; + top.Ext.getCmp('depart').setValue(orgUnitName.substring(orgUnitName.lastIndexOf("-")+1));//设置科室 + } + if(orgUnitCodes){ + var orgUnitCode = orgUnitCodes.split(';')[0]; + top.Ext.getCmp('departCoding').setValue(orgUnitCode);//科室代码 + } + } + + }else{ + showResult('找不到该员工号所对应的人员信息'); + top.Ext.getCmp('returnOfPeople').setValue(); + top.Ext.getCmp('depart').setValue(); + top.Ext.getCmp('departCoding').setValue(); + } + }); + } + staffNumField.setValue(); +} +// 一次性物品 +function loadPeopleByStaffNum_forDiposableGoods(staffNumField){ + var staffNum = staffNumField.getValue(); + if(staffNum){ + UserTableManager.getUserObjByName(staffNum,function(user){ + if(user){ + var fullName = user.split(",")[0]; + var orgUnitNames = user.split(",")[1]; + var orgUnitCodes = user.split(",")[2]; + top.Ext.getCmp('returnOfPeople').setValue(fullName);//设置退货人 + var currentDepart = getCurrentDepart(); + var currentDepartCoding = getCurrentDepartCoding(); + var resetDepart = true; + if(currentDepart != '' || currentDepartCoding != ''){ + resetDepart = false; + } + if(resetDepart){ + if(orgUnitNames){ + var orgUnitName = orgUnitNames.split(';')[0];//如果有多个,默认拿第一个,当前系统只有一个; + top.Ext.getCmp('depart').setValue(orgUnitName.substring(orgUnitName.lastIndexOf("-")+1));//设置科室 + } + if(orgUnitCodes){ + var orgUnitCode = orgUnitCodes.split(';')[0]; + top.Ext.getCmp('departCoding').setValue(orgUnitCode);//科室代码 + } + } + + }else{ + showResult('找不到该员工号所对应的人员信息'); + top.Ext.getCmp('returnOfPeople').setValue(); + top.Ext.getCmp('depart').setValue(); + top.Ext.getCmp('departCoding').setValue(); + } + }); + } + staffNumField.setValue(); +} +//获取grid的数据 +function getReturnGoodsDetailGridData() { + var returnGoodsDetails = buildJSONStringFromStore(returnGoodsItemStore); + //alert(returnGoodsDetails); + top.Ext.getCmp('returnGoodsItemIds').setValue(returnGoodsDetails); +} + + +function getReturnGoodsDetailGridDataToPrint() { + var tousseIds = null; + for ( var i = 0; i < returnGoodsItemStore.getCount(); i++) { + var record = returnGoodsItemStore.getAt(i); + if (tousseIds == null) { + tousseIds = record.get('barcode') + '#&' + record.get('tousseName') + "#&" + record.get('amount') + '#&' + record.get('batchNumber') + '#&' + record.get('fluctuationPrice') + '#&' + record.get('expDate') + '#&'+ accMul(record.get('fluctuationPrice'),record.get('amount')); + } else { + tousseIds += "#@" + record.get('barcode') + '#&' + record.get('tousseName') + "#&" + record.get('amount') + '#&' + record.get('batchNumber') + '#&' + record.get('fluctuationPrice') + '#&' + record.get('expDate') + '#&' + accMul(record.get('fluctuationPrice'),record.get('amount')); + } + } + return tousseIds; +} + +function setReturnGoodsRecordForm(returnGoodsRecord){ + top.Ext.getCmp("id").setValue(returnGoodsRecord.id); + top.Ext.getCmp("operator").setValue(returnGoodsRecord.operator); + top.Ext.getCmp("depart").setValue(returnGoodsRecord.depart); + top.Ext.getCmp("returnTime").setValue(returnGoodsRecord.returnTime); +// Ext.getCmp("signStatus").setValue(returnGoodsRecord.signStatus); + top.Ext.getCmp("remark").setValue(returnGoodsRecord.remark); + top.Ext.getCmp("returnOfPeople").setValue(returnGoodsRecord.returnOfPeople); + top.Ext.getCmp("departCoding").setValue(returnGoodsRecord.departCoding); + var warehouse = top.Ext.getCmp("warehouse"); + if(warehouse != null){ + warehouse.setValue(returnGoodsRecord.warehouseName); + } +} + +//TODO 器械包退货 +/*********************************** 器械包退货 form start****************************************/ +function parseToInt(v) { + if (typeof(v) == "number") + return v; + var parseIntV = 0; + try { + parseIntV = parseInt(v, 10); + if (isNaN(parseIntV)) { + parseIntV = 0; + } + } catch (e) { + } + return parseIntV; +} + +function returnNewParentNodeOfModifyAmount(pNode, amount,price){ + var difAmount = parseToInt(pNode.attributes.amount) + parseToInt(amount); + if(difAmount <= 0){ + return false; + }else{ + return createParentNode(pNode.attributes.recordId, pNode.attributes.tousseName, difAmount,price,pNode.attributes.isDelivery, pNode.attributes.isPacking); + } +} + +function returnNewParentNodeOfModifyIsDelivery(pNode, isDelivery){ + if (isDelivery != '是'){ + isDelivery = '否'; + } + var newPNode = createParentNode(pNode.attributes.recordId, pNode.attributes.tousseName, pNode.attributes.amount,pNode.attributes.price, isDelivery,pNode.attributes.isPacking); + pNode.eachChild(function(cNode){ + //newPNode.appendChild(createChildNode(cNode.attributes.barcode)); + newPNode.appendChild(createChildNode(cNode.attributes.tousseInstance)); + }); + return newPNode; +} + +function returnNewParentNodeOfModifyIsPacking(pNode, isPacking){ + if (isPacking != '是'){ + isPacking = '否'; + } + var newPNode = createParentNode(pNode.attributes.recordId, pNode.attributes.tousseName, pNode.attributes.amount,pNode.attributes.price, pNode.attributes.isDelivery, isPacking); + pNode.eachChild(function(cNode){ + //newPNode.appendChild(createChildNode(cNode.attributes.barcode)); + newPNode.appendChild(createChildNode(cNode.attributes.tousseInstance)); + }); + return newPNode; +} +// 复制父节点 +function copyParentNode(copyFromNode){ + return createParentNodeFrom(copyFromNode); +} +function deleteReturnedGoodsColumnTreeItem(clickNode) { + var pNode = clickNode.parentNode; + clickNode.remove(); + if(clickNode.isLeaf()){ + // 调整数量 + adjustAmount(pNode,-1); + if(pNode.attributes.amount <= 0){ + // 删除整个器械包目录 + pNode.remove(); + }else{ + var ppNode = pNode.parentNode; + var newParentNode = copyParentNode(pNode); + ppNode.replaceChild(newParentNode,pNode); + } +// var newParentNode = returnNewParentNodeOfModifyAmount(pNode, -1); +// if(!newParentNode){ +// pNode.remove(); +// } + } +} +// 刷新数量 +// 调整数量 +function adjustAmount(node,amount){ + node.attributes.amount += amount; +} +function getChildNodesAmountOrBarcode(pNode, isGetBarcode){ + if(pNode.isLeaf()){ + if(isGetBarcode){ + return ''; + }else{ + return 1; + } + }else{ + if(isGetBarcode){ + var barcode = ''; + pNode.eachChild(function(tousseNode) { + barcode += '@#' + tousseNode.attributes.barcode; + }); + return barcode; + }else{ + if(pNode.hasChildNodes()){ + return pNode.childNodes.length; + }else{ + return 0; + } + } + } +} + +function setIsClickDel(v) { + isClickDel = (v == 1 ? true : false); +} + +function checkStatus(v, escapeTousseName, attr){ + var rootNode = top.Ext.getCmp('returnGoodsColumnTree').getRootNode(); + var childNode = rootNode.findChild('tousseName',unescape(escapeTousseName)); + if(childNode){ + var newNode; + if(attr=='isDelivery'){ + newNode = returnNewParentNodeOfModifyIsDelivery(childNode, v); + }else{ + newNode = returnNewParentNodeOfModifyIsPacking(childNode, v); + } + rootNode.replaceChild(newNode, childNode); + } +} + +//获取器械包退货明细信息 +//格式为:ID@#包名@#数量@#是否重新发货@#是否重新装配@#条码...@;ID@#包名@#数量@#是否重新发货@#是否重新装配@#条码... +function getReturnTousseDetailGridData(isGetBarcode) { + var returnTousseItemStr = ''; + var rootNode = top.Ext.getCmp('returnGoodsColumnTree').getRootNode(); + + rootNode.eachChild(function(tousseNode) { + if(returnTousseItemStr){ + returnTousseItemStr += '@;'; + } + var attr = tousseNode.attributes; + returnTousseItemStr += (attr.recordId + '@#' + attr.tousseName + '@#' + attr.amount + '@#' + attr.isDelivery + '@#' + attr.isPacking + "@#" + attr.price); + if(isGetBarcode){ + returnTousseItemStr += getChildNodesAmountOrBarcode(tousseNode, true); + } + }); + return returnTousseItemStr; +} + +//把器械包添加到tree中 +function addScanningTousseItemToTree(tousseInstance){ + var barcode = tousseInstance.barcode; + var tousseName = tousseInstance.tousseName; + + var amount = 1; + var price = tousseInstance.fluctuationPrice; + // 如果是固定条码 + var tousseFixedBarcode = tousseInstance.tousseFixedBarcode; + if(!isUndefinedOrNull(tousseFixedBarcode) && tousseFixedBarcode){ + addReturnTousseItemToTree('',tousseName,1,price); + return; + } + var departCoding = tousseInstance.settleAccountsDepartCode; + var depart = tousseInstance.settleAccountsDepart; + if(isUndefinedOrNullOrEmpty(departCoding)){ + departCoding = tousseInstance.location; + depart = tousseInstance.locationForDisplay; + } + // 校验退货人的科室是否和当前器械包的一致 + //var curDepartCoding = top.Ext.getCmp('departCoding').getValue(); + //alert(curDepartCoding) + //alert(departCoding) + //alert(depart) +// if(curDepartCoding != '' ){ +// //alert(departCoding) +// if((curDepartCoding != undefined && curDepartCoding != null && curDepartCoding != '') && (curDepartCoding != tousseInstance.location)){ +// showResult("器械包科室和退货人科室不一致!"); +// return false; +// } +// }else{ +// top.Ext.getCmp('departCoding').setValue(departCoding); +// top.Ext.getCmp('depart').setValue(depart); +// } + top.Ext.getCmp('departCoding').setValue(departCoding); + top.Ext.getCmp('depart').setValue(depart); + + //是否为包实例 --》是:包实例 否:包定义 + var isTousseInstance = (barcode?true:false); + var flag = true;//子循环标识 + var tousseNodeExist = false/*包定义节点是否存在*/, tousseInstanceNodeExist = false/*包实例节点是否存在*/; + var rootNode = top.Ext.getCmp('returnGoodsColumnTree').getRootNode(); + rootNode.eachChild(function(tousseNode) { + // 有且只有二层节点(不包括根节点rootNode) + if (tousseNode.attributes.tousseName == tousseName) { + tousseNodeExist = true;//找到包定义节点 + + if(isTousseInstance){//如果是有条码,则为包实例 + + //查找当前包定义下的所有包实例(查重) + tousseNode.eachChild(function(tousseInstanceNode) { + // 包实例节点 + if (tousseInstanceNode.attributes.barcode == barcode) { + showResult("该条码的器械包实例已存在!"); + tousseInstanceNodeExist = true;//找到包实例节点 + return true; + } + }); + + if(!tousseInstanceNodeExist){ + //在当前包定义下添加一个新的包实例节点 + //var mynode = createChildNode(barcode); + var mynode = createChildNode(tousseInstance); + // 把新增的子节点追加到父节点中 + var newPNode = returnNewParentNodeOfModifyAmount(tousseNode, 1,price); + tousseNode.eachChild(function(cNode){ + //newPNode.appendChild(createChildNode(cNode.attributes.barcode)); + newPNode.appendChild(createChildNode(cNode.attributes.tousseInstance)); + }); + newPNode.appendChild(mynode); + rootNode.replaceChild(newPNode, tousseNode); + } + return true; + + }else{//否则,修改包定义数量 + var newPNode = returnNewParentNodeOfModifyAmount(tousseNode, amount,price); + newPNode.appendChild(tousseNode.childNodes); + // 替换原子节点 + rootNode.replaceChild(newPNode, tousseNode); + return true; + } + } + + }); + + if(tousseNodeExist){ + return true; + } + + if(isTousseInstance){ + amount = 1; + } + + var tousseNode = createParentNode(0, tousseName, amount,price, '否', '否'); + + if(isTousseInstance){ + //tousseInstanceNode = createChildNode(barcode); + tousseInstanceNode = createChildNode(tousseInstance); + // 绑定到包定义节点 + tousseNode.appendChild(tousseInstanceNode); + } + + rootNode.appendChild(tousseNode); + + return true; +} +// 是否已经有包实例 +function isTousseInstanceExist(){ + + var exist = false; + var rootNode = top.Ext.getCmp('returnGoodsColumnTree').getRootNode(); + rootNode.eachChild(function(tousseNode) { + // 有且只有二层节点(不包括根节点rootNode) + tousseNode.eachChild(function(tousseInstanceNode) { + // 包实例节点 + if (tousseInstanceNode.attributes.barcode != '') { + exist = true; + } + }); + }); + //alert('isTousseInstanceExist='+exist); + return exist; +} +//把器械包添加到tree中 +function addReturnTousseItemToTree(barcode, tousseName, amount,price,departCoding,depart){ + + if(!tousseName) { + showResult("请输入器械包名称!"); + return false; + } + + if(amount == "" || amount < 1) { + showResult("请输入数量且不能小于0!"); + return false; + } + + //是否为包实例 --》是:包实例 否:包定义 + var isTousseInstance = (barcode?true:false); + var tousseNodeExist = false/*包定义节点是否存在*/, tousseInstanceNodeExist = false/*包实例节点是否存在*/; + var rootNode = top.Ext.getCmp('returnGoodsColumnTree').getRootNode(); + var replaceNodeNew = null; + var replaceNodeOld = null; + var nodeNew = null; + rootNode.eachChild(function(tousseNode) { + // 有且只有二层节点(不包括根节点rootNode) + if (tousseNode.attributes.tousseName == tousseName) { + tousseNodeExist = true;//找到包定义节点 + + replaceNodeOld = tousseNode; + + return true; + } + + }); + if(replaceNodeOld != null){ + adjustAmount(replaceNodeOld, amount); + var newPNode = copyParentNode(replaceNodeOld); + rootNode.replaceChild(newPNode, replaceNodeOld); + return; + } + if(tousseNodeExist){ + return true; + } + + + var tousseNode = createParentNode(0, tousseName, amount,price, '否', '否'); + + if(isTousseInstance){ + tousseInstanceNode = createChildNode(barcode); + // 绑定到包定义节点 + tousseNode.appendChild(tousseInstanceNode); + } + + rootNode.appendChild(tousseNode); + + return true; +} + +/** + * 创建子节点 public + */ +//function createChildNode(barcode) { +// return createNodeByParam(false, 0, '', 1,0.00, barcode, '', ''); +//} +function createChildNode(tousseInstance) { + // 创建子节点 + var node = new Ext.tree.TreeNode({ + id : Ext.id(), + text : '', + iconCls : 'task', + uiProvider : Ext.tree.ColumnNodeUI, + leaf : true, + expanded : true + }); + node.attributes.amount = 1; + node.attributes.barcode = tousseInstance.barcode; + // 科室编码 + node.attributes.departCoding = tousseInstance.location; + node.attributes.location = tousseInstance.location; + node.attributes.settleAccountsDepartCode = tousseInstance.settleAccountsDepartCode; + node.attributes.settleAccountsDepart = tousseInstance.settleAccountsDepart; + node.attributes.recordId = 0; + node.attributes.tousseInstance = tousseInstance; + return node; +} + +/** + * 创建父节点 public + */ +function createParentNode(recordId, tousseName, amount,price, isDelivery, isPacking){ + return createNodeByParam(true, recordId, tousseName, amount,price, '', isDelivery, isPacking); +} +function createParentNodeFrom(pNode){ + //alert(111) + var node; + // 创建父节点 + node = new Ext.tree.TreeNode({ + id : Ext.id(), + text : pNode.tousseName, + cls : 'master-task', + iconCls : 'task-folder', + uiProvider : Ext.tree.ColumnNodeUI, + leaf : pNode.leaf, + expanded : true + }); + node.attributes.amount = pNode.attributes.amount; + node.attributes.tousseName = pNode.attributes.tousseName; + node.attributes.isDelivery = pNode.attributes.isDelivery; + node.attributes.isPacking = pNode.attributes.isPacking; + node.attributes.price = pNode.attributes.price; + node.attributes.recordId = pNode.attributes.recordId; + + pNode.eachChild(function(cNode){ + var cNodeNew = createChildNode(cNode.attributes.tousseInstance); + node.appendChild(cNodeNew); + }); + return node; +} +//private +function createNodeByParam(isParentNode, recordId, tousseName, amount,price, barcode, isDelivery, isPacking) { + var node; + if (isParentNode == true) { + // 创建父节点 + node = new Ext.tree.TreeNode({ + id : Ext.id(), + text : tousseName, + cls : 'master-task', + iconCls : 'task-folder', + uiProvider : Ext.tree.ColumnNodeUI, + leaf : false, + expanded : true + }); + node.attributes.amount = amount; + node.attributes.tousseName = tousseName; + node.attributes.isDelivery = isDelivery; + node.attributes.isPacking = isPacking; + node.attributes.price = price; + } else { + // 创建子节点 + node = new Ext.tree.TreeNode({ + id : Ext.id(), + text : tousseName, + iconCls : 'task', + uiProvider : Ext.tree.ColumnNodeUI, + leaf : true, + expanded : true + }); + node.attributes.amount = 1; + node.attributes.barcode = barcode; + } + node.attributes.recordId = recordId; + // ********************** 节点保存的属性值 ****************************// + return node; +} +Ext.onReady(function() { + Ext.QuickTips.init(); + Ext.BLANK_IMAGE_URL = WWWROOT + '/ext/resources/images/default/s.gif'; + + addAndEditReturnDisposableGoodsByInvoicePlan(invoicePlanId); +}); +/*********************************** 器械包退货 form end****************************************/ Index: ssts-web/src/main/webapp/disinfectsystem/returnGoodsRecord/returnDisposableGoodsByInvoicePlan.js =================================================================== diff -u --- ssts-web/src/main/webapp/disinfectsystem/returnGoodsRecord/returnDisposableGoodsByInvoicePlan.js (revision 0) +++ ssts-web/src/main/webapp/disinfectsystem/returnGoodsRecord/returnDisposableGoodsByInvoicePlan.js (revision 17711) @@ -0,0 +1,1637 @@ +var entityName = "退货记录"; +var grid; + +var returnGoodsItemStore = null; +var returnTousseItemStore = null; +var isClickDel = false; +var form = null; +var editableConfig = {editable:false}; + +var returnGoodsItemStore = null; +var returnTousseItemStore = null; +var isClickDel = false; +var form = null; +var editableConfig = {editable:false}; +var curDiposableGood = null;// 当前扫描的一次性物品 +var curBatch = null; +var haveScannedDiposableGoods = false;// 已扫描过一次性物品条码 +var loadDiposableGoodsByBarcode = false; + + +var wareHouseStore = new Ext.data.Store({ + reader : new Ext.data.JsonReader({ + fields : [ + {name : 'id',mapping : 'id'}, + {name : 'name',mapping : 'name'}, + {name : 'orgUnitCode',mapping : 'orgUnitCode'} + ] + }), + listeners : { + load : function(store,records) { + var id = top.Ext.getCmp('warehouseID').getValue(); + var name = top.Ext.getCmp('warehouseName').getValue(); + if(records.length > 0 && (id == null || id == '')){ + id=records[0].data.id; + name = records[0].data.name; + } + top.Ext.getCmp('warehouse').setValue(id); + top.Ext.getCmp('warehouseID').setValue(id); + top.Ext.getCmp('warehouseName').setValue(name); + } + } +}); +var wareHouseFields = [ + {name : 'id'}, + {name : 'name'}, + {name : 'orgUnitCode'} + ]; +var WareHouseRecord = Ext.data.Record.create(wareHouseFields); +function removeGridItem(){ + var totalMoney = 0.0; + var rows = top.Ext.getCmp('returnGoodsItemGrid').getSelectionModel().getSelections();// 返回值为 + if (rows) { + for ( var i = 0; i < rows.length; i++) { + returnGoodsItemStore.remove(rows[i]); +// totalMoney = top.Ext.getCmp("totalMoney").getValue(); +// top.Ext.getCmp("totalMoney").setValue(accSubtr(totalMoney,accMul(rows[i].data.price,rows[i].data.amount))); + } + } + setTotalMoney(); +} + +var addReturnGoodsItem = Ext.data.Record.create([ + {name : 'id'}, + {name : 'tousseName'}, + {name : 'unit'}, + {name : 'batchID'}, + {name : 'disposableGoodsID'}, + {name : 'disposableGoodsStockID'}, + {name : 'disposableGoodsBatchID'}, + {name : 'disposableGoodsBatchStockID'}, + {name : 'identificationID'}, + {name : 'expensiveDisposablegoodsId'}, + {name : 'amount'}, + {name : 'amountCanReturn'}, + {name : 'barcode'}, + {name : 'batchNumber'}, + {name : 'isDelivery'}, + {name : 'price'}, + {name : 'fluctuationPrice'}, + {name : 'expDate'} +]); +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 diposableGoodsBatchNumStore = null; +var BatchRecord = null; +//单价数据源 +var priceStore = null; +var PriceRecord = null; + +//校验退货人科室是否有问题 +function isDepartValid(r){ + var v = true; + var departs = []; + var rootNode = top.Ext.getCmp('returnGoodsColumnTree').getRootNode(); + + rootNode.eachChild(function(tousseNode) { + // 有且只有二层节点(不包括根节点rootNode) + tousseNode.eachChild(function(tousseInstanceNode) { + var depart = tousseInstanceNode.attributes.settleAccountsDepartCode; + if(isUndefinedOrNullOrEmpty(depart)){ + depart = tousseInstanceNode.attributes.location; + } + //alert('depart='+depart); + departs.push(depart); +// if(typeof(departs[depart]) == 'undefined'){ +// ++departs.departCount; +// departs[depart] = depart; +// itemDepart = depart; +// }else{ +// +// } + + // 包实例节点 +// if (tousseInstanceNode.attributes.barcode != '') { +// exist = true; +// } + }); + }); + if(departs.length == 0){ + return true; + }else{ + var firstDepart = departs[0]; + for(var d=1;d 0){ + top.Ext.getCmp("batchNumber").setValue(batches[0].batchNumber); + curBatch = batches[0]; + // 出发选中事件 + if(fireSelect){ + combo.fireEvent('select', combo,diposableGoodsBatchNumStore.getAt(0),0); + } + } +} +// 设置价格 +function setPrices(prices) { + priceStore.removeAll(); + top.Ext.getCmp("combo_price").setValue(''); + if(typeof(prices) == 'undefined' || prices == null){ + return; + } + for(var i = 0;i 0){ + top.Ext.getCmp("combo_price").setValue(prices[0].fluctuationPrice); + } +} +//验证条码是否重复扫描 +function isBarcodeRepeat(barcode){ + if(barcode != null && barcode.length > 0){ + for ( var i = 0; i < returnGoodsItemStore.getCount(); i++) { + var record = returnGoodsItemStore.getAt(i); + var tempBarcode =record.get('barcode'); + if(barcode == tempBarcode){ + return true; + break; + } + } + } + return false; +} +//验证一次性物品是否重复 +function isDiposableGoodsRepeat(diposableGood,batch,priceAmount){ + for ( var i = 0; i < returnGoodsItemStore.getCount(); i++) { + var record = returnGoodsItemStore.getAt(i); + var price = record.get('price'); + var fluctuationPrice = record.get('fluctuationPrice'); + var barcode = record.get('barcode'); + + //alert('price='+price+',barcode='+barcode+',newprice='+priceAmount.price+',newbarcode='+batch.barcode); + if(barcode == batch.barcode && fluctuationPrice == priceAmount.fluctuationPrice){ + return true; + break; + } + } + return false; +} +//验证一次性物品是否重复 +function isExpensiveDisposablegoodsRepeat(diposableGood){ + for ( var i = 0; i < returnGoodsItemStore.getCount(); i++) { + var record = returnGoodsItemStore.getAt(i); + var price = record.get('price'); + var fluctuationPrice = record.get('fluctuationPrice'); + var barcode = record.get('barcode'); + + if(barcode == diposableGood.barcode){ + return true; + break; + } + } + return false; +} + +// 添加一次性物品 +function onAddDiposableGoodsClick(){ + // 判断批次和价格是否已选择 + var batchNumber = top.Ext.getCmp("batchNumber").getValue(); + var fluctuationPrice = top.Ext.getCmp("combo_price").getValue(); + if(batchNumber == ''){ + showResult('请选择批次!'); + return false; + } + if(fluctuationPrice+'' == ''){ + showResult('请选择价格!'); + return false; + } + var priceAmount = null; + var index = priceStore.find('fluctuationPrice', fluctuationPrice); + if(index == -1){ + showResult('请选择价格!'); + return false; + } + priceAmount = priceStore.getAt(index).data; + addDiposableGoodsItems(curDiposableGood,curBatch,priceAmount); + //top.Ext.getCmp("count1").getValue()); + +} +// +function addAndEditReturnDisposableGoodsByInvoicePlan(invoicePlanId){ + addAndEditReturnGoodsRecord('',true); +} +function addAndEditReturnGoodsRecord(id, enableBtn) { + editableConfig.editable = enableBtn; + var diposableGoodsStore = new Ext.data.Store({ + pageSize: 100, + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectSystem/diposableGoodsAction!getDiposableGoodsData.do?allItems=yes', + 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(diposableGoodsBatchNumStore == null){ + diposableGoodsBatchNumStore = new Ext.data.Store({ + reader : new Ext.data.JsonReader({ + fields : [ + {name : 'batchNumber'}, + {name : 'batchID'}, + {name : 'barcode'}, + {name : 'cost'}, + {name : 'expDate'} + ] + }) + }); + } + + if(BatchRecord == null){ + BatchRecord = Ext.data.Record.create([ + {name : 'batchNumber'}, + {name : 'disposableGoodsId'}, + {name : 'disposableGoodsStockId'}, + {name : 'disposableGoodsBatchId'}, + {name : 'disposableGoodsBatchStockId'}, + {name : 'barcode'}, + {name : 'cost'}, + {name : 'expDate'} + ]); + } + //单价数据源 + if(priceStore == null){ + priceStore = new Ext.data.Store({ + reader : new Ext.data.JsonReader({ + fields : [ + {name : 'price'}, + {name : 'fluctuationPrice'}, + {name : 'sentAmount'}, + {name : 'returnedAmount'}, + ] + }) + }); + } + if(PriceRecord == null){ + PriceRecord = Ext.data.Record.create([ + {name : 'price'}, + {name : 'fluctuationPrice'}, + {name : 'sentAmount'}, + {name : 'returnedAmount'}, + ]); + } + //该退货记录已经录入的退货详细信息 + var dataReader = new Ext.data.JsonReader({ + fields : [ + {name : 'id'}, + {name : 'tousseName'}, + {name : 'unit'}, + {name : 'disposableGoodsID'}, + {name : 'disposableGoodsStockID'}, + {name : 'disposableGoodsBatchID'}, + {name : 'disposableGoodsBatchStockID'}, + {name : 'identificationID'}, + {name : 'expensiveDisposablegoodsId'}, + {name : 'amount'}, + {name : 'amountCanReturn'}, + {name : 'barcode'}, + {name : 'batchNumber'}, + {name : 'price'}, + {name : 'fluctuationPrice'}, + {name : 'isDelivery'}, + {name : 'expDate'} + ] + }); + + //初始化加载器械包 + returnGoodsItemStore = new Ext.data.Store({ + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectSystem/returnGoodsRecordAction!loadReturnGoodsItemByInvoicePlanId.do', + method : 'POST' + }), + reader : dataReader, + listeners : { + load : function() { + setTotalMoney(); + } + } + }); + + function rowTotalRender(value, cellmeta, record, rowIndex, columnIndex, store) { + return accMul(record.data.fluctuationPrice,record.data.amount); + } + var isToDeliveryStore = new top.Ext.data.SimpleStore( { + fields : [ 'value'], + data : [['是'],['否']] + }); + + var cmArr = new Array(new Ext.grid.RowNumberer(), + {header : "条码",width : 80,dataIndex : 'barcode',menuDisabled:true}, + {id : 'autoWidth',header : "物品",dataIndex : 'tousseName',width : 180,menuDisabled:true}, + {header : "退货数量",width : 70,dataIndex : 'amount',menuDisabled:true, + editor : new top.Ext.form.NumberField({ + allowBlank : false, + disabled:!enableBtn, + allowNegative : false, + style : 'text-align: left', + allowDecimals : false + }) + }, + {header : "单位",width : 50,dataIndex : 'unit',menuDisabled:true}, + {header : "可退货数量",width : 70,dataIndex : 'amountCanReturn',menuDisabled:true}, + {header : "批次",width : 100,dataIndex : 'batchNumber',menuDisabled:true}, + {header : "单价",width : 50,dataIndex : 'fluctuationPrice',menuDisabled:true}, + {header : "失效日期",width : 80,dataIndex : 'expDate',menuDisabled:true}, + {header : "金额",width : 60,dataIndex : 'rowTotal',renderer:rowTotalRender,menuDisabled:true}, + {header : '删除',dataIndex:'button',width:60,menuDisabled:true, + renderer: function(v,p,record){ + var str = ''; + if(editableConfig.editable){ + str = ""; + } + + return str; + } + }); + + if(id){ + cmArr.splice(2,0,{header : "是否重发",dataIndex : 'isDelivery',width : 60,menuDisabled:true}); + }else{ + cmArr.splice(2,0,{header : "是否重发",dataIndex : 'isDelivery',width : 60,menuDisabled:true, + editor : new top.Ext.form.ComboBox({ + id : 'isDeliveryComboBox', + name : 'isDeliveryComboBox', + valueField : 'value', + displayField : 'value', + store : isToDeliveryStore, + forceSelection : true, + mode : 'local', + triggerAction : 'all' + }) + }); + } + + var cm = new top.Ext.grid.ColumnModel(cmArr); + + + returnGoodsItemStore.on("beforeload", function(thiz, options) { + thiz.baseParams["invoicePlanId"] = invoicePlanId; + thiz.baseParams["warehouseId"] = top.Ext.getCmp('warehouseID').getValue(); + }); + + /*var deptStore = new Ext.data.SimpleStore({ + fields : [ 'departName','departCoding' ], + url : WWWROOT + '/disinfectSystem/baseData/supplyRoomConfigAction!getAllOrgUnitName.do' + });*/ + + form = new top.Ext.FormPanel({ + id : 'returnGoodsRecordForm', + frame : true, + border : 0, + labelSeparator : ':', + bodyStyle : 'padding:5px 5px 0px 5px', + width : 950, + labelAlign:'right', + autoHeight : true, + autoScroll : true, + items : [{ + xtype:"fieldset", + layout:'column', + title :'退货记录信息', + autoHeight:true, + items:[{ + layout : 'column', + items : [{ + xtype : 'hidden', + name : 'id', + id : 'id' + },{ + xtype : 'hidden', + name : 'returnGoodsItemIds', + id : 'returnGoodsItemIds' + },{ + xtype : 'hidden', + name : 'departCoding', + id : 'departCoding' + },{ + xtype : 'hidden', + name : 'warehouseID', + id : 'warehouseID' + },{ + xtype : 'hidden', + name : 'warehouseName', + id : 'warehouseName' + },{ + xtype : 'hidden', + name : 'invoicePlanId', + id : 'invoicePlanId', + value:invoicePlanId + },{ + columnWidth : .5, + layout : 'form', + labelWidth : 80, + items : [{ + xtype : 'textfield', + fieldLabel : '操作人', + maxLength : '16', + id : 'operator', + name : 'operator', + allowBlank : false, + value : $Id('userName').value, + anchor : '80%', + readOnly : true, + cls:'fieldReadOnlyNoRemove' + }] + }, { + columnWidth : .5, + layout : 'form', + labelWidth : 70, + items : [{ + xtype : 'datefieldWithMin', + fieldLabel : '时间', + id : 'returnTime', + name : 'returnTime', + editable:false, + disabled:!editableConfig.editable, + allowBlank: false, + format:'Y-m-d H:i', +// value: new Date(), + anchor : '80%', + listeners : { + render : function() { //一次性物品的的退货时间,取服务器时间 cjr) + (!id) ? setStartDate(top.Ext, 'yyyy/MM/dd HH:mm', 'returnTime') : (function(){})(); + } + } + + }] + }, { + columnWidth : .5, + layout : 'form', + labelWidth : 80, + items : [{ + xtype : 'textfield', + fieldLabel : '退货人员工号', + id : 'returnOfPeopleBarcode', + name : 'returnOfPeopleBarcode', + disabled:!editableConfig.editable, + allowBlank : true, + listeners : { + specialkey : function(field,e){ + if(e.getKey() == 13){ + loadPeopleByStaffNum_forDiposableGoods(field); + } + } + }, + anchor : '80%' + }] + } ,{ + columnWidth : .5, + layout : 'form', + labelWidth : 70, + items : [{ + xtype : 'textfield', + fieldLabel : '退货人', + id : 'returnOfPeople', + name : 'returnOfPeople', + allowBlank : true, + anchor : '80%', + readOnly : true, + cls:'x-item-disabled' + }] + } , { + columnWidth : .5, + layout : 'form', + labelWidth : 80, + items : [{ + xtype : 'combo', + id : 'depart', + name : 'depart', + disabled:!editableConfig.editable, + queryParam : 'spell', + fieldLabel : '退货人科室', + queryParam : 'spell', + minChars : 0, + valueField : 'name', + displayField : 'name', + anchor : '80%', + store : departJsonStore, + forceSelection : true, + lazyInit : true, + triggerAction : 'all', + hideTrigger : true, + typeAhead : false, + allowBlank : false, + listeners :{ + select:function(combo, record, index ){ + var tem = record.data.id; + top.Ext.getCmp('departCoding').setValue(tem); + } + } + }] + } ,{ + columnWidth : .5, + layout : 'form', + labelWidth : 70, + items:[{ + xtype : 'combo', + fieldLabel : '退货仓库', + id : 'warehouse', + name : 'warehouse', + minChars : 0, + valueField : 'id', + displayField : 'name', + store : wareHouseStore, + forceSelection : true, + lazyInit : false, + mode : 'local', + triggerAction : 'all', + hideTrigger : true, + typeAhead : false, + allowBlank : false, + width : 100, + listeners : { + select : function(combo, record, index) { +// top.Ext.getCmp('warehouse').setValue(record.data.name); + top.Ext.getCmp('warehouseID').setValue(record.data.id); + top.Ext.getCmp('warehouseName').setValue(record.data.name); + + returnGoodsItemStore.removeAll(); + returnGoodsItemStore.load(); + setTotalMoney(); + }, + specialkey : function(field, ee) { + if (ee.getKey() == Ext.EventObject.ENTER) { + top.Ext.getCmp('remark').focus(); + } + } + } + }] + },{ + columnWidth : .5, + layout : 'form', + labelWidth : 80, + items : [{ + xtype : 'textfield', + fieldLabel : '总金额', + maxLength : '16', + id : 'totalMoney', + name : 'totalMoney', + anchor : '80%', + readOnly : true, + cls:'x-item-disabled' + }] + },{ + columnWidth : 1, + layout : 'form', + labelWidth : 80, + items : [{ + xtype : 'textarea', + height : 45, + fieldLabel : '备注', + id : 'remark', + name : 'remark', + disabled:!editableConfig.editable, + allowBlank : true, + anchor : '90%' + }] + }] + }] + },{ + xtype:"fieldset", + layout:'column', + title :'退货记录明细', + autoHeight:true, + items:[{ + layout : 'form', + columnWidth : 1, + items :[new top.Ext.grid.EditorGridPanel({ + id : 'returnGoodsItemGrid', + store : returnGoodsItemStore, + bodyStyle : 'border:1px solid #afd7af', + cm : cm, + width :920, + height : 270, + autoExpandColumn : 'autoWidth', + border : true, + frame : false, + viewConfig: { + forceFit:true + }, + clicksToEdit : 1,// 设置点击几次才可编辑 + selModel : new top.Ext.grid.RowSelectionModel({ + singleSelect : false + }), + listeners:{ + afteredit : function() { + setTotalMoney(); + } + } + })] + }] + }], + buttonAlign :'center', + buttons : [{ + text : '打印', + handler : function() { + var title = ""; + DWREngine.setAsync(false); + SupplyRoomConfigTableManager.getStartTimeObject(function(config){ + if(config != null){ + title = config.unitName; + } + }); + DWREngine.setAsync(true); + var operator = top.Ext.getCmp('operator').getValue(); + var returnTime = new Date(top.Ext.getCmp('returnTime').getValue()).format('Y-m-d'); + var depart = top.Ext.getCmp('depart').getValue(); + var totalMoney = top.Ext.getCmp('totalMoney').getValue(); + var remark = top.Ext.getCmp('remark').getValue(); + var returnGoodsItems = getReturnGoodsDetailGridDataToPrint(); + printReturnGoodsRecord(title,operator,returnTime,depart,totalMoney,remark,returnGoodsItems,0); + } + },{ + text : '保存', + id : 'saveBtn', + hidden:SSTS_ReturnGoodsRecord_Create && SSTS_ReturnGoodsRecord_Update, + disabled:!enableBtn, + handler : function(){ + top.Ext.MessageBox.confirm("请确认","是否保存"+ entityName + "信息?",function(btn) { + if(btn=='yes') { + if(!form.getForm().isValid()){ + showResult('请正确填写表单各值'); + return false; + } +// if(top.Ext.getCmp('returnOfPeople').getValue().length<1){ +// showResult('退货人信息不能为空'); +// return false; +// } + + if(returnGoodsItemStore.getCount()<1){ + showResult('退货详细信息列表不能为空'); + return false; + } + + //获取grid数据 + getReturnGoodsDetailGridData(); + top.Ext.getCmp("depart").enable(); + /*top.Ext.getCmp('returnOfPeople').setDisabled(false); + top.Ext.getCmp('depart').setDisabled(false);*/ +// return false; + form.form.submit({ + url : WWWROOT + '/disinfectSystem/returnGoodsRecordAction!saveReturnGoodsRecord.do', + method : 'POST', + waitMsg : '正在保存数据,请稍候', + waitTitle : '提交表单', + success : function(form, action) { + if(action.result.success){ + showResult('保存成功'); + } else if (action.result.error){ + showResult(action.result.error); + } else if(action.result.errMsg){ + showResult(action.result.errMsg); + } else { + showResult('保存失败'); + } +// grid.dwrReload(); + top.Ext.getCmp('returnGoodsRecordWin').close(); + document.location.href = WWWROOT+'/disinfectsystem/returnGoodsRecord/returnGoodsRecordView.jsp'; + }, + failure : function(form, action) { + top.Ext.getCmp("depart").disable();// 禁止修改科室 + if (action.result.error){ + showResult(action.result.error); + } else if(action.result.errMsg){ + showResult(action.result.errMsg); + } else { + showResult('保存失败'); + } + } + }); + } + }); + } + },{ + text : '取消', + handler : function() { + top.Ext.getCmp('returnGoodsRecordWin').close(); + } + }] + }); + + var win = new top.Ext.Window({ + id : 'returnGoodsRecordWin', + layout : 'fit', + title : entityName + '信息', + width : 930, + modal : true, +// autoHeight : true, + border : false, + height:580, + plain : true, + items : [ form ] + }); + win.show(); + + DWREngine.setAsync(false); + ReturnGoodsRecordTableManager.getInvoicePlanInfo(invoicePlanId,function(batchesStr){ + var invoicePlanInfo = top.Ext4.JSON.decode(batchesStr); + var warehouses = invoicePlanInfo.warehouses; + wareHouseStore.removeAll(); + for(var i=0;i 0){ + // 选中第一个 + var combo = top.Ext.getCmp("warehouse"); + combo.setValue(warehouses[0].id); + // 触发选中事件 + combo.fireEvent('select', combo,wareHouseStore.getAt(0),0); + } + top.Ext.getCmp('depart').setValue(invoicePlanInfo.depart); + top.Ext.getCmp('departCoding').setValue(invoicePlanInfo.departCoding); + + }); + DWREngine.setAsync(true); +} + +// 器械包,科室退货人为空时才能更改退货人科室 +function loadPeopleByStaffNum(staffNumField){ + var staffNum = staffNumField.getValue(); + if(staffNum){ + UserTableManager.getUserObjByName(staffNum,function(user){ + if(user){ + var fullName = user.split(",")[0]; + var orgUnitNames = user.split(",")[1]; + var orgUnitCodes = user.split(",")[2]; + top.Ext.getCmp('returnOfPeople').setValue(fullName);//设置退货人 + var currentDepart = getCurrentDepart(); + var currentDepartCoding = getCurrentDepartCoding(); + var resetDepart = true; + if(currentDepart != '' || currentDepartCoding != ''){ + resetDepart = false; + } + if(resetDepart){ + if(orgUnitNames){ + var orgUnitName = orgUnitNames.split(';')[0];//如果有多个,默认拿第一个,当前系统只有一个; + top.Ext.getCmp('depart').setValue(orgUnitName.substring(orgUnitName.lastIndexOf("-")+1));//设置科室 + } + if(orgUnitCodes){ + var orgUnitCode = orgUnitCodes.split(';')[0]; + top.Ext.getCmp('departCoding').setValue(orgUnitCode);//科室代码 + } + } + + }else{ + showResult('找不到该员工号所对应的人员信息'); + top.Ext.getCmp('returnOfPeople').setValue(); + top.Ext.getCmp('depart').setValue(); + top.Ext.getCmp('departCoding').setValue(); + } + }); + } + staffNumField.setValue(); +} +// 一次性物品 +function loadPeopleByStaffNum_forDiposableGoods(staffNumField){ + var staffNum = staffNumField.getValue(); + if(staffNum){ + UserTableManager.getUserObjByName(staffNum,function(user){ + if(user){ + var fullName = user.split(",")[0]; + var orgUnitNames = user.split(",")[1]; + var orgUnitCodes = user.split(",")[2]; + top.Ext.getCmp('returnOfPeople').setValue(fullName);//设置退货人 + var currentDepart = getCurrentDepart(); + var currentDepartCoding = getCurrentDepartCoding(); + var resetDepart = true; + if(currentDepart != '' || currentDepartCoding != ''){ + resetDepart = false; + } + if(resetDepart){ + if(orgUnitNames){ + var orgUnitName = orgUnitNames.split(';')[0];//如果有多个,默认拿第一个,当前系统只有一个; + top.Ext.getCmp('depart').setValue(orgUnitName.substring(orgUnitName.lastIndexOf("-")+1));//设置科室 + } + if(orgUnitCodes){ + var orgUnitCode = orgUnitCodes.split(';')[0]; + top.Ext.getCmp('departCoding').setValue(orgUnitCode);//科室代码 + } + } + + }else{ + showResult('找不到该员工号所对应的人员信息'); + top.Ext.getCmp('returnOfPeople').setValue(); + top.Ext.getCmp('depart').setValue(); + top.Ext.getCmp('departCoding').setValue(); + } + }); + } + staffNumField.setValue(); +} +//获取grid的数据 +function getReturnGoodsDetailGridData() { + var returnGoodsDetails = buildJSONStringFromStore(returnGoodsItemStore); + //alert(returnGoodsDetails); + top.Ext.getCmp('returnGoodsItemIds').setValue(returnGoodsDetails); +} + + +function getReturnGoodsDetailGridDataToPrint() { + var tousseIds = null; + for ( var i = 0; i < returnGoodsItemStore.getCount(); i++) { + var record = returnGoodsItemStore.getAt(i); + if (tousseIds == null) { + tousseIds = record.get('barcode') + '#&' + record.get('tousseName') + "#&" + record.get('amount') + '#&' + record.get('batchNumber') + '#&' + record.get('fluctuationPrice') + '#&' + record.get('expDate') + '#&'+ accMul(record.get('fluctuationPrice'),record.get('amount')); + } else { + tousseIds += "#@" + record.get('barcode') + '#&' + record.get('tousseName') + "#&" + record.get('amount') + '#&' + record.get('batchNumber') + '#&' + record.get('fluctuationPrice') + '#&' + record.get('expDate') + '#&' + accMul(record.get('fluctuationPrice'),record.get('amount')); + } + } + return tousseIds; +} + +function setReturnGoodsRecordForm(returnGoodsRecord){ + top.Ext.getCmp("id").setValue(returnGoodsRecord.id); + top.Ext.getCmp("operator").setValue(returnGoodsRecord.operator); + top.Ext.getCmp("depart").setValue(returnGoodsRecord.depart); + top.Ext.getCmp("returnTime").setValue(returnGoodsRecord.returnTime); +// Ext.getCmp("signStatus").setValue(returnGoodsRecord.signStatus); + top.Ext.getCmp("remark").setValue(returnGoodsRecord.remark); + top.Ext.getCmp("returnOfPeople").setValue(returnGoodsRecord.returnOfPeople); + top.Ext.getCmp("departCoding").setValue(returnGoodsRecord.departCoding); + var warehouse = top.Ext.getCmp("warehouse"); + if(warehouse != null){ + warehouse.setValue(returnGoodsRecord.warehouseName); + } +} + +//TODO 器械包退货 +/*********************************** 器械包退货 form start****************************************/ +function parseToInt(v) { + if (typeof(v) == "number") + return v; + var parseIntV = 0; + try { + parseIntV = parseInt(v, 10); + if (isNaN(parseIntV)) { + parseIntV = 0; + } + } catch (e) { + } + return parseIntV; +} + +function returnNewParentNodeOfModifyAmount(pNode, amount,price){ + var difAmount = parseToInt(pNode.attributes.amount) + parseToInt(amount); + if(difAmount <= 0){ + return false; + }else{ + return createParentNode(pNode.attributes.recordId, pNode.attributes.tousseName, difAmount,price,pNode.attributes.isDelivery, pNode.attributes.isPacking); + } +} + +function returnNewParentNodeOfModifyIsDelivery(pNode, isDelivery){ + if (isDelivery != '是'){ + isDelivery = '否'; + } + var newPNode = createParentNode(pNode.attributes.recordId, pNode.attributes.tousseName, pNode.attributes.amount,pNode.attributes.price, isDelivery,pNode.attributes.isPacking); + pNode.eachChild(function(cNode){ + //newPNode.appendChild(createChildNode(cNode.attributes.barcode)); + newPNode.appendChild(createChildNode(cNode.attributes.tousseInstance)); + }); + return newPNode; +} + +function returnNewParentNodeOfModifyIsPacking(pNode, isPacking){ + if (isPacking != '是'){ + isPacking = '否'; + } + var newPNode = createParentNode(pNode.attributes.recordId, pNode.attributes.tousseName, pNode.attributes.amount,pNode.attributes.price, pNode.attributes.isDelivery, isPacking); + pNode.eachChild(function(cNode){ + //newPNode.appendChild(createChildNode(cNode.attributes.barcode)); + newPNode.appendChild(createChildNode(cNode.attributes.tousseInstance)); + }); + return newPNode; +} +// 复制父节点 +function copyParentNode(copyFromNode){ + return createParentNodeFrom(copyFromNode); +} +function deleteReturnedGoodsColumnTreeItem(clickNode) { + var pNode = clickNode.parentNode; + clickNode.remove(); + if(clickNode.isLeaf()){ + // 调整数量 + adjustAmount(pNode,-1); + if(pNode.attributes.amount <= 0){ + // 删除整个器械包目录 + pNode.remove(); + }else{ + var ppNode = pNode.parentNode; + var newParentNode = copyParentNode(pNode); + ppNode.replaceChild(newParentNode,pNode); + } +// var newParentNode = returnNewParentNodeOfModifyAmount(pNode, -1); +// if(!newParentNode){ +// pNode.remove(); +// } + } +} +// 刷新数量 +// 调整数量 +function adjustAmount(node,amount){ + node.attributes.amount += amount; +} +function getChildNodesAmountOrBarcode(pNode, isGetBarcode){ + if(pNode.isLeaf()){ + if(isGetBarcode){ + return ''; + }else{ + return 1; + } + }else{ + if(isGetBarcode){ + var barcode = ''; + pNode.eachChild(function(tousseNode) { + barcode += '@#' + tousseNode.attributes.barcode; + }); + return barcode; + }else{ + if(pNode.hasChildNodes()){ + return pNode.childNodes.length; + }else{ + return 0; + } + } + } +} + +function setIsClickDel(v) { + isClickDel = (v == 1 ? true : false); +} + +function checkStatus(v, escapeTousseName, attr){ + var rootNode = top.Ext.getCmp('returnGoodsColumnTree').getRootNode(); + var childNode = rootNode.findChild('tousseName',unescape(escapeTousseName)); + if(childNode){ + var newNode; + if(attr=='isDelivery'){ + newNode = returnNewParentNodeOfModifyIsDelivery(childNode, v); + }else{ + newNode = returnNewParentNodeOfModifyIsPacking(childNode, v); + } + rootNode.replaceChild(newNode, childNode); + } +} + +//获取器械包退货明细信息 +//格式为:ID@#包名@#数量@#是否重新发货@#是否重新装配@#条码...@;ID@#包名@#数量@#是否重新发货@#是否重新装配@#条码... +function getReturnTousseDetailGridData(isGetBarcode) { + var returnTousseItemStr = ''; + var rootNode = top.Ext.getCmp('returnGoodsColumnTree').getRootNode(); + + rootNode.eachChild(function(tousseNode) { + if(returnTousseItemStr){ + returnTousseItemStr += '@;'; + } + var attr = tousseNode.attributes; + returnTousseItemStr += (attr.recordId + '@#' + attr.tousseName + '@#' + attr.amount + '@#' + attr.isDelivery + '@#' + attr.isPacking + "@#" + attr.price); + if(isGetBarcode){ + returnTousseItemStr += getChildNodesAmountOrBarcode(tousseNode, true); + } + }); + return returnTousseItemStr; +} + +//把器械包添加到tree中 +function addScanningTousseItemToTree(tousseInstance){ + var barcode = tousseInstance.barcode; + var tousseName = tousseInstance.tousseName; + + var amount = 1; + var price = tousseInstance.fluctuationPrice; + // 如果是固定条码 + var tousseFixedBarcode = tousseInstance.tousseFixedBarcode; + if(!isUndefinedOrNull(tousseFixedBarcode) && tousseFixedBarcode){ + addReturnTousseItemToTree('',tousseName,1,price); + return; + } + var departCoding = tousseInstance.settleAccountsDepartCode; + var depart = tousseInstance.settleAccountsDepart; + if(isUndefinedOrNullOrEmpty(departCoding)){ + departCoding = tousseInstance.location; + depart = tousseInstance.locationForDisplay; + } + // 校验退货人的科室是否和当前器械包的一致 + //var curDepartCoding = top.Ext.getCmp('departCoding').getValue(); + //alert(curDepartCoding) + //alert(departCoding) + //alert(depart) +// if(curDepartCoding != '' ){ +// //alert(departCoding) +// if((curDepartCoding != undefined && curDepartCoding != null && curDepartCoding != '') && (curDepartCoding != tousseInstance.location)){ +// showResult("器械包科室和退货人科室不一致!"); +// return false; +// } +// }else{ +// top.Ext.getCmp('departCoding').setValue(departCoding); +// top.Ext.getCmp('depart').setValue(depart); +// } + top.Ext.getCmp('departCoding').setValue(departCoding); + top.Ext.getCmp('depart').setValue(depart); + + //是否为包实例 --》是:包实例 否:包定义 + var isTousseInstance = (barcode?true:false); + var flag = true;//子循环标识 + var tousseNodeExist = false/*包定义节点是否存在*/, tousseInstanceNodeExist = false/*包实例节点是否存在*/; + var rootNode = top.Ext.getCmp('returnGoodsColumnTree').getRootNode(); + rootNode.eachChild(function(tousseNode) { + // 有且只有二层节点(不包括根节点rootNode) + if (tousseNode.attributes.tousseName == tousseName) { + tousseNodeExist = true;//找到包定义节点 + + if(isTousseInstance){//如果是有条码,则为包实例 + + //查找当前包定义下的所有包实例(查重) + tousseNode.eachChild(function(tousseInstanceNode) { + // 包实例节点 + if (tousseInstanceNode.attributes.barcode == barcode) { + showResult("该条码的器械包实例已存在!"); + tousseInstanceNodeExist = true;//找到包实例节点 + return true; + } + }); + + if(!tousseInstanceNodeExist){ + //在当前包定义下添加一个新的包实例节点 + //var mynode = createChildNode(barcode); + var mynode = createChildNode(tousseInstance); + // 把新增的子节点追加到父节点中 + var newPNode = returnNewParentNodeOfModifyAmount(tousseNode, 1,price); + tousseNode.eachChild(function(cNode){ + //newPNode.appendChild(createChildNode(cNode.attributes.barcode)); + newPNode.appendChild(createChildNode(cNode.attributes.tousseInstance)); + }); + newPNode.appendChild(mynode); + rootNode.replaceChild(newPNode, tousseNode); + } + return true; + + }else{//否则,修改包定义数量 + var newPNode = returnNewParentNodeOfModifyAmount(tousseNode, amount,price); + newPNode.appendChild(tousseNode.childNodes); + // 替换原子节点 + rootNode.replaceChild(newPNode, tousseNode); + return true; + } + } + + }); + + if(tousseNodeExist){ + return true; + } + + if(isTousseInstance){ + amount = 1; + } + + var tousseNode = createParentNode(0, tousseName, amount,price, '否', '否'); + + if(isTousseInstance){ + //tousseInstanceNode = createChildNode(barcode); + tousseInstanceNode = createChildNode(tousseInstance); + // 绑定到包定义节点 + tousseNode.appendChild(tousseInstanceNode); + } + + rootNode.appendChild(tousseNode); + + return true; +} +// 是否已经有包实例 +function isTousseInstanceExist(){ + + var exist = false; + var rootNode = top.Ext.getCmp('returnGoodsColumnTree').getRootNode(); + rootNode.eachChild(function(tousseNode) { + // 有且只有二层节点(不包括根节点rootNode) + tousseNode.eachChild(function(tousseInstanceNode) { + // 包实例节点 + if (tousseInstanceNode.attributes.barcode != '') { + exist = true; + } + }); + }); + //alert('isTousseInstanceExist='+exist); + return exist; +} +//把器械包添加到tree中 +function addReturnTousseItemToTree(barcode, tousseName, amount,price,departCoding,depart){ + + if(!tousseName) { + showResult("请输入器械包名称!"); + return false; + } + + if(amount == "" || amount < 1) { + showResult("请输入数量且不能小于0!"); + return false; + } + + //是否为包实例 --》是:包实例 否:包定义 + var isTousseInstance = (barcode?true:false); + var tousseNodeExist = false/*包定义节点是否存在*/, tousseInstanceNodeExist = false/*包实例节点是否存在*/; + var rootNode = top.Ext.getCmp('returnGoodsColumnTree').getRootNode(); + var replaceNodeNew = null; + var replaceNodeOld = null; + var nodeNew = null; + rootNode.eachChild(function(tousseNode) { + // 有且只有二层节点(不包括根节点rootNode) + if (tousseNode.attributes.tousseName == tousseName) { + tousseNodeExist = true;//找到包定义节点 + + replaceNodeOld = tousseNode; + + return true; + } + + }); + if(replaceNodeOld != null){ + adjustAmount(replaceNodeOld, amount); + var newPNode = copyParentNode(replaceNodeOld); + rootNode.replaceChild(newPNode, replaceNodeOld); + return; + } + if(tousseNodeExist){ + return true; + } + + + var tousseNode = createParentNode(0, tousseName, amount,price, '否', '否'); + + if(isTousseInstance){ + tousseInstanceNode = createChildNode(barcode); + // 绑定到包定义节点 + tousseNode.appendChild(tousseInstanceNode); + } + + rootNode.appendChild(tousseNode); + + return true; +} + +/** + * 创建子节点 public + */ +//function createChildNode(barcode) { +// return createNodeByParam(false, 0, '', 1,0.00, barcode, '', ''); +//} +function createChildNode(tousseInstance) { + // 创建子节点 + var node = new Ext.tree.TreeNode({ + id : Ext.id(), + text : '', + iconCls : 'task', + uiProvider : Ext.tree.ColumnNodeUI, + leaf : true, + expanded : true + }); + node.attributes.amount = 1; + node.attributes.barcode = tousseInstance.barcode; + // 科室编码 + node.attributes.departCoding = tousseInstance.location; + node.attributes.location = tousseInstance.location; + node.attributes.settleAccountsDepartCode = tousseInstance.settleAccountsDepartCode; + node.attributes.settleAccountsDepart = tousseInstance.settleAccountsDepart; + node.attributes.recordId = 0; + node.attributes.tousseInstance = tousseInstance; + return node; +} + +/** + * 创建父节点 public + */ +function createParentNode(recordId, tousseName, amount,price, isDelivery, isPacking){ + return createNodeByParam(true, recordId, tousseName, amount,price, '', isDelivery, isPacking); +} +function createParentNodeFrom(pNode){ + //alert(111) + var node; + // 创建父节点 + node = new Ext.tree.TreeNode({ + id : Ext.id(), + text : pNode.tousseName, + cls : 'master-task', + iconCls : 'task-folder', + uiProvider : Ext.tree.ColumnNodeUI, + leaf : pNode.leaf, + expanded : true + }); + node.attributes.amount = pNode.attributes.amount; + node.attributes.tousseName = pNode.attributes.tousseName; + node.attributes.isDelivery = pNode.attributes.isDelivery; + node.attributes.isPacking = pNode.attributes.isPacking; + node.attributes.price = pNode.attributes.price; + node.attributes.recordId = pNode.attributes.recordId; + + pNode.eachChild(function(cNode){ + var cNodeNew = createChildNode(cNode.attributes.tousseInstance); + node.appendChild(cNodeNew); + }); + return node; +} +//private +function createNodeByParam(isParentNode, recordId, tousseName, amount,price, barcode, isDelivery, isPacking) { + var node; + if (isParentNode == true) { + // 创建父节点 + node = new Ext.tree.TreeNode({ + id : Ext.id(), + text : tousseName, + cls : 'master-task', + iconCls : 'task-folder', + uiProvider : Ext.tree.ColumnNodeUI, + leaf : false, + expanded : true + }); + node.attributes.amount = amount; + node.attributes.tousseName = tousseName; + node.attributes.isDelivery = isDelivery; + node.attributes.isPacking = isPacking; + node.attributes.price = price; + } else { + // 创建子节点 + node = new Ext.tree.TreeNode({ + id : Ext.id(), + text : tousseName, + iconCls : 'task', + uiProvider : Ext.tree.ColumnNodeUI, + leaf : true, + expanded : true + }); + node.attributes.amount = 1; + node.attributes.barcode = barcode; + } + node.attributes.recordId = recordId; + // ********************** 节点保存的属性值 ****************************// + return node; +} +Ext.onReady(function() { + Ext.QuickTips.init(); + Ext.BLANK_IMAGE_URL = WWWROOT + '/ext/resources/images/default/s.gif'; + + addAndEditReturnDisposableGoodsByInvoicePlan(invoicePlanId); +}); +/*********************************** 器械包退货 form end****************************************/