fix(用例管理): 修复用例详情相关问题

--bug=1037261 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001037261
--bug=1036542 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001036542
--bug=1035893 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001035893
This commit is contained in:
guoyuqi 2024-03-22 19:56:47 +08:00 committed by 刘瑞斌
parent 54f7adf4f0
commit 932d9fdb77
8 changed files with 83 additions and 25 deletions

View File

@ -241,7 +241,7 @@ export function getThirdDemandList(data: TableQueryParams) {
// 上传文件并关联用例
export function uploadOrAssociationFile(data: Record<string, any>) {
return MSR.uploadFile({ url: UploadOrAssociationFileUrl }, { request: data.request, fileList: data.file });
return MSR.uploadFile({ url: UploadOrAssociationFileUrl }, { request: data.request, fileList: [data.file] });
}
// 转存文件
export function transferFileRequest(data: OperationFile) {

View File

@ -806,10 +806,14 @@ export function customFieldDataToTableData(customFieldData: Record<string, any>[
tableData[field.id] = JSON.parse(field.value).join('') || '-';
} else if (multipleExcludes.includes(field.type) && Array.isArray(field.options) && field.value) {
// 多值的类型后端返回的是json字符串
field.value = JSON.parse(field.value);
tableData[field.id] = field.value
.map((val: string) => field.options.find((option: { value: string }) => option.value === val)?.text)
.join(',');
try {
field.value = JSON.parse(field.value);
tableData[field.id] = field.value
.map((val: string) => field.options.find((option: { value: string }) => option.value === val)?.text)
.join(',');
} catch (e) {
console.log('自定义字段值不是数组');
}
} else {
tableData[field.id] = field.value;
}

View File

@ -646,7 +646,7 @@
line-height: 32px;
@apply flex;
.label {
width: 38%;
width: 84px;
color: var(--color-text-3);
}
}

View File

@ -99,6 +99,7 @@
if (isContinue) {
Message.success(t('caseManagement.featureCase.addSuccess'));
caseModuleDetailRef.value.resetForm();
return;
}
createSuccessId.value = res.data.id;

View File

@ -672,7 +672,7 @@
@apply flex;
.label {
flex-shrink: 0;
width: 38%;
width: 84px;
color: var(--color-text-3);
}
.value {
@ -682,8 +682,26 @@
:deep(.arco-form-item-layout-horizontal) {
margin-bottom: 16px !important;
}
:deep(.arco-form-item-label-col) {
padding-right: 0;
}
:deep(.arco-col-9) {
flex: 0 0 84px;
width: 84px;
}
:deep(.arco-col-15) {
flex: 0 0 calc(100% - 84px);
width: calc(100% - 84px);
}
:deep(.arco-form-item-label::after) {
color: red !important;
}
:deep(.arco-form-item-label-col > .arco-form-item-label) {
color: var(--color-text-3) !important;
width: 84px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
:deep(.arco-select-view-single) {
border-color: transparent !important;

View File

@ -160,7 +160,6 @@
ref="fileListRef"
v-model:file-list="fileList"
:show-tab="false"
mode="static"
:request-params="{
caseId: detailForm.id,
projectId: currentProjectId,
@ -168,6 +167,7 @@
:upload-func="uploadOrAssociationFile"
:handle-delete="deleteFileHandler"
:show-delete="props.allowEdit"
@finish="uploadFileOver"
>
<template #actions="{ item }">
<div v-if="props.allowEdit">
@ -287,6 +287,7 @@
import AddStep from '../addStep.vue';
import TransferModal from './transferModal.vue';
import { deleteRecycleCase } from '@/api/modules/api-test/management';
import {
checkFileIsUpdateRequest,
deleteFileOrCancelAssociation,
@ -302,8 +303,9 @@
import { getModules, getModulesCount } from '@/api/modules/project-management/fileManagement';
import { PreviewEditorImageUrl } from '@/api/requrls/case-management/featureCase';
import { useI18n } from '@/hooks/useI18n';
import useModal from '@/hooks/useModal';
import useAppStore from '@/store/modules/app';
import { downloadByteFile, getGenerateId } from '@/utils';
import { downloadByteFile, getGenerateId, sleep } from '@/utils';
import { scrollIntoView } from '@/utils/dom';
import type { AssociatedList, DetailCase, StepList } from '@/models/caseManagement/featureCase';
@ -314,6 +316,7 @@
const caseFormRef = ref<FormInstance>();
const appStore = useAppStore();
const { openModal } = useModal();
const currentProjectId = computed(() => appStore.currentProjectId);
const { t } = useI18n();
@ -533,21 +536,36 @@
//
async function deleteFileHandler(item: MsFileItem) {
try {
const params = {
id: item.uid,
local: item.local,
caseId: detailForm.value.id,
projectId: currentProjectId.value,
};
await deleteFileOrCancelAssociation(params);
Message.success(
item.local ? t('caseManagement.featureCase.deleteSuccess') : t('caseManagement.featureCase.cancelLinkSuccess')
);
emit('updateSuccess');
} catch (error) {
console.log(error);
}
openModal({
type: 'error',
title: t('caseManagement.featureCase.deleteFile', { name: item?.name }),
content: t('caseManagement.featureCase.deleteFileTip'),
okText: t('common.confirmDelete'),
cancelText: t('common.cancel'),
okButtonProps: {
status: 'danger',
},
onBeforeOk: async () => {
try {
const params = {
id: item.uid,
local: item.local,
caseId: detailForm.value.id,
projectId: currentProjectId.value,
};
await deleteFileOrCancelAssociation(params);
Message.success(
item.local
? t('caseManagement.featureCase.deleteSuccess')
: t('caseManagement.featureCase.cancelLinkSuccess')
);
emit('updateSuccess');
} catch (error) {
console.log(error);
}
},
hideCancel: false,
});
}
const transferVisible = ref<boolean>(false);
@ -627,6 +645,12 @@
}
}
async function restartUpload() {
await sleep(300);
console.log('ooo');
fileListRef.value?.startUpload();
}
watch(
() => props.form,
(val) => {
@ -681,6 +705,10 @@
return data;
}
async function uploadFileOver() {
emit('updateSuccess');
}
function handleChange(_fileList: MsFileItem[], fileItem?: MsFileItem) {
//
const isRepeat = _fileList.filter((item) => item.name === fileItem?.name && item.local).length > 1;
@ -700,7 +728,7 @@
local: true, //
};
});
startUpload();
restartUpload();
}
}

View File

@ -271,4 +271,8 @@ export default {
'caseManagement.featureCase.excelImportTip': 'Only xls/xlsx files are supported',
'caseManagement.featureCase.xmindImportTip': 'Only xmind files are supported',
'caseManagement.featureCase.AssociatedSuccess': 'Associated with success',
'caseManagement.featureCase.deleteFile': 'Are you sure you want to delete file {name} ',
'caseManagement.featureCase.deleteFileTip':
'After deletion, the file cannot be restored. Please operate with caution!',
'caseManagement.featureCase.nameNotNull': 'The name can not be null!',
};

View File

@ -267,4 +267,7 @@ export default {
'caseManagement.featureCase.excelImportTip': '仅支持xls/xlsx格式的文件',
'caseManagement.featureCase.xmindImportTip': '仅支持xmind格式的文件',
'caseManagement.featureCase.AssociatedSuccess': '关联成功',
'caseManagement.featureCase.deleteFile': '确认删除文件 {name} 吗',
'caseManagement.featureCase.deleteFileTip': '删除后,文件无法恢复,请谨慎操作!',
'caseManagement.featureCase.nameNotNull': '用例名称不能为空!',
};