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

View File

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

View File

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

View File

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