<div class="jurisdictionManagement">
  <div class="groupInfo">
    <div class="title">角色类型</div>
    <div class="operate display_flex">
      <div *ngIf="coopBtns.add" class="add item flex_1" (click)="showCoopModal('add')">新增</div>
      <div *ngIf="coopBtns.edit" class="add item flex_1" (click)="showCoopModal('edit')">编辑</div>
      <div *ngIf="coopBtns.del&&(checkedRole.rolecode!='dsadmin'&&checkedRole.rolecode!='nurse'&&checkedRole.rolecode!='pharmacist'&&checkedRole.rolecode!='worker'&&checkedRole.rolecode!='service desk')"
        class="del item flex_1" (click)="showDelModal()">删除</div>
    </div>
    <div class="roles" *ngIf="!loading1">
      <div [ngClass]="{'item':true,'checked':data.id==checkedRole.id}" *ngFor="let data of roleList"
        (click)="checkRole(data)">{{data.role}}</div>
    </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="userInfo">
    <div class="top">
      <div [ngClass]="{'checked':menuType==1}" (click)="checkMenu(1)">
        功能权限
      </div>
      <div [ngClass]="{'checked':menuType==2}" (click)="checkMenu(2)">
        信息权限
      </div>
    </div>
    <div [hidden]="loading2 || loading3">
      <overlay-scrollbars #osComponentRef1 class="views menuViews" [hidden]="menuType!=1">
        <div class="tree">
          <div nz-row class="checkedAll">
            <div nz-col nzSpan="8">
              <label nz-checkbox [(ngModel)]="menuAllChecked" (ngModelChange)="checkedAllMenu()">全选/反选</label>
            </div>
          </div>
          <div class="row" nz-row *ngFor="let item of menuList;trackBy:trackByMenu">
            <div class="menuTitle" nz-col nzSpan="24">
              <label nz-checkbox [(ngModel)]="menuChecked[item.id]"
                (ngModelChange)="updateCheckedMenu1(true,item)">【{{item.title}}】</label>
            </div>
            <div style="margin-left: 24px;" nz-row *ngFor="let data of item.children;trackBy:trackByMenu">
              <div nz-col nzSpan="4">
                <label nz-checkbox [(ngModel)]="menuChecked[data.id]"
                  (ngModelChange)="updateCheckedMenu1(true,data,item.id)">{{data.title}}</label>
              </div>
              <div nz-col nzSpan="20">
                <div nz-row>
                  <div nz-col nzSpan="5" *ngFor="let e of data.children;trackBy:trackByMenu">
                    <label nz-checkbox [(ngModel)]="menuChecked[e.id]"
                      (ngModelChange)="updateCheckedMenu1(true,e,data.id,item.id)">{{e.title}}</label>
                  </div>
                </div>
              </div>
            </div>
          </div>


        </div>

        <div *ngIf="coopBtns.edit" class="btnBox display_flex justify-content_flex-center">
          <button nzType="primary" [nzLoading]="saveLoading" nz-button (click)="saveMenus()">保存</button>
        </div>
      </overlay-scrollbars>
      <overlay-scrollbars #osComponentRef2 class="views infoViews" [hidden]="menuType!=2">
        <div class="con">
          <div class="hospital">
            <div class="title">
              <label class="label" nz-checkbox [(nzDisabled)]="!coopBtns.edit" [(ngModel)]="allChecked"
                (ngModelChange)="updateAllChecked(1)">
                院区
              </label>
            </div>
            <div class="checkBox">
              <nz-checkbox-group [(ngModel)]="checkedHospitals" [(nzDisabled)]="!coopBtns.edit"
                (ngModelChange)="updateSingleChecked()">
              </nz-checkbox-group>
            </div>
          </div>
          <div class="hospital">
            <div class="title">
              <label class="label" nz-checkbox [(nzDisabled)]="!coopBtns.edit" [(ngModel)]="checkAllHospitalType"
                (ngModelChange)="updateAllHospitalType()">
                任务类型</label>
            </div>

            <div class="checkBox" *ngFor="let item of typeGroupList">
              <label class="label" nz-checkbox [(nzDisabled)]="!coopBtns.edit" [(ngModel)]="typeAllChecked[''+item.id]"
                (ngModelChange)="updTypeAllChecked(item.id)">
                {{item.hosName}}
              </label>
              <nz-checkbox-wrapper style="width: 100%;" (nzOnChange)="logTypeItem($event,item.id)">
                <div nz-row>
                  <div *ngFor="let i of item.taskTypes" nz-col nzSpan="8"><label nz-checkbox
                      [(nzDisabled)]="!coopBtns.edit" [nzValue]="i.id"
                      [(ngModel)]="typeChecked[''+i.id]">{{item.hosName}}
                      - {{i.taskName}}</label></div>
                </div>
              </nz-checkbox-wrapper>
            </div>
          </div>
          <div class="hospital">
            <div class="title">
              <label class="label" nz-checkbox [(nzDisabled)]="!coopBtns.edit" [(ngModel)]="checkAllHospitalGroup"
                (ngModelChange)="updateAllHospitalGroup()">
                工作组</label>
            </div>
            <div class="checkBox" *ngFor="let item of typeGroupList">
              <label class="label" nz-checkbox [(nzDisabled)]="!coopBtns.edit" [(ngModel)]="groupAllChecked[''+item.id]"
                (ngModelChange)="updGroupAllChecked(item.id)">
                {{item.hosName}}
              </label>
              <nz-checkbox-wrapper style="width: 100%;" (nzOnChange)="logGroupItem($event,item.id)">
                <div nz-row>
                  <div *ngFor="let i of item.groups" nz-col nzSpan="8">
                    <label nz-checkbox [nzValue]="i.id" [(nzDisabled)]="!coopBtns.edit"
                      [(ngModel)]="groupChecked[''+i.id]">{{item.hosName}} - {{i.groupName}}</label>
                  </div>
                </div>
              </nz-checkbox-wrapper>
            </div>
          </div>
        </div>
        <div *ngIf="coopBtns.edit" class="btnBox display_flex justify-content_flex-center">
          <button nzType="primary" nz-button [nzLoading]="saveLoading" (click)="saveInfo()">保存</button>
        </div>
      </overlay-scrollbars>
    </div>
    <div *ngIf="loading2||loading3" style="height: 825px;">
      <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="save add display_flex align-items_center justify-content_flex-center" *ngIf="coopModal">
    <div class="modalBody">
      <div class="title">{{coopType==='add'?'新增':'编辑'}}角色类型<i class="icon_transport transport-guanbi"
          (click)="hideCoopModal()"></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="role">角色名称</nz-form-label>
            <nz-form-control nzErrorTip="请输入角色名称!">
              <nz-input-group>
                <input type="role" nz-input formControlName="role" placeholder="请输入角色名称" />
              </nz-input-group>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="remark">角色描述</nz-form-label>
            <nz-form-control nzErrorTip="请输入角色描述!">
              <nz-input-group>
                <input type="remark" 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 [nzLoading]="btnLoading" (click)="submitForm()">确认</button>
        <button class="btn cancel" nz-button nzType="default" (click)="hideCoopModal()">取消</button>
      </div>
    </div>
  </div>
  <!-- 删除模态框 -->
<app-dialog-delete [delModal]="delModal" (hideDelModalEvent)="hideDelModal()" [btnLoading]="btnLoading"
(confirmDelEvent)="confirmDel()" content="您确认要删除此角色类型吗？"></app-dialog-delete>
</div>

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