Index: ssts-web/src/main/webapp/disinfectsystem/recyclingApplication/goodsTemplateApplicationView.js
===================================================================
diff -u -r14937 -r14960
--- ssts-web/src/main/webapp/disinfectsystem/recyclingApplication/goodsTemplateApplicationView.js (.../goodsTemplateApplicationView.js) (revision 14937)
+++ ssts-web/src/main/webapp/disinfectsystem/recyclingApplication/goodsTemplateApplicationView.js (.../goodsTemplateApplicationView.js) (revision 14960)
@@ -327,6 +327,9 @@
{name : 'packageSpec',mapping : 'packageSpec'},
{name : 'unit',mapping : 'unit'},
{name : 'amount',mapping : 'amount'},
+ {name : 'middlePackageUnit',mapping : 'middlePackageUnit'},
+ {name : 'middlePackageAmount',mapping : 'middlePackageAmount'},
+ {name : 'transferScale',mapping : 'transferScale'},
{name : 'urgentAmount',mapping : 'urgentAmount'},
{name : 'materials',mapping : 'materials'},
{name : 'minApplyAmount',mapping : 'minApplyAmount'},
@@ -467,6 +470,9 @@
{name : 'name'},
{name : 'count'},
{name : 'amout'},
+ {name : 'minUnit'},
+ {name : 'transferScale'},
+ {name : 'unitCount'},
{name : 'countBackup'},
{name : 'minApplyAmount'},
{name : 'maxApplyAmount'},
@@ -595,7 +601,7 @@
return foundNode;
}
-function updateNode(treegrid, foundNode, count, price,urgentAmount){
+function updateNode(treegrid, foundNode, count, price,urgentAmount,para){
var targetNode = foundNode;
targetNode.set('urgentAmount', urgentAmount);
@@ -613,17 +619,51 @@
var panel = top.Ext4.getCmp(treegrid);
targetNode.set('count', count);
targetNode.set('totalPrice', roundValue(price*count));
+
+ if (!isUndefinedOrNullOrEmpty(para)){
+ para.price = price;
+ para.count = count;
+ }
+ resetDisGoodProperties(targetNode,para);
+
panel.getSelectionModel().select(targetNode, true);
}
+/**
+ * 重新设置一次性物品节点的值
+ * @param targetNode 对应的节点
+ * @param para 需要传递的参数
+ */
+function resetDisGoodProperties(targetNode,para) {
+ // 判断该一次性物品是否有中包装单位装换单位系数或者中包装单位,如果没有,则将表格的transferScale,unitCount,minUnit清空,单位用回最小的单位,
+ // 这里是用于提交了设置了中包装单位的一次性物品后,中包装单位发生变化,用户点击了同样物品添加时,这时的单位和中包装单位装换单位系数取最新的数值,如果只是在单元格修改其数量,
+ // 只会取原来的比例和单位
+ if (targetNode.get('tousseType') == "一次性物品" && !isUndefinedOrNullOrEmpty(para)){
+ if (isUndefinedOrNullOrEmpty(para.transferScale) || isUndefinedOrNullOrEmpty(para.middlePackageUnit)){
+ targetNode.set('transferScale','');
+ targetNode.set('unitCount','');
+ var minUnit = targetNode.get('minUnit');
+ targetNode.set('minUnit','');
+ targetNode.set('unit',minUnit);
+ }
+ else {
+ targetNode.set('transferScale',para.transferScale);
+ targetNode.set('unitCount', para.count * para.transferScale);
+ targetNode.set('minUnit',targetNode.get('unit'));
+ targetNode.set('unit',para.middlePackageUnit);
+ targetNode.set('totalPrice', roundValue(para.price * para.count * para.transferScale));
+ }
+ }
+}
+
//TODO 5 取消科室申请模板
function addItems(tousseDefinitionID,name,count,diposable,isApplyEntireTousse,price,externalCode,storageAmount,tousseType,materials,unit,packageSpec,minApplyAmount,maxApplyAmount,urgentAmount,para){
var foundNode = null;
if('是' == diposable){
foundNode = getExsistNode(rightTemplateStore, name);
if (foundNode != null){
- updateNode('diposableTreeGrid', foundNode, count, price,urgentAmount);
+ updateNode('diposableTreeGrid', foundNode, count, price,urgentAmount,para);
}
}else{
foundNode = getExsistNodeByTousseDefinitionID(leftTemplateStore, tousseDefinitionID);
@@ -642,6 +682,8 @@
// 设置添加节点的leaf属性:以及决定加入的位置
var tousseInstance = null;
if (tousseType != tousseType_disinfectGoods){
+ var transferScale = para.transferScale;
+ var middlePackageUnit = para.middlePackageUnit;
tousseInstance = Ext4.create('ApplyItemModel',{
id : 0,
tousseDefinitionID: tousseDefinitionID,
@@ -652,13 +694,18 @@
price : price,
externalCode : externalCode,
storage : storageAmount,
- unit : unit,
+ //如果存在中包装的单位这里的单位就显示中包装,minUnit缓存原来的最小单位,如果不存在则直接用回原来的单位
+ unit : isUndefinedOrNullOrEmpty(middlePackageUnit) ? unit :middlePackageUnit,
+ minUnit : unit,
+ transferScale : isUndefinedOrNullOrEmpty(transferScale) ? '':transferScale,
+ //原来最小单位的数量
+ unitCount : isUndefinedOrNullOrEmpty(transferScale) ? '':count * transferScale,
leaf : true,
children : materials,
minApplyAmount : minApplyAmount,
maxApplyAmount : maxApplyAmount,
urgentAmount : urgentAmount,
- totalPrice:roundValue(price*count),
+ totalPrice: isUndefinedOrNullOrEmpty(transferScale) ? roundValue(price*count) : roundValue(price*count*transferScale),
packageSpec:packageSpec
});
}
@@ -793,15 +840,19 @@
var tousseType = top.Ext4.getCmp('tousseType').getValue();
var materials = top.Ext4.getCmp('materials').getValue();
var urgentAmount = top.Ext4.getCmp('urgentAmount').getValue();
-
+ var transferScale = top.Ext4.getCmp('transferScale').getValue();
+ var middlePackageUnit = top.Ext4.getCmp('middlePackageUnit').getValue();
+
var price = top.Ext4.getCmp('price').getValue();
var externalCode = isDiposableGoods == '是' ?top.Ext4.getCmp('externalCode').getValue() : '';
var unit = top.Ext4.getCmp('unit').getValue();
var packageSpec = top.Ext4.getCmp('packageSpec').getValue();
var isApplyEntireTousse = top.Ext4.getCmp('isApplyEntireTousse').getValue();
//para对象,里面可以有多钟属性,方便以后扩展addItems用
var para = {
- behavior : 'add'
+ behavior : 'add',
+ transferScale: transferScale,
+ middlePackageUnit: middlePackageUnit
};
if(Ext4.isEmpty(name)){
var alertTips = "请输入器械包!";
@@ -966,6 +1017,12 @@
obj.tousseType = node.get("tousseType");
obj.externalCode = node.get("externalCode");
obj.urgentAmount = node.get("urgentAmount");
+ if (node.get("tousseType") == "一次性物品"){
+ obj.transferScale = node.get("transferScale");
+ obj.minUnit = node.get("minUnit");
+ obj.unitCount = node.get("unitCount");
+ }
+
// 普通物品
if (node.get("leaf") == true){
obj.spec = "";
@@ -1492,6 +1549,21 @@
flex : 1,
sortable: false
},{
+ header : "最小单位数量",
+ dataIndex : 'unitCount',
+ hidden: true,
+ sortable: false
+ },{
+ header : "原来的最小单位",
+ dataIndex : 'minUnit',
+ hidden: true,
+ sortable: false
+ },{
+ header : "中包装单位装换单位系数",
+ dataIndex : 'transferScale',
+ hidden: true,
+ sortable: false
+ },{
header : "包装规格",
dataIndex : 'packageSpec',
width : 65 * fontSizeScale,
@@ -1647,6 +1719,7 @@
var isDiposableGoods = record.get("diposable");
var minApplyAmount = record.get("minApplyAmount");
var maxApplyAmount = record.get("maxApplyAmount");
+ var totalPrice;
if (isDiposableGoods == '是' && context.value != null && context.value != ''){
if ("urgentAmount" != context.field){
@@ -1663,6 +1736,7 @@
top.Ext4.Msg.alert("提示消息","申请数量大于最大可申请数量");
}
}
+ totalPrice = reCalculateTotalPriceAndSetUnitCount(record,context);
}
var depth = record.getDepth();
@@ -1686,7 +1760,7 @@
}
}
- record.set("totalPrice", roundValue(context.value * record.get("price")));
+ record.set("totalPrice", isUndefinedOrNullOrEmpty(totalPrice) ? roundValue(context.value * record.get("price")):totalPrice);
if (context.value == 0){
record.set("count", "");
}
@@ -1712,7 +1786,25 @@
}
});
+ /**
+ * 重新计算总价格并重新设置最小单位的数量
+ * @param record 该行的数据
+ * @param context
+ * @returns {*} 返回新的总价格
+ */
+ function reCalculateTotalPriceAndSetUnitCount(record,context) {
+ var totalPrice;
+ //如果配置了中包装单位装换单位系数,则小计=最小单位数量*单价
+ var transferScale = record.get('transferScale');
+ if (!isUndefinedOrNullOrEmpty(transferScale)){
+ var unitCount = context.value * transferScale;
+ record.set('unitCount',unitCount);
+ totalPrice = roundValue(unitCount * record.get("price"));
+ }
+ return totalPrice;
+ }
+
var handleUrgentAmount = {
//判断加急数量是否大于申请数量
handleUaAndCount: function (urgentAmount,count) {
@@ -1758,9 +1850,13 @@
// 右边的,如果这次遍历没找到externalCode相同,则旧数据当成是新数据插入
handleRight: function(cache,newData,flag){
Ext.each(newData,function (i) {
- if(cache.externalCode == i.externalCode){
+ if(cache.name == i.name){
+ // if(cache.externalCode == i.externalCode){
i.count = cache.count;
i.urgentAmount = cache.urgentAmount;
+ i.transferScale = cache.transferScale;
+ i.minUnit = cache.minUnit;
+ i.unitCount = cache.unitCount;
flag = false;
}
});
@@ -1953,8 +2049,16 @@
xtype : 'hidden',
name : 'unit',
id : 'unit'
- }, {
+ },{
xtype : 'hidden',
+ name : 'middlePackageUnit',
+ id : 'middlePackageUnit'
+ }, {
+ xtype : 'hidden',
+ name : 'transferScale',
+ id : 'transferScale'
+ },{
+ xtype : 'hidden',
name : 'price',
id : 'price'
}, {
@@ -2248,13 +2352,16 @@
var packageSpec = record.data.packageSpec;
top.Ext4.getCmp('unit').setValue(unit);
top.Ext4.getCmp('packageSpec').setValue(packageSpec);
- var unitInfo = ' 单位:' + unit + ' ';
+ var middlePackageUnit = record.data.middlePackageUnit;
+ var unitInfo = ' 单位:' + (isUndefinedOrNullOrEmpty(middlePackageUnit) ? unit : middlePackageUnit) + ' ';
if (packageSpec != null && packageSpec != ''){
unitInfo += '包装规格:' + packageSpec + '';
}
top.Ext4.getCmp('unitInfoDisplayField').setValue(unitInfo);
}
top.Ext4.getCmp('price').setValue(record.data.price);
+ top.Ext4.getCmp('middlePackageUnit').setValue(record.data.middlePackageUnit);
+ top.Ext4.getCmp('transferScale').setValue(record.data.transferScale);
top.Ext4.getCmp('count1').focus('',10);
},
specialkey : function(field, ee) {
@@ -2519,6 +2626,10 @@
var totalPrice = stringToFloat(n.get('totalPrice') + "");
var urgentAmount = n.get('urgentAmount');
var isApplyEntireTousse = n.get('isApplyEntireTousse');
+ //下面三个是一次物品配置了中包装单位,数量,比例才会有
+ var unitCount = n.get('unitCount');
+ var minUnit = n.get('minUnit');
+ var transferScale = n.get('transferScale');
tousseNames += n.get('name') + ";";
var tousseType = n.get('tousseType');
@@ -2569,6 +2680,9 @@
'diposable': n.get('diposable'),
'tousseType': tousseType,
'unit': unit,
+ 'unitCount': isUndefinedOrNullOrEmpty(unitCount) ? null : unitCount,
+ 'minUnit': isUndefinedOrNullOrEmpty(minUnit) ? null : minUnit,
+ 'transferScale': isUndefinedOrNullOrEmpty(transferScale) ? null : transferScale,
'disinfectMaterilas':disinfectMaterilas
});
}
@@ -3471,7 +3585,7 @@
}];
//如果不是用版本2或者是在高级视图的全部申请单打开或者不是临床科室则按原来的显示
- if (recyclingApplicationVersion != 2 || listType == 'all' || isCssdUser == 'true'){
+ if (recyclingApplicationVersion != 2 || listType == 'all' || isCssdUser == "true"){
grid = new Ext.ux.ForgonPageGrid({
title : entityName + '单列表',
tbar : tbar,