feat(测试用例): 功能用例批量关联需求优化

This commit is contained in:
xinxin.wu 2024-09-10 12:48:16 +08:00 committed by Craftsman
parent 5843371237
commit c0e7d517db
6 changed files with 100 additions and 301 deletions

View File

@ -452,7 +452,6 @@
});
function updateHandler() {
showDrawerVisible.value = false;
router.push({
name: RouteEnum.BUG_MANAGEMENT_DETAIL,
query: {

View File

@ -809,6 +809,10 @@
}
});
onDeactivated(() => {
detailVisible.value = false;
});
onBeforeUnmount(() => {
detailVisible.value = false;
});

View File

@ -375,7 +375,12 @@
import { MsExportDrawerMap, MsExportDrawerOption } from '@/components/pure/ms-export-drawer/types';
import MsIcon from '@/components/pure/ms-icon-font/index.vue';
import MsBaseTable from '@/components/pure/ms-table/base-table.vue';
import type { BatchActionParams, BatchActionQueryParams, MsTableColumn } from '@/components/pure/ms-table/type';
import type {
BatchActionConfig,
BatchActionParams,
BatchActionQueryParams,
MsTableColumn,
} from '@/components/pure/ms-table/type';
import { MsTableProps } from '@/components/pure/ms-table/type';
import useTable from '@/components/pure/ms-table/useTable';
import MsTableMoreAction from '@/components/pure/ms-table-more-action/index.vue';
@ -707,7 +712,40 @@
];
const platformInfo = ref<Record<string, any>>({});
const tableBatchActions = {
const batchMoreActions = computed<BatchActionParams[]>(() => {
const addDemandAction = [
{
label: 'caseManagement.featureCase.addDemand',
eventTag: 'addDemand',
permission: ['FUNCTIONAL_CASE:READ+UPDATE'],
},
];
const linkDemandAction = [
{
label: 'caseManagement.featureCase.associatedDemand',
eventTag: 'associatedDemand',
permission: ['FUNCTIONAL_CASE:READ+UPDATE'],
},
];
const deleteMoreAction = [
{
isDivider: true,
},
{
label: 'common.delete',
eventTag: 'delete',
permission: ['FUNCTIONAL_CASE:READ+DELETE'],
danger: true,
},
];
if (!Object.keys(platformInfo.value).length) {
return [...addDemandAction, ...deleteMoreAction];
}
return [...addDemandAction, ...linkDemandAction, ...deleteMoreAction];
});
const tableBatchActions: BatchActionConfig = {
baseAction: [
{
label: 'caseManagement.featureCase.export',
@ -740,35 +778,7 @@
permission: ['FUNCTIONAL_CASE:READ+ADD'],
},
],
moreAction: [
{
label: 'caseManagement.featureCase.addDemand',
eventTag: 'addDemand',
permission: ['FUNCTIONAL_CASE:READ+UPDATE'],
},
{
label: 'caseManagement.featureCase.associatedDemand',
eventTag: 'associatedDemand',
permission: ['FUNCTIONAL_CASE:READ+UPDATE'],
},
// {
// label: 'caseManagement.featureCase.generatingDependencies',
// eventTag: 'generatingDependencies',
// },
// {
// label: 'caseManagement.featureCase.addToPublic',
// eventTag: 'addToPublic',
// },
{
isDivider: true,
},
{
label: 'common.delete',
eventTag: 'delete',
permission: ['FUNCTIONAL_CASE:READ+DELETE'],
danger: true,
},
],
moreAction: [],
};
const filterConfigList = computed<FilterFormItem[]>(() => [
@ -1776,12 +1786,7 @@
if (result && result.platform_key) {
platformInfo.value = { ...result };
}
if (Object.keys(result).length === 0) {
tableBatchActions.moreAction = [
...tableBatchActions.moreAction.slice(0, 1),
...tableBatchActions.moreAction.slice(-2),
];
}
tableBatchActions.moreAction = batchMoreActions.value;
} catch (error) {
console.log(error);
}

View File

@ -40,7 +40,7 @@
@cancel="cancelLink"
@open="openDemandUrl"
@associate="linkDemandDrawer = true"
></AssociatedDemandTable>
/>
<AddDemandModal
ref="demandModalRef"
v-model:visible="showAddModel"
@ -50,54 +50,13 @@
@save="saveHandler"
@success="searchList()"
/>
<MsDrawer
<ThirdDemandDrawer
v-model:visible="linkDemandDrawer"
:ok-disabled="tableSelected.length < 1"
:mask="false"
:title="t('caseManagement.featureCase.associatedDemand')"
:ok-text="t('caseManagement.featureCase.associated')"
:ok-loading="drawerLoading"
:width="960"
unmount-on-close
:show-continue="false"
@confirm="handleDrawerConfirm"
@cancel="handleDrawerCancel"
>
<div class="flex items-center justify-between">
<div>
<span class="font-medium">{{ platName }}</span>
<span class="ml-1 text-[var(--color-text-4)]">({{ propsRes?.msPagination?.total || 0 }})</span>
</div>
<a-input-search
v-model="platformKeyword"
:max-length="255"
:placeholder="t('caseManagement.featureCase.searchByIdAndName')"
allow-clear
class="mx-[8px] w-[240px]"
@search="searchHandler"
@press-enter="searchHandler"
@clear="searchHandler"
></a-input-search>
</div>
<ms-base-table ref="tableRef" v-bind="propsRes" v-on="propsEvent">
<template #demandId="{ record }">
<a-tooltip :content="record.demandId" :mouse-enter-delay="300">
<div class="one-line-text max-w-[300px]">
{{ record.demandId }}
</div>
</a-tooltip>
</template>
<template #demandName="{ record }">
<span class="ml-1 text-[rgb(var(--primary-5))]">
{{ record.demandName }}
<span v-if="(record.children || []).length"> ({{ (record.children || []).length || 0 }}) </span>
</span>
</template>
<template v-for="item in customFields" :key="item.slotName" #[item.dataIndex]="{ record }">
<span> {{ getSlotName(record, item) }} </span>
</template>
</ms-base-table>
</MsDrawer>
:case-id="caseId"
:drawer-loading="drawerLoading"
:platform-info="platformInfo"
@save="handleDrawerConfirm"
/>
</div>
</template>
@ -106,17 +65,13 @@
import { Message } from '@arco-design/web-vue';
import { debounce } from 'lodash-es';
import MsDrawer from '@/components/pure/ms-drawer/index.vue';
import MsBaseTable from '@/components/pure/ms-table/base-table.vue';
import type { MsTableColumn, MsTableColumnData } from '@/components/pure/ms-table/type';
import useTable from '@/components/pure/ms-table/useTable';
import AddDemandModal from './addDemandModal.vue';
import AssociatedDemandTable from './associatedDemandTable.vue';
import ThirdDemandDrawer from './thirdDemandDrawer.vue';
import {
addDemandRequest,
cancelAssociationDemand,
getThirdDemandList,
updateDemandReq,
} from '@/api/modules/case-management/featureCase';
import { getCaseRelatedInfo } from '@/api/modules/project-management/menuManagement';
@ -124,9 +79,6 @@
import { useAppStore } from '@/store';
import type { CreateOrUpdateDemand, DemandItem } from '@/models/caseManagement/featureCase';
import { TableKeyEnum } from '@/enums/tableEnum';
import { getPlatName } from '@/views/case-management/caseManagementFeature/components/utils';
const { t } = useI18n();
const appStore = useAppStore();
@ -170,137 +122,14 @@
modelForm.value = { ...record };
}
const columns: MsTableColumn = [
{
title: 'caseManagement.featureCase.tableColumnID',
slotName: 'demandId',
dataIndex: 'demandId',
width: 200,
showTooltip: true,
},
{
title: 'caseManagement.featureCase.demandName',
slotName: 'demandName',
dataIndex: 'demandName',
width: 300,
showTooltip: true,
},
// {
// title: 'caseManagement.featureCase.platformDemandState',
// width: 300,
// dataIndex: 'status',
// showTooltip: true,
// ellipsis: true,
// },
// {
// title: 'caseManagement.featureCase.platformDemandHandler',
// width: 300,
// dataIndex: 'handler',
// showTooltip: true,
// ellipsis: true,
// },
];
let fullColumns: MsTableColumn = [...columns];
const { propsRes, propsEvent, loadList, setLoadListParams, resetSelector } = useTable(getThirdDemandList, {
tableKey: TableKeyEnum.CASE_MANAGEMENT_TAB_DEMAND_PLATFORM,
columns: fullColumns,
rowKey: 'demandId',
scroll: { x: '100%' },
heightUsed: 290,
selectable: true,
showSelectorAll: false,
showSetting: false,
rowSelectionDisabledConfig: {
checkStrictly: false,
disabledKey: 'disabled',
},
});
const drawerLoading = ref<boolean>(false);
const tableSelected = computed(() => {
const selectedIds = [...propsRes.value.selectedKeys];
const filteredData: DemandItem[] = [];
function filterData(data: DemandItem[]) {
for (let i = 0; i < data.length; i++) {
const item: DemandItem = data[i];
if (selectedIds.includes(item.demandId)) {
filteredData.push(item);
}
if (item.children) {
filterData(item.children);
}
}
}
filterData(propsRes.value.data);
return filteredData;
});
const platformKeyword = ref<string>('');
const tableRef = ref();
const initData = async () => {
tableRef.value?.initColumn(fullColumns);
setLoadListParams({ keyword: platformKeyword.value, projectId: currentProjectId.value, caseId: props.caseId });
loadList();
};
const customFields = ref<any[]>([]);
async function initColumn() {
fullColumns = [...columns];
try {
const res = await getThirdDemandList({
current: 1,
pageSize: 10,
projectId: currentProjectId.value,
caseId: props.caseId,
});
customFields.value = (res.data.customHeaders || []).map((item: any) => {
return {
title: item.name,
slotName: item.id,
dataIndex: item.id,
width: 200,
options: item.options,
};
}) as any;
fullColumns = [...columns, ...customFields.value];
} catch (error) {
console.log(error);
}
}
//
const linkDemandDrawer = ref<boolean>(false);
function associatedDemand() {
initColumn();
linkDemandDrawer.value = true;
}
const searchHandler = () => {
if (linkDemandDrawer.value) {
initData();
resetSelector();
}
};
function getSlotName(record: any, item: MsTableColumnData) {
if (item?.options) {
const currentRecord = {
...record,
...record.customFields,
};
const currentValue = currentRecord[item.dataIndex as string];
const currentOptions = (JSON.parse(item.options) || []).find((it: any) => it.value === currentValue);
if (currentOptions) {
return currentOptions.text;
}
}
return record.customFields[item.dataIndex as string] || '-';
}
function openDemandUrl(record: DemandItem) {
if (record.demandUrl) {
window.open(record.demandUrl);
@ -308,44 +137,30 @@
}
const platformInfo = ref<Record<string, any>>({});
async function handleDrawerConfirm() {
const demandList = tableSelected.value.map((item) => {
return {
demandId: item.demandId,
parent: item.parent,
demandName: item.demandName,
demandUrl: item.demandUrl,
};
});
const params = {
id: JSON.parse(platformInfo.value.demand_platform_config).zentaoId,
caseId: props.caseId,
demandPlatform: platformInfo.value.platform_key,
demandList: propsRes.value.selectorStatus === 'all' ? [] : demandList,
functionalDemandBatchRequest: {
keyword: platformKeyword.value,
excludeIds: [...propsRes.value.excludeKeys],
selectAll: propsRes.value.selectorStatus === 'all',
},
};
async function handleDrawerConfirm(associatedParams: CreateOrUpdateDemand) {
try {
drawerLoading.value = true;
const { demandPlatform, demandList, functionalDemandBatchRequest } = associatedParams;
const params = {
id: JSON.parse(platformInfo.value.demand_platform_config).zentaoId,
caseId: props.caseId,
demandPlatform,
demandList,
functionalDemandBatchRequest,
};
await addDemandRequest(params);
Message.success(t('caseManagement.featureCase.associatedSuccess'));
linkDemandDrawer.value = false;
demandRef.value.initData();
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
} finally {
drawerLoading.value = false;
}
}
function handleDrawerCancel() {
linkDemandDrawer.value = false;
platformKeyword.value = '';
}
//
async function cancelLink(record: DemandItem) {
try {
@ -353,6 +168,7 @@
Message.success(t('caseManagement.featureCase.cancelLinkSuccess'));
demandRef.value.initData();
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
}
}
@ -365,26 +181,11 @@
caseEnable.value = platformInfo.value.case_enable !== 'false';
}
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
}
}
watch(
() => linkDemandDrawer.value,
(val) => {
if (val) {
resetSelector();
nextTick(async () => {
await tableRef.value?.initColumn(fullColumns);
initData();
});
}
},
{
immediate: true,
}
);
const confirmLoading = ref<boolean>(false);
const demandModalRef = ref();
@ -404,6 +205,7 @@
demandModalRef.value.resetForm();
demandRef.value.initData();
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
} finally {
confirmLoading.value = false;
@ -418,19 +220,6 @@
onMounted(async () => {
initPlatform();
});
const platName = computed(() => {
return getPlatName(platformInfo.value.platform_key);
});
</script>
<style scoped lang="less">
:deep(.arco-table-cell-align-left) > span:first-child {
padding-left: 0 !important;
}
:deep(.arco-table-cell-align-left) {
.arco-table-cell-inline-icon + .arco-table-td-content {
padding-right: 19px !important;
}
}
</style>
<style scoped lang="less"></style>

View File

@ -13,10 +13,10 @@
@cancel="handleDrawerCancel"
>
<div class="flex items-center justify-between">
<div
><span class="font-medium">{{ platName }}</span
><span class="ml-1 text-[var(--color-text-4)]">({{ propsRes?.msPagination?.total || 0 }})</span></div
>
<div>
<span class="font-medium">{{ platName }}</span>
<span class="ml-1 text-[var(--color-text-4)]">({{ propsRes?.msPagination?.total || 0 }})</span>
</div>
<a-input-search
v-model="platformKeyword"
:max-length="255"
@ -26,7 +26,7 @@
@search="searchHandler"
@press-enter="searchHandler"
@clear="searchHandler"
></a-input-search>
/>
</div>
<ms-base-table ref="tableRef" v-bind="propsRes" v-on="propsEvent">
<template #demandName="{ record }">
@ -65,7 +65,7 @@
const currentProjectId = computed(() => appStore.currentProjectId);
const props = defineProps<{
visible: boolean;
caseId: string;
caseId?: string; // id
drawerLoading: boolean;
platformInfo: Record<string, any>;
}>();
@ -93,6 +93,7 @@
width: 300,
showTooltip: true,
},
// TODO
// {
// title: 'caseManagement.featureCase.platformDemandState',
// width: 300,
@ -118,7 +119,13 @@
rowKey: 'demandId',
scroll: { x: '100%' },
selectable: true,
heightUsed: 290,
showSetting: false,
showSelectorAll: !props.caseId,
rowSelectionDisabledConfig: {
checkStrictly: false,
disabledKey: props.caseId ? 'disabled' : '',
},
});
const tableSelected = computed(() => {
@ -188,7 +195,7 @@
}
const initData = async () => {
setLoadListParams({ keyword: platformKeyword.value, projectId: currentProjectId.value });
setLoadListParams({ keyword: platformKeyword.value, projectId: currentProjectId.value, caseId: props.caseId });
loadList();
};
@ -220,31 +227,17 @@
fullColumns = [...columns, ...customFields.value];
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
}
}
// watch(
// () => props.platformInfo.demand_platform_config,
// (val) => {
// if (val) {
// console.log(val);
// initColumn();
// }
// }
// );
// watchEffect(() => {
// if (props.platformInfo.demand_platform_config) {
// }
// });
watch(
() => innerLinkDemandVisible.value,
async (val) => {
if (val) {
resetSelector();
platformKeyword.value = '';
if (props.platformInfo.demand_platform_config) {
nextTick(() => {
tableRef.value?.initColumn(fullColumns);
@ -256,4 +249,13 @@
);
</script>
<style scoped></style>
<style scoped lang="less">
:deep(.arco-table-cell-align-left) > span:first-child {
padding-left: 0 !important;
}
:deep(.arco-table-cell-align-left) {
.arco-table-cell-inline-icon + .arco-table-td-content {
padding-right: 18px !important;
}
}
</style>

View File

@ -173,6 +173,7 @@
import { defaultDetailCount, testPlanDefaultDetail } from '@/config/testPlan';
import { useI18n } from '@/hooks/useI18n';
import useModal from '@/hooks/useModal';
import useOpenNewPage from '@/hooks/useOpenNewPage';
import useAppStore from '@/store/modules/app';
import useCacheStore from '@/store/modules/cache/cache';
import useMinderStore from '@/store/modules/components/minder-editor';
@ -194,6 +195,8 @@
const appStore = useAppStore();
const { openModal } = useModal();
const { t } = useI18n();
const { openNewPage } = useOpenNewPage();
const route = useRoute();
const router = useRouter();
const minderStore = useMinderStore();
@ -417,12 +420,9 @@
testPlanId: detail.value.id as string,
triggerMode: 'MANUAL',
});
router.push({
name: TestPlanRouteEnum.TEST_PLAN_REPORT_DETAIL,
query: {
id: reportId,
type: testPlanTypeEnum.TEST_PLAN,
},
openNewPage(TestPlanRouteEnum.TEST_PLAN_REPORT_DETAIL, {
id: reportId,
type: testPlanTypeEnum.TEST_PLAN,
});
Message.success(t('testPlan.testPlanDetail.successfullyGenerated'));
} catch (error) {