import React, { useState, useEffect, useRef } from 'react'; import Icon from '../../Icon/index'; import { Input } from 'antd'; import '../g.scss'; import defaultImg from './story_default.svg'; function CockpitList(props: ICockpitList) { const { cockpitList, change, value } = props; const { data, total } = cockpitList; const [inputValue, setInputValue] = useState(''); //Input的value const inputRef = useRef(null); return (
} onChange={(e) => setInputValue(e.target.value)} onPressEnter={() => { inputRef?.current?.blur(); }} onBlur={(e) => change?.({ type: 'searchCockpit', value: e.target.value }) } />
    {data?.length > 0 && data?.map((item) => { return (
  • change?.({ type: 'targetCockpit', value: item?.reportId }) } className={`zl-lagre-screen-cockpit-list-data ${ value === item?.reportId ? 'active' : '' }`} title={item?.name} > {item?.name}

    {item?.name}

  • ); })}
  • {data?.length >= total ? (

    已加载全部数据

    ) : (

    change({ type: 'getMoreCockpit', value: inputValue }) } > 加载更多

    )}
); } export default CockpitList; export interface ICockpitList { value: ''; cockpitList: ICockpitObj; change: Function; } export interface ICockpitObj { total: number; data: cockpitData[]; } export interface cockpitData { autoCoverPicUrl: string; reportId: string | number; name?: string; }