From 92224e3d5e03f223bf2fb4b0eb88b74e790d8da9 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 17 一月 2022 10:00:05 +0800 Subject: [PATCH] 2022-01-17 --- src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx | 36 ++++++++++++++---------------------- 1 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx b/src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx index 9969166..c364c6d 100644 --- a/src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx +++ b/src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx @@ -2,14 +2,13 @@ import { useDrop } from 'react-dnd' import { is, fromJS } from 'immutable' import update from 'immutability-helper' -import { Icon, Popover } from 'antd' +import { Popover } from 'antd' +import { EditOutlined } from '@ant-design/icons' import Utils from '@/utils/utils.js' import Card from './card' import './index.scss' -const Container = ({list, setting, gridBtn, showfield, placeholder, handleList, handleMenu, handleGridBtn, deleteMenu, markMenu }) => { - let target = null - +const Container = ({list, setting, gridBtn, showfield, handleList, handleMenu, handleGridBtn, deleteMenu, markMenu }) => { const [cards, setCards] = useState(list) const moveCard = (id, atIndex) => { const { card, index } = findCard(id) @@ -31,7 +30,6 @@ const editCard = id => { const { card } = findCard(id) - delete card.focus // 鍏煎鏃╂湡鐨勫悎骞跺垪 handleMenu(card) @@ -46,10 +44,6 @@ const markCard = id => { const { card } = findCard(id) markMenu(card) - } - - const hasDrop = (item) => { - target = item } const [, drop] = useDrop({ @@ -70,7 +64,7 @@ newcard.contrastType = 'static' newcard.IsSort = 'true' newcard.type = item.subType - newcard.Width = 120 + newcard.Width = item.subType === 'number' ? 80 : 120 if (item.subType === 'colspan') { newcard.sublist = [] newcard.subfield = [] @@ -78,20 +72,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,13 +142,12 @@ delCard={delCard} markCard={markCard} findCard={findCard} - hasDrop={hasDrop} /> ))} {i === (columns.length - 1) && gridBtn && gridBtn.display ? <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ <div className="mk-popover-control"> - <Icon className="edit" type="edit" onClick={handleGridBtn}/> + <EditOutlined className="edit" onClick={handleGridBtn}/> </div> } trigger="hover"> <div className="page-card" style={{flex: gridBtn.Width}}> @@ -174,7 +166,7 @@ {cards.length === 0 ? <div className="common-drawarea-placeholder"> - {placeholder} + 璇锋坊鍔犳樉绀哄垪 </div> : null } </div> -- Gitblit v1.8.0