fix(测试计划): 修复关联用例入参和补充调整部分逻辑
This commit is contained in:
parent
a283dec6a2
commit
0b3213f387
|
@ -7,6 +7,7 @@
|
||||||
baseAction: [],
|
baseAction: [],
|
||||||
moreAction: [],
|
moreAction: [],
|
||||||
}"
|
}"
|
||||||
|
always-show-selected-count
|
||||||
v-on="propsEvent"
|
v-on="propsEvent"
|
||||||
@row-select-change="rowSelectChange"
|
@row-select-change="rowSelectChange"
|
||||||
@select-all-change="selectAllChange"
|
@select-all-change="selectAllChange"
|
||||||
|
@ -344,25 +345,44 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const { rowSelectChange, selectAllChange, clearSelector, setModuleInfo } = useModuleSelection(
|
const tableSelectedProps = ref({
|
||||||
|
modulesTree: props.moduleTree,
|
||||||
|
moduleCount: props.modulesCount,
|
||||||
|
});
|
||||||
|
const { rowSelectChange, selectAllChange, clearSelector } = useModuleSelection(
|
||||||
innerSelectedModulesMaps.value,
|
innerSelectedModulesMaps.value,
|
||||||
propsRes.value
|
propsRes.value,
|
||||||
|
tableSelectedProps.value
|
||||||
);
|
);
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
loadCaseList();
|
|
||||||
});
|
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
[() => props.moduleTree, () => props.modulesCount],
|
() => props.moduleTree,
|
||||||
(val) => {
|
(val) => {
|
||||||
setModuleInfo(val);
|
if (val) {
|
||||||
|
tableSelectedProps.value.modulesTree = val;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true,
|
immediate: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.modulesCount,
|
||||||
|
(val) => {
|
||||||
|
if (val) {
|
||||||
|
tableSelectedProps.value.moduleCount = val;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loadCaseList();
|
||||||
|
});
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
getApiCaseSaveParams,
|
getApiCaseSaveParams,
|
||||||
loadCaseList,
|
loadCaseList,
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
baseAction: [],
|
baseAction: [],
|
||||||
moreAction: [],
|
moreAction: [],
|
||||||
}"
|
}"
|
||||||
|
always-show-selected-count
|
||||||
v-on="propsEvent"
|
v-on="propsEvent"
|
||||||
@filter-change="getModuleCount"
|
@filter-change="getModuleCount"
|
||||||
@row-select-change="rowSelectChange"
|
@row-select-change="rowSelectChange"
|
||||||
|
@ -304,25 +305,44 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const { rowSelectChange, selectAllChange, clearSelector, setModuleInfo } = useModuleSelection(
|
const tableSelectedProps = ref({
|
||||||
|
modulesTree: props.moduleTree,
|
||||||
|
moduleCount: props.modulesCount,
|
||||||
|
});
|
||||||
|
const { rowSelectChange, selectAllChange, clearSelector } = useModuleSelection(
|
||||||
innerSelectedModulesMaps.value,
|
innerSelectedModulesMaps.value,
|
||||||
propsRes.value
|
propsRes.value,
|
||||||
|
tableSelectedProps.value
|
||||||
);
|
);
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
loadApiList();
|
|
||||||
});
|
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
[() => props.moduleTree, () => props.modulesCount],
|
() => props.moduleTree,
|
||||||
(val) => {
|
(val) => {
|
||||||
setModuleInfo(val);
|
if (val) {
|
||||||
|
tableSelectedProps.value.modulesTree = val;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true,
|
immediate: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.modulesCount,
|
||||||
|
(val) => {
|
||||||
|
if (val) {
|
||||||
|
tableSelectedProps.value.moduleCount = val;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loadApiList();
|
||||||
|
});
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
getApiSaveParams,
|
getApiSaveParams,
|
||||||
loadApiList,
|
loadApiList,
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
baseAction: [],
|
baseAction: [],
|
||||||
moreAction: [],
|
moreAction: [],
|
||||||
}"
|
}"
|
||||||
|
always-show-selected-count
|
||||||
v-on="propsEvent"
|
v-on="propsEvent"
|
||||||
@filter-change="getModuleCount"
|
@filter-change="getModuleCount"
|
||||||
@row-select-change="rowSelectChange"
|
@row-select-change="rowSelectChange"
|
||||||
|
@ -317,15 +318,34 @@
|
||||||
return [...propsRes.value.selectedKeys];
|
return [...propsRes.value.selectedKeys];
|
||||||
});
|
});
|
||||||
|
|
||||||
const { rowSelectChange, selectAllChange, clearSelector, setModuleInfo } = useModuleSelection(
|
const tableSelectedProps = ref({
|
||||||
|
modulesTree: props.moduleTree,
|
||||||
|
moduleCount: props.modulesCount,
|
||||||
|
});
|
||||||
|
const { rowSelectChange, selectAllChange, clearSelector } = useModuleSelection(
|
||||||
innerSelectedModulesMaps.value,
|
innerSelectedModulesMaps.value,
|
||||||
propsRes.value
|
propsRes.value,
|
||||||
|
tableSelectedProps.value
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
[() => props.moduleTree, () => props.modulesCount],
|
() => props.moduleTree,
|
||||||
(val) => {
|
(val) => {
|
||||||
setModuleInfo(val);
|
if (val) {
|
||||||
|
tableSelectedProps.value.modulesTree = val;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.modulesCount,
|
||||||
|
(val) => {
|
||||||
|
if (val) {
|
||||||
|
tableSelectedProps.value.moduleCount = val;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true,
|
immediate: true,
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
baseAction: [],
|
baseAction: [],
|
||||||
moreAction: [],
|
moreAction: [],
|
||||||
}"
|
}"
|
||||||
|
always-show-selected-count
|
||||||
v-on="propsEvent"
|
v-on="propsEvent"
|
||||||
@filter-change="getModuleCount"
|
@filter-change="getModuleCount"
|
||||||
@row-select-change="rowSelectChange"
|
@row-select-change="rowSelectChange"
|
||||||
|
@ -283,15 +284,34 @@
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const { rowSelectChange, selectAllChange, clearSelector, setModuleInfo } = useModuleSelection(
|
const tableSelectedProps = ref({
|
||||||
|
modulesTree: props.moduleTree,
|
||||||
|
moduleCount: props.modulesCount,
|
||||||
|
});
|
||||||
|
const { rowSelectChange, selectAllChange, clearSelector } = useModuleSelection(
|
||||||
innerSelectedModulesMaps.value,
|
innerSelectedModulesMaps.value,
|
||||||
propsRes.value
|
propsRes.value,
|
||||||
|
tableSelectedProps.value
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
[() => props.moduleTree, () => props.modulesCount],
|
() => props.moduleTree,
|
||||||
(val) => {
|
(val) => {
|
||||||
setModuleInfo(val);
|
if (val) {
|
||||||
|
tableSelectedProps.value.modulesTree = val;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.modulesCount,
|
||||||
|
(val) => {
|
||||||
|
if (val) {
|
||||||
|
tableSelectedProps.value.moduleCount = val;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true,
|
immediate: true,
|
||||||
|
|
|
@ -9,34 +9,76 @@ import { SelectAllEnum } from '@/enums/tableEnum';
|
||||||
|
|
||||||
import type { moduleKeysType } from './types';
|
import type { moduleKeysType } from './types';
|
||||||
|
|
||||||
|
export interface SelectedModuleProps {
|
||||||
|
modulesTree: MsTreeNodeData[];
|
||||||
|
moduleCount: Record<string, any>;
|
||||||
|
}
|
||||||
|
|
||||||
export default function useModuleSelections<T>(
|
export default function useModuleSelections<T>(
|
||||||
innerSelectedModulesMaps: Record<string, moduleKeysType>,
|
innerSelectedModulesMaps: Record<string, moduleKeysType>,
|
||||||
propsRes: MsTableProps<T>
|
propsRes: MsTableProps<T>,
|
||||||
|
tableSelectedProps: SelectedModuleProps
|
||||||
) {
|
) {
|
||||||
const moduleSelectedMap = ref<Record<string, string[]>>({});
|
const moduleSelectedMap = ref<Record<string, string[]>>({});
|
||||||
|
const { modulesTree, moduleCount } = tableSelectedProps;
|
||||||
|
const moduleTree = ref<MsTreeNodeData[]>(modulesTree);
|
||||||
|
const allModuleTotal = ref<Record<string, any>>(moduleCount);
|
||||||
|
|
||||||
const moduleTree = ref<MsTreeNodeData[]>([]);
|
// 初始化节点,防止选择时报错
|
||||||
const allModuleTotal = ref<Record<string, any>>({});
|
function setUnSelectNode(moduleId: string, key = 'id') {
|
||||||
|
if (!innerSelectedModulesMaps[moduleId]) {
|
||||||
|
const node = findNodeByKey<MsTreeNodeData>(moduleTree.value, moduleId, key);
|
||||||
|
innerSelectedModulesMaps[moduleId] = {
|
||||||
|
selectAll: false,
|
||||||
|
selectIds: new Set(),
|
||||||
|
excludeIds: new Set(),
|
||||||
|
count: moduleId === 'all' ? allModuleTotal.value.all : node?.count ?? 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 初始化表格数据的选择
|
// 初始化表格数据的选择
|
||||||
function initTableDataSelected() {
|
function initTableDataSelected() {
|
||||||
propsRes.selectedKeys = new Set([]);
|
propsRes.selectedKeys = new Set([]);
|
||||||
propsRes.excludeKeys = new Set([]);
|
propsRes.excludeKeys = new Set([]);
|
||||||
const allSelectIds: Set<string> = new Set();
|
const allSelectIds: Set<string> = new Set();
|
||||||
|
if (!innerSelectedModulesMaps.all) {
|
||||||
|
setUnSelectNode('all');
|
||||||
|
}
|
||||||
propsRes.data.forEach((item: any) => {
|
propsRes.data.forEach((item: any) => {
|
||||||
const selectAllProps = innerSelectedModulesMaps[item.moduleId];
|
const selectAllProps = innerSelectedModulesMaps[item.moduleId];
|
||||||
|
// 首次上来默认全选则追加moduleSelectedMap里边所对应moduleId所有的Ids
|
||||||
if (
|
if (
|
||||||
selectAllProps &&
|
selectAllProps &&
|
||||||
selectAllProps.selectAll &&
|
selectAllProps.selectAll &&
|
||||||
!selectAllProps.selectIds.size &&
|
!selectAllProps.selectIds.size &&
|
||||||
!selectAllProps.excludeIds.size
|
!selectAllProps.excludeIds.size
|
||||||
) {
|
) {
|
||||||
(moduleSelectedMap.value[item.moduleId] || []).forEach((id) => allSelectIds.add(id));
|
(moduleSelectedMap.value[item.moduleId] || []).forEach((id) => {
|
||||||
} else if (selectAllProps && !selectAllProps.selectAll && selectAllProps.selectIds.size) {
|
allSelectIds.add(id);
|
||||||
|
innerSelectedModulesMaps.all.selectIds.add(id);
|
||||||
|
innerSelectedModulesMaps.all.excludeIds.delete(id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 有选择则从选择里边的去回显选项项
|
||||||
|
if (selectAllProps && selectAllProps.selectIds.size) {
|
||||||
selectAllProps.selectIds.forEach((id) => allSelectIds.add(id));
|
selectAllProps.selectIds.forEach((id) => allSelectIds.add(id));
|
||||||
}
|
}
|
||||||
|
// 有排除的则从全部的里边排除掉排除的进行回显选择项
|
||||||
|
// 确保单独更新行选中或者取消能精确判断是否已经选中或排除
|
||||||
|
if (selectAllProps && selectAllProps.excludeIds.size) {
|
||||||
|
(moduleSelectedMap.value[item.moduleId] || []).forEach((id) => {
|
||||||
|
if (!selectAllProps.excludeIds.has(id)) {
|
||||||
|
allSelectIds.add(id);
|
||||||
|
innerSelectedModulesMaps[item.moduleId].selectIds.add(id);
|
||||||
|
innerSelectedModulesMaps.all.selectIds.add(id);
|
||||||
|
} else {
|
||||||
|
innerSelectedModulesMaps[item.moduleId].excludeIds.add(id);
|
||||||
|
innerSelectedModulesMaps.all.excludeIds.add(id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
propsRes.selectedKeys = new Set([...allSelectIds]);
|
propsRes.selectedKeys = new Set([...allSelectIds]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,39 +114,27 @@ export default function useModuleSelections<T>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化节点,防止选择时报错
|
|
||||||
function setUnSelectNode(moduleId: string, key = 'id') {
|
|
||||||
if (!innerSelectedModulesMaps[moduleId]) {
|
|
||||||
const node = findNodeByKey<MsTreeNodeData>(moduleTree.value, moduleId, key);
|
|
||||||
innerSelectedModulesMaps[moduleId] = {
|
|
||||||
selectAll: false,
|
|
||||||
selectIds: new Set(),
|
|
||||||
excludeIds: new Set(),
|
|
||||||
count: moduleId === 'all' ? allModuleTotal.value.all : node?.count ?? 0,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 设置最新状态
|
// 设置最新状态
|
||||||
function setSelectedModuleStatus(moduleId: string) {
|
function setSelectedModuleStatus(moduleId: string) {
|
||||||
const selectedProps = innerSelectedModulesMaps[moduleId];
|
const selectedProps = innerSelectedModulesMaps[moduleId];
|
||||||
if (selectedProps) {
|
if (selectedProps) {
|
||||||
const { selectIds: selectModuleIds, count, excludeIds } = selectedProps;
|
const { selectIds: selectModuleIds, count, excludeIds, selectAll } = selectedProps;
|
||||||
|
|
||||||
if (excludeIds.size) {
|
|
||||||
selectedProps.selectAll = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// 如果排除的数量等于总count则置为false且清空
|
||||||
if (excludeIds.size === count) {
|
if (excludeIds.size === count) {
|
||||||
resetModule(moduleId, false);
|
resetModule(moduleId, false);
|
||||||
}
|
}
|
||||||
|
// 如果选中的数量等于总count则置为true且清空
|
||||||
if (selectModuleIds.size === count) {
|
if (selectModuleIds.size === count) {
|
||||||
if (moduleId === 'all') {
|
|
||||||
resetModule(moduleId, true);
|
resetModule(moduleId, true);
|
||||||
} else {
|
|
||||||
setSelectedAll(moduleId);
|
|
||||||
}
|
}
|
||||||
|
// 全选无排除则全选为了上来全选取消一条再选择则为全选
|
||||||
|
if (selectAll && !excludeIds.size) {
|
||||||
|
resetModule(moduleId, true);
|
||||||
|
}
|
||||||
|
// 右侧表格选择后再排除此刻设置为false且清空已选项
|
||||||
|
if (!selectAll && !selectModuleIds.size) {
|
||||||
|
resetModule(moduleId, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,6 +142,8 @@ export default function useModuleSelections<T>(
|
||||||
// 更新选择数据
|
// 更新选择数据
|
||||||
function updateSelectModule(moduleId: string, id: string) {
|
function updateSelectModule(moduleId: string, id: string) {
|
||||||
const selectedProps = innerSelectedModulesMaps[moduleId];
|
const selectedProps = innerSelectedModulesMaps[moduleId];
|
||||||
|
console.log(222);
|
||||||
|
|
||||||
if (selectedProps) {
|
if (selectedProps) {
|
||||||
const selectedSet = selectedProps.selectIds;
|
const selectedSet = selectedProps.selectIds;
|
||||||
const excludedSet = selectedProps.excludeIds;
|
const excludedSet = selectedProps.excludeIds;
|
||||||
|
@ -140,7 +172,6 @@ export default function useModuleSelections<T>(
|
||||||
} else if (!selectedSet.has(id) && !excludedSet.has(id)) {
|
} else if (!selectedSet.has(id) && !excludedSet.has(id)) {
|
||||||
selectedProps.selectIds.add(id);
|
selectedProps.selectIds.add(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
innerSelectedModulesMaps[moduleId] = selectedProps;
|
innerSelectedModulesMaps[moduleId] = selectedProps;
|
||||||
setSelectedModuleStatus(moduleId);
|
setSelectedModuleStatus(moduleId);
|
||||||
}
|
}
|
||||||
|
@ -149,7 +180,6 @@ export default function useModuleSelections<T>(
|
||||||
function rowSelectChange(record: Record<string, any>) {
|
function rowSelectChange(record: Record<string, any>) {
|
||||||
const { moduleId } = record;
|
const { moduleId } = record;
|
||||||
setUnSelectNode(moduleId);
|
setUnSelectNode(moduleId);
|
||||||
setUnSelectNode('all');
|
|
||||||
updateSelectModule(moduleId, record.id);
|
updateSelectModule(moduleId, record.id);
|
||||||
updateSelectModule('all', record.id);
|
updateSelectModule('all', record.id);
|
||||||
}
|
}
|
||||||
|
@ -162,7 +192,8 @@ export default function useModuleSelections<T>(
|
||||||
const { moduleId } = item;
|
const { moduleId } = item;
|
||||||
setUnSelectNode(moduleId);
|
setUnSelectNode(moduleId);
|
||||||
const lastSelectedProps = innerSelectedModulesMaps[moduleId];
|
const lastSelectedProps = innerSelectedModulesMaps[moduleId];
|
||||||
if (!lastSelectedProps.selectAll) {
|
// 数据为data当前分页的数据
|
||||||
|
if (lastSelectedProps) {
|
||||||
innerSelectedModulesMaps[moduleId].selectIds.add(item.id);
|
innerSelectedModulesMaps[moduleId].selectIds.add(item.id);
|
||||||
innerSelectedModulesMaps[moduleId].excludeIds.delete(item.id);
|
innerSelectedModulesMaps[moduleId].excludeIds.delete(item.id);
|
||||||
setSelectedModuleStatus(moduleId);
|
setSelectedModuleStatus(moduleId);
|
||||||
|
@ -175,15 +206,20 @@ export default function useModuleSelections<T>(
|
||||||
setUnSelectNode(moduleId);
|
setUnSelectNode(moduleId);
|
||||||
innerSelectedModulesMaps[item.moduleId].selectIds.delete(item.id);
|
innerSelectedModulesMaps[item.moduleId].selectIds.delete(item.id);
|
||||||
innerSelectedModulesMaps[item.moduleId].excludeIds.add(item.id);
|
innerSelectedModulesMaps[item.moduleId].excludeIds.add(item.id);
|
||||||
|
const selectedProps = innerSelectedModulesMaps[moduleId];
|
||||||
|
if (selectedProps) {
|
||||||
|
const resultIds = (moduleSelectedMap.value[moduleId] || []).filter((id) => !selectedProps.excludeIds.has(id));
|
||||||
|
// 取消加了排除ids此刻全选状态为false,并且排除当前页ids,则从所有列表里边收集到模块ids
|
||||||
|
resultIds.forEach((e) => {
|
||||||
|
innerSelectedModulesMaps[moduleId].selectIds.add(e);
|
||||||
|
innerSelectedModulesMaps[moduleId].excludeIds.delete(e);
|
||||||
|
});
|
||||||
|
}
|
||||||
setSelectedModuleStatus(moduleId);
|
setSelectedModuleStatus(moduleId);
|
||||||
updateSelectModule('all', item.id);
|
updateSelectModule('all', item.id);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function setModuleInfo([tree, count]: [MsTreeNodeData[], Record<string, any>]) {
|
|
||||||
moduleTree.value = tree;
|
|
||||||
allModuleTotal.value = count;
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearSelector() {
|
function clearSelector() {
|
||||||
Object.keys(innerSelectedModulesMaps).forEach((key) => {
|
Object.keys(innerSelectedModulesMaps).forEach((key) => {
|
||||||
|
@ -213,6 +249,46 @@ export default function useModuleSelections<T>(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 设置模块树
|
||||||
|
function setModuleTree(tree: MsTreeNodeData[]) {
|
||||||
|
moduleTree.value = tree;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置模块
|
||||||
|
function setModuleCount(count: Record<string, any>) {
|
||||||
|
allModuleTotal.value = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => tableSelectedProps.modulesTree,
|
||||||
|
(val) => {
|
||||||
|
setModuleTree(val);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true,
|
||||||
|
deep: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => tableSelectedProps.moduleCount,
|
||||||
|
(val) => {
|
||||||
|
if (val) {
|
||||||
|
setModuleCount(val);
|
||||||
|
innerSelectedModulesMaps.all = {
|
||||||
|
selectAll: false,
|
||||||
|
selectIds: new Set(),
|
||||||
|
excludeIds: new Set(),
|
||||||
|
count: val.all || 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true,
|
||||||
|
deep: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
moduleSelectedMap,
|
moduleSelectedMap,
|
||||||
rowSelectChange,
|
rowSelectChange,
|
||||||
|
@ -224,6 +300,5 @@ export default function useModuleSelections<T>(
|
||||||
setSelectedAll,
|
setSelectedAll,
|
||||||
updateSelectModule,
|
updateSelectModule,
|
||||||
clearSelector,
|
clearSelector,
|
||||||
setModuleInfo,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,14 +83,14 @@ export default function useTreeSelection(selectedModuleProps: SelectedModuleProp
|
||||||
return Object.keys(selectedModulesMaps.value).reduce((total, key) => {
|
return Object.keys(selectedModulesMaps.value).reduce((total, key) => {
|
||||||
const module = selectedModulesMaps.value[key];
|
const module = selectedModulesMaps.value[key];
|
||||||
if (key !== 'all') {
|
if (key !== 'all') {
|
||||||
// 未全选存在排除则要 count总-排除掉的 = 已选
|
// 全选
|
||||||
if (module.excludeIds.size && !module.selectAll) {
|
if (module.selectAll && !module.excludeIds.size && !module.selectIds.size) {
|
||||||
total += module.count - module.excludeIds.size;
|
|
||||||
// 已全选未排除则要+count
|
|
||||||
} else if (module.selectAll && !module.excludeIds.size) {
|
|
||||||
total += module.count;
|
total += module.count;
|
||||||
// 未全选则 + 选择的id集合
|
// 具有排除项则半选
|
||||||
} else if (!module.selectAll && module.selectIds.size) {
|
} else if (module.selectAll && module.excludeIds.size) {
|
||||||
|
total += module.count - module.excludeIds.size;
|
||||||
|
// 初始化上来选择右侧列表计算selectIds.size为和
|
||||||
|
} else if (!module.selectAll) {
|
||||||
total += module.selectIds.size;
|
total += module.selectIds.size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,8 +114,8 @@ export default function useTreeSelection(selectedModuleProps: SelectedModuleProp
|
||||||
Object.entries(val).forEach(([moduleId, selectedProps]) => {
|
Object.entries(val).forEach(([moduleId, selectedProps]) => {
|
||||||
const { selectAll: selectIdsAll, selectIds, count, excludeIds } = selectedProps;
|
const { selectAll: selectIdsAll, selectIds, count, excludeIds } = selectedProps;
|
||||||
if (selectedProps) {
|
if (selectedProps) {
|
||||||
// 全选和取消全选
|
// 全选状态则其他参数的size都为0
|
||||||
if (selectIdsAll) {
|
if (selectIdsAll && !selectIds.size && !excludeIds.size) {
|
||||||
checkedKeysSet.add(moduleId);
|
checkedKeysSet.add(moduleId);
|
||||||
} else {
|
} else {
|
||||||
checkedKeysSet.delete(moduleId);
|
checkedKeysSet.delete(moduleId);
|
||||||
|
|
|
@ -244,7 +244,7 @@
|
||||||
</template>
|
</template>
|
||||||
</a-table>
|
</a-table>
|
||||||
<div
|
<div
|
||||||
v-if="showBatchAction || !!attrs.showPagination"
|
v-if="showBatchAction || !!attrs.showPagination || alwaysShowSelectedCount"
|
||||||
id="ms-table-footer-wrapper"
|
id="ms-table-footer-wrapper"
|
||||||
class="mt-[16px] flex w-full flex-row flex-nowrap items-center overflow-hidden"
|
class="mt-[16px] flex w-full flex-row flex-nowrap items-center overflow-hidden"
|
||||||
:class="{ 'justify-between': showBatchAction }"
|
:class="{ 'justify-between': showBatchAction }"
|
||||||
|
@ -259,7 +259,7 @@
|
||||||
</span>
|
</span>
|
||||||
<div class="flex flex-grow items-center">
|
<div class="flex flex-grow items-center">
|
||||||
<batch-action
|
<batch-action
|
||||||
v-if="showBatchAction"
|
v-if="showBatchAction || alwaysShowSelectedCount"
|
||||||
class="flex-1"
|
class="flex-1"
|
||||||
:select-row-count="selectedCount"
|
:select-row-count="selectedCount"
|
||||||
:action-config="props.actionConfig"
|
:action-config="props.actionConfig"
|
||||||
|
@ -360,6 +360,7 @@
|
||||||
showSelectorAll?: boolean;
|
showSelectorAll?: boolean;
|
||||||
firstColumnWidth?: number; // 选择、拖拽列的宽度
|
firstColumnWidth?: number; // 选择、拖拽列的宽度
|
||||||
paginationSize?: 'small' | 'mini' | 'medium' | 'large';
|
paginationSize?: 'small' | 'mini' | 'medium' | 'large';
|
||||||
|
alwaysShowSelectedCount?: boolean; // 是否总是保持显示已选项
|
||||||
}>();
|
}>();
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: 'batchAction', value: BatchActionParams, queryParams: BatchActionQueryParams): void;
|
(e: 'batchAction', value: BatchActionParams, queryParams: BatchActionQueryParams): void;
|
||||||
|
|
Loading…
Reference in New Issue