fix(测试跟踪): 用例库列表标签显示优化

--bug=1023677 --user=陈建星 【测试跟踪】功能测试-公共用例库列表-标签为空显示为[] https://www.tapd.cn/55049933/s/1340774
This commit is contained in:
chenjianxing 2023-02-22 16:01:22 +08:00 committed by 刘瑞斌
parent 8a83008b82
commit 60351d2119
3 changed files with 48 additions and 22 deletions

View File

@ -312,7 +312,7 @@ import {
getCustomFieldValueForTrack, getCustomFieldValueForTrack,
getProjectMemberOption getProjectMemberOption
} from "@/business/utils/sdk-utils"; } from "@/business/utils/sdk-utils";
import {initTestCaseConditionComponents, openCaseEdit} from "@/business/case/test-case"; import {getTagToolTips, initTestCaseConditionComponents, openCaseEdit, parseColumnTag} from "@/business/case/test-case";
export default { export default {
@ -628,25 +628,10 @@ export default {
}); });
}, },
getTagToolTips(tags) { getTagToolTips(tags) {
try { return getTagToolTips(tags);
let showTips = '';
tags.forEach((item) => {
showTips += item + ',';
});
return showTips.substr(0, showTips.length - 1);
} catch (e) {
return '';
}
}, },
parseColumnTag(tags) { parseColumnTag(tags) {
if (tags.length > 1) { return parseColumnTag(tags);
let parseTags = [];
parseTags.push(tags[0]);
parseTags.push("+" + (tags.length - 1));
return parseTags;
} else {
return tags;
}
}, },
initConditionComponents() { initConditionComponents() {
this.condition.components = initTestCaseConditionComponents(this.condition, this.testCaseTemplate.customFields, this.trashEnable); this.condition.components = initTestCaseConditionComponents(this.condition, this.testCaseTemplate.customFields, this.trashEnable);

View File

@ -143,9 +143,20 @@
:label="$t('commons.tag')" :label="$t('commons.tag')"
min-width="80"> min-width="80">
<template v-slot:default="scope"> <template v-slot:default="scope">
<ms-single-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain" <el-tooltip class="item" effect="dark" placement="top">
:show-tooltip="scope.row.tags.length === 1 && itemName.length * 12 <= 80" <div v-html="getTagToolTips(scope.row.tags)" slot="content"></div>
:content="itemName" style="margin-left: 0px; margin-right: 2px"/> <div class="oneLine">
<ms-single-tag
v-for="(itemName, index) in parseColumnTag(scope.row.tags)"
:key="index"
type="success"
effect="plain"
:show-tooltip="scope.row.tags.length === 1 && itemName.length * 12 <= 100"
:content="itemName"
style="margin-left: 0px; margin-right: 2px"/>
</div>
</el-tooltip>
<span/>
</template> </template>
</ms-table-column> </ms-table-column>
@ -240,7 +251,7 @@ import {useStore} from "@/store";
import {getProjectMemberUserFilter} from "@/api/user"; import {getProjectMemberUserFilter} from "@/api/user";
import TypeTableItem from "@/business/common/tableItems/planview/TypeTableItem"; import TypeTableItem from "@/business/common/tableItems/planview/TypeTableItem";
import {getVersionFilters} from "@/business/utils/sdk-utils"; import {getVersionFilters} from "@/business/utils/sdk-utils";
import {openCaseEdit} from "@/business/case/test-case"; import {getTagToolTips, openCaseEdit, parseColumnTag} from "@/business/case/test-case";
import PublicTestCaseShow from "@/business/case/components/public/PublicTestCaseShow" import PublicTestCaseShow from "@/business/case/components/public/PublicTestCaseShow"
@ -503,6 +514,12 @@ export default {
}) })
} }
}, },
getTagToolTips(tags) {
return getTagToolTips(tags);
},
parseColumnTag(tags) {
return parseColumnTag(tags);
},
isOwner(testCase) { isOwner(testCase) {
return testCase.maintainer === this.currentUser || testCase.createUser === this.currentUser; return testCase.maintainer === this.currentUser || testCase.createUser === this.currentUser;
}, },

View File

@ -96,3 +96,27 @@ export function openCaseCreate(query, v) {
}); });
window.open(TestCaseData.href, '_blank'); window.open(TestCaseData.href, '_blank');
} }
export function getTagToolTips(tags) {
try {
let showTips = '';
tags.forEach((item) => {
showTips += item + ',';
});
return showTips.substr(0, showTips.length - 1);
} catch (e) {
return '';
}
}
export function parseColumnTag(tags) {
if (tags.length > 1) {
let parseTags = [];
parseTags.push(tags[0]);
parseTags.push("+" + (tags.length - 1));
return parseTags;
} else {
return tags;
}
}