| | |
| | | import React from 'react' |
| | | import { useDrag, useDrop } from 'react-dnd' |
| | | import { Select, DatePicker, Input, InputNumber, Button, Popover, Switch, Radio, Checkbox, Form, Rate } from 'antd' |
| | | import { QuestionCircleOutlined, UploadOutlined, EditOutlined, CopyOutlined, CloseOutlined, StarFilled } from '@ant-design/icons' |
| | | import { QuestionCircleOutlined, UploadOutlined, EditOutlined, CopyOutlined, CloseOutlined, StarFilled, FontColorsOutlined } from '@ant-design/icons' |
| | | import moment from 'moment' |
| | | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import MkIcon from '@/components/mk-icon' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import './index.scss' |
| | | |
| | | const { MonthPicker } = DatePicker |
| | |
| | | copyCard(id) |
| | | } |
| | | |
| | | const changeStyle = () => { |
| | | let options = ['font'] |
| | | |
| | | MKEmitter.emit('changeStyle', ['form', card.uuid], options, card.style || {}) |
| | | } |
| | | |
| | | let selectval = '' |
| | | if (card.type === 'multiselect' || card.type === 'select' || card.type === 'link') { |
| | | if (card.initval) { |
| | |
| | | } else if (card.type === 'color') { |
| | | formItem = (<ColorSketch value={card.initval || 'transparent'}/>) |
| | | } else if (card.type === 'date') { |
| | | formItem = (<DatePicker value={card.initval ? moment().subtract(card.initval, 'days') : null} />) |
| | | let format = 'YYYY-MM-DD' |
| | | if (card.precision === 'hour') { |
| | | format = 'YYYY-MM-DD HH' |
| | | } else if (card.precision === 'minute') { |
| | | format = 'YYYY-MM-DD HH:mm' |
| | | } else if (card.precision === 'second') { |
| | | format = 'YYYY-MM-DD HH:mm:ss' |
| | | } |
| | | formItem = (<DatePicker format={format} value={card.initval ? moment().subtract(card.initval, 'days') : null} />) |
| | | } else if (card.type === 'datemonth') { |
| | | formItem = (<MonthPicker value={card.initval ? moment().subtract(card.initval, 'month') : null} />) |
| | | } else if (card.type === 'datetime') { |
| | | formItem = (<DatePicker showTime value={card.initval ? moment().subtract(card.initval, 'days') : null} />) |
| | | formItem = (<DatePicker format='YYYY-MM-DD HH:mm:ss' value={card.initval ? moment().subtract(card.initval, 'days') : null} />) |
| | | } else if (card.type === 'textarea') { |
| | | formItem = (<TextArea value={card.initval} placeholder={card.placeholder || ''} autoSize={{ minRows: 2, maxRows: 6 }} />) |
| | | } else if (card.type === 'brafteditor') { |
| | |
| | | <Checkbox value="D">D</Checkbox> |
| | | </Checkbox.Group>) |
| | | } else if (card.type === 'hint') { |
| | | formItem = <div style={{marginTop: '10px', color: 'rgba(0, 0, 0, 0.85)', lineHeight: '1.5'}}>{card.message}</div> |
| | | formItem = <div style={{marginTop: '10px', color: 'rgba(0, 0, 0, 0.85)', lineHeight: '1.5', ...card.style}}>{card.message}</div> |
| | | } else if (card.type === 'split') { |
| | | formItem = <div className="split-line">{card.label}</div> |
| | | formItem = <div className="split-line" style={card.style}>{card.label}</div> |
| | | } else if (card.type === 'checkcard') { |
| | | className += ' checkcard' |
| | | formItem = <CheckCard config={card} /> |
| | | } |
| | | |
| | | let _label = card.label |
| | | let colon = !!card.label |
| | | let _label = <span className="mk-form-label" style={card.style}>{card.label}</span> |
| | | |
| | | if (card.tooltip) { |
| | | _label = <span><QuestionCircleOutlined className="mk-form-tip" />{card.label}</span> |
| | | _label = <><QuestionCircleOutlined className="mk-form-tip" /><span className="mk-form-label" style={card.style}>{card.label}</span></> |
| | | } |
| | | if (card.type === 'brafteditor' && card.hidelabel === 'true') { |
| | | _label = null |
| | | colon = false |
| | | } else if (card.type === 'hint') { |
| | | _label = _label || ' ' |
| | | } else if (card.type === 'hint' && !card.label) { |
| | | _label = ' ' |
| | | } |
| | | |
| | | return ( |
| | |
| | | <div className="mk-popover-control"> |
| | | <EditOutlined className="edit" onClick={edit} /> |
| | | <CopyOutlined className="copy" onClick={copy} /> |
| | | <FontColorsOutlined className="style" onClick={changeStyle} /> |
| | | <CloseOutlined className="close" onClick={close} /> |
| | | </div> |
| | | } trigger="hover"> |
| | |
| | | <div ref={node => drag(drop(node))} onDoubleClick={edit}> |
| | | {card.type === 'split' ? formItem : <Form.Item |
| | | className={className} |
| | | colon={colon} |
| | | colon={false} |
| | | label={_label} |
| | | required={card.required === 'true'} |
| | | extra={card.extra || null} |
| | |
| | | wrapperCol={card.labelwidth ? {style: {width: (100 - card.labelwidth) + '%'}} : null} |
| | | > |
| | | {formItem} |
| | | <div></div> |
| | | {showField ? <div className="field-name" style={card.writein === 'false' ? {color: 'orange'} : {}}> |
| | | {card.field}{card.hidden === 'true' ? '(隐藏)' : ''}{card.readonly === 'true' ? '(只读)' : ''} |
| | | {card.field}{card.hidden === 'true' || card.type === 'funcvar' ? '(隐藏)' : ''}{card.readonly === 'true' ? '(只读)' : ''}{card.linkField ? <span style={{color: '#1890ff'}}>{`(关联${card.linkField})`}</span> : ''}{card.supField ? <span style={{color: '#8E44AD'}}>{`(上级${card.supField})`}</span> : ''} |
| | | </div> : ''} |
| | | </Form.Item>} |
| | | </div> |