export const changeWidth={
    mounted() {
        // this.dragControllerDiv()
    },
    methods: {
        dragControllerDiv:function() {
            var resize = document.getElementsByClassName('resize');
            var left = document.getElementsByClassName('left');
            var mid = document.getElementsByClassName('mid');
            var box = document.getElementsByClassName('box');
            for (let i = 0; i < resize.length; i++) {
                // 鼠标按下事件
                resize[i].onmousedown = function (e) {
                    //颜色改变提醒
                    resize[i].style.background = '#818181';
                    var startX = e.clientX;
                    resize[i].left = resize[i].offsetLeft;
                    // 鼠标拖动事件
                    document.onmousemove = function (e) {
                        var endX = e.clientX;
                        var moveLen = resize[i].left + (endX - startX); // （endx-startx）=移动的距离。resize[i].left+移动的距离=左边区域最后的宽度
                        var maxT = box[i].clientWidth - resize[i].offsetWidth; // 容器宽度 - 左边区域的宽度 = 右边区域的宽度

                        if (moveLen < 32) moveLen = 32; // 左边区域的最小宽度为32px
                        if (moveLen > maxT - 150) moveLen = maxT - 150; //右边区域最小宽度为150px

                        resize[i].style.left = moveLen; // 设置左侧区域的宽度

                        for (let j = 0; j < left.length; j++) {
                            left[j].style.width = moveLen + 'px';
                           if(mid[j]){
                            mid[j].style.width = (box[i].clientWidth - moveLen - 10) + 'px';
                           }
                            
                        }
                    };
                    // 鼠标松开事件
                    document.onmouseup = function (evt) {
                        //颜色恢复
                        resize[i].style.background = '#d6d6d6';
                        document.onmousemove = null;
                        document.onmouseup = null;
                        resize[i].releaseCapture && resize[i].releaseCapture(); //当你不在需要继续获得鼠标消息就要应该调用ReleaseCapture()释放掉
                    };
                    resize[i].setCapture && resize[i].setCapture(); //该函数在属于当前线程的指定窗口里设置鼠标捕获
                    return false;
                };
            }
        },
        dragControllerDiv1:function() {
            var resize1 = document.getElementsByClassName('resize1');
            var left = document.getElementsByClassName('left1');
            var mid = document.getElementsByClassName('mid1');
            var box = document.getElementsByClassName('box1');
            
            for (let i = 0; i < resize1.length; i++) {
                // 鼠标按下事件
                resize1[i].onmousedown = function (e) {
                    //颜色改变提醒
                    resize1[i].style.background = '#818181';
                    var startX = e.clientX;
                    resize1[i].left = resize1[i].offsetLeft-50;
                    // 鼠标拖动事件
                    document.onmousemove = function (e) {
                        var flex = box[i].style.flexDirection
                        var endX = e.clientX;
                        var moveLen = resize1[i].left + (endX - startX); // （endx-startx）=移动的距离。resize[i].left+移动的距离=左边区域最后的宽度
                        var maxT = box[i].clientWidth - resize1[i].offsetWidth; // 容器宽度 - 左边区域的宽度 = 右边区域的宽度

                        if (moveLen < 32) moveLen = 32; // 左边区域的最小宽度为32px
                        if (moveLen > maxT - 150) moveLen = maxT - 150; //右边区域最小宽度为150px

                        resize1[i].style.left = moveLen; // 设置左侧区域的宽度

                        for (let j = 0; j < left.length; j++) {
                            switch (flex) {
                                case 'row-reverse':
                                    mid[j].style.width = moveLen + 'px';
                                    if(left[j]){
                                     left[j].style.width = (box[i].clientWidth - moveLen - 10) + 'px';
                                    }
                                    break;
                                case 'row':
                                    left[j].style.width = moveLen + 'px';
                                    if(mid[j]){
                                        mid[j].style.width = (box[i].clientWidth - moveLen - 10) + 'px';
                                    }
                                    break;
                                case 'column-reverse':
                                    
                                    break;
                                case 'column':
                                    
                                    break;
                                default:
                                    break;
                            }
                       
                          
                        }
                    };
                    // 鼠标松开事件
                    document.onmouseup = function (evt) {
                        //颜色恢复
                        resize1[i].style.background = '#d6d6d6';
                        document.onmousemove = null;
                        document.onmouseup = null;
                        resize1[i].releaseCapture && resize1[i].releaseCapture(); //当你不在需要继续获得鼠标消息就要应该调用ReleaseCapture()释放掉
                    };
                    resize1[i].setCapture && resize1[i].setCapture(); //该函数在属于当前线程的指定窗口里设置鼠标捕获
                    return false;
                };
            }
        },
        dragControllerDiv2:function() {
            var resize1 = document.getElementsByClassName('resize2');
            var left = document.getElementsByClassName('left1');
            var mid = document.getElementsByClassName('mid1');
            var box = document.getElementsByClassName('box1');
            
            for (let i = 0; i < resize1.length; i++) {
                // 鼠标按下事件
                resize1[i].onmousedown = function (e) {
                    var flex = box[i].style.flexDirection
                    switch (flex) {
                        case 'row-reverse':
                           
                            break;
                        case 'row':
                            
                            break;
                        case 'column-reverse':
                            resize1[i].top = mid[i].offsetHeight;
                            break;
                        case 'column':
                            resize1[i].top = left[i].offsetHeight;
                            break;
                        default:
                            break;
                    }
                    //颜色改变提醒
                    resize1[i].style.background = '#818181';
                    var startX = e.clientY;
                    // resize1[i].top = resize1[i].offsetTop;
                    // 鼠标拖动事件
                    document.onmousemove = function (e) {
                        
                        var endX = e.clientY;
                        var moveLen = resize1[i].top + (endX - startX); // （endx-startx）=移动的距离。resize[i].left+移动的距离=左边区域最后的宽度
                        var maxT = box[i].clientHeight - resize1[i].offsetHeight; // 容器宽度 - 左边区域的宽度 = 右边区域的宽度
                        if (moveLen < 150) moveLen = 150; // 左边区域的最小宽度为32px
                        if (moveLen > maxT - 150) moveLen = maxT - 150; //右边区域最小宽度为150px

                        resize1[i].style.top = moveLen; // 设置左侧区域的宽度
                        for (let j = 0; j < left.length; j++) {
                            switch (flex) {
                                case 'row-reverse':
                                   
                                    break;
                                case 'row':
                                    
                                    break;
                                case 'column-reverse':
                                    mid[j].style.height = moveLen + 10 + 'px';
                                    if(left[j]){
                                        left[j].style.height = (box[i].clientHeight - moveLen ) + 'px';
                                    }
                                    break;
                                case 'column':
                                    left[j].style.height = moveLen + 10 + 'px';
                                    if(mid[j]){
                                        mid[j].style.height = (box[i].clientHeight - moveLen ) + 'px';
                                    }
                                    break;
                                default:
                                    break;
                            }
                       
                          
                        }
                    };
                    // 鼠标松开事件
                    document.onmouseup = function (evt) {
                        //颜色恢复
                        resize1[i].style.background = '#d6d6d6';
                        document.onmousemove = null;
                        document.onmouseup = null;
                        resize1[i].releaseCapture && resize1[i].releaseCapture(); //当你不在需要继续获得鼠标消息就要应该调用ReleaseCapture()释放掉
                    };
                    resize1[i].setCapture && resize1[i].setCapture(); //该函数在属于当前线程的指定窗口里设置鼠标捕获
                    return false;
                };
            }
        },
    },
}