fix(用例管理): 修复用例管理一系列问题

--bug=1037064 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001037064
This commit is contained in:
guoyuqi 2024-03-12 20:11:32 +08:00 committed by Craftsman
parent fdabab9052
commit e4134996c4
10 changed files with 264 additions and 26 deletions

View File

@ -83,6 +83,7 @@
left join test_plan tp on brc.test_plan_id = tp.id
where b.deleted = false
<include refid="queryWhereConditionByProvider"/>
<include refid="filter"/>
order by
<if test="sort != null and sort != ''">
brc.${sort}
@ -108,6 +109,63 @@
</if>
</sql>
<sql id="filter">
<if test="request.filter != null and request.filter.size() > 0">
<foreach collection="request.filter.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">
<choose>
<!-- 处理人 -->
<when test="key == 'handleUser'">
and b.handle_user in
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
</when>
<!-- 删除人 -->
<when test="key == 'deleteUser'">
and b.delete_user in
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
</when>
<!-- 更新人 -->
<when test="key == 'updateUser'">
and b.update_user in
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
</when>
<!-- 创建人 -->
<when test="key == 'createUser'">
and b.create_user in
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
</when>
<!-- 平台 -->
<when test="key == 'platform'">
and b.platform in
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
</when>
<!-- 状态 -->
<when test="key == 'status'">
and b.status in
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
</when>
<!-- 自定义单选字段 -->
<when test="key.startsWith('custom_single')">
and b.id in (
select bug_id from bug_custom_field where concat('custom_single_', field_id) = #{key}
and trim(both '"' from `value`) in
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
)
</when>
<!-- 自定义多选字段 -->
<when test="key.startsWith('custom_multiple')">
and b.id in (
select bug_id from bug_custom_field where concat('custom_multiple_', field_id) = #{key}
and
<include refid="io.metersphere.system.mapper.BaseMapper.filterMultipleWrapper"/>
)
</when>
</choose>
</if>
</foreach>
</if>
</sql>
<sql id="queryModuleWhereCondition">
<!-- 待补充关联Case弹窗中的高级搜索条件 -->
<if test="request.keyword != null and request.keyword != ''">

View File

@ -246,6 +246,11 @@
and functional_case.create_user in
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
</when>
<!-- 创建人 -->
<when test="key=='deleteUserName'">
and functional_case.delete_user in
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
</when>
</choose>
</if>
</foreach>

View File

@ -308,7 +308,7 @@ public class FunctionalCaseCommentService {
List<String> notifiers = Arrays.asList(notifierStr.split(";"));
userIds.addAll(notifiers);
}
userIds = userIds.stream().distinct().toList();
userIds = userIds.stream().filter(StringUtils::isNotBlank).distinct().toList();
return userIds;
}

View File

@ -2,7 +2,10 @@
<div class="flex flex-row gap-[8px]">
<div class="p-1"> <MsAvatar :avatar="creatorInfo.avatar" /></div>
<div class="flex w-full flex-col">
<div class="font-medium text-[var(--color-text-1)]">{{ creatorInfo.name }}</div>
<div class="font-medium text-[var(--color-text-1)]">
{{ creatorInfo.name }}
<span v-if="props.element.replyUser">{{ t('ms.comment.reply') }} {{ replyUserName }}</span>
</div>
<div v-dompurify-html="props.element.content" class="markdown-body mt-[4px]"></div>
<div class="mb-4 mt-[16px] flex flex-row items-center">
@ -112,7 +115,14 @@
};
const creatorInfo = computed(() => {
return props.element.commentUserInfos.filter((item) => item.id === props.element.createUser)[0];
return props.element.commentUserInfos.filter((item) => item != null && item.id === props.element.createUser)[0];
});
const replyUserName = computed(() => {
if (props.element.replyUser) {
return props.element.commentUserInfos.filter((item) => item != null && item.id === props.element.replyUser)[0]
.name;
}
return '';
});
</script>

View File

