fix(测试计划): 更改测试计划执行时环境选择弹窗样式,增加滚动条;关联用例时增加按钮loading防止重复提交

--bug=1024332 --user=宋天阳 【测试跟踪】测试计划执行的弹窗,环境较多时,显示的弹窗没有滚动条
https://www.tapd.cn/55049933/s/1349014
This commit is contained in:
song-tianyang 2023-03-13 19:13:34 +08:00 committed by 建国
parent 497654d673
commit 09ac00a06e
5 changed files with 256 additions and 152 deletions

View File

@ -1,29 +1,45 @@
<template> <template>
<div class="msDialogHeader"> <div class="msDialogHeader">
<span style="float: left;font-size: 18px;color: #303133;">{{ title }}</span> <span style="float: left; font-size: 18px; color: #303133">{{
title
}}</span>
<div style="top: 20px; right: 50px; position: absolute;"> <div style="top: 20px; right: 50px; position: absolute">
<el-tooltip effect="dark" :content="$t('commons.full_screen_editing')" <el-tooltip
placement="top-start"> effect="dark"
<font-awesome-icon class="alt-ico" :icon="['fa', 'expand-alt']" size="lg" @click="fullScreen"/> :content="$t('commons.full_screen_editing')"
placement="top-start"
>
<font-awesome-icon
class="alt-ico"
:icon="['fa', 'expand-alt']"
size="lg"
@click="fullScreen"
/>
</el-tooltip> </el-tooltip>
</div> </div>
<div v-if="!hideButton" style="float: right;width: fit-content;"> <div v-if="!hideButton" style="float: right; width: fit-content">
<div style="float: left; margin-right: 8px;"> <div style="float: left; margin-right: 8px">
<slot name="other"></slot> <slot name="other"></slot>
</div> </div>
<div class="ms_btn"> <div class="ms_btn">
<el-button v-if="enableCancel" @click="cancel" :size="btnSize">{{ $t('commons.cancel') }}</el-button> <el-button v-if="enableCancel" @click="cancel" :size="btnSize">{{
<el-button type="primary" @click="confirm" @keydown.enter.native.prevent v-prevent-re-click :size="btnSize"> $t("commons.cancel")
{{ $t('commons.confirm') }} }}</el-button>
<el-button
type="primary"
:loading="isButtonSaving"
@click="confirm"
@keydown.enter.native.prevent
v-prevent-re-click
:size="btnSize"
>
{{ $t("commons.confirm") }}
</el-button> </el-button>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
@ -34,11 +50,12 @@ export default {
btnSize: { btnSize: {
type: String, type: String,
default() { default() {
return 'small'; return "small";
} },
}, },
hideButton: Boolean, hideButton: Boolean,
enableCancel: Boolean enableCancel: Boolean,
isButtonSaving: Boolean,
}, },
methods: { methods: {
cancel() { cancel() {
@ -49,9 +66,9 @@ export default {
}, },
fullScreen() { fullScreen() {
this.$emit("fullScreen"); this.$emit("fullScreen");
} },
} },
} };
</script> </script>
<style scoped> <style scoped>

View File

@ -7,7 +7,7 @@
@close="close" @close="close"
:visible.sync="runModeVisible" :visible.sync="runModeVisible"
> >
<div class="env-container"> <div class="env-container" style="max-height: 400px; overflow: auto">
<div> <div>
<div>{{ $t("commons.environment") }}</div> <div>{{ $t("commons.environment") }}</div>
<env-select-popover <env-select-popover

View File

