| | |
| | | import React from 'react' |
| | | import { useDrag, useDrop } from 'react-dnd' |
| | | import { Icon, Button, Select, DatePicker, Input, InputNumber } from 'antd' |
| | | import { Icon, Button, Select, DatePicker, Input, InputNumber, Popover } from 'antd' |
| | | import moment from 'moment' |
| | | import ItemTypes from './itemtypes' |
| | | import './index.scss' |
| | |
| | | } |
| | | |
| | | return ( |
| | | <div className="page-card" style={{ opacity: opacity}}> |
| | | <div ref={node => drag(drop(node))}> |
| | | {type === 'search' ? |
| | | <div className="ant-row ant-form-item"> |
| | | <div className={'ant-col ant-form-item-label ant-col-xs-24 ' + labelCol}> |
| | | <label title={card.label}>{card.label}</label> |
| | | <Icon className="edit" title="编辑" type="edit" onClick={edit} /> |
| | | <Icon className="edit copy" title="复制" type="copy" onClick={copy} /> |
| | | <Icon className="edit close" title="删除" type="close" onClick={del} /> |
| | | </div> |
| | | <div className={'ant-col ant-form-item-control-wrapper ant-col-xs-24 ' + wrapCol}> |
| | | {card.type === 'text' ? |
| | | <Input style={{marginTop: '4px'}} defaultValue={card.initval} /> : null |
| | | } |
| | | {card.type === 'number' ? |
| | | <InputNumber defaultValue={card.initval} precision={card.decimal} /> : null |
| | | } |
| | | {(card.type === 'multiselect' || card.type === 'select' || card.type === 'link') ? |
| | | <Select defaultValue={_defaultValue}></Select> : null |
| | | } |
| | | {card.type === 'date' ? |
| | | <DatePicker defaultValue={card.initval ? moment().subtract(card.initval, 'days') : null} /> : null |
| | | } |
| | | {card.type === 'datemonth' ? |
| | | <MonthPicker defaultValue={card.initval ? moment().subtract(card.initval, 'month') : null} /> : null |
| | | } |
| | | {card.type === 'datetime' ? |
| | | <DatePicker showTime defaultValue={card.initval ? moment().subtract(card.initval, 'days') : null} /> : null |
| | | } |
| | | {card.type === 'textarea' ? |
| | | <TextArea defaultValue={card.initval} autosize={{ minRows: 2, maxRows: 6 }} /> : null |
| | | } |
| | | {card.type === 'funcvar' && |
| | | <Input style={{marginTop: '4px'}} defaultValue={card.linkfield} /> |
| | | } |
| | | {card.type === 'fileupload' ? |
| | | <Button> |
| | | <Icon type="upload" /> 点击上传 |
| | | </Button> : null |
| | | } |
| | | <div className="input-mask"></div> |
| | | </div> |
| | | </div> : null |
| | | <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={edit} /> |
| | | {type === 'search' ? <Icon className="edit copy" title="复制" type="copy" onClick={copy} /> : null} |
| | | {type === 'action' && card.btnType !== 'cancel' ? |
| | | <Icon className="edit profile" title="校验规则" type="profile" onClick={profile} /> : 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 === 'search' || (type === 'action' && card.btnType !== 'confirm' && card.btnType !== 'cancel') ? <Icon className="edit close" title="删除" type="close" onClick={del} /> : null} |
| | | </div> |
| | | {type === 'action' ? <Icon className="edit" title="编辑" type="edit" onClick={edit} /> : null} |
| | | {type === 'action' && card.btnType !== 'cancel' ? |
| | | <Icon className="edit profile" title="校验规则" type="profile" onClick={profile} /> : null |
| | | } |
| | | {type === 'action' && card.btnType !== 'confirm' && card.btnType !== 'cancel' && <Icon className="edit close" title="删除" type="close" onClick={del} />} |
| | | </div> |
| | | } trigger="hover"> |
| | | <div className="page-card" style={{ opacity: opacity}}> |
| | | <div ref={node => drag(drop(node))}> |
| | | {type === 'search' ? |
| | | <div className="ant-row ant-form-item"> |
| | | <div className={'ant-col ant-form-item-label ant-col-xs-24 ' + labelCol}> |
| | | <label title={card.label}>{card.label}</label> |
| | | </div> |
| | | <div className={'ant-col ant-form-item-control-wrapper ant-col-xs-24 ' + wrapCol}> |
| | | {card.type === 'text' ? |
| | | <Input style={{marginTop: '4px'}} defaultValue={card.initval} /> : null |
| | | } |
| | | {card.type === 'number' ? |
| | | <InputNumber defaultValue={card.initval} precision={card.decimal} /> : null |
| | | } |
| | | {(card.type === 'multiselect' || card.type === 'select' || card.type === 'link') ? |
| | | <Select defaultValue={_defaultValue}></Select> : null |
| | | } |
| | | {card.type === 'date' ? |
| | | <DatePicker defaultValue={card.initval ? moment().subtract(card.initval, 'days') : null} /> : null |
| | | } |
| | | {card.type === 'datemonth' ? |
| | | <MonthPicker defaultValue={card.initval ? moment().subtract(card.initval, 'month') : null} /> : null |
| | | } |
| | | {card.type === 'datetime' ? |
| | | <DatePicker showTime defaultValue={card.initval ? moment().subtract(card.initval, 'days') : null} /> : null |
| | | } |
| | | {card.type === 'textarea' ? |
| | | <TextArea defaultValue={card.initval} autosize={{ minRows: 2, maxRows: 6 }} /> : null |
| | | } |
| | | {card.type === 'funcvar' && |
| | | <Input style={{marginTop: '4px'}} defaultValue={card.linkfield} /> |
| | | } |
| | | {card.type === 'fileupload' ? |
| | | <Button> |
| | | <Icon type="upload" /> 点击上传 |
| | | </Button> : null |
| | | } |
| | | <div className="input-mask"></div> |
| | | </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 |
| | | } |
| | | </div> |
| | | </div> |
| | | </Popover> |
| | | ) |
| | | } |
| | | export default Card |