<div class="hospitalConfig">
  <nz-radio-group [(ngModel)]="hospitalConfig" (ngModelChange)="changeHospitalConfig($event)">
    <label nz-radio [nzValue]="item.id" *ngFor="let item of hospitalConfigList">{{ item.name }}</label>
  </nz-radio-group>
</div>

<div class="content">
  <div class="contentInner">
    <div class="address">
      <div class="contentHead">一级<div><button nz-button nzType="primary" nzSize="small" (click)="removeCategory(1, activeCategory1)" class="mr8" *ngIf="activeCategory1.id && hospitalConfig === 2 && !categoryList2.length && !categoryLoading2">删除</button><button nz-button nzType="primary" nzSize="small" (click)="editCategory(1, activeCategory1)" class="mr8" *ngIf="activeCategory1.id && hospitalConfig === 2">编辑</button><button nz-button nzType="primary" nzSize="small" (click)="addCategoryModal(1)">新增</button></div></div>
      <overlay-scrollbars #osComponentRef1 class="contentBody">
        <nz-spin nzSimple [nzSpinning]="categoryLoading1" class="mt8 text_align_center"></nz-spin>
        <div [hidden]="categoryLoading1" class="contentItem" [title]="item.category" [ngClass]="{ active: item.id === activeCategory1.id }" (click)="clickCategory(item, 1)" *ngFor="let item of categoryList1">{{ item.category }}</div>
      </overlay-scrollbars>
    </div>
    <div class="address">
      <div class="contentHead">二级<div><button nz-button nzType="primary" nzSize="small" *ngIf="activeCategory2.id && hospitalConfig === 2 && !categoryList3.length && !categoryLoading3" (click)="removeCategory(2, activeCategory2)" class="mr8">删除</button><button nz-button nzType="primary" nzSize="small" *ngIf="activeCategory2.id && hospitalConfig === 2" (click)="editCategory(2, activeCategory2)" class="mr8">编辑</button><button nz-button nzType="primary" nzSize="small" *ngIf="activeCategory1.id" (click)="addCategoryModal(2)">新增</button></div></div>
      <overlay-scrollbars #osComponentRef2 class="contentBody">
        <nz-spin nzSimple [nzSpinning]="categoryLoading2" class="mt8 text_align_center"></nz-spin>
        <div [hidden]="categoryLoading2" class="contentItem" [title]="item.category" [ngClass]="{ active: item.id === activeCategory2.id }" (click)="clickCategory(item, 2)" *ngFor="let item of categoryList2">{{ item.category }}</div>
      </overlay-scrollbars>
    </div>
    <div class="address">
      <div class="contentHead">三级<div><button nz-button nzType="primary" nzSize="small" *ngIf="activeCategory3.id && hospitalConfig === 2" (click)="removeCategory(3, activeCategory3)" class="mr8">删除</button><button nz-button nzType="primary" nzSize="small" *ngIf="activeCategory3.id && hospitalConfig === 2" (click)="editCategory(3, activeCategory3)" class="mr8">编辑</button><button nz-button nzType="primary" nzSize="small" *ngIf="activeCategory2.id" (click)="addCategoryModal(3)">新增</button></div></div>
      <overlay-scrollbars #osComponentRef3 class="contentBody">
        <nz-spin nzSimple [nzSpinning]="categoryLoading3" class="mt8 text_align_center"></nz-spin>
        <div [hidden]="categoryLoading3" class="contentItem" [title]="item.category" [ngClass]="{ active: item.id === activeCategory3.id }" (click)="clickCategory(item, 3)" *ngFor="let item of categoryList3">{{ item.category }}</div>
      </overlay-scrollbars>
    </div>
    <div class="addressAssign">
      <div class="contentHead">
        <div class="title" title="{{activeCategory1.category}}{{activeCategory2.category ? ' - ' + activeCategory2.category : ''}}{{activeCategory3.category ? ' - ' + activeCategory3.category : ''}}">{{activeCategory1.category}}{{activeCategory2.category ? ' - ' + activeCategory2.category : ''}}{{activeCategory3.category ? ' - ' + activeCategory3.category : ''}}</div>
        <div class="btns" *ngIf="activeCategory1.id || activeCategory2.id || activeCategory3.id">
          <button nz-button nzType="primary" nzSize="small" (click)="showDelModal(null, hospitalConfig === 1 ? '您确认向下复制您的配置信息吗？' : '您确认向下复制您的配置吗？将会移除各科室的配置，使用当前配置进行覆盖。','向下复制','copy')" *ngIf="currentChildrenCategoryList">向下复制</button>
          <button nz-button nzType="primary" nzSize="small" class="ml8" *ngIf="hospitalConfig === 2" (click)="addConfigModal()">新增</button>
        </div>
      </div>
      <div class="contentBody" id="categoryTable">
        <div class="list-template">
          <div class="list-template__content">
            <div class="list-template__bottom">
              <nz-table class="list-template__nzTable" [nzData]="categoryConfigList" nzSize="middle" [nzShowPagination]="false"
                [nzLoading]="loading1" [nzScroll]="{ y: tableCategoryHeight + 'px' }">
                <thead>
                  <tr class="thead">
                    <th nzWidth="16%">院区</th>
                    <th nzWidth="16%">责任部门</th>
                    <th nzWidth="16%">优先级</th>
                    <th nzWidth="16%">积分</th>
                    <th nzWidth="16%">维修人|组</th>
                    <th nzWidth="20%">操作</th>
                  </tr>
                </thead>
                <tbody>
                  <tr *ngFor="let data of categoryConfigList;let i = index">
                    <td>{{data.hospitalDTO?.hosName}}</td>
                    <td>{{data.dutyDTO?.hosName}}</td>
                    <td>{{data.priorityDTO?.name}}</td>
                    <td>{{data.score?.value}}</td>
                    <td>{{data.userGroup === 1 ? data.userDTO?.name : (data.userGroup === 2 ? data.groupDTO?.groupName : '')}}</td>
                    <td>
                      <div class="coop">
                        <span (click)="showDelModal(data,'您确认要删除吗？','删除','delConfig')">删除</span>
                        <span (click)="editConfig(data)">编辑</span>
                      </div>
                    </td>
                  </tr>
                </tbody>
              </nz-table>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<!-- 新增/编辑关联模态框 -->
