/** * @description 数字输入框和slider滑动条绑定 * * @date 创建时间 2022-10-27 15:33 * @author 开发人员 yena */ import React, { forwardRef, ForwardedRef } from "react"; import { PlaceOrderInput } from "../PlaceOrderInput"; import { OrderTypeEnum } from "@shared/types"; import { SuffixPrice } from "./SuffixPrice"; export interface PriceInputProps { scale?: number; step?: number; error?: boolean; value?: any; orderType: OrderTypeEnum; quote: string; lastPrice?: string; name?: any; onChangePriceInput: (val: string, focus: any) => void; triggerTypeChange: (type: OrderTypeEnum) => void; optimumLevel?: number | string; } export const PriceInput = forwardRef((props: PriceInputProps, ref: ForwardedRef) => { const { orderType, lastPrice, quote, optimumLevel = 5 } = props; const onChangePriceInput = (val: string, focus?: boolean) => { props.onChangePriceInput?.(val, focus); }; return orderType === OrderTypeEnum.Market ? ( <> ) : ( onChangePriceInput?.(lastPrice ?? "", true)} condition={orderType === OrderTypeEnum.TriggerLimit || orderType === OrderTypeEnum.TriggerMarket} triggerValue={orderType} onTriggerTypeChange={props.triggerTypeChange} /> } centerAdornment={
{orderType === OrderTypeEnum.TriggerMarket ? `最优${optimumLevel}档` : ""}
} limitInputStep={true} scale={props.scale} step={props.step} error={props.error} /> ); });