CardAdvBottom.ets 1.53 KB
import { CompDTO } from 'wdBean/Index';
import { DateTimeUtils, Logger } from 'wdKit/Index';
import PageModel from '../../viewmodel/PageModel';

/**
 * @Description: 广告稿件 底部标签+删除按钮
 * @Author:
 * @Email: liyubing@wondertek.com.cn
 * @CreateDate:
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
@Component
export struct CardAdvBottom {
  pageModel: PageModel = new PageModel();
  @State compDTO: CompDTO = {} as CompDTO

  build() {

    Row() {
      Text($r('app.string.comp_advertisement')).fontSize('12fp').fontColor($r('app.color.color_B0B0B0'))

      Blank()

      Stack() {
        Image($r('app.media.comp_adv_close'))
          .width(9)
          .height(9)
          .borderRadius({
            topLeft: '4vp',
            topRight: '4vp',
            bottomLeft: '4vp',
            bottomRight: '4vp'
          })
      }
      .width(18)
      .height(14)
      .borderWidth(0.5)
      .borderColor($r('app.color.color_EDEDED'))
      .borderRadius(4)

    }.width('100%').onClick(() => {

      this.delComp()
    })
  }
  /**
   * 删除稿件
   */
  private delComp() {
    if (this.pageModel) {

      let a = this.compDTO;
      let currentIndex = -1
      for (let i = 0; i < this.pageModel.compList.size(); i++) {
        let b = this.pageModel.compList.getData(i) as CompDTO
        if (a.compStyle === b.compStyle && a.matInfo === b.matInfo) {
          currentIndex = i
          break;
        }
      }
      if (currentIndex >= 0) {
        this.pageModel.compList.deleteItem(currentIndex)
      }
    }
  }
}