|
@ -11,44 +11,39 @@ |
|
|
}"> |
|
|
}"> |
|
|
{{ data.title }} - {{ level * 10 + 'px' }} |
|
|
{{ data.title }} - {{ level * 10 + 'px' }} |
|
|
</div> |
|
|
</div> |
|
|
<NiuTreeDrag v-bind="props" :status="status" :style="{ |
|
|
|
|
|
marginLeft: level * 10 + 'px', |
|
|
|
|
|
}"></NiuTreeDrag> |
|
|
|
|
|
</slot> |
|
|
</slot> |
|
|
|
|
|
<div :style="{ marginLeft: level * 10 + 'px' }" :class="[ |
|
|
|
|
|
{ |
|
|
|
|
|
'ps-tree-drag-up': |
|
|
|
|
|
dataSourceKey != data.key && |
|
|
|
|
|
dataSourceKey != undefined && |
|
|
|
|
|
!isChildOf(data.key, dataSourceKey, list) && |
|
|
|
|
|
status === ENiuTreeStatus.DragUp, |
|
|
|
|
|
'ps-tree-drag-in': |
|
|
|
|
|
dataSourceKey != data.key && |
|
|
|
|
|
dataSourceKey && |
|
|
|
|
|
!isChildOf(data.key, dataSourceKey, list) && |
|
|
|
|
|
status === ENiuTreeStatus.DragIn, |
|
|
|
|
|
'ps-tree-drag-down': |
|
|
|
|
|
dataSourceKey != data.key && |
|
|
|
|
|
dataSourceKey && |
|
|
|
|
|
!isChildOf(data.key, dataSourceKey, list) && |
|
|
|
|
|
status === ENiuTreeStatus.DragDown, |
|
|
|
|
|
}, |
|
|
|
|
|
]"></div> |
|
|
</div> |
|
|
</div> |
|
|
<div class="ps-tree-sub-node" v-if="(opts.justOpen || data.isExpand) && data.children && data.children.length"> |
|
|
<div class="ps-tree-sub-node" v-if="(opts.justOpen || data.isExpand) && data.children && data.children.length"> |
|
|
<template v-for="(item, index) in data.children" :key="item.key"> |
|
|
<slot name="children" :datalist="data.children" :level="level + 1" :status="status"> |
|
|
<node @onDragstart="(e: INiuTreeKey) => emit('onDragstart', e)" |
|
|
|
|
|
@onDragend="(e: INiuTreeKey) => emit('onDragend', e)" |
|
|
|
|
|
@onDrop="(e: INiuTreeKey, s?: ENiuTreeStatus) => emit('onDrop', e, s)" |
|
|
|
|
|
@onDragover="(e: INiuTreeKey) => emit('onDragover', e)" |
|
|
|
|
|
@onDragleave="(e: INiuTreeKey) => emit('onDragleave', e)" |
|
|
|
|
|
@click="(e: INiuTreeData) => emit('click', e)" :data-source-key="dataSourceKey" :data="item" |
|
|
|
|
|
:list="list" :level="level + 1"> |
|
|
|
|
|
<template |
|
|
|
|
|
#default="{ data, deep, dataSourceKey, status }: { data: INiuTreeData, deep: number, dataSourceKey: INiuTreeKey, status: ENiuTreeStatus }"> |
|
|
|
|
|
<slot :data="data" :deep="deep" :dataSourceKey="dataSourceKey" :status="status"> |
|
|
|
|
|
<div :style="{ |
|
|
|
|
|
marginLeft: deep * 10 + 'px', |
|
|
|
|
|
'position': 'relative', |
|
|
|
|
|
zIndex: 10 |
|
|
|
|
|
}"> |
|
|
|
|
|
{{ data.title }} - {{ deep * 10 + 'px' }} |
|
|
|
|
|
</div> |
|
|
|
|
|
<NiuTreeDrag v-bind="props" :status="status" :style="{ |
|
|
|
|
|
marginLeft: deep * 10 + 'px', |
|
|
|
|
|
}"></NiuTreeDrag> |
|
|
|
|
|
</slot> |
|
|
</slot> |
|
|
</template> |
|
|
|
|
|
</node> |
|
|
|
|
|
</template> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script lang="ts" setup> |
|
|
<script lang="ts" setup> |
|
|
|
|
|
import node from './node.vue' |
|
|
|
|
|
import { inject, ref, provide, useSlots } from 'vue' |
|
|
import { isChildOf } from './util' |
|
|
import { isChildOf } from './util' |
|
|
import NiuTreeDrag from './tree-drag.vue'; |
|
|
import TreeDrag from './tree-drag.vue'; |
|
|
import { ENiuTreeStatus, INiuTreeData, INiuTreeKey } from './type'; |
|
|
import { ENiuTreeStatus, INiuTreeData, INiuTreeKey } from './type'; |
|
|
const props = withDefaults( |
|
|
const props = withDefaults( |
|
|
defineProps<{ |
|
|
defineProps<{ |
|
@ -61,6 +56,7 @@ const props = withDefaults( |
|
|
level: 0, |
|
|
level: 0, |
|
|
} |
|
|
} |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
const opts = inject("tree:opts", { |
|
|
const opts = inject("tree:opts", { |
|
|
justOpen: false |
|
|
justOpen: false |
|
|
}) |
|
|
}) |
|
@ -146,9 +142,3 @@ function onDragleave() { |
|
|
emit('onDragleave', props.data.key) |
|
|
emit('onDragleave', props.data.key) |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
<script lang="ts"> |
|
|
|
|
|
import { defineComponent, inject, ref, provide } from 'vue' |
|
|
|
|
|
export default defineComponent({ |
|
|
|
|
|
name: 'ps-tree-node', |
|
|
|
|
|
}) |
|
|
|
|
|
</script> |
|
|
|