style(接口测试): 优化接口用例编辑抽屉的布局

--story=1011683 --user=宋天阳 固定接口case执行按钮行
https://www.tapd.cn/55049933/s/1360395
This commit is contained in:
song-tianyang 2023-04-07 17:27:23 +08:00 committed by 建国
parent d805b50884
commit bc5dc86247
3 changed files with 310 additions and 250 deletions

View File

@ -1,207 +1,214 @@
<template> <template>
<el-card style="margin-top: 5px" @click.native="selectTestCase(apiCase, $event)" v-loading="saveLoading"> <el-card style="margin-top: 5px" @click.native="selectTestCase(apiCase, $event)" v-loading="saveLoading">
<div @click="active(apiCase)" v-if="type !== 'detail'"> <el-container>
<el-row> <el-header style="margin-bottom: 20px">
<el-col :span="api.protocol === 'HTTP' ? 4 : 8" v-loading="loading && !(apiCase.active || type === 'detail')"> <div @click="active(apiCase)" v-if="type !== 'detail'" ref="elementHeader">
<span @click.stop>
<i class="icon el-icon-arrow-right" :class="{ 'is-active': apiCase.active }" @click="active(apiCase)" />
<el-input
v-if="!apiCase.id || isShowInput"
size="small"
v-model="apiCase.name"
:name="index"
:key="index"
class="ms-api-header-select"
style="width: 180px"
:readonly="!hasPermission('PROJECT_API_DEFINITION:READ+EDIT_CASE')"
:placeholder="$t('commons.input_name')"
ref="nameEdit" />
<span v-else>
<el-tooltip :content="apiCase.id ? apiCase.name : ''" placement="top">
<span>{{ apiCase.id ? apiCase.name : '' | ellipsis }}</span>
</el-tooltip>
<i class="el-icon-edit" style="cursor: pointer" @click="showInput(apiCase)" />
</span>
<el-link type="primary" style="margin-left: 10px" @click="openHis(apiCase)" v-if="apiCase.id">{{
$t('operating_log.change_history')
}}</el-link>
</span>
<div v-if="apiCase.id" style="color: #999999; font-size: 12px">
<span style="margin-left: 10px">
{{ apiCase.updateTime | datetimeFormat }}
{{ apiCase.updateUser }}
{{ $t('api_test.definition.request.update_info') }}
</span>
</div>
</el-col>
<el-col :span="2">
<el-select
size="mini"
v-model="apiCase.priority"
class="ms-api-select"
@change="changePriority(apiCase)"
:disabled="readonly">
<el-option v-for="grd in priorities" :key="grd.id" :label="grd.name" :value="grd.id" />
</el-select>
</el-col>
<el-col :span="api.protocol === 'HTTP' ? 4 : 0">
<span v-if="api.protocol === 'HTTP'">
<el-tag
size="mini"
:style="{
'background-color': getColor(true, apiCase.request.method),
border: getColor(true, apiCase.request.method),
}"
class="api-el-tag">
{{ apiCase.request.method }}
</el-tag>
<el-tooltip :content="apiCase.request.path">
<span class="ms-col-name">{{ apiCase.request.path }}</span>
</el-tooltip>
</span>
</el-col>
<el-col :span="5">
<el-row> <el-row>
<el-col :span="8"> <el-col
<el-select :span="api.protocol === 'HTTP' ? 4 : 8"
size="small" v-loading="loading && !(apiCase.active || type === 'detail')">
v-model="apiCase.caseStatus" <span @click.stop>
style="margin-right: 5px" <i class="icon el-icon-arrow-right" :class="{ 'is-active': apiCase.active }" @click="active(apiCase)" />
@change="saveTestCase(apiCase, true)" <el-input
:disabled="readonly"> v-if="!apiCase.id || isShowInput"
<el-option v-for="item in options" :key="item.id" :label="$t(item.label)" :value="item.id" /> size="small"
</el-select> v-model="apiCase.name"
</el-col> :name="index"
<el-col :span="16"> :key="index"
<div class="tag-item" @click.stop> class="ms-api-header-select"
<el-tooltip style="width: 180px"
:content="$t('commons.follow')" :readonly="!hasPermission('PROJECT_API_DEFINITION:READ+EDIT_CASE')"
placement="bottom" :placeholder="$t('commons.input_name')"
effect="dark" ref="nameEdit" />
v-if="!showFollow" <span v-else>
:disabled="true"> <el-tooltip :content="apiCase.id ? apiCase.name : ''" placement="top">
<i <span>{{ apiCase.id ? apiCase.name : '' | ellipsis }}</span>
class="el-icon-star-off" </el-tooltip>
style="
color: var(--primary_color); <i class="el-icon-edit" style="cursor: pointer" @click="showInput(apiCase)" />
font-size: 25px; </span>
margin-top: 2px;
margin-right: 15px; <el-link type="primary" style="margin-left: 10px" @click="openHis(apiCase)" v-if="apiCase.id">{{
cursor: pointer; $t('operating_log.change_history')
" }}</el-link>
@click="saveFollow" /> </span>
</el-tooltip> <div v-if="apiCase.id" style="color: #999999; font-size: 12px">
<el-tooltip <span style="margin-left: 10px">
:content="$t('commons.cancel')" {{ apiCase.updateTime | datetimeFormat }}
placement="bottom" {{ apiCase.updateUser }}
effect="dark" {{ $t('api_test.definition.request.update_info') }}
v-if="showFollow" </span>
:disabled="true">
<i
class="el-icon-star-on"
style="color: #783987; font-size: 28px; margin-top: 2px; margin-right: 15px; cursor: pointer"
@click="saveFollow"
v-if="showFollow" />
</el-tooltip>
</div> </div>
</el-col> </el-col>
</el-row> <el-col :span="2">
<el-row style="margin-top: 5px"> <el-select
<div class="tag-item" @click.stop>
<ms-input-tag
:currentScenario="apiCase"
ref="tag"
@keyup.enter.native="saveTestCase(apiCase, true)"
:read-only="readonly" />
</div>
</el-row>
</el-col>
<el-col :span="3">
<span @click.stop v-if="!loaded">
<ms-tip-button
@click="singleRun(apiCase)"
:tip="$t('api_test.run')"
icon="el-icon-video-play"
v-permission="['PROJECT_API_DEFINITION:READ+RUN']"
class="run-button"
size="mini"
:disabled="!apiCase.id || loaded"
circle
v-if="!loading" />
<el-tooltip :content="$t('report.stop_btn')" placement="top" :enterable="false" v-else>
<el-button
:disabled="!apiCase.id"
@click.once="stop(apiCase)"
size="mini" size="mini"
style="color: white; padding: 0; width: 28px; height: 28px" v-model="apiCase.priority"
class="stop-btn" class="ms-api-select"
circle> @change="changePriority(apiCase)"
<div style="transform: scale(0.72)"> :disabled="readonly">
<span style="margin-left: -3.5px; font-weight: bold">STOP</span> <el-option v-for="grd in priorities" :key="grd.id" :label="grd.name" :value="grd.id" />
</el-select>
</el-col>
<el-col :span="api.protocol === 'HTTP' ? 4 : 0">
<span v-if="api.protocol === 'HTTP'">
<el-tag
size="mini"
:style="{
'background-color': getColor(true, apiCase.request.method),
border: getColor(true, apiCase.request.method),
}"
class="api-el-tag">
{{ apiCase.request.method }}
</el-tag>
<el-tooltip :content="apiCase.request.path">
<span class="ms-col-name">{{ apiCase.request.path }}</span>
</el-tooltip>
</span>
</el-col>
<el-col :span="5">
<el-row>
<el-col :span="8">
<el-select
size="small"
v-model="apiCase.caseStatus"
style="margin-right: 5px"
@change="saveTestCase(apiCase, true)"
:disabled="readonly">
<el-option v-for="item in options" :key="item.id" :label="$t(item.label)" :value="item.id" />
</el-select>
</el-col>
<el-col :span="16">
<div class="tag-item" @click.stop>
<el-tooltip
:content="$t('commons.follow')"
placement="bottom"
effect="dark"
v-if="!showFollow"
:disabled="true">
<i
class="el-icon-star-off"
style="
color: var(--primary_color);
font-size: 25px;
margin-top: 2px;
margin-right: 15px;
cursor: pointer;
"
@click="saveFollow" />
</el-tooltip>
<el-tooltip
:content="$t('commons.cancel')"
placement="bottom"
effect="dark"
v-if="showFollow"
:disabled="true">
<i
class="el-icon-star-on"
style="color: #783987; font-size: 28px; margin-top: 2px; margin-right: 15px; cursor: pointer"
@click="saveFollow"
v-if="showFollow" />
</el-tooltip>
</div>
</el-col>
</el-row>
<el-row style="margin-top: 5px">
<div class="tag-item" @click.stop>
<ms-input-tag
:currentScenario="apiCase"
ref="tag"
@keyup.enter.native="saveTestCase(apiCase, true)"
:read-only="readonly" />
</div> </div>
</el-button> </el-row>
</el-tooltip> </el-col>
</span>
<span @click.stop>
<ms-api-extend-btns :is-case-edit="isCaseEdit" :environment="environment" :row="apiCase" />
</span>
</el-col>
<el-col :span="4"> <el-col :span="3">
<ms-api-report-status :status="apiCase.execResult" /> <span @click.stop v-if="!loaded">
<div v-if="apiCase.id" style="color: #999999; font-size: 12px; padding: 5px"> <ms-tip-button
<span> {{ apiCase.execTime | datetimeFormat }}</span> @click="singleRun(apiCase)"
{{ apiCase.updateUser }} :tip="$t('api_test.run')"
icon="el-icon-video-play"
v-permission="['PROJECT_API_DEFINITION:READ+RUN']"
class="run-button"
size="mini"
:disabled="!apiCase.id || loaded"
circle
v-if="!loading" />
<el-tooltip :content="$t('report.stop_btn')" placement="top" :enterable="false" v-else>
<el-button
:disabled="!apiCase.id"
@click.once="stop(apiCase)"
size="mini"
style="color: white; padding: 0; width: 28px; height: 28px"
class="stop-btn"
circle>
<div style="transform: scale(0.72)">
<span style="margin-left: -3.5px; font-weight: bold">STOP</span>
</div>
</el-button>
</el-tooltip>
</span>
<span @click.stop>
<ms-api-extend-btns :is-case-edit="isCaseEdit" :environment="environment" :row="apiCase" />
</span>
</el-col>
<el-col :span="4">
<ms-api-report-status :status="apiCase.execResult" />
<div v-if="apiCase.id" style="color: #999999; font-size: 12px; padding: 5px">
<span> {{ apiCase.execTime | datetimeFormat }}</span>
{{ apiCase.updateUser }}
</div>
</el-col>
<el-col :span="2">
<el-link style="float: right" type="primary" @click.stop @click="showHistory(apiCase.id)">
{{ $t('commons.execute_history') }}
</el-link>
</el-col>
</el-row>
</div>
</el-header>
<el-main :style="{ height: componentHeight + 'px' }">
<!-- 请求参数-->
<el-collapse-transition>
<div v-if="apiCase.active || type === 'detail'" v-loading="loading">
<el-divider></el-divider>
<p class="tip">{{ $t('api_test.definition.request.req_param') }}</p>
<ms-api-request-form
:isShowEnable="true"
:showScript="true"
:headers="apiCase.request.headers"
:response="apiCase.responseData"
:request="apiCase.request"
:case-id="apiCase.apiDefinitionId"
v-if="api.protocol === 'HTTP'" />
<tcp-format-parameters
:showScript="true"
:show-pre-script="true"
:request="apiCase.request"
:response="apiCase.responseData"
v-if="api.method === 'TCP' || api.method === 'ESB'" />
<ms-sql-basis-parameters
:showScript="true"
:request="apiCase.request"
:response="apiCase.responseData"
v-if="api.method === 'SQL'" />
<ms-dubbo-basis-parameters
:showScript="true"
:request="apiCase.request"
:response="apiCase.responseData"
v-if="api.protocol === 'DUBBO'" />
<!-- HTTP 请求返回数据 -->
<p class="tip">{{ $t('api_test.definition.request.res_param') }}</p>
<api-response-component
:currentProtocol="apiCase.request.protocol"
:api-item="apiCase"
:result="apiCase.responseData" />
</div> </div>
</el-col> </el-collapse-transition>
<el-col :span="2"> </el-main>
<el-link style="float: right" type="primary" @click.stop @click="showHistory(apiCase.id)"> </el-container>
{{ $t('commons.execute_history') }}
</el-link>
</el-col>
</el-row>
</div>
<!-- 请求参数-->
<el-collapse-transition>
<div v-if="apiCase.active || type === 'detail'" v-loading="loading">
<el-divider></el-divider>
<p class="tip">{{ $t('api_test.definition.request.req_param') }}</p>
<ms-api-request-form
:isShowEnable="true"
:showScript="true"
:headers="apiCase.request.headers"
:response="apiCase.responseData"
:request="apiCase.request"
:case-id="apiCase.apiDefinitionId"
v-if="api.protocol === 'HTTP'" />
<tcp-format-parameters
:showScript="true"
:show-pre-script="true"
:request="apiCase.request"
:response="apiCase.responseData"
v-if="api.method === 'TCP' || api.method === 'ESB'" />
<ms-sql-basis-parameters
:showScript="true"
:request="apiCase.request"
:response="apiCase.responseData"
v-if="api.method === 'SQL'" />
<ms-dubbo-basis-parameters
:showScript="true"
:request="apiCase.request"
:response="apiCase.responseData"
v-if="api.protocol === 'DUBBO'" />
<!-- HTTP 请求返回数据 -->
<p class="tip">{{ $t('api_test.definition.request.res_param') }}</p>
<api-response-component
:currentProtocol="apiCase.request.protocol"
:api-item="apiCase"
:result="apiCase.responseData" />
</div>
</el-collapse-transition>
<ms-change-history ref="changeHistory" /> <ms-change-history ref="changeHistory" />
<el-dialog <el-dialog
:visible.sync="syncCaseVisible" :visible.sync="syncCaseVisible"
@ -326,6 +333,7 @@ export default {
checkedCases: new Set(), checkedCases: new Set(),
visible: false, visible: false,
condition: {}, condition: {},
componentHeight: document.body.clientHeight - 170,
responseData: { type: 'HTTP', responseResult: {}, subRequestResults: [] }, responseData: { type: 'HTTP', responseResult: {}, subRequestResults: [] },
isShowInput: false, isShowInput: false,
methodColorMap: new Map(API_METHOD_COLOUR), methodColorMap: new Map(API_METHOD_COLOUR),
@ -367,6 +375,7 @@ export default {
return 0; return 0;
}, },
}, },
caseItemHeight: Number,
api: { api: {
type: Object, type: Object,
default() { default() {
@ -388,6 +397,7 @@ export default {
this.$EventBus.$off('showXpackCaseSet'); this.$EventBus.$off('showXpackCaseSet');
}, },
created() { created() {
window.addEventListener('resize', this.resizeTable, false);
store.scenarioEnvMap = undefined; store.scenarioEnvMap = undefined;
if (this.apiCase.request && this.apiCase.request.hashTree && this.apiCase.request.hashTree.length > 0) { if (this.apiCase.request && this.apiCase.request.hashTree && this.apiCase.request.hashTree.length > 0) {
let index = this.apiCase.request.hashTree.findIndex((item) => item.type === 'Assertions'); let index = this.apiCase.request.hashTree.findIndex((item) => item.type === 'Assertions');
@ -421,8 +431,12 @@ export default {
}); });
} }
this.reload(); this.reload();
this.resizeTable();
}, },
watch: { watch: {
caseItemHeight() {
this.changeScreen(this.caseItemHeight);
},
'apiCase.name': { 'apiCase.name': {
handler(v) { handler(v) {
this.saveStatus(); this.saveStatus();
@ -477,6 +491,25 @@ export default {
} }
}, },
methods: { methods: {
changeScreen(height) {
let headerHeight = 100 + this.$refs.elementHeader.clientHeight;
if (height > headerHeight) {
this.componentHeight = height - headerHeight;
} else {
this.componentHeight = headerHeight;
}
},
resizeTable() {
if (this.$refs.elementHeader) {
let headerHeight = 100 + this.$refs.elementHeader.clientHeight;
let documentClientHeight = document.body.clientHeight;
if (documentClientHeight > headerHeight) {
this.componentHeight = documentClientHeight - headerHeight;
} else {
this.componentHeight = headerHeight;
}
}
},
setOriginal(scenarioDefinition) { setOriginal(scenarioDefinition) {
for (let i in scenarioDefinition) { for (let i in scenarioDefinition) {
let typeArray = ['JDBCPostProcessor', 'JDBCSampler', 'JDBCPreProcessor']; let typeArray = ['JDBCPostProcessor', 'JDBCSampler', 'JDBCPreProcessor'];

View File

@ -1,6 +1,12 @@
<template> <template>
<div v-if="visible"> <div v-if="visible">
<ms-drawer :size="60" @close="apiCaseClose" direction="bottom" ref="testCaseDrawer" class="ms-drawer-case-header"> <ms-drawer
:size="60"
@close="apiCaseClose"
@changeScreen="changeScreen"
direction="bottom"
ref="testCaseDrawer"
class="ms-drawer-case-header">
<template v-slot:header> <template v-slot:header>
<api-case-header <api-case-header
:api="api" :api="api"
@ -32,6 +38,7 @@
@showHistory="showHistory" @showHistory="showHistory"
@reLoadCase="reLoadCase" @reLoadCase="reLoadCase"
:environment="environment" :environment="environment"
:case-item-height="caseItemHeight"
@setSelectedCaseId="setSelectedCaseId" @setSelectedCaseId="setSelectedCaseId"
:is-case-edit="isCaseEdit" :is-case-edit="isCaseEdit"
:api="api" :api="api"
@ -60,7 +67,7 @@
</div> </div>
</template> </template>
<script> <script>
import {apiTestCaseList, editApiCaseByParam, getCaseById, getPassRateById} from '@/api/api-test-case'; import { apiTestCaseList, editApiCaseByParam, getCaseById, getPassRateById } from '@/api/api-test-case';
import { getMaintainer } from '@/api/project'; import { getMaintainer } from '@/api/project';
import ApiCaseHeader from './ApiCaseHeader'; import ApiCaseHeader from './ApiCaseHeader';
import { getCurrentProjectID } from 'metersphere-frontend/src/utils/token'; import { getCurrentProjectID } from 'metersphere-frontend/src/utils/token';
@ -105,6 +112,7 @@ export default {
apiCaseList: [], apiCaseList: [],
batchLoadingIds: [], batchLoadingIds: [],
singleLoading: false, singleLoading: false,
caseItemHeight: 100,
singleRunId: '', singleRunId: '',
runData: [], runData: [],
reportId: '', reportId: '',
@ -155,6 +163,9 @@ export default {
}, },
}, },
methods: { methods: {
changeScreen(height) {
this.caseItemHeight = height;
},
getMaintainerOptions() { getMaintainerOptions() {
getMaintainer().then((response) => { getMaintainer().then((response) => {
this.maintainerOptions = response.data; this.maintainerOptions = response.data;
@ -432,8 +443,8 @@ export default {
this.apiCaseList[0].responseData = data; this.apiCaseList[0].responseData = data;
this.apiCaseList[0].passRate = passRate; this.apiCaseList[0].passRate = passRate;
this.$refs.apiCaseItem.runLoading = false; this.$refs.apiCaseItem.runLoading = false;
store.currentApiCase = {refresh: true, id: data.id, status: status, passRate: passRate}; store.currentApiCase = { refresh: true, id: data.id, status: status, passRate: passRate };
}) });
} }
}, },
errorRefresh() { errorRefresh() {
@ -677,6 +688,7 @@ export default {
.ms-drawer-case-header :deep(.ms-drawer-header) { .ms-drawer-case-header :deep(.ms-drawer-header) {
margin-left: 0px; margin-left: 0px;
} }
fieldset { fieldset {
padding: 0px; padding: 0px;
margin: 0px; margin: 0px;

View File

@ -1,23 +1,31 @@
<template> <template>
<div v-if="visible" id="ms-drawer" class="ms-drawer" :class="directionStyle" <div
:style="{width: w + 'px', height: h + 'px'}" ref="msDrawer"> v-if="visible"
id="ms-drawer"
class="ms-drawer"
:class="directionStyle"
:style="{ width: w + 'px', height: h + 'px' }"
ref="msDrawer"
>
<ms-bottom2-top-drag-bar v-if="direction == 'bottom'" />
<ms-bottom2-top-drag-bar v-if="direction == 'bottom'"/> <ms-right2-left-drag-bar v-if="direction == 'right'" />
<ms-right2-left-drag-bar v-if="direction == 'right'"/> <ms-right2-left-drag-bar v-if="direction == 'default'" />
<ms-right2-left-drag-bar v-if="direction == 'default'"/>
<div class="ms-drawer-header"> <div class="ms-drawer-header">
<slot name="header"></slot> <slot name="header"></slot>
<i v-if="isShowClose" class="el-icon-close" @click="close"/> <i v-if="isShowClose" class="el-icon-close" @click="close" />
<ms-full-screen-button v-if="showFullScreen" :is-full-screen.sync="isFullScreen"/> <ms-full-screen-button
v-if="showFullScreen"
:is-full-screen.sync="isFullScreen"
/>
</div> </div>
<div class="ms-drawer-body"> <div class="ms-drawer-body">
<slot></slot> <slot></slot>
</div> </div>
<ms-left2-right-drag-bar v-if="direction == 'left'"/> <ms-left2-right-drag-bar v-if="direction == 'left'" />
</div> </div>
</template> </template>
@ -29,51 +37,56 @@ import MsFullScreenButton from "./MsFullScreenButton";
export default { export default {
name: "MsDrawer", name: "MsDrawer",
components: {MsFullScreenButton, MsBottom2TopDragBar, MsLeft2RightDragBar, MsRight2LeftDragBar}, components: {
MsFullScreenButton,
MsBottom2TopDragBar,
MsLeft2RightDragBar,
MsRight2LeftDragBar,
},
data() { data() {
return { return {
x: 0, x: 0,
y: 0, y: 0,
w: 100, w: 100,
h: 100, h: 100,
directionStyle: 'left-style', directionStyle: "left-style",
dragBarDirection: 'vertical', dragBarDirection: "vertical",
isFullScreen: false, isFullScreen: false,
originalW: 0, originalW: 0,
originalH: 0, originalH: 0,
} };
}, },
props: { props: {
direction: { direction: {
type: String, type: String,
default() { default() {
return "left"; return "left";
} },
}, },
visible: { visible: {
type: Boolean, type: Boolean,
default() { default() {
return true; return true;
} },
}, },
size: { size: {
type: Number, type: Number,
default() { default() {
return 40; return 40;
} },
}, },
showFullScreen: { showFullScreen: {
type: Boolean, type: Boolean,
default() { default() {
return true; return true;
} },
}, },
isShowClose: { isShowClose: {
type: Boolean, type: Boolean,
default() { default() {
return true; return true;
} },
} },
}, },
mounted() { mounted() {
this.init(); this.init();
@ -81,71 +94,71 @@ export default {
watch: { watch: {
isFullScreen() { isFullScreen() {
if (this.isFullScreen) { if (this.isFullScreen) {
this.fullScreen() this.fullScreen();
} else { } else {
this.unFullScreen(); this.unFullScreen();
} }
} },
}, },
methods: { methods: {
setfullScreen() { setfullScreen() {
if (!this.isFullScreen) { if (!this.isFullScreen) {
this.$nextTick(() => { this.$nextTick(() => {
this.isFullScreen = true; this.isFullScreen = true;
}) });
} }
}, },
init() { init() {
window.addEventListener("resize", this.listenScreenChange, false); window.addEventListener("resize", this.listenScreenChange, false);
// todo // todo
switch (this.direction) { switch (this.direction) {
case 'left': case "left":
this.w = this.getWidthPercentage(this.size); this.w = this.getWidthPercentage(this.size);
this.h = this.getHeightPercentage(100); this.h = this.getHeightPercentage(100);
this.x = 0; this.x = 0;
this.y = 0; this.y = 0;
this.directionStyle = 'left-style'; this.directionStyle = "left-style";
this.dragBarDirection = 'horizontal'; this.dragBarDirection = "horizontal";
break; break;
case 'right': case "right":
this.w = this.getWidthPercentage(this.size); this.w = this.getWidthPercentage(this.size);
this.h = this.getHeightPercentage(100); this.h = this.getHeightPercentage(100);
this.x = document.body.clientWidth - this.w; this.x = document.body.clientWidth - this.w;
this.y = 0; this.y = 0;
this.directionStyle = 'right-style'; this.directionStyle = "right-style";
this.dragBarDirection = 'horizontal'; this.dragBarDirection = "horizontal";
break; break;
case 'top': case "top":
this.w = this.getWidthPercentage(100); this.w = this.getWidthPercentage(100);
this.h = this.getHeightPercentage(this.size); this.h = this.getHeightPercentage(this.size);
this.x = 0; this.x = 0;
this.y = 0; this.y = 0;
this.directionStyle = 'top-style'; this.directionStyle = "top-style";
this.dragBarDirection = 'vertical'; this.dragBarDirection = "vertical";
break; break;
case 'bottom': case "bottom":
this.w = this.getWidthPercentage(100); this.w = this.getWidthPercentage(100);
this.h = this.getHeightPercentage(this.size); this.h = this.getHeightPercentage(this.size);
this.x = 0; this.x = 0;
this.y = document.body.clientHeight - this.h; this.y = document.body.clientHeight - this.h;
this.directionStyle = 'bottom-style'; this.directionStyle = "bottom-style";
this.dragBarDirection = 'vertical'; this.dragBarDirection = "vertical";
break; break;
default: default:
this.w = this.getWidthPercentage(this.size); this.w = this.getWidthPercentage(this.size);
this.h = this.getHeightPercentage(100); this.h = this.getHeightPercentage(100);
this.x = document.body.clientWidth - this.w; this.x = document.body.clientWidth - this.w;
this.y = 0; this.y = 0;
this.directionStyle = 'right-style'; this.directionStyle = "right-style";
this.dragBarDirection = 'horizontal'; this.dragBarDirection = "horizontal";
break; break;
} }
}, },
getWidthPercentage(per) { getWidthPercentage(per) {
return document.body.clientWidth * per / 100.0; return (document.body.clientWidth * per) / 100.0;
}, },
getHeightPercentage(per) { getHeightPercentage(per) {
return document.body.clientHeight * per / 100.0; return (document.body.clientHeight * per) / 100.0;
}, },
fullScreen() { fullScreen() {
if (this.originalW === 0) { if (this.originalW === 0) {
@ -156,13 +169,15 @@ export default {
} }
this.w = document.body.clientWidth; this.w = document.body.clientWidth;
this.h = document.body.clientHeight; this.h = document.body.clientHeight;
this.$emit("changeScreen", this.h);
}, },
unFullScreen() { unFullScreen() {
this.w = this.originalW; this.w = this.originalW;
this.h = this.originalH; this.h = this.originalH;
this.$emit("changeScreen", this.h);
}, },
close() { close() {
this.$emit('close'); this.$emit("close");
window.removeEventListener("resize", this.listenScreenChange); window.removeEventListener("resize", this.listenScreenChange);
}, },
listenScreenChange() { listenScreenChange() {
@ -171,16 +186,16 @@ export default {
this.h = document.body.clientHeight; this.h = document.body.clientHeight;
} else { } else {
switch (this.direction) { switch (this.direction) {
case 'left': case "left":
this.h = document.documentElement.clientHeight; this.h = document.documentElement.clientHeight;
break; break;
case 'right': case "right":
this.h = document.documentElement.clientHeight; this.h = document.documentElement.clientHeight;
break; break;
case 'top': case "top":
this.w = document.documentElement.clientWidth; this.w = document.documentElement.clientWidth;
break; break;
case 'bottom': case "bottom":
this.w = document.documentElement.clientWidth; this.w = document.documentElement.clientWidth;
break; break;
default: default:
@ -189,18 +204,19 @@ export default {
break; break;
} }
} }
} },
} },
} };
</script> </script>
<style scoped> <style scoped>
.ms-drawer { .ms-drawer {
background-color: white; background-color: white;
border: 1px #DCDFE6 solid; border: 1px #dcdfe6 solid;
-webkit-box-shadow: 0 8px 10px -5px rgba(0, 0, 0, .2), 0 16px 24px 2px rgba(0, 0, 0, .14), 0 6px 30px 5px rgba(0, 0, 0, .12); -webkit-box-shadow: 0 8px 10px -5px rgba(0, 0, 0, 0.2),
box-shadow: 0 8px 10px -5px rgba(0, 0, 0, .2), 0 16px 24px 2px rgba(0, 0, 0, .14), 0 6px 30px 5px rgba(0, 0, 0, .12); 0 16px 24px 2px rgba(0, 0, 0, 0.14), 0 6px 30px 5px rgba(0, 0, 0, 0.12);
box-shadow: 0 8px 10px -5px rgba(0, 0, 0, 0.2),
0 16px 24px 2px rgba(0, 0, 0, 0.14), 0 6px 30px 5px rgba(0, 0, 0, 0.12);
z-index: 999 !important; z-index: 999 !important;
position: fixed; position: fixed;
overflow: auto; overflow: auto;
@ -269,5 +285,4 @@ export default {
right: 40px; right: 40px;
top: 15px; top: 15px;
} }
</style> </style>