import React, { useEffect, useState } from 'react'; import t, { string } from 'prop-types'; import { IOTIconSliderProps } from './interface'; import './style/index.less'; const prefixCls = 'iot-icon-slider-out'; import Slider from '../IOTSlider/Slider/Slider'; import { typeConversion } from "../../base/utils"; import {dataSource} from "../sliderConfig"; import NormalIcon from '../../base/normalIcon'; const IOTIconSlider: React.FC = ({ streamId, title, streamName, subTitle, type, icon, min, max, intType = 'float', step, unit, disabled = false, unitdesc, curValue, leftIcon, rightIcon, startHandler = (val: any) => { }, endHandler = (val: any) => { }, ...rest }) => { const [currentValue, setcurrentValue] = useState(curValue); const onChange = (value: any) => { setcurrentValue(value); // console.log(value); }; useEffect(() => { setcurrentValue(typeConversion(type, curValue)); }, [curValue]) return (
{icon?.show && (
)}
{title}
{intType !== 'float' ? currentValue :Number.parseFloat(currentValue).toFixed(1)} {unit}
50 无极 否则 有极 isStep={Number.parseFloat(step) === 1 &&(Math.round((Number.parseFloat(max) - Number.parseFloat(min)) / Number.parseFloat(step)) >50) } dotsData={dataSource(min,max,step)} onchange={(val: any) => { // // console.log(val); const item = { streamId, value: intType !== 'float' ? val : val.toFixed(1), }; setcurrentValue(val); endHandler(item); }} move={(val: any) => { // // console.log(val); setcurrentValue(val); }} start={() => { startHandler('start'); }} >
); }; export default IOTIconSlider;