|
|
@ -1,8 +1,8 @@ |
|
|
|
<template> |
|
|
|
<div class="ps-tree component" draggable="true" :style="{backgroundColor: isDrag?bg:''}" @dragover.prevent="onDragover2" |
|
|
|
<div class="ps-tree component" :style="{backgroundColor: isDrag?bg:''}" @dragover.prevent="onDragover2" |
|
|
|
@dragleave.stop="onDragleave2" @drop.stop="onDrop2"> |
|
|
|
<template v-for="(item, index) in sortedList" :key="item.key"> |
|
|
|
<node @onDragstart="onDragstart" @expand="onExpand" @onDragEnd="onDragEnd" @onDrop="onDrop" |
|
|
|
<node @onDragstart="onDragstart" @expand="onExpand" @onDragover="onDragover" @onDragoverSelf="onDragoverSelf" @onDragEnd="onDragEnd" @onDrop="onDrop" |
|
|
|
:data-source-key="dataSourceKey" :data="item" :list="sortedList" :level="level" |
|
|
|
@click="(item) => clickNode(item)" :bg="bg"> |
|
|
|
<template |
|
|
@ -136,8 +136,22 @@ function onDragstart(key: INiuTreeKey) { |
|
|
|
dataSourceKey.value = key |
|
|
|
emit("itemDragstart") |
|
|
|
} |
|
|
|
function onDragover(key: INiuTreeKey) { |
|
|
|
if (!props.sort) return |
|
|
|
if (!key) return |
|
|
|
let data = findByKey(key, props.list) |
|
|
|
if (isChild(key, props.list) && data.isFile) { |
|
|
|
isDrag.value = true |
|
|
|
}else{ |
|
|
|
isDrag.value = false |
|
|
|
} |
|
|
|
} |
|
|
|
function onDragoverSelf() { |
|
|
|
isDrag.value = false |
|
|
|
} |
|
|
|
function onDragEnd(key: INiuTreeKey) { |
|
|
|
dataSourceKey.value = undefined |
|
|
|
isDrag.value = false |
|
|
|
emit("itemDragend") |
|
|
|
} |
|
|
|
async function onDrop(key: INiuTreeKey, status?: ENiuTreeStatus) { |
|
|
@ -147,6 +161,7 @@ async function onDrop(key: INiuTreeKey, status?: ENiuTreeStatus) { |
|
|
|
let targetData = findByKey(key, props.list) |
|
|
|
const sourceKey = dataSourceKey.value; |
|
|
|
dataSourceKey.value = undefined |
|
|
|
isDrag.value = false |
|
|
|
switch (status) { |
|
|
|
case ENiuTreeStatus.DragInner: |
|
|
|
const parentData = findByKeyParent(key, props.list) |
|
|
|