feat(测试计划): 测试计划关联用例新增协议入参
This commit is contained in:
parent
7f4983b72a
commit
1572175a69
|
@ -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(
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
innerVisible.value = false;
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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'>;
|
||||
|
|
Loading…
Reference in New Issue