@ -1,11 +1,11 @@
<template> <template>
<test-case-relevance-base <test-case-relevance-base
@setProject="setProject" @setProject="setProject"
@save="saveCaseRelevance" @save="saveCaseRelevance"
:plan-id="planId" :plan-id="planId"
ref="baseRelevance"> :is-saving="isSaving"
ref="baseRelevance"
>
<template v-slot:aside> <template v-slot:aside>
<ms-api-module <ms-api-module
:relevance-project-id="projectId" :relevance-project-id="projectId"
@ -16,7 +16,8 @@
:show-case-num="false" :show-case-num="false"
:is-read-only="true" :is-read-only="true"
:is-relevance="true" :is-relevance="true"
ref="nodeTree"/> ref="nodeTree"
/>
</template> </template>
<relevance-api-list <relevance-api-list
@ -31,10 +32,15 @@
:version-enable="versionEnable" :version-enable="versionEnable"
@isApiListEnableChange="isApiListEnableChange" @isApiListEnableChange="isApiListEnableChange"
@selectCountChange="setSelectCounts" @selectCountChange="setSelectCounts"
ref="apiList"> ref="apiList"
>
<template v-slot:version> <template v-slot:version>
<mx-version-select v-xpack :project-id="projectId" @changeVersion="changeVersion($event,'api')" <mx-version-select
margin-left="10"/> v-xpack
:project-id="projectId"
@changeVersion="changeVersion($event, 'api')"
margin-left="10"
/>
</template> </template>
</relevance-api-list> </relevance-api-list>
@ -50,27 +56,35 @@
:plan-id="planId" :plan-id="planId"
@isApiListEnableChange="isApiListEnableChange" @isApiListEnableChange="isApiListEnableChange"
@selectCountChange="setSelectCounts" @selectCountChange="setSelectCounts"
ref="apiCaseList"> ref="apiCaseList"
>
<template v-slot:version> <template v-slot:version>
<mx-version-select v-xpack :project-id="projectId" @changeVersion="changeVersion($event, 'case')" <mx-version-select
margin-left="10"/> v-xpack
:project-id="projectId"
@changeVersion="changeVersion($event, 'case')"
margin-left="10"
/>
</template> </template>
</relevance-case-list> </relevance-case-list>
</test-case-relevance-base> </test-case-relevance-base>
</template> </template>
<script> <script>
import TestCaseRelevanceBase from "../base/TestCaseRelevanceBase"; import TestCaseRelevanceBase from "../base/TestCaseRelevanceBase";
import MxVersionSelect from "metersphere-frontend/src/components/version/MxVersionSelect"; import MxVersionSelect from "metersphere-frontend/src/components/version/MxVersionSelect";
import {apiDefinitionListBatch, apiDefinitionRelevance} from "@/api/remote/api/api-definition"; import {
import {apiTestCaseListBlobs, apiTestCaseRelevance} from "@/api/remote/api/api-case"; apiDefinitionListBatch,
apiDefinitionRelevance,
} from "@/api/remote/api/api-definition";
import {
apiTestCaseListBlobs,
apiTestCaseRelevance,
} from "@/api/remote/api/api-case";
import RelevanceApiList from "@/business/plan/view/comonents/api/RelevanceApiList"; import RelevanceApiList from "@/business/plan/view/comonents/api/RelevanceApiList";
import RelevanceCaseList from "@/business/plan/view/comonents/api/RelevanceCaseList"; import RelevanceCaseList from "@/business/plan/view/comonents/api/RelevanceCaseList";
import MsApiModule from "@/business/plan/view/comonents/api/module/ApiModule"; import MsApiModule from "@/business/plan/view/comonents/api/module/ApiModule";
import {getVersionFilters} from "@/business/utils/sdk-utils"; import { getVersionFilters } from "@/business/utils/sdk-utils";
export default { export default {
name: "TestCaseApiRelevance", name: "TestCaseApiRelevance",
@ -79,7 +93,7 @@ export default {
RelevanceCaseList, RelevanceCaseList,
RelevanceApiList, RelevanceApiList,
TestCaseRelevanceBase, TestCaseRelevanceBase,
MxVersionSelect MxVersionSelect,
}, },
data() { data() {
return { return {
@ -94,16 +108,17 @@ export default {
currentRow: {}, currentRow: {},
projectId: "", projectId: "",
versionFilters: [], versionFilters: [],
isSaving: false,
}; };
}, },
props: { props: {
planId: { planId: {
type: String type: String,
}, },
versionEnable: { versionEnable: {
type: Boolean, type: Boolean,
default: false default: false,
} },
}, },
watch: { watch: {
planId() { planId() {
@ -111,7 +126,7 @@ export default {
}, },
projectId() { projectId() {
this.getVersionOptions(); this.getVersionOptions();
} },
}, },
mounted() { mounted() {
this.getVersionOptions(); this.getVersionOptions();
@ -178,9 +193,10 @@ export default {
}, },
saveCaseRelevance() { saveCaseRelevance() {
let url = ''; let url = "";
let environmentId = undefined; let environmentId = undefined;
let selectIds = []; let selectIds = [];
this.isSaving = true;
if (this.isApiListEnable) { if (this.isApiListEnable) {
// //
let params = this.$refs.apiList.getConditions(); let params = this.$refs.apiList.getConditions();
@ -188,53 +204,75 @@ export default {
.then((response) => { .then((response) => {
let apis = response.data; let apis = response.data;
environmentId = this.$refs.apiList.environmentId; environmentId = this.$refs.apiList.environmentId;
selectIds = Array.from(apis).map(row => row.id); selectIds = Array.from(apis).map((row) => row.id);
let protocol = this.$refs.apiList.currentProtocol; let protocol = this.$refs.apiList.currentProtocol;
this.postRelevance(apiDefinitionRelevance, environmentId, selectIds, protocol); this.postRelevance(
apiDefinitionRelevance,
environmentId,
selectIds,
protocol
);
})
.catch(() => {
this.isSaving = false;
}); });
} else { } else {
let params = this.$refs.apiCaseList.getConditions(); let params = this.$refs.apiCaseList.getConditions();
apiTestCaseListBlobs(params) apiTestCaseListBlobs(params)
.then((response) => { .then((response) => {
let apiCases = response.data; let apiCases = response.data;
environmentId = this.$refs.apiCaseList.environmentId; environmentId = this.$refs.apiCaseList.environmentId;
selectIds = Array.from(apiCases).map(row => row.id); selectIds = Array.from(apiCases).map((row) => row.id);
let protocol = this.$refs.apiCaseList.currentProtocol; let protocol = this.$refs.apiCaseList.currentProtocol;
this.postRelevance(apiTestCaseRelevance, environmentId, selectIds, protocol); this.postRelevance(
}); apiTestCaseRelevance,
environmentId,
selectIds,
protocol
);
})
.catch(() => {
this.isSaving = false;
});
} }
}, },
postRelevance(relevanceList, environmentId, selectIds, protocol) { postRelevance(relevanceList, environmentId, selectIds, protocol) {
let param = {}; let param = {};
if (protocol !== 'DUBBO') { if (protocol !== "DUBBO") {
if (!environmentId) { if (!environmentId) {
this.$warning(this.$t('api_test.environment.select_environment')); this.isSaving = false;
this.$warning(this.$t("api_test.environment.select_environment"));
return; return;
} }
} }
if (selectIds.length < 1) { if (selectIds.length < 1) {
this.$warning(this.$t('test_track.plan_view.please_choose_test_case')); this.isSaving = false;
this.$warning(this.$t("test_track.plan_view.please_choose_test_case"));
return; return;
} }
param.planId = this.planId; param.planId = this.planId;
param.selectIds = selectIds; param.selectIds = selectIds;
param.environmentId = environmentId; param.environmentId = environmentId;
relevanceList(param) relevanceList(param)
.then(() => { .then(() => {
this.$success(this.$t('commons.save_success')); this.$success(this.$t("commons.save_success"));
this.$emit('refresh'); this.$emit("refresh");
this.refresh(); this.refresh();
this.$refs.baseRelevance.close(); this.$refs.baseRelevance.close();
}); this.isSaving = false;
})
.catch(() => {
this.isSaving = false;
});
}, },
getVersionOptions() { getVersionOptions() {
getVersionFilters(this.projectId) getVersionFilters(this.projectId).then(
.then(r => this.versionFilters = r.data); (r) => (this.versionFilters = r.data)
);
}, },
changeVersion(currentVersion, type) { changeVersion(currentVersion, type) {
if (type == 'api') { if (type == "api") {
this.$refs.apiList.condition.versionId = currentVersion || null; this.$refs.apiList.condition.versionId = currentVersion || null;
this.$refs.apiList.initTable(); this.$refs.apiList.initTable();
} else { } else {
@ -245,12 +283,11 @@ export default {
setSelectCounts(data) { setSelectCounts(data) {
this.$refs.baseRelevance.selectCounts = data; this.$refs.baseRelevance.selectCounts = data;
}, },
} },
} };
</script> </script>
<style scoped> <style scoped>
:deep(.select-menu) { :deep(.select-menu) {
margin-bottom: 15px; margin-bottom: 15px;
} }
@ -259,5 +296,4 @@ export default {
float: right; float: right;
margin-right: 10px; margin-right: 10px;
} }
</style> </style>

View File

@ -1,11 +1,11 @@
<template> <template>
<test-case-relevance-base <test-case-relevance-base
@setProject="setProject" @setProject="setProject"
@save="saveCaseRelevance" @save="saveCaseRelevance"
:plan-id="planId" :plan-id="planId"
ref="baseRelevance"> ref="baseRelevance"
:is-saving="isSaving"
>
<template v-slot:aside> <template v-slot:aside>
<ms-api-scenario-module <ms-api-scenario-module
@nodeSelectEvent="nodeChange" @nodeSelectEvent="nodeChange"
@ -14,7 +14,8 @@
:show-case-num="false" :show-case-num="false"
:relevance-project-id="projectId" :relevance-project-id="projectId"
:is-read-only="true" :is-read-only="true"
ref="nodeTree"/> ref="nodeTree"
/>
</template> </template>
<relevance-scenario-list <relevance-scenario-list
@ -24,21 +25,23 @@
:plan-id="planId" :plan-id="planId"
:project-id="projectId" :project-id="projectId"
@selectCountChange="setSelectCounts" @selectCountChange="setSelectCounts"
ref="apiScenarioList"/> ref="apiScenarioList"
/>
</test-case-relevance-base> </test-case-relevance-base>
</template> </template>
<script> <script>
import TestCaseRelevanceBase from "../base/TestCaseRelevanceBase"; import TestCaseRelevanceBase from "../base/TestCaseRelevanceBase";
import RelevanceScenarioList from "./RelevanceScenarioList"; import RelevanceScenarioList from "./RelevanceScenarioList";
import {ENV_TYPE} from "metersphere-frontend/src/utils/constants"; import { ENV_TYPE } from "metersphere-frontend/src/utils/constants";
import {getCurrentProjectID, hasLicense, strMapToObj} from "@/business/utils/sdk-utils"; import {
import {getVersionFilters} from "@/business/utils/sdk-utils"; getCurrentProjectID,
import {testPlanAutoCheck} from "@/api/remote/plan/test-plan"; hasLicense,
import {scenarioRelevance} from "@/api/remote/plan/test-plan-scenario"; strMapToObj,
} from "@/business/utils/sdk-utils";
import { getVersionFilters } from "@/business/utils/sdk-utils";
import { testPlanAutoCheck } from "@/api/remote/plan/test-plan";
import { scenarioRelevance } from "@/api/remote/plan/test-plan-scenario";
import MsApiScenarioModule from "@/business/plan/view/comonents/api/module/ApiScenarioModule"; import MsApiScenarioModule from "@/business/plan/view/comonents/api/module/ApiScenarioModule";
export default { export default {
@ -59,16 +62,17 @@ export default {
currentRow: {}, currentRow: {},
projectId: "", projectId: "",
versionFilters: [], versionFilters: [],
isSaving: false,
}; };
}, },
props: { props: {
planId: { planId: {
type: String type: String,
}, },
versionEnable: { versionEnable: {
type: Boolean, type: Boolean,
default: false default: false,
} },
}, },
methods: { methods: {
open() { open() {
@ -116,18 +120,19 @@ export default {
param.environmentType = envType; param.environmentType = envType;
param.envGroupId = envGroupId; param.envGroupId = envGroupId;
scenarioRelevance(param) scenarioRelevance(param).then(() => {
.then(() => { this.$success(this.$t("commons.save_success"));
this.$success(this.$t('commons.save_success')); this.$emit("refresh");
this.$emit('refresh'); this.refresh();
this.refresh(); this.autoCheckStatus();
this.autoCheckStatus(); this.$refs.baseRelevance.close();
this.$refs.baseRelevance.close(); });
});
}, },
async saveCaseRelevance() { async saveCaseRelevance() {
this.isSaving = true;
const sign = await this.$refs.apiScenarioList.checkEnv(); const sign = await this.$refs.apiScenarioList.checkEnv();
if (!sign) { if (!sign) {
this.isSaving = false;
return false; return false;
} }
let selectIds = []; let selectIds = [];
@ -138,16 +143,19 @@ export default {
let envGroupId = this.$refs.apiScenarioList.envGroupId; let envGroupId = this.$refs.apiScenarioList.envGroupId;
if (selectRows.size < 1) { if (selectRows.size < 1) {
this.$warning(this.$t('test_track.plan_view.please_choose_test_case')); this.isSaving = false;
this.$warning(this.$t("test_track.plan_view.please_choose_test_case"));
return; return;
} }
selectRows.forEach(row => { selectRows.forEach((row) => {
selectIds.push(row.id); selectIds.push(row.id);
}) });
if (envType === ENV_TYPE.JSON && (!envMap || envMap.size < 1)) { if (envType === ENV_TYPE.JSON && (!envMap || envMap.size < 1)) {
this.isSaving = false;
this.$warning(this.$t("api_test.environment.select_environment")); this.$warning(this.$t("api_test.environment.select_environment"));
return false; return false;
} else if (envType === ENV_TYPE.GROUP && !envGroupId) { } else if (envType === ENV_TYPE.GROUP && !envGroupId) {
this.isSaving = false;
this.$warning(this.$t("api_test.environment.select_environment")); this.$warning(this.$t("api_test.environment.select_environment"));
return false; return false;
} }
@ -161,14 +169,19 @@ export default {
param.condition = this.$refs.apiScenarioList.condition; param.condition = this.$refs.apiScenarioList.condition;
scenarioRelevance(param) scenarioRelevance(param)
.then(() => { .then(() => {
this.$success(this.$t('commons.save_success')); this.isSaving = false;
this.$emit('refresh'); this.$success(this.$t("commons.save_success"));
this.$emit("refresh");
this.refresh(); this.refresh();
this.autoCheckStatus(); this.autoCheckStatus();
this.$refs.baseRelevance.close(); this.$refs.baseRelevance.close();
})
.catch(() => {
this.isSaving = false;
}); });
}, },
autoCheckStatus() { // autoCheckStatus() {
//
if (!this.planId) { if (!this.planId) {
return; return;
} }
@ -179,16 +192,16 @@ export default {
}, },
getVersionOptions() { getVersionOptions() {
if (hasLicense()) { if (hasLicense()) {
getVersionFilters(getCurrentProjectID()) getVersionFilters(getCurrentProjectID()).then(
.then(r => this.versionFilters = r.data); (r) => (this.versionFilters = r.data)
);
} }
}, },
} },
}; };
</script> </script>
<style scoped> <style scoped>
:deep(.select-menu) { :deep(.select-menu) {
margin-bottom: 15px; margin-bottom: 15px;
} }
@ -201,5 +214,4 @@ export default {
:deep(.module-input) { :deep(.module-input) {
width: 243px; width: 243px;
} }
</style> </style>

View File

@ -1,29 +1,59 @@
<template> <template>
<relevance-dialog :width="width" :title="dialogTitle" ref="relevanceDialog" :full-screen="isFullScreen"> <relevance-dialog
:width="width"
:title="dialogTitle"
ref="relevanceDialog"
:full-screen="isFullScreen"
>
<!-- todo --> <!-- todo -->
<template slot="headerBtn" v-if="$slots.headerBtn"> <template slot="headerBtn" v-if="$slots.headerBtn">
<div> <div>
<slot name="headerBtn"></slot> <slot name="headerBtn"></slot>
</div> </div>
</template> </template>
<template slot="title" slot-scope="{title}" v-if="!$slots.headerBtn"> <template slot="title" slot-scope="{ title }" v-if="!$slots.headerBtn">
<ms-dialog-header :title="title" :enable-cancel="false" @confirm="save" btn-size="mini" @fullScreen="isFullScreen=!isFullScreen"> <ms-dialog-header
:is-button-saving="isSaving"
:title="title"
:enable-cancel="false"
@confirm="save"
btn-size="mini"
@fullScreen="isFullScreen = !isFullScreen"
>
<template #other> <template #other>
<table-select-count-bar :count="selectCounts" style="float: left; margin: 5px;"/> <table-select-count-bar
:count="selectCounts"
style="float: left; margin: 5px"
/>
<div v-if="flag" style="margin: 5px; float: left;"> <div v-if="flag" style="margin: 5px; float: left">
<el-checkbox v-model="checked" class="el-checkbox__label">{{ $t('test_track.sync_add_api_load') }}</el-checkbox> <el-checkbox v-model="checked" class="el-checkbox__label">{{
$t("test_track.sync_add_api_load")
}}</el-checkbox>
</div> </div>
</template> </template>
</ms-dialog-header> </ms-dialog-header>
</template> </template>
<template v-slot:aside> <template v-slot:aside>
<span v-if="isAcrossSpace" class="menu-title">{{ '[' + $t('project.version.checkout') + $t('commons.space') + ']' }}</span> <span v-if="isAcrossSpace" class="menu-title">{{
<el-select v-if="isAcrossSpace" filterable slot="prepend" v-model="workspaceId" @change="changeWorkspace" "[" + $t("project.version.checkout") + $t("commons.space") + "]"
class="ms-header-workspace" }}</span>
size="small"> <el-select
<el-option v-for="(item,index) in workspaceList" :key="index" :label="item.name" :value="item.id"/> v-if="isAcrossSpace"
filterable
slot="prepend"
v-model="workspaceId"
@change="changeWorkspace"
class="ms-header-workspace"
size="small"
>
<el-option
v-for="(item, index) in workspaceList"
:key="index"
:label="item.name"
:value="item.id"
/>
</el-select> </el-select>
<select-menu <select-menu
:data="projects" :data="projects"
@ -31,22 +61,25 @@
width="155px" width="155px"
:current-data="currentProject" :current-data="currentProject"
:title="$t('test_track.switch_project')" :title="$t('test_track.switch_project')"
@dataChange="changeProject"/> @dataChange="changeProject"
/>
<slot name="aside"></slot> <slot name="aside"></slot>
</template> </template>
<slot></slot> <slot></slot>
</relevance-dialog> </relevance-dialog>
</template> </template>
<script> <script>
import MsDialogHeader from "metersphere-frontend/src/components/MsDialogHeader";
import MsDialogHeader from 'metersphere-frontend/src/components/MsDialogHeader'
import SelectMenu from "@/business/common/SelectMenu"; import SelectMenu from "@/business/common/SelectMenu";
import RelevanceDialog from "./RelevanceDialog"; import RelevanceDialog from "./RelevanceDialog";
import {getCurrentProjectID, getCurrentUserId, getCurrentWorkspaceId} from "metersphere-frontend/src/utils/token"; import {
import {getUserWorkspaceList} from "metersphere-frontend/src/api/workspace"; getCurrentProjectID,
import {getUserProjectList} from "metersphere-frontend/src/api/project"; getCurrentUserId,
getCurrentWorkspaceId,
} from "metersphere-frontend/src/utils/token";
import { getUserWorkspaceList } from "metersphere-frontend/src/api/workspace";
import { getUserProjectList } from "metersphere-frontend/src/api/project";
import TableSelectCountBar from "metersphere-frontend/src/components/table/MsTableSelectCountBar"; import TableSelectCountBar from "metersphere-frontend/src/components/table/MsTableSelectCountBar";
export default { export default {
@ -55,31 +88,31 @@ export default {
RelevanceDialog, RelevanceDialog,
SelectMenu, SelectMenu,
MsDialogHeader, MsDialogHeader,
TableSelectCountBar TableSelectCountBar,
}, },
data() { data() {
return { return {
checked: true, checked: true,
currentProject: {}, currentProject: {},
projectId: '', projectId: "",
projectName: '', projectName: "",
projects: [], projects: [],
workspaceId: '', workspaceId: "",
workspaceList: [], workspaceList: [],
currentWorkSpaceId: '', currentWorkSpaceId: "",
selectCounts: null, selectCounts: null,
isFullScreen: false isFullScreen: false,
}; };
}, },
props: { props: {
planId: { planId: {
type: String type: String,
}, },
dialogTitle: { dialogTitle: {
type: String, type: String,
default() { default() {
return this.$t('test_track.plan_view.relevance_test_case'); return this.$t("test_track.plan_view.relevance_test_case");
} },
}, },
flag: { flag: {
type: Boolean, type: Boolean,
@ -89,26 +122,26 @@ export default {
type: Boolean, type: Boolean,
default() { default() {
return false; return false;
} },
}, },
isAcrossSpace: { isAcrossSpace: {
type: Boolean, type: Boolean,
default() { default() {
return false; return false;
} },
}, },
multipleProject: { multipleProject: {
type: Boolean, type: Boolean,
default: true default: true,
} },
}, },
methods: { methods: {
refreshNode() { refreshNode() {
this.$emit('refresh'); this.$emit("refresh");
}, },
save() { save() {
this.$emit('save', this.checked); this.$emit("save", this.checked);
}, },
close() { close() {
@ -123,14 +156,16 @@ export default {
}, },
getProject() { getProject() {
let realWorkSpaceId = this.isAcrossSpace ? this.workspaceId : this.currentWorkSpaceId; let realWorkSpaceId = this.isAcrossSpace
getUserProjectList( { ? this.workspaceId
: this.currentWorkSpaceId;
getUserProjectList({
userId: getCurrentUserId(), userId: getCurrentUserId(),
workspaceId: realWorkSpaceId workspaceId: realWorkSpaceId,
}).then( res => { }).then((res) => {
let data = res.data; let data = res.data;
if (data && data.length > 0) { if (data && data.length > 0) {
const index = data.findIndex(d => d.id === getCurrentProjectID()); const index = data.findIndex((d) => d.id === getCurrentProjectID());
this.projects = data; this.projects = data;
if (index !== -1) { if (index !== -1) {
this.projectId = data[index].id; this.projectId = data[index].id;
@ -142,27 +177,31 @@ export default {
this.changeProject(data[0]); this.changeProject(data[0]);
} }
} else { } else {
this.$message.warning(this.$t('commons.current_workspace') + this.$t('commons.not_exist') + this.$t('commons.project') + "!"); this.$message.warning(
this.$t("commons.current_workspace") +
this.$t("commons.not_exist") +
this.$t("commons.project") +
"!"
);
} }
}) });
}, },
changeProject(project) { changeProject(project) {
if (project) { if (project) {
this.currentProject = project; this.currentProject = project;
this.$emit('setProject', project.id); this.$emit("setProject", project.id);
// //
this.$emit('refreshNode'); this.$emit("refreshNode");
} }
}, },
getWorkSpaceList() { getWorkSpaceList() {
getUserWorkspaceList() getUserWorkspaceList().then((r) => {
.then((r) => { this.workspaceList = r.data;
this.workspaceList = r.data; });
});
}, },
changeWorkspace() { changeWorkspace() {
this.getProject(); this.getProject();
} },
}, },
created() { created() {
this.currentWorkSpaceId = getCurrentWorkspaceId(); this.currentWorkSpaceId = getCurrentWorkspaceId();
@ -170,8 +209,8 @@ export default {
if (this.isAcrossSpace) { if (this.isAcrossSpace) {
this.getWorkSpaceList(); this.getWorkSpaceList();
} }
} },
} };
</script> </script>
<style scoped> <style scoped>