import React, { useEffect, useState } from 'react'; import { IOTCordEntryNumberProps } from './interface'; import IOTBottomSlide from '../../common/IOTBottomSlide/index' import IOTNumberSlider from './IOTNumberSlider/index'; import {dataSource} from "../sliderConfig"; import './style/index.less'; import { typeConversion } from '../../base/utils'; const prefixCls = 'iot-cord-entry-number-out'; const IOTCordEntryNumber: React.FC = ({ title, streamId, type, streamName, curValue, subTitle, unit, icon, min, intType = 'float', max, step, disabled = false, handler, startHandler = (val: any) => { }, endHandler = (val: any) => { }, unitdesc, ...rest }) => { const [currentValue, setcurrentValue] = useState(0); const [btmSlider, setBtmSlider] = useState(false); const [tempValue, setTempValue] = useState(Number(curValue)); const onChange = (value: any) => { setcurrentValue(value); // console.log(value); }; const [btmBarType, setBtmBarType] = useState('com'); // com // show useEffect(() => { if (!btmSlider) { setcurrentValue(Number.parseFloat(typeConversion(type, curValue))); } }, [curValue, btmSlider]); return ( <>
{ icon?.show && (
) }
{title}
{ subTitle?.show && (
{subTitle['value']}
) }
{ }}>
{ setBtmSlider(true); }}>
{curValue}{unit}
{disabled && (
)}
{ // console.log(val); if(val){ const item = { streamId, value: intType !== 'float' ? tempValue : tempValue.toFixed(1), }; handler && handler(item); }else{ setTempValue(Number(curValue)); } setBtmSlider(false); }} leftText='取消' rightText='确定' title={title}> 50) } showHandleBtn={false} curValue={currentValue +''} dotsData={dataSource(min, max, step)} disabled={false} onchange={(val: any) => { setTempValue(val); // // console.log(val); // const item = { // streamId, // value: intType !== 'float' ? val : val.toFixed(1), // }; // handler && handler(item); }} move={(val: any) => { // console.log(val); // setcurrentValue(val); }} start={() => { // startHandler('start'); }} / > ); }; export default IOTCordEntryNumber;