Index: ssts-web/src/main/webapp/disinfectsystem/sterilizationmanager/sterilizationrecord/sterilizationRecordPic.js =================================================================== diff -u -r15667 -r15669 --- ssts-web/src/main/webapp/disinfectsystem/sterilizationmanager/sterilizationrecord/sterilizationRecordPic.js (.../sterilizationRecordPic.js) (revision 15667) +++ ssts-web/src/main/webapp/disinfectsystem/sterilizationmanager/sterilizationrecord/sterilizationRecordPic.js (.../sterilizationRecordPic.js) (revision 15669) @@ -9,6 +9,11 @@ var currentImageId;//当前image对象id var ImgView; var curRotateIndex = 0; +// 当前旋转的宽和高 +var currentRotateWidth = 0; +var currentRotateHeight = 0; +// 连续选择次数 +var continueRotateCount = 0; Ext.onReady(function() { //屏蔽右击事件 @@ -94,24 +99,40 @@ }catch(e){ //alert(e.msg); } + currentRotateWidth = 0; + currentRotateHeight = 0; + continueRotateCount = 0; currentImageWidth = nwidth; }, - switchHeightWidth: function(el) { + switchHeightWidth: function(el,curWidth,curHeight,rotateCount) { var width = el.getWidth(); - var height = el.getHeight(); + var height = el.getHeight(); var nwidth = height; var nheight = width; - if(curRotateIndex == 0 || curRotateIndex == 2){ - // 如果原图高比宽大,那么转后的高也要比宽大 - if( ((srcHeight > srcWidth) && (nheight < nwidth)) - || ((srcHeight < srcWidth) && (nheight > nwidth)) ){ - var temp = nheight; - nheight = nwidth; - nwidth = temp; + if(curWidth > 0 && curHeight > 0){ + var num = rotateCount % 2; + if(num == 0){ + // 宽高不变 + nwidth = curWidth; + nheight = curHeight; + }else{ + // 宽高切换 + nwidth = curHeight; + nheight = curWidth; } } +// if(curRotateIndex == 0 || curRotateIndex == 2){ +// // 如果原图高比宽大,那么转后的高也要比宽大 +// if( ((srcHeight > srcWidth) && (nheight < nwidth)) +// || ((srcHeight < srcWidth) && (nheight > nwidth)) ){ +// var temp = nheight; +// nheight = nwidth; +// nwidth = temp; +// } +// } var left = (width > nwidth) ? -((nwidth - width) / 2):((width - nwidth) / 2); var top = (height > nheight) ? -((nheight - height) / 2):((height - nheight) / 2); +// alert("height : " + height + " to " + nheight ); try{ el.animate( { @@ -309,12 +330,18 @@ xtype : 'button', text : '放大', handler : function(){ + currentRotateWidth = 0; + currentRotateHeight = 0; + continueRotateCount = 0; Ext.get(currentImageId).parent.zoom(Ext.get(currentImageId), scale,true); } },{ xtype : 'button', text : '缩小', handler : function(){ + currentRotateWidth = 0; + currentRotateHeight = 0; + continueRotateCount = 0; Ext.get(currentImageId).parent.zoom(Ext.get(currentImageId), scale,false); } },{ @@ -328,8 +355,13 @@ // document.getElementById(currentImageId).className = className;alert(className); curRotateIndex = (curRotateIndex + 1) % 4; var imageBrowse = Ext.get(currentImageId); - // 切换宽高 - Ext.get(currentImageId).parent.switchHeightWidth(imageBrowse); + if(currentRotateWidth == 0 && currentRotateHeight == 0){ + currentRotateWidth = imageBrowse.getWidth(); + currentRotateHeight = imageBrowse.getHeight(); + } + continueRotateCount++; + // 切换宽高 + Ext.get(currentImageId).parent.switchHeightWidth(imageBrowse,currentRotateWidth,currentRotateHeight,continueRotateCount); var url = WWWROOT + '/disinfectSystem/sterilization/sterilizationRecordAction!getSterilizationRecordPic.do?id=' + id + '&page=' + page + '&rotateIndex=' + curRotateIndex + '&time='+new Date(); var image = imageBrowse.dom; image.src = url;// 覆盖原来的图片 @@ -344,8 +376,13 @@ } curRotateIndex = (curRotateIndex - 1) % 4; var imageBrowse = Ext.get(currentImageId); + if(currentRotateWidth == 0 && currentRotateHeight == 0){ + currentRotateWidth = imageBrowse.getWidth(); + currentRotateHeight = imageBrowse.getHeight(); + } + continueRotateCount++; // 切换宽高 - Ext.get(currentImageId).parent.switchHeightWidth(imageBrowse); + Ext.get(currentImageId).parent.switchHeightWidth(imageBrowse,currentRotateWidth,currentRotateHeight,continueRotateCount); var url = WWWROOT + '/disinfectSystem/sterilization/sterilizationRecordAction!getSterilizationRecordPic.do?id=' + id + '&page=' + page + '&rotateIndex=' + curRotateIndex + '&time='+new Date(); var image = imageBrowse.dom; image.src = url;// 覆盖原来的图片 @@ -373,6 +410,9 @@ image.src = url;// 覆盖原来的图片 var element = top.Ext.get(toolbarPage.el); element.update('第' + page + '页'); + currentRotateWidth = 0; + currentRotateHeight = 0; + continueRotateCount = 0; }, failure : function(){ @@ -390,6 +430,9 @@ page = page - 1; var lastRotateIndex = curRotateIndex; curRotateIndex = 0; + currentRotateWidth = 0; + currentRotateHeight = 0; + continueRotateCount = 0; var imageBrowse = Ext.get(currentImageId); // 还原大小 Ext.get(currentImageId).parent.restore(imageBrowse); @@ -416,6 +459,9 @@ page = page + 1; var lastRotateIndex = curRotateIndex; curRotateIndex = 0; + currentRotateWidth = 0; + currentRotateHeight = 0; + continueRotateCount = 0; // 还原大小 var imageBrowse = Ext.get(currentImageId); if(lastRotateIndex == 1 || lastRotateIndex == 3){