LabelComp.ets 1.29 KB
/**
 * 主界面更多,按钮Comp
 */
import { CompDTO } from '../bean/CompDTO';
import { LabelBean } from '../bean/LabelBean';
import { NetDataStatusType } from '../enum/NetDataStatusType';
import { DataFromExtraComp } from './DataFromExtraComp';
import List from '@ohos.util.List';
import { LabelDTO } from '../bean/LabelDTO';
import { ExtraDTO } from '../bean/ExtraDTO';
import { WDGroup } from './WDGroup';

export class LabelComp extends DataFromExtraComp<LabelBean> {
  constructor(parent: WDGroup, compDTO: CompDTO, initParams: Map<string, Object>) {
    super(parent, compDTO, initParams);
    this.status = NetDataStatusType.LOADED
  }

  public getItems(): List<LabelBean> {
    return this.items;
  }

  protected convertDto2Vo(extraDataDTO: ExtraDTO): List<LabelBean> {
    if (!extraDataDTO) {
      return new List<LabelBean>();
    }
    let beanList: List<LabelBean> = new List<LabelBean>();
    // let dtoArray: LabelDTO[] | undefined = extraDataDTO["labels"]
    let dtoArray: LabelDTO[]  | undefined= extraDataDTO.labels
    if (!dtoArray) {
      return new List<LabelBean>();
    }
    for (let index = 0; index < dtoArray.length; index = index + 1) {
      let dto: LabelDTO = dtoArray[index];
      let bean: LabelBean = new LabelBean(dto);
      beanList.add(bean);
    }
    return beanList;
  }
}