<div class="list-template">
  <div class="list-template__content">
    <div class="list-template__top" nz-row>
      <div nz-col nzXl='18' class="list-template__searchBox"></div>
      <div nz-col nzLg="6" class="list-template__btns">
        <button nz-button *ngIf="coopBtns.add" class="btn default" (click)="addModal()">新增</button>
      </div>
    </div>
    <div class="list-template__bottom">
      <nz-table class="list-template__nzTable" [nzData]="listOfData" nzSize="middle" [nzShowPagination]="false"
        [nzLoading]="loading1">
        <thead>
          <tr class="thead">
            <th nzWidth="15%">方案名称</th>
            <th nzWidth="27%">方案描述</th>
            <th nzWidth="7%">方案类型</th>
            <th nzWidth="8%">方案状态</th>
            <th nzWidth="15%">定时启用时间</th>
            <th nzWidth="28%">操作</th>
          </tr>
        </thead>
        <tbody>
          <tr *ngFor="let data of listOfData;let i = index">
            <td>{{data.name}}</td>
            <td>{{data.describe}}</td>
            <td>{{data.workType == 1?'综合排班':'自选排班'}}</td>
            <td>{{data.status?'启用中':'停用中'}}</td>
            <td>{{data.startTime?data.startTime:'-'}}</td>
            <td>
              <div class="coop">
                <span *ngIf="coopBtns.isStartUp"
                  (click)="showDelModal(data,'启用【'+data.name+'】将会停用正在使用的方案，您是否确定启用【'+data.name+'】？','启用','switch',data.status)">启用</span>
                <span *ngIf="coopBtns.isTimedStartUp&&!data.status"
                  (click)="addDateModal(data)">{{data.timingStatus?'关闭定时启用':'定时启用'}}</span>
                <span *ngIf="coopBtns.del&&!data.status" (click)="showDelModal(data,'您确认要删除此方案吗？','删除','del')">删除</span>
                <span *ngIf="coopBtns.copy" (click)="copy(data)">复制</span>
                <span *ngIf="coopBtns.edit" (click)="edit(data)">编辑</span>
              </div>
            </td>
          </tr>
        </tbody>
      </nz-table>
      <div class="list-template__pagination">
        <nz-pagination [(nzPageIndex)]="pageIndex" [(nzTotal)]="listLength" [(nzPageSize)]="pageSize"
          (nzPageIndexChange)="getList(0)" (nzPageSizeChange)="getList(0)">
        </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">{{modelName}}<i class="icon_transport transport-guanbi" (click)="hideAddModal()"></i></div>
      <div class="content">
        <form nz-form [formGroup]="validateForm" class="addForm">
          <nz-form-item>
            <nz-form-label [nzSpan]="24" nzRequired nzFor="workAssignmentName">方案名称</nz-form-label>
            <nz-form-control nzErrorTip="请输入方案名称!">
              <nz-input-group>
                <input nz-input formControlName="workAssignmentName" placeholder="请输入方案名称" />
              </nz-input-group>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSpan]="6" nzRequired nzFor="workAssignmentType">方案类型</nz-form-label>
            <nz-form-control [nzSpan]="18" nzErrorTip="请输入方案类型!">
              <nz-radio-group formControlName="workAssignmentType" [nzDisabled]="!this.add||copyModel">
                <label nz-radio nzValue="1">综合排班</label>
                <label nz-radio nzValue="2">自选排班</label>
              </nz-radio-group>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="workAssignmentDescribe">方案描述</nz-form-label>
            <nz-form-control nzErrorTip="请输入方案描述!">
              <nz-input-group>
                <textarea class="workAssignmentDescribe" formControlName="workAssignmentDescribe" nz-input
                  placeholder="请输入方案描述"></textarea>
              </nz-input-group>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSpan]="8" nzRequired nzFor="showBusy">是否支持上班示忙</nz-form-label>
            <nz-form-control [nzSpan]="16" nzErrorTip="请输入是否支持上班示忙!">
              <nz-radio-group formControlName="showBusy" (ngModelChange)="changeShowBusy()">
                <label nz-radio [nzValue]="1">是</label>
                <label nz-radio [nzValue]="0">否</label>
              </nz-radio-group>
            </nz-form-control>
          </nz-form-item>
          <ng-container *ngIf="validateForm.value.showBusy == 1">
            <div *ngFor="let busy of busyList;let index = index" class="busyList">
              <input class="busyContent" nz-input [(ngModel)]="busy.busyContent" [ngModelOptions]="{standalone: true}" placeholder="请填写示忙原因" />
              <nz-input-number [(ngModel)]="busy.busyMinute" [ngModelOptions]="{standalone: true}" [nzMin]="1" [nzStep]="1" [nzPrecision]="0"></nz-input-number>分钟
            </div>
          </ng-container>
        </form>
      </div>
      <div class=" display_flex justify-content_flex-center">
        <button nzType="primary" nz-button (click)="submitForm()" [nzLoading]="btnLoading">{{add?'开始':'修改'}}配置</button>
        <button class="btn" nzGhost nzType="primary" nz-button (click)="submitForm(true)" [nzLoading]="btnLoading1"
          *ngIf="copyModel||!add">完成配置</button>
        <button class="btn cancel" nz-button nzType="default" (click)="hideAddModal()">取消</button>
      </div>
    </div>
  </div>
  <!-- 定时启用设置日期模态框 -->
  <div class="save display_flex justify-content_flex-center align-items_center add" *ngIf="dateModal">
    <div class="modalBody">
      <div class="title">定时启用<i class="icon_transport transport-guanbi" (click)="hideDateModal()"></i>
      </div>
      <div class="content">
        <form nz-form [formGroup]="validateDateForm" class="addForm" (ngSubmit)="submitDateForm()">
          <nz-form-item>
            <nz-form-label [nzSm]="24" [nzXs]="24" nzRequired nzFor="datePickerTime">选择日期</nz-form-label>
            <nz-form-control [nzSm]="24" [nzXs]="24" nzErrorTip="请选择日期!">
              <nz-date-picker [ngModel]="datePicker" (ngModelChange)="datePickerChange($event)"
                [nzShowTime]="{ nzDefaultOpenValue: timeDefaultValue }" formControlName="datePickerTime"
                [nzDisabledTime]="disabledDateTime"></nz-date-picker>
            </nz-form-control>
          </nz-form-item>
        </form>
      </div>
      <div class=" display_flex justify-content_flex-center">
        <button nzType="primary" nz-button (click)="submitDateForm()" [nzLoading]="btnLoading">确定</button>
        <button class="btn cancel" nz-button nzType="default" (click)="hideDateModal()">取消</button>
      </div>
    </div>
  </div>
  <!-- 删除模态框 -->
  <app-dialog-delete [delModal]="delModal" (hideDelModalEvent)="hideDelModal()" [btnLoading]="btnLoading"
    (confirmDelEvent)="confirmDel()" [content]="tipsMsg1"></app-dialog-delete>
</div>
<!-- 操作成功/失败提示框 -->
<app-prompt-modal *ngIf="promptModalShow" [content]="promptContent" [success]="ifSuccess" [show]="promptModalShow"
  [info]="promptInfo">
</app-prompt-modal>
<!-- 查看详情 -->
<router-outlet></router-outlet>
