feat(测试计划): 测试计划关联用例_下&测试计划详情复制联调
This commit is contained in:
parent
7ac6abd389
commit
ab662b8f93
|
@ -497,11 +497,21 @@
|
|||
const indeterminate = ref<boolean>(false);
|
||||
|
||||
const totalCount = computed(() => {
|
||||
if (isCheckedAll.value) {
|
||||
return modulesCount.value.all;
|
||||
}
|
||||
return Object.values(selectedModulesMaps.value).reduce((total, module) => {
|
||||
return total + (module.selectAll ? module.count : module.selectIds.size);
|
||||
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 total;
|
||||
}, 0);
|
||||
});
|
||||
|
||||
|
@ -712,19 +722,20 @@
|
|||
|
||||
Object.entries(val).forEach(([moduleId, selectedProps]) => {
|
||||
const { selectAll: selectIdsAll, selectIds, count } = selectedProps;
|
||||
if (selectedProps) {
|
||||
// 全选和取消全选
|
||||
if (selectIdsAll) {
|
||||
checkedKeysSet.add(moduleId);
|
||||
} else {
|
||||
checkedKeysSet.delete(moduleId);
|
||||
}
|
||||
|
||||
// 全选和取消全选
|
||||
if (selectIdsAll) {
|
||||
checkedKeysSet.add(moduleId);
|
||||
} else {
|
||||
checkedKeysSet.delete(moduleId);
|
||||
}
|
||||
|
||||
// 半选状态
|
||||
if (selectIds.size > 0 && selectIds.size < count) {
|
||||
halfCheckedKeysSet.add(moduleId);
|
||||
} else {
|
||||
halfCheckedKeysSet.delete(moduleId);
|
||||
// 半选状态
|
||||
if (selectIds.size > 0 && selectIds.size < count) {
|
||||
halfCheckedKeysSet.add(moduleId);
|
||||
} else {
|
||||
halfCheckedKeysSet.delete(moduleId);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -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 (selectModuleIds.size < count) {
|
||||
innerSelectedModulesMaps[moduleId].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([]);
|
||||
|
||||
// 处理单个模块的选择状态
|
||||
if (moduleId !== 'all') {
|
||||
if (selectModuleIds.size < count) {
|
||||
selectedProps.selectAll = false;
|
||||
}
|
||||
// 符合选择条数和总数相等,置空模块选择参数
|
||||
if (selectModuleIds.size === count) {
|
||||
setSelectedAll(moduleId);
|
||||
}
|
||||
|
||||
if (excludeIds.size === count) {
|
||||
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') {
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue