Browse Source

缩放调整

jwyu 1 năm trước cách đây
mục cha
commit
c297ec31c6
1 tập tin đã thay đổi với 12 bổ sung1 xóa
  1. 12 1
      src/views/smartReport/editReport.vue

+ 12 - 1
src/views/smartReport/editReport.vue

@@ -342,13 +342,24 @@ export default {
         handleResizeP(e,index){
             this.isDragResize=true
             e.preventDefault()
+            const parentBox=e.target.parentNode.parentNode
+            const parentBoxWidth=parentBox.offsetWidth
+
             const targetBox=e.target.parentNode
             const targetBoxHeight=targetBox.offsetHeight
+            const targetBoxWidth=targetBox.offsetWidth
+
             const startY=e.clientY
+            const startX=e.clientX
             document.onmousemove=(mouseEl)=>{
                 mouseEl.preventDefault()
                 const h=mouseEl.clientY-startY+targetBoxHeight
                 targetBox.style.minHeight=`${h<50?50:h}px`
+
+                // 计算宽度
+                const w=mouseEl.clientX-startX+targetBoxWidth
+                const resW= (w/parentBoxWidth)*100//计算出的百分比结果值
+                targetBox.style.width=`${resW>=100?100:resW}%`
             }
             document.onmouseup=(el)=>{
                 console.log(targetBox.style.cssText);
@@ -1148,7 +1159,7 @@ div{
                 height: 8px;
                 display: none;
                 border: 1px solid #0052D9;
-                cursor: n-resize;
+                cursor: nw-resize;
             }
         }
         .report-drag-item-wrap_child-wrap{