<div class="jobAssignment">
  <div class="breadNav">
    <h2>方案名称：{{queryParamsName}}</h2>
    <div>
      <button class="btn default mr8" nzType="primary" nz-button
        (click)="goToCheck()">切换</button>
      <button class="btn default" nzType="primary" nz-button (click)="goToList()">返回列表</button>
    </div>
  </div>
  <div class="typeInfo">
    <div class="title">任务类型</div>
    <div class="roles" *ngIf="!loading1">
      <overlay-scrollbars #osComponentRef1 [ngStyle]="{ height:'100%' }">
        <div [ngClass]="{'item':true,'checked':data.id==checkedType.id}" *ngFor="let data of typeList"
          (click)="checkType(data)" [title]="data.taskName">{{data.taskName}}</div>
      </overlay-scrollbars>
    </div>
    <div class="roles" *ngIf="loading1">
      <div class="loadingFull display_flex justify-content_flex-center align-items_center">
        <div class="loadingFullInner">
          <img src="../../../assets/images/loading.gif" alt="">
          <div>加载中...</div>
        </div>
      </div>
    </div>
  </div>
  <div class="classesInfo">
    <div class="top display_flex align-items_space-evenly">
      <div *ngFor="let item of checkedType.classesIds" [ngClass]="{'checked':classesId==item.id}"
        (click)="checkClasses(item.id)">
        {{item.name}}
      </div>
    </div>
    <div *ngFor="let item of checkedType.classesIds">
      <div class="views menuViews" *ngIf="classesId==item.id">
        <div class="radioes">
          <nz-radio-group [(ngModel)]="ruleTypes[checkedType['id'] + '' +item.id]"
            (ngModelChange)="changeRadio($event,item.id)">
            <label nz-radio nzValue="1">自由抢单</label>
            <label nz-radio nzValue="2">指定分组</label>
            <label nz-radio nzValue="3">科室绑定人员</label>
            <label nz-radio nzValue="4">科室绑定分组</label>
          </nz-radio-group>
        </div>
        <div class="replicationScheme" *ngIf="copyFlag" (click)="replicationSchemeClick(checkedType,item)">复制方案</div>
        <!-- 自由抢单 -->
        <div class="con" *ngIf="ruleTypes[checkedType['id'] + '' +item.id]==1">
          <div class="inner display_flex justify-content_flex-center align-items_center">
            <div class="innerBox display_flex justify-content_flex-center align-items_center">
              <div class="msg">
                <img src="../../assets/images/image_kongbaiye.png" alt="">
                <p>当前类型下所有工单全员可进行抢单！</p>
              </div>
            </div>
          </div>
          <div class="btnBox display_flex justify-content_flex-center ">
            <button class="btn default" nzType="primary" [nzLoading]="btnLoading" nz-button
              (click)="save(1)">保存</button>
            <button class="btn ml8" nzType="primary" [nzLoading]="takeLoading" nz-button
              (click)="takeEffect()">生效</button>
          </div>
        </div>
        <!-- 指定分组 -->
        <div class="con" *ngIf="ruleTypes[checkedType['id'] + '' +item.id]==2">
          <div class="inner display_flex justify-content_flex-center align-items_center">
            <div class="table" *ngIf="!getClassesGroupsLoading">
              <nz-table class="groupManagementTable" #rowSelectionTable [nzPageSize]="9999"
                [nzData]="classesGroups[checkedType['id']+''+item.id]" [nzShowPagination]="false" #fixedTable
                [nzLoading]="tLoading">
                <tbody>
                  <tr *ngFor="let data of classesGroups[checkedType['id'] + '' + classesId]">
                    <td style="text-align: left;" nzShowCheckbox
                      [(nzChecked)]="mapOfCheckedId[checkedType.id+''+classesId][data.id]"
                      (nzCheckedChange)="refreshStatus()"></td>
                    <td>{{data.groupName}}</td>
                  </tr>
                </tbody>
              </nz-table>
            </div>
            <div class="table-loading" *ngIf="getClassesGroupsLoading"><img src="../../assets/images/loading.gif"
                alt=""></div>
          </div>
          <div class="btnBox display_flex justify-content_flex-center ">
            <button class="btn default" nzType="primary" [nzLoading]="btnLoading" nz-button (click)="save(2)"
              [disabled]="!refreshStatusGlag">保存</button>
            <button class="btn ml8" nzType="primary" [nzLoading]="takeLoading" nz-button
              (click)="takeEffect()">生效</button>
          </div>
        </div>
        <!-- 科室绑定人员 -->
        <div class="con" *ngIf="ruleTypes[checkedType['id'] + '' +item.id]==3">
          <div class="inner display_flex justify-content_flex-center align-items_center">
            <overlay-scrollbars class="box" #osComponentRef2>
              <div style="padding-right:16px">
                <div class="top">
                  <div class="search display_flex align-items_center justify-content_space-between">
                    <div class="searchBoxes">
                      <span class="label">楼栋：</span>
                      <nz-select [nzDropdownMatchSelectWidth]="false" class="items" nzShowSearch nzAllowClear
                        nzPlaceHolder="楼栋" [(ngModel)]="building1">
                        <nz-option nzLabel="{{data.buildingName}}" nzValue="{{data.id}}"
                          *ngFor="let data of allBuilding">
                        </nz-option>
                      </nz-select>
                      <span class="label">科室名称：</span>
                      <input class="items" nz-input [(ngModel)]="deptName1" placeholder="请选择科室名称" nzSize="default" />
                      <!-- <span class="label">科室编码：</span> -->
                      <!-- <input class="items" nz-input [(ngModel)]="deptNum1" placeholder="请选择科室编码" nzSize="default" /> -->
                      <span class="label">科室类型：</span>
                      <nz-select [nzDropdownMatchSelectWidth]="false" style="width: 130px;" class="items" nzShowSearch
                        nzAllowClear nzPlaceHolder="请选择科室类型" [(ngModel)]="deptType1">
                        <nz-option nzLabel="{{data.name}}" nzValue="{{data.id}}" *ngFor="let data of allDeptType">
                        </nz-option>
                      </nz-select>
                    </div>
                    <div>
                      <button class="btn default" (click)='search1(1)'>搜索</button>
                    </div>
                  </div>
                  <div class="assign">
                    <button class="btn " (click)="resBatchAllot1()">搜索结果批量分配</button>
                    <button class="btn " (click)="resBatchUnAllot1()">搜索结果批量取消分配</button>
                  </div>
                </div>
                <div class="center bind">
                  <nz-table class="groupManagementTable nopadding" [nzPageSize]="9999" [nzData]="deptsByAllocation1"
                    nzSize="middle" [nzShowPagination]="false" [nzLoading]="tLoading">
                    <thead>
                      <tr class="thead">
                        <th nzWidth="5%" style="text-align: left;" nzShowCheckbox
                          [(nzChecked)]="isAllDisplayDataChecked1" (nzCheckedChange)="checkAll1($event)"></th>
                        <th nzWidth="12%">科室所属院区</th>
                        <th nzWidth="14%">科室名称</th>
                        <th nzWidth="10%">科室编码</th>
                        <th nzWidth="12%">科室类型</th>
                        <th nzWidth="12%">科室位置</th>
                        <th nzWidth="15%">负责人</th>
                        <th nzWidth="20%">操作</th>
                      </tr>
                    </thead>
                    <tbody>
                      <tr *ngFor="let data of deptsByAllocation1">
                        <td style="text-align: left;" nzShowCheckbox [(nzChecked)]="mapOfCheckedId1[data.id]"
                          (nzCheckedChange)="refreshStatus1()"></td>
                        <td> {{ data.hospital?data.hospital.hosName:'' }}</td>
                        <td> {{ data.dept }}</td>
                        <td> {{ data.pcode }}</td>
                        <td> {{ data.type?data.type.name:'' }}</td>
                        <td> {{ data.building?data.building.buildingName:''}} {{data.floor?data.floor.floorName:''}}
                          {{data.address?data.address:''}}</td>
                        <td>
                          <div *ngIf="data.users">
                            <span *ngFor="let user of data.users;let i = index;">
                              <span *ngIf="i!=data.users.length-1">{{user.name}},</span>
                              <span *ngIf="i==data.users.length-1">{{user.name}}</span>
                            </span>
                          </div>
                        </td>
                        <td>
                          <div class="coop">
                            <span (click)="allot1(data)">分配</span>
                            <span *ngIf="data.users" class="line">|</span>
                            <span *ngIf="data.users" (click)="unAllot1(data)">取消分配</span>
                          </div>
                        </td>
                      </tr>
                    </tbody>
                  </nz-table>
                  <div class="pagination">
                    <nz-pagination [(nzPageIndex)]="pageIndex1" [(nzTotal)]="listLength1" nzShowSizeChanger
                      [(nzPageSize)]="pageSize1" (nzPageIndexChange)="search1(0)" (nzPageSizeChange)="search1(0)">
                    </nz-pagination>
                  </div>
                </div>
                <div class="bottom display_flex">
                  <div class="left">
                    <nz-select [nzDropdownMatchSelectWidth]="false" class="selectOne"
                      style="width: 100% ;min-height: 80px;" [(ngModel)]="checkedmultipleValue1" nzSize="default"
                      (ngModelChange)="changeCheckedDept1($event)" nzMode="multiple">
                      <nz-option *ngFor="let option of checkedAllDeptInfos1" [nzLabel]="option.dept"
                        [nzValue]="option.id">
                      </nz-option>
                    </nz-select>
                    <div>已选中{{checkedmultipleValue1.length}}个科室</div>
                  </div>
                  <div class="right display_flex col-flex justify-content_space-between">
                    <div class="btn " (click)="initCheckedTableInfo1()">清空选项</div>
                    <!-- <div class="btn " (click)="batchPro1()">选中批量分配
                  </div> -->
                    <button [disabled]="checkedmultipleValue1.length===0" class="btn" nz-button nzType="primary"
                      (click)="batchPro1()">选中批量分配</button>
                    <button [disabled]="checkedmultipleValue1.length===0" class="btn" nz-button nzType="default"
                      (click)="batchUnAllot1()">选中取消批量分配</button>
                    <!-- <div class="btn " (click)="batchUnAllot1()">选中取消批量分配</div> -->
                  </div>
                </div>
              </div>
            </overlay-scrollbars>
          </div>
          <div class="btnBox display_flex justify-content_flex-center ">
            <!-- <button class="btn" (click)="save(3)">保存</button> -->
            <button class="btn" nzType="primary" [nzLoading]="takeLoading" nz-button (click)="takeEffect()">生效</button>
          </div>
        </div>
        <!-- 科室绑定分组 -->
        <div class="con" *ngIf="ruleTypes[checkedType['id'] + '' +item.id]==4">
          <div class="inner display_flex justify-content_flex-center align-items_center">
            <overlay-scrollbars class="box" #osComponentRef3>
              <div style="padding-right:16px">
                <div class="top">
                  <div class="search display_flex align-items_center justify-content_space-between">
                    <div class="searchBoxes">
                      <span class="label">楼栋：</span>
                      <nz-select [nzDropdownMatchSelectWidth]="false" class="items" nzShowSearch nzAllowClear
                        nzPlaceHolder="楼栋" [(ngModel)]="building2">
                        <nz-option nzLabel="{{data.buildingName}}" nzValue="{{data.id}}"
                          *ngFor="let data of allBuilding">
                        </nz-option>
                      </nz-select>
                      <span class="label">科室名称：</span>
                      <input class="items" nz-input [(ngModel)]="deptName2" placeholder="请选择科室名称" nzSize="default" />
                      <!-- <span class="label">科室编码：</span> -->
                      <!-- <input class="items" nz-input [(ngModel)]="deptNum2" placeholder="请选择科室编码" nzSize="default" /> -->
                      <span class="label">科室类型：</span>
                      <nz-select [nzDropdownMatchSelectWidth]="false" style="width: 130px;" class="items" nzShowSearch
                        nzAllowClear nzPlaceHolder="请选择科室类型" [(ngModel)]="deptType2">
                        <nz-option nzLabel="{{data.name}}" nzValue="{{data.id}}" *ngFor="let data of allDeptType">
                        </nz-option>
                      </nz-select>
                    </div>
                    <div>
                      <button class="btn default" (click)='search2(1)'>搜索</button>
                    </div>
                  </div>
                  <div class="assign">
                    <button class="btn" (click)="resBatchAllot2()">搜索结果批量分配</button>
                    <button class="btn" (click)="resBatchUnAllot2()">搜索结果批量取消分配</button>
                  </div>
                </div>
                <div class="center bind">
                  <nz-table class="groupManagementTable nopadding" [nzPageSize]="9999" [nzData]="deptsByAllocation2"
                    nzSize="middle" [nzShowPagination]="false" [nzLoading]="tLoading">
                    <thead>
                      <tr class="thead">
                        <th nzWidth="5%" style="text-align: left;" nzShowCheckbox
                          [(nzChecked)]="isAllDisplayDataChecked2" (nzCheckedChange)="checkAll2($event)"></th>
                        <th nzWidth="12%">科室所属院区</th>
                        <th nzWidth="14%">科室名称</th>
                        <th nzWidth="10%">科室编码</th>
                        <th nzWidth="12%">科室类型</th>
                        <th nzWidth="12%">科室位置</th>
                        <th nzWidth="15%">负责组</th>
                        <th nzWidth="20%">操作</th>
                      </tr>
                    </thead>
                    <tbody>
                      <tr *ngFor="let data of deptsByAllocation2">
                        <td style="text-align: left;" nzShowCheckbox [(nzChecked)]="mapOfCheckedId2[data.id]"
                          (nzCheckedChange)="refreshStatus2()"></td>
                        <td> {{ data.hospital?data.hospital.hosName:'' }}</td>
                        <td> {{ data.dept }}</td>
                        <td> {{ data.pcode }}</td>
                        <td> {{ data.type?data.type.name:'' }}</td>
                        <td> {{ data.building?data.building.buildingName:''}} {{data.floor?data.floor.floorName:''}}
                          {{data.address?data.address:''}}</td>
                        <td>
                          <div *ngIf="data.groups">
                            <span *ngFor="let group of data.groups;let i = index;">
                              <span *ngIf="i!=data.groups.length-1">{{group.groupName}},</span>
                              <span *ngIf="i==data.groups.length-1">{{group.groupName}}</span>
                            </span>
                          </div>
                        </td>
                        <td>
                          <div class="coop">
                            <span (click)="allot2(data)">分配</span>
                            <span *ngIf="data.groups" class="line">|</span>
                            <span *ngIf="data.groups" (click)="unAllot2(data)">取消分配</span>
                          </div>
                        </td>
                      </tr>
                    </tbody>
                  </nz-table>
                  <div class="pagination">
                    <nz-pagination [(nzPageIndex)]="pageIndex2" [(nzTotal)]="listLength2" nzShowSizeChanger
                      [(nzPageSize)]="pageSize2" (nzPageIndexChange)="search2(0)" (nzPageSizeChange)="search2(0)">
                    </nz-pagination>
                  </div>
                </div>
                <div class="bottom display_flex">
                  <div class="left">
                    <nz-select [nzDropdownMatchSelectWidth]="false" class="selectOne"
                      style="width: 100% ;min-height: 80px;" [(ngModel)]="checkedmultipleValue2" nzSize="default"
                      (ngModelChange)="changeCheckedDept2($event)" nzMode="multiple">
                      <nz-option *ngFor="let option of checkedAllDeptInfos2" [nzLabel]="option.dept"
                        [nzValue]="option.id">
                      </nz-option>
                    </nz-select>
                    <div>已选中{{checkedmultipleValue2.length}}个科室</div>
                  </div>
                  <div class="right display_flex col-flex justify-content_space-between">
                    <div class="btn" (click)="initCheckedTableInfo2()">清空选项</div>
                    <!-- <div class="btn" (click)="batchPro2()">选中批量分配
                  </div>
                  <div class="btn" (click)="batchUnAllot2()">
                    选中取消批量分配</div> -->
                    <button [disabled]="checkedmultipleValue2.length === 0" class="btn" nz-button nzType="primary"
                      (click)="batchPro2()">选中批量分配</button>
                    <button [disabled]="checkedmultipleValue2.length === 0" class="btn" nz-button nzType="default"
                      (click)="batchUnAllot2()">选中取消批量分配</button>
                  </div>
                </div>
              </div>
            </overlay-scrollbars>
          </div>
          <div class="btnBox display_flex justify-content_flex-center ">
            <!-- <button class="btn" (click)="save(3)">保存</button> -->
            <button class="btn" nzType="primary" [nzLoading]="takeLoading" nz-button (click)="takeEffect()">生效</button>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>



