diff --git a/frontend/src/business/components/api/head/ApiHeaderMenus.vue b/frontend/src/business/components/api/head/ApiHeaderMenus.vue index b4dcf3f51b..409e7409d4 100644 --- a/frontend/src/business/components/api/head/ApiHeaderMenus.vue +++ b/frontend/src/business/components/api/head/ApiHeaderMenus.vue @@ -6,8 +6,12 @@ - - + + @@ -108,6 +112,7 @@ export default { isProjectActivation: true, isRouterAlive: true, apiTestProjectPath: '', + currentProject: '' } }, // watch: { diff --git a/frontend/src/business/components/common/head/SearchList.vue b/frontend/src/business/components/common/head/SearchList.vue index b6f3c3ba2c..e4effd6cbe 100644 --- a/frontend/src/business/components/common/head/SearchList.vue +++ b/frontend/src/business/components/common/head/SearchList.vue @@ -2,7 +2,7 @@
@@ -16,8 +16,8 @@
@@ -32,7 +32,8 @@ import {PROJECT_ID, ROLE_TEST_MANAGER, ROLE_TEST_USER, ROLE_TEST_VIEWER} from "@ export default { name: "SearchList", props: { - options: Object + options: Object, + currentProject: String }, mounted() { this.init(); @@ -41,44 +42,68 @@ export default { return { result: {}, items: [], - search_text: '', + searchArray: [], + searchString: '', userId: getCurrentUser().id, currentProjectId: localStorage.getItem(PROJECT_ID) } }, watch: { - search_text(val) { - if (!val) { - this.init(); - } else { - this.search(); - } + searchString(val) { + this.query(val) } }, methods: { init: function () { if (hasRoles(ROLE_TEST_VIEWER, ROLE_TEST_USER, ROLE_TEST_MANAGER)) { - this.result = this.$get(this.options.url, (response) => { + this.result = this.$get("/project/listAll", response => { this.items = response.data; - this.items = this.items.splice(0, 3); + this.searchArray = response.data; if (!getCurrentProjectID() && this.items.length > 0) { this.change(this.items[0].id); } - }); + let projectId = getCurrentProjectID(); + this.changeProjectName(projectId); + }) } }, search() { if (hasRoles(ROLE_TEST_VIEWER, ROLE_TEST_USER, ROLE_TEST_MANAGER)) { - this.result = this.$post("/project/search", {name: this.search_text},response => { + this.result = this.$post("/project/search", {name: this.searchString},response => { this.items = response.data; }) } }, + query(queryString) { + this.items = queryString ? this.searchArray.filter(this.createFilter(queryString)) : this.searchArray; + }, + createFilter(queryString) { + return item => { + return (item.name.toLowerCase().indexOf(queryString.toLowerCase()) !== -1); + }; + }, change(projectId) { this.$post("/user/update/current", {id: this.userId, lastProjectId: projectId}, () => { localStorage.setItem(PROJECT_ID, projectId); - window.location.reload(); + if (this.$route.path.indexOf('/track/review/view/') >= 0) { + this.$router.replace('/track/review/all'); + } else if (this.$route.path.indexOf('/track/plan/view/') >= 0) { + this.$router.replace('/track/plan/all'); + } else { + window.location.reload(); + } + this.changeProjectName(projectId); }); + }, + changeProjectName(projectId) { + if (projectId) { + let project = this.searchArray.filter(p => p.id === projectId); + if (project.length > 0) { + this.$emit("update:currentProject", project[0].name); + } + } else { + this.$emit("update:currentProject", '选择项目'); + } } } } diff --git a/frontend/src/business/components/performance/head/PerformanceHeaderMenus.vue b/frontend/src/business/components/performance/head/PerformanceHeaderMenus.vue index 79324356fb..e63010aaec 100644 --- a/frontend/src/business/components/performance/head/PerformanceHeaderMenus.vue +++ b/frontend/src/business/components/performance/head/PerformanceHeaderMenus.vue @@ -1,13 +1,17 @@ @@ -98,7 +102,7 @@ export default { router(item) { } }, - input2: '' + currentProject: '' } }, methods: { diff --git a/frontend/src/business/components/track/head/TrackHeaderMenus.vue b/frontend/src/business/components/track/head/TrackHeaderMenus.vue index 3ac4dc779d..7f01d57323 100644 --- a/frontend/src/business/components/track/head/TrackHeaderMenus.vue +++ b/frontend/src/business/components/track/head/TrackHeaderMenus.vue @@ -2,13 +2,17 @@ @@ -78,6 +82,7 @@ export default { testCaseReviewEditPath: '', testCaseProjectPath: '', isProjectActivation: true, + currentProject: '', projectRecent: { title: this.$t('project.recent'), url: "/project/recent/5",