| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Form, Row, Col, Input, Select, InputNumber } from 'antd' |
| | | import { Form, Row, Col, Input, Select, Radio, InputNumber } from 'antd' |
| | | |
| | | import ColorSketch from '@/mob/colorsketch' |
| | | |
| | |
| | | title = node.attrs.text.text || '' |
| | | } |
| | | |
| | | let fontSize = '' |
| | | if (node.attrs && node.attrs.text) { |
| | | fontSize = node.attrs.text.fontSize || 12 |
| | | } |
| | | |
| | | let fontFill = '' |
| | | if (node.attrs && node.attrs.text) { |
| | | fontFill = node.attrs.text.fill || '#262626' |
| | | } |
| | | |
| | | if (node.shape === 'edge') { |
| | | // let fontSize = 14 |
| | | // if (node.attrs && node.attrs.text) { |
| | | // fontSize = node.attrs.text.fontSize || 14 |
| | | // } |
| | | let stroke = '' |
| | | |
| | | if (node.attrs && node.attrs.body) { |
| | | stroke = node.attrs.body.stroke || '' |
| | | } |
| | | let fill = '' |
| | | |
| | | if (node.attrs && node.attrs.body) { |
| | | fill = node.attrs.body.fill || '' |
| | | if (node.attrs && node.attrs.line) { |
| | | stroke = node.attrs.line.stroke || '#A2B1C3' |
| | | } |
| | | |
| | | if (node.shape === 'edge') { |
| | | let strokeWidth = '' |
| | | |
| | | if (node.attrs && node.attrs.line) { |
| | | strokeWidth = node.attrs.line.strokeWidth || 2 |
| | | } |
| | | |
| | | let lineType = 'solid' |
| | | |
| | | if (node.attrs && node.attrs.line && node.attrs.line.strokeDasharray) { |
| | | lineType = 'dash' |
| | | } |
| | | |
| | | return [ |
| | | { |
| | | type: 'title', |
| | | label: '内容' |
| | | }, |
| | | { |
| | | type: 'text', |
| | | field: 'title', |
| | |
| | | initval: title |
| | | }, |
| | | { |
| | | type: 'color', |
| | | field: 'fill', |
| | | label: '背景', |
| | | initval: fill |
| | | type: 'title', |
| | | label: '样式' |
| | | }, |
| | | { |
| | | type: 'color', |
| | | field: 'stroke', |
| | | label: '边框', |
| | | label: '颜色', |
| | | initval: stroke |
| | | }, |
| | | { |
| | | type: 'number', |
| | | field: 'fontSize', |
| | | label: '字号', |
| | | initval: fontSize |
| | | field: 'strokeWidth', |
| | | label: '线宽', |
| | | initval: strokeWidth |
| | | }, |
| | | { |
| | | type: 'color', |
| | | field: 'fontFill', |
| | | label: '颜色', |
| | | initval: fontFill |
| | | } |
| | | type: 'radio', |
| | | field: 'lineType', |
| | | label: '线型', |
| | | initval: lineType, |
| | | options: [ |
| | | {value: 'solid', text: '实线'}, |
| | | {value: 'dash', text: '虚线'} |
| | | ] |
| | | }, |
| | | // { |
| | | // type: 'number', |
| | | // field: 'fontSize', |
| | | // label: '字号', |
| | | // initval: fontSize |
| | | // }, |
| | | // { |
| | | // type: 'color', |
| | | // field: 'fontFill', |
| | | // label: '颜色', |
| | | // initval: fontFill |
| | | // } |
| | | ] |
| | | } else { |
| | | let fontFill = '#262626' |
| | | if (node.attrs && node.attrs.text) { |
| | | fontFill = node.attrs.text.fill || '#262626' |
| | | } |
| | | |
| | | let fill = '' |
| | | |
| | | if (node.attrs && node.attrs.body) { |
| | | fill = node.attrs.body.fill || '' |
| | | } |
| | | let fontSize = 12 |
| | | if (node.attrs && node.attrs.text) { |
| | | fontSize = node.attrs.text.fontSize || 12 |
| | | } |
| | | let stroke = '' |
| | | |
| | | if (node.attrs && node.attrs.body) { |
| | | stroke = node.attrs.body.stroke || '' |
| | | } |
| | | return [ |
| | | { |
| | | type: 'title', |
| | |
| | | } |
| | | |
| | | change = (value, key) => { |
| | | if (key === 'title') { |
| | | |
| | | } else if (key === 'fill') { |
| | | |
| | | } else if (key === 'stroke') { |
| | | |
| | | } else if (key === 'fontSize') { |
| | | if (key === 'fontSize') { |
| | | if (typeof(value) !== 'number' || value < 0) { |
| | | return |
| | | } |
| | | } else if (key === 'fontFill') { |
| | | |
| | | } |
| | | |
| | | this.props.onChange(value, key) |
| | |
| | | <Form.Item label={item.label}> |
| | | <Select |
| | | showSearch |
| | | defaultValue={item.initval} |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | onChange={(value) => {this.change(value, item.field)}} |
| | | > |
| | | {item.options.map(option => |
| | | <Select.Option id={option.MenuID} title={option.text} key={option.MenuID} value={option.MenuID}> |
| | | <Select.Option key={option.value} value={option.value}> |
| | | {option.text} |
| | | </Select.Option> |
| | | )} |
| | |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'radio') { |
| | | fields.push( |
| | | <Col span={24} key={index}> |
| | | <Form.Item label={item.label}> |
| | | <Radio.Group defaultValue={item.initval} style={{whiteSpace: 'nowrap'}} onChange={(e) => {this.change(e.target.value, item.field)}}> |
| | | {item.options.map(option => { |
| | | return ( |
| | | <Radio key={option.value} value={option.value}>{option.text}</Radio> |
| | | ) |
| | | })} |
| | | </Radio.Group> |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'color') { |
| | | fields.push( |
| | | <Col span={24} key={index}> |