Index: ssts-web/src/main/webapp/disinfectsystem/invoice/expressInvoiceView.jsp =================================================================== diff -u --- ssts-web/src/main/webapp/disinfectsystem/invoice/expressInvoiceView.jsp (revision 0) +++ ssts-web/src/main/webapp/disinfectsystem/invoice/expressInvoiceView.jsp (revision 20509) @@ -0,0 +1,138 @@ +<%@page import="java.text.SimpleDateFormat"%> +<%@page import="com.forgon.disinfectsystem.entity.tousseitem.TousseItem"%> +<%@page import="java.util.Calendar"%> +<%@page import="com.forgon.disinfectsystem.entity.invoicemanager.InvoicePlan"%> +<%@ page contentType="text/html; charset=UTF-8"%> +<%@ include file="/common/taglibs.jsp"%> +<%@ include file="/common/includeExtJsAndCss.jsp"%> + + + +发货计划单管理 + + + + +<% + request.setAttribute("userName",AcegiHelper.getLoginUser().getUserFullName()); + + //设置日期定义 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Calendar cal = Calendar.getInstance(); + String today = sdf.format(cal.getTime());//今天 + pageContext.setAttribute("today", today + ";" + today); + + cal.add(Calendar.DATE, -1); + String yesterday = sdf.format(cal.getTime());//昨天 + pageContext.setAttribute("yesterday", yesterday + ";" + yesterday); + + cal.add(Calendar.DATE, -1); + String threeDaysAgo = sdf.format(cal.getTime());//前天(近三天的起始日) + pageContext.setAttribute("lastThreeDays", threeDaysAgo + ";" + today); + + cal.add(Calendar.DATE, -4); + String sixDaysAgo = sdf.format(cal.getTime());//6天前(近一周的起始日) + pageContext.setAttribute("lastSixDays", sixDaysAgo + ";" + today); + +%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + + \ No newline at end of file Index: ssts-web/src/main/webapp/disinfectsystem/invoice/expressInvoiceView.js =================================================================== diff -u --- ssts-web/src/main/webapp/disinfectsystem/invoice/expressInvoiceView.js (revision 0) +++ ssts-web/src/main/webapp/disinfectsystem/invoice/expressInvoiceView.js (revision 20509) @@ -0,0 +1,422 @@ +var grid; +var INVOICE_FORM_OPEN_MODE_CLICKITEM = 'clickItem'; +var INVOICE_FORM_OPEN_MODE_SCANBARCODE = 'barcode'; +var INVOICE_FORM_OPEN_MODE_CLICKRETURNRECORD = 'clickReturnRecord'; +/** + * 刷新列表 + * @param isSetDateValue 是否要设置开始时间和结束时间 + * @param isLoad 是否要重新加载 + */ +var selectedApplyDate; +var selectedTousseType; +var appFormType = ''; +var invoiceDepartGroups = ''; +var appDepartCode = ''; +//申请科室Store +var appDepartJsonStore = new Ext.data.Store({ + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectSystem/baseData/supplyRoomConfigAction!getApplicationDepartJson.do', + method : 'POST' + }), + reader : new Ext.data.JsonReader({ + root : 'data' + },[ + {name : 'id',mapping : 'id'}, + {name : 'departCode',mapping : 'departCode'}, + {name : 'name',mapping : 'name'} + ] + ) +}); + +function processListParams(isSetDateValue,isLoad){ + selectedApplyDate = Ext.getCmp('applyDate').getValue(); + selectedTousseType = Ext.getCmp('tousseType').getValue(); + + appDepartCode = Ext.getCmp('appDepart').getValue(); + if(!isUndefinedOrNullOrEmpty(appDepartCode)){ + invoiceDepartGroups = appDepartCode; + }else{ + invoiceDepartGroups = Ext.getCmp('invoiceDepartGroup').getValue(); + } + var startDate = Ext.getCmp('startDate'); + var endDate = Ext.getCmp('endDate'); + + appFormType = Ext.getCmp('appFormType').getValue(); + if (!isUndefinedOrNullOrEmpty(isSetDateValue) && isSetDateValue == true){ + var dateArray = selectedApplyDate.split(';'); + startDate.setValue(dateArray[0]); + endDate.setValue(dateArray[1] ? dateArray[1] : ''); + } + // if (!isUndefinedOrNullOrEmpty(isLoad) && isLoad == true){ + var startDateValue = startDate.value; + var endDateValue = endDate.value; + if (!isUndefinedOrNullOrEmpty(startDateValue) && !isUndefinedOrNullOrEmpty(endDateValue)){ + if (checkEtGreaterThanSt(endDateValue,startDateValue)){ + Ext.Msg.alert('警告','结束时间不能少于开始时间!'); + return; + } + selectedApplyDate = startDateValue.concat(';').concat(endDateValue); + } +} +function refreshList(isSetDateValue,isLoad){ + processListParams(isSetDateValue,isLoad); + var store = grid.getStore(); + store.baseParams['departCode'] = invoiceDepartGroups; + store.baseParams['applyDate'] = selectedApplyDate; + store.baseParams['tousseType'] = selectedTousseType; + store.baseParams['appFormType'] = appFormType; + //刷新列表界面 + store.load(); + // } +} + + +/** + * 修改记录 + * modifyRecord函数 触发modify函数调用,并传入当前列的值以及record.data对象 + * 页面中需要定义 modify(v,data) 函数 + */ +function callModifyFunction(){ + var records = grid.getSelectionModel().getSelections(); + if (records.length == 0) { + showResult("请选择发货计划单!"); + return false; + } + if (records.length > 1) { + showResult("一次只能修改一个发货计划单!"); + return false; + } + var departCode = records[0].data['departCode']; + var depart = records[0].data['depart']; + openMode = INVOICE_FORM_OPEN_MODE_CLICKITEM; + addAndEditInvoicePlan(departCode,depart); +} +/** + * 通过扫描条码打开发货计划单。条码可以是科室条码(不是科室编码),也可以是单号 + */ +var openMode = INVOICE_FORM_OPEN_MODE_CLICKITEM; +var invoicePlanOpening = false; +var v_callback_yes = null; +var v_callback_no = null; +function globalOnKeyDownProcessor(barcode){ + if(barcode == BARCODE_ACTION_YES){ + if(v_callback_yes){ + v_callback_yes(); + } + return; + }else if(barcode == BARCODE_ACTION_NO){ + if(v_callback_no){ + v_callback_no(); + } + return; + } + openInvoicePlanByBarcode(barcode); +} +function openInvoicePlanByBarcode(barcode){ + if(isUndefinedOrNullOrEmpty(barcode)){ + showResult("请扫描科室条码或申请单条码"); + return; + } + if(invoicePlanOpening){ + showResult("申请单正在打开,请勿扫描太快!"); + return; + } + invoicePlanOpening = true; + var store = grid.getStore(); + var departCode = store.baseParams['departCode']; + var applyDate = store.baseParams['applyDate']; + var tousseType = store.baseParams['tousseType']; + Ext.Ajax.request({ + url : WWWROOT + '/disinfectSystem/invoicePlanAction!getScanResult.do', + params : {barcode : barcode,departCode:departCode,applyDate:applyDate,tousseType:tousseType}, + success : function(response, options) { + invoicePlanOpening = false; + var result = Ext.decode(response.responseText); + if(result){ + if(result.success){ + openMode = INVOICE_FORM_OPEN_MODE_SCANBARCODE; + addAndEditInvoicePlan(result.data.departCode,result.data.depart,result.data.invoicePlanId); + showResult(result.data.depart + "的发货单"); + }else{ + showResult(result.message); + } + } + }, + failure : function(form, action) { + invoicePlanOpening = false; + if(action.result && action.result.message){ + showResult(action.result.message); + } + } + }); +} + +/** + * 创建申请单下拉框 + * @returns {Ext.form.ComboBox|Ext4.form.ComboBox} + */ +function createAppFormCombo() { + var appFormModel = sstsConfig.appFormModel || [ + ['全部申请单', ''] + ,['一次性物品申请单', '一次性物品申请单'] + ,['器械包申请单', '器械包申请单'] + ,['消毒物品申请单', '消毒物品申请单'] + ,['外来器械包申请单', '外来器械包申请单'] + ,['自定义器械包申请单', '自定义器械包申请单'] + ,['借物单', '借物单'] + ,['代理灭菌单', '代理灭菌单'] + ,['外部器械包代理灭菌申请单', '外部器械包代理灭菌申请单'] + ,['回收申请单', '回收申请单'] + ,['手术预约申请单', '手术预约申请单'] + ]; + var appFormStore = new Ext.data.SimpleStore({ + data: appFormModel, + fields: ['key', 'value'] + }); + var comboConfig = { + id: 'appFormType', + name: 'appFormType', + emptyText: '请选择申请单类型', + mode: 'local', + store: appFormStore, + listeners: { + select: function (combo, record, index) { + refreshList(); + } + } + }; + return ext2CompUtil.getComboBuilder().getCombo(comboConfig); +} + +/** + * 请求服务器,生成时间筛选对应的值 + * @returns {[*,*,*,*,*]} + */ +function getTimeComboData() { + var dateHelper = new DateHelper(); + var applyDateDataArray = [['全部', '']]; + var format = sstsConfig.timeSearchFmt ? 'yyyy-MM-dd HH:mm' : 'yyyy-MM-dd'; + var url = WWWROOT + '/system/serverTimeAction!getInvoicePlanComboTime.do'; + dateHelper.getServerTimeByJQ(format, Ext, url, function (result) { + var time = result.time; + applyDateDataArray.push(['今天', time.todayTime]); + //花都区人民医院要求:时间选择增加今天上午和下午 + if (sstsConfig.showMorAndAf){ + applyDateDataArray.push(['今天上午', time.todayMorningTodayTime]); + applyDateDataArray.push(['今天下午', time.todayAfternoonTodayTime]); + } + applyDateDataArray.push(['昨天', time.yesterdayTodayTime]); + applyDateDataArray.push(['近三天', time.threeDayBeforeTodayTime]); + applyDateDataArray.push(['近一周', time.thisWeekTodayTime]); + }); + return applyDateDataArray; +} +Ext.onReady(function() { + Ext.QuickTips.init(); + if(!isUndefinedOrNullOrEmpty(param_openMode)){ + openMode = param_openMode; + } + function renderCallModifyFunction(v, p, record){ + return "" + v + ""; + } + + var departGroupStore = new Ext.data.SimpleStore({ + fields : ['id', 'shift','departCode' ], + url : WWWROOT + '/disinfectSystem/invoiceDepartmentAction!loadDepartGroup.do' + }); + + departGroupStore.on('load', function(){ + + ShiftDef = Ext.data.Record.create([ + {name: "id", type: "string"}, + {name: "shift", type: "string"}, + {name: "departCode", type: "string"} + ]); + var record = new ShiftDef({ + id: '', + shift: "全部", + departCode: "" + }); + + departGroupStore.insert(0, record); + }); + + var selectModel = new Ext.grid.CheckboxSelectionModel(); + grid = new Ext.grid.GridPanel({ + store : new Ext.data.Store({ + autoLoad: false, + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectSystem/invoicePlanAction!getDepartInvoiePlansByDepartCodes.do', + method : 'POST' + }), + reader : new Ext.data.JsonReader({ + fields : [ + {name : 'departCode'} + ,{name : 'depart'} + ,{name : 'remark'} + ,{name : 'urgency'} + ] + }) + , sortInfo: { + field: 'urgency', + direction: 'DESC' // 'ASC'or 'DESC' + } + }), + height : 325, + width : 485, + bodyStyle : 'border:1px solid #afd7af', + sm : selectModel, + cm : new top.Ext.grid.ColumnModel([selectModel, + {header : "紧急度",width : 20,dataIndex : 'urgency', renderer : urgencyIconRender3}, + {header : "科室",width : 50,dataIndex : 'depart',menuDisabled:true,renderer : renderCallModifyFunction}, + {id:'remark',header : "备注",width : 130,dataIndex : 'remark',menuDisabled:true} + ]), + autoExpandColumn : 'remark', + frame : false, + viewConfig: { + forceFit:true, + //是否隔行换色 + stripeRows: false, + getRowClass : function(record,rowIndex,rowParams,store){ + //借物单高亮 + var remark = record.get('remark'); + if (remark.indexOf("借物单") != -1){ + return 'BorrowList'; + } + } + }, + loadMask:{msg:'正在加载,请稍候...'}, + title : '发货计划列表', + tbar : [{ + text : '科室分组:' + },{ + xtype : 'combo', + id : 'invoiceDepartGroup', + name : 'invoiceDepartGroup', + valueField : 'departCode', + displayField : 'shift', + allowBlank : false, + editable : false, + emptyText:'请选择科室分组', + width : 120, + store : departGroupStore, + forceSelection : true, + triggerAction : 'all', + listeners : { + select : function(combo, record, index){ + refreshList(); + } + }, + anchor : '95%' + },{ + text : '申请日期:' + },{ + xtype : 'combo', + id : 'applyDate', + name : 'applyDate', + valueField : 'value', + displayField : 'key', + allowBlank : true, + editable : false, + width : 120, + emptyText:'请选择申请单日期', + mode:'local', + store : new Ext.data.SimpleStore({ + data: getTimeComboData(), + fields:['key','value'] + }), + forceSelection : true, + triggerAction : 'all', + listeners : { + select : function(combo, record, index){ + refreshList(true); + } + }, + anchor : '95%' + },{ + text : '开始日期:' + },{ + xtype : sstsConfig.timeSearchFmt ? 'datefieldWithMin' : 'datefield', + fieldLabel : '开始日期', + name : 'startDate', + format : sstsConfig.timeSearchFmt || 'Y-m-d', + id : 'startDate', + readOnly : false, + editable : false, + width : sstsConfig.timeSearchFmt ? 150 : 100 + },{ + text : '结束日期:' + },{ + xtype : sstsConfig.timeSearchFmt ? 'datefieldWithMin' : 'datefield', + fieldLabel : '结束日期', + name : 'endDate', + id : 'endDate', + readOnly : false, + editable : false, + // altFormats: sstsConfig.timeSearchFmt || 'Y-m-d|Y-n-j|y-n-j|y-m-j|y-m-d|y-n-d|Y-n-d|Y-m-j|Ymd|Ynj|ynj|ymj|ymd|ynd|Ynd|Ymj|Y/m/d|Y/n/j|y/n/j|y/m/j|y/m/d|y/n/d|Y/n/d|Y/m/j', + format : sstsConfig.timeSearchFmt || 'Y-m-d', + width : sstsConfig.timeSearchFmt ? 150 : 100 + }, { + text : '物品类型:' + },{ + xtype : 'multiSelect', + id : 'tousseType', + name : 'tousseType', + valueField : 'value', + displayField : 'key', + allowBlank : true, + editable : false, + fieldLabel:'类型', + width : 150, + emptyText:'请选择物品类型', + mode:'local', + store : new Ext.data.SimpleStore({ + data:tousseTypeDataArray, + fields:['key','value'] + }), +// forceSelection : true, + triggerAction : 'all', + listeners : { + select : function(combo, record, index){ + refreshList(); + } + }, + anchor : '95%' + },{ + text : '刷新列表', + iconCls : 'btn_ext_refresh1', + handler : function() { + refreshList(false,true); + } + }], + listeners: { + render : function() { + // 自动加载列表 + Ext.getCmp('tousseType').selectAll(); + refreshList(); + } + } + + }); + + var viewport = new Ext.Viewport({ + layout:'border', + items:[{ + region:'center', + margins:'0 5 5 0', + xtype : 'panel', + autoScroll:true, + layout: 'fit', + items:grid + }] + }); + g_stopDefault = false; + //globalOnKeyDown(globalOnKeyDownProcessor); + globalOnKeyDown(openInvoicePlanByBarcode); + window.focus(); + + // 自动打开科室发货界面 + if(openMode == INVOICE_FORM_OPEN_MODE_CLICKRETURNRECORD && !isUndefinedOrNullOrEmpty(returnRecordId)){ + addAndEditInvoicePlan(param_departCode,param_depart); + } +}); \ No newline at end of file Index: ssts-web/src/main/webapp/disinfectsystem/invoice/expressInvoiceForm.js =================================================================== diff -u --- ssts-web/src/main/webapp/disinfectsystem/invoice/expressInvoiceForm.js (revision 0) +++ ssts-web/src/main/webapp/disinfectsystem/invoice/expressInvoiceForm.js (revision 20509) @@ -0,0 +1,2198 @@ +var sendOutGoodsStore; +var recyclingapplicationStore; +//定义首篮筐的label变量 +var beginBarcodeLabel = '扫描条码:'; +var hiddenEndBarcode = true;//隐藏尾篮筐 +var defaultFocusedFieldOnInvoiceForm = 'scanText'; +var lastLoadWarehouseId = null; +var wareHouseStoreLoaded = false; +var recyclingapplicationStoreLoaded = false; +var postInitDataTimer = null; +var confirmSaveWin = null; +var isScanAmountEqualsAppAmountConfirmed = false; +var wareHouseStore = new Ext.data.Store({ + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectSystem/baseData/wareHouseAction!getWareHouseData.do', + method : 'POST' + }), + reader : new Ext.data.JsonReader({ + totalProperty : 'totalCount', + root : 'data' + }, [ + {name : 'id',mapping : 'id'}, + {name : 'name',mapping : 'name'}, + {name : 'orgUnitCode',mapping : 'orgUnitCode'}, + ]), + listeners : { + load : function(store,records) { + var id = top.Ext.getCmp('sourceWarehouseId').getValue(); + //var name = top.Ext.getCmp('sourceWarehouseName').getValue(); + if(records.length > 0 && (id == null || id == '')){ + //id=records[0].data.id; + //name = records[0].data.name; + var combo = top.Ext.getCmp("warehouse"); + // 触发选中事件 + combo.fireEvent('select', combo,records[0],0); + } + wareHouseStoreLoaded = true; + //top.Ext.getCmp('warehouse').setValue(id); + //top.Ext.getCmp('sourceWarehouseId').setValue(id); + //top.Ext.getCmp('sourceWarehouseName').setValue(name); + } + } +}); + +if(sstsConfig.disableLoadToVirtualBasket == false){ + beginBarcodeLabel = '条码/篮筐(首):'; + hiddenEndBarcode = false;//显示尾篮筐 +} + +//条码扫描模式(单个条码逐个扫描或首尾条码段扫描两种模式) +var currentScanMode = "single"; +if(sstsConfig.invoicePageScanMode && sstsConfig.invoicePageScanMode != null){ + currentScanMode = sstsConfig.invoicePageScanMode; +} + +function getDefaultAmount(v,p,record){ + if (v==null || v.length <= 0){ + return 0; + }else{ + return v; + } +} +function formatScannedAmount(v,p,record){ + var tousseAmount = 0; + if (v==null || v.length <= 0){ + tousseAmount = 0; + }else{ + tousseAmount = v; + } + var goodsType = record.get('goodsType'); + var isCleanedEntirely = record.get('isCleanedEntirely'); + var scannedMaterialAmount = record.get('scannedMaterialAmount'); + if (scannedMaterialAmount == null){ + scannedMaterialAmount = 0; + } + if((goodsType == '消毒物品') && (isCleanedEntirely == '否')){ + return tousseAmount+'('+scannedMaterialAmount+')'; + }else{ + return tousseAmount; + } +} +function formatStorage(v,p,record){ + if (v==null || v.length <= 0){ + return ''; + }else{ + return v; + } +} +function sayGoods(record){ + if(record && record.data){ + speaker.speak(record.data.showTousseName + ",数量为" + record.data.count); + } +} +//发货单明细累减 +function updateAmount1(name,amount){ + if(name != null && name.length > 0){ + for ( var i = 0; i < recyclingapplicationStore.getCount(); i++) { + var record = recyclingapplicationStore.getAt(i); + var tempName = record.get('name'); + var tempAmount = record.get('tempAmount'); + if(tempName == name){ + if(tempAmount==null || tempAmount.length <= 0){ + tempAmount = 0; + } + record.set('tempAmount',Number(tempAmount) - Number(amount)); + updateErrorAmount(record); + refreshTotalAmount(); + } + } + } + return false; +} +//删除发货扫描的物品 +function removeSendOutGoods(id){ + var rows = top.Ext.getCmp('sendOutGoods').getSelectionModel().getSelections();// 返回值为 + if (rows) { + for ( var i = 0; i < rows.length; i++) { + var name = rows[i].data['name']; + var amount = rows[i].data['count']; + var barcode = rows[i].data['barcode']; + sendOutGoodsStore.remove(rows[i]); + +// var appRecord = rows[i].data['appRecord']; + var appRecord = barcodeToAppRecordMap[barcode]; + if(!isUndefinedOrNullOrEmpty(appRecord)){ + updateAmountByRecord(appRecord,-amount); + }else{ + updateAmount1(name,amount); + } + + sendDeleteScannedGoodsLog(rows[i].data); + } + } +} + +//删除发货明细项 +function removeSendOutGoodsDetail(id){ + var rows = top.Ext.getCmp('sendOutGoodsDetail').getSelectionModel().getSelections();// 返回值为 + if (rows) { + for ( var i = 0; i < rows.length; i++) { + var name = rows[i].data['name']; + var amount = rows[i].data['count']; + recyclingapplicationStore.remove(rows[i]); + } + } +} + +//删除发货明细项 +function removeSendOutTousseByBarcode(barcode){ + var record = findRecordByNameAndValueFromStore(sendOutGoodsStore,'barcode',barcode); + if(record != null){ + var name = record.data['name']; + sendOutGoodsStore.remove(record); + updateAmount1(name,1); + } +} + +//验证条码是否重复扫描 +function isBarcodeRepeat(barcode){ + if(barcode != null && barcode.length > 0){ + for ( var i = 0; i < sendOutGoodsStore.getCount(); i++) { + var record = sendOutGoodsStore.getAt(i); + var tempBarcode =record.get('barcode'); + if(barcode == tempBarcode){ + return true; + break; + } + } + } + return false; +} +function removeTousseIfNeeded(goods){ + var barcode = goods.barcode; + if(isBarcodeRepeat(barcode)){ + var name = goods.name; + for (var i = 0; i < recyclingapplicationStore.getCount(); i++) { + var record = recyclingapplicationStore.getAt(i); + var tempName = record.get('name'); + var tempAmount = record.get('tempAmount'); + if(tempName == name){ + var errorAmount = record.get('errorAmount'); + if(errorAmount < 0){ + removeSendOutTousseByBarcode(barcode); + return true; + } + } + } + } + return false; +} + +//扫描的物品是否是待发货物品 +//name不是showTousseName字段 +function isInvoiceGoods(name){ + if(name != null && name.length > 0){ + for ( var i = 0; i < recyclingapplicationStore.getCount(); i++) { + var record = recyclingapplicationStore.getAt(i); + var name1 =record.get('name'); + if(name == name1){ + return true; + break; + } + } + } + return false; +} + +//发货单明细累加 +function updateAmount(name,amount){ + if(name != null && name.length > 0){ + for (var i = 0; i < recyclingapplicationStore.getCount(); i++) { + var record = recyclingapplicationStore.getAt(i); + var tempName = record.get('name'); + var tempAmount = record.get('tempAmount'); + if(tempName == name){ + if(tempAmount==null || tempAmount.length <= 0){ + tempAmount = 0; + } + record.set('tempAmount',Number(amount) + Number(tempAmount)); + updateErrorAmount(record); + refreshTotalAmount(); + } + } + } + return false; +} +function updateAmountByRecord(record,amount){ + var tempAmount = record.get('tempAmount'); + if(tempAmount==null || tempAmount.length <= 0){ + tempAmount = 0; + } + var newAmount = Number(amount) + Number(tempAmount); + record.set('tempAmount',newAmount); + // 计算材料数量 + var materialAmount = calculateScannedMaterialAmount(record); + record.set('scannedMaterialAmount',materialAmount); + updateErrorAmount(record); + refreshTotalAmount(); + + return false; +} +function calculateScannedMaterialAmount(record){ + var tempAmount = record.get('tempAmount'); + var tousseItems = record.get('tousseItems'); + var goodsType = record.get('goodsType'); + var isCleanedEntirely = record.get('isCleanedEntirely'); + var scannedMaterialAmount1 = 0;// 非固定条码 + var scannedTousseAmount1 = 0;// 非固定条码 + var scannedMaterialAmount2 = 0;// 固定条码 + if((goodsType == '消毒物品') && (isCleanedEntirely == '否') && !isUndefinedOrNull(tousseItems)){ + + }else{ + return 0; + } + for ( var i = 0; i < sendOutGoodsStore.getCount(); i++) { + var sendOutRecord = sendOutGoodsStore.getAt(i); + var barcode = sendOutRecord.get('barcode'); + var tousseFixedBarcode = sendOutRecord.get('tousseFixedBarcode'); + var count = sendOutRecord.get('count'); + var goods = barcodeToScanGoodsMap[barcode]; + var tempMaterialAmount = 0; + if(goods && goods.materialAmount){ + tempMaterialAmount = goods.materialAmount; + } + if(barcodeToAppRecordMap[barcode] == record && !tousseFixedBarcode){ + scannedMaterialAmount1 += tempMaterialAmount; + scannedTousseAmount1 += count; + } + } + if(scannedTousseAmount1 < tempAmount){ + var scannedTousseAmount2 = tempAmount - scannedTousseAmount1; + var amountArray = []; + for(var i=0;i 0){ + --count; + amountArray.push(materialAmount); + } + } + scannedTousseAmount2 = Math.min(scannedTousseAmount2,amountArray.length); + + for(var i=0;i Number(applicationAmount)){//发货数量不能大于待发货数量 + b = false; + top.Ext.getCmp('sendOutGoodsDetail').getView().getRow(i).style.backgroundColor = '#FFB5B5'; + showResult(record.get('name')+" 发货数量不能大于" + applicationAmount); + } + } + return b; +} + +var addGridItem = Ext.data.Record.create([ + {name : 'id'}, + {name : 'barcode'}, + {name : 'name'}, + {name : 'appRecord'}, + {name : 'tousseFixedBarcode'}, + {name : 'showTousseName'}, + {name : 'count'}, + {name : 'waitDeliveryCount'}, + {name : 'diposable'}, + {name : 'price'}, + {name : 'fluctuationPrice'}, + {name : 'storage'}, + {name : 'batchNumber'}, + {name : 'tousseType'}, + {name : 'typeInfoOnScanned'}, + {name : 'sterilizerName'}, + {name : 'frequency'}, + {name : 'isTracable'}, + {name : 'tousseDefinitionId'} + ]); + +// 根据条码获取发送项 +function getSendOutGoodsByBarcode(barcode){ + if(isUndefinedOrNullOrEmpty(barcode)){ + return null; + } + for ( var i = 0; i < sendOutGoodsStore.getCount(); i++) { + var record = sendOutGoodsStore.getAt(i); + var tempBarcode =record.get('barcode'); + if(barcode == tempBarcode){ + return record.data; + } + } + return null; +} +function getSendOutRecordByBarcode(barcode){ + if(isUndefinedOrNullOrEmpty(barcode)){ + return null; + } + for ( var i = 0; i < sendOutGoodsStore.getCount(); i++) { + var record = sendOutGoodsStore.getAt(i); + var tempBarcode = record.get('barcode'); + if(barcode == tempBarcode){ + return record; + } + } + return null; +} +// 名字到数量的map +function getTousseNameToAmountMap(scannedResult){ + var map = {}; + for(var i=0;i= storageAmount){ + return; + } + + } + if(goods.tousseFixedBarcode || (goods.diposable == '是')){ + if(notSendAmount < storageAmount){// 待发货数量小于库存 + count = notSendAmount; + }else{ + count = storageAmount; + } + } + if(project == 'gdsy'){ + if(goods.diposable == '是'){ + if(storageAmount < notSendAmount){// 库存小于待发货数量 + var msg = getTtsNameByGoods(goods) + goods.barcode + ',该批次只满足部分发货!' + showResult(msg); + } + } + } + + + // 固定条码每次增加的数量不能超过包定义的扫描数量 + if(goods.tousseFixedBarcode){ + var remnantStorage = storageAmount - sendAmount; + count = Math.min(count,goods.scanAmount);// 单次增加数量不能超过每次扫描数量 + count = Math.min(count,remnantStorage);// 增加数量不能超过剩余库存 + + if(count == 0){ + return; + } + } + + var price = goods.price; + var add = true; + if(goods.tousseFixedBarcode){ + var existingRecord = getSendOutRecordByBarcode(goods.barcode); + if(existingRecord != null){ + add = false; + var totalCount = count + existingRecord.data.count; + existingRecord.set('count',totalCount); + } + } + if(add){ + var newRecord = new addGridItem({ + id : 0, + barcode : goods.barcode, + name : goods.name, + ttsName : goods.ttsName, +// appRecord: record, + tousseFixedBarcode : goods.tousseFixedBarcode, + showTousseName : goods.showTousseName, + count : count, + scanAmount : goods.scanAmount, + waitDeliveryCount:waitDeliveryCount, + diposable : goods.diposable, + price : price, + fluctuationPrice : goods.fluctuationPrice, + storage : storageAmount, + batchNumber : goods.batchNumber, + tousseType : goods.tousseType, + typeInfoOnScanned : goods.typeInfoOnScanned, + sterilizerName : goods.sterilizerName, + frequency : goods.frequency, + isTracable : goods.isTracable, + tousseDefinitionId : goods.tousseDefinitionId, + externalCode : goods.externalCode, + isRoutine : goods.isRoutine + }); + sendOutGoodsStore.insert(0,newRecord); + } + barcodeToAppRecordMap[goods.barcode] = record; + barcodeToScanGoodsMap[goods.barcode] = goods; + speakBasket.addGoods('',getTtsNameByGoods(goods),count); +// clearScanText(); + updateAmountByRecord(record,count); + resortRecyclingapplication(record) +} + +/* +按(待发数量-已扫数量)的降序排序,当扫描一个条码后, +对应右边的物品行显示顺序调整到第一行,接下来的行的顺序是已扫数量为0的行按待发数量从大到小排序、 +(待发数量-已扫数量)按大到小排、已扫描的物品按扫描的先后顺序倒排等 +*/ +var g_curRecord = null; +function safelyGetScanTime(r){ + var scanTime = Number(r.get('scanTime')); + if(scanTime){ + return Number(scanTime); + } + return 0; +} +function sortFun(r1,r2){ + var waitDeliveryCount1 = Number(r1.get('count'));// 申请数量 + var waitDeliveryCount2 = Number(r2.get('count'));// 申请数量 + var sendAmount1 = Number(r1.get('tempAmount'));// 已扫描数量 + var sendAmount2 = Number(r2.get('tempAmount'));// 已扫描数量 + var notSendAmount1 = Number(r1.get('count')) - Number(r1.get('tempAmount')); + var notSendAmount2 = Number(r2.get('count')) - Number(r2.get('tempAmount')); + var scanTime1 = safelyGetScanTime(r1);// 扫描时间 + var scanTime2 = safelyGetScanTime(r2);// 扫描时间 + // 是否当前记录 + if(r1 == g_curRecord){ + return -1; + }else if(r2 == g_curRecord){ + return 1; + } + // 已扫数量为0 + if(sendAmount1 == 0 && sendAmount2 != 0){ + return -1; + }else if(sendAmount2 == 0 && sendAmount1 != 0){ + return 1; + }else if(sendAmount2 == 0 && sendAmount1 == 0){ + if(waitDeliveryCount1 != waitDeliveryCount2){ + return waitDeliveryCount2 - waitDeliveryCount1; + } + } + // 剩余待发数量 + if(notSendAmount1 != notSendAmount2){ + return notSendAmount2 - notSendAmount1; + } + // 扫描时间。 + return scanTime2 - scanTime1; +} +function resortRecyclingapplication(curRecord){ + if(!sstsConfig.invoicePlanExtractedForm_resortRecyclingApplicationItems){ + return; + } + g_curRecord = curRecord; + var records = []; + for ( var i = 0; i < recyclingapplicationStore.getCount(); i++) { + var record = recyclingapplicationStore.getAt(i); +// record.set('sortValue',i+1); + records.push(record); + } +// curRecord.set('sortValue',0); + curRecord.set('scanTime',new Date().getTime()); +// recyclingapplicationStore.sort('sortValue'); + records.sort(sortFun); + recyclingapplicationStore.removeAll(); + recyclingapplicationStore.add(records); +} +function clearScanText(){ + var barcodeEnd = top.Ext.getCmp("scanTextEnd").getValue().Trim(); + if(barcodeEnd == ''){ + if(hiddenEndBarcode || currentScanMode == 'single'){ + top.Ext.getCmp('scanText').setValue("");//如果使用虚拟篮筐机制,扫描成功后需要清除该文本内容 + }else{ + top.Ext.getCmp('scanTextEnd').focus();//否则不清除,条码/篮筐(尾)获得焦点 + } + } + if(barcodeEnd != ''){ + top.Ext.getCmp('scanText').setValue("");//尾条码输入完成,所有条码都取消,要输入确认取消条码了 + top.Ext.getCmp('scanTextEnd').setValue("");//清除尾条码,以输入确认取消条码 + top.Ext.getCmp('scanText').focus();//否则不清除,条码/篮筐(尾)获得焦点 + } +} +function getApplicationGoodsByName(goodsName){ + var record = findRecordByNameAndValueFromStore(recyclingapplicationStore,"name",goodsName); + if(record != null){ + return record.data; + } + return null; +} +function preprocessBeforeGetBarcodeInfo(){ + var barcode = top.Ext.getCmp("scanText").getValue().Trim(); + var barcodeEnd = top.Ext.getCmp("scanTextEnd").getValue().Trim(); + + clearScanText();// 清除条码 + var singleMode = true; + if(barcodeEnd != ''){ + singleMode = false; + } + var sourceWarehouseId = top.Ext.getCmp("sourceWarehouseId").getValue(); + if(isUndefinedOrNullOrEmpty(sourceWarehouseId)){ + showResult('请先选择仓库!'); + return false; + } + if(singleMode){// 判断是否已经扫描过该条码 + var goods = getSendOutGoodsByBarcode(barcode); + if(goods != null){ + if(goods.tousseFixedBarcode){ + // 固定条码允许重复扫 + return true; + } + if(goods.tousseType == '器械包'){// 目前只处理普通器械包的误差,以及删除 + var appGoods = getApplicationGoodsByName(goods.name); + if(appGoods.errorAmount >= 0){// 误差数量大于等于0时,能正常发货,此时重复扫描,按以前的逻辑处理,提示条码已存在 + showResult('条形码:'+barcode+' 已经存在!'); + return false; + }else{// 误差数量小于0时,说明扫描数量已经大于申请数量,此时重复扫描某个包,需要删除该包。 + // 删除该器械包 + removeSendOutTousseByBarcode(goods.barcode); + return false; + } + }else{ + showResult('条形码:'+barcode+' 已经存在!'); + return false; + } + } + } + return true; +} +//名字到数量的map +function getComboTousseNameToAmountMap(tousseInstancesBelongToThisComboTousse){ + var map = {}; + for(var i=0;i 1) && goods.tousseFixedBarcode){// 扫单个包才提示 + continue; + } + + var b = isBarcodeRepeat(goods.barcode); + if(b && (goods.diposable == '是' || !goods.tousseFixedBarcode)){// 扫描多个时,如果存在已扫描的,直接忽略,跳过 + continue; + } + // 校验是否超过待发数量,如果是,也跳过 + if(exceedAmountNames.hasOwnProperty(goods.name)){ + continue; + } +// var record = findRecordByNameAndValueFromStore(recyclingapplicationStore,"name",goods.name); + var record = findRecordByGoodsVOFromRecyclingApplication(goods); + + // 如果未找到,继续找下一个 + if (record == undefined){ + var msg = '['+getTtsNameByGoods(goods)+']不在发货计划中!'; + if(!isUndefinedOrNullOrEmpty(goods.tousseType)){ + msg = '['+goods.tousseType+']'+'['+getTtsNameByGoods(goods)+']不在发货计划中!'; + } + showResult(msg); + continue; + } + // 唯一条码消毒物品的校验 + if(goods.tousseType == '消毒物品' && !goods.tousseFixedBarcode){ + if(!validateDisinfection(record,goods)){ + showResult(getTtsNameByGoods(goods)+'的材料与申请单中的材料不一致'); + continue; + } + } + if((goods.tousseType == '外部代理灭菌' || goods.tousseType == '外来器械包' || goods.tousseType == '外来器械拆分小包' || goods.proxyDisinfection_id) && !goods.tousseFixedBarcode){ + var inPlan = false; + for(var i=0;i 0){ +// showResult(msg); +// } +// } + speakBasket.speakContent(); +// if(result.data.length > 0 && alreadyAddAmount == 0){ +// showResult("器械包已扫描或不在发货单中"); +// } + }, + failure : function(response, options) { + top.Ext.getCmp("sendOutGoods").getEl().unmask(); + showResult('获取条码信息失败'); + top.Ext.getCmp('scanText').setValue(""); + top.Ext.getCmp('scanTextEnd').setValue(""); + top.Ext.getCmp('scanText').focus(); + } + + }); +} + +//发货单明细修改 +function updateAmount2(record, amount) { + if (name != null && name.length > 0) { + for ( var i = 0; i < recyclingapplicationStore.getCount(); i++) { + var record = recyclingapplicationStore.getAt(i); + var tempName = record.get('name'); + var tempAmount = record.get('tempAmount'); + if (tempName == name) { + if (tempAmount == null || tempAmount.length <= 0) { + tempAmount = 0; + } + record.set('tempAmount', Number(amount)); + updateErrorAmount(record); + refreshTotalAmount(); + } + } + } + return false; +} + +//function getTypeName(diposable){ +// if(diposable == '是'){ +// return '一次性物品'; +// } +//} +// +function findRecordByGoodsVOFromRecyclingApplication(vo) { + for ( var i = 0; i < recyclingapplicationStore.getCount(); i++) { + var record = recyclingapplicationStore.getAt(i); + var name = record.get('name'); + var diposable = record.get('diposable'); + var disposableGoodsIdSet = record.get('disposableGoodsIdSet'); + if(name == vo.name && diposable != vo.diposable){ + var msg = '待发物品['+name+']为一次性物品,请扫描一次性物品条码!'; + if(diposable != '是'){ + msg = '待发物品['+name+']为器械包,请扫描器械包条码!'; + } + showResult(msg); + return null; + } + + if(diposable == '是'){ + // 一次性物品优先根据id来匹配 + if(disposableGoodsIdSet.length > 0 && !isUndefinedOrNullOrEmpty(vo.typeInfoOnScanned)){ + var typeInfoOnScanned = JSON.parse(vo.typeInfoOnScanned); + for(var di=0;di 0){ + for(var di=0;di 0){ + for ( var i = 0; i < storages.length; i++) { + var storage = storages[i]; + var record = findAppRecordByStorageInfo(storage); + if(record){ +// if(!isUndefinedOrNull(storage.middlePackageStorage)){ +// record.set('storage',storage.storage); +// }else{ +// record.set('storage',storage.storage); +// } + record.set('storage',storage.storage); + } + } + } +} +function findAppRecordByStorageInfo(storage){ + for(var i=0;i 0){ + return true; + } + return false; +} +/** + * 发货单窗口 + * @param orgUnitCoding 科室编码 + * @param depart 科室名称 + * @param invoicePlanId 发货计划id + */ +var invoicePlanFormOpened = false; +var g_orgUnitCoding = ''; +function addAndEditInvoicePlan(orgUnitCoding,depart,invoicePlanId) { + if(invoicePlanFormOpened){ + return; + } + g_orgUnitCoding = orgUnitCoding; + invoicePlanFormOpened = true; + lastLoadWarehouseId = null; + defaultFocusedFieldOnInvoiceForm = getStrValueFromJs('sstsConfig.defaultFocusedFieldOnInvoiceForm',defaultFocusedFieldOnInvoiceForm); + // 发货物品 + sendOutGoodsStore = new Ext.data.Store({ + reader : new Ext.data.JsonReader({ + fields : [ + {name : 'id'}, + {name : 'barcode'}, + {name : 'name'}, + {name : 'ttsName'}, + {name : 'appRecord'}, + {name : 'showTousseName'}, + {name : 'count'}, + {name : 'scanAmount'}, + {name : 'waitDeliveryCount'}, + {name : 'diposable'}, + {name : 'tousseType'}, + {name : 'tousseFixedBarcode'}, + {name : 'price'}, + {name : 'fluctuationPrice'}, + {name : 'storage'}, + {name : 'batchNumber'}, + {name : 'sterilizerName'}, + {name : 'frequency'}, + {name : 'externalCode'} + ] + }) + }); + + var rd = new Ext.data.JsonReader( { + fields : [ + {name : 'id'}, + {name : 'barcode'}, + {name : 'name'}, + {name : 'ttsName'}, + {name : 'tousseItems'}, + {name : 'scannedMaterialAmount'}, + {name : 'showTousseName'}, + {name : 'count'}, + {name : 'middlePackageAmount'}, + {name : 'diposable'}, + {name : 'goodsType'}, + {name : 'price'}, + {name : 'urgentAmount'}, + {name : 'tempAmount'}, + {name : 'errorAmount'}, + {name : 'storage'}, + {name : 'amount'}, + {name : 'scanTime'}, + {name : 'sortValue'}, + {name : 'applicationAmount'}, + {name : 'batchNumber'}, + {name : 'isCleanedEntirely'}, + {name : 'disposableGoodsIdSet'}, + {name : 'invoicePlanIDList'}, + {name : 'invoicePlanType'} + ] + }); + //科室申请单的store + var departApplicationStore = new Ext.data.Store({ + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectSystem/invoicePlanAction!getInvoicePlansByOrgAndTousseType.do?departCode=' + + orgUnitCoding + '&applyDate=' + + selectedApplyDate + '&tousseType=' + + encodeURI(selectedTousseType), + method : 'POST' + }), + reader : new Ext.data.JsonReader({fields : [{name : 'id'},{name : 'typeAndserialNumber'},{name : 'remark'}]}), + listeners: { + load: function(thiz,records,options){ + // 设置备注 + var remarks = ''; + if(records.length > 0){ + for(var i = 0; i < records.length;++i){ + if(!isUndefinedOrNullOrEmpty(records[i].data.remark)){ + remarks += records[i].data.remark; + } + } + top.Ext.getCmp('remark2').setValue(remarks); + } + + if(records.length > 0 && invoicePlanId){ + var index; + for(var index = 0; index < records.length;++index){ + if(records[index].data.id == invoicePlanId){ + break; + } + } + if(index < records.length){ + var combo = top.Ext.getCmp('invoicePlanId'); + combo.setValue(records[index].data.id); + combo.fireEvent('select', combo,records[index],index); + } + } + } + } + }); + + //申请物品 + recyclingapplicationStore = new Ext.data.Store({ + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectSystem/invoiceAction!loadDepartApplicationAllGoodsByCondition.do', + method : 'POST' + }), + reader : rd, + listeners: { + load: function(thiz,records,options){ + initErrorAmount(); + var sourceWarehouseIdCmp = top.Ext.getCmp('sourceWarehouseId'); + if(sourceWarehouseIdCmp != null){ + var sourceWarehouseId = sourceWarehouseIdCmp.getValue(); + refreshTotalAmount(); + refreshStorage(sourceWarehouseId); + } + recyclingapplicationStoreLoaded = true; + } + } + }); + + recyclingapplicationStore.removeAll(); + recyclingapplicationStore.on("beforeload", function(thiz, options) { + thiz.baseParams["orgUnitCoding"] = orgUnitCoding; + recyclingapplicationStore.baseParams['invoicePlanId'] = selectedInvoicePlanId; + recyclingapplicationStore.baseParams['applyDate'] = selectedApplyDate; + recyclingapplicationStore.baseParams['tousseType'] = encodeURI(selectedTousseType); + }); + + recyclingapplicationStore.load(); +// sendOutGoodsStore.removeAll(); +// sendOutGoodsStore.on("beforeload", function(thiz, options) { +// thiz.baseParams["orgUnitCoding"] = orgUnitCoding; +// }); +// sendOutGoodsStore.load(); + + var recyclingapplicationCm = new Ext.grid.ColumnModel([ + {header : "申请的物品",dataIndex : 'showTousseName',width : 180,menuDisabled: true}, + {header : "name",dataIndex : 'name',hidden : true,menuDisabled: true}, + {header : "待发",dataIndex : 'count',width : 50, menuDisabled: true/*, + editor : new Ext.form.TextField( { + allowBlank : false, + listeners : { + focus : function(thiz){ + thiz.selectText(); + } + } + })*/ + }, + {header : '加急',id : 'urgentAmount',dataIndex : 'urgentAmount',width : 50,value : 0, menuDisabled: true,renderer:getDefaultAmount}, + {header : '实发',id : 'tempAmount',dataIndex : 'tempAmount',width : 50,value : 0, menuDisabled: true,renderer:formatScannedAmount}, + {header : '误差',id : 'errorAmount',dataIndex : 'errorAmount',width : 50,value : 0, menuDisabled: true,renderer:getDefaultAmount}, + {header : '库存',id : 'storage',dataIndex : 'storage',width : 50,value : 0, menuDisabled: true,renderer:formatStorage}, + {id : 'diposable',header : "是否一次性材料",dataIndex : 'diposable',hidden :true}, + {id :'applicationAmount',header : "最大发货数量",dataIndex : 'applicationAmount',hidden : true,width :150} +// {id : 'deleteItem',header:'删除',hidden :true,width :40,menuDisabled: true, +// renderer: function(v,p,record){ +// var str = ""; +// return str; +// }, +// dataIndex:'button' +// } + ]); + + var recyclingErrorCm = new Ext.grid.ColumnModel([ + {header : "材料名称",dataIndex : 'goodsName',width : 170,menuDisabled: true}, + {header : "缺失数量",dataIndex : 'count',width : 60, menuDisabled: true}, + {header : '单价',id : 'price',dataIndex : 'price',width : 60,value : 0,menuDisabled: true} + ]); + + var cm = new Ext.grid.ColumnModel([ + {header : "条码",dataIndex : 'barcode',width : 65,menuDisabled: true}, + {header : "物品名称",dataIndex : 'showTousseName',width : 190,menuDisabled: true}, + {header : "name",dataIndex : 'name',hidden : true,menuDisabled: true}, + {header : "批次/灭菌日期",dataIndex : 'batchNumber',width : 125,menuDisabled: true}, + {header : "灭菌炉名称",dataIndex : 'sterilizerName',width : 200,menuDisabled: true,hidden :true}, + {header : "炉次",dataIndex : 'frequency',width : 50,menuDisabled: true,hidden :true}, + {id : 'diposable',header : "是否一次性材料",dataIndex : 'diposable',hidden :true,width : 150}, + {header : "单价",dataIndex : 'fluctuationPrice',width : 50, align:'right', menuDisabled: true}, + {header : "数量",dataIndex : 'count',width : 50, align:'right', menuDisabled: true, + editor : new Ext.form.NumberField({ + allowBlank : false, + allowNegative : false, + minValue :1, + style : 'text-align: left', + allowDecimals : false, + listeners : { + focus : function(thiz){ + thiz.selectText(); + } + } + })}, + {id : 'deleteItem',header:'删除',width : 25, align:'center', menuDisabled: true, + renderer: function(v,p,record){ + var str = ""; + return str; + }, + dataIndex:'button' + }]); + function doSaveAction(printInvoiceCallback){ + if (!form.getForm().isValid()) { + showResult('请正确填写表单各值'); + return false; + } + //验证发货物品表格 + if(!sendOutGoodsStore || sendOutGoodsStore.getCount() == 0){ + showResult('发货物品不能为空!'); + return false; + } + /*var b = validTousseGridData(); + if(!b){ + return false; + }*/ + var bool = validGridAmount(); + if(!bool){ + return false; + } + if(project == 'gdsy'){ + if(!isScanAmountEqualsAppAmountConfirmed){ + if(!isScanAmountEqualsAppAmount()){ + confirmSaveWin = top.Ext.MessageBox.prompt("请确认","部分物品实发数量与待发数量存在差异,是否继续发货?", + function(button, text) { + + if ("cancel" == button || (!isUndefinedOrNullOrEmpty(text) && (text != BARCODE_ACTION_YES))){ + confirmSaveWin = null; + isScanAmountEqualsAppAmountConfirmed = false; + }else{ + isScanAmountEqualsAppAmountConfirmed = true; + doSaveAction(); + } + }); + speaker.speak("部分物品实发数量与待发数量存在差异,是否继续发货","是否继续发货"); + return false; + } + } + } + isScanAmountEqualsAppAmountConfirmed = false; + getTousseGridData(); + form.form.submit( { + //url : WWWROOT + '/disinfectSystem/invoiceAction!saveDepartInvoice.do', + url : WWWROOT + '/disinfectSystem/invoiceAction!saveInvoiceByDepartOrInvoicePlanId.do', + method : 'POST', + waitMsg : '正在保存数据,请稍候', + waitTitle : '提交表单', + success : function(form, action) { + // 一定要事务提交成功才返回发货计划列表界面 + showResult(action.result.message); + if(action.result.success){ + if(printInvoiceCallback != null){ + printInvoiceCallback(action.result.invoiceIds); + } + closeInvoiceFormWindow(); + // 返回退货界面 + if(openMode == INVOICE_FORM_OPEN_MODE_CLICKRETURNRECORD){ + document.location.href = WWWROOT+'/disinfectsystem/returnGoodsRecord/returnGoodsRecordView.jsp'; + return; + } + grid.getStore().reload(); + } + }, + failure : function(form, action) { + if(!isUndefinedOrNullOrEmpty(action.result) && !isUndefinedOrNullOrEmpty(action.result.message)){ + showResult(action.result.message); + }else{ + showResult("发货超时,请稍后查看发货单以确定发货是否成功,避免重复发货!"); + closeInvoiceFormWindow(); + // 返回退货界面 + if(openMode == INVOICE_FORM_OPEN_MODE_CLICKRETURNRECORD){ + document.location.href = WWWROOT+'/disinfectsystem/returnGoodsRecord/returnGoodsRecordView.jsp'; + return; + } + grid.getStore().reload(); + } + } + }); + } + /** + * 发货并打印发货单 + * @param invoiceIds 发货单的id数组 + */ + function printInvoiceAfterInvoice(invoiceIds){ + if(!isUndefinedOrNull(invoiceIds)){ + var invoicePrintModule = new InvoicePrintModule(grid,$Id('userName').value); + invoicePrintModule.batchPrintInvoiceWithType(invoiceIds.join(","),'全部'); + } + } + function callback_yes(){ + doSaveAction(); + } + function callback_no(){ + if(confirmSaveWin){ + confirmSaveWin.hide(); + confirmSaveWin = null; + isScanAmountEqualsAppAmountConfirmed = false; + }else{ + closeInvoiceFormWindow(); + } + } + function closeInvoiceFormWindow(){ + if(invoiceFormWindow){ + selectedInvoicePlanId = ""; + invoiceFormWindow.close(); + invoiceFormWindow = null; + v_callback_yes = null; + v_callback_no = null; + } + } + v_callback_yes = callback_yes; + v_callback_no = callback_no; + var barcodeBtn = new BarcodeBtn(function(){callback_yes();},function(){callback_no();}); + var form = new top.Ext.FormPanel({ + id : 'recyclingApplicationForm', + frame : true, + labelSeparator : ':', + bodyStyle : 'padding:5px 5px 0px 5px', + width : 1020, + height : 580, + // autoHeight : true, + autoScroll : true, + labelAlign:'right', + layout : 'form', + items : [{ + xtype : "fieldset", + title : "基础数据", + layout : 'column', + style: 'padding:0px', + autoHeight : true, + items : [{ + layout : 'column', + columnWidth :1, + items:[{ + xtype : 'hidden', + name : 'id', + id : 'id' + },{ + xtype : 'hidden', + name : 'sendOutGoodsStoreData', + id : 'sendOutGoodsStoreData' + },{ + xtype :'hidden', + name : 'recyclingappStoreData', + id : 'recyclingappStoreData' + },{ + xtype :'hidden', + name : 'status', + id : 'status' + },{ + xtype :'hidden', + name : 'orgUnitCoding', + id : 'orgUnitCoding', + value:orgUnitCoding + },{ + xtype :'hidden', + name : 'applyDate', + id : 'applyDateHidden', + value:selectedApplyDate + },{ + xtype :'hidden', + name : 'tousseType', + id : 'tousseTypeHidden', + value:selectedTousseType + },{ + xtype :'hidden', + name : 'invoicePlanId', + id : 'invoicePlanIdHidden', + value:selectedInvoicePlanId + },{ + xtype :'hidden', + name : 'personInChargeCode', + id : 'personInChargeCode' + },{ + xtype : 'hidden', + name : 'sourceWarehouseId', + id : 'sourceWarehouseId' + },{ + xtype : 'hidden', + name : 'sourceWarehouseName', + id : 'sourceWarehouseName' + },{ + xtype : 'hidden', + name : 'warehouseID', + id : 'warehouseID' + },{ + xtype : 'hidden', + name : 'warehouseName', + id : 'warehouseName' + },{ + layout : 'form', + labelWidth :70, + columnWidth :.33, + items : [{ + xtype : 'textfield', + fieldLabel : '申请科室', + maxLength : '100', + id : 'depart2', + name : 'depart', + value : depart, + readOnly:true, + anchor : '99%', + cls:'fieldReadOnlyNoRemove' + + }] + },{ + layout : 'form', + labelWidth :70, + columnWidth :.67, + items : [{ + xtype : 'textfield', + fieldLabel : '发货员', + maxLength : '41', + id : 'deliveryPerson', + name : 'deliveryPerson', + readOnly:true, + allowBlank : false, + anchor : '99%', + value:$Id('userName').value, + cls:'fieldReadOnlyNoRemove' + }] + },{ + layout : 'form', + labelWidth :70, + columnWidth :.33, + items : [{ + xtype : 'textfield', + fieldLabel : '核对员条码', + maxLength : '16', + id : 'senderBarcode', + name : 'senderBarcode', + anchor : '99%', + listeners : { + render : function(p) { + p.getEl().on('keypress',function(e) { + if (e.getKey() == 13) {//回车键 + InvoiceTableManager.getUserNameOfCurrentLoginUserOrgsByBarcode( + top.Ext.getCmp('senderBarcode').getValue(),function(userName) { + if (userName != null) { + var resultArray = userName.split(":"); + if(resultArray[0] == "success"){ + top.Ext.getCmp('sender').setValue(resultArray[1]); + Ext.state.Manager.getProvider().set('cookieSender',resultArray[1]); + }else{ + showResult(resultArray[1]); + top.Ext.getCmp('sender').setValue(""); + } + } + top.Ext.getCmp('senderBarcode').setValue(""); + top.Ext.getCmp('personInChargeBarcode').focus(); + }); + } + }); + } + } + }] + },{ + layout : 'form', + labelWidth :70, + columnWidth :.33, + items : [{ + xtype : 'textfield', + fieldLabel : '核对员', + maxLength : '41', + id : 'sender', + name : 'sender', + readOnly:true, + allowBlank : false, + anchor : '99%', + cls:'x-item-disabled' + }] + },{ + layout : 'form', + labelWidth :90, + columnWidth :.33, + items : [{ + xtype : 'textfield', + fieldLabel : '下送责任人条码', + maxLength : '16', + id : 'personInChargeBarcode', + name : 'personInChargeBarcode', + anchor : '99%', + listeners : { + render : function(p) { + p.getEl().on('keypress',function(e) { + if (e.getKey() == 13) {//回车键 + var barcode = top.Ext.getCmp('personInChargeBarcode').getValue(); + top.Ext.getCmp('personInChargeBarcode').setValue(""); + UserTableManager.getUserByBarcode(barcode,function(responseText){ + if(!isUndefinedOrNullOrEmpty(responseText)){ + var result = top.Ext.decode(responseText); + if(!result.success){ + result.isNotSameOrgUnit?showResult("不允许登记非本科室人员,请扫描本科室人员条码"):showResult("输入的条码有误!"); + return; + } + Ext.state.Manager.getProvider().set('cookiePersonInCharge',result.fullName); + Ext.state.Manager.getProvider().set('cookiePersonInChargeCode',result.name); + top.Ext.getCmp('personInCharge').setValue(result.fullName); + top.Ext.getCmp('personInChargeCode').setValue(result.name); + top.Ext.getCmp('scanText').focus(); + }else{ + showResult('找不到该条码所对应的人员信息'); + } + }); + } + }); + } + } + }] + },{ + layout : 'form', + labelWidth :70, + columnWidth :.33, + items : [{ + xtype : 'textfield', + fieldLabel : '下送责任人', + maxLength : '41', + id : 'personInCharge', + name : 'personInCharge', + readOnly:true, + anchor : '99%', + cls:'x-item-disabled' + }] + },{ + layout : 'form', + labelWidth :70, + columnWidth :.33, + items : [{ + xtype : 'datefieldWithMin', + fieldLabel : '发货时间', + id : 'sendTime', + name : 'sendTime', + allowBlank : false, + altFormats:'Y-m-d|Y-n-j|y-n-j|y-m-j|y-m-d|y-n-d|Y-n-d|Y-m-j|Ymd|Ynj|ynj|ymj|ymd|ynd|Ynd|Ymj|Y/m/d|Y/n/j|y/n/j|y/m/j|y/m/d|y/n/d|Y/n/d|Y/m/j', + format:'Y-m-d H:i', +// value:new Date(), + anchor : '99%', + listeners : { + render : function() { + setStartDate(top.Ext, 'yyyy/MM/dd HH:mm', 'sendTime'); //(设置发货时间,取服务器时间 cjr) + } + } + + }] + },{ + columnWidth : .5, + layout : 'form', + labelWidth : 90, + columnWidth :.33, + items:[{ + xtype : 'combo', + fieldLabel : '仓库', + id : 'warehouse', + name : 'warehouse', + minChars : 0, + valueField : 'id', + displayField : 'name', + store : wareHouseStore, + forceSelection : true, + lazyInit : false, + triggerAction : 'all', + hideTrigger : true, + typeAhead : false, + allowBlank : false, + anchor : '99%', + listeners : { + select : function(combo, record, index) { + top.Ext.getCmp('warehouse').setValue(record.data.name); + top.Ext.getCmp('sourceWarehouseId').setValue(record.data.id); + top.Ext.getCmp('sourceWarehouseName').setValue(record.data.name); + // 刷新库存数据 + refreshStorage(record.data.id); +// top.Ext.getCmp('remark2').focus(); + }, + specialkey : function(field, ee) { + if (ee.getKey() == Ext.EventObject.ENTER) { +// top.Ext.getCmp('remark2').focus(); + } + } + } + }] + },{ + layout : 'form', + columnWidth : 1, + labelWidth :70, + items : [{ + xtype : 'textarea', + fieldLabel : '备注', + id : 'remark2', + name : 'remark', + anchor : '98.5%', + height : 40, + readOnly:true + }] + }] + }] + },{ + layout:'column', + items:[{ + layout : 'form', + columnWidth : 0.57, + items:[ + new top.Ext.grid.EditorGridPanel({ + id : 'sendOutGoods', + store : sendOutGoodsStore, + columnWidth : 0.5, + cm : cm, + width : 560, + height : 425, + autoExpandColumn : 'deleteItem', + enableHdMenu : false, + frame : false, + bodyStyle : 'border:1px solid #afd7af', + viewConfig: { + autoFit:true + }, + clicksToEdit : 1,// 设置点击几次才可编辑 + selModel : new top.Ext.grid.RowSelectionModel({ + singleSelect : false + }), + tbar : [{ + text : '扫描模式:', + hidden : hiddenEndBarcode + },{ + xtype:'combo', + id : 'scanMode', + name : 'scanMode', + hidden : hiddenEndBarcode, + fieldLabel : '扫描模式', + valueField : 'scanModeCode', + displayField : 'scanModeName', + triggerAction : 'all', + width : 80, + allowBlank : true, + editable : false, + value:currentScanMode, + store : new Ext.data.SimpleStore({ + fields : ['scanModeCode', 'scanModeName' ], + data : [['single','单个条码'],['area','首尾条码']] + }), + mode:'local', + forceSelection : true, + triggerAction : 'all', + listeners : { + select : function(combo, record, index){ + //alert(record.get("scanModeCode")); + currentScanMode = record.get("scanModeCode"); + //首尾条码全部清空,且让首条码得到焦点 + top.Ext.getCmp('scanText').setValue(""); + top.Ext.getCmp('scanTextEnd').setValue(""); + top.Ext.getCmp('scanText').focus(); + } + }, + anchor : '100%' + },{ + text : beginBarcodeLabel + },{ + xtype : 'textfield', + id : 'scanText', + name : 'scanText', + width : 90, + enableKeyEvents : true, + listeners : { + render : function(c) { + c.getEl().on('keypress',function(e) { + if (e.getKey() == 13) {// 输入;号键,grid重新加载 + if(top.Ext.getCmp("scanText").getValue() != ''){ + if(!barcodeBtn.processBarcode(top.Ext.getCmp("scanText").getValue())){ + loadGoodsByBarcode(orgUnitCoding); + } + }else{ + showResult("请扫描输入器械包/篮筐(首)条码!"); + } + } + }); + c.getEl().on('focus',function(e) { + top.Ext.getCmp('scanText').setValue(''); + }); + } + } + },{ + text : '条码/篮筐(尾):', + hidden : hiddenEndBarcode + },{ + xtype : 'textfield', + id : 'scanTextEnd', + name : 'scanTextEnd', + hidden : hiddenEndBarcode, + width : 90, + enableKeyEvents : true, + listeners : { + render : function(c) { + c.getEl().on('keypress',function(e) { + if (e.getKey() == 13) {// 输入;号键,grid重新加载 + if(top.Ext.getCmp("scanTextEnd").getValue() != ''){ + if(!barcodeBtn.processBarcode(top.Ext.getCmp("scanTextEnd").getValue())){ + loadGoodsByBarcode(orgUnitCoding); + } + }else{ + showResult("请扫描输入器械包/篮筐(尾)条码!"); + } + } + }); + c.getEl().on('focus',function(e) { + top.Ext.getCmp('scanTextEnd').setValue(''); + }); + } + } + }], + listeners : { + beforeedit : function(grid){// 只有一次性物品和固定条码才能编辑数量 + var record = grid.record; + var goods = record.data; + if(record.data.diposable == '是') { + return true; + } + if((goods.tousseType == '器械包' || goods.tousseType == '敷料包') && goods.tousseFixedBarcode){ + return true; + } + return false; + }, + afteredit :function(grid){ + var id = grid.record.data['id']; + var name = grid.record.data['name']; + var count = grid.record.data['count']; + var countInt = parseInt(count); + var storage = grid.record.data['storage']; + var storageInt = parseInt(storage); + var waitDeliveryCount = grid.record.data['waitDeliveryCount']; + var waitDeliveryCountInt = parseInt(waitDeliveryCount); + if(id==0){ + var maxAmountCanSend = Math.min(storageInt,waitDeliveryCountInt); + if(countInt > storageInt){ + showResult('库存量为:' + storage + ',已超过库存量!'); + } + if(countInt > waitDeliveryCountInt){ + showResult('申请数量为:' + waitDeliveryCountInt + ',已超过申请数量!'); + } + + if(countInt <= maxAmountCanSend){ + updateAmount2(name,countInt); + } else { + updateAmount2(name,maxAmountCanSend); +// showResult('库存量为:' + storage + ',已超过库存量!'); +// var index = recyclingapplicationStore.find("name",name); +// var tempAmount = recyclingapplicationStore.getAt(index).data['tempAmount']; + grid.record.set('count',maxAmountCanSend); + } + } else { + var record = getRecord(recyclingapplicationStore, "name", name, 0); + if(record != null) { + var tempAmount = record.data['tempAmount']; + if(parseInt(count) <= (storageInt + parseInt(tempAmount))){ + updateAmount2(name,count); + } else { + showResult('库存量为:' + storage + ',已超过库存量!'); + grid.record.set('count',tempAmount); + } + } + } + } + } + } + )] + },{ + layout : 'form', + columnWidth : 0.43, + items:[new top.Ext.grid.EditorGridPanel({ + id : 'sendOutGoodsDetail', + title : '发货单明细', + store : recyclingapplicationStore, + cm : recyclingapplicationCm, + enableHdMenu : false, + width :423, + height :425, + loadMask : true, + tbar:[{ + text:'申请单:' + },{ + xtype:'combo', + id : 'invoicePlanId', + name : 'invoicePlanId', + valueField : 'id', + listWidth : 280, + displayField : 'typeAndserialNumber', + allowBlank : true, + editable : false, + store : departApplicationStore, + forceSelection : true, + triggerAction : 'all', + listeners : { + select : function(combo, record, index){ + //1.根据申请单号的条件重新加载发货单明细 + var id = record.get('id'); + selectedInvoicePlanId = id; + recyclingapplicationStore.baseParams['invoicePlanId'] = id; + recyclingapplicationStore.load(); + //2.清除已扫描的记录 + sendOutGoodsStore.removeAll(); + top.Ext.getCmp('sendOutGoodsStoreData').setValue(''); + //3.hidden赋值 + top.Ext.getCmp('invoicePlanIdHidden').setValue(id); + //4.已扫描的首尾器械包或篮筐条码清空 + top.Ext.getCmp('scanText').setValue(''); + top.Ext.getCmp('scanTextEnd').setValue(''); + } + }, + anchor : '95%' + },{ + text: "", + id : 'tousseAmountInfo' + }], + autoExpandColumn : 'deleteItem', + frame : false, + bodyStyle : 'border:1px solid #afd7af', + viewConfig: { + forceFit:true, + getRowClass : function(record,rowIndex,rowParams,store){ + if(record.data.errorAmount < 0){ + return 'my_row_red'; + }else if(record.data.errorAmount > 0){ + return 'my_row_yellow'; + }else{ + return 'my_row_green'; + } + } + }, + clicksToEdit:1, + selModel : new top.Ext.grid.RowSelectionModel({ + singleSelect : false + }), + listeners:{ + validateedit : function(o){ + if(!isPositiveInteger(o.value))return false; + } + } + })] + } + ] + }], + buttons : [{ + text : '保存', + id:'saveButton', + handler : function(){doSaveAction();} + },{ + text : '保存并打印', + id:'saveAndPrintButton', + hidden:!sstsConfig.enableSaveAndPrintWhenInvoice, + handler : function(){doSaveAction(printInvoiceAfterInvoice);} + },{ + text : '取消', + handler : function() { + //切记注意:按取消关闭window后,一定要把已选择的申请单号变量清空 + closeInvoiceFormWindow(); + + // 返回退货界面 + if(openMode == INVOICE_FORM_OPEN_MODE_CLICKRETURNRECORD){ + document.location.href = WWWROOT+'/disinfectsystem/returnGoodsRecord/returnGoodsRecordView.jsp'; + } + } + }, { + text : '辅助发货', + hidden: openMode == INVOICE_FORM_OPEN_MODE_CLICKRETURNRECORD || assistDelivery, + handler : function() { + + closeInvoiceFormWindow(); + openAuxiliaryInvoiceForm(orgUnitCoding,depart,invoicePlanId); + } + }] + }); + +// Ext.Ajax.request({ +// url : WWWROOT + '/disinfectSystem/invoicePlanAction!loadDepartApplicationInfo.do', +// params : {orgUnitCoding : orgUnitCoding}, +// success : function(response, options) { +// var result = Ext.decode(response.responseText); +// var remark = result.remark; +// top.Ext.getCmp('remark2').setValue(remark); +// }, +// failure : function(form, action) { +// } +// }); + var cookieSender = Ext.state.Manager.getProvider().get('cookieSender'); + if(cookieSender){ + top.Ext.getCmp('sender').setValue(cookieSender); + } + var cookiePersonInCharge = Ext.state.Manager.getProvider().get('cookiePersonInCharge'); + var cookiePersonInChargeCode = Ext.state.Manager.getProvider().get('cookiePersonInChargeCode'); + if(cookiePersonInCharge){ + top.Ext.getCmp('personInCharge').setValue(cookiePersonInCharge); + } + if(cookiePersonInChargeCode){ + top.Ext.getCmp('personInChargeCode').setValue(cookiePersonInChargeCode); + } + + var invoiceFormWindow = new top.Ext.Window( { + id : 'recyclingApplicationWin', + layout : 'fit', + title : '发货单', + width : 1000, + // width : 1020, + // height : 660, + height : top.screen.height > 800 ? 660 : 500, + border : false, + modal : true, + plain : true, + items : [form] + }); + + invoiceFormWindow.on('close',function(w){ + //切记注意:按取消关闭window后,一定要把已选择的申请单号变量清空 + selectedInvoicePlanId = ""; + invoicePlanFormOpened = false; + top.getCurrentTab().focus(); + }); + + invoiceFormWindow.show(); + if(project == 'gdsy'){ + if(openMode == INVOICE_FORM_OPEN_MODE_SCANBARCODE){ + var sender = top.Ext.getCmp('sender').getValue(); + var personInCharge = top.Ext.getCmp('personInCharge').getValue(); + if(isUndefinedOrNullOrEmpty(sender)){ + top.Ext.getCmp('senderBarcode').focus(false, 100); + }else{ + if(isUndefinedOrNullOrEmpty(personInCharge)){ + top.Ext.getCmp('personInChargeBarcode').focus(false, 100); + }else{ + top.Ext.getCmp('scanText').focus(false, 100); + } + } + }else{ + top.Ext.getCmp('senderBarcode').focus(false, 100); + } + }else{ + top.Ext.getCmp(defaultFocusedFieldOnInvoiceForm).focus(false, 100); + } + +// top.Ext.getCmp('senderBarcode').focus(false, 100); + + var sendOutGoodsDetailGrid = top.Ext.getCmp('sendOutGoodsDetail'); + sendOutGoodsDetailGrid.on('rowdblclick', function(grid, index) { + var record = grid.getStore().getAt(index); + if(record.data.invoicePlanType == invoicePlanType_disinfect){ + var goodsName = record.data.name; + //显示消毒物品材料 + showDisinfectMaterial(goodsName); + } + }, this, { + buffer : 250 + }); + wareHouseStore.load(); + departApplicationStore.load(); + + if(openMode == INVOICE_FORM_OPEN_MODE_CLICKRETURNRECORD && !isUndefinedOrNullOrEmpty(returnRecordId)){ + if(postInitDataTimer != null){ + window.clearInterval(postInitDataTimer); + postInitDataTimer = null; + } + postInitDataTimer = setInterval("postInitData()", 500); + } +} + +function postInitData(){ +// alert('wareHouseStoreLoaded='+wareHouseStoreLoaded+',recyclingapplicationStoreLoaded='+recyclingapplicationStoreLoaded) + if(!wareHouseStoreLoaded || !recyclingapplicationStoreLoaded){ + return; + } + window.clearInterval(postInitDataTimer); + if(openMode == INVOICE_FORM_OPEN_MODE_CLICKRETURNRECORD && !isUndefinedOrNullOrEmpty(returnRecordId)){ + DWREngine.setAsync(false); + ReturnGoodsRecordTableManager.findToussesByReturnGoodsRecordId(returnRecordId,function(retStr){ + var tousses = top.Ext4.JSON.decode(retStr); + for(var i=0;i