<!-- 表格头部 -->
@if (!isEdit) {
<nz-page-header nzTitle="创建新合集">
  <nz-breadcrumb nz-page-header-breadcrumb>
    <nz-breadcrumb-item>创建合集</nz-breadcrumb-item>
    <nz-breadcrumb-item><a>报送合集</a></nz-breadcrumb-item>
  </nz-breadcrumb>
</nz-page-header>
}
<div class="content" [style.padding]="isEdit ? '0' : '0 24px 16px'">
  <form
    nz-form
    [formGroup]="validateForm"
    class="login-form"
    (ngSubmit)="submitForm('save')"
  >
    <div class="title">基本信息</div>
    <div class="fill-template">
      <div nz-row>
        <div nz-col nzSpan="12">
          <nz-form-item class="row" style="margin-bottom: 16px">
            <nz-form-label
              class="label"
              [nzNoColon]="true"
              [nzSm]="18"
              [nzXs]="18"
              nzRequired
              >合集名称</nz-form-label
            >
            <nz-form-control
              class="val"
              nzErrorTip="请填写合集名称"
              style="width: 100%"
            >
              <nz-input-group
                [nzAddOnAfter]="validateForm.value.name.length + '/' + 50"
              >
                <input
                  nz-input
                  type="text"
                  placeholder="请填写合集名称"
                  formControlName="name"
                  nzStatus=""
                  maxlength="50"
                />
              </nz-input-group>
            </nz-form-control>
          </nz-form-item>
        </div>
        <div nz-col nzSpan="12">
          <nz-form-item class="row" style="margin-bottom: 16px">
            <nz-form-label
              class="label"
              [nzNoColon]="true"
              [nzSm]="18"
              [nzXs]="18"
              nzRequired
              >合集描述</nz-form-label
            >
            <nz-form-control
              class="val"
              nzErrorTip="请填写合集描述"
              style="width: 100%"
            >
              <nz-input-group
                [nzAddOnAfter]="validateForm.value.desc.length + '/' + 50"
              >
                <input
                  nz-input
                  type="text"
                  placeholder="请填合集描述"
                  formControlName="desc"
                  nzStatus=""
                  maxlength="50"
                />
              </nz-input-group>
            </nz-form-control>
          </nz-form-item>
        </div>
      </div>
      <div nz-row>
        <div nz-col nzSpan="12">
          <nz-form-item class="row" style="margin-bottom: 16px">
            <nz-form-label
              class="label"
              [nzNoColon]="true"
              [nzSm]="18"
              [nzXs]="18"
              nzRequired
              >合集code</nz-form-label
            >
            <nz-form-control
              class="val"
              nzErrorTip="请填写合集code"
              style="width: 100%"
            >
              <nz-input-group
                [nzAddOnAfter]="validateForm.value.code.length + '/' + 50"
              >
                <input
                  nz-input
                  type="text"
                  placeholder="请填写合集code"
                  formControlName="code"
                  nzStatus=""
                  maxlength="50"
                />
              </nz-input-group>
            </nz-form-control>
          </nz-form-item>
        </div>
        <div nz-col nzSpan="12">
          @if (isEdit) {
          <nz-form-item class="row" style="margin-bottom: 16px">
            <nz-form-label
              class="label"
              [nzNoColon]="true"
              [nzSm]="18"
              [nzXs]="18"
              nzRequired
              >流程数量</nz-form-label
            >
            <nz-form-control
              class="val"
              nzErrorTip="请填写流程数量"
              style="width: 100%"
            >
              <nz-input-group [nzAddOnAfter]="getNumlength() + '/' + 50">
                <input
                  nz-input
                  type="number"
                  placeholder="请填写流程数量"
                  formControlName="num"
                  nzStatus=""
                  maxlength="50"
                />
              </nz-input-group>
            </nz-form-control>
          </nz-form-item>
          }@else {
          <nz-form-item class="row" style="margin-bottom: 16px">
            <nz-form-label
              class="label"
              [nzNoColon]="true"
              [nzSm]="18"
              [nzXs]="18"
              nzRequired
              >关联省级行政区</nz-form-label
            >
            <nz-form-control
              class="val"
              nzErrorTip="请填写选择关联省级行政区"
              style="width: 100%"
            >
              <nz-select
                style="width: 100%"
                nzShowSearch
                nzAllowClear
                nzPlaceHolder="请填写选择关联省级行政区"
                formControlName="area"
              >
                @for(item of provinces; track item;let index = $index){
                <nz-option nzCustomContent [nzValue]="item" [nzLabel]="item">{{
                  item
                }}</nz-option>
                }
              </nz-select>
            </nz-form-control>
          </nz-form-item>
          }
        </div>
      </div>
      <div nz-row>
        <div nz-col nzSpan="24">
          <div class="title-row">
            <div>
              <div class="title">报送人</div>
              <div class="tips">
                报送人可查看合集中所有流程报送的教材、报送配额、用户，可创建所属省份与自己相同的账号、用户组；可公示和报送合集中所有教材。
              </div>
            </div>
            <a class="btn" (click)="onShowCheck()">{{
              eduCollection?.get("profileSubmitted")?.id
                ? "修改报送人"
                : "选择报送人"
            }}</a>
          </div>
          <div class="tabs" #maxWidth>
            @if (eduCollection?.get('profileSubmitted') && !showProfileFrom) {
            <app-profile
              [idList]="profileId ? [profileId] : []"
              (change)="changeSubmitted($event)"
              [maxWidth]="maxWidth"
              [disabled]="true"
            ></app-profile>
            } @else if(showProfileFrom){
            <app-profile
              [idList]="profileId ? [profileId] : []"
              [maxWidth]="maxWidth"
              (change)="changeSubmitted($event)"
            ></app-profile>
            }
          </div>
          <div class="fonter">
            @if (!eduCollection?.id) {
            <button
              class="form-button"
              type="button"
              mat-raised-button
              (click)="submitForm('save')"
            >
              创建
            </button>
            <button
              class="form-button close"
              type="button"
              mat-raised-button
              (click)="submitForm('close')"
            >
              取消
            </button>
            } @else {
            <button
              class="form-button"
              type="button"
              mat-raised-button
              (click)="submitForm('save')"
            >
              保存
            </button>
            <button
              class="form-button close"
              type="button"
              mat-raised-button
              (click)="submitForm('close')"
            >
              取消
            </button>
            }
          </div>
        </div>
      </div>
    </div>
  </form>
</div>
