import React from 'react'; import './nodetype.less'; import { Select, Form, InputNumber, Radio, Row, Col } from 'antd'; export interface LabeledValue { key?: string; value: string; label: React.ReactNode; } export interface IProps { onChangeDataType?: ((value: string, option: object) => void) | undefined; optionlist?: Array; optionvalue?: string; placeholder?: string | React.ReactNode; onChange?: (option: object) => void; dataJson?: any; disabled?: boolean; } const NodeType: React.FC = (props: IProps) => { const { Option } = Select; const { onChangeDataType, onChange, optionlist, optionvalue, placeholder, dataJson, disabled, } = props; const { maxlength, datetype, format, precision, min, max, styletype, } = dataJson; const handleChange = (value: string) => { let jsons: any = { text: { maxlength: 50, textvalue: `${value}(50)` }, date: { datetype: 'current', format: 'YYYY-MM-DD HH:mm:ss', textvalue: `${value}(current, YYYY-MM-DD HH:mm:ss)`, }, number: { precision: 2, min: 0, max: 999999, textvalue: `${value}(2,0,999999)`, }, images: { min: 0, max: 6, textvalue: `${value}(0,6)` }, radio: { styletype: 'radio', textvalue: `${value}(radio)` }, checkbox: { styletype: 'checkbox', min: 0, max: 2, textvalue: `${value}(checkbox,0,2)`, }, richtext: { maxlength: 50, textvalue: `${value}(50)` }, }; let option: object = jsons[value]; if (onChangeDataType) onChangeDataType(value, option); }; const handleChange2 = (type: string, e: any) => { let value = null; if (type === 'datetype' || type === 'styletype') value = e.target.value; else value = e; let newdata = dataJson; delete newdata.textvalue; newdata[type] = value; let newtextvalue = ''; let textvaluearray: Array<{}> = []; for (let key in newdata) { textvaluearray.push(newdata[key]); } newtextvalue = `${optionvalue}(${textvaluearray.join(',')})`; let option: Object = { ...newdata, textvalue: newtextvalue }; if (onChange) onChange(option); }; function getviews() { let views =
; switch (optionvalue) { case 'text': views = ( ); break; case 'date': views = ( <> 当前日期 指定日期 ); break; case 'number': views = ( <> ); break; case 'images': views = ( <> ); break; case 'checkbox': views = ( <> 多选框 下拉多选 树选择 ); break; case 'radio': views = ( <> 单选框 下拉单选 级联选择 ); break; case 'richtext': views = ( <> ); break; } return views; } return (
{optionvalue && optionvalue !== ' ' ? (
{getviews()}
) : null}
); }; export default NodeType;