<div class="site-page-header">
  <nz-page-header>
    <nz-breadcrumb nz-page-header-breadcrumb>
      <div class="back" (click)="back()">
        <span nz-icon nzType="left" nzTheme="outline"></span>返回
      </div>
    </nz-breadcrumb>
    <nz-page-header-title
      >{{ activity?.get("name") ? activity?.get("name") : "创建评委活动" }}
    </nz-page-header-title>
  </nz-page-header>
  <nz-tabset [(nzSelectedIndex)]="active">
    <nz-tab nzTitle="活动规则设置"> </nz-tab>
    <nz-tab nzTitle="评审明细"> </nz-tab>
  </nz-tabset>
</div>
<div class="edit-content">
  @if (active == 0) {
  <div class="basic">
    <div class="title" style="margin-top: 10px">基本信息</div>
    <ul nz-row nzJustify="space-between">
      <li nz-col nzSpan="11">
        <p>评审活动名称<span>*</span></p>
        <input
          nz-input
          placeholder="请输入评审活动名称"
          [(ngModel)]="name"
          type="text"
        />
      </li>
      <li nz-col nzSpan="11">
        <p>开始时间<span></span></p>
        <nz-date-picker
          nzShowTime
          nzFormat="yyyy-MM-dd HH:mm:ss"
          [(ngModel)]="startDate"
        ></nz-date-picker>
      </li>
      <li nz-col nzSpan="11">
        <p>结束时间<span></span></p>
        <nz-date-picker
          nzShowTime
          nzFormat="yyyy-MM-dd HH:mm:ss"
          [(ngModel)]="deadline"
        ></nz-date-picker>
      </li>
    </ul>

    <button (click)="save()" class="btn save" nz-button nzType="primary">
      保存
    </button>
    <button (click)="reset()" class="btn replay" nz-button nzType="primary">
      重置
    </button>
    <div class="title">评审规则</div>
    <ul nz-row nzJustify="space-between">
      <li nz-col nzSpan="11">
        <p>总分值计算方式<span>*</span></p>
        <nz-radio-group
          [(ngModel)]="calculation"
          (ngModelChange)="changeCalculation()"
        >
          <label nz-radio nzValue="mean">平均数</label>
          <label nz-radio nzValue="truncatedMean">截尾平均数</label>
        </nz-radio-group>
      </li>
      <li nz-col nzSpan="11">
        <p>评审细则</p>
        @if(reviewDetails?.url){
        <a target="_blank" [href]="reviewDetails?.url">
          <span nz-icon nzType="file" nzTheme="outline"></span>
          {{ reviewDetails?.name }}
        </a>
        }

        <div class="uploadBtn">
          <app-comp-upload
            [type]="'pdf'"
            (change)="upload($event)"
            title="上传评审细则文件"
          ></app-comp-upload>
        </div>
      </li>
    </ul>
    <div class="title">
      评审组
      <button
        (click)="creatReviewGroup()"
        class="btn replay"
        nz-button
        nzType="primary"
      >
        创建评审组
      </button>
    </div>
    @if (expertGroupList.length>0) {
    <div class="reviewGroup">
      @for (item of expertGroupList; track $index) {
      <div class="group-compl">
        <div>
          <div class="name">{{ item?.get("name") || "未命名" }}</div>
          <div class="row">
            <div class="lable">更新时间：</div>
            <div class="val">
              {{ item?.get("updatedAt") | date : "yyyy-MM-dd HH:mm:ss" }}
            </div>
          </div>
          <div class="row">
            <div class="lable">评审教材：</div>
            <div class="val">
              @for (booktext of item?.get('textbookList'); track booktext.id;let
              j = $index) { @if(j<5){
              {{ booktext?.get("title") + " " }}
              } } @if (item?.get('textbookList')?.length > 5){ 等{{
                item?.get("textbookList")?.length
              }}个 }
            </div>
          </div>
          <div class="row">
            <div class="lable">评审专家：</div>
            <div class="val">
              @for (p of item?.get('reviewList'); track p.id;let j = $index) {
              @if(j<5){
              {{ p?.get("user")?.get("name") + " " }}
              } } @if (item?.get('reviewList')?.length > 5){ 等{{
                item?.get("textbookList")?.length
              }}个 }
            </div>
          </div>
        </div>
        <div>
          <button
            class="btn replay"
            nz-button
            nzType="text"
            (click)="
              goUrl('/nav-province-contact/manage/review-edit/' + item.id)
            "
          >
            编辑</button
          ><br />
          <button
            (click)="deleteGroup($index)"
            nz-button
            nzType="text"
            nzDanger
          >
            删除
          </button>
        </div>
      </div>
      }
    </div>
    }@else {
    <nz-empty
      class="empty"
      nzNotFoundImage="simple"
      nzNotFoundContent="还没有评审组"
    ></nz-empty>
    }
  </div>
  } @else if (active == 1) {
  <app-review-details
    [listOfFilter]="listOfFilter"
    [filterObj]="filterObj"
  ></app-review-details>
  }
</div>

<div class="loading" [hidden]="!saveLoading">
  <nz-spin nzSimple [nzSize]="'large'"></nz-spin>
</div>
