<div class="list-template">
  <div class="list-template__content">
    <div class="list-template__top" nz-row>
      <div nz-col nzXl='16' class="list-template__searchBox">
        <div class="list-template__searchItem">
          <span class="label" style="width: 100px;">资产编码|SN号</span>：
          <input nz-input class="formItem" placeholder="请输入资产编码|SN号" [(ngModel)]="searchDto.searchKey" />
        </div>
        <div class="list-template__searchItem">
          <span class="label">资产名称</span>：
          <input nz-input class="formItem" placeholder="请输入资产名称" [(ngModel)]="searchDto.name" />
        </div>
        <div class="list-template__searchItem">
          <span class="label">状态</span>：
          <nz-select class="formItem" [nzDropdownMatchSelectWidth]="false" nzAllowClear nzPlaceHolder="请选择状态" [(ngModel)]="searchDto.status">
            <ng-container *ngFor="let option of dispatchMethods">
              <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 class="list-template__searchItem">
          <span class="label">使用科室</span>：
          <nz-select class="formItem" [nzDropdownMatchSelectWidth]="false" nzServerSearch nzShowSearch
            (nzOnSearch)="changeInp('search', 'department', $event)" nzAllowClear nzPlaceHolder="请选择使用科室" [(ngModel)]="searchDto.deptId">
            <ng-container *ngFor="let option of departmentSearchList">
              <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>
        </div>
      </div>
      <div nz-col nzLg="8" class="list-template__btns">
        <button nz-button class="btn default ml8" (click)='search()'>搜索</button>
        <button nz-button class="btn default ml8" (click)='reset()'>重置</button>
        <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="12%">资产编号|SN号</th>
            <th nzWidth="11%">资产名称</th>
            <th nzWidth="11%">存放位置</th>
            <th nzWidth="11%">状态</th>
            <th nzWidth="11%">入库时间|有效期至</th>
            <th nzWidth="11%">关联产品</th>
            <th nzWidth="11%">供应商</th>
            <th nzWidth="11%">使用科室</th>
            <th nzWidth="11%">责任部门</th>
          </tr>
        </thead>
        <tbody>
          <tr *ngFor="let data of listOfData;let i = index">
            <td>{{data.code}}<br>{{data.snCode}}</td>
            <td>{{data.name}}</td>
            <td>{{data.buildDTO?.buildingName}}{{data.floorDTO?.floorName}}{{data.address}}</td>
            <td>{{data.status?.name}}</td>
            <td>{{data.inTime| date:'yyyy-MM-dd'}}<br>{{data.overTime| date:'yyyy-MM-dd'}}</td>
            <td>{{data.assetProductDTO?.name}}</td>
            <td>{{data.supplierDTO?.name}}</td>
            <td>{{data.deptDTO?.dept}}</td>
            <td>{{data.duty?.hosName}}</td>
          </tr>
        </tbody>
      </nz-table>
      <div class="list-template__pagination">
        <nz-pagination [(nzPageIndex)]="pageIndex" [(nzTotal)]="listLength" [(nzPageSize)]="pageSize" nzShowSizeChanger
          (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]="5" nzRequired nzFor="code">资产编码</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请输入资产编码!">
              <nz-input-group>
                  <input formControlName="code" nz-input placeholder="请输入资产编码">
              </nz-input-group>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSpan]="5" nzRequired nzFor="snCode">SN号</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请输入SN号!">
              <nz-input-group>
                  <input formControlName="snCode" nz-input placeholder="请输入SN号">
              </nz-input-group>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSpan]="5" nzRequired nzFor="productId">关联产品</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请选择关联产品!">
              <nz-select (nzOnSearch)="changeInp('add', 'assetProduct', $event)" [nzDropdownMatchSelectWidth]="false" nzServerSearch nzShowSearch formControlName="productId" nzPlaceHolder="请选择关联产品" (ngModelChange)="changeAssetProduct($event)" (nzOpenChange)="changeInp('add', 'assetProduct', '')">
                <ng-container *ngFor="let option of assetProductList">
                  <nz-option *ngIf="!isLoading" [nzLabel]="option.name + '(' + option.brand + ')' + '(' + option.model + ')'" [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="name">资产名称</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请输入资产名称!">
              <nz-input-group>
                  <input formControlName="name" nz-input placeholder="请输入资产名称">
              </nz-input-group>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSpan]="5" nzRequired nzFor="buildId">存放位置</nz-form-label>
            <nz-form-control [nzSpan]="9" nzErrorTip="请选择楼栋!">
              <nz-select (nzOnSearch)="changeInp('add', 'building', $event)" [nzDropdownMatchSelectWidth]="false" nzServerSearch nzShowSearch nzAllowClear formControlName="buildId" nzPlaceHolder="请选择楼栋" (ngModelChange)="changeBuilding($event)">
                <ng-container *ngFor="let option of buildingAddList">
                  <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-control [nzSpan]="9" [nzPush]="1" nzErrorTip="请选择楼层!">
              <nz-select (nzOnSearch)="changeInp('add', 'floor', $event)" [nzDropdownMatchSelectWidth]="false" nzServerSearch nzShowSearch nzAllowClear formControlName="floorId" nzPlaceHolder="请选择楼层">
                <ng-container *ngFor="let option of floorList">
                  <nz-option *ngIf="!isLoading" [nzLabel]="option.floorName" [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="address">具体位置</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请输入具体位置!">
              <nz-input-group>
                  <input formControlName="address" nz-input placeholder="请输入具体位置">
              </nz-input-group>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSpan]="5" nzRequired nzFor="status">状态</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请选择状态!">
              <nz-select [nzDropdownMatchSelectWidth]="false" formControlName="status" nzShowSearch
                nzPlaceHolder="请选择状态" nzServerSearch>
                <ng-container *ngFor="let data of dispatchMethods">
                  <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="brand">品牌</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请输入品牌!">
              <nz-input-group>
                  <input formControlName="brand" nz-input placeholder="请输入品牌">
              </nz-input-group>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSpan]="5" nzRequired nzFor="supplierId">供应商</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请选择供应商!">
              <nz-select [nzDropdownMatchSelectWidth]="false" nzAllowClear formControlName="supplierId" nzPlaceHolder="请选择供应商">
                <ng-container *ngFor="let option of companyList">
                  <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="deptId">使用科室</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请选择使用科室!">
              <nz-select (nzOnSearch)="changeInp('add', 'department', $event)" [nzDropdownMatchSelectWidth]="false" nzServerSearch nzShowSearch nzAllowClear formControlName="deptId" nzPlaceHolder="请选择使用科室" (nzOpenChange)="changeInp('add', 'department', '')">
                <ng-container *ngFor="let option of departmentAddList">
                  <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="dutyId">责任部门</nz-form-label>
            <nz-form-control [nzSpan]="19" nzErrorTip="请选择责任部门!">
              <nz-select [nzDisabled]="disableDutyId" (nzOnSearch)="changeInp('add', 'hospital', $event)" [nzDropdownMatchSelectWidth]="false" nzServerSearch nzShowSearch nzAllowClear formControlName="dutyId" nzPlaceHolder="请选择责任部门" (nzOpenChange)="changeInp('add', 'hospital', '')">
                <ng-container *ngFor="let option of dutyList">
                  <nz-option *ngIf="!isLoading" [nzLabel]="option.hosName" [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)="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>
