<div class="list-template">
  <div class="list-template__content">
    <div class="list-template__top" nz-row>
      <div nz-col nzXl='18' class="list-template__searchBox">
				<div class="list-template__searchItem">
				  <span class="label">任务标题</span>：
				  <input nz-input class="formItem" [(ngModel)]="taskTitle" placeholder="请输入任务标题" nzSize="default" />
				</div>
				<div class="list-template__searchItem">
				  <span class="label">责任人：</span>
					<nz-select class="formItem" [nzDropdownMatchSelectWidth]="false" nzServerSearch nzShowSearch
					  (nzOnSearch)="changeUser($event)" nzAllowClear nzPlaceHolder="请选择执行人员" [(ngModel)]="liableUser">
					  <ng-container *ngFor="let option of dutyUser">
					    <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" nzShowSearch nzPlaceHolder="请选择优先级" [(ngModel)]="priority">
            <ng-container *ngFor="let option of priorityData">
              <nz-option [nzLabel]="option.name" [nzValue]="option.id"></nz-option>
            </ng-container>
          </nz-select>
        </div>
				<div class="list-template__searchItem">
				  <span class="label width-105">开始时间区间：</span>
				  <nz-range-picker nzShowTime [(ngModel)]="dateRange" (ngModelChange)="changeDate($event)"></nz-range-picker>
				</div>
      </div>
      <div nz-col nzXl='6' class="list-template__btns">
        <button nz-button class="btn default" (click)='search()'>搜索</button>
        <button nz-button class="btn ml8 default" (click)='reset()'>重置</button>
        <button nz-button *ngIf="coopBtns.add" class="btn ml8 default" (click)="showModal()">新增</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>任务标题</th>
            <th>任务描述</th>
            <th>优先级</th>
            <th>责任人</th>
            <th>开始时间</th>
						<th>结束时间</th>
						<th>状态</th>
            <th nzWidth="250px">操作</th>
          </tr>
        </thead>
        <tbody>
          <tr *ngFor="let data of listOfData;let index=index;">
            <td>{{ data.taskTitle||'-' }}</td>
            <td>{{ data.taskDescribe||'-' }}</td>
            <td>{{ data.priority && data.priority.name||'-'}}</td>
            <td>{{ data.liableUserDTO && data.liableUserDTO.name||'-' }}</td>
            <td>{{ data.startTime | date:'yyyy-MM-dd HH:mm:ss' }}</td>
            <td>{{ data.endTime | date:'yyyy-MM-dd HH:mm:ss' }}</td>
						<td>{{ data.state && data.state.name||'-'}}</td>
            <td>
              <div class="coop">
                <span *ngIf="coopBtns.edit && data.state.value==1" (click)="edit(data)">编辑</span>
                <span *ngIf="coopBtns.del && data.state.value==1" (click)="del(data)">删除</span>
								<span *ngIf="coopBtns.allocation && data.state.value==1" (click)="allocation(data)">分配任务</span>
								<span *ngIf="coopBtns.accomplish && data.state.value==1" (click)="accomplish(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>
<!-- 新增/编辑模态框 -->
<div class="save add display_flex align-items_center justify-content_flex-center" *ngIf="modal">
  <div class="modalBody">
    <div class="title">{{add?"新增":"编辑"}}<i class="icon_transport transport-guanbi" (click)="hideModal()"></i>
    </div>
    <div class="content">
      <form nz-form [formGroup]="validateForm" class="addForm" (ngSubmit)="submitForm()">
        <nz-form-item>
          <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="taskTitle">任务标题</nz-form-label>
          <nz-form-control nzErrorTip="请选择任务标题!">
            <nz-input-group>
        			<input nz-input class="formItem" formControlName="taskTitle" placeholder="请输入任务标题" nzSize="default" />
            </nz-input-group>
          </nz-form-control>
        </nz-form-item>
				
				<nz-form-item>
				  <nz-form-label class="margin-label" [nzSm]="6" [nzXs]="24" nzRequired nzFor="taskDescribe">任务描述</nz-form-label>
				  <nz-form-control nzErrorTip="请选择任务描述!">
				    <nz-input-group>
							<textarea formControlName="taskDescribe" nz-input rows="3" placeholder="请输入任务描述"></textarea>
						</nz-input-group>
				  </nz-form-control>
				</nz-form-item>
				
				<nz-form-item>
          <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="priority">优先级</nz-form-label>
          <nz-form-control nzErrorTip="请选择优先级!">
            <nz-input-group>
							<nz-select class="formItem" [nzDropdownMatchSelectWidth]="false" nzShowSearch nzPlaceHolder="请选择优先级" formControlName="priority">
							  <ng-container *ngFor="let option of priorityData">
							    <nz-option [nzLabel]="option.name" [nzValue]="option.id"></nz-option>
							  </ng-container>
							</nz-select>
            </nz-input-group>
          </nz-form-control>
        </nz-form-item>
				
				<nz-form-item *ngIf="add">
				  <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="liableUser">责任人</nz-form-label>
				  <nz-form-control nzErrorTip="请选择责任人!">
				    <nz-input-group>
							<nz-select class="formItem" [nzDropdownMatchSelectWidth]="false" nzServerSearch nzShowSearch
							  (nzOnSearch)="changeUser($event)" nzAllowClear nzPlaceHolder="请选择责任人" formControlName="liableUser">
								<ng-container *ngFor="let option of dutyUser">
								  <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-input-group>
				  </nz-form-control>
				</nz-form-item>
				
				<nz-form-item *ngIf="!add">
				  <nz-form-label [nzSm]="6" [nzXs]="24" nzFor="liableUserNmae">责任人</nz-form-label>
				  <nz-form-control nzErrorTip="请选择责任人!">
				    <nz-input-group>
							<input nz-input class="formItem" disabled formControlName="liableUserNmae" placeholder="请选择责任人" nzSize="default" />
				    </nz-input-group>
				  </nz-form-control>
				</nz-form-item>
				
				<div class="df">
					<nz-form-item>
					  <nz-form-label [nzSm]="8" [nzXs]="24" nzRequired nzFor="startTime">开始时间</nz-form-label>
					  <nz-form-control nzErrorTip="请选择开始时间!">
					    <nz-input-group>
					      <nz-date-picker
									nzShowTime
									nzFormat="yyyy-MM-dd HH:mm:ss"
									nzPlaceHolder="请选择开始时间"
									formControlName="startTime"
									(ngModelChange)="onStartChange($event)"
								></nz-date-picker>
					    </nz-input-group>
					  </nz-form-control>
					</nz-form-item>
					
					<nz-form-item>
					  <nz-form-label [nzSm]="8" [nzXs]="24" nzRequired nzFor="endTime">结束时间</nz-form-label>
					  <nz-form-control nzErrorTip="请选择结束时间!">
					    <nz-input-group>
					      <nz-date-picker
									nzShowTime
									nzFormat="yyyy-MM-dd HH:mm:ss"
									nzPlaceHolder="请选择结束时间"
									formControlName="endTime"
									(ngModelChange)="onEndChange($event)"
								></nz-date-picker>
					    </nz-input-group>
					  </nz-form-control>
					</nz-form-item>
				</div>
      </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)="hideModal()">取消</button>
    </div>
  </div>
