diff --git a/frontend/src/business/components/track/case/components/TestCaseList.vue b/frontend/src/business/components/track/case/components/TestCaseList.vue index 828899a26c..dd07bc61f8 100644 --- a/frontend/src/business/components/track/case/components/TestCaseList.vue +++ b/frontend/src/business/components/track/case/components/TestCaseList.vue @@ -264,7 +264,14 @@ import { } from "@/common/js/tableUtils"; import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOperate"; import PlanStatusTableItem from "@/business/components/track/common/tableItems/plan/PlanStatusTableItem"; -import {getCurrentProjectID, getCurrentUserId, getCurrentWorkspaceId, getUUID, hasLicense} from "@/common/js/utils"; +import { + getCurrentProjectID, + getCurrentUserId, + getCurrentWorkspaceId, + getUUID, + hasLicense, + parseTag +} from "@/common/js/utils"; import {getTestTemplate} from "@/network/custom-field-template"; import {getProjectMember} from "@/network/user"; import MsTable from "@/business/components/common/components/table/MsTable"; @@ -758,46 +765,23 @@ export default { if (this.projectId) { this.condition.projectId = this.projectId; this.$emit('setCondition', this.condition); + let url = '/test/case/list'; if (this.publicEnable) { + url = '/test/case/publicList'; this.condition.casePublic = true; this.condition.workspaceId = getCurrentWorkspaceId(); - this.page.result = this.$post(this.buildPagePath('/test/case/publicList'), this.condition, response => { - let data = response.data; - this.page.total = data.itemCount; - this.page.data = data.listObject; - this.page.data.forEach(item => { - if (item.customFields) { - item.customFields = JSON.parse(item.customFields); - } - }); - this.page.data.forEach((item) => { - try { - item.tags = JSON.parse(item.tags); - } catch (e) { - item.tags = []; - } - }); - }) - } else { - this.page.result = this.$post(this.buildPagePath('/test/case/list'), this.condition, response => { - let data = response.data; - this.page.total = data.itemCount; - this.page.data = data.listObject; - this.page.data.forEach(item => { - if (item.customFields) { - item.customFields = JSON.parse(item.customFields); - } - }); - this.page.data.forEach((item) => { - try { - item.tags = JSON.parse(item.tags); - } catch (e) { - item.tags = []; - } - - }); - }); } + this.page.result = this.$post(this.buildPagePath(url), this.condition, response => { + let data = response.data; + this.page.total = data.itemCount; + this.page.data = data.listObject; + this.page.data.forEach(item => { + if (item.customFields) { + item.customFields = JSON.parse(item.customFields); + } + }); + parseTag(this.page.data); + }); this.$emit("getTrashList"); this.$emit("getPublicList") } diff --git a/frontend/src/common/js/utils.js b/frontend/src/common/js/utils.js index 2831af873d..a73145c9f4 100644 --- a/frontend/src/common/js/utils.js +++ b/frontend/src/common/js/utils.js @@ -9,10 +9,8 @@ import { TokenKey, WORKSPACE_ID } from "./constants"; -import axios from "axios"; import {jsPDF} from "jspdf"; import JSEncrypt from 'jsencrypt'; -import {CUSTOM_FIELD_TYPE_OPTION} from "@/common/js/table-constants"; import i18n from "@/i18n/i18n"; export function hasRole(role) { @@ -510,3 +508,18 @@ export function getTranslateOptions(data) { }); return options; } + +export function parseTag(data) { + data.forEach(item => { + try { + let tags = JSON.parse(item.tags); + if (tags instanceof Array) { + item.tags = tags ? tags : []; + } else { + item.tags = tags ? [tags + ''] : []; + } + } catch (e) { + item.tags = []; + } + }); +}