| | |
| | | import React from 'react' |
| | | import { useDrag, useDrop } from 'react-dnd' |
| | | import { Icon, Select, DatePicker, Input, InputNumber, Button, Popover, Switch, Radio, Checkbox, Form } from 'antd' |
| | | import { Select, DatePicker, Input, InputNumber, Button, Popover, Switch, Radio, Checkbox, Form } from 'antd' |
| | | import { QuestionCircleOutlined, UploadOutlined, EditOutlined, CopyOutlined, CloseOutlined } from '@ant-design/icons' |
| | | import moment from 'moment' |
| | | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | |
| | | } |
| | | |
| | | let formItem = null |
| | | let className = 'ant-form-item' |
| | | if (card.type === 'text') { |
| | | formItem = (<Input style={{marginTop: '4px'}} value={card.initval} />) |
| | | formItem = (<Input style={{marginTop: '4px'}} placeholder={card.placeholder || ''} value={card.initval} />) |
| | | } else if (card.type === 'number') { |
| | | formItem = (<InputNumber value={card.initval} precision={card.decimal} />) |
| | | } else if (card.type === 'multiselect' || card.type === 'select' || card.type === 'link') { |
| | |
| | | } else if (card.type === 'datetime') { |
| | | formItem = (<DatePicker showTime value={card.initval ? moment().subtract(card.initval, 'days') : null} />) |
| | | } else if (card.type === 'textarea') { |
| | | formItem = (<TextArea value={card.initval} autoSize={{ minRows: 2, maxRows: 6 }} />) |
| | | formItem = (<TextArea value={card.initval} placeholder={card.placeholder || ''} autoSize={{ minRows: 2, maxRows: 6 }} />) |
| | | } else if (card.type === 'brafteditor') { |
| | | formItem = (<Editor />) |
| | | } else if (card.type === 'fileupload') { |
| | | formItem = (<Button style={{marginTop: '3px'}}><Icon type="upload" /> 点击上传 </Button>) |
| | | formItem = (<Button style={{marginTop: '3px'}}><UploadOutlined /> 点击上传 </Button>) |
| | | } else if (card.type === 'funcvar') { |
| | | formItem = (<Input style={{marginTop: '4px'}} value={card.linkfield} />) |
| | | } else if (card.type === 'linkMain') { |
| | |
| | | } else if (card.type === 'split') { |
| | | formItem = <div className="split-line">{card.label}</div> |
| | | } else if (card.type === 'checkcard') { |
| | | formItem = <CheckCard width={card.width} ratio={card.ratio} display={card.display} fields={card.fields} options={card.options} /> |
| | | className += ' checkcard' |
| | | formItem = <CheckCard config={card} /> |
| | | } |
| | | |
| | | let _label = card.label |
| | | if (card.tooltip) { |
| | | _label = <span><Icon type="question-circle" />{card.label}</span> |
| | | _label = <span><QuestionCircleOutlined className="mk-form-tip" />{card.label}</span> |
| | | } |
| | | if (card.type === 'brafteditor' && card.hidelabel === 'true') { |
| | | _label = null |
| | |
| | | return ( |
| | | <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | | <div className="mk-popover-control"> |
| | | <Icon className="edit" type="edit" onClick={edit} /> |
| | | <Icon className="copy" type="copy" onClick={copy} /> |
| | | <Icon className="close" type="close" onClick={close} /> |
| | | <EditOutlined className="edit" onClick={edit} /> |
| | | <CopyOutlined className="copy" onClick={copy} /> |
| | | <CloseOutlined className="close" onClick={close} /> |
| | | </div> |
| | | } trigger="hover"> |
| | | <div className="page-card" style={{ opacity: opacity}}> |
| | | <div ref={node => drag(drop(node))}> |
| | | <div ref={node => drag(drop(node))} onDoubleClick={edit}> |
| | | {card.type === 'split' ? formItem : <Form.Item |
| | | className="ant-form-item" |
| | | className={className} |
| | | colon={!!_label} |
| | | label={_label} |
| | | required={card.required === 'true'} |
| | |
| | | wrapperCol={card.labelwidth ? {style: {width: (100 - card.labelwidth) + '%'}} : null} |
| | | > |
| | | {formItem} |
| | | {showField ? <div className="field-name">{card.field}</div> : ''} |
| | | {showField ? <div className="field-name">{card.field}{card.hidden === 'true' ? '(隐藏)' : ''}</div> : ''} |
| | | </Form.Item>} |
| | | </div> |
| | | </div> |