feat(测试计划): 测试计划关联用例新增协议入参

This commit is contained in:
xinxin.wu 2024-07-19 17:37:15 +08:00 committed by 刘瑞斌
parent 7f4983b72a
commit 1572175a69
4 changed files with 26 additions and 46 deletions

View File

@ -350,6 +350,7 @@
<script setup lang="ts">
import { ref } from 'vue';
import { useVModel } from '@vueuse/core';
import { isEqual } from 'lodash-es';
import { MsAdvanceFilter } from '@/components/pure/ms-advance-filter';
import MsDrawer from '@/components/pure/ms-drawer/index.vue';
@ -368,7 +369,7 @@
import type { ModuleTreeNode, TableQueryParams } from '@/models/common';
import type { ProjectListItem } from '@/models/setting/project';
import type { PlanDetailApiCaseTreeParams } from '@/models/testPlan/testPlan';
import type { AssociateCaseRequestParams, PlanDetailApiCaseTreeParams } from '@/models/testPlan/testPlan';
import { CaseModulesApiTypeEnum, CasePageApiTypeEnum } from '@/enums/associateCaseEnum';
import { CaseLinkEnum } from '@/enums/caseEnum';
@ -398,6 +399,7 @@
associatedIds?: string[]; // id
hideProjectSelect?: boolean; //
associatedType: keyof typeof CaseLinkEnum; //
protocols?: string[]; //
}>();
const emit = defineEmits<{
@ -533,10 +535,10 @@
const apiCaseCollectionId = ref<string>('');
const apiScenarioCollectionId = ref<string>('');
const selectedProtocols = ref<string[]>([]);
//
function handleConfirm() {
const params = {
const params: AssociateCaseRequestParams = {
moduleMaps: getMapParams(),
syncCase: false,
apiCaseCollectionId: '',
@ -545,6 +547,7 @@
projectId: innerProject.value,
associateType: 'FUNCTIONAL',
totalCount: totalCount.value,
protocols: [],
};
//
if (props.associatedType === CaseLinkEnum.FUNCTIONAL && syncCase.value) {
@ -555,6 +558,7 @@
if (props.associatedType === CaseLinkEnum.API) {
params.associateType = showType.value === 'API' ? showType.value : 'API_CASE';
params.protocols = selectedProtocols.value;
} else {
params.associateType = props.associatedType;
}
@ -586,7 +590,6 @@
}
}
const selectedProtocols = ref<string[]>([]);
async function initModulesCount(params: TableQueryParams) {
try {
modulesCount.value = await initGetModuleCountFunc(
@ -652,6 +655,7 @@
apiCaseCollectionId.value = apiSetTree.value[0].id;
apiScenarioCollectionId.value = scenarioSetTree.value[0].id;
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
}
}
@ -689,6 +693,12 @@
function handleProtocolChange(val: string[]) {
selectedProtocols.value = val;
//
nextTick(() => {
if (!isEqual(props.protocols, selectedProtocols.value)) {
clearSelector();
}
});
}
watch(

View File

@ -20,16 +20,13 @@
</template>
<script setup lang="ts">
import { useRoute } from 'vue-router';
import { Message } from '@arco-design/web-vue';
import MsCaseAssociate from '@/components/business/ms-associate-case/index.vue';
import type { saveParams } from '@/components/business/ms-associate-case/types';
import { useI18n } from '@/hooks/useI18n';
import useAppStore from '@/store/modules/app';
import type { AssociateCaseRequestParams, AssociateCaseRequestType } from '@/models/testPlan/testPlan';
import type { AssociateCaseRequestParams } from '@/models/testPlan/testPlan';
import { CaseCountApiTypeEnum, CaseModulesApiTypeEnum, CasePageApiTypeEnum } from '@/enums/associateCaseEnum';
import { CaseLinkEnum } from '@/enums/caseEnum';
@ -37,7 +34,6 @@
const props = defineProps<{
associationType: CaseLinkEnum;
modulesMaps?: Record<string, saveParams>;
saveApi?: (params: AssociateCaseRequestType) => Promise<any>;
testPlanId?: string;
}>();
const innerVisible = defineModel<boolean>('visible', {
@ -48,31 +44,13 @@
}>();
const appStore = useAppStore();
const route = useRoute();
const currentProjectId = ref(appStore.currentProjectId);
const confirmLoading = ref<boolean>(false);
const planId = ref(route.query.id as string);
async function saveHandler(params: AssociateCaseRequestParams) {
if (typeof props.saveApi !== 'function') {
emit('success', { ...params });
} else {
try {
confirmLoading.value = true;
await props.saveApi({
functionalSelectIds: params.selectIds,
testPlanId: planId.value,
});
emit('success', { ...params });
Message.success(t('ms.case.associate.associateSuccess'));
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
} finally {
confirmLoading.value = false;
}
}
emit('success', { ...params });
innerVisible.value = false;
}
</script>

View File

@ -225,6 +225,7 @@
:association-type="currentSelectCase"
:test-plan-id="props.planId"
:modules-maps="selectedAssociateCasesParams.moduleMaps"
:protocols="selectedAssociateCasesParams.protocols"
@success="writeAssociateCases"
/>
</template>
@ -553,19 +554,13 @@
//
const selectedAssociateCasesParams = ref<AssociateCaseRequestParams>({
excludeIds: [],
selectIds: [],
selectAll: false,
condition: {},
moduleIds: [],
versionId: '',
refId: '',
projectId: '',
moduleMaps: {},
syncCase: true,
apiCaseCollectionId: '',
apiScenarioCollectionId: '',
selectAllModule: false,
protocols: [],
});
function writeAssociateCases(param: AssociateCaseRequestParams) {
@ -590,19 +585,13 @@
function clearSelectedCases() {
selectedAssociateCasesParams.value = {
excludeIds: [],
selectIds: [],
selectAll: false,
condition: {},
moduleIds: [],
versionId: '',
refId: '',
projectId: '',
moduleMaps: {},
syncCase: true,
apiCaseCollectionId: '',
apiScenarioCollectionId: '',
selectAllModule: false,
protocols: [],
};
const node: PlanMinderNode = window.minder.getNodeById(activePlanSet.value?.data.id);
if (node?.data) {
@ -632,7 +621,7 @@
}
watch(
() => [configForm.value, selectedAssociateCasesParams.value.selectIds],
() => [configForm.value, selectedAssociateCasesParams.value.moduleMaps],
() => {
if (!switchingConfigFormData.value && configForm.value) {
configFormUnsaved.value = true;

View File

@ -40,14 +40,17 @@ export interface AssociateCaseRequest extends BatchApiParams {
associateApiType?: string;
}
export interface AssociateCaseRequestParams extends AssociateCaseRequest {
associateType?: string;
export interface AssociateCaseRequestParams {
moduleMaps?: Record<string, saveParams>;
syncCase: boolean;
apiCaseCollectionId: string;
apiScenarioCollectionId: string;
selectAllModule: boolean;
projectId: string;
protocols: string[];
totalCount?: number;
associateApiType?: string;
associateType?: string;
}
export type AssociateCaseRequestType = Pick<AssociateCaseRequest, 'functionalSelectIds' | 'testPlanId'>;