| | |
| | | import React from 'react' |
| | | import { useDrag, useDrop } from 'react-dnd' |
| | | import { Icon, Button, Select, DatePicker, Input } from 'antd' |
| | | import { Icon, Select, DatePicker, Input } from 'antd' |
| | | import moment from 'moment' |
| | | import ItemTypes from './itemtypes' |
| | | import './index.scss' |
| | | |
| | | const { MonthPicker, WeekPicker, RangePicker } = DatePicker |
| | | // const { Paragraph } = Typography |
| | | |
| | | const Card = ({ id, type, card, moveCard, findCard, editCard, delCard, copyCard, profileCard, hasDrop, showfield }) => { |
| | | const Card = ({ id, type, card, moveCard, findCard, editCard, delCard, hasDrop, showfield }) => { |
| | | const originalIndex = findCard(id).index |
| | | const [{ isDragging }, drag] = useDrag({ |
| | | item: { type: ItemTypes[type], id, originalIndex }, |
| | |
| | | delCard(id) |
| | | } |
| | | |
| | | const copy = () => { |
| | | copyCard(id) |
| | | } |
| | | |
| | | const profile = () => { |
| | | profileCard(id) |
| | | } |
| | | |
| | | let _defaultValue = '' // 下拉搜索、时间范围类型,初始值需要预处理 |
| | | |
| | | if (type === 'search' && (card.type === 'multiselect' || card.type === 'select' || card.type === 'link')) { |
| | |
| | | } catch { |
| | | _defaultValue = [null, null] |
| | | } |
| | | } |
| | | } |
| | | |
| | | let hasProfile = false |
| | | if (type === 'action') { |
| | | if (['pop', 'prompt', 'exec'].includes(card.OpenType)) { |
| | | hasProfile = true |
| | | } else if (card.OpenType === 'excelIn' || card.OpenType === 'excelOut') { |
| | | hasProfile = true |
| | | } else if (card.funcType === 'print') { |
| | | hasProfile = true |
| | | } |
| | | } |
| | | |
| | |
| | | </div> |
| | | </div> : null |
| | | } |
| | | {type === 'action' ? |
| | | <Button |
| | | className={'mk-btn mk-' + card.class} |
| | | icon={card.icon} |
| | | key={card.uuid} |
| | | > |
| | | {card.label}{card.position === 'grid' && <Icon type="table" />} |
| | | </Button> : null |
| | | } |
| | | {type === 'columns' ? |
| | | <span className="ant-table-header-column"> |
| | | <div className="ant-table-column-sorters" title={card.label} style={{textAlign: card.Align}}> |
| | |
| | | </div> |
| | | <Icon className="edit" title="编辑" type="edit" onClick={edit} /> |
| | | <Icon className="edit close" title="删除" type="close" onClick={del} /> |
| | | {type === 'action' ? <Icon className="edit copy" title="复制" type="copy" onClick={copy} /> : null} |
| | | {hasProfile ? <Icon className="edit profile" title="校验规则" type="profile" onClick={profile} /> : null} |
| | | </div> |
| | | ) |
| | | } |