From c8804ceb1fe2dea76f9949c5ea04423876ee2c81 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 28 六月 2024 14:02:47 +0800 Subject: [PATCH] 2024-06-28 --- src/menu/components/share/actioncomponent/dragaction/card.jsx | 81 ++++++++++++++++++++++++++++++---------- 1 files changed, 60 insertions(+), 21 deletions(-) diff --git a/src/menu/components/share/actioncomponent/dragaction/card.jsx b/src/menu/components/share/actioncomponent/dragaction/card.jsx index 88df555..5955f56 100644 --- a/src/menu/components/share/actioncomponent/dragaction/card.jsx +++ b/src/menu/components/share/actioncomponent/dragaction/card.jsx @@ -1,9 +1,13 @@ import React from 'react' import { useDrag, useDrop } from 'react-dnd' -import { Icon, Button, Popover } from 'antd' +import { Button, Popover } from 'antd' +import { CopyOutlined, EditOutlined, FontColorsOutlined, CloseOutlined, ProfileOutlined, WarningOutlined, DisconnectOutlined } from '@ant-design/icons' + +import MkIcon from '@/components/mk-icon' +import { resetStyle } from '@/utils/utils-custom.js' import './index.scss' -const Card = ({ id, card, moveCard, findCard, editCard, delCard, copyCard, changeStyle, profileCard, doubleClickCard }) => { +const Card = ({ id, card, type, moveCard, findCard, editCard, delCard, copyCard, changeStyle, profileCard, doubleClickCard }) => { const originalIndex = findCard(id).index const [{ isDragging }, drag] = useDrag({ item: { type: 'action', id, originalIndex }, @@ -14,66 +18,101 @@ const [, drop] = useDrop({ accept: 'action', canDrop: () => true, - drop: () => {}, - hover({ id: draggedId }) { + drop: ({ id: draggedId }) => { if (!draggedId || draggedId === id) return - const { index: originIndex } = findCard(id) + const { index: originIndex } = findCard(draggedId) if (originIndex === -1) return const { index: overIndex } = findCard(id) moveCard(draggedId, overIndex) }, }) - const opacity = isDragging ? 0 : 1 + const opacity = isDragging ? 0.5 : 1 let hasProfile = false + let forbidSql = false if (['pop', 'prompt', 'exec'].includes(card.OpenType)) { hasProfile = true + if (card.verify && card.verify.default === 'false') { + forbidSql = true + } } else if (card.OpenType === 'excelIn' || card.OpenType === 'excelOut') { hasProfile = true + if (card.verify && card.verify.default === 'false') { + forbidSql = true + } } else if (card.funcType === 'print') { + hasProfile = true + } else if (card.funcType === 'megvii') { + hasProfile = true + } else if (card.payMode === 'system') { hasProfile = true } let btnElement = null - if (card.show === 'icon') { + let _style = resetStyle(card.style) + let _class = '' + let show = card.show + if (type === 'datacard' || type === 'dualdatacard') { + _style = null + _class = 'swiper swiper-' + card.color + show = 'button' + } + if (card.hidden === 'true') { + _class += ' mk-hidden' + } + let warning = null + if (card.OpenType === 'innerpage' && !card.pageTemplate) { + warning = <WarningOutlined style={{color: 'orange', marginLeft: '5px'}}/> + } else if (forbidSql) { + warning = <DisconnectOutlined className="mk-disconnect"/> + } + + if (show === 'icon') { btnElement = ( <Button type="link" - icon={card.icon} - style={card.btnstyle} + style={_style} + className={_class} onDoubleClick={() => doubleClickCard(id)} - >{card.icon ? '' : card.label}</Button> + >{card.icon ? <MkIcon type={card.icon}/> : card.label}{warning}</Button> ) - } else if (card.show === 'link') { + } else if (show === 'link') { btnElement = ( <Button type="link" - style={card.btnstyle} + style={_style} + className={_class} onDoubleClick={() => doubleClickCard(id)} - >{card.label}{card.icon ? <Icon type={card.icon}/> : null}</Button> + >{card.label}{card.icon ? <MkIcon type={card.icon}/> : null}{warning}</Button> ) } else { btnElement = ( <Button - icon={card.icon} - style={card.btnstyle} + style={_style} + className={_class} onDoubleClick={() => doubleClickCard(id)} > - {card.label} + <MkIcon type={card.icon}/>{card.label}{warning} </Button> ) + } + + let updateTime = null + if (card.updateTime && card.updateTime.indexOf(window.GLOB.curDate) > -1) { + updateTime = card.updateTime.substr(11) } return ( <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ <div className="mk-popover-control"> - <Icon className="edit" title="缂栬緫" type="edit" onClick={() => editCard(id)} /> - <Icon className="copy" title="澶嶅埗" type="copy" onClick={() => copyCard(id)} /> - <Icon className="close" title="鍒犻櫎" type="close" onClick={() => delCard(id)} /> - <Icon className="style" title="璋冩暣鏍峰紡" onClick={() => changeStyle(id)} type="font-colors" /> - {hasProfile ? <Icon className="profile" title="楠岃瘉" type="profile" onClick={() => profileCard(id)} /> : null} + <EditOutlined className="edit" onClick={() => editCard(id)} /> + {!card.$fixed ? <CopyOutlined className="copy" onClick={() => copyCard(id)} /> : null} + {!card.$fixed ? <CloseOutlined className="close" onClick={() => delCard(id)} /> : null} + {type !== 'datacard' && type !== 'basetable' && !card.$fixed ? <FontColorsOutlined className="style" title="璋冩暣鏍峰紡" onClick={() => changeStyle(id)}/> : ''} + {hasProfile ? <ProfileOutlined className="profile" title="楠岃瘉" onClick={() => profileCard(id)} /> : null} + {updateTime} </div> } trigger="hover"> <div className="page-card" style={{ opacity: opacity}}> -- Gitblit v1.8.0