<div class="list-template">
  <div class="list-template__content">
    <div class="list-template__top" nz-row>
      <div nz-col nzXl='12' class="list-template__searchBox">
      </div>
      <div nz-col nzXl="12" class="list-template__btns">
        <button nz-button *ngIf="coopBtns.add" class="btn default ml8" (click)="addModal()">新增</button>
        <button nz-button *ngIf="coopBtns.batchConversion" class="btn default ml8" (click)="convertOrRestore('batchConversion')">批量转换</button>
      </div>
    </div>
    <div class="list-template__bottom">
      <nz-table class="list-template__nzTable" [nzData]="listOfData" nzSize="middle" [nzShowPagination]="false"
        [nzLoading]="loading">
        <thead>
          <tr class="thead">
            <th nzWidth="7%">序号</th>
            <th nzWidth="31%">文字描述</th>
            <th nzWidth="31%">匹配方式</th>
            <th nzWidth="31%">操作</th>
          </tr>
        </thead>
        <tbody>
          <tr *ngFor="let data of listOfData;let i = index">
            <td>{{ i+1 }}</td>
            <td>{{ data.key1 }}</td>
            <td>
              <ng-container *ngIf="data.matchType == 1">
                模糊匹配
              </ng-container>
              <ng-container *ngIf="data.matchType == 2">
                完全匹配
              </ng-container>
            </td>
            <td>
              <div class="coop">
                <span *ngIf="coopBtns.edit" (click)="edit(data)">修改</span>
                <span *ngIf="coopBtns.del" (click)="showDelModal(data.id, '您确认要删除吗？')">删除</span>
                <span *ngIf="coopBtns.oneClickConversion" (click)="convertOrRestore('oneClickConversion', data)">一键转换</span>
                <span *ngIf="coopBtns.oneClickRecovery" (click)="convertOrRestore('oneClickRecovery', data)">一键恢复</span>
              </div>
            </td>
          </tr>
        </tbody>
      </nz-table>
      <div class="list-template__pagination">
        <nz-pagination [(nzPageIndex)]="pageIndex" [(nzTotal)]="listLength" [(nzPageSize)]="pageSize"
          (nzPageIndexChange)="getList()" (nzPageSizeChange)="getList()">
        </nz-pagination>
      </div>
    </div>
  </div>

  <!-- 新增/编辑模态框 -->
  <div class="save display_flex justify-content_flex-center align-items_center add" *ngIf="modal">
    <div class="modalBody">
      <div class="title">{{add?"新增":"编辑"}}<i class="icon_transport transport-guanbi" (click)="hideAddModal()"></i>
      </div>
      <div class="content">
        <form nz-form [formGroup]="validateForm" class="addForm" (ngSubmit)="submitForm()">
          <nz-form-item>
            <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="key1">检查文字描述</nz-form-label>
            <nz-form-control nzErrorTip="请输入检查文字描述!">
              <nz-input-group>
                <input nz-input formControlName="key1" placeholder="请输入检查文字描述" />
              </nz-input-group>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="matchType">匹配方式</nz-form-label>
            <nz-form-control nzErrorTip="请选择匹配方式!">
              <nz-select [nzDropdownMatchSelectWidth]="false" formControlName="matchType" nzShowSearch nzPlaceHolder="请选择匹配方式">
                <ng-container *ngFor="let data of matchTypes">
                  <nz-option *ngIf="!isLoading" nzLabel="{{data.name}}" nzValue="{{data.id}}">
                  </nz-option>
                </ng-container>
                <nz-option *ngIf="isLoading" nzDisabled nzCustomContent>
                  <i nz-icon nzType="loading" class="loading-icon"></i> 搜索中...
                </nz-option>
              </nz-select>
            </nz-form-control>
          </nz-form-item>
        </form>
      </div>
      <div class=" display_flex justify-content_flex-center">
        <button nzType="primary" nz-button (click)="submitForm()" [nzLoading]="btnLoading">保存</button>
        <button class="btn cancel" nz-button nzType="default" (click)="hideAddModal()">取消</button>
      </div>
    </div>
  </div>

  <!-- 删除模态框 -->
  <app-dialog-delete [delModal]="dialogDelete.delModal" (hideDelModalEvent)="hideDelModal()" [btnLoading]="dialogDelete.btnLoading"
    (confirmDelEvent)="confirmDel()" [content]="dialogDelete.content"></app-dialog-delete>
</div>
<!-- 操作成功/失败提示框 -->
<app-prompt-modal [content]="promptModal.content" [success]="promptModal.success" [show]="promptModal.show"
  [info]="promptModal.info">
</app-prompt-modal>
<!-- 模态框 -->
<app-dialog-delete [delModal]="dialogConvertOrRestore.delModal" (hideDelModalEvent)="hideConvertOrRestoreModal()" [btnLoading]="dialogConvertOrRestore.btnLoading"
(confirmDelEvent)="confirmConvertOrRestore()" [content]="dialogConvertOrRestore.content"></app-dialog-delete>