<!-- 返回列表模态框 -->
<div class="save display_flex justify-content_flex-center align-items_center" *ngIf="delModal">
  <div class="modalBody">
    <div class="title">提示<i class="icon_transport transport-guanbi" (click)="hideDelModal()"></i></div>
    <div class="content">
      <div class="icon"><i class="icon_transport transport-wenhao"></i></div>
      <div class="defeat">{{tipsMsg1}}</div>
    </div>
    <div class=" display_flex justify-content_flex-center">
      <button nz-button nzType="primary" (click)="confirmDel()" [nzLoading]="btnLoading">确认</button>
      <button class="btn cancel " nz-button nzType="default" (click)="hideDelModal()">取消</button>
    </div>
  </div>
</div>
<!-- 分配人员模态框 -->
<div class="save display_flex align-items_center justify-content_flex-center" *ngIf="allotModal1">
  <div class="modalBody" *ngIf="!loading2">
    <div class="title">人员选择<i class="icon_transport transport-guanbi" (click)="hideAllotModal1()"></i></div>
    <div class="content">
      <div class="title">人员选择：</div>
      <div class="content-ct">
        <nz-select style="width: 100%" [nzDropdownMatchSelectWidth]="false" [(ngModel)]="allotUsers1" nzServerSearch
          (nzOnSearch)="changeInp($event)" (nzOpenChange)="changeIt($event)" nzSize="middle" nzMode="multiple"
          nzPlaceHolder="请选择人员" (ngModelChange)="showDataDepts1Click($event)">
          <ng-container *ngFor="let option of pageUserList">
            <nz-option *ngIf="!isLoading" [nzLabel]="option.name" [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>
      </div>
      <div style="margin: 16px 0;text-align: left;word-break: break-all;" *ngIf="showDataDepts1.length">
        <span *ngFor="let item of showDataDepts1;let last = last;">{{item.dept.dept}}<i *ngIf="!last">，</i></span>
      </div>
      <label *ngIf="replaceFlag" class="mt8" nz-checkbox
        [(ngModel)]="isReplace">勾选后当前任务类型班次下相同的科室分配的人员将被替换为新增分配的人员</label>
    </div>
    <div class="display_flex justify-content_flex-center">
      <button nz-button nzType="primary" [nzLoading]="btnLoading" (click)="confirm1()">确认</button>
      <button class="btn cancel" nz-button nzType="default" (click)="hideAllotModal1()">关闭</button>
    </div>
  </div>
  <div class="modalBody" *ngIf="loading2">
    <div class="loadingFull display_flex justify-content_flex-center align-items_center" style="min-height: 249px;">
      <div class="loadingFullInner">
        <img src="../../../assets/images/loading.gif" alt="">
        <div>加载中...</div>
      </div>
    </div>
  </div>
</div>
<!-- 取消分配人员模态框 -->
<div class="save display_flex align-items_center justify-content_flex-center" *ngIf="unAllotModal1">
  <div class="modalBody">
    <div class="title">人员选择<i class="icon_transport transport-guanbi" (click)="hideUnAllotModal1()"></i></div>
    <div class="content">
      <div class="icon"><i class="icon_transport transport-wenhao"></i></div>
      <div class="defeat">您确认要取消分配吗？</div>
    </div>
    <div class="display_flex justify-content_flex-center">
      <button nz-button nzType="primary" [nzLoading]="btnLoading" (click)="confirmUn1()">确认</button>
      <button class=" btn cancel" nz-button nzType="default" (click)="hideUnAllotModal1()">取消</button>
    </div>
  </div>
</div>


<!-- 分配分组模态框 -->
<div class="save display_flex align-items_center justify-content_flex-center" *ngIf="allotModal2">
  <div class="modalBody" *ngIf="!loading2">
    <div class="title">分组选择<i class="icon_transport transport-guanbi" (click)="hideAllotModal2()"></i></div>
    <div class="content">
      <div class="title">分组选择：</div>
      <div class="content-ct">
        <nz-select style="width: 100%" [nzDropdownMatchSelectWidth]="false" [(ngModel)]="allotGroups2" nzSize="middle"
          nzMode="multiple" nzPlaceHolder="请选择分组" (ngModelChange)="showDataDepts2Click($event)">
          <nz-option *ngFor="let option of classesGroups[checkedType['id'] + '' + classesId]"
            [nzLabel]="option.groupName" [nzValue]="option.id"></nz-option>
        </nz-select>
      </div>
      <div style="margin: 16px 0;text-align: left;word-break: break-all;" *ngIf="showDataDepts2.length">
        <span *ngFor="let item of showDataDepts2;let last = last;">{{item.dept.dept}}<i *ngIf="!last">，</i></span>
      </div>
      <label *ngIf="replaceFlag" class="mt8" nz-checkbox
        [(ngModel)]="isReplace">勾选后当前任务类型班次下相同的科室分配的组将被替换为新增分配的组</label>
    </div>
    <div class="display_flex justify-content_flex-center">
      <button nz-button nzType="primary" [nzLoading]="btnLoading" (click)="confirm2()">确认</button>
      <button class=" btn cancel" nz-button nzType="default" (click)="hideAllotModal2()">取消</button>
    </div>
  </div>
  <div class="modalBody" *ngIf="loading2">
    <div class="loadingFull display_flex justify-content_flex-center align-items_center" style="min-height: 249px;">
      <div class="loadingFullInner">
        <img src="../../../assets/images/loading.gif" alt="">
        <div>加载中...</div>
      </div>
    </div>
  </div>
</div>
<!-- 取消分配分组模态框 -->
<div class="save display_flex align-items_center justify-content_flex-center" *ngIf="unAllotModal2">
  <div class="modalBody">
    <div class="title">分组选择<i class="icon_transport transport-guanbi" (click)="hideUnAllotModal2()"></i></div>
    <div class="content">
      <div class="icon"><i class="icon_transport transport-wenhao"></i></div>
      <div class="defeat">您确认要取消分配吗？</div>
    </div>
    <div class="display_flex justify-content_flex-center">
      <button nz-button nzType="primary" [nzLoading]="btnLoading" (click)="confirmUn2()">确认</button>
      <button class=" btn cancel" nz-button nzType="default" (click)="hideUnAllotModal2()">取消</button>
    </div>
  </div>
</div>

<!-- 操作成功/失败提示框 -->
<app-prompt-modal *ngIf="promptModalShow" [content]="promptContent" [success]="ifSuccess" [show]="promptModalShow"
  [info]="promptInfo">
</app-prompt-modal>

<!-- 复制方案弹窗 -->
<app-replication-scheme [currentTaskType]="currentTaskType" [show]="replicationModalShow"
  (closeModelHs)="closeModelHs($event)" (reloadModelHs)="reloadModelHs($event)"></app-replication-scheme>
