refactor(测试计划): 报告状态筛选优化

This commit is contained in:
fit2-zhao 2024-05-14 18:19:32 +08:00 committed by Craftsman
parent 58140fb2b7
commit 318b7fc950
4 changed files with 25 additions and 36 deletions

View File

@ -9,17 +9,17 @@ export function reportList(data: TableQueryParams) {
}
// 删除报告
export function reportDelete(moduleType: string, id: string) {
export function reportDelete(id: string) {
return MSR.get({ url: `${reportUrl.PlanDeleteUrl}/${id}` });
}
// 重命名
export function reportRename(moduleType: string, id: string, data: string) {
export function reportRename(id: string, data: string) {
return MSR.post({ url: `${reportUrl.PlanReportRenameUrl}/${id}`, data });
}
// 批量删除
export function reportBathDelete(moduleType: string, data: TableQueryParams) {
export function reportBathDelete(data: TableQueryParams) {
return MSR.post({ url: reportUrl.PlanBatchDeleteUrl, data });
}

View File

@ -1,6 +1,6 @@
<template>
<div class="p-[16px]">
<div class="flex items-center justify-between">
<div class="mb-4 flex items-center justify-between">
<a-radio-group v-model:model-value="showType" type="button" class="file-show-type" @change="changeShowType">
<a-radio value="All">{{ t('report.all') }}</a-radio>
<a-radio value="INDEPENDENT">{{ t('report.independent') }}</a-radio>
@ -137,7 +137,7 @@
size="small"
>
<a-checkbox v-for="key of statusFilters" :key="key" :value="key">
<ExecutionStatus :module-type="moduleType" :status="key" />
<ExecutionStatus :module-type="ReportStatusEnum.REPORT_STATUS" :status="key" />
</a-checkbox>
</a-checkbox-group>
</div>
@ -179,7 +179,7 @@
size="small"
>
<a-checkbox v-for="key of execStatusFilters" :key="key" :value="key">
<ExecutionStatus :module-type="moduleType" :status="key" />
<ExecutionStatus :module-type="ReportStatusEnum.EXEC_STATUS" :status="key" />
</a-checkbox>
</a-checkbox-group>
</div>
@ -196,7 +196,7 @@
</a-trigger>
</template>
<template #status="{ record }">
<ExecutionStatus :module-type="moduleType" :status="record.status" />
<ExecutionStatus :module-type="ReportStatusEnum.REPORT_STATUS" :status="record.status" />
</template>
<template #triggerMode="{ record }">
<span>{{ t(TriggerModeLabel[record.triggerMode as keyof typeof TriggerModeLabel]) }}</span>
@ -247,7 +247,6 @@
const appStore = useAppStore();
const tableStore = useTableStore();
const { t } = useI18n();
const moduleType = ReportStatusEnum.REPORT_STATUS;
const keyword = ref<string>('');
const statusFilterVisible = ref(false);
const execStatusFilterVisible = ref(false);
@ -375,7 +374,7 @@
const rename = async (record: any) => {
try {
await reportRename(moduleType, record.id, record.name);
await reportRename(record.id, record.name);
Message.success(t('common.updateSuccess'));
return true;
} catch (error) {
@ -391,7 +390,7 @@
},
showSetting: true,
selectable: hasAnyPermission(['PROJECT_TEST_PLAN_REPORT:READ+DELETE']),
heightUsed: 230,
heightUsed: 242,
paginationSize: 'mini',
showSelectorAll: true,
},
@ -461,7 +460,7 @@
setLoadListParams({
keyword: keyword.value,
projectId: appStore.currentProjectId,
moduleType,
filter: {
status: statusListFiltersMap.value[showType.value],
integrated: integratedFilters.value,
@ -517,7 +516,7 @@
},
onBeforeOk: async () => {
try {
await reportBathDelete(moduleType, batchParams.value);
await reportBathDelete(batchParams.value);
Message.success(t('apiTestDebug.deleteSuccess'));
resetSelector();
initData();
@ -546,7 +545,7 @@
},
onBeforeOk: async () => {
try {
await reportDelete(moduleType, id);
await reportDelete(id);
Message.success(t('apiTestDebug.deleteSuccess'));
initData();
} catch (error) {
@ -616,16 +615,6 @@
function showReportDetail(id: string, rowIndex: number) {
//
}
watch(
() => moduleType,
(val) => {
if (val) {
resetSelector();
initData();
}
}
);
</script>
<style lang="less" scoped>

View File

@ -24,15 +24,17 @@
const iconTypeStatus: Record<string, any> = {
[ReportStatusEnum.REPORT_STATUS]: {
RUNNING: {
icon: 'icon-icon_testing',
label: 'report.status.running',
color: '!text-[rgb(var(--link-6))]',
SUCCESS: {
icon: 'icon-icon_succeed_colorful',
label: 'report.successful',
},
PENDING: {
icon: 'icon-icon_block_filled',
label: 'report.status.pending',
color: '!text-[var(--color-text-input-border)]',
ERROR: {
icon: 'icon-icon_close_colorful',
label: 'report.failure',
},
FAKE_ERROR: {
icon: 'icon-icon_warning_colorful',
label: 'report.fake.error',
},
DEFAULT: {
icon: 'icon-icon_block_filled',
@ -65,10 +67,8 @@
};
function getExecutionResult(): IconType {
if (props.status in iconTypeStatus[props.moduleType]) {
return iconTypeStatus[props.moduleType][props.status];
}
return iconTypeStatus[props.moduleType].DEFAULT;
const moduleConfig = iconTypeStatus[props.moduleType];
return moduleConfig?.[props.status] ?? moduleConfig?.DEFAULT;
}
</script>

View File

@ -17,7 +17,7 @@ export default {
'report.status.running': '执行中',
'report.status.rerunning': '重跑中',
'report.status.pending': '未执行',
'report.stopped': '停止',
'report.stopped': '停止',
'report.trigger.scheduled': '定时执行',
'report.trigger.manual': '手动执行',
'report.trigger.interface': 'API 执行',