From c98e45bfac25e9110ad0383faac54a54d98ea9d5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 18 十一月 2021 20:47:04 +0800 Subject: [PATCH] 2021-11-18 --- src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx | 63 +++++++++++++++---------------- 1 files changed, 31 insertions(+), 32 deletions(-) diff --git a/src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx b/src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx index 16da247..1fa8a7c 100644 --- a/src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx +++ b/src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx @@ -2,14 +2,12 @@ import { useDrop } from 'react-dnd' import { is, fromJS } from 'immutable' import update from 'immutability-helper' -import { Icon } from 'antd' +import { Icon, Popover } from 'antd' 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 [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 } }) @@ -99,17 +91,20 @@ let _colCards = [] // 杩囨护鍚堝苟鍒� - let _hideCol = [] + let _hideCol = [] + + if (!showfield) { cards.forEach(col => { if (col.type === 'colspan' && col.sublist) { _hideCol.push(...col.sublist) } }) - cards.forEach(col => { - if (_hideCol.includes(col.uuid)) return + } + cards.forEach(col => { + if (_hideCol.includes(col.uuid)) return - _colCards.push(col) - }) + _colCards.push(col) + }) // 鏄剧ず鍒楀垎琛� if (_colCards.length > 10) { @@ -146,20 +141,24 @@ delCard={delCard} markCard={markCard} findCard={findCard} - hasDrop={hasDrop} /> ))} {i === (columns.length - 1) && gridBtn && gridBtn.display ? - <div className="page-card" style={{flex: gridBtn.Width}}> - <div style={{cursor: 'default'}}> - <span className="ant-table-header-column"> - <div className="ant-table-column-sorters" title={gridBtn.label} style={{textAlign: gridBtn.Align}}> - <span className="ant-table-column-title">{gridBtn.label}</span> - </div> - </span> + <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}/> </div> - <Icon className="edit" type="edit" onClick={handleGridBtn}/> - </div> : null + } trigger="hover"> + <div className="page-card" style={{flex: gridBtn.Width}}> + <div style={{cursor: 'default'}}> + <span className="ant-table-header-column"> + <div className="ant-table-column-sorters" title={gridBtn.label} style={{textAlign: gridBtn.Align}}> + <span className="ant-table-column-title">{gridBtn.label}</span> + </div> + </span> + </div> + </div> + </Popover> : null } </div> ))} -- Gitblit v1.8.0