fix(功能用例): 修改ts类型

This commit is contained in:
xinxin.wu 2023-12-11 12:52:44 +08:00 committed by Craftsman
parent 5ddf98c414
commit 879d929ff3
12 changed files with 139 additions and 73 deletions

View File

@ -181,19 +181,19 @@
const actionType = ref([
{
value: 'API',
name: '接口用例',
name: t('caseManagement.featureCase.apiCase'),
},
{
value: 'SCENE',
name: '接口用例',
name: t('caseManagement.featureCase.sceneCase'),
},
{
value: 'UI',
name: 'UI用例',
name: t('caseManagement.featureCase.uiCase'),
},
{
value: 'PERFORMANCE',
name: '性能用例',
name: t('caseManagement.featureCase.propertyCase'),
},
]);

View File

@ -24,7 +24,7 @@
props.titleTag
}}</a-tag></div
>
<div class="flex"> <slot name="tbutton"></slot></div>
<slot name="tbutton"></slot>
</div>
</slot>
</template>

View File

@ -1,6 +1,10 @@
import { TagData } from '@arco-design/web-vue';
import { TableQueryParams } from '@/models/common';
import { StatusType } from '@/enums/caseEnum';
import { RawCommands } from '@halo-dev/richtext-editor';
export interface ModulesTreeType {
id: string;
name: string;
@ -28,6 +32,23 @@ export interface customFieldsItem {
value: string;
}
export interface OptionsFieldId {
fieldId: string;
value: string;
text: string;
internal: boolean; // 是否是内置
}
export interface CustomAttributes {
fieldId: string;
fieldName: string;
required: boolean;
apiFieldId: null | undefined | 'string'; // 三方API
defaultValue: string;
type: string;
options: OptionsFieldId[];
}
// 功能用例表
export interface CaseManagementTable {
id: string;
@ -39,20 +60,23 @@ export interface CaseManagementTable {
reviewStatus: StatusType[keyof StatusType]; // 评审状态:未评审/评审中/通过/不通过/重新提审
tags: any; // 标签JSON)
caseEditType: string; // 编辑模式:步骤模式/文本模式
prerequisite: string; // 前置条件
pos: number; // 自定义排序间隔5000
versionId: string; // 版本ID
refId: string; // 指向初始版本ID
lastExecuteResult: string; // 最近的执行结果:未执行/通过/失败/阻塞/跳过
deleted: true; // 是否在回收站0-否1-是
publicCase: true; // 是否是公共用例0-否1-是
latest: true; // 是否为最新版本0-否1-是
deleted: boolean; // 是否在回收站0-否1-是
publicCase: boolean; // 是否是公共用例0-否1-是
latest: boolean; // 是否为最新版本0-否1-是
createUser: string;
updateUser: string;
deleteUser: string;
createTime: string;
updateTime: string;
deleteTime: string;
customFields: customFieldsItem[]; // 自定义字段集合
steps: string;
customFields: CustomAttributes[]; // 自定义字段集合
[key: string]: any;
}
// 选择类型步骤和预期结果列表
@ -107,22 +131,6 @@ export interface BatchDeleteType {
projectId: string;
}
export interface OptionsFieldId {
fieldId: string;
value: string;
text: string;
internal: boolean; // 是否是内置
}
export interface CustomAttributes {
fieldId: string;
fieldName: string;
required: boolean;
apiFieldId: null | undefined | 'string'; // 三方API
defaultValue: string;
type: string;
options: OptionsFieldId[];
}
// 批量编辑
export interface BatchEditCaseType {
selectIds: string[];
@ -145,7 +153,9 @@ export interface BatchMoveOrCopyType {
condition: Record<string, any>;
}
export interface CreateCase {
// 创建或者更新
export interface CreateOrUpdateCase {
id?: string;
projectId: string;
templateId: string;
name: string;
@ -158,9 +168,48 @@ export interface CreateCase {
publicCase: boolean; // 是否公共用例
moduleId: string;
versionId: string;
tags: string[];
customFields: Record<string, any>; // 自定义字段集合
relateFileMetaIds?: string[]; // 关联文件ID集合
deleteFileMetaIds?: string[]; // 删除本地上传的文件id
unLinkFilesIds?: string[]; // 取消关联的文件id
[key: string]: any;
}
export interface AttachFileInfo {
id: string;
fileId: string;
fileName: string;
size: number;
local: boolean;
createUser: string;
createTime: number;
[key: string]: any;
}
// 详情
export interface DetailCase {
id: string;
num?: number;
moduleId: string;
moduleName?: string;
projectId: string;
templateId?: string;
name: string;
reviewStatus?: string;
tags: any;
customFields: CustomAttributes[] | Record<string, any>; // 自定义字段集合
relateFileMetaIds: string[]; // 关联文件ID集合
caseEditType: string;
versionId?: string;
publicCase: boolean;
latest?: boolean;
createUser?: string;
steps: string;
textDescription: string;
expectedResult: string;
prerequisite: string;
description: string;
customFields: CustomAttributes[];
attachments?: AttachFileInfo[];
followFlag?: boolean;
[key: string]: any;
}

View File

@ -193,7 +193,7 @@
function loadedCase(detail: CaseManagementTable) {
detailInfo.value = { ...detail };
customFields.value = detailInfo.value.customFields as CustomAttributes[];
customFields.value = detailInfo.value.customFields;
}
const moduleName = computed(() => {

View File

@ -195,8 +195,9 @@
import type {
CaseManagementTable,
CreateCase,
CreateOrUpdateCase,
CustomAttributes,
DetailCase,
TabItemType,
} from '@/models/caseManagement/featureCase';
import { FormCreateKeyEnum } from '@/enums/formCreateEnum';
@ -251,7 +252,8 @@
break;
}
}
const initDetail: CreateCase = {
const initDetail: DetailCase = {
id: '',
projectId: '',
templateId: '',
name: '',
@ -269,12 +271,12 @@
relateFileMetaIds: [], // ID
};
const detailInfo = ref<CreateCase>({ ...initDetail });
const detailInfo = ref<DetailCase>({ ...initDetail });
const customFields = ref<CustomAttributes[]>([]);
const caseLevels = ref(0);
function loadedCase(detail: CreateCase) {
function loadedCase(detail: DetailCase) {
detailInfo.value = { ...detail };
customFields.value = detailInfo.value.customFields as CustomAttributes[];
customFields.value = detailInfo.value.customFields;
const caseLevelsValue = customFields.value.find((item) => item.fieldName === '用例等级')?.defaultValue;
if (caseLevelsValue) {
caseLevels.value = JSON.parse(caseLevelsValue).replaceAll('P', '') * 1;
@ -313,13 +315,15 @@
async function followHandler() {
followLoading.value = true;
try {
await followerCaseRequest({ userId: userId.value as string, functionalCaseId: detailInfo.value.id });
updateSuccess();
Message.success(
detailInfo.value.followFlag
? t('caseManagement.featureCase.cancelFollowSuccess')
: t('caseManagement.featureCase.followSuccess')
);
if (detailInfo.value.id) {
await followerCaseRequest({ userId: userId.value as string, functionalCaseId: detailInfo.value.id });
updateSuccess();
Message.success(
detailInfo.value.followFlag
? t('caseManagement.featureCase.cancelFollowSuccess')
: t('caseManagement.featureCase.followSuccess')
);
}
} catch (error) {
console.log(error);
} finally {

View File

@ -237,7 +237,13 @@
import useFormCreateStore from '@/store/modules/form-create/form-create';
import { getGenerateId } from '@/utils';
import type { AssociatedList, CreateCase, StepList } from '@/models/caseManagement/featureCase';
import type {
AssociatedList,
AttachFileInfo,
CreateOrUpdateCase,
DetailCase,
StepList,
} from '@/models/caseManagement/featureCase';
import type { CustomField, DefinedFieldItem } from '@/models/setting/template';
import { FormCreateKeyEnum } from '@/enums/formCreateEnum';
@ -280,7 +286,8 @@
const modelId = computed(() => featureCaseStore.moduleId[0]);
const caseTree = computed(() => featureCaseStore.caseTree);
const initForm: CreateCase = {
const initForm: DetailCase = {
id: '',
projectId: currentProjectId.value,
templateId: '',
name: '',
@ -298,7 +305,7 @@
relateFileMetaIds: [],
};
const form = ref<CreateCase>({ ...initForm });
const form = ref<DetailCase | CreateOrUpdateCase>({ ...initForm });
watch(
() => stepData.value,
@ -381,7 +388,7 @@
}
const isEditOrCopy = computed(() => !!route.query.id);
const attachmentsList = ref([]);
const attachmentsList = ref<AttachFileInfo[]>([]);
// localitem
const oldLocalFileList = computed(() => {
@ -433,12 +440,12 @@
});
//
function getDetailData(detailResult: CreateCase) {
function getDetailData(detailResult: DetailCase) {
const { customFields, attachments, steps, tags } = detailResult;
form.value = {
...detailResult,
name: route.params.mode === 'copy' ? `${detailResult.name}_copy` : detailResult.name,
tags: JSON.parse(tags as string),
tags: JSON.parse(tags),
};
//
selectData.value = getCustomDetailFields(
@ -454,19 +461,21 @@
};
});
}
attachmentsList.value = attachments;
if (attachments) {
attachmentsList.value = attachments;
//
fileList.value = attachments
.map((fileInfo: any) => {
return {
...fileInfo,
name: fileInfo.fileName,
};
})
.map((fileInfo: any) => {
return convertToFile(fileInfo);
});
//
fileList.value = attachments
.map((fileInfo: any) => {
return {
...fileInfo,
name: fileInfo.fileName,
};
})
.map((fileInfo: any) => {
return convertToFile(fileInfo);
});
}
}
//
@ -474,7 +483,7 @@
try {
isLoading.value = true;
await getAllCaseFields();
const detailResult = await getCaseDetail(route.query.id as string);
const detailResult: DetailCase = await getCaseDetail(route.query.id as string);
getDetailData(detailResult);
} catch (error) {
console.log(error);
@ -605,7 +614,7 @@
formRuleList.value?.forEach((item) => {
customFieldsMaps[item.field as string] = item.value;
});
form.value.customFields = customFieldsMaps as Record<string, any>;
form.value.customFields = customFieldsMaps;
},
{ deep: true }
);

View File

@ -5,7 +5,7 @@
allow-clear
class="mb-[16px]"
></a-input>
<a-spin class="min-h-[300px] w-full" :loading="loading">
<a-spin class="min-h-[400px] w-full" :loading="loading">
<MsTree
v-model:focus-node-key="focusNodeKey"
:selected-keys="props.selectedKeys"
@ -59,7 +59,6 @@
const props = defineProps<{
isExpandAll: boolean;
selectedKeys?: Array<string | number>; // key
isModal?: boolean; //
modulesCount?: Record<string, number>; //
showType?: string; //
getTreeRequest: (params: any) => Promise<ModuleTreeNode[]>; //
@ -76,7 +75,7 @@
const virtualListProps = computed(() => {
return {
height: 'calc(100vh - 350px)',
height: 'calc(100vh - 296px)',
};
});

View File

@ -127,10 +127,6 @@
onMounted(() => {
resetSelector();
});
onMounted(() => {
resetSelector();
});
</script>
<style scoped></style>

View File

@ -199,7 +199,7 @@
import { downloadByteFile, getGenerateId } from '@/utils';
import { scrollIntoView } from '@/utils/dom';
import type { AssociatedList, CreateCase, StepList } from '@/models/caseManagement/featureCase';
import type { AssociatedList, CreateOrUpdateCase, DetailCase, StepList } from '@/models/caseManagement/featureCase';
import { FormCreateKeyEnum } from '@/enums/formCreateEnum';
import { convertToFile } from '../utils';
@ -216,7 +216,7 @@
const props = withDefaults(
defineProps<{
form: CreateCase;
form: DetailCase;
allowEdit?: boolean; //
}>(),
{

View File

@ -199,4 +199,8 @@ export default {
'caseManagement.featureCase.reviewComment': 'Review Comments',
'caseManagement.featureCase.executiveReview': 'Executive review',
'caseManagement.featureCase.linkCase': 'Associated case',
'caseManagement.featureCase.apiCase': 'API Case',
'caseManagement.featureCase.sceneCase': 'Scene Case',
'caseManagement.featureCase.uiCase': 'UI Case',
'caseManagement.featureCase.propertyCase': 'Property Case',
};

View File

@ -197,4 +197,8 @@ export default {
'caseManagement.featureCase.reviewComment': '评审评论',
'caseManagement.featureCase.executiveReview': '执行评论',
'caseManagement.featureCase.linkCase': '关联用例',
'caseManagement.featureCase.apiCase': '接口用例',
'caseManagement.featureCase.sceneCase': '场景用例',
'caseManagement.featureCase.uiCase': 'UI用例',
'caseManagement.featureCase.propertyCase': '性能用例',
};

View File

@ -280,7 +280,7 @@
import { useI18n } from '@/hooks/useI18n';
import type { CreateCase } from '@/models/caseManagement/featureCase';
import type { DetailCase } from '@/models/caseManagement/featureCase';
const route = useRoute();
const { t } = useI18n();
@ -324,7 +324,8 @@
{ label: resultMap[3].label, value: 'reReview' },
]);
const initDetail: CreateCase = {
const initDetail: DetailCase = {
id: '',
projectId: '',
templateId: '',
name: '',
@ -341,7 +342,7 @@
customFields: [], //
relateFileMetaIds: [], // ID
};
const detailForm = ref<CreateCase>({ ...initDetail });
const detailForm = ref<DetailCase>({ ...initDetail });
const caseList = ref([
{