import React, { createElement, useState, useEffect, Component } from 'react'; import { Button, Icon, Dialog, NumberPicker } from '@alifd/next'; import './index.scss' interface ColorDialogSetterProps { } const Divider = ()=>{ return
} const CircleBotton = ({type,onClick})=>{ return
} const ColorDialogSetter = (props)=>{ const { value , onChange } = props const [colors,setColors] = useState(value||[]) const [visible,setVisible] = useState(false) useEffect(()=>{ onChange(value||[]) },[]) // 添加一项 const pushColors = ()=>{ setColors([...colors,{start:null,end:null,color:'#ffffff'}]) } // 删除一项 const delColors = (index)=>{ const temp = colors.filter((_,i)=>i!==index) setColors(temp) } // 范围修改 const rangeChange = (value,index,type)=>{ let temp = JSON.parse(JSON.stringify(colors)) temp[index][type] = value setColors(temp) } // 颜色修改 const colorChange = (value,index)=>{ let temp = JSON.parse(JSON.stringify(colors)) temp[index].color = value.target.value setColors(temp) } // 确认提交 const submit = ()=>{ onChange(colors) setVisible(false) } return(
{colors.length>0?'已进行颜色范围配置':''} setVisible(false)} footerActions={['cancel', 'ok']} > {colors.map((e,i)=>
颜色范围 rangeChange(v,i,'start')} /> rangeChange(v,i,'end')} />
colorChange(v,i)} /> {e.color}
delColors(i)} />
)}
) } export default class extends Component { render() { return ; } }