</div>

<!-- 分配任务 -->
<div class="save add display_flex align-items_center justify-content_flex-center" *ngIf="allocationModal">
  <div class="modalBody">
    <div class="title">分配任务<i class="icon_transport transport-guanbi" (click)="hideAllocationModal()"></i>
    </div>
    <div class="content">
      <form nz-form [formGroup]="validateAllocationForm" class="addForm" (ngSubmit)="submitAllocationForm()">
				
				<nz-form-item>
				  <nz-form-label class="margin-label" [nzSm]="6" [nzXs]="24" nzRequired nzFor="taskContent">任务内容</nz-form-label>
				  <nz-form-control nzErrorTip="请选择任务内容!">
				    <nz-input-group>
							<textarea formControlName="taskContent" nz-input rows="3" placeholder="请输入任务内容"></textarea>
						</nz-input-group>
				  </nz-form-control>
				</nz-form-item>
				
				<nz-form-item>
				  <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="executor">执行人</nz-form-label>
				  <nz-form-control nzErrorTip="请选择执行人!">
				    <nz-input-group>
							<nz-select class="formItem" [nzDropdownMatchSelectWidth]="false" nzServerSearch nzShowSearch
							  (nzOnSearch)="changeUser($event)" nzAllowClear nzPlaceHolder="请选择执行人" formControlName="executor">
							  <ng-container *ngFor="let option of dutyUser">
							    <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-input-group>
				  </nz-form-control>
				</nz-form-item>
				
				<nz-form-item>
          <nz-form-label [nzSm]="8" [nzXs]="24" nzRequired nzFor="estimatedCompletionTime">预计完成时间</nz-form-label>
          <nz-form-control nzErrorTip="请选择预计完成时间!">
            <nz-input-group>
              <nz-date-picker
								class="width-100"
								nzShowTime
								nzFormat="yyyy-MM-dd HH:mm:ss"
								nzPlaceHolder="请选择预计完成时间"
								formControlName="estimatedCompletionTime"
								(ngModelChange)="onAllocationChange($event)"
							></nz-date-picker>
            </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)="submitAllocationForm()" [nzLoading]="btnLoading">确认</button>
      <button class="btn cancel" nz-button nzType="default" (click)="hideAllocationModal()">取消</button>
    </div>
  </div>
</div>
<!-- 任务完成 -->
<div class="save add display_flex align-items_center justify-content_flex-center" *ngIf="accomplishModal">
  <div class="modalBody">
    <div class="title">任务完成<i class="icon_transport transport-guanbi"></i>
    </div>
    <div class="content padding-bottom">
			<span class="label"><span class="sign">*</span> 月度任务总结:</span>
      <textarea [(ngModel)]="taskConclusion" nz-input rows="3" placeholder="请输入任务内容"></textarea>
    </div>
    <div class="display_flex justify-content_flex-center">
      <button nzType="primary" nz-button (click)="submitAccomplishForm()" [nzLoading]="btnLoading">确认</button>
      <button class="btn cancel" nz-button nzType="default" (click)="hideAccomplishModal()">取消</button>
    </div>
  </div>
</div>
<!-- 删除模态框 -->
<app-dialog-delete [delModal]="delModal" (hideDelModalEvent)="hideDelModal()" [btnLoading]="btnLoading" 
  (confirmDelEvent)="confirmDel()" (cancelDelEvent)="cancelDel()" content="您确认要删除吗？" confirmTxt="是" cancelTxt="否">
</app-dialog-delete>

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

<!-- 查看详情 -->
<router-outlet (deactivate)="getList()"></router-outlet>

