<div class="list-template">
  <div class="list-template__content">
    <div class="list-template__top" nz-row>
      <div nz-col nzLg='20' class="list-template__searchBox">
        <div class="list-template__searchItem">
          <span class="label">科室：</span>
          <nz-select class="formItem" [nzDropdownMatchSelectWidth]="false" (nzOnSearch)="changeInp($event,'dept')" nzServerSearch nzShowSearch nzPlaceHolder="请选择科室" [(ngModel)]="department">
            <ng-container *ngFor="let option of hospitals1">
              <nz-option *ngIf="!isDeptLoading" [nzLabel]="option.dept" [nzValue]="option.id"></nz-option>
            </ng-container>
            <nz-option *ngIf="isDeptLoading" 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" (nzOnSearch)="changeInp($event,'drug')" nzServerSearch nzShowSearch nzPlaceHolder="请选择药品" [(ngModel)]="drug">
					  <ng-container *ngFor="let option of drugData">
					    <nz-option *ngIf="!isDeptLoading" [nzLabel]="option.drugName + '('+option.specs+')'" [nzValue]="option.id"></nz-option>
					  </ng-container>
					  <nz-option *ngIf="isDeptLoading" nzDisabled nzCustomContent>
					    <i nz-icon nzType="loading" class="loading-icon"></i> 搜索中...
					  </nz-option>
					</nz-select>
        </div>
      </div>
      <div nz-col nzLg="4" class="list-template__btns">
        <button class="btn default" (click)='search()'>搜索</button>
        <button class="btn default ml8" (click)='reset()'>重置</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="10%">科室名称</th>
						<th nzWidth="10%">药品标识</th>
            <th nzWidth="20%">药品名称</th>
            <th nzWidth="10%">规格</th>
            <th nzWidth="20%">库存数量（正负值）</th>
            <th nzWidth="20%">库存价值（正负值）</th>
            <th nzWidth="10%">操作</th>
          </tr>
        </thead>
        <tbody>
          <tr *ngFor="let data of listOfData" (click)="selectedListData(data.id)">
            <td>{{ data.departmentDTO?data.departmentDTO.dept:'-' }}</td>
						<td>{{ data.drugsInfoDTO?data.drugsInfoDTO.drugCode:'-' }}</td>
            <td>{{ data.drugsInfoDTO?data.drugsInfoDTO.drugName:'-' }}</td>
            <td>{{ data.drugsInfoDTO?data.drugsInfoDTO.specs:'0' }}</td>
            <td>{{ data.inventoryNum || '0' }}</td>
            <td>{{ data.inventoryPrice || '0' }}</td>
            <td>
              <div class="coop">
                <span *ngIf="coopBtns.historyRecord" (click)="detail($event,data)">历史记录</span>
              </div>
            </td>
          </tr>
        </tbody>
      </nz-table>
      <div class="list-template__pagination">
        <nz-pagination [(nzPageIndex)]="pageIndex" [(nzTotal)]="listLength" nzShowSizeChanger [(nzPageSize)]="pageSize"
          (nzPageIndexChange)="getList()" (nzPageSizeChange)="getList()">
        </nz-pagination>
      </div>
    </div>
  </div>

  <!-- 历史记录 -->
  <div class="save add display_flex align-items_center justify-content_flex-center" *ngIf="modal">
    <div class="modalBody">
      <div class="title">历史记录<i class="icon_transport transport-guanbi" (click)="hideModal()"></i>
      </div>
      <overlay-scrollbars #osComponentRef1 class="content">
        <div class="list-template__bottom">
          <nz-table class="list-template__nzTable" [nzData]="viewData" nzSize="middle" [nzShowPagination]="false"
            [nzLoading]="loading1">
            <thead>
              <tr class="thead">
                <th nzWidth="13%">时间</th>
                <th nzWidth="13%">批次号</th>
								<th nzWidth="13%">发药单号</th>
                <th nzWidth="8%">消耗数量</th>
								<th nzWidth="8%">原库存数</th>
								<th nzWidth="7%">增减</th>
                <th nzWidth="10%">包装规格</th>
                <th nzWidth="10%">发药药箱</th>
								<th nzWidth="8%">实发数量</th>
                <th nzWidth="10%">计算后库存</th>
              </tr>
            </thead>
            <tbody>
              <tr *ngFor="let data of viewData">
                <td>{{ data.createTime|date:'yyyy-MM-dd HH:mm'}}</td>
                <td>{{ data.drugsList?data.drugsList.batch.batchNo : '无' }}</td>
                <td>{{ data.drugsList?data.drugsList.packingNo : '无' }}</td>
								<td>{{ data.drugsConfig?data.drugsConfig.expendCount:'0' }}</td>
								<td>{{ data.drugsConfig&&data.drugsConfig.formerInventory?data.drugsConfig.formerInventory:'0' }}</td>
								<td>{{ data.drugsConfig&&data.drugsConfig.addSub?data.drugsConfig.addSub:'0' }}</td>
                <td>{{ data.drugsInfo?data.drugsInfo.packingSpecs:'0' }}</td>
                <td>{{ data.drugsConfig?data.drugsConfig.cartonNum : '0' }}</td>
                <td>{{ data.drugsConfig?data.drugsConfig.actualCount : '0'}}</td>
        				<td>{{ data.drugsConfig?data.drugsConfig.afterInventory : '0' }}</td>
              </tr>
            </tbody>
          </nz-table>
        <!--  <div class="list-template__pagination">
            <nz-pagination [(nzPageIndex)]="pageIndex" [(nzTotal)]="listLength" nzShowSizeChanger [(nzPageSize)]="pageSize"
              (nzPageIndexChange)="getList()" (nzPageSizeChange)="getList()">
            </nz-pagination>
          </div> -->
        </div>
      </overlay-scrollbars>
      <div class="display_flex justify-content_flex-center">
        <button class="btn" nz-button nzType="primary" (click)="hideModal()">知道了</button>
      </div>
    </div>
  </div>

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

<app-excel-import [isShow]="isShow" (hideFormHand)="hideExcelImport($event)" *ngIf="isShow" (submitFormHand)="submitExcelImport($event)"></app-excel-import>
