From 37a134bd23ec4b227a0e010b08a1a89c2bbaaa0d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 03 十一月 2020 17:10:14 +0800 Subject: [PATCH] 2020-11-03 --- src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx | 25 ++++++++----------------- 1 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx b/src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx index 9969166..1fa8a7c 100644 --- a/src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx +++ b/src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx @@ -8,8 +8,6 @@ import './index.scss' const Container = ({list, setting, gridBtn, showfield, placeholder, handleList, handleMenu, handleGridBtn, deleteMenu, markMenu }) => { - let target = null - const [cards, setCards] = useState(list) const moveCard = (id, atIndex) => { const { card, index } = findCard(id) @@ -31,7 +29,6 @@ const editCard = id => { const { card } = findCard(id) - delete card.focus // 鍏煎鏃╂湡鐨勫悎骞跺垪 handleMenu(card) @@ -46,10 +43,6 @@ const markCard = id => { const { card } = findCard(id) markMenu(card) - } - - const hasDrop = (item) => { - target = item } const [, drop] = useDrop({ @@ -78,20 +71,19 @@ newcard.order = 'vertical' } - let targetId = cards.length > 0 ? cards[cards.length - 1].uuid : 0 - if (target) { - targetId = target.uuid + let targetId = '' + + if (item.dropTargetId) { + targetId = item.dropTargetId + delete item.dropTargetId + } else if (cards.length > 0) { + targetId = cards[cards.length - 1].uuid } const { index: overIndex } = findCard(`${targetId}`) - let targetIndex = overIndex - - targetIndex++ - - const _cards = update(cards, { $splice: [[targetIndex, 0, newcard]] }) + const _cards = update(cards, { $splice: [[overIndex + 1, 0, newcard]] }) handleList(_cards, newcard) - target = null } }) @@ -149,7 +141,6 @@ delCard={delCard} markCard={markCard} findCard={findCard} - hasDrop={hasDrop} /> ))} {i === (columns.length - 1) && gridBtn && gridBtn.display ? -- Gitblit v1.8.0