feat(测试计划): 测试计划关联用例_下&测试计划详情复制联调

This commit is contained in:
xinxin.wu 2024-07-11 15:39:10 +08:00 committed by 刘瑞斌
parent 7ac6abd389
commit ab662b8f93
3 changed files with 70 additions and 41 deletions

View File

@ -497,11 +497,21 @@
const indeterminate = ref<boolean>(false);
const totalCount = computed(() => {
if (isCheckedAll.value) {
return modulesCount.value.all;
return Object.keys(selectedModulesMaps.value).reduce((total, key) => {
const module = selectedModulesMaps.value[key];
if (key !== 'all') {
// count- =
if (module.excludeIds.size && !module.selectAll) {
total += module.count - module.excludeIds.size;
// +count
} else if (module.selectAll && !module.excludeIds.size) {
total += module.count;
// + id
} else if (!module.selectAll && module.selectIds.size) {
total += module.selectIds.size;
}
return Object.values(selectedModulesMaps.value).reduce((total, module) => {
return total + (module.selectAll ? module.count : module.selectIds.size);
}
return total;
}, 0);
});
@ -712,7 +722,7 @@
Object.entries(val).forEach(([moduleId, selectedProps]) => {
const { selectAll: selectIdsAll, selectIds, count } = selectedProps;
if (selectedProps) {
//
if (selectIdsAll) {
checkedKeysSet.add(moduleId);
@ -726,6 +736,7 @@
} else {
halfCheckedKeysSet.delete(moduleId);
}
}
});
// checkedKeys halfCheckedKeys
@ -736,11 +747,13 @@
const isAllCheckedModuleProps = val.all;
if (isAllCheckedModuleProps) {
const { selectAll, selectIds, count } = isAllCheckedModuleProps;
if (totalCount.value === isAllCheckedModuleProps.count) {
isCheckedAll.value = true;
} else {
isCheckedAll.value = false;
}
isCheckedAll.value = selectAll;
if (selectIds.size > 0 && selectIds.size < count) {
if (totalCount.value < isAllCheckedModuleProps.count) {
indeterminate.value = true;
} else {
indeterminate.value = false;

View File

@ -52,11 +52,16 @@ export default function useModuleSelections<T>(
});
}
// 单选或复选时处理全选状态
function setSelectedAll(moduleId: string) {
innerSelectedModulesMaps[moduleId].selectAll = true;
// 重置模块参数
function resetModule(moduleId: string, isChecked: boolean) {
innerSelectedModulesMaps[moduleId].selectAll = isChecked;
innerSelectedModulesMaps[moduleId].selectIds = new Set([]);
innerSelectedModulesMaps[moduleId].excludeIds = new Set([]);
}
// 单选或复选时处理全选状态
function setSelectedAll(moduleId: string) {
resetModule(moduleId, true);
const selectedProp = innerSelectedModulesMaps[moduleId];
if (selectedProp) {
if (selectedProp.selectAll && !selectedProp.selectIds.size && !selectedProp.excludeIds.size) {
@ -85,16 +90,27 @@ export default function useModuleSelections<T>(
const selectedProps = innerSelectedModulesMaps[moduleId];
if (selectedProps) {
const { selectIds: selectModuleIds, count, excludeIds } = selectedProps;
// 处理单个模块的选择状态
if (moduleId !== 'all') {
if (selectModuleIds.size < count) {
innerSelectedModulesMaps[moduleId].selectAll = false;
selectedProps.selectAll = false;
}
// 符合选择条数和总数相等,置空模块选择参数
if (selectModuleIds.size === count) {
setSelectedAll(moduleId);
}
if (excludeIds.size === count) {
innerSelectedModulesMaps[moduleId].selectAll = false;
innerSelectedModulesMaps[moduleId].selectIds = new Set([]);
innerSelectedModulesMaps[moduleId].excludeIds = new Set([]);
resetModule(moduleId, false);
}
} else if (moduleId === 'all') {
// 处理全选选择状态
if (excludeIds.size) {
selectedProps.selectAll = false;
} else {
resetModule(moduleId, true);
}
}
}
}
@ -107,19 +123,20 @@ export default function useModuleSelections<T>(
const excludedSet = selectedProps.excludeIds;
const isSelectAllModule =
selectedProps.selectAll && !selectedProps.selectIds.size && !selectedProps.excludeIds.size;
// 初始化全选优先级最高,若全选则按照模块右侧列表全部分类追加集合
if (isSelectAllModule && moduleId === 'all') {
Object.entries(moduleSelectedMap.value).forEach(([item, allSelectIds]) => {
allSelectIds.forEach((key) => {
selectedProps.selectIds.add(key);
});
});
// 只选择某模块则追加某模块的集合
} else if (isSelectAllModule && moduleId !== 'all') {
moduleSelectedMap.value[moduleId].forEach((key) => {
selectedProps.selectIds.add(key);
});
}
// 在更新上边的ids集合后进行判断是选择还是取消
if (selectedSet.has(id)) {
selectedProps.excludeIds.add(id);
selectedProps.selectIds.delete(id);
@ -134,14 +151,14 @@ export default function useModuleSelections<T>(
setSelectedModuleStatus(moduleId);
}
}
// 单独选择或取消行
function rowSelectChange(record: Record<string, any>) {
const { moduleId } = record;
setUnSelectNode(moduleId);
updateSelectModule(moduleId, record.id);
updateSelectModule('all', record.id);
}
// 全选当前页或者取消当前页
function selectAllChange(v: SelectAllEnum) {
const { data } = propsRes;
if (v === 'current') {

View File

@ -530,7 +530,7 @@
done();
}
// TODO:
//
const copyLoading = ref<boolean>(false);
async function copyHandler() {
copyLoading.value = true;
@ -539,9 +539,8 @@
Message.success(t('common.copySuccess'));
router.push({
name: TestPlanRouteEnum.TEST_PLAN_INDEX_DETAIL,
// TODO id
query: {
id: res.id,
id: res.operationId,
},
});
initDetail();