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([ const actionType = ref([
{ {
value: 'API', value: 'API',
name: '接口用例', name: t('caseManagement.featureCase.apiCase'),
}, },
{ {
value: 'SCENE', value: 'SCENE',
name: '接口用例', name: t('caseManagement.featureCase.sceneCase'),
}, },
{ {
value: 'UI', value: 'UI',
name: 'UI用例', name: t('caseManagement.featureCase.uiCase'),
}, },
{ {
value: 'PERFORMANCE', value: 'PERFORMANCE',
name: '性能用例', name: t('caseManagement.featureCase.propertyCase'),
}, },
]); ]);

View File

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

View File

@ -1,6 +1,10 @@
import { TagData } from '@arco-design/web-vue';
import { TableQueryParams } from '@/models/common'; import { TableQueryParams } from '@/models/common';
import { StatusType } from '@/enums/caseEnum'; import { StatusType } from '@/enums/caseEnum';
import { RawCommands } from '@halo-dev/richtext-editor';
export interface ModulesTreeType { export interface ModulesTreeType {
id: string; id: string;
name: string; name: string;
@ -28,6 +32,23 @@ export interface customFieldsItem {
value: string; 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 { export interface CaseManagementTable {
id: string; id: string;
@ -39,20 +60,23 @@ export interface CaseManagementTable {
reviewStatus: StatusType[keyof StatusType]; // 评审状态:未评审/评审中/通过/不通过/重新提审 reviewStatus: StatusType[keyof StatusType]; // 评审状态:未评审/评审中/通过/不通过/重新提审
tags: any; // 标签JSON) tags: any; // 标签JSON)
caseEditType: string; // 编辑模式:步骤模式/文本模式 caseEditType: string; // 编辑模式:步骤模式/文本模式
prerequisite: string; // 前置条件
pos: number; // 自定义排序间隔5000 pos: number; // 自定义排序间隔5000
versionId: string; // 版本ID versionId: string; // 版本ID
refId: string; // 指向初始版本ID refId: string; // 指向初始版本ID
lastExecuteResult: string; // 最近的执行结果:未执行/通过/失败/阻塞/跳过 lastExecuteResult: string; // 最近的执行结果:未执行/通过/失败/阻塞/跳过
deleted: true; // 是否在回收站0-否1-是 deleted: boolean; // 是否在回收站0-否1-是
publicCase: true; // 是否是公共用例0-否1-是 publicCase: boolean; // 是否是公共用例0-否1-是
latest: true; // 是否为最新版本0-否1-是 latest: boolean; // 是否为最新版本0-否1-是
createUser: string; createUser: string;
updateUser: string; updateUser: string;
deleteUser: string; deleteUser: string;
createTime: string; createTime: string;
updateTime: string; updateTime: string;
deleteTime: string; deleteTime: string;
customFields: customFieldsItem[]; // 自定义字段集合 steps: string;
customFields: CustomAttributes[]; // 自定义字段集合
[key: string]: any;
} }
// 选择类型步骤和预期结果列表 // 选择类型步骤和预期结果列表
@ -107,22 +131,6 @@ export interface BatchDeleteType {
projectId: string; 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 { export interface BatchEditCaseType {
selectIds: string[]; selectIds: string[];
@ -145,7 +153,9 @@ export interface BatchMoveOrCopyType {
condition: Record<string, any>; condition: Record<string, any>;
} }
export interface CreateCase { // 创建或者更新
export interface CreateOrUpdateCase {
id?: string;
projectId: string; projectId: string;
templateId: string; templateId: string;
name: string; name: string;
@ -158,9 +168,48 @@ export interface CreateCase {
publicCase: boolean; // 是否公共用例 publicCase: boolean; // 是否公共用例
moduleId: string; moduleId: string;
versionId: 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; tags: any;
customFields: CustomAttributes[] | Record<string, any>; // 自定义字段集合 caseEditType: string;
relateFileMetaIds: string[]; // 关联文件ID集合 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; [key: string]: any;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -199,7 +199,7 @@
import { downloadByteFile, getGenerateId } from '@/utils'; import { downloadByteFile, getGenerateId } from '@/utils';
import { scrollIntoView } from '@/utils/dom'; 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 { FormCreateKeyEnum } from '@/enums/formCreateEnum';
import { convertToFile } from '../utils'; import { convertToFile } from '../utils';
@ -216,7 +216,7 @@
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
form: CreateCase; form: DetailCase;
allowEdit?: boolean; // allowEdit?: boolean; //
}>(), }>(),
{ {

View File

@ -199,4 +199,8 @@ export default {
'caseManagement.featureCase.reviewComment': 'Review Comments', 'caseManagement.featureCase.reviewComment': 'Review Comments',
'caseManagement.featureCase.executiveReview': 'Executive review', 'caseManagement.featureCase.executiveReview': 'Executive review',
'caseManagement.featureCase.linkCase': 'Associated case', '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.reviewComment': '评审评论',
'caseManagement.featureCase.executiveReview': '执行评论', 'caseManagement.featureCase.executiveReview': '执行评论',
'caseManagement.featureCase.linkCase': '关联用例', '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 { useI18n } from '@/hooks/useI18n';
import type { CreateCase } from '@/models/caseManagement/featureCase'; import type { DetailCase } from '@/models/caseManagement/featureCase';
const route = useRoute(); const route = useRoute();
const { t } = useI18n(); const { t } = useI18n();
@ -324,7 +324,8 @@
{ label: resultMap[3].label, value: 'reReview' }, { label: resultMap[3].label, value: 'reReview' },
]); ]);
const initDetail: CreateCase = { const initDetail: DetailCase = {
id: '',
projectId: '', projectId: '',
templateId: '', templateId: '',
name: '', name: '',
@ -341,7 +342,7 @@
customFields: [], // customFields: [], //
relateFileMetaIds: [], // ID relateFileMetaIds: [], // ID
}; };
const detailForm = ref<CreateCase>({ ...initDetail }); const detailForm = ref<DetailCase>({ ...initDetail });
const caseList = ref([ const caseList = ref([
{ {