fix: 拖拽节点到根节点报错

This commit is contained in:
chenjianxing 2021-02-04 17:43:13 +08:00
parent ad1c9d3ffe
commit 6bad2e75df
4 changed files with 57 additions and 50 deletions

View File

@ -11,6 +11,7 @@
@edit="edit"
@drag="drag"
@remove="remove"
@refresh="list"
@nodeSelectEvent="nodeChange"
ref="nodeTree">
@ -34,24 +35,24 @@
</template>
<script>
import SelectMenu from "../../../track/common/SelectMenu";
import MsAddBasisScenario from "@/business/components/api/automation/scenario/AddBasisScenario";
import {getCurrentProjectID} from "@/common/js/utils";
import MsNodeTree from "../../../track/common/NodeTree";
import {buildNodePath} from "../../definition/model/NodeTree";
import ModuleTrashButton from "../../definition/components/module/ModuleTrashButton";
import SelectMenu from "../../../track/common/SelectMenu";
import MsAddBasisScenario from "@/business/components/api/automation/scenario/AddBasisScenario";
import {getCurrentProjectID} from "@/common/js/utils";
import MsNodeTree from "../../../track/common/NodeTree";
import {buildNodePath} from "../../definition/model/NodeTree";
import ModuleTrashButton from "../../definition/components/module/ModuleTrashButton";
export default {
name: 'MsApiScenarioModule',
components: {
ModuleTrashButton,
MsNodeTree,
MsAddBasisScenario,
SelectMenu,
},
props: {
isReadOnly: {
type: Boolean,
export default {
name: 'MsApiScenarioModule',
components: {
ModuleTrashButton,
MsNodeTree,
MsAddBasisScenario,
SelectMenu,
},
props: {
isReadOnly: {
type: Boolean,
default() {
return false
}

View File

@ -11,6 +11,7 @@
@edit="edit"
@drag="drag"
@remove="remove"
@refresh="list"
@nodeSelectEvent="nodeChange"
ref="nodeTree">
@ -33,26 +34,26 @@
</template>
<script>
import MsAddBasisApi from "../basis/AddBasisApi";
import SelectMenu from "../../../../track/common/SelectMenu";
import {OPTIONS} from "../../model/JsonData";
import ApiImport from "../import/ApiImport";
import {getCurrentProjectID} from "@/common/js/utils";
import MsNodeTree from "../../../../track/common/NodeTree";
import ApiModuleHeader from "./ApiModuleHeader";
import {buildNodePath} from "../../model/NodeTree";
import MsAddBasisApi from "../basis/AddBasisApi";
import SelectMenu from "../../../../track/common/SelectMenu";
import {OPTIONS} from "../../model/JsonData";
import ApiImport from "../import/ApiImport";
import {getCurrentProjectID} from "@/common/js/utils";
import MsNodeTree from "../../../../track/common/NodeTree";
import ApiModuleHeader from "./ApiModuleHeader";
import {buildNodePath} from "../../model/NodeTree";
export default {
name: 'MsApiModule',
components: {
ApiModuleHeader,
MsNodeTree,
MsAddBasisApi,
SelectMenu,
ApiImport
},
data() {
return {
export default {
name: 'MsApiModule',
components: {
ApiModuleHeader,
MsNodeTree,
MsAddBasisApi,
SelectMenu,
ApiImport
},
data() {
return {
result: {},
condition: {
protocol: OPTIONS[0].value,

View File

@ -220,6 +220,10 @@ export default {
if (dropType === "none" || dropType === undefined) {
return;
}
if (dropNode.data.id === 'root' && dropType === 'before') {
this.$emit('refresh');
return false;
}
let param = this.buildParam(draggingNode, dropNode, dropType);
let list = [];
this.getNodeTree(this.treeNodes, draggingNode.data.id, list);

View File

@ -8,25 +8,26 @@
@drag="drag"
@remove="remove"
@nodeSelectEvent="nodeChange"
@refresh="list"
ref="nodeTree"/>
</template>
<script>
import NodeEdit from "./NodeEdit";
import {getCurrentProjectID} from "../../../../common/js/utils";
import MsNodeTree from "./NodeTree";
import NodeEdit from "./NodeEdit";
import {getCurrentProjectID} from "../../../../common/js/utils";
import MsNodeTree from "./NodeTree";
export default {
name: "TestCaseNodeTree",
components: {MsNodeTree, NodeEdit },
data() {
return {
defaultProps: {
children: "children",
label: "label"
},
result: {},
treeNodes: [],
export default {
name: "TestCaseNodeTree",
components: {MsNodeTree, NodeEdit},
data() {
return {
defaultProps: {
children: "children",
label: "label"
},
result: {},
treeNodes: [],
projectId: ""
};
},