<div class="list-template">
  <div class="list-template__content">
    <div class="list-template__top" nz-row>
      <div nz-col nzXl='15' class="list-template__searchBox"></div>
      <div nz-col nzXl="9" class="list-template__btns">
        <button nz-button *ngIf="coopBtns.add" class="btn default ml8" (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="5%">序号</th>
            <th nzWidth="10%">标题</th>
            <th nzWidth="10%">重复策略</th>
            <th nzWidth="15%">定时发送时间</th>
            <th nzWidth="10%">状态</th>
            <th nzWidth="25%">定时下班班次</th>
            <th nzWidth="25%">操作</th>
          </tr>
        </thead>
        <tbody>
          <tr *ngFor="let data of listOfData;let i = index">
            <td>{{ i+1 }}</td>
            <td>{{ data.title }}</td>
            <td [ngSwitch]="data.timeStep">
              <ng-container *ngSwitchCase="'day'">每日</ng-container>
              <ng-container *ngSwitchCase="'week'">每周</ng-container>
              <ng-container *ngSwitchCase="'month'">每月</ng-container>
              <ng-container *ngSwitchCase="'year'">每年</ng-container>
            </td>
            <td [ngSwitch]="data.timeStep">
              <ng-container *ngSwitchCase="'day'">{{ data.executeTime|date:'HH时mm分' }}</ng-container>
              <ng-container *ngSwitchCase="'week'">{{data.weekName}} {{ data.executeTime|date:'HH时mm分' }}</ng-container>
              <ng-container *ngSwitchCase="'month'">{{data.extra1}}日 {{ data.executeTime|date:'HH时mm分' }}</ng-container>
              <ng-container *ngSwitchCase="'year'">{{ data.executeTime|date:'MM月dd日HH时mm分' }}</ng-container>
            </td>
            <td>{{ data.active?'开启':'关闭' }}</td>
            <td>{{ data.usersName }}</td>
            <td>
              <div class="coop">
                <span *ngIf="coopBtns.edit" (click)="edit(data)">编辑</span>
                <span *ngIf="coopBtns.del" (click)="showDelModal(data,'您确认要删除吗？','删除','del')">删除</span>
                <span *ngIf="coopBtns.isStartUp"
                  (click)="showDelModal(data,data.active?'您确认要停用吗？':'您确认要启用吗？',data.active?'停用':'启用','switch',data.active)">{{data.active?'停用':'启用'}}</span>
                <span *ngIf="coopBtns.executeNow" (click)="openExecModal(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>
      <overlay-scrollbars #osComponentRef1 class="content">
        <form nz-form [formGroup]="validateForm" class="addForm" (ngSubmit)="submitForm()">
          <nz-form-item>
            <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="title">标题</nz-form-label>
            <nz-form-control nzErrorTip="请输入标题!">
              <nz-input-group>
                <input nz-input formControlName="title" placeholder="请输入标题" />
              </nz-input-group>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSm]="24" [nzXs]="24" nzRequired nzFor="timeStep">重复策略</nz-form-label>
            <nz-form-control nzErrorTip="请选择重复策略!">
              <nz-radio-group formControlName="timeStep" (ngModelChange)="timeStepChange($event)">
                <label nz-radio nzValue="day">每天</label>
                <label nz-radio nzValue="week">每周</label>
                <label nz-radio nzValue="month">每月</label>
                <label nz-radio nzValue="year">每年</label>
              </nz-radio-group>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item *ngIf="validateForm.value.timeStep == 'week'">
            <nz-form-label [nzSm]="24" [nzXs]="24" nzRequired nzFor="doWeek">计划执行周（每周）</nz-form-label>
            <nz-form-control nzErrorTip="请选择周!">
              <nz-select formControlName="doWeek" nzPlaceHolder="请选择周">
                <nz-option nzValue="1" nzLabel="周一"></nz-option>
                <nz-option nzValue="2" nzLabel="周二"></nz-option>
                <nz-option nzValue="3" nzLabel="周三"></nz-option>
                <nz-option nzValue="4" nzLabel="周四"></nz-option>
                <nz-option nzValue="5" nzLabel="周五"></nz-option>
                <nz-option nzValue="6" nzLabel="周六"></nz-option>
                <nz-option nzValue="7" nzLabel="周日"></nz-option>
              </nz-select>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item *ngIf="validateForm.value.timeStep == 'month'">
            <nz-form-label [nzSm]="24" [nzXs]="24" nzRequired nzFor="doMonth">计划执行（每月）</nz-form-label>
            <nz-form-control nzErrorTip="请选择日!">
              <nz-select formControlName="doMonth" nzPlaceHolder="请选择日">
                <nz-option nzValue="{{item}}" nzLabel="{{item}}号" *ngFor="let item of months">
                </nz-option>
              </nz-select>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item *ngIf="validateForm.value.timeStep == 'year'">
            <nz-form-label [nzSm]="24" [nzXs]="24" nzRequired nzFor="doYear">计划执行（每年）</nz-form-label>
            <nz-form-control nzErrorTip="请选择月日!">
              <nz-date-picker nzFormat="MM-dd" formControlName="doYear" nzPlaceHolder="请选择月日"></nz-date-picker>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSm]="24" [nzXs]="24" nzRequired nzFor="executeTime">定时发送时间</nz-form-label>
            <nz-form-control nzErrorTip="请选择定时发送时间!">
              <nz-time-picker nzFormat="HH:mm" class="executeTime" formControlName="executeTime"
                nzPlaceHolder="请选择定时发送时间" [nzAllowEmpty]="false">
              </nz-time-picker>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSm]="24" [nzXs]="24" nzRequired nzFor="active">是否启用</nz-form-label>
            <nz-form-control nzErrorTip="请选择是否启用!">
              <nz-radio-group formControlName="active">
                <label nz-radio [nzValue]="true">开启</label>
                <label nz-radio [nzValue]="false">关闭</label>
              </nz-radio-group>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="classIds">定时下班班次</nz-form-label>
            <nz-form-control nzErrorTip="请选择定时下班班次!">
              <nz-select [nzMode]="'multiple'" [nzDropdownMatchSelectWidth]="false" formControlName="classIds"
                nzShowSearch nzAllowClear nzPlaceHolder="请选择定时下班班次" nzServerSearch (nzOpenChange)="changeForm($event)">
                <ng-container *ngFor="let data of classes">
                  <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>
      </overlay-scrollbars>
      <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]="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>
<!-- 立即执行 -->
<app-dialog-delete [delModal]="execModal" (hideDelModalEvent)="closeExecModal()" [btnLoading]="btnLoading"
  (confirmDelEvent)="confirmExec()" content="您确认要立即执行该定时下班策略吗？"></app-dialog-delete>
<!-- 遮罩 -->
<app-mask *ngIf="maskFlag"></app-mask>