@ -329,8 +329,12 @@
class: 'mention',
},
// TODO userMap
renderLabel({ options, node }) {
return `${options.suggestion.char}${node.attrs.label ?? node.attrs.id}`;
renderHTML({ options, node }) {
return [
'span',
{ style: 'color: #783887' },
`${options.suggestion.char}${node.attrs.label ?? node.attrs.id}`,
];
// return `${options.suggestion.char}${userMap[node.attrs.id]}`;
},
suggestion,

View File

@ -12,10 +12,12 @@
@refresh="fetchData()"
>
<template #left>
<div class="text-[var(--color-text-1)]"
>{{ moduleNamePath }}
<span class="text-[var(--color-text-4)]"> ({{ props.modulesCount[props.activeFolder] || 0 }})</span></div
>
<a-tooltip :content="moduleNamePath + '('+(props.modulesCount[props.activeFolder] || 0) +')' " position="bottom" background-color="#FFFFFF" :content-style="{color: '#000000'}">
<div class="one-line-text max-h-[32px] max-w-[116px] text-[var(--color-text-1)]"
>{{ moduleNamePath }}
<span class="text-[var(--color-text-4)]"> ({{ props.modulesCount[props.activeFolder] || 0 }})</span></div
>
</a-tooltip>
</template>
<template #right>
<a-radio-group v-model:model-value="showType" type="button" class="file-show-type">

View File

@ -73,10 +73,17 @@
@refresh="fetchData()"
>
<template #left>
<div class="text-[var(--color-text-1)]"
>{{ moduleNamePath }}
<span class="text-[var(--color-text-4)]"> ({{ recycleModulesCount[activeFolder] || 0 }})</span></div
<a-tooltip
:content="moduleNamePath + '(' + (recycleModulesCount[activeFolder] || 0) + ')'"
position="bottom"
background-color="#FFFFFF"
:content-style="{ color: '#000000' }"
>
<div class="one-line-text max-h-[32px] max-w-[116px] text-[var(--color-text-1)]"
>{{ moduleNamePath }}
<span class="text-[var(--color-text-4)]"> ({{ recycleModulesCount[activeFolder] || 0 }})</span></div
>
</a-tooltip>
</template>
</MsAdvanceFilter>
<ms-base-table
@ -605,7 +612,7 @@
const moduleNamePath = computed(() => {
return activeFolder.value === 'all'
? t('caseManagement.featureCase.allCase')
: findNodeByKey<Record<string, any>>(caseTree.value, featureCaseStore.moduleId[0], 'id')?.name;
: findNodeByKey<Record<string, any>>(caseTree.value, activeFolder.value, 'id')?.name;
});
const memberOptions = ref<{ label: string; value: string }[]>([]);

View File

@ -5,17 +5,21 @@
<a-tooltip>
<template #content>
{{ t('caseManagement.featureCase.noAssociatedDefect') }}
<span class="text-[rgb(var(--primary-4))]" @click="createDefect">{{
<span v-permission="['PROJECT_BUG:READ+ADD']" class="text-[rgb(var(--primary-4))]" @click="createDefect">{{
t('caseManagement.featureCase.createDefect')
}}</span>
</template>
<a-button class="mr-3" type="primary" @click="linkDefect">
<a-button v-permission="['FUNCTIONAL_CASE:READ+UPDATE']" class="mr-3" type="primary" @click="linkDefect">
{{ t('caseManagement.featureCase.linkDefect') }}
</a-button>
</a-tooltip>
<a-button type="outline" @click="createDefect">{{ t('caseManagement.featureCase.createDefect') }} </a-button>
<a-button v-permission="['PROJECT_BUG:READ+ADD']" type="outline" @click="createDefect"
>{{ t('caseManagement.featureCase.createDefect') }}
</a-button>
</div>
<div v-else class="font-medium">{{ t('caseManagement.featureCase.testPlanLinkList') }}</div>
<div v-else v-permission="['FUNCTIONAL_CASE:READ+UPDATE']" class="font-medium">{{
t('caseManagement.featureCase.testPlanLinkList')
}}</div>
<div class="mb-4">
<a-radio-group v-model:model-value="showType" type="button" class="file-show-type ml-[4px]">
<a-radio value="link" class="show-type-icon p-[2px]">{{
@ -29,10 +33,10 @@
v-model:model-value="keyword"
:placeholder="t('caseManagement.featureCase.searchByName')"
allow-clear
class="mx-[8px] w-[240px]"
@search="getFetch"
@press-enter="getFetch"
@clear="resetFetch"
class="mx-[8px] w-[240px]"
></a-input-search>
</div>
</div>
@ -48,17 +52,69 @@
</template>
</a-popover>
</template>
<template #handleUserFilter="{ columnConfig }">
<TableFilter
v-model:visible="handleUserFilterVisible"
v-model:status-filters="handleUserFilterValue"
:title="(columnConfig.title as string)"
:list="handleUserFilterOptions"
value-key="value"
@search="searchData()"
>
<template #item="{ item }">
{{ item.text }}
</template>
</TableFilter>
</template>
<template #statusFilter="{ columnConfig }">
<TableFilter
v-model:visible="statusFilterVisible"
v-model:status-filters="statusFilterValue"
:title="(columnConfig.title as string)"
:list="statusFilterOptions"
value-key="value"
@search="searchData()"
>
<template #item="{ item }">
{{ item.text }}
</template>
</TableFilter>
</template>
<template #severityFilter="{ columnConfig }">
<TableFilter
v-model:visible="severityFilterVisible"
v-model:status-filters="severityFilterValue"
:title="(columnConfig.title as string)"
:list="severityFilterOptions"
value-key="value"
@search="searchData()"
>
<template #item="{ item }">
{{ item.text }}
</template>
</TableFilter>
</template>
<template #operation="{ record }">
<MsButton @click="cancelLink(record.id)">{{ t('caseManagement.featureCase.cancelLink') }}</MsButton>
<MsButton v-permission="['FUNCTIONAL_CASE:READ+UPDATE']" @click="cancelLink(record.id)">{{
t('caseManagement.featureCase.cancelLink')
}}</MsButton>
</template>
<template v-if="(keyword || '').trim() === ''" #empty>
<div class="flex w-full items-center justify-center">
{{ t('caseManagement.caseReview.tableNoData') }}
<MsButton class="ml-[8px]" @click="linkDefect">
{{ t('caseManagement.featureCase.tableNoDataWidthComma') }}
<span v-permission="['FUNCTIONAL_CASE:READ+UPDATE', 'PROJECT_BUG:READ+ADD']">{{
t('caseManagement.featureCase.please')
}}</span>
<MsButton v-permission="['FUNCTIONAL_CASE:READ+UPDATE']" class="ml-[8px]" @click="linkDefect">
{{ t('caseManagement.featureCase.linkDefect') }}
</MsButton>
{{ t('caseManagement.featureCase.or') }}
<MsButton class="ml-[8px]" @click="createDefect">
<span v-permission="['FUNCTIONAL_CASE:READ+UPDATE', 'PROJECT_BUG:READ+ADD']">{{
t('caseManagement.featureCase.or')
}}</span>
<MsButton v-permission="['PROJECT_BUG:READ+ADD']" class="ml-[8px]" @click="createDefect">
{{ t('caseManagement.featureCase.createDefect') }}
</MsButton>
</div>
@ -76,6 +132,49 @@
</template>
</a-popover>
</template>
<template #handleUserFilter="{ columnConfig }">
<TableFilter
v-model:visible="handleUserFilterVisible"
v-model:status-filters="handleUserFilterValue"
:title="(columnConfig.title as string)"
:list="handleUserFilterOptions"
value-key="value"
@search="searchData()"
>
<template #item="{ item }">
{{ item.text }}
</template>
</TableFilter>
</template>
<template #statusFilter="{ columnConfig }">
<TableFilter
v-model:visible="statusFilterVisible"
v-model:status-filters="statusFilterValue"
:title="(columnConfig.title as string)"
:list="statusFilterOptions"
value-key="value"
@search="searchData()"
>
<template #item="{ item }">
{{ item.text }}
</template>
</TableFilter>
</template>
<template #severityFilter="{ columnConfig }">
<TableFilter
v-model:visible="severityFilterVisible"
v-model:status-filters="severityFilterValue"
:title="(columnConfig.title as string)"
:list="severityFilterOptions"
value-key="value"
@search="searchData()"
>
<template #item="{ item }">
{{ item.text }}
</template>
</TableFilter>
</template>
<template #operation="{ record }">
<MsButton @click="cancelLink(record.id)">{{ t('caseManagement.featureCase.cancelLink') }}</MsButton>
</template>
@ -111,7 +210,9 @@
import useTable from '@/components/pure/ms-table/useTable';
import AddDefectDrawer from './addDefectDrawer.vue';
import LinkDefectDrawer from './linkDefectDrawer.vue';
import TableFilter from '@/views/case-management/caseManagementFeature/components/tableFilter.vue';
import { getCustomOptionHeader } from '@/api/modules/bug-management';
import {
associatedDrawerDebug,
cancelAssociatedDebug,
@ -120,8 +221,8 @@
import { useI18n } from '@/hooks/useI18n';
import { useAppStore } from '@/store';
import useFeatureCaseStore from '@/store/modules/case/featureCase';
import { characterLimit } from '@/utils';
import { BugOptionItem } from '@/models/bug-management';
import type { TableQueryParams } from '@/models/common';
const featureCaseStore = useFeatureCaseStore();
@ -136,6 +237,16 @@
const showType = ref('link');
const keyword = ref<string>('');
const handleUserFilterVisible = ref(false);
const handleUserFilterValue = ref<string[]>([]);
const handleUserFilterOptions = ref<BugOptionItem[]>([]);
const statusFilterVisible = ref(false);
const statusFilterValue = ref<string[]>([]);
const statusFilterOptions = ref<BugOptionItem[]>([]);
const severityFilterOptions = ref<BugOptionItem[]>([]);
const severityFilterVisible = ref(false);
const severityFilterValue = ref<string[]>([]);
const severityColumnId = ref('');
const columns: MsTableColumn = [
{
@ -160,6 +271,7 @@
title: 'caseManagement.featureCase.defectState',
slotName: 'statusName',
dataIndex: 'statusName',
titleSlotName: 'statusFilter',
showInTable: true,
showTooltip: true,
width: 200,
@ -168,8 +280,9 @@
},
{
title: 'caseManagement.featureCase.updateUser',
slotName: 'name',
dataIndex: 'updateUser',
slotName: 'handleUserName',
dataIndex: 'handleUserName',
titleSlotName: 'handleUserFilter',
showInTable: true,
showTooltip: true,
width: 300,
@ -261,6 +374,40 @@
enableDrag: true,
});
function initTableParams() {
const filterParams = {
status: statusFilterValue.value,
handleUser: handleUserFilterValue.value,
};
filterParams[severityColumnId.value] = severityFilterValue.value;
return {
keyword: keyword.value,
caseId: props.caseId,
projectId: appStore.currentProjectId,
filter: { ...filterParams },
condition: {
keyword: keyword.value,
filter: showType.value === 'link' ? linkPropsRes : 'testPlanPropsRes',
},
};
}
function searchData() {
if (showType.value === 'link') {
setLinkListParams(initTableParams());
loadLinkList();
} else {
setTestPlanListParams(initTableParams());
testPlanLinkList();
}
}
async function initFilterOptions() {
const res = await getCustomOptionHeader(appStore.currentProjectId);
handleUserFilterOptions.value = res.handleUserOption;
statusFilterOptions.value = res.statusOption;
}
async function getFetch() {
if (showType.value === 'link') {
setLinkListParams({ keyword: keyword.value, projectId: appStore.currentProjectId, caseId: props.caseId });
@ -348,6 +495,7 @@
onMounted(() => {
getFetch();
initFilterOptions();
});
</script>

View File

@ -215,6 +215,7 @@ export default {
'caseManagement.featureCase.uiCase': 'UI Case',
'caseManagement.featureCase.propertyCase': 'Property Case',
'caseManagement.featureCase.or': 'Or',
'caseManagement.featureCase.please': 'please',
'caseManagement.featureCase.formExcelExport': 'Import use cases from Excel files',
'caseManagement.featureCase.formXMindExport': 'Import use cases from Xmind files',
'caseManagement.featureCase.dragOrClick': 'Drag or click this area to select a file',
@ -250,6 +251,7 @@ export default {
'caseManagement.featureCase.CheckFailure': 'Check failure',
'caseManagement.featureCase.CheckSuccess': 'Check success',
'caseManagement.featureCase.tableNoData': 'No data available',
'caseManagement.featureCase.tableNoDataWidthComma': 'No data available, ',
'caseManagement.featureCase.noAssociatedDefect': 'No associated defects, please',
'caseManagement.featureCase.fileIsUpdated': 'File is updated',
'caseManagement.featureCase.selectTransferDirectory': 'Please select the transfer directory',

View File

@ -214,6 +214,7 @@ export default {
'caseManagement.featureCase.uiCase': 'UI用例',
'caseManagement.featureCase.propertyCase': '性能用例',
'caseManagement.featureCase.or': '或',
'caseManagement.featureCase.please': '请',
'caseManagement.featureCase.formExcelExport': '从 Excel 文件导入用例',
'caseManagement.featureCase.formXMindExport': '从 Xmind 文件导入用例',
'caseManagement.featureCase.dragOrClick': '拖拽或点击此区域选择文件',
@ -246,6 +247,7 @@ export default {
'caseManagement.featureCase.CheckFailure': '校验失败',
'caseManagement.featureCase.CheckSuccess': '校验成功',
'caseManagement.featureCase.tableNoData': '暂无数据',
'caseManagement.featureCase.tableNoDataWidthComma': '暂无数据,',
'caseManagement.featureCase.noAssociatedDefect': '暂无可关联缺陷,请',
'caseManagement.featureCase.fileIsUpdated': '当前文件已更新',
'caseManagement.featureCase.selectTransferDirectory': '请选择转存目录',