fix(接口场景): 场景步骤问题修复
This commit is contained in:
parent
0b59e73899
commit
66ee2c3d33
|
@ -126,6 +126,7 @@
|
||||||
actionOnNodeClick?: 'expand'; // 点击节点时的操作
|
actionOnNodeClick?: 'expand'; // 点击节点时的操作
|
||||||
nodeHighlightClass?: string; // 节点高亮背景色
|
nodeHighlightClass?: string; // 节点高亮背景色
|
||||||
hideSwitcher?: boolean; // 隐藏展开折叠图标
|
hideSwitcher?: boolean; // 隐藏展开折叠图标
|
||||||
|
handleDrop?: boolean; // 是否处理拖拽
|
||||||
titleTooltipPosition?:
|
titleTooltipPosition?:
|
||||||
| 'top'
|
| 'top'
|
||||||
| 'tl'
|
| 'tl'
|
||||||
|
@ -333,6 +334,10 @@
|
||||||
dropNode: MsTreeNodeData; // 放入的节点
|
dropNode: MsTreeNodeData; // 放入的节点
|
||||||
dropPosition: number; // 放入的位置,-1 为放入节点前,1 为放入节点后,0 为放入节点内
|
dropPosition: number; // 放入的位置,-1 为放入节点前,1 为放入节点后,0 为放入节点内
|
||||||
}) {
|
}) {
|
||||||
|
if (props.handleDrop) {
|
||||||
|
emit('drop', data.value, dragNode, dropNode, dropPosition);
|
||||||
|
return;
|
||||||
|
}
|
||||||
loop(data.value, dragNode.key, (item, index, arr) => {
|
loop(data.value, dragNode.key, (item, index, arr) => {
|
||||||
arr.splice(index, 1);
|
arr.splice(index, 1);
|
||||||
});
|
});
|
||||||
|
|
|
@ -969,7 +969,7 @@
|
||||||
function handleClose() {
|
function handleClose() {
|
||||||
if (isReplace.value) {
|
if (isReplace.value) {
|
||||||
isReplace.value = false;
|
isReplace.value = false;
|
||||||
} else if (!requestVModel.value.isNew) {
|
} else {
|
||||||
emit('applyStep', cloneDeep(makeRequestParams()) as RequestParam);
|
emit('applyStep', cloneDeep(makeRequestParams()) as RequestParam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
block-node
|
block-node
|
||||||
draggable
|
draggable
|
||||||
hide-switcher
|
hide-switcher
|
||||||
|
handle-drop
|
||||||
@select="(selectedKeys, node) => handleStepSelect(node as ScenarioStepItem)"
|
@select="(selectedKeys, node) => handleStepSelect(node as ScenarioStepItem)"
|
||||||
@expand="handleStepExpand"
|
@expand="handleStepExpand"
|
||||||
@more-actions-close="() => setFocusNodeKey('')"
|
@more-actions-close="() => setFocusNodeKey('')"
|
||||||
|
@ -910,7 +911,11 @@
|
||||||
const { isQuoteScenario } = getStepType(node as ScenarioStepItem);
|
const { isQuoteScenario } = getStepType(node as ScenarioStepItem);
|
||||||
if (stepDetail) {
|
if (stepDetail) {
|
||||||
// 如果复制的步骤还有详情数据,则也复制详情数据
|
// 如果复制的步骤还有详情数据,则也复制详情数据
|
||||||
stepDetails.value[id] = cloneDeep(stepDetail);
|
stepDetails.value[id] = cloneDeep({
|
||||||
|
...stepDetail,
|
||||||
|
stepId: id,
|
||||||
|
uniqueId: id,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (stepFileParam) {
|
if (stepFileParam) {
|
||||||
// 如果复制的步骤还有详情数据,则也复制详情数据
|
// 如果复制的步骤还有详情数据,则也复制详情数据
|
||||||
|
|
|
@ -195,11 +195,13 @@ export default function useStepOperation({
|
||||||
}
|
}
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
const offspringIds: string[] = [];
|
const offspringIds: string[] = [];
|
||||||
mapTree(cloneDeep(dragNode.children || []), (e) => {
|
const realStep = findNodeByKey<ScenarioStepItem>(steps.value, dragNode.uniqueId, 'uniqueId');
|
||||||
|
if (!realStep) return;
|
||||||
|
mapTree(cloneDeep(realStep.children || []), (e) => {
|
||||||
offspringIds.push(e.uniqueId);
|
offspringIds.push(e.uniqueId);
|
||||||
return e;
|
return e;
|
||||||
});
|
});
|
||||||
const stepIdAndOffspringIds = [dragNode.uniqueId, ...offspringIds];
|
const stepIdAndOffspringIds = [realStep.uniqueId, ...offspringIds];
|
||||||
if (dropPosition === 0) {
|
if (dropPosition === 0) {
|
||||||
// 拖拽到节点内
|
// 拖拽到节点内
|
||||||
if (selectedKeys.value.includes(dropNode.uniqueId)) {
|
if (selectedKeys.value.includes(dropNode.uniqueId)) {
|
||||||
|
@ -209,7 +211,7 @@ export default function useStepOperation({
|
||||||
} else if (dropNode.parent && selectedKeys.value.includes(dropNode.parent.uniqueId)) {
|
} else if (dropNode.parent && selectedKeys.value.includes(dropNode.parent.uniqueId)) {
|
||||||
// 释放位置的节点的父节点已选中,则需要把拖动的节点及其子孙节点也需要选中(因为父级选中子级也会展示选中状态)
|
// 释放位置的节点的父节点已选中,则需要把拖动的节点及其子孙节点也需要选中(因为父级选中子级也会展示选中状态)
|
||||||
selectedKeys.value = selectedKeys.value.concat(stepIdAndOffspringIds);
|
selectedKeys.value = selectedKeys.value.concat(stepIdAndOffspringIds);
|
||||||
} else if (dragNode.parent && selectedKeys.value.includes(dragNode.parent.uniqueId)) {
|
} else if (realStep.parent && selectedKeys.value.includes(realStep.parent.uniqueId)) {
|
||||||
// 如果被拖动的节点的父节点在选中的节点中,则需要把被拖动的节点及其子孙节点从选中的节点中移除
|
// 如果被拖动的节点的父节点在选中的节点中,则需要把被拖动的节点及其子孙节点从选中的节点中移除
|
||||||
selectedKeys.value = selectedKeys.value.filter((e) => {
|
selectedKeys.value = selectedKeys.value.filter((e) => {
|
||||||
for (let i = 0; i < stepIdAndOffspringIds.length; i++) {
|
for (let i = 0; i < stepIdAndOffspringIds.length; i++) {
|
||||||
|
@ -222,7 +224,7 @@ export default function useStepOperation({
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const dragResult = handleTreeDragDrop(steps.value, dragNode, dropNode, dropPosition, 'uniqueId');
|
const dragResult = handleTreeDragDrop(steps.value, realStep, dropNode, dropPosition, 'uniqueId');
|
||||||
if (dragResult) {
|
if (dragResult) {
|
||||||
Message.success(t('common.moveSuccess'));
|
Message.success(t('common.moveSuccess'));
|
||||||
scenario.value.unSaved = true;
|
scenario.value.unSaved = true;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { traverseTree } from '@/utils';
|
||||||
|
|
||||||
import { RequestResult } from '@/models/apiTest/common';
|
import { RequestResult } from '@/models/apiTest/common';
|
||||||
import { type Scenario, type ScenarioStepDetails, ScenarioStepItem } from '@/models/apiTest/scenario';
|
import { type Scenario, type ScenarioStepDetails, ScenarioStepItem } from '@/models/apiTest/scenario';
|
||||||
import { ScenarioExecuteStatus, ScenarioStepType } from '@/enums/apiEnum';
|
import { ScenarioExecuteStatus, ScenarioStepType } from '@/enums/apiEnum';
|
||||||
|
@ -123,7 +125,7 @@ export function getScenarioFileParams(scenario: Scenario) {
|
||||||
*/
|
*/
|
||||||
export function getStepDetails(steps: ScenarioStepItem[], details: Record<string, ScenarioStepDetails>) {
|
export function getStepDetails(steps: ScenarioStepItem[], details: Record<string, ScenarioStepDetails>) {
|
||||||
const newStepDetails: Record<string, ScenarioStepDetails> = {};
|
const newStepDetails: Record<string, ScenarioStepDetails> = {};
|
||||||
steps.forEach((step) => {
|
traverseTree(steps, (step) => {
|
||||||
const currentDetail = details[step.id] as RequestParam;
|
const currentDetail = details[step.id] as RequestParam;
|
||||||
if (
|
if (
|
||||||
currentDetail &&
|
currentDetail &&
|
||||||
|
|
Loading…
Reference in New Issue