|
@@ -14,31 +14,126 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import { mapGetters } from "vuex";
|
|
|
+
|
|
|
export default {
|
|
|
props: {
|
|
|
positionDebug: {
|
|
|
type: String,
|
|
|
default: '',
|
|
|
},
|
|
|
- level: {
|
|
|
+ indentLevel: {
|
|
|
+ type: Number,
|
|
|
+ default: 1,
|
|
|
+ },
|
|
|
+ topologyLevel: {
|
|
|
type: Number,
|
|
|
default: 1,
|
|
|
},
|
|
|
+ parentNode: {
|
|
|
+ type: Object,
|
|
|
+ default: null,
|
|
|
+ },
|
|
|
},
|
|
|
computed: {
|
|
|
+ ...mapGetters({
|
|
|
+ dragInfo: 'editorNavDragInfo',
|
|
|
+ }),
|
|
|
marginLeft() {
|
|
|
- return (this.level - 1) * 12 + 'px'
|
|
|
+ return (this.indentLevel - 1) * 12 + 'px'
|
|
|
},
|
|
|
},
|
|
|
methods: {
|
|
|
+ canDrop() {
|
|
|
+ switch (this.dragInfo.type) {
|
|
|
+ case 'scene': // 被拖拽的是场景
|
|
|
+ if (this.topologyLevel === 1) {
|
|
|
+ console.log('情况1:被拖拽的是场景,拖拽到一级分组列表');
|
|
|
+ return false
|
|
|
+ } else if (this.topologyLevel === 2) {
|
|
|
+ console.log('情况2:被拖拽的是场景,拖拽到二级分组列表');
|
|
|
+ return false
|
|
|
+ } else if (this.topologyLevel === 3) {
|
|
|
+ console.log('情况3:被拖拽的是场景,拖拽到场景列表');
|
|
|
+ return true
|
|
|
+ } else {
|
|
|
+ console.error('情况4:不该出现');
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ case 'topologyGroupLevel2': // 被拖拽的是拓扑结构中二级分组
|
|
|
+ if (this.topologyLevel === 1) {
|
|
|
+ console.log('情况5:被拖拽的是拓扑结构中二级分组,拖拽到一级分组列表');
|
|
|
+ return true
|
|
|
+ } else if (this.topologyLevel === 2) {
|
|
|
+ console.log('情况6:被拖拽的是拓扑结构中二级分组,拖拽到二级分组列表');
|
|
|
+ return true
|
|
|
+ } else if (this.topologyLevel === 3) {
|
|
|
+ if (this.indentLevel === 2) {
|
|
|
+ console.log('情况7:被拖拽的是拓扑结构中二级分组,拖拽到隐藏的默认二级分组中场景列表');
|
|
|
+ return true
|
|
|
+ } else {
|
|
|
+ console.log('情况8:被拖拽的是拓扑结构中二级分组,拖拽到普通的二级分组中场景列表');
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ console.error('情况9:不该出现');
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ case 'topologyGroupLevel1': // 被拖拽的是拓扑结构中一级分组
|
|
|
+ if (this.topologyLevel === 1) {
|
|
|
+ console.log('情况10:被拖拽的是拓扑结构中一级分组,拖拽到一级分组列表');
|
|
|
+ return true
|
|
|
+ } else if (this.topologyLevel === 2) { // 拖拽到二级分组列表
|
|
|
+ if (this.dragInfo.node.children.length === 1 && this.dragInfo.node.children[0].name === '默认二级分组') {
|
|
|
+ console.log('情况11:被拖拽的一级分组只有一个隐藏的默认二级分组,拖拽到二级分组列表');
|
|
|
+ return true
|
|
|
+ } else {
|
|
|
+ console.log('情况12:被拖拽的一级分组并非只有一个隐藏的默认二级分组,拖拽到二级分组列表');
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ } else if (this.topologyLevel === 3) { // 拖拽到场景列表
|
|
|
+ if (this.indentLevel === 2) { // 拖拽到隐藏的默认二级分组中的场景列表
|
|
|
+ if (this.dragInfo.node.children.length === 1 && this.dragInfo.node.children[0].name === '默认二级分组') {
|
|
|
+ if (this.dragInfo.node.children[0].id === this.parentNode?.id) {
|
|
|
+ console.log('情况13:被拖拽的一级分组只有一个隐藏的默认二级分组,拖拽到自身的默认二级分组中的场景列表');
|
|
|
+ return false
|
|
|
+ } else {
|
|
|
+ console.log('情况14:被拖拽的一级分组只有一个隐藏的默认二级分组,拖拽到另一个一级分组中隐藏的默认二级分组中的场景列表');
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ console.log('情况15:被拖拽的一级分组并非只有一个隐藏的默认二级分组,拖拽到隐藏的默认二级分组中的场景列表');
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ console.log('情况16:被拖拽的是拓扑结构中一级分组,拖拽到普通二级分组中的场景列表')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ console.error('情况17:不该出现');
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ console.error('情况18:不该出现');
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ },
|
|
|
onDragEnterMarginPlaceholder(e) {
|
|
|
- e.preventDefault()
|
|
|
- e.target.style.backgroundColor = '#0076f6'
|
|
|
- e.dataTransfer.dropEffect = 'move'
|
|
|
+ if (!this.canDrop()) {
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ e.preventDefault()
|
|
|
+ e.target.style.backgroundColor = '#0076f6'
|
|
|
+ e.dataTransfer.dropEffect = 'move'
|
|
|
+ }
|
|
|
},
|
|
|
onDragOverMarginPlaceholder(e) {
|
|
|
- e.preventDefault()
|
|
|
- e.dataTransfer.dropEffect = 'move'
|
|
|
+ if (!this.canDrop()) {
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ e.preventDefault()
|
|
|
+ e.dataTransfer.dropEffect = 'move'
|
|
|
+ }
|
|
|
},
|
|
|
onDragLeaveMarginPlaceHolder(e) {
|
|
|
// e.preventDefault()
|