fix: 接口测试步骤树数据无联动修复&系统查看用户组权限调整

This commit is contained in:
baiqi 2024-07-22 17:06:58 +08:00 committed by 刘瑞斌
parent 9532269472
commit cbd2f91fa1
8 changed files with 42 additions and 19 deletions

View File

@ -98,7 +98,7 @@
import type { ActionsItem } from '@/components/pure/ms-table-more-action/types';
import useContainerShadow from '@/hooks/useContainerShadow';
import { mapTree } from '@/utils';
import { mapTree, traverseTree } from '@/utils';
import type { MsTreeExpandedData, MsTreeFieldNames, MsTreeNodeData, MsTreeSelectedData } from './types';
import { VirtualListProps } from '@arco-design/web-vue/es/_components/virtual-list-v2/interface';
@ -127,6 +127,9 @@
nodeHighlightClass?: string; //
hideSwitcher?: boolean; //
handleDrop?: boolean; //
// 使
// (使 data filterTreeData slot node data使 data filterTreeData )
useMapData?: boolean;
titleTooltipPosition?:
| 'top'
| 'tl'
@ -156,6 +159,7 @@
isLeaf: 'isLeaf',
}),
disabledTitleTooltip: false,
useMapData: true,
}
);
@ -260,10 +264,17 @@
() => data.value,
debounce((val) => {
if (!props.keyword) {
filterTreeData.value = mapTree(val, (node) => {
node.expanded = props.defaultExpandAll;
return node;
});
if (props.useMapData) {
filterTreeData.value = mapTree(val, (node) => {
node.expanded = props.defaultExpandAll;
return node;
});
} else {
traverseTree(val, (node) => {
node.expanded = props.defaultExpandAll;
});
filterTreeData.value = val;
}
if (props.defaultExpandAll && treeRef.value) {
treeRef.value.expandAll(true);
}
@ -281,7 +292,18 @@
() => props.keyword,
(val) => {
if (!val) {
filterTreeData.value = data.value;
if (props.useMapData) {
filterTreeData.value = mapTree(data.value, (node) => {
node.expanded = props.defaultExpandAll;
return node;
});
} else {
traverseTree(data.value, (node) => {
node.expanded = props.defaultExpandAll;
});
filterTreeData.value = data.value;
}
treeRef.value?.expandAll(false);
} else {
updateDebouncedSearch();
}
@ -409,7 +431,7 @@
(val) => {
if (typeof val === 'boolean') {
treeRef.value?.expandAll(val);
filterTreeData.value = mapTree(filterTreeData.value, (node) => {
traverseTree(filterTreeData.value, (node) => {
node.expanded = val;
return node;
});

View File

@ -178,7 +178,7 @@
/>
<a-tooltip
v-else
placement="top"
position="top"
content-class="max-w-[400px]"
:content="String(record[item.dataIndex as string])"
:disabled="record[item.dataIndex as string] === '' || record[item.dataIndex as string] === undefined || record[item.dataIndex as string] === null"

View File

@ -494,7 +494,6 @@ export function insertNodes<T>(
}
return false;
}
insertNodeInTree(treeArr);
}

View File

@ -145,7 +145,7 @@
import { useI18n } from '@/hooks/useI18n';
import useModal from '@/hooks/useModal';
import useAppStore from '@/store/modules/app';
import { mapTree } from '@/utils';
import { characterLimit, mapTree } from '@/utils';
import { hasAnyPermission } from '@/utils/permission';
import { ApiScenarioGetModuleParams } from '@/models/apiTest/scenario';
@ -341,7 +341,7 @@
function deleteFolder(node: MsTreeNodeData) {
openModal({
type: 'error',
title: t('apiScenario.module.deleteTipTitle', { name: node.name }),
title: t('apiScenario.module.deleteTipTitle', { name: characterLimit(node.name) }),
content: t('apiScenario.module.deleteTipContent'),
okText: t('apiScenario.deleteConfirm'),
okButtonProps: {

View File

@ -21,6 +21,7 @@
title-class="step-tree-node-title"
node-highlight-class="step-tree-node-focus"
action-on-node-click="expand"
:use-map-data="false"
disabled-title-tooltip
checkable
block-node

View File

@ -3,7 +3,7 @@ import { Message } from '@arco-design/web-vue';
import MsTree from '@/components/business/ms-tree/index.vue';
import { getScenarioDetail } from '@/api/modules/api-test/scenario';
import { t } from '@/hooks/useI18n';
import { useI18n } from '@/hooks/useI18n';
import { findNodeByKey, getGenerateId, mapTree } from '@/utils';
import type { Scenario, ScenarioStepConfig, ScenarioStepDetail, ScenarioStepItem } from '@/models/apiTest/scenario';
@ -43,6 +43,8 @@ export default function useStepNodeEdit({
selectedKeys: Ref<Array<string | number>>;
showScenarioConfig: Ref<boolean>;
}) {
const { t } = useI18n();
/**
*
* @param dataKey key

View File

@ -107,6 +107,7 @@
import useTableStore from '@/hooks/useTableStore';
import useAppStore from '@/store/modules/app';
import { operationWidth } from '@/utils';
import { hasAnyPermission } from '@/utils/permission';
import { ApiScenarioTableItem } from '@/models/apiTest/scenario';
import { ApiScenarioStatus } from '@/enums/apiEnum';
@ -324,8 +325,8 @@
scroll: { x: '100%' },
tableKey: props.readOnly ? undefined : TableKeyEnum.API_SCENARIO,
showSetting: !props.readOnly,
selectable: true,
showSelectAll: !props.readOnly,
selectable: hasAnyPermission(['PROJECT_API_SCENARIO:READ+DELETE']),
showSelectAll: hasAnyPermission(['PROJECT_API_SCENARIO:READ+DELETE']),
draggable: undefined,
heightUsed: 374,
showSubdirectory: true,

View File

@ -742,11 +742,9 @@
async function init() {
try {
if (hasAnyPermission(['SYSTEM_USER_ROLE:READ'])) {
userGroupOptions.value = await getSystemRoles();
if (userGroupOptions.value.length) {
userForm.value.userGroup = userGroupOptions.value.filter((e: SystemRole) => e.selected === true);
}
userGroupOptions.value = await getSystemRoles();
if (userGroupOptions.value.length) {
userForm.value.userGroup = userGroupOptions.value.filter((e: SystemRole) => e.selected === true);
}
} catch (error) {
// eslint-disable-next-line no-console