<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)" nzServerSearch nzShowSearch nzAllowClear 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>
          <input nz-input class="formItem" [(ngModel)]="batchNumber" placeholder="请输入批次号" nzSize="default" />
        </div>
        <div class="list-template__searchItem">
          <span class="label">创建时间：</span>
          <nz-range-picker [(ngModel)]="dateRange" nzFormat="yyyy-MM-dd"
					(ngModelChange)="changeDate($event)"></nz-range-picker>
        </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="10%">申请科室</th>
            <th nzWidth="7%">总件数</th>
            <th nzWidth="7%">品类数</th>
            <th nzWidth="7%">消耗总价</th>
            <th nzWidth="7%">实发总价</th>
            <th nzWidth="10%">取药药房</th>
						<th nzWidth="7%">是否已建单</th>
						<th nzWidth="6%">状态</th>
            <th nzWidth="18%">操作</th>
          </tr>
        </thead>
        <tbody v-if="listOfData && listOfData.length>0">
          <tr *ngFor="let data of listOfData" (click)="selectedListData(data.id)">
            <td>
							<div>{{ data.packingNo}}</div>
							<div>{{ data.createTime|date:'yyyy-MM-dd HH:mm'}}</div>
						</td>
            <td>{{ data.batch?data.batch.batchNo:'-' }}</td>
            <td>{{ data.applyDeptDTO?data.applyDeptDTO.dept :'-' }}</td>
            <td>{{ data.totalCount||'0' }}</td>
            <td>{{data.kindCount||'0'}}</td>
            <td>{{ data.expendPrice ||'0' }}</td>
            <td>{{ data.actualPrice || '0'}}</td>
            <td>{{ data.pharmacyDTO?data.pharmacyDTO.dept:'-'}}</td>
						<td>{{ data.createOrder==1?'是':'否'}}</td>
						<td>{{ data.orderState.name}}</td>
            <td>
              <div class="coop">
                <span *ngIf="coopBtns.look" (click)="detail($event,data.id)">查看</span>
                <span *ngIf="coopBtns.print" (click)="print($event, data, data.id)">打印</span>
                <span *ngIf="coopBtns.establish && ( data.createOrder=='0' || data.createOrder==null)" (click)="addDateModal(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="10%">药品标识</th>
                <th nzWidth="10%">药品名称</th>
                <th nzWidth="10%">规格</th>
                <th nzWidth="10%">消耗数量</th>
                <th nzWidth="10%">实发数量</th>
                <th nzWidth="10%">包装规格</th>
                <th nzWidth="10%">发药药箱</th>
                <th nzWidth="10%">原库存数</th>
                <th nzWidth="10%">计算后库存</th>
        				<th nzWidth="10%">增减</th>
              </tr>
            </thead>
            <tbody>
              <tr *ngFor="let data of viewData">
								<td>{{ data.drugsInfoDTO?data.drugsInfoDTO.drugCode:'无' }}</td>
                <td>{{ data.drugsInfoDTO?data.drugsInfoDTO.drugName:'无' }}</td>
                <td>{{ data.drugsInfoDTO?data.drugsInfoDTO.specs:'无' }}</td>
                <td>{{ data.expendCount||'0' }}</td>
                <td>{{ data.actualCount||'0' }}</td>
                <td>{{ data.drugsInfoDTO?data.drugsInfoDTO.packingSpecs:'0' }}</td>
                <td>{{ data.cartonNum || '0' }}</td>
                <td>{{ data.formerInventory || '0' }}</td>
                <td>{{ data.afterInventory || '0'}}</td>
        				<td>{{ data.addSub || '0' }}</td>
              </tr>
            </tbody>
          </nz-table>
        </div>
      </overlay-scrollbars>
      <div class="display_flex justify-content_flex-center">
        <button class="btn" nz-button nzType="primary" (click)="hideModal()">知道了</button>
      </div>
    </div>
  </div>
  <!-- 删除模态框 -->
  <app-dialog-delete [delModal]="delModal" (hideDelModalEvent)="hideDelModal()" [btnLoading]="btnLoading"
    (confirmDelEvent)="confirmDel()" content="您确认要删除科室吗？"></app-dialog-delete>

  <!-- 启用停用模态框 -->
  <app-dialog-delete [delModal]="delModal1" (hideDelModalEvent)="hideDelModal1()" [btnLoading]="btnLoading"
    (confirmDelEvent)="confirmDel1()" [content]="'您确认要建立配送工单吗？'"></app-dialog-delete>

  <!-- 打印 -->
  <div id="report" style="display: none;">
		<div class="monad" 
				*ngIf="rowData"
				style="padding: 10px;
				border: 1px solid #e7e7e7;
				border-radius: 5px;">
			<div class="monad-title" 
				style="text-align: center;
				font-size: 18px;
				border-bottom: 1px solid #e7e7e7;
				padding-bottom: 10px;">
				大输液发药单-{{rowData.applyDeptDTO?rowData.applyDeptDTO.dept:''}}
			</div>
			<div class="monad-sign" style="display: flex;line-height: 23px;font-size: 14px;">
				<div style="margin-right: 15px;">日期：{{rowData.createTime|date:'yyyy-MM-dd HH:mm'}}</div>
				<div style="margin-right: 15px;">批次号：{{rowData.batch?rowData.batch.batchNo:'-'}}</div>
				<div style="margin-right: 15px;">单号：{{rowData.packingNo}}</div>
			</div>
			<div class="monad-sign" style="display: flex;line-height: 23px;font-size: 14px;">
				<div style="margin-right: 15px;">取药药房：{{rowData.pharmacyDTO?rowData.pharmacyDTO.dept:'-'}}</div>
			</div>
			<div style="border: 1px solid #e7e7e7;border-bottom: none;font-size: 14px;">
				<div class="thead" style="display: flex;">
					<div style="width: 40%;display: flex;font-size: 12px;
					align-items: center;
					justify-content: center;
					flex-wrap: wrap;
					border-right: 1px solid #e7e7e7;
					border-bottom: 1px solid #e7e7e7;">药品名称</div>
					
					<div style="width: 20%;display: flex;font-size: 12px;
					align-items: center;
					justify-content: center;
					flex-wrap: wrap;
					border-right: 1px solid #e7e7e7;
					border-bottom: 1px solid #e7e7e7;">规格</div>
					
					<div style="width: 10%;display: flex;font-size: 12px;
					align-items: center;
					justify-content: center;
					flex-wrap: wrap;
					border-right: 1px solid #e7e7e7;
					border-bottom: 1px solid #e7e7e7;">15日消耗</div>
					
					<div style="width: 8%;display: flex;font-size: 12px;
					align-items: center;
					justify-content: center;
					flex-wrap: wrap;
					border-right: 1px solid #e7e7e7;
					border-bottom: 1px solid #e7e7e7;">包规</div>
					
					<div style="width: 8%;display: flex;font-size: 12px;
					align-items: center;
					justify-content: center;
					flex-wrap: wrap;
					border-right: 1px solid #e7e7e7;
					border-bottom: 1px solid #e7e7e7;">实消</div>
					
					<div style="width: 10%;display: flex;font-size: 12px;
					align-items: center;
					justify-content: center;
					flex-wrap: wrap;
					border-right: 1px solid #e7e7e7;
					border-bottom: 1px solid #e7e7e7;">临时增发</div>
					
					<div style="width: 10%;display: flex;font-size: 12px;
					align-items: center;
					justify-content: center;
					flex-wrap: wrap;
					border-bottom: 1px solid #e7e7e7;">箱数</div>
				</div>
				<div *ngFor="let data of codes" style="display: flex;">
					<div style="width: 40%;display: flex;font-size: 12px;
					align-items: center;
					justify-content: center;
					flex-wrap: wrap;
					border-right: 1px solid #e7e7e7;
					border-bottom: 1px solid #e7e7e7;">{{ data.drugsInfoDTO.drugName }}</div>
					
					<div style="width: 20%;display: flex;font-size: 12px;
					align-items: center;
					justify-content: center;
					flex-wrap: wrap;
					border-right: 1px solid #e7e7e7;
					border-bottom: 1px solid #e7e7e7;">{{ data.drugsInfoDTO.specs }}</div>
					
					<div style="width: 10%;display: flex;font-size: 12px;
					align-items: center;
					justify-content: center;
					flex-wrap: wrap;
					border-right: 1px solid #e7e7e7;
					border-bottom: 1px solid #e7e7e7;">{{data.fifteenExpendCount}}</div>
					
					<div style="width: 8%;display: flex;font-size: 12px;
					align-items: center;
					justify-content: center;
					flex-wrap: wrap;
					border-right: 1px solid #e7e7e7;
					border-bottom: 1px solid #e7e7e7;">{{ data.drugsInfoDTO.packingSpecs }}</div>
					
					<div style="width: 8%;display: flex;font-size: 12px;
					align-items: center;
					justify-content: center;
					flex-wrap: wrap;
					border-right: 1px solid #e7e7e7;
					border-bottom: 1px solid #e7e7e7;">{{ data.expendCount }}</div>
					
					<div style="width: 10%;display: flex;font-size: 12px;
					align-items: center;
					justify-content: center;
					flex-wrap: wrap;
					border-right: 1px solid #e7e7e7;
					border-bottom: 1px solid #e7e7e7;">{{ data.addSub || 0 }}</div>
					
					<div style="width: 10%;display: flex;font-size: 12px;
					align-items: center;
					justify-content: center;
					flex-wrap: wrap;
					border-bottom: 1px solid #e7e7e7;">
						<span *ngIf="data.drugsInfoDTO.drugName!='合计'">
							{{ data.giveOutType.value==1 ? data.actualCount :data.cartonNum }}
							{{data.giveOutType && data.giveOutType.value==1?
							data.drugsInfoDTO.unit:'箱'}}
						</span>
						<span *ngIf="data.drugsInfoDTO.drugName=='合计'">
							{{ data.cartonActual}}
						</span>
					</div>
					
				</div>
			</div>
		</div>
  </div>

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

<!-- 查看详情 -->
<router-outlet></router-outlet>
<!-- 遮罩 -->
<app-mask *ngIf="maskFlag"></app-mask>
<app-excel-import [isShow]="isShow" (hideFormHand)="hideExcelImport($event)" *ngIf="isShow" (submitFormHand)="submitExcelImport($event)"></app-excel-import>