<div class="save display_flex justify-content_flex-center align-items_center add" *ngIf="modalConfig">
  <div class="modalBody">
    <div class="title">{{modelName}}<i class="icon_transport transport-guanbi" (click)="hideConfigModal()"></i></div>
    <div class="content">
      <form nz-form [formGroup]="validateConfigForm" class="addForm">
        <nz-form-item>
          <nz-form-label [nzSpan]="5" nzRequired nzFor="hosId">院区</nz-form-label>
          <nz-form-control [nzSpan]="19" nzErrorTip="请选择院区!">
            <nz-select [nzDropdownMatchSelectWidth]="false" formControlName="hosId" nzShowSearch
              nzPlaceHolder="请选择院区" nzServerSearch (ngModelChange)="changeHospital($event)" [nzDisabled]="!add">
              <ng-container *ngFor="let data of hospitalList">
                <nz-option *ngIf="!isLoading" [nzLabel]="data.hosName" [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>
        <nz-form-item>
          <nz-form-label [nzSpan]="5" nzRequired nzFor="dutyId">责任部门</nz-form-label>
          <nz-form-control [nzSpan]="19" nzErrorTip="请选择责任部门!">
            <nz-select [nzDropdownMatchSelectWidth]="false" formControlName="dutyId" nzShowSearch
              nzPlaceHolder="请选择责任部门" nzServerSearch (ngModelChange)="changeDuty($event)" [nzDisabled]="!add">
              <ng-container *ngFor="let data of dutyList">
                <nz-option *ngIf="!isLoading" [nzLabel]="data.hosName" [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>
        <nz-form-item>
          <nz-form-label [nzSpan]="5" nzRequired nzFor="priority">优先级</nz-form-label>
          <nz-form-control [nzSpan]="19" nzErrorTip="请选择优先级!">
            <nz-select [nzDropdownMatchSelectWidth]="false" formControlName="priority" nzShowSearch
            nzPlaceHolder="请选择优先级" nzServerSearch>
              <ng-container *ngFor="let option of priority_c_List">
                <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>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item>
          <nz-form-label [nzSpan]="5" nzRequired nzFor="score">积分</nz-form-label>
          <nz-form-control [nzSpan]="19" nzErrorTip="请选择积分!">
            <nz-select [nzDropdownMatchSelectWidth]="false" formControlName="score" nzShowSearch
              nzPlaceHolder="请选择积分" nzServerSearch>
              <ng-container *ngFor="let data of scoreList">
                <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>
        <nz-form-item>
          <nz-form-label [nzSpan]="5" nzRequired nzFor="userGroup">分配方式</nz-form-label>
          <nz-form-control [nzSpan]="19" nzErrorTip="请选择分配方式!">
            <nz-radio-group formControlName="userGroup" (ngModelChange)="changeUserGroup($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>
          <nz-form-label [nzSpan]="5" nzRequired nzFor="groupId">维修组</nz-form-label>
          <nz-form-control [nzSpan]="19" nzErrorTip="请选择维修组!">
            <nz-select (nzOnSearch)="changeInp('group', $event)" [nzDropdownMatchSelectWidth]="false" nzServerSearch nzShowSearch nzAllowClear formControlName="groupId" nzPlaceHolder="请选择维修组" (ngModelChange)="changeGroup($event)">
              <ng-container *ngFor="let option of groupList">
                <nz-option *ngIf="!isLoading" [nzLabel]="option.groupName" [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="validateConfigForm.value.userGroup === 1">
          <nz-form-label [nzSpan]="5" nzRequired nzFor="userId">维修人</nz-form-label>
          <nz-form-control [nzSpan]="19" nzErrorTip="请选择维修人!">
            <nz-select (nzOnSearch)="changeInp('user', $event)" [nzDropdownMatchSelectWidth]="false" nzServerSearch nzShowSearch nzAllowClear formControlName="userId" nzPlaceHolder="请选择维修人">
              <ng-container *ngFor="let option of userList">
                <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>
          </nz-form-control>
        </nz-form-item>
      </form>
    </div>
    <div class=" display_flex justify-content_flex-center">
      <button nzType="primary" nz-button (click)="submitConfigForm()" [nzLoading]="btnLoading">确认</button>
      <button class="btn cancel" nz-button nzType="default" (click)="hideConfigModal()">取消</button>
    </div>
  </div>
</div>

<!-- 新增/编辑故障现象模态框 -->
<div class="save display_flex justify-content_flex-center align-items_center add" *ngIf="modalCategory">
  <div class="modalBody">
    <div class="title">{{modelName}}<i class="icon_transport transport-guanbi" (click)="hideCategoryModal()"></i></div>
    <div class="content">
      <div class="tips" *ngIf="coopType === 1 && add">您将添加一级故障现象，请输入故障现象</div>
      <div class="tips" *ngIf="coopType === 2 && add">您将在“<span class="red">{{activeCategory1.category}}</span>”下新增故障现象，请输入故障现象</div>
      <div class="tips" *ngIf="coopType === 3 && add">您将在“<span class="red">{{activeCategory1.category}}{{activeCategory2.category ? ' - ' + activeCategory2.category : ''}}</span>”下新增故障现象，请输入故障现象</div>
      <form nz-form [formGroup]="validateCategoryForm" class="addForm">
        <nz-form-item *ngIf="!add && (coopType === 2 || coopType === 3)">
          <nz-form-label nzFor="category1" nzRequired [nzSpan]="6">一级故障现象</nz-form-label>
          <nz-form-control [nzSpan]="24" nzErrorTip="请选择一级故障现象!">
						<nz-select class="formItem" [nzDropdownMatchSelectWidth]="false" nzPlaceHolder="请选择一级故障现象" formControlName="category1" (ngModelChange)="changeOneCategory($event)">
						  <ng-container *ngFor="let option of categoryListP1">
						    <nz-option *ngIf="!isLoading" [nzLabel]="option.category" [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="!add && coopType === 3">
          <nz-form-label nzFor="category2" nzRequired [nzSpan]="6">二级故障现象</nz-form-label>
          <nz-form-control [nzSpan]="24" nzErrorTip="请选择二级故障现象!">
						<nz-select class="formItem" [nzDropdownMatchSelectWidth]="false" nzPlaceHolder="请选择二级故障现象" formControlName="category2">
						  <ng-container *ngFor="let option of categoryListP2">
						    <nz-option *ngIf="!isLoading" [nzLabel]="option.category" [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 nzFor="category" nzRequired [nzSpan]="6" *ngIf="!add">故障现象名称</nz-form-label>
          <nz-form-control [nzSpan]="24" nzErrorTip="请输入故障现象名称!">
            <nz-input-group>
              <textarea formControlName="name" nz-input placeholder="请输入故障现象名称" [nzAutosize]="{minRows: 3}"></textarea>
            </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)="submitCategoryForm()" [nzLoading]="btnLoading">确认</button>
      <button class="btn cancel" nz-button nzType="default" (click)="hideCategoryModal()">取消</button>
    </div>
  </div>
</div>

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

<!-- 删除模态框 -->
<app-dialog-delete [delModal]="delModal" (hideDelModalEvent)="hideDelModal()" [btnLoading]="btnLoading"
(confirmDelEvent)="confirmDel()" [content]="tipsMsg1"></app-dialog-delete>
