From c7aece35a62b6e91fd98a625bf0e53f64bfbd18d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 17 八月 2023 16:22:15 +0800 Subject: [PATCH] 2023-08-17 --- src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx | 95 ++++++++++++++++++++++++++++++----------------- 1 files changed, 61 insertions(+), 34 deletions(-) diff --git a/src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx b/src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx index 3c608b0..267c6c4 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 } 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 }) => { - 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,6 +30,8 @@ const editCard = id => { const { card } = findCard(id) + delete card.focus // 鍏煎鏃╂湡鐨勫悎骞跺垪 + handleMenu(card) } @@ -39,9 +40,10 @@ const { card } = findCard(id) deleteMenu(card) } - - const hasDrop = (item) => { - target = item + + const markCard = id => { + const { card } = findCard(id) + markMenu(card) } const [, drop] = useDrop({ @@ -59,9 +61,10 @@ newcard.label = 'label' newcard.field = '' newcard.Hide = 'false' + 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 = [] @@ -69,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 } }) @@ -90,17 +92,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) { @@ -126,6 +131,23 @@ {i === 0 && column.length > 0 && setting.tableType === 'radio' ? <div className="page-card" style={{flex: 60}}></div> : null } + {i === 0 && gridBtn && gridBtn.display && gridBtn.position === 'left' ? + <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ + <div className="mk-popover-control"> + <EditOutlined className="edit" onClick={handleGridBtn}/> + </div> + } 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 + } {column.map(card => ( <Card key={card.uuid} @@ -135,28 +157,33 @@ moveCard={moveCard} editCard={editCard} 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> + {i === (columns.length - 1) && gridBtn && gridBtn.display && gridBtn.position !== 'left' ? + <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ + <div className="mk-popover-control"> + <EditOutlined className="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> ))} {cards.length === 0 ? <div className="common-drawarea-placeholder"> - {placeholder} + 璇锋坊鍔犳樉绀哄垪 </div> : null } </div> -- Gitblit v1.8.0