全局左右拖拽组件
This commit is contained in:
parent
8e1d3a3da7
commit
883fff3808
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<el-container>
|
<el-container>
|
||||||
<el-aside class="scenario-aside" id="silderLeft">
|
<el-aside class="scenario-aside">
|
||||||
<div class="scenario-list">
|
<div class="scenario-list">
|
||||||
<ms-api-collapse v-model="activeName" @change="handleChange">
|
<ms-api-collapse v-model="activeName" @change="handleChange">
|
||||||
<draggable :list="scenarios" group="Scenario" class="scenario-draggable" ghost-class="scenario-ghost">
|
<draggable :list="scenarios" group="Scenario" class="scenario-draggable" ghost-class="scenario-ghost">
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
<el-button slot="reference" :disabled="isReadOnly" class="scenario-create" type="primary" size="mini"
|
<el-button slot="reference" :disabled="isReadOnly" class="scenario-create" type="primary" size="mini"
|
||||||
icon="el-icon-plus" plain/>
|
icon="el-icon-plus" plain/>
|
||||||
</el-popover>
|
</el-popover>
|
||||||
<div class="moveBtn" v-move></div>
|
<ms-horizontal-drag-bar/>
|
||||||
</el-aside>
|
</el-aside>
|
||||||
|
|
||||||
<el-main class="scenario-main">
|
<el-main class="scenario-main">
|
||||||
|
@ -77,11 +77,13 @@ import {Request, Scenario} from "../model/ScenarioModel";
|
||||||
import draggable from 'vuedraggable';
|
import draggable from 'vuedraggable';
|
||||||
import MsApiScenarioSelect from "@/business/components/api/test/components/ApiScenarioSelect";
|
import MsApiScenarioSelect from "@/business/components/api/test/components/ApiScenarioSelect";
|
||||||
import {parseEnvironment} from "../model/EnvironmentModel";
|
import {parseEnvironment} from "../model/EnvironmentModel";
|
||||||
|
import MsHorizontalDragBar from "../../../common/components/MsHorizontalDragBar";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "MsApiScenarioConfig",
|
name: "MsApiScenarioConfig",
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
|
MsHorizontalDragBar,
|
||||||
MsApiScenarioSelect,
|
MsApiScenarioSelect,
|
||||||
MsApiRequestConfig,
|
MsApiRequestConfig,
|
||||||
MsApiScenarioForm,
|
MsApiScenarioForm,
|
||||||
|
@ -112,23 +114,6 @@ export default {
|
||||||
currentScenario: {}
|
currentScenario: {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
directives: {
|
|
||||||
move(el, bindings) {
|
|
||||||
el.onmousedown = function (e) {
|
|
||||||
const init = e.clientX;
|
|
||||||
const parent = document.getElementById("silderLeft");
|
|
||||||
const initWidth = parent.offsetWidth;
|
|
||||||
document.onmousemove = function (e) {
|
|
||||||
const end = e.clientX;
|
|
||||||
const newWidth = end - init + initWidth;
|
|
||||||
parent.style.width = newWidth + "px";
|
|
||||||
};
|
|
||||||
document.onmouseup = function () {
|
|
||||||
document.onmousemove = document.onmouseup = null;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
watch: {
|
||||||
test() {
|
test() {
|
||||||
this.initScenarioEnvironment();
|
this.initScenarioEnvironment();
|
||||||
|
@ -355,13 +340,4 @@ export default {
|
||||||
color: #8a8b8d;
|
color: #8a8b8d;
|
||||||
}
|
}
|
||||||
|
|
||||||
.moveBtn{
|
|
||||||
height: 100%;
|
|
||||||
width: 2px;
|
|
||||||
position: absolute;
|
|
||||||
right: 0px;
|
|
||||||
top: 0;
|
|
||||||
cursor: col-resize;
|
|
||||||
background-color: #DCDFE6;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,17 +1,20 @@
|
||||||
<template>
|
<template>
|
||||||
<el-aside :width="width" class="ms-aside-container"
|
<el-aside :width="width" class="ms-aside-container"
|
||||||
:style="{'margin-left': !asideHidden ? 0 : '-' + width}">
|
:style="{'margin-left': !asideHidden ? 0 : '-' + width}">
|
||||||
<div v-if="enableAsideHidden" class="hiddenBottom" @click="asideHidden = !asideHidden" :style="{'left': asideHidden ? 0 : width}">
|
<!--<div v-if="enableAsideHidden" class="hiddenBottom" @click="asideHidden = !asideHidden">-->
|
||||||
<i v-if="!asideHidden" class="el-icon-arrow-left"/>
|
<!--<i v-if="!asideHidden" class="el-icon-arrow-left"/>-->
|
||||||
<i v-if="asideHidden" class="el-icon-arrow-right"/>
|
<!--<i v-if="asideHidden" class="el-icon-arrow-right"/>-->
|
||||||
</div>
|
<!--</div>-->
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
|
<ms-horizontal-drag-bar/>
|
||||||
</el-aside>
|
</el-aside>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import MsHorizontalDragBar from "./MsHorizontalDragBar";
|
||||||
export default {
|
export default {
|
||||||
name: "MsAsideContainer",
|
name: "MsAsideContainer",
|
||||||
|
components: {MsHorizontalDragBar},
|
||||||
props: {
|
props: {
|
||||||
width: {
|
width: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -39,12 +42,16 @@
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
background-color: #FFF;
|
background-color: #FFF;
|
||||||
height: calc(100vh - 80px);
|
height: calc(100vh - 80px);
|
||||||
|
border-right: 0px;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hiddenBottom {
|
.hiddenBottom {
|
||||||
width: 8px;
|
width: 8px;
|
||||||
height: 50px;
|
height: 50px;
|
||||||
top: calc((100vh - 80px)/3);
|
top: calc((100vh - 80px)/3);
|
||||||
|
right: -10px;
|
||||||
|
/*top: 0;*/
|
||||||
line-height: 50px;
|
line-height: 50px;
|
||||||
border-radius: 0 15px 15px 0;
|
border-radius: 0 15px 15px 0;
|
||||||
background-color: #acb7c1;
|
background-color: #acb7c1;
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
<template>
|
||||||
|
<div class="drag-bar" v-horizontal-drag/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: "MsHorizontalDragBar"
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
.drag-bar {
|
||||||
|
height: 100%;
|
||||||
|
width: 1px;
|
||||||
|
position: absolute;
|
||||||
|
right: 0px;
|
||||||
|
top: 0;
|
||||||
|
cursor: col-resize;
|
||||||
|
background-color: #E6E6E6;
|
||||||
|
border: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.drag-bar:hover {
|
||||||
|
width: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
|
@ -18,6 +18,7 @@ import '../common/css/menu-header.css';
|
||||||
import '../common/css/main.css';
|
import '../common/css/main.css';
|
||||||
import CKEditor from '@ckeditor/ckeditor5-vue';
|
import CKEditor from '@ckeditor/ckeditor5-vue';
|
||||||
import VueFab from 'vue-float-action-button'
|
import VueFab from 'vue-float-action-button'
|
||||||
|
import {horizontalDrag} from "../common/js/directive";
|
||||||
|
|
||||||
Vue.config.productionTip = false;
|
Vue.config.productionTip = false;
|
||||||
Vue.use(icon);
|
Vue.use(icon);
|
||||||
|
@ -43,6 +44,9 @@ Vue.directive('xpack', xpack);
|
||||||
|
|
||||||
Vue.directive('tester', tester);
|
Vue.directive('tester', tester);
|
||||||
|
|
||||||
|
//支持左右拖拽
|
||||||
|
Vue.directive('horizontal-drag', horizontalDrag);
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
el: '#app',
|
el: '#app',
|
||||||
router,
|
router,
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
export const horizontalDrag = {
|
||||||
|
inserted(el, binding) {
|
||||||
|
el.onmousedown = function (e) {
|
||||||
|
const init = e.clientX;
|
||||||
|
const parent = el.parentNode;
|
||||||
|
const initWidth = parent.offsetWidth;
|
||||||
|
document.onmousemove = function (e) {
|
||||||
|
const end = e.clientX;
|
||||||
|
const newWidth = end - init + initWidth;
|
||||||
|
parent.style.width = newWidth + "px";
|
||||||
|
};
|
||||||
|
document.onmouseup = function () {
|
||||||
|
document.onmousemove = document.onmouseup = null;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue