<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="5%">序号</th>
            <th nzWidth="10%">任务类型</th>
            <th nzWidth="10%">是否限制所有科室</th>
            <th nzWidth="10%">楼栋名称</th>
            <th nzWidth="10%">科室名称</th>
            <th nzWidth="10%">限制方式</th>
            <th nzWidth="10%">时间限制</th>
            <th nzWidth="10%">提示备注</th>
            <th nzWidth="10%">是否限制发起数量</th>
            <th nzWidth="25%">操作</th>
          </tr>
        </thead>
        <tbody>
          <tr *ngFor="let data of listOfData;let index = index">
            <td>{{index+(pageIndex-1) * pageSize + 1}}</td>
            <td>{{data.taskNames || '-'}}</td>
            <td>{{data.limitAllDept == 1 ? '是' : '否'}}</td>
            <td>{{data.buildingListNames || '-'}}</td>
            <td>{{data.deptListNames || '-'}}</td>
            <td>{{data.limitType == 1 ? '仅提示允许建单' : (data.limitType == 2 ? '提示不允许建单' : '-')}}</td>
            <td>{{data.startTime | date: 'HH:mm'}} ~ {{data.endTime | date: 'HH:mm'}}</td>
            <td>{{data.remark || '-'}}</td>
            <td>{{data.limitNum == 1 ? '是' : '否'}}</td>
            <td>
              <div class="coop">
                <span *ngIf="coopBtns.del&&!data.status" (click)="showDelModal(data,'您确认要删除此方案吗？','删除','del')">删除</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="taskTypeIds">任务类型</nz-form-label>
            <nz-form-control nzErrorTip="请选择任务类型!">
              <nz-select class="formItem" nzMode="multiple" (nzOnSearch)="changeInp($event, 'taskTypeIds')" [nzDropdownMatchSelectWidth]="false" nzServerSearch nzShowSearch nzPlaceHolder="请选择任务类型" formControlName="taskTypeIds" (nzOpenChange)="getTaskTypeList($event)">
                <ng-container *ngFor="let option of taskTypeList">
                  <nz-option *ngIf="!isLoading" [nzLabel]="option.taskName" [nzValue]="option.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>
          <!-- new -->
          <nz-form-item>
            <nz-form-label [nzSpan]="8" nzRequired nzFor="limitNum">是否限制发起数量</nz-form-label>
            <nz-form-control [nzSpan]="16" nzErrorTip="请选择是否限制发起数量!">
              <nz-radio-group formControlName="limitNum" (ngModelChange)="changeLimitNum($event)">
                <label nz-radio [nzValue]="1">是</label>
                <label nz-radio [nzValue]="0">否</label>
              </nz-radio-group>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item *ngIf="validateForm.value.limitNum == 1">
            <nz-form-label [nzSpan]="5" nzRequired nzFor="limitTime">限制时间</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请选择限制时间!">
              <nz-radio-group formControlName="limitTime">
                <label nz-radio nzValue="0.5">每半小时</label>
                <label nz-radio nzValue="1">每一小时</label>
              </nz-radio-group>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item *ngIf="validateForm.value.limitNum == 1">
            <nz-form-label [nzSpan]="8" nzRequired nzFor="fqLimitNum">发起限制数量</nz-form-label>
            <nz-form-control [nzSpan]="16" nzErrorTip="请选择发起限制数量!">
              <nz-input-number formControlName="fqLimitNum" [nzMin]="0" [nzStep]="1" [nzPrecision]="0"></nz-input-number>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item *ngIf="validateForm.value.limitNum == 1">
            <nz-form-label [nzSpan]="8" nzRequired nzFor="yyLimitNum">预约限制数量</nz-form-label>
            <nz-form-control [nzSpan]="16" nzErrorTip="请选择预约限制数量!">
              <nz-input-number formControlName="yyLimitNum" [nzMin]="0" [nzStep]="1" [nzPrecision]="0"></nz-input-number>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item *ngIf="validateForm.value.limitNum == 1">
            <nz-form-label [nzSpan]="24" nzRequired nzFor="createRemark"><span class="mr8">建单限制提示备注</span><span *ngFor="let item of variableNamesCreate; let last = last;" (click)="writeIn(item, $event, 'createRemark')"><strong style="cursor:pointer;color: #266CA4;">{{item}}</strong><em *ngIf="!last">、</em><em *ngIf="last">。</em></span></nz-form-label>
            <nz-form-control nzErrorTip="请输入建单限制提示备注!">
              <nz-input-group>
                <input nz-input formControlName="createRemark" placeholder="请输入建单限制提示备注" />
              </nz-input-group>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item *ngIf="validateForm.value.limitNum == 1">
            <nz-form-label [nzSpan]="24" nzRequired nzFor="yyLimitRemark"><span class="mr8">预约限制提示备注</span><span *ngFor="let item of variableNamesYy; let last = last;" (click)="writeIn(item, $event, 'yyLimitRemark')"><strong style="cursor:pointer;color: #266CA4;">{{item}}</strong><em *ngIf="!last">、</em><em *ngIf="last">。</em></span></nz-form-label>
            <nz-form-control nzErrorTip="请输入预约限制提示备注!">
              <nz-input-group>
                <input nz-input formControlName="yyLimitRemark" placeholder="请输入预约限制提示备注" />
              </nz-input-group>
            </nz-form-control>
          </nz-form-item>
          <!-- new -->
          <nz-form-item *ngIf="validateForm.value.limitNum != 1">
            <nz-form-label [nzSpan]="8" nzRequired nzFor="limitAllDept">是否限制所有科室</nz-form-label>
            <nz-form-control [nzSpan]="16" nzErrorTip="请选择是否限制所有科室!">
              <nz-radio-group formControlName="limitAllDept" (ngModelChange)="changeLimitAllDept($event)">
                <label nz-radio [nzValue]="1">是</label>
                <label nz-radio [nzValue]="0">否</label>
              </nz-radio-group>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item *ngIf="validateForm.value.limitAllDept === 0">
            <nz-form-label [nzSpan]="24" nzFor="buildingIds">楼栋名称</nz-form-label>
            <nz-form-control nzErrorTip="请选择楼栋名称!">
              <nz-select nzMode="multiple" class="formItem" (nzOnSearch)="changeInp($event, 'building')" [nzDropdownMatchSelectWidth]="false" nzAllowClear nzServerSearch nzShowSearch nzPlaceHolder="请选择楼栋名称" formControlName="buildingIds" (nzOpenChange)="getBuildingList($event)">
                <ng-container *ngFor="let option of buildingList">
                  <nz-option *ngIf="!isLoading" [nzLabel]="option.buildingName" [nzValue]="option.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>
          <nz-form-item *ngIf="validateForm.value.limitAllDept === 0">
            <nz-form-label [nzSpan]="24" nzFor="deptIds">科室名称</nz-form-label>
            <nz-form-control nzErrorTip="请选择科室名称!">
              <nz-select nzMode="multiple" class="formItem" (nzOnSearch)="changeInp($event, 'department')" [nzDropdownMatchSelectWidth]="false" nzAllowClear nzServerSearch nzShowSearch nzPlaceHolder="请选择科室名称" formControlName="deptIds" (nzOpenChange)="getDepartmentList($event)">
                <ng-container *ngFor="let option of departmentList">
                  <nz-option *ngIf="!isLoading" [nzLabel]="option.dept" [nzValue]="option.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>
          <nz-form-item>
            <nz-form-label [nzSpan]="5" nzRequired nzFor="limitType">限制方式</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请选择限制方式!">
              <nz-radio-group formControlName="limitType" (ngModelChange)="changeLimitType($event)">
                <label nz-radio [nzValue]="1">仅提示允许建单</label>
                <label nz-radio [nzValue]="2">提示不允许建单</label>
              </nz-radio-group>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item *ngIf="validateForm.value.limitType == 2">
            <nz-form-label [nzSpan]="8" nzRequired nzFor="limitDispatchDesk">调度台是否限制</nz-form-label>
            <nz-form-control [nzSpan]="16" nzErrorTip="请选择调度台是否限制!">
              <nz-radio-group formControlName="limitDispatchDesk">
                <label nz-radio [nzValue]="1">是</label>
                <label nz-radio [nzValue]="0">否</label>
              </nz-radio-group>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSpan]="5" nzRequired nzFor="startTime">时间限制</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请选择时间限制!">
              <nz-time-picker nzFormat="HH:mm" formControlName="startTime" [nzDisabledHours]="startTimeHourdis" [nzDisabledMinutes]="startTimeMindis" (nzOpenChange)="timeChange($event,'startTime')">
            </nz-time-picker>
            -
            <nz-time-picker nzFormat="HH:mm" formControlName="endTime" [nzDisabledHours]="endTimeHourdis" [nzDisabledMinutes]="endTimeMindis" (nzOpenChange)="timeChange($event,'endTime')"></nz-time-picker>
            </nz-form-control>
            <div style="text-align: left;color: red;" *ngIf="(!validateForm.value.startTime||!validateForm.value.endTime)||!(validateForm.value.startTime&&validateForm.value.endTime)">请选择完整的时间限制</div>
          </nz-form-item>
          <nz-form-item *ngIf="validateForm.value.limitNum == 0">
            <nz-form-label [nzSpan]="24" nzRequired nzFor="remark">提示备注</nz-form-label>
            <nz-form-control nzErrorTip="请输入提示备注!">
              <nz-input-group>
                <input nz-input formControlName="remark" placeholder="请输入提示备注" />
              </nz-input-group>
            </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]="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>

