fix(测试用例): 修复功能用例关联文件跨页选择问题&文案bug

This commit is contained in:
xinxin.wu 2024-07-22 18:55:05 +08:00 committed by Craftsman
parent 9df8359874
commit c344bc03a0
4 changed files with 60 additions and 20 deletions

View File

@ -38,6 +38,8 @@
}"
no-disable
v-on="propsEvent"
@row-select-change="rowSelectChange"
@select-all-change="selectAllChange"
>
<template #name="{ record }">
<MsTag
@ -90,7 +92,7 @@
import type { CommonList, ModuleTreeNode, TableQueryParams } from '@/models/common';
import type { FileListQueryParams } from '@/models/projectManagement/file';
import { Repository } from '@/models/projectManagement/file';
import { TableKeyEnum } from '@/enums/tableEnum';
import { SelectAllEnum, TableKeyEnum } from '@/enums/tableEnum';
const { t } = useI18n();
@ -100,7 +102,7 @@
offspringIds: string[]; // id
modulesCount: Record<string, any>; //
folderTree: ModuleTreeNode[];
selectFile: AssociatedList[]; //
// selectFile: AssociatedList[]; //
getListRequest: (params: TableQueryParams) => Promise<CommonList<AssociatedList>>;
showType: 'Module' | 'Storage'; //
storageList: Repository[]; //
@ -111,7 +113,7 @@
}>();
const emit = defineEmits<{
(e: 'init', params: FileListQueryParams): void;
(e: 'update:selectFile', val: AssociatedList[]): void;
// (e: 'update:selectFile', val: AssociatedList[]): void;
(e: 'updateFileIds', val: string[]): void;
}>();
@ -125,6 +127,9 @@
const combine = ref<Record<string, any>>({});
const isMyOrAllFolder = computed(() => ['my', 'all'].includes(props.activeFolder)); // /
const innerSelectFile = defineModel<AssociatedList[]>('selectFile', {
required: true,
});
const columns: MsTableColumn = [
{
title: 'project.fileManagement.name',
@ -337,32 +342,67 @@
};
});
const selectedIds = computed(() => {
const selectedFileIds = computed(() => {
return [...propsRes.value.selectedKeys];
});
watch(
() => selectedIds.value,
() => selectedFileIds.value,
(val) => {
emit(
'update:selectFile',
propsRes.value.data.filter((item: any) => selectedIds.value.indexOf(item.id) > -1)
);
emit('updateFileIds', val);
const newValue = [...val];
if (!newValue.length) {
innerSelectFile.value = [];
}
},
{
deep: true,
}
);
const selectedIds = computed(() => {
return innerSelectFile.value.map((file) => file.id);
});
const selectedKey = ref('');
watch(
() => selectedKey.value,
(key) => {
emit(
'update:selectFile',
propsRes.value.data.filter((item: any) => key === item.id)
);
innerSelectFile.value = propsRes.value.data.filter((item: any) => key === item.id);
}
);
//
function updateInnerSelectFile(record: Record<string, any>, shouldAdd: boolean) {
const index = innerSelectFile.value.findIndex((e) => e.id === record.id);
// ididpush
if (shouldAdd) {
if (index === -1) {
innerSelectFile.value.push(record as AssociatedList);
}
//
} else if (index !== -1) {
innerSelectFile.value.splice(index, 1);
}
emit('updateFileIds', selectedIds.value);
}
//
function rowSelectChange(record: Record<string, any>) {
updateInnerSelectFile(record, propsRes.value.selectedKeys.has(record.id));
}
//
function selectAllChange(v: SelectAllEnum) {
propsRes.value.data.forEach((record: Record<string, any>) => {
if (v === 'current') {
updateInnerSelectFile(record, true);
} else {
updateInnerSelectFile(record, false);
}
});
}
defineExpose({
resetSelector,
});

View File

@ -904,9 +904,9 @@
return {
moduleIds,
projectId: currentProjectId.value,
excludeIds: batchParams.value.excludeIds,
excludeIds: batchParams.value.excludeIds || [],
selectAll: batchParams.value.selectAll,
selectIds: batchParams.value.selectedIds as string[],
selectIds: batchParams.value.selectedIds || [],
keyword: keyword.value,
combine: batchParams.value.condition,
};
@ -1058,9 +1058,8 @@
Message.success(t('caseManagement.featureCase.batchCopySuccess'));
}
isMove.value = false;
emitTableParams();
resetSelector();
loadList();
initData();
} catch (error) {
console.log(error);
} finally {

View File

@ -394,7 +394,8 @@
node.count = obj?.[node.id] || 0;
node.hideMoreAction = node.id === 'root' || props.isModal;
});
}
},
{ deep: true }
);
onBeforeMount(() => {

View File

@ -20,7 +20,7 @@
<a-input-search
v-model="platformKeyword"
:max-length="255"
:placeholder="t('project.member.searchMember')"
:placeholder="t('caseManagement.featureCase.searchByIdAndName')"
allow-clear
class="mx-[8px] w-[240px]"
@search="searchHandler"