Index: ssts-web/src/main/webapp/disinfectsystem/common/terminateInvoicePlan.js =================================================================== diff -u -r15550 -r16674 --- ssts-web/src/main/webapp/disinfectsystem/common/terminateInvoicePlan.js (.../terminateInvoicePlan.js) (revision 15550) +++ ssts-web/src/main/webapp/disinfectsystem/common/terminateInvoicePlan.js (.../terminateInvoicePlan.js) (revision 16674) @@ -1,4 +1,4 @@ -function terminateInvoicePlan(grid) { +function terminateInvoicePlan(grid, formType) { var records = grid.getSelectionModel().getSelections(); if (records.length == 0) { showResult("请选择需要终止的申请单"); @@ -9,9 +9,16 @@ if(type == '外部器械包代理灭菌申请单'){ continue; } - if ("已发货" == records[i].get('deliverStatus') && "借物单" != type){ - showResult("该单已发货或已终止的,不能被终止!"); - return false; + // if ("已发货" == records[i].get('deliverStatus') && "已回收" == records[i].get('recyclingStatus') && "借物单" != type){ + // showResult("该单已发货或已终止的,不能被终止!"); + // return false; + // } + if ("借物单" != type){ + //因为外来器械包record没有type,所以通过来formType来传 + type = type || formType; + if (judgeCanBeEnd(type, records[i])){ + return false; + } } } @@ -73,4 +80,73 @@ //showResult("请选择终止申请单原因。"); return false; } +} + +/** + * 判断是否能被终止 + * @param type 申请单类型 + * @param record 选中的记录 + * @returns {boolean} + */ +function judgeCanBeEnd(type, record) { + var recyclingStatus = record.get('recyclingStatus'); + if ("器械包申请单" == type || "消毒物品申请单" == type){ + return judgeTousseAndDis(record); + } + else if ("一次性物品申请单" == type){ + return judgeDisposeGood(record); + } + else if("外来器械包申请单" == type){ + return judgeForeign(record); + } + else if ("通用申请单" == type){ + return Ext.isEmpty(recyclingStatus) ? judgeDisposeGood(record) : judgeTousseAndDis(record); + } + return false; +} + +/** + * 判断器械包或者消毒物品申请单是否能被终止 + * @param record 选中的记录 + * @returns {boolean} + */ +function judgeTousseAndDis(record) { + var deliverStatus = record.get('deliverStatus'); + var recyclingStatus = record.get('recyclingStatus'); + if ("已发货" == deliverStatus && "已回收" == recyclingStatus){ + showResult("该单不能被终止!"); + return true; + } + return false; +} + +/** + * 判断一次性物品申请单是否能被终止 + * @param record 选中的记录 + * @returns {boolean} + */ +function judgeDisposeGood(record) { + var deliverStatus = record.get('deliverStatus'); + if ("已发货" == deliverStatus){ + showResult("该单不能被终止!"); + return true; + } + return false; +} + +/** + * 判断外来器械申请单是否能被终止 + * @param record 选中的记录 + * @returns {boolean} + */ +function judgeForeign(record) { + var returnTime = record.get('returnTime'); + var returnMan = record.get('returnMan'); + var deliverStatus = record.get('deliverStatus'); + var recyclingStatus = record.get('recyclingStatus'); + if ("已发货" == deliverStatus && "已回收" == recyclingStatus && (!Ext.isEmpty(returnTime) || !Ext.isEmpty(returnMan))){ + showResult("该单不能被终止!"); + return true; + } + return false; } \ No newline at end of file