From 407c0f1765c7d085218a91ad8842784977383d05 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 23 十月 2020 00:18:13 +0800 Subject: [PATCH] 2020-10-23 --- src/menu/components/tabs/tabcomponents/index.jsx | 26 ++++++++++---------------- 1 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/menu/components/tabs/tabcomponents/index.jsx b/src/menu/components/tabs/tabcomponents/index.jsx index b7613f6..2608e82 100644 --- a/src/menu/components/tabs/tabcomponents/index.jsx +++ b/src/menu/components/tabs/tabcomponents/index.jsx @@ -11,8 +11,6 @@ const { confirm } = Modal const Container = ({ config, handleList }) => { - let target = null - const [cards, setCards] = useState(config.components) const moveCard = (id, atIndex) => { const { card, index } = findCard(id) @@ -30,10 +28,6 @@ card, index: cards.indexOf(card), } - } - - const hasDrop = (item) => { - target = item } const updateConfig = (element) => { @@ -93,6 +87,7 @@ bar: '鏌辩姸鍥�', line: '鎶樼嚎鍥�', tabs: '鏍囩缁�', + pie: '楗煎浘', card: '鍗$墖' } let i = 1 @@ -111,25 +106,25 @@ parentId: config.parentId, type: item.component, subtype: item.subtype, + config: item.config, + width: item.width || 24, name: name, floor: config.floor ? (config.floor + 1) : 2, // 缁勪欢鐨勫眰绾� isNew: true // 鏂版坊鍔犳爣蹇楋紝鐢ㄤ簬鍒濆鍖� } - let targetId = cards.length > 0 ? cards[cards.length - 1].uuid : 0 - if (target) { - targetId = target.uuid + let targetId = '0' + + if (item.dropTargetId) { + targetId = 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({...config, components: _cards}) - target = null } }) @@ -144,7 +139,6 @@ moveCard={moveCard} delCard={deleteCard} findCard={findCard} - hasDrop={hasDrop} updateConfig={updateConfig} /> ))} -- Gitblit v1.8.0