feat(测试计划): 测试计划关联用例_下&测试计划详情复制联调
This commit is contained in:
parent
7ac6abd389
commit
ab662b8f93
|
@ -497,11 +497,21 @@
|
||||||
const indeterminate = ref<boolean>(false);
|
const indeterminate = ref<boolean>(false);
|
||||||
|
|
||||||
const totalCount = computed(() => {
|
const totalCount = computed(() => {
|
||||||
if (isCheckedAll.value) {
|
return Object.keys(selectedModulesMaps.value).reduce((total, key) => {
|
||||||
return modulesCount.value.all;
|
const module = selectedModulesMaps.value[key];
|
||||||
}
|
if (key !== 'all') {
|
||||||
return Object.values(selectedModulesMaps.value).reduce((total, module) => {
|
// 未全选存在排除则要 count总-排除掉的 = 已选
|
||||||
return total + (module.selectAll ? module.count : module.selectIds.size);
|
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);
|
}, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -712,19 +722,20 @@
|
||||||
|
|
||||||
Object.entries(val).forEach(([moduleId, selectedProps]) => {
|
Object.entries(val).forEach(([moduleId, selectedProps]) => {
|
||||||
const { selectAll: selectIdsAll, selectIds, count } = selectedProps;
|
const { selectAll: selectIdsAll, selectIds, count } = selectedProps;
|
||||||
|
if (selectedProps) {
|
||||||
|
// 全选和取消全选
|
||||||
|
if (selectIdsAll) {
|
||||||
|
checkedKeysSet.add(moduleId);
|
||||||
|
} else {
|
||||||
|
checkedKeysSet.delete(moduleId);
|
||||||
|
}
|
||||||
|
|
||||||
// 全选和取消全选
|
// 半选状态
|
||||||
if (selectIdsAll) {
|
if (selectIds.size > 0 && selectIds.size < count) {
|
||||||
checkedKeysSet.add(moduleId);
|
halfCheckedKeysSet.add(moduleId);
|
||||||
} else {
|
} else {
|
||||||
checkedKeysSet.delete(moduleId);
|
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;
|
const isAllCheckedModuleProps = val.all;
|
||||||
|
|
||||||
if (isAllCheckedModuleProps) {
|
if (isAllCheckedModuleProps) {
|
||||||
const { selectAll, selectIds, count } = isAllCheckedModuleProps;
|
if (totalCount.value === isAllCheckedModuleProps.count) {
|
||||||
|
isCheckedAll.value = true;
|
||||||
|
} else {
|
||||||
|
isCheckedAll.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
isCheckedAll.value = selectAll;
|
if (totalCount.value < isAllCheckedModuleProps.count) {
|
||||||
|
|
||||||
if (selectIds.size > 0 && selectIds.size < count) {
|
|
||||||
indeterminate.value = true;
|
indeterminate.value = true;
|
||||||
} else {
|
} else {
|
||||||
indeterminate.value = false;
|
indeterminate.value = false;
|
||||||
|
|
|
@ -52,11 +52,16 @@ export default function useModuleSelections<T>(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 单选或复选时处理全选状态
|
// 重置模块参数
|
||||||
function setSelectedAll(moduleId: string) {
|
function resetModule(moduleId: string, isChecked: boolean) {
|
||||||
innerSelectedModulesMaps[moduleId].selectAll = true;
|
innerSelectedModulesMaps[moduleId].selectAll = isChecked;
|
||||||
innerSelectedModulesMaps[moduleId].selectIds = new Set([]);
|
innerSelectedModulesMaps[moduleId].selectIds = new Set([]);
|
||||||
innerSelectedModulesMaps[moduleId].excludeIds = new Set([]);
|
innerSelectedModulesMaps[moduleId].excludeIds = new Set([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 单选或复选时处理全选状态
|
||||||
|
function setSelectedAll(moduleId: string) {
|
||||||
|
resetModule(moduleId, true);
|
||||||
const selectedProp = innerSelectedModulesMaps[moduleId];
|
const selectedProp = innerSelectedModulesMaps[moduleId];
|
||||||
if (selectedProp) {
|
if (selectedProp) {
|
||||||
if (selectedProp.selectAll && !selectedProp.selectIds.size && !selectedProp.excludeIds.size) {
|
if (selectedProp.selectAll && !selectedProp.selectIds.size && !selectedProp.excludeIds.size) {
|
||||||
|
@ -85,16 +90,27 @@ export default function useModuleSelections<T>(
|
||||||
const selectedProps = innerSelectedModulesMaps[moduleId];
|
const selectedProps = innerSelectedModulesMaps[moduleId];
|
||||||
if (selectedProps) {
|
if (selectedProps) {
|
||||||
const { selectIds: selectModuleIds, count, excludeIds } = selectedProps;
|
const { selectIds: selectModuleIds, count, excludeIds } = selectedProps;
|
||||||
if (selectModuleIds.size < count) {
|
|
||||||
innerSelectedModulesMaps[moduleId].selectAll = false;
|
// 处理单个模块的选择状态
|
||||||
}
|
if (moduleId !== 'all') {
|
||||||
if (selectModuleIds.size === count) {
|
if (selectModuleIds.size < count) {
|
||||||
setSelectedAll(moduleId);
|
selectedProps.selectAll = false;
|
||||||
}
|
}
|
||||||
if (excludeIds.size === count) {
|
// 符合选择条数和总数相等,置空模块选择参数
|
||||||
innerSelectedModulesMaps[moduleId].selectAll = false;
|
if (selectModuleIds.size === count) {
|
||||||
innerSelectedModulesMaps[moduleId].selectIds = new Set([]);
|
setSelectedAll(moduleId);
|
||||||
innerSelectedModulesMaps[moduleId].excludeIds = new Set([]);
|
}
|
||||||
|
|
||||||
|
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 excludedSet = selectedProps.excludeIds;
|
||||||
const isSelectAllModule =
|
const isSelectAllModule =
|
||||||
selectedProps.selectAll && !selectedProps.selectIds.size && !selectedProps.excludeIds.size;
|
selectedProps.selectAll && !selectedProps.selectIds.size && !selectedProps.excludeIds.size;
|
||||||
|
// 初始化全选优先级最高,若全选则按照模块右侧列表全部分类追加集合
|
||||||
if (isSelectAllModule && moduleId === 'all') {
|
if (isSelectAllModule && moduleId === 'all') {
|
||||||
Object.entries(moduleSelectedMap.value).forEach(([item, allSelectIds]) => {
|
Object.entries(moduleSelectedMap.value).forEach(([item, allSelectIds]) => {
|
||||||
allSelectIds.forEach((key) => {
|
allSelectIds.forEach((key) => {
|
||||||
selectedProps.selectIds.add(key);
|
selectedProps.selectIds.add(key);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
// 只选择某模块则追加某模块的集合
|
||||||
} else if (isSelectAllModule && moduleId !== 'all') {
|
} else if (isSelectAllModule && moduleId !== 'all') {
|
||||||
moduleSelectedMap.value[moduleId].forEach((key) => {
|
moduleSelectedMap.value[moduleId].forEach((key) => {
|
||||||
selectedProps.selectIds.add(key);
|
selectedProps.selectIds.add(key);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// 在更新上边的ids集合后进行判断是选择还是取消
|
||||||
if (selectedSet.has(id)) {
|
if (selectedSet.has(id)) {
|
||||||
selectedProps.excludeIds.add(id);
|
selectedProps.excludeIds.add(id);
|
||||||
selectedProps.selectIds.delete(id);
|
selectedProps.selectIds.delete(id);
|
||||||
|
@ -134,14 +151,14 @@ export default function useModuleSelections<T>(
|
||||||
setSelectedModuleStatus(moduleId);
|
setSelectedModuleStatus(moduleId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 单独选择或取消行
|
||||||
function rowSelectChange(record: Record<string, any>) {
|
function rowSelectChange(record: Record<string, any>) {
|
||||||
const { moduleId } = record;
|
const { moduleId } = record;
|
||||||
setUnSelectNode(moduleId);
|
setUnSelectNode(moduleId);
|
||||||
updateSelectModule(moduleId, record.id);
|
updateSelectModule(moduleId, record.id);
|
||||||
updateSelectModule('all', record.id);
|
updateSelectModule('all', record.id);
|
||||||
}
|
}
|
||||||
|
// 全选当前页或者取消当前页
|
||||||
function selectAllChange(v: SelectAllEnum) {
|
function selectAllChange(v: SelectAllEnum) {
|
||||||
const { data } = propsRes;
|
const { data } = propsRes;
|
||||||
if (v === 'current') {
|
if (v === 'current') {
|
||||||
|
|
|
@ -530,7 +530,7 @@
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 复制 TODO:待联调
|
// 复制
|
||||||
const copyLoading = ref<boolean>(false);
|
const copyLoading = ref<boolean>(false);
|
||||||
async function copyHandler() {
|
async function copyHandler() {
|
||||||
copyLoading.value = true;
|
copyLoading.value = true;
|
||||||
|
@ -539,9 +539,8 @@
|
||||||
Message.success(t('common.copySuccess'));
|
Message.success(t('common.copySuccess'));
|
||||||
router.push({
|
router.push({
|
||||||
name: TestPlanRouteEnum.TEST_PLAN_INDEX_DETAIL,
|
name: TestPlanRouteEnum.TEST_PLAN_INDEX_DETAIL,
|
||||||
// TODO 后台需要补id
|
|
||||||
query: {
|
query: {
|
||||||
id: res.id,
|
id: res.operationId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
initDetail();
|
initDetail();
|
||||||
|
|
Loading…
Reference in New Issue