feat(功能用例): 联调公共关联用例抽屉接口

This commit is contained in:
xinxin.wu 2024-01-03 10:51:23 +08:00 committed by Craftsman
parent f650d0c78d
commit 58c27af024
13 changed files with 407 additions and 271 deletions

View File

@ -1,6 +1,7 @@
import MSR from '@/api/http/index'; import MSR from '@/api/http/index';
import { import {
AddDemandUrl, AddDemandUrl,
AddDependOnRelationUrl,
BatchAssociationDemandUrl, BatchAssociationDemandUrl,
BatchCopyCaseUrl, BatchCopyCaseUrl,
BatchDeleteCaseUrl, BatchDeleteCaseUrl,
@ -21,12 +22,17 @@ import {
DownloadFileUrl, DownloadFileUrl,
FollowerCaseUrl, FollowerCaseUrl,
GetAssociatedFilePageUrl, GetAssociatedFilePageUrl,
GetAssociationPublicCaseModuleCountUrl,
GetAssociationPublicCasePageUrl,
GetAssociationPublicModuleTreeUrl,
GetCaseListUrl, GetCaseListUrl,
GetCaseModulesCountUrl, GetCaseModulesCountUrl,
GetCaseModuleTreeUrl, GetCaseModuleTreeUrl,
GetCommentListUrl, GetCommentListUrl,
GetDefaultTemplateFieldsUrl, GetDefaultTemplateFieldsUrl,
GetDemandListUrl, GetDemandListUrl,
GetDependOnPageUrl,
GetDependOnRelationUrl,
GetDetailCaseReviewUrl, GetDetailCaseReviewUrl,
GetFileIsUpdateUrl, GetFileIsUpdateUrl,
GetRecycleCaseListUrl, GetRecycleCaseListUrl,
@ -67,8 +73,8 @@ import type {
import type { CommonList, MoveModules, TableQueryParams } from '@/models/common'; import type { CommonList, MoveModules, TableQueryParams } from '@/models/common';
import type { UserListItem } from '@/models/setting/user'; import type { UserListItem } from '@/models/setting/user';
// 获取模块树 // 获取模块树
export function getCaseModuleTree(projectId: string) { export function getCaseModuleTree(params: TableQueryParams) {
return MSR.get<ModulesTreeType[]>({ url: `${GetCaseModuleTreeUrl}/${projectId}` }); return MSR.get<ModulesTreeType[]>({ url: `${GetCaseModuleTreeUrl}/${params.projectId}` });
} }
// 创建模块树 // 创建模块树
@ -157,7 +163,7 @@ export function getRecycleModulesCounts(data: CaseModuleQueryParams) {
return MSR.post({ url: GetRecycleCaseModulesCountUrl, data }); return MSR.post({ url: GetRecycleCaseModulesCountUrl, data });
} }
// 获取全部用例模块数量 // 获取全部用例模块数量
export function getCaseModulesCounts(data: CaseModuleQueryParams) { export function getCaseModulesCounts(data: TableQueryParams) {
return MSR.post({ url: GetCaseModulesCountUrl, data }); return MSR.post({ url: GetCaseModulesCountUrl, data });
} }
// 批量恢复回收站用例表 // 批量恢复回收站用例表
@ -276,4 +282,31 @@ export function getReviewerList(projectId: string, keyword: string) {
return MSR.get<UserListItem[]>({ url: `${GetReviewerListUrl}/${projectId}`, params: { keyword } }); return MSR.get<UserListItem[]>({ url: `${GetReviewerListUrl}/${projectId}`, params: { keyword } });
} }
// 用例接口用例分页列表
export function getPublicLinkCaseList(data: TableQueryParams) {
return MSR.post<CommonList<CaseManagementTable>>({ url: GetAssociationPublicCasePageUrl, data });
}
// 获取用例详情接口用例模块数量
export function getPublicLinkCaseModulesCounts(data: TableQueryParams) {
return MSR.post({ url: GetAssociationPublicCaseModuleCountUrl, data });
}
// 获取关联用例接口模块树
export function getPublicLinkModuleTree(data: TableQueryParams) {
return MSR.post<ModulesTreeType[]>({ url: `${GetAssociationPublicModuleTreeUrl}`, data });
}
// 获取前后置用例
export function getDependOnCase(data: TableQueryParams) {
return MSR.post<CommonList<CaseManagementTable>>({ url: `${GetDependOnPageUrl}`, data });
}
// 用例管理-功能用例-用例详情-前后置关系
export function getPrepositionRelation(data: TableQueryParams) {
return MSR.post<CommonList<CaseManagementTable>>({ url: `${GetDependOnRelationUrl}`, data });
}
// 添加前后置关系
export function addPrepositionRelation(data: TableQueryParams) {
return MSR.post<ModulesTreeType[]>({ url: `${AddDependOnRelationUrl}`, data });
}
export default {}; export default {};

View File

@ -102,5 +102,15 @@ export const DeleteCommentItemUrl = '/functional/case/comment/delete';
export const GetDetailCaseReviewUrl = '/functional/case/review/page'; export const GetDetailCaseReviewUrl = '/functional/case/review/page';
// 获取有权限的评审人 // 获取有权限的评审人
export const GetReviewerListUrl = '/case/review/user-option'; export const GetReviewerListUrl = '/case/review/user-option';
// 获取用例详情弹窗关联用例接口用例
export default {}; export const GetAssociationPublicCasePageUrl = '/functional/case/test/associate/case/page';
// 获取接口测试接口模块数量
export const GetAssociationPublicCaseModuleCountUrl = '/functional/case/test/associate/case/module/count';
// 获取用例详情接口模块树
export const GetAssociationPublicModuleTreeUrl = '/functional/case/test/associate/case/module/tree';
// 获取前后置用例列表
export const GetDependOnPageUrl = '/functional/case/relationship/page';
// 用例管理-功能用例-用例详情-前后置关系
export const GetDependOnRelationUrl = '/functional/case/relationship/relate/page';
// 添加前后置关系
export const AddDependOnRelationUrl = '/functional/case/relationship/add';

View File

@ -5,6 +5,7 @@
:width="1200" :width="1200"
:footer="false" :footer="false"
no-content-padding no-content-padding
unmount-on-close
> >
<template #headerLeft> <template #headerLeft>
<div class="float-left"> <div class="float-left">
@ -24,7 +25,7 @@
<div class="w-[292px] border-r border-[var(--color-text-n8)] p-[16px]"> <div class="w-[292px] border-r border-[var(--color-text-n8)] p-[16px]">
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<MsProjectSelect v-model:project="innerProject" class="mb-[16px]" /> <MsProjectSelect v-model:project="innerProject" class="mb-[16px]" />
<a-select v-if="caseType === 'API_CASE'" v-model="protocolType" class="mb-[16px] ml-2 max-w-[90px]"> <a-select v-if="caseType === 'API'" v-model="protocolType" class="mb-[16px] ml-2 max-w-[90px]">
<a-option v-for="item of protocolOptions" :key="item" :value="item">{{ item }}</a-option> <a-option v-for="item of protocolOptions" :key="item" :value="item">{{ item }}</a-option>
</a-select> </a-select>
</div> </div>
@ -38,7 +39,7 @@
<div :class="getFolderClass('all')" @click="setActiveFolder('all')"> <div :class="getFolderClass('all')" @click="setActiveFolder('all')">
<MsIcon type="icon-icon_folder_filled1" class="folder-icon" /> <MsIcon type="icon-icon_folder_filled1" class="folder-icon" />
<div class="folder-name">{{ t('caseManagement.featureCase.allCase') }}</div> <div class="folder-name">{{ t('caseManagement.featureCase.allCase') }}</div>
<div class="folder-count">({{ props.modulesCount['all'] }})</div> <div class="folder-count">({{ modulesCount['all'] }})</div>
</div> </div>
</div> </div>
<a-divider class="my-[8px]" /> <a-divider class="my-[8px]" />
@ -47,7 +48,7 @@
v-model:selected-keys="selectedModuleKeys" v-model:selected-keys="selectedModuleKeys"
:data="folderTree" :data="folderTree"
:keyword="moduleKeyword" :keyword="moduleKeyword"
:empty-text="t('caseManagement.caseReview.noReviews')" :empty-text="t('caseManagement.featureCase.caseEmptyRecycle')"
:virtual-list-props="virtualListProps" :virtual-list-props="virtualListProps"
:field-names="{ :field-names="{
title: 'name', title: 'name',
@ -146,7 +147,7 @@
import useAppStore from '@/store/modules/app'; import useAppStore from '@/store/modules/app';
import { mapTree } from '@/utils'; import { mapTree } from '@/utils';
import type { CaseManagementTable, CaseModuleQueryParams } from '@/models/caseManagement/featureCase'; import type { CaseManagementTable } from '@/models/caseManagement/featureCase';
import type { CommonList, TableQueryParams } from '@/models/common'; import type { CommonList, TableQueryParams } from '@/models/common';
import { ModuleTreeNode } from '@/models/projectManagement/file'; import { ModuleTreeNode } from '@/models/projectManagement/file';
@ -157,11 +158,13 @@
const props = defineProps<{ const props = defineProps<{
visible: boolean; visible: boolean;
project: string; projectId: string; // id
getModulesFunc: (projectId: string) => Promise<ModuleTreeNode[]>; // caseId?: string; // id
getTableFunc: (params: TableQueryParams) => Promise<CommonList<CaseManagementTable>>; // getModulesFunc: (params: TableQueryParams) => Promise<ModuleTreeNode[]>; //
modulesParams?: Record<string, any>; //
getTableFunc: (params: TableQueryParams) => Promise<CommonList<CaseManagementTable>>; //
tableParams?: TableQueryParams; // tableParams?: TableQueryParams; //
modulesCount: Record<string, number>; // modulesCount: Record<string, any>; //
okButtonDisabled?: boolean; // okButtonDisabled?: boolean; //
currentSelectCase: string | number | Record<string, any> | undefined; // currentSelectCase: string | number | Record<string, any> | undefined; //
moduleOptions?: { label: string; value: string }[]; // moduleOptions?: { label: string; value: string }[]; //
@ -173,7 +176,7 @@
(e: 'update:visible', val: boolean): void; (e: 'update:visible', val: boolean): void;
(e: 'update:project', val: string): void; (e: 'update:project', val: string): void;
(e: 'update:currentSelectCase', val: string | number | Record<string, any> | undefined): void; (e: 'update:currentSelectCase', val: string | number | Record<string, any> | undefined): void;
(e: 'init', val: CaseModuleQueryParams): void; // (e: 'init', val: TableQueryParams): void; //
(e: 'close'): void; (e: 'close'): void;
(e: 'save', params: TableQueryParams): void; // table (e: 'save', params: TableQueryParams): void; // table
}>(); }>();
@ -184,7 +187,7 @@
}; };
}); });
const activeFolder = ref('all'); const activeFolder = ref('');
const activeFolderName = ref(t('ms.case.associate.allCase')); const activeFolderName = ref(t('ms.case.associate.allCase'));
const filterRowCount = ref(0); const filterRowCount = ref(0);
@ -205,11 +208,21 @@
} }
const innerVisible = ref(props.visible); const innerVisible = ref(props.visible);
const innerProject = ref(props.project); const innerProject = ref(props.projectId);
const protocolType = ref('HTTP'); // const protocolType = ref('HTTP'); //
const protocolOptions = ref(['HTTP']); const protocolOptions = ref(['HTTP']);
//
const caseType = computed({
get() {
return props.currentSelectCase;
},
set(val) {
emit('update:currentSelectCase', val);
},
});
/** /**
* 初始化模块树 * 初始化模块树
* @param isSetDefaultKey 是否设置第一个节点为选中节点 * @param isSetDefaultKey 是否设置第一个节点为选中节点
@ -217,7 +230,18 @@
async function initModules(isSetDefaultKey = false) { async function initModules(isSetDefaultKey = false) {
try { try {
moduleLoading.value = true; moduleLoading.value = true;
const res = await props.getModulesFunc(innerProject.value); let params = {
projectId: innerProject.value,
sourceType: props.moduleOptions && props.moduleOptions.length ? caseType.value : undefined,
sourceId: props.moduleOptions && props.moduleOptions.length ? props.caseId : undefined,
};
if (props.modulesParams) {
params = {
...params,
...props.modulesParams,
};
}
const res = await props.getModulesFunc(params);
folderTree.value = mapTree<ModuleTreeNode>(res, (e) => { folderTree.value = mapTree<ModuleTreeNode>(res, (e) => {
return { return {
...e, ...e,
@ -260,16 +284,6 @@
}); });
} }
//
const caseType = computed({
get() {
return props.currentSelectCase;
},
set(val) {
emit('update:currentSelectCase', val);
},
});
const keyword = ref(''); const keyword = ref('');
const version = ref(''); const version = ref('');
const versionOptions = ref([ const versionOptions = ref([
@ -339,13 +353,16 @@
}, },
]; ];
const getTableList = computed(() => props.getTableFunc);
const { propsRes, propsEvent, loadList, setLoadListParams, resetSelector } = useTable( const { propsRes, propsEvent, loadList, setLoadListParams, resetSelector } = useTable(
props.getTableFunc, getTableList.value,
{ {
columns, columns,
showSetting: false, showSetting: false,
selectable: true, selectable: true,
showSelectAll: true, showSelectAll: true,
heightUsed: 310,
}, },
(record) => { (record) => {
return { return {
@ -366,17 +383,21 @@
}); });
function getLoadListParams() { function getLoadListParams() {
if (activeFolder.value === 'all') { if (activeFolder.value === 'all' || !activeFolder.value) {
searchParams.value.moduleIds = []; searchParams.value.moduleIds = [];
} else { } else {
searchParams.value.moduleIds = [activeFolder.value, ...offspringIds.value]; searchParams.value.moduleIds = [activeFolder.value, ...offspringIds.value];
} }
if (props.moduleOptions && props.moduleOptions.length) {
searchParams.value.sourceType = caseType.value;
searchParams.value.sourceId = props.caseId;
}
setLoadListParams({ setLoadListParams({
...searchParams.value, ...searchParams.value,
...props.tableParams, ...props.tableParams,
keyword: keyword.value, keyword: keyword.value,
projectId: innerProject.value, projectId: innerProject.value,
excludeIds: [...props.associatedIds], excludeIds: [...props.associatedIds], // id
}); });
} }
@ -484,6 +505,7 @@
projectId: innerProject.value, projectId: innerProject.value,
current: propsRes.value.msPagination?.current, current: propsRes.value.msPagination?.current,
pageSize: propsRes.value.msPagination?.pageSize, pageSize: propsRes.value.msPagination?.pageSize,
sourceId: props.caseId,
combine: combine.value, combine: combine.value,
}); });
} }
@ -505,8 +527,11 @@
moduleIds, moduleIds,
versionId, versionId,
refId: '', refId: '',
sourceType: caseType.value,
projectId: innerProject.value, projectId: innerProject.value,
sourceId: props.caseId,
}; };
emit('save', params); emit('save', params);
} }
@ -530,6 +555,7 @@
(val) => { (val) => {
innerVisible.value = val; innerVisible.value = val;
if (val) { if (val) {
resetSelector();
searchCase(); searchCase();
initFilter(); initFilter();
} }
@ -539,8 +565,9 @@
watch( watch(
() => innerVisible.value, () => innerVisible.value,
(val) => { (val) => {
if (!val) { emit('update:visible', val);
emit('update:visible', false); if (val) {
initModules(true);
} }
} }
); );
@ -550,6 +577,7 @@
() => caseType.value, () => caseType.value,
(val) => { (val) => {
if (val) { if (val) {
emit('update:currentSelectCase', val);
initModules(true); initModules(true);
searchCase(); searchCase();
} }
@ -557,7 +585,7 @@
); );
watch( watch(
() => props.project, () => props.projectId,
(val) => { (val) => {
if (val) { if (val) {
innerProject.value = val; innerProject.value = val;
@ -569,7 +597,6 @@
() => innerProject.value, () => innerProject.value,
(val) => { (val) => {
emit('update:project', val); emit('update:project', val);
resetSelector();
initModules(true); initModules(true);
searchCase(); searchCase();
} }
@ -597,10 +624,6 @@
} }
); );
onBeforeMount(() => {
innerProject.value = appStore.currentProjectId;
});
defineExpose({ defineExpose({
initModules, initModules,
}); });

View File

@ -117,9 +117,9 @@
@update-success="updateSuccess" @update-success="updateSuccess"
/> />
<TabDemand v-else-if="activeTab === 'requirement'" :case-id="props.detailId" /> <TabDemand v-else-if="activeTab === 'requirement'" :case-id="props.detailId" />
<TabCaseTable v-else-if="activeTab === 'case'" /> <TabCaseTable v-else-if="activeTab === 'case'" :case-id="props.detailId" />
<TabDefect v-else-if="activeTab === 'bug'" /> <TabDefect v-else-if="activeTab === 'bug'" />
<TabDependency v-else-if="activeTab === 'dependency'" /> <TabDependency v-else-if="activeTab === 'dependency'" :case-id="props.detailId" />
<TabCaseReview v-else-if="activeTab === 'caseReview'" :case-id="props.detailId" /> <TabCaseReview v-else-if="activeTab === 'caseReview'" :case-id="props.detailId" />
<TabTestPlan v-else-if="activeTab === 'testPlan'" /> <TabTestPlan v-else-if="activeTab === 'testPlan'" />
<TabComment v-else-if="activeTab === 'comments'" :case-id="props.detailId" /> <TabComment v-else-if="activeTab === 'comments'" :case-id="props.detailId" />
@ -248,6 +248,7 @@
const userId = computed(() => userStore.userInfo.id); const userId = computed(() => userStore.userInfo.id);
const appStore = useAppStore(); const appStore = useAppStore();
provide('caseId', props.detailId);
const currentProjectId = computed(() => appStore.currentProjectId); const currentProjectId = computed(() => appStore.currentProjectId);

View File

@ -188,6 +188,7 @@
:page-change="propsEvent.pageChange" :page-change="propsEvent.pageChange"
:pagination="propsRes.msPagination!" :pagination="propsRes.msPagination!"
/> />
<AddDemandModal v-model:visible="showDemandModel" :case-id="caseId" :form="modelForm" />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -220,6 +221,7 @@
import CaseDetailDrawer from './caseDetailDrawer.vue'; import CaseDetailDrawer from './caseDetailDrawer.vue';
import FeatureCaseTree from './caseTree.vue'; import FeatureCaseTree from './caseTree.vue';
import ExportExcelDrawer from './exportExcelDrawer.vue'; import ExportExcelDrawer from './exportExcelDrawer.vue';
import AddDemandModal from './tabContent/tabDemand/addDemandModal.vue';
import TableFormChange from './tableFormChange.vue'; import TableFormChange from './tableFormChange.vue';
import { import {
@ -243,6 +245,7 @@
CaseManagementTable, CaseManagementTable,
CaseModuleQueryParams, CaseModuleQueryParams,
CustomAttributes, CustomAttributes,
DemandItem,
} from '@/models/caseManagement/featureCase'; } from '@/models/caseManagement/featureCase';
import type { TableQueryParams } from '@/models/common'; import type { TableQueryParams } from '@/models/common';
import { CaseManagementRouteEnum } from '@/enums/routeEnum'; import { CaseManagementRouteEnum } from '@/enums/routeEnum';
@ -924,8 +927,25 @@
}); });
} }
const showDemandModel = ref<boolean>(false);
const caseId = ref('');
const modelForm = ref<DemandItem>({
id: '',
caseId: '', // ID
demandId: '', // ID
demandName: '', //
demandUrl: '', //
demandPlatform: '', //
createTime: '',
updateTime: '',
createUser: '',
updateUser: '',
children: [], //
});
// //
function addDemand() {} function addDemand() {
showDemandModel.value = true;
}
// //
function handleAssociatedDemand() {} function handleAssociatedDemand() {}
@ -991,7 +1011,7 @@
} }
// //
const customFieldsColumns = ref<Record<string, any>[]>([]); let customFieldsColumns: Record<string, any>[] = [];
let fullColumns: MsTableColumn = []; // let fullColumns: MsTableColumn = []; //
const tableRef = ref<InstanceType<typeof MsBaseTable> | null>(null); const tableRef = ref<InstanceType<typeof MsBaseTable> | null>(null);
@ -999,7 +1019,7 @@
async function getDefaultFields() { async function getDefaultFields() {
const result = await getCaseDefaultFields(currentProjectId.value); const result = await getCaseDefaultFields(currentProjectId.value);
initDefaultFields.value = result.customFields; initDefaultFields.value = result.customFields;
customFieldsColumns.value = initDefaultFields.value.map((item: any) => { customFieldsColumns = initDefaultFields.value.map((item: any) => {
return { return {
title: item.fieldName, title: item.fieldName,
slotName: item.fieldId as string, slotName: item.fieldId as string,
@ -1012,7 +1032,7 @@
fullColumns = [ fullColumns = [
...columns.slice(0, columns.length - 1), ...columns.slice(0, columns.length - 1),
...customFieldsColumns.value, ...customFieldsColumns,
...columns.slice(columns.length - 1, columns.length), ...columns.slice(columns.length - 1, columns.length),
]; ];
tableStore.initColumn(TableKeyEnum.CASE_MANAGEMENT_TABLE, fullColumns, 'drawer'); tableStore.initColumn(TableKeyEnum.CASE_MANAGEMENT_TABLE, fullColumns, 'drawer');

View File

@ -230,8 +230,8 @@
import MsFileList from '@/components/pure/ms-upload/fileList.vue'; import MsFileList from '@/components/pure/ms-upload/fileList.vue';
import MsUpload from '@/components/pure/ms-upload/index.vue'; import MsUpload from '@/components/pure/ms-upload/index.vue';
import type { MsFileItem } from '@/components/pure/ms-upload/types'; import type { MsFileItem } from '@/components/pure/ms-upload/types';
import AddAttachment from '@/components/business/ms-add-attachment/index.vue';
import LinkFileDrawer from '@/components/business/ms-link-file/associatedFileDrawer.vue'; import LinkFileDrawer from '@/components/business/ms-link-file/associatedFileDrawer.vue';
import AddAttachment from './addAttachment.vue';
import AddStep from './addStep.vue'; import AddStep from './addStep.vue';
import TransferModal from './tabContent/transferModal.vue'; import TransferModal from './tabContent/transferModal.vue';

View File

@ -158,7 +158,7 @@
async function initModules(isSetDefaultKey = false) { async function initModules(isSetDefaultKey = false) {
try { try {
loading.value = true; loading.value = true;
const res = await getCaseModuleTree(currentProjectId.value); const res = await getCaseModuleTree({ projectId: currentProjectId.value });
caseTree.value = mapTree<ModuleTreeNode>(res, (e) => { caseTree.value = mapTree<ModuleTreeNode>(res, (e) => {
return { return {
...e, ...e,

View File

@ -96,8 +96,8 @@
], ],
}); });
const buggerTab: TabItemType[] = []; let buggerTab: TabItemType[] = [];
const testPlanTab: TabItemType[] = []; let testPlanTab: TabItemType[] = [];
const tabDefaultSettingList = ref<TabItemType[]>([ const tabDefaultSettingList = ref<TabItemType[]>([
{ {
key: 'case', key: 'case',
@ -126,6 +126,8 @@
}, },
]); ]);
async function getTabModule() { async function getTabModule() {
buggerTab = [];
testPlanTab = [];
const result = await postTabletList({ projectId: currentProjectId.value }); const result = await postTabletList({ projectId: currentProjectId.value });
const enableModuleArr = result.filter((item: any) => item.module === 'testPlan' || item.module === 'bugManagement'); const enableModuleArr = result.filter((item: any) => item.module === 'testPlan' || item.module === 'bugManagement');
enableModuleArr.forEach((item) => { enableModuleArr.forEach((item) => {

View File

@ -27,18 +27,21 @@
</ms-base-table> </ms-base-table>
<MsCaseAssociate <MsCaseAssociate
v-model:visible="innerVisible" v-model:visible="innerVisible"
v-model:project="innerProject" v-model:project-id="innerProject"
v-model:currentSelectCase="currentSelectCase" v-model:currentSelectCase="currentSelectCase"
:ok-button-disabled="associateForm.reviewers.length === 0" :ok-button-disabled="associateForm.reviewers.length === 0"
:get-modules-func="getCaseModuleTree" :get-modules-func="getPublicLinkModuleTree"
:get-table-func="getCaseList" :modules-params="modulesTreeParams"
:get-table-func="getPublicLinkCaseList"
:table-params="getTableParams"
:modules-count="modulesCount" :modules-count="modulesCount"
:module-options="caseTypeOptions" :module-options="caseTypeOptions"
:confirm-loading="confirmLoading" :confirm-loading="confirmLoading"
:case-id="props.caseId"
:associated-ids="associatedIds" :associated-ids="associatedIds"
@close="emit('close')" @close="emit('close')"
@init="getModuleCount"
@save="saveHandler" @save="saveHandler"
@init="getModuleCount"
> >
</MsCaseAssociate> </MsCaseAssociate>
</div> </div>
@ -55,16 +58,15 @@
import { getAssociatedIds } from '@/api/modules/case-management/caseReview'; import { getAssociatedIds } from '@/api/modules/case-management/caseReview';
import { import {
getCaseList, getPublicLinkCaseList,
getCaseModulesCounts, getPublicLinkCaseModulesCounts,
getCaseModuleTree, getPublicLinkModuleTree,
getRecycleListRequest, getRecycleListRequest,
} from '@/api/modules/case-management/featureCase'; } from '@/api/modules/case-management/featureCase';
import { postTabletList } from '@/api/modules/project-management/menuManagement'; import { postTabletList } from '@/api/modules/project-management/menuManagement';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import { useAppStore } from '@/store'; import { useAppStore } from '@/store';
import type { CaseModuleQueryParams } from '@/models/caseManagement/featureCase';
import type { TableQueryParams } from '@/models/common'; import type { TableQueryParams } from '@/models/common';
import { TableKeyEnum } from '@/enums/tableEnum'; import { TableKeyEnum } from '@/enums/tableEnum';
@ -74,6 +76,10 @@
const currentProjectId = computed(() => appStore.currentProjectId); const currentProjectId = computed(() => appStore.currentProjectId);
const props = defineProps<{
caseId: string; // id
}>();
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'update:visible', val: boolean): void; (e: 'update:visible', val: boolean): void;
(e: 'update:project', val: string): void; (e: 'update:project', val: string): void;
@ -152,7 +158,7 @@
}); });
const innerVisible = ref(false); const innerVisible = ref(false);
const innerProject = ref(''); const innerProject = ref(currentProjectId.value);
const associateForm = ref({ const associateForm = ref({
reviewers: [], reviewers: [],
@ -168,11 +174,30 @@
// } // }
} }
const currentSelectCase = ref<string | number | Record<string, any> | undefined>(''); const currentSelectCase = ref<string>('');
const countParams = ref<TableQueryParams>({});
const modulesTreeParams = ref<TableQueryParams>({});
const getTableParams = ref<TableQueryParams>({});
function getParams() {
switch (currentSelectCase.value) {
case 'API':
modulesTreeParams.value = { protocol: 'HTTP' };
countParams.value = { sourceId: props.caseId, protocol: 'HTTP' };
getTableParams.value = { sourceId: props.caseId, protocol: 'HTTP' };
break;
default:
break;
}
}
function handleSelect(value: string | number | Record<string, any> | undefined) { function handleSelect(value: string | number | Record<string, any> | undefined) {
currentSelectCase.value = value; currentSelectCase.value = value as string;
innerVisible.value = true; innerVisible.value = true;
getLinkedIds(); getLinkedIds();
// getParams();
} }
function cancelLink(record: any) {} function cancelLink(record: any) {}
@ -181,9 +206,9 @@
const modulesCount = ref<Record<string, any>>({}); const modulesCount = ref<Record<string, any>>({});
async function getModuleCount(params: CaseModuleQueryParams) { async function getModuleCount(params: TableQueryParams) {
try { try {
modulesCount.value = await getCaseModulesCounts(params); modulesCount.value = await getPublicLinkCaseModulesCounts(params);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }
@ -191,40 +216,44 @@
const confirmLoading = ref<boolean>(false); const confirmLoading = ref<boolean>(false);
function saveHandler(params: TableQueryParams) {} function saveHandler(params: TableQueryParams) {
console.log(params);
}
const moduleMaps: Record<string, { label: string; value: string }[]> = { const moduleMaps: Record<string, { label: string; value: string }[]> = {
apiTest: [ apiTest: [
{ {
value: 'API_CASE', value: 'API',
label: t('caseManagement.featureCase.apiCase'), label: t('caseManagement.featureCase.apiCase'),
}, },
{ {
value: 'SCENE_CASE', value: 'SCENARIO',
label: t('caseManagement.featureCase.sceneCase'), label: t('caseManagement.featureCase.sceneCase'),
}, },
], ],
uiTest: [ uiTest: [
{ {
value: 'UI_CASE', value: 'UI',
label: t('caseManagement.featureCase.uiCase'), label: t('caseManagement.featureCase.uiCase'),
}, },
], ],
loadTest: [ loadTest: [
{ {
value: 'LOAD_CASE', value: 'PERFORMANCE',
label: t('caseManagement.featureCase.propertyCase'), label: t('caseManagement.featureCase.propertyCase'),
}, },
], ],
}; };
onBeforeMount(async () => { onMounted(async () => {
const result = await postTabletList({ projectId: currentProjectId.value }); const result = await postTabletList({ projectId: currentProjectId.value });
const caseArr = result.filter((item) => Object.keys(moduleMaps).includes(item.module)); const caseArr = result.filter((item) => Object.keys(moduleMaps).includes(item.module));
caseArr.forEach((item: any) => { caseArr.forEach((item: any) => {
const currentModule = moduleMaps[item.module]; const currentModule = moduleMaps[item.module];
caseTypeOptions.value.push(...currentModule); caseTypeOptions.value.push(...currentModule);
}); });
currentSelectCase.value = caseTypeOptions.value[0].value;
getParams();
}); });
</script> </script>

View File

@ -12,14 +12,15 @@
<div :class="getFolderClass('all')" @click="setActiveFolder('all')"> <div :class="getFolderClass('all')" @click="setActiveFolder('all')">
<MsIcon type="icon-icon_folder_filled1" class="folder-icon" /> <MsIcon type="icon-icon_folder_filled1" class="folder-icon" />
<div class="folder-name">{{ t('caseManagement.featureCase.allCase') }}</div> <div class="folder-name">{{ t('caseManagement.featureCase.allCase') }}</div>
<div class="folder-count">({{ allFileCount }})</div> <div class="folder-count">({{ modulesCount['all'] }})</div>
</div> </div>
</div> </div>
<a-divider class="my-[8px]" /> <a-divider class="my-[8px]" />
<a-spin class="w-full" :loading="moduleLoading"> <a-spin class="w-full" :loading="moduleLoading">
<MsTree <MsTree
v-model:selected-keys="selectedModuleKeys" v-model:focus-node-key="focusNodeKey"
:data="folderTree" :selected-keys="selectedNodeKeys"
:data="caseTree"
:keyword="moduleKeyword" :keyword="moduleKeyword"
:empty-text="t('caseManagement.featureCase.caseEmptyRecycle')" :empty-text="t('caseManagement.featureCase.caseEmptyRecycle')"
:virtual-list-props="virtualListProps" :virtual-list-props="virtualListProps"
@ -31,11 +32,15 @@
}" }"
block-node block-node
title-tooltip-position="left" title-tooltip-position="left"
@select="folderNodeSelect" @select="caseNodeSelect"
> >
<template #title="nodeData"> <template #title="nodeData">
<div class="inline-flex w-full"> <div class="inline-flex w-full">
<div class="one-line-text w-[calc(100%-32px)] text-[var(--color-text-1)]">{{ nodeData.name }}</div> <div
class="one-line-text w-[calc(100%-32px)] text-[var(--color-text-1)]"
@click="setFocusKey(nodeData)"
>{{ nodeData.name }}</div
>
<div class="ml-[4px] text-[var(--color-text-4)]">({{ nodeData.count || 0 }})</div> <div class="ml-[4px] text-[var(--color-text-4)]">({{ nodeData.count || 0 }})</div>
</div> </div>
</template> </template>
@ -46,7 +51,7 @@
<div class="mb-[16px] flex items-center justify-between"> <div class="mb-[16px] flex items-center justify-between">
<div class="flex items-center"> <div class="flex items-center">
<div class="mr-[4px] text-[var(--color-text-1)]">{{ activeFolderName }}</div> <div class="mr-[4px] text-[var(--color-text-1)]">{{ activeFolderName }}</div>
<div class="text-[var(--color-text-4)]">({{ activeFolderName }})</div> <div class="text-[var(--color-text-4)]">({{ modulesCount[activeFolder] }})</div>
</div> </div>
<div class="flex items-center gap-[8px]"> <div class="flex items-center gap-[8px]">
<a-select <a-select
@ -72,7 +77,7 @@
</div> </div>
<ms-base-table v-bind="propsRes" no-disable v-on="propsEvent"> <ms-base-table v-bind="propsRes" no-disable v-on="propsEvent">
<template #caseLevel="{ record }"> <template #caseLevel="{ record }">
<caseLevel :case-level="record.caseLevel" /> <caseLevel :case-level="(getCaseLevel(record) as CaseLevel)" />
</template> </template>
</ms-base-table> </ms-base-table>
<div class="footer"> <div class="footer">
@ -84,7 +89,12 @@
<a-button type="secondary" :disabled="loading" class="mr-[12px]" @click="cancel">{{ <a-button type="secondary" :disabled="loading" class="mr-[12px]" @click="cancel">{{
t('common.cancel') t('common.cancel')
}}</a-button> }}</a-button>
<a-button type="primary" :loading="loading" @click="handleConfirm"> <a-button
type="primary"
:loading="loading"
:disabled="propsRes.selectedKeys.size === 0"
@click="handleConfirm"
>
{{ t('common.add') }} {{ t('common.add') }}
</a-button> </a-button>
</slot> </slot>
@ -104,29 +114,36 @@
import { MsTableColumn } from '@/components/pure/ms-table/type'; import { MsTableColumn } from '@/components/pure/ms-table/type';
import useTable from '@/components/pure/ms-table/useTable'; import useTable from '@/components/pure/ms-table/useTable';
import caseLevel from '@/components/business/ms-case-associate/caseLevel.vue'; import caseLevel from '@/components/business/ms-case-associate/caseLevel.vue';
import type { CaseLevel } from '@/components/business/ms-case-associate/types';
import MsTree from '@/components/business/ms-tree/index.vue'; import MsTree from '@/components/business/ms-tree/index.vue';
import type { MsTreeNodeData } from '@/components/business/ms-tree/types'; import type { MsTreeNodeData } from '@/components/business/ms-tree/types';
import { getModules } from '@/api/modules/project-management/fileManagement'; import {
addPrepositionRelation,
getCaseModulesCounts,
getCaseModuleTree,
getPrepositionRelation,
} from '@/api/modules/case-management/featureCase';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import useAppStore from '@/store/modules/app'; import useAppStore from '@/store/modules/app';
import { mapTree } from '@/utils'; import { mapTree } from '@/utils';
import type { CaseManagementTable, CaseModuleQueryParams } from '@/models/caseManagement/featureCase';
import type { TableQueryParams } from '@/models/common';
import { ModuleTreeNode } from '@/models/projectManagement/file'; import { ModuleTreeNode } from '@/models/projectManagement/file';
const appStore = useAppStore(); const appStore = useAppStore();
const currentProjectId = computed(() => appStore.currentProjectId);
const { t } = useI18n(); const { t } = useI18n();
const props = defineProps<{ const props = defineProps<{
visible: boolean; visible: boolean;
showType: 'preposition' | 'postPosition'; showType: 'preposition' | 'postPosition';
caseId: string;
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'update:visible', val: boolean): void; (e: 'update:visible', val: boolean): void;
(e: 'update:project', val: string): void;
(e: 'init', val: string[]): void;
(e: 'folderNodeSelect', ids: (string | number)[], springIds: string[]): void;
(e: 'success', val: string[]): void; (e: 'success', val: string[]): void;
(e: 'close'): void; (e: 'close'): void;
}>(); }>();
@ -140,13 +157,11 @@
}, },
}); });
const selectedModuleKeys = ref<string[]>([]);
const title = computed(() => { const title = computed(() => {
return props.showType === 'preposition' ? '添加前置用例' : '添加后置用例'; return props.showType === 'preposition' ? '添加前置用例' : '添加后置用例';
}); });
const folderTree = ref<ModuleTreeNode[]>([]); const caseTree = ref<ModuleTreeNode[]>([]);
const moduleLoading = ref(false); const moduleLoading = ref(false);
const moduleKeyword = ref(''); const moduleKeyword = ref('');
@ -159,20 +174,30 @@
const activeFolder = ref('all'); const activeFolder = ref('all');
const activeFolderName = ref(t('ms.case.associate.allCase')); const activeFolderName = ref(t('ms.case.associate.allCase'));
const offspringIds = ref<string[]>([]);
const modulesCount = ref<Record<string, any>>({});
//
const selectedNodeKeys = computed({
get: () => [activeFolder.value],
set: (val) => val,
});
/** /**
* 处理文件夹树节点选中事件 * 处理文件夹树节点选中事件
*/ */
function folderNodeSelect(_selectedKeys: (string | number)[], node: MsTreeNodeData) { const focusNodeKey = ref<string>('');
selectedModuleKeys.value = _selectedKeys as string[];
function caseNodeSelect(_selectedKeys: (string | number)[], node: MsTreeNodeData) {
[activeFolder.value] = _selectedKeys as string[];
activeFolder.value = node.id; activeFolder.value = node.id;
activeFolderName.value = node.name; activeFolderName.value = node.name;
const offspringIds: string[] = []; offspringIds.value = [];
mapTree(node.children || [], (e) => { mapTree(node.children || [], (e) => {
offspringIds.push(e.id); offspringIds.value.push(e.id);
return e; return e;
}); });
emit('folderNodeSelect', _selectedKeys, offspringIds); focusNodeKey.value = '';
} }
const allFileCount = ref(0); const allFileCount = ref(0);
@ -183,8 +208,6 @@
function setActiveFolder(id: string) { function setActiveFolder(id: string) {
activeFolder.value = id; activeFolder.value = id;
activeFolderName.value = t('ms.case.associate.allCase'); activeFolderName.value = t('ms.case.associate.allCase');
selectedModuleKeys.value = [];
emit('folderNodeSelect', [id], []);
} }
const keyword = ref(''); const keyword = ref('');
const version = ref(''); const version = ref('');
@ -212,7 +235,7 @@
sortable: { sortable: {
sortDirections: ['ascend', 'descend'], sortDirections: ['ascend', 'descend'],
}, },
width: 90, width: 200,
}, },
{ {
title: 'caseManagement.featureCase.tableColumnName', title: 'caseManagement.featureCase.tableColumnName',
@ -221,7 +244,7 @@
sortDirections: ['ascend', 'descend'], sortDirections: ['ascend', 'descend'],
}, },
showTooltip: true, showTooltip: true,
width: 200, width: 300,
}, },
{ {
title: 'ms.case.associate.caseLevel', title: 'ms.case.associate.caseLevel',
@ -241,85 +264,8 @@
}, },
]; ];
const { propsRes, propsEvent, loadList, setLoadListParams } = useTable( const { propsRes, propsEvent, loadList, setLoadListParams, resetSelector } = useTable(
() => getPrepositionRelation,
Promise.resolve({
list: [
{
id: 'ded3d43',
name: '测试评审1',
creator: '张三',
reviewer: '李四',
module: '模块1',
caseLevel: 0, //
caseCount: 100,
passCount: 0,
failCount: 10,
reviewCount: 20,
reviewingCount: 25,
tags: ['标签1', '标签2'],
type: 'single',
desc: 'douifd9304',
cycle: [1700200794229, 1700200994229],
},
{
id: 'g545hj4',
name: '测试评审2',
creator: '张三',
reviewer: '李四',
module: '模块1',
caseLevel: 1, //
caseCount: 105,
passCount: 50,
failCount: 10,
reviewCount: 20,
reviewingCount: 25,
tags: ['标签1', '标签2'],
type: 'single',
desc: 'douifd9304',
cycle: [1700200794229, 1700200994229],
},
{
id: 'hj65b54',
name: '测试评审3',
creator: '张三',
reviewer: '李四',
module: '模块1',
caseLevel: 2, //
caseCount: 125,
passCount: 70,
failCount: 10,
reviewCount: 20,
reviewingCount: 25,
passRate: '80%',
tags: ['标签1', '标签2'],
type: 'single',
desc: 'douifd9304',
cycle: [1700200794229, 1700200994229],
},
{
id: 'wefwefw',
name: '测试评审4',
creator: '张三',
reviewer: '李四',
module: '模块1',
caseLevel: 3, //
caseCount: 130,
passCount: 70,
failCount: 10,
reviewCount: 0,
reviewingCount: 50,
passRate: '80%',
tags: ['标签1', '标签2'],
type: 'single',
desc: 'douifd9304',
cycle: [1700200794229, 1700200994229],
},
],
current: 1,
pageSize: 10,
total: 2,
}),
{ {
columns, columns,
scroll: { scroll: {
@ -329,30 +275,30 @@
selectable: true, selectable: true,
showSelectAll: true, showSelectAll: true,
}, },
(item) => { (record) => {
return { return {
...item, ...record,
tags: item.tags?.map((e: string) => ({ id: e, name: e })) || [], tags: (JSON.parse(record.tags) || []).map((item: string, i: number) => {
return {
id: `${record.id}-${i}`,
name: item,
};
}),
}; };
} }
); );
const loading = ref(false); //
function getCaseLevel(record: CaseManagementTable) {
async function handleConfirm() { const caseLevelRes = record.customFields.find((item: any) => item.name === '用例等级');
try { if (caseLevelRes) {
loading.value = true; return JSON.parse(caseLevelRes.value).replaceAll('P', '') * 1;
Message.success(t('ms.case.associate.associateSuccess'));
innerVisible.value = false;
emit('success', Array.from(propsRes.value.selectedKeys));
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
} finally {
loading.value = false;
} }
return 0;
} }
const loading = ref(false);
function cancel() { function cancel() {
innerVisible.value = false; innerVisible.value = false;
emit('close'); emit('close');
@ -361,26 +307,24 @@
* 初始化模块树 * 初始化模块树
* @param isSetDefaultKey 是否设置第一个节点为选中节点 * @param isSetDefaultKey 是否设置第一个节点为选中节点
*/ */
const selectedKeysNode = ref<(string | number)[]>([]);
async function initModules(isSetDefaultKey = false) { async function initModules(isSetDefaultKey = false) {
try { try {
moduleLoading.value = true; moduleLoading.value = true;
const res = await getModules(appStore.currentProjectId); const res = await getCaseModuleTree({ projectId: appStore.currentProjectId });
folderTree.value = res; caseTree.value = mapTree<ModuleTreeNode>(res, (e) => {
return {
...e,
hideMoreAction: e.id === 'root',
draggable: false,
disabled: false,
count: modulesCount.value?.[e.id] || 0,
};
});
if (isSetDefaultKey) { if (isSetDefaultKey) {
selectedModuleKeys.value = [folderTree.value[0].id]; selectedKeysNode.value = [caseTree.value[0].id];
activeFolderName.value = folderTree.value[0].name;
const offspringIds: string[] = [];
mapTree(folderTree.value[0].children || [], (e) => {
offspringIds.push(e.id);
return e;
});
emit('folderNodeSelect', selectedModuleKeys.value, offspringIds);
} }
emit(
'init',
folderTree.value.map((e) => e.name)
);
} catch (error) { } catch (error) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log(error); console.log(error);
@ -388,17 +332,115 @@
moduleLoading.value = false; moduleLoading.value = false;
} }
} }
/**
* @param 获取回收站模块
*/
function searchCase() { // count
setLoadListParams({ const emitTableParams: CaseModuleQueryParams = {
version: version.value, keyword: keyword.value,
keyword: keyword.value, moduleIds: [],
}); projectId: currentProjectId.value,
loadList(); current: propsRes.value.msPagination?.current,
pageSize: propsRes.value.msPagination?.pageSize,
};
async function getModulesCount() {
try {
modulesCount.value = await getCaseModulesCounts(emitTableParams);
} catch (error) {
console.log(error);
}
} }
onBeforeMount(() => { const searchParams = ref<TableQueryParams>({
searchCase(); projectId: currentProjectId.value,
moduleIds: [],
});
//
function getLoadListParams() {
if (activeFolder.value === 'all') {
searchParams.value.moduleIds = [];
} else {
searchParams.value.moduleIds = [activeFolder.value, ...offspringIds.value];
}
setLoadListParams({
...searchParams.value,
keyword: keyword.value,
id: props.caseId,
type: props.showType === 'preposition' ? 'PRE' : 'POST',
});
}
const setFocusKey = (node: MsTreeNodeData) => {
focusNodeKey.value = node.id || '';
};
function searchCase() {
getLoadListParams();
loadList();
getModulesCount();
}
async function handleConfirm() {
loading.value = true;
try {
const { excludeKeys, selectedKeys, selectorStatus } = propsRes.value;
const { versionId, moduleIds } = searchParams.value;
const params = {
id: props.caseId,
excludeIds: [...excludeKeys],
selectIds: selectorStatus === 'all' ? [] : [...selectedKeys],
selectAll: selectorStatus === 'all',
moduleIds,
versionId,
refId: '',
type: props.showType === 'preposition' ? 'PRE' : 'POST',
projectId: currentProjectId.value,
};
await addPrepositionRelation(params);
Message.success(t('common.addSuccess'));
innerVisible.value = false;
resetSelector();
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
} finally {
loading.value = false;
}
}
watch(
() => innerVisible.value,
(val) => {
if (val) {
searchCase();
}
}
);
watch(
() => modulesCount.value,
(obj) => {
caseTree.value = mapTree<ModuleTreeNode>(caseTree.value, (node) => {
return {
...node,
count: obj?.[node.id] || 0,
};
});
}
);
watch(
() => activeFolder.value,
() => {
searchCase();
}
);
onMounted(() => {
resetSelector();
}); });
defineExpose({ defineExpose({

View File

@ -10,7 +10,7 @@
</a-button> </a-button>
</div> </div>
<div> <div>
<a-radio-group v-model:model-value="showType" type="button" class="file-show-type ml-[4px]"> <a-radio-group v-model="showType" type="button" class="file-show-type ml-[4px]">
<a-radio value="preposition" class="show-type-icon p-[2px]">{{ <a-radio value="preposition" class="show-type-icon p-[2px]">{{
t('caseManagement.featureCase.preCase') t('caseManagement.featureCase.preCase')
}}</a-radio> }}</a-radio>
@ -26,7 +26,7 @@
></a-input-search> ></a-input-search>
</div> </div>
</div> </div>
<ms-base-table v-if="showType === 'preposition'" ref="tableRef" v-bind="prePropsRes" v-on="preTableEvent"> <ms-base-table ref="tableRef" v-bind="propsRes" v-on="propsEvent">
<template #operation="{ record }"> <template #operation="{ record }">
<MsButton @click="cancelDependency(record)">{{ t('caseManagement.featureCase.cancelDependency') }}</MsButton> <MsButton @click="cancelDependency(record)">{{ t('caseManagement.featureCase.cancelDependency') }}</MsButton>
</template> </template>
@ -39,20 +39,7 @@
</div> </div>
</template> </template>
</ms-base-table> </ms-base-table>
<ms-base-table v-else v-bind="postPropsRes" v-on="postTableEvent"> <PreAndPostCaseDrawer ref="drawerRef" v-model:visible="showDrawer" :show-type="showType" :case-id="props.caseId" />
<template #operation="{ record }">
<MsButton @click="cancelDependency(record)">{{ t('caseManagement.featureCase.cancelDependency') }}</MsButton>
</template>
<template v-if="(keyword || '').trim() === ''" #empty>
<div class="flex items-center justify-center">
{{ t('caseManagement.caseReview.tableNoData') }}
<MsButton class="ml-[8px]" @click="addCase('postPosition')">
{{ t('caseManagement.featureCase.addPostCase') }}
</MsButton>
</div>
</template>
</ms-base-table>
<PreAndPostCaseDrawer ref="drawerRef" v-model:visible="showDrawer" :show-type="showType" />
</div> </div>
</template> </template>
@ -65,16 +52,21 @@
import useTable from '@/components/pure/ms-table/useTable'; import useTable from '@/components/pure/ms-table/useTable';
import PreAndPostCaseDrawer from './preAndPostCaseDrawer.vue'; import PreAndPostCaseDrawer from './preAndPostCaseDrawer.vue';
import { getRecycleListRequest } from '@/api/modules/case-management/featureCase'; import { getDependOnCase } from '@/api/modules/case-management/featureCase';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import { useAppStore } from '@/store';
import { TableKeyEnum } from '@/enums/tableEnum'; const appStore = useAppStore();
export type types = 'preposition' | 'postPosition'; export type types = 'preposition' | 'postPosition';
const currentProjectId = computed(() => appStore.currentProjectId);
const showType = ref<types>('preposition'); const showType = ref<types>('preposition');
const { t } = useI18n(); const { t } = useI18n();
const keyword = ref<string>(''); const keyword = ref<string>('');
const props = defineProps<{
caseId: string;
}>();
const columns: MsTableColumn = [ const columns: MsTableColumn = [
{ {
@ -84,7 +76,6 @@
showInTable: true, showInTable: true,
showTooltip: true, showTooltip: true,
ellipsis: true, ellipsis: true,
showDrag: false,
}, },
{ {
title: 'caseManagement.featureCase.tableColumnName', title: 'caseManagement.featureCase.tableColumnName',
@ -94,7 +85,6 @@
showTooltip: true, showTooltip: true,
width: 300, width: 300,
ellipsis: true, ellipsis: true,
showDrag: false,
}, },
{ {
title: 'caseManagement.featureCase.tableColumnVersion', title: 'caseManagement.featureCase.tableColumnVersion',
@ -104,7 +94,6 @@
showTooltip: true, showTooltip: true,
width: 300, width: 300,
ellipsis: true, ellipsis: true,
showDrag: false,
}, },
{ {
title: 'caseManagement.featureCase.tableColumnCreateUser', title: 'caseManagement.featureCase.tableColumnCreateUser',
@ -114,7 +103,6 @@
showTooltip: true, showTooltip: true,
width: 300, width: 300,
ellipsis: true, ellipsis: true,
showDrag: false,
}, },
{ {
title: 'caseManagement.featureCase.tableColumnActions', title: 'caseManagement.featureCase.tableColumnActions',
@ -123,47 +111,29 @@
fixed: 'right', fixed: 'right',
width: 140, width: 140,
showInTable: true, showInTable: true,
showDrag: false,
}, },
]; ];
const { const { propsRes, propsEvent, loadList, setLoadListParams } = useTable(getDependOnCase, {
propsRes: prePropsRes,
propsEvent: preTableEvent,
loadList: loadPreList,
setLoadListParams: setPreListParams,
} = useTable(getRecycleListRequest, {
columns, columns,
tableKey: TableKeyEnum.CASE_MANAGEMENT_TAB_DEPENDENCY_PRE_CASE,
scroll: { x: '100%' },
heightUsed: 340,
enableDrag: true,
});
const {
propsRes: postPropsRes,
propsEvent: postTableEvent,
loadList: loadPostList,
setLoadListParams: setPostListParams,
} = useTable(getRecycleListRequest, {
columns,
tableKey: TableKeyEnum.CASE_MANAGEMENT_TAB_DEPENDENCY_POST_CASE,
scroll: { x: '100%' }, scroll: { x: '100%' },
heightUsed: 340, heightUsed: 340,
selectable: false,
noDisable: true,
showSetting: false,
enableDrag: true, enableDrag: true,
}); });
// //
function cancelDependency(record: any) {} function cancelDependency(record: any) {}
function getFetch() { function getParams() {
if (showType.value === 'preposition') { setLoadListParams({
setPreListParams({ keyword: keyword.value }); projectId: currentProjectId.value,
loadPreList(); keyword: keyword.value,
} else { type: showType.value === 'preposition' ? 'PRE' : 'POST',
setPostListParams({ keyword: keyword.value }); id: props.caseId,
loadPostList(); });
}
} }
const showDrawer = ref<boolean>(false); const showDrawer = ref<boolean>(false);
@ -176,12 +146,16 @@
watch( watch(
() => showType.value, () => showType.value,
(val) => { () => {
if (val) { getParams();
getFetch(); loadList();
}
} }
); );
onBeforeMount(() => {
getParams();
loadList();
});
</script> </script>
<style scoped></style> <style scoped></style>

View File

@ -1,16 +1,18 @@
<template> <template>
<MsCaseAssociate <MsCaseAssociate
v-model:visible="innerVisible" v-model:visible="innerVisible"
v-model:project="innerProject" v-model:project-id="innerProject"
v-model:currentSelectCase="currentSelectCase" v-model:currentSelectCase="currentSelectCase"
:ok-button-disabled="associateForm.reviewers.length === 0" :ok-button-disabled="associateForm.reviewers.length === 0"
:get-modules-func="getCaseModuleTree" :get-modules-func="getCaseModuleTree"
:modules-count="modulesCount" :modules-params="modulesTreeParams"
:get-table-func="getCaseList" :get-table-func="getCaseList"
:associated-ids="associatedIds" :modules-count="modulesCount"
:confirm-loading="confirmLoading" :confirm-loading="confirmLoading"
@init="getModuleCount" :associated-ids="associatedIds"
@close="emit('close')"
@save="saveHandler" @save="saveHandler"
@init="getModuleCount"
> >
<template #footerLeft> <template #footerLeft>
<a-form ref="associateFormRef" :model="associateForm"> <a-form ref="associateFormRef" :model="associateForm">
@ -119,7 +121,7 @@
} }
); );
const innerProject = ref(''); const innerProject = ref(appStore.currentProjectId);
watch( watch(
() => props.project, () => props.project,
@ -166,8 +168,8 @@
const currentSelectCase = ref<string | number | Record<string, any> | undefined>(''); const currentSelectCase = ref<string | number | Record<string, any> | undefined>('');
const modulesCount = ref<Record<string, any>>({}); const modulesCount = ref<Record<string, any>>({});
const modulesTreeParams = ref<TableQueryParams>({});
async function getModuleCount(params: CaseModuleQueryParams) { async function getModuleCount(params: TableQueryParams) {
try { try {
modulesCount.value = await getCaseModulesCounts(params); modulesCount.value = await getCaseModulesCounts(params);
} catch (error) { } catch (error) {