<div class="list-template detail-box">
  <div class="list-template__content">
		<div class="detail-title">
			<h3 *ngIf="deptName">{{deptName}}-发药单</h3>
			<button class="btn right-btn" nz-button nzType="primary" (click)="back()">返回</button>
		</div>
    <div class="list-template__bottom" style="padding: 0 !important;">
      <nz-table class="list-template__nzTable" [nzData]="listOfData" nzSize="middle" [nzShowPagination]="false"
        [nzLoading]="loading1">
        <thead>
          <tr class="thead">
            <th nzWidth="25%">药品名称</th>
            <th>规格</th>
						<th>实消</th>
						<th>15日消耗</th>
						<th>原库存</th>
						<th>包规</th>
						<th>发药箱数</th>
						<th>实发</th>
            <th>新库存</th>
						<th>增减</th>
            <th>操作</th>
          </tr>
        </thead>
        <tbody>
          <tr *ngFor="let data of listOfData">
            <td nz-tooltip [nzTooltipTitle]="data.drugsInfoDTO.drugCode" style="position: relative;">
							<div class="sign" *ngIf="data.giveOutType.value=='1'"></div>
							{{ data.drugsInfoDTO?data.drugsInfoDTO.drugName:'-' }}
						</td>
            <td>{{ data.drugsInfoDTO?data.drugsInfoDTO.specs:'-' }}</td>
            <td>{{ data.expendCount||'0' }}</td>
						<td>{{ data.fifteenExpendCount||'0' }}</td>
            <td>{{ data.formerInventory || '0' }}</td>
            <td>{{ data.drugsInfoDTO?data.drugsInfoDTO.packingSpecs:'0' }}</td>
						<td>{{ data.cartonNum || 0 }}</td> 
						<td>{{ data.actualCount||'0' }}</td>
						<td>{{ data.afterInventory||'0' }}</td>
						<td>{{ data.addSub||'0' }}</td>
            <td>
              <div class="coop">
                <span (click)="itemClick($event, data, 'add')">增发</span>
								<!-- <span (click)="itemClick($event, data, 'del')">减少</span> -->
								<span (click)="grantClick($event, data)">{{data.giveOutType.value=='2'?'单发':'箱发'}}</span>
							</div>
            </td>
          </tr>
        </tbody>
      </nz-table>
    </div>
  </div>
	<div class="right-content">
		<div class="right-top">
			<h3 class="title">快速添加发药科室</h3>
			<div class="right-template">
			  <span class="label">科室：</span>
			  <nz-select class="formItem" (ngModelChange)="deptChange($event)" [nzDropdownMatchSelectWidth]="false" 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>
				<span (click)='addDept()' class="icon_transport transport-tag27fuben add-class"></span>
			</div>
		</div>
		<div class="right-bottom">
			<h3 class="title">发药科室列表</h3>
			<div class="right-template">
			  <span class="label">楼栋：</span>
			  <nz-select class="formItem" (ngModelChange)="buildingChange($event)" [nzDropdownMatchSelectWidth]="false" nzServerSearch nzShowSearch
			    (nzOnSearch)="changeInp($event, 'building')" nzAllowClear nzPlaceHolder="请选择楼栋" [(ngModel)]="building">
			    <ng-container *ngFor="let option of buildingList">
			      <nz-option *ngIf="!isDeptLoading" [nzLabel]="option.buildingName" [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="dept-box">
				<div *ngFor="let item of deptList;let index=index;" class="dept-item" 
					[ngClass]="{'activeClass': index == deptIndex}" (click)="deptClick($event,item,index)">
					<div>{{item.applyDeptDTO?item.applyDeptDTO.dept:'-'}}</div>
					<span class="icon_transport transport-lajitong" (click)="deptDel($event,item,index)"></span>
				</div>
			</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">
       <form nz-form [formGroup]="validateForm" class="addForm" (ngSubmit)="submitForm()">
       	<nz-form-item *ngIf="add">
       	  <nz-form-label nzRequired nzFor="addNum">增发数量<span class="color-stylr"> (支持负数)</span></nz-form-label>
       	  <nz-form-control nzErrorTip="请选择增发数量!">
       	    <nz-input-group>
       				<nz-input-number
								nz-input
       					formControlName="addNum"
       					[nzMin]="-999999"
       					[nzPrecision]="0"
       					[nzMax]="999999"
       					[nzStep]="1"
       					[nzPlaceHolder]="'请填写增发数量'"
       				 ></nz-input-number>
       			</nz-input-group>
       	  </nz-form-control>
       	</nz-form-item>
				<div *ngIf="rowData.giveOutType.value=='2'" style="text-align: left;" [ngClass]="{'red': isRight == false, 'green': isRight == true}">(消耗数+原库存数 + 增发数量) / 包装规格 = 1 (计算后数量必须是整数) </div>
		<!-- 		<nz-form-item *ngIf="!add">
				  <nz-form-label nzRequired nzFor="delNum">减少数量</nz-form-label>
				  <nz-form-control nzErrorTip="请选择减少数量!">
				    <nz-input-group>
							<nz-input-number
								nz-input
								formControlName="delNum"
								[nzMin]="0"
								[nzPrecision]="0"
								[nzMax]="999999"
								[nzStep]="1"
								[nzPlaceHolder]="'请填写减少数量'"
							 ></nz-input-number>
						</nz-input-group>
				  </nz-form-control>
				</nz-form-item> -->
       </form>
      </overlay-scrollbars>
      <div class="display_flex justify-content_flex-center">
        <button class="btn" nz-button nzType="primary" (click)="submitForm()" [nzLoading]="btnLoading">保存</button>
    		<button class="btn cancel" nz-button nzType="default" (click)="hideModal()">取消</button>
      </div>
    </div>
  </div>
	<div class="mask-style" *ngIf="isSpinning">
		<nz-spin nzSimple class="spin-style"></nz-spin>
	</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="您确认要删除发药科室吗？"></app-dialog-delete>

<!-- 单发/箱发 -->
  <app-dialog-delete [delModal]="delGrantModal" (hideDelModalEvent)="hideGrantModal()" [btnLoading]="btnLoading"
    (confirmDelEvent)="confirmGrantDel()" [content]="content"></app-dialog-delete>

