From 12c4dd8bb0bb4c523dcf2fbb81191a7f3556a430 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 15 一月 2020 12:50:22 +0800 Subject: [PATCH] 2020-01-15 --- src/templates/comtableconfig/tabdragelement/index.jsx | 15 ++++++--------- 1 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/templates/comtableconfig/tabdragelement/index.jsx b/src/templates/comtableconfig/tabdragelement/index.jsx index 5f50bde..0c9d518 100644 --- a/src/templates/comtableconfig/tabdragelement/index.jsx +++ b/src/templates/comtableconfig/tabdragelement/index.jsx @@ -1,6 +1,7 @@ import React, { useState } from 'react' import { useDrop } from 'react-dnd' import update from 'immutability-helper' +import { is, fromJS } from 'immutable' import { Tabs, Icon } from 'antd' import Utils from '@/utils/utils.js' import Card from './card' @@ -13,12 +14,13 @@ const [cards, setCards] = useState(list) const moveCard = (id, atIndex) => { const { card, index } = findCard(id) - if (!card) return - const _cards = update(cards, { $splice: [[index, 1], [atIndex, 0, card]] }) - setCards(_cards) handleList(type, _cards) + } + + if (!is(fromJS(cards), fromJS(list))) { + setCards(list) } const findCard = id => { @@ -58,15 +60,10 @@ const { index: overIndex } = findCard(`${targetId}`) let targetIndex = overIndex - // if (!target) { + targetIndex++ - // } - // if (targetIndex < 0) { - // targetIndex = 0 - // } const _cards = update(cards, { $splice: [[targetIndex, 0, newcard]] }) - setCards(_cards) handleList(type, _cards, newcard) target = null } -- Gitblit v1.8.0