<div class="wrapper">
	<div class="panel panel-default">
		<div class="panel-body">
			<div class="m-b form-inline">
				<button ui-sref="batch.info.paperTaskUpload" class="btn btn-default" ng-if="curUserRole.code=='processManagement'">
					<i class="glyphicon glyphicon-import"> 导入命卷任务</i>
				</button>
				<button ng-click="showAddPaperTaskModal()" class="btn btn-default" ng-if="curUserRole.code=='processManagement'">
					<i class="glyphicon glyphicon-plus"> 添加命卷任务</i>
				</button>
				<button ui-sref="batch.info.paperTasksTeacherAssessments" class="btn btn-default" ng-if="curUserRole.code=='processManagement'">
					<i class="glyphicon glyphicon-list"> 所有教师评价</i>
				</button>
				<button ng-click="exportAllFiles()" class="btn btn-default" ng-if="curUserRole.code=='processManagement'">
					<i class="glyphicon glyphicon-export"> 导出试卷及答案</i>
				</button>
				<button ng-click="exportRkData()" class="btn btn-default" ng-if="curUserRole.code=='processManagement'">
					<i class="glyphicon glyphicon-scale"> 导出入库数据</i>
				</button>
				<button ng-click="exportMTJSQD()" class="btn btn-default" ng-if="curUserRole.code=='processManagement'">
					<i class="glyphicon glyphicon-export"> 导出命题教师签到</i>
				</button>
				<button ng-click="exportMTSTFGB()" class="btn btn-default" ng-if="curUserRole.code=='processManagement'">
					<i class="glyphicon glyphicon-export"> 导出分工表</i>
				</button>
				<div class="input-group col-md-3" style="width: 190px;">
		      		<div class="input-group-addon"><i class="glyphicon glyphicon-search"></i></div>
					<input type="text" class="form-control" ng-model="search.taskNo" placeholder="试卷编号" ng-change="search={taskNo:search.taskNo};matchType = false;"/>
				</div>
				<span ng-if="isBusinessManager">已完成课程：{{courseCount-unfinishedCourseCount}} / {{courseCount}}</span>
			</div>
			
			<div class="col-md-8">
				<!-- 待处理任务 -->
				<button class="btn m-b-xs {{search.curDealer == curUser.id && search.status == '!ARCHIVED' ? 'btn-info' : 'btn-todo'}}" 
					type="button" ng-click="filterBy([{'curDealer':curUser.id, 'status' : '!ARCHIVED'}, {'curDealer':curUser.id, 'status' : '!ARCHIVED_REVIEW'}])"
					ng-if="curUser != null && !isBusinessManager">
			 		 待处理 <span class="badge">{{(array | filter:{'curDealer':curUser.id, 'status' : '!ARCHIVED'}:true | filter : {'curDealer':curUser.id, 'status' : '!ARCHIVED_REVIEW'} : true).length}}</span>
				</button>
			
				<!-- 未完成任务数（业务管理员） -->
				<button class="btn m-b-xs {{search.status=='!ARCHIVED' && !search.curDealer && !search.primarySecretary 
										&& !search.assistantSecretary && !search.propositionTeacher
										&& !search.auditTeacher ? 'btn-info' : 'btn-gray'}}" 
					type="button" ng-click="filterBy({'status':'!ARCHIVED', 'batchType' : '!SHI_JUAN_FU_SHEN'})"
					ng-if="(array | filter:{'status': '!ARCHIVED', 'batchType' : '!SHI_JUAN_FU_SHEN'}).length > 0 && isBusinessManager">
			 		 未完成  <span class="badge">{{(array | filter:{'status': '!ARCHIVED', 'batchType' : '!SHI_JUAN_FU_SHEN'}).length}}</span>
				</button>
							
				<!-- 按状态统计的任务数（业务管理员） -->	
				<span ng-repeat="row in paperTaskStatus">
					<button class="btn m-b-xs {{search.status==row.key && !search.curDealer && !search.primarySecretary 
										&& !search.assistantSecretary && !search.propositionTeacher
										&& !search.auditTeacher ? 'btn-info' : 'btn-gray'}}" type="button" 
							ng-click="filterBy({'status': row.key, 'batchType' : '!SHI_JUAN_FU_SHEN'});" 
							ng-if="(array | filter:{'status': row.key, 'batchType' : '!SHI_JUAN_FU_SHEN'}:true).length > 0 && isBusinessManager">
				 		 {{row.value}} <span class="badge">{{(array | filter:{'status': row.key, 'batchType' : '!SHI_JUAN_FU_SHEN'}:true).length}}</span>
					</button>
				</span>
				
				<!-- 主审任务 -->
				<button class="btn m-b-xs {{search.status=='!ARCHIVED' && search.primarySecretary ? 'btn-info' : 'btn-orange'}}" 
					type="button" ng-click="filterBy({'primarySecretary':curUser.id,'status':'!ARCHIVED', 'batchType' : '!SHI_JUAN_FU_SHEN'})"
					ng-if="(array | filter:{'primarySecretary':curUser.id,'status':'!ARCHIVED', 'batchType' : '!SHI_JUAN_FU_SHEN'}:true).length > 0">
			 		 未完成(主审任务)  <span class="badge">{{(array | filter:{'primarySecretary':curUser.id,'status':'!ARCHIVED', 'batchType' : '!SHI_JUAN_FU_SHEN'}:true).length}}</span>
				</button>
				<span ng-repeat="row in paperTaskStatus">
					<button class="btn m-b-xs {{search.status==row.key && search.primarySecretary ? 'btn-info' : 'btn-orange'}}" type="button" 
							ng-click="filterBy({'primarySecretary':curUser.id, 'status': row.key, 'batchType' : '!SHI_JUAN_FU_SHEN'});" 
							ng-if="(array | filter:{'primarySecretary':curUser.id,'status': row.key, 'batchType' : '!SHI_JUAN_FU_SHEN'}:true).length > 0">
				 		 {{row.value}}(主) <span class="badge">{{(array | filter:{'primarySecretary':curUser.id,'status': row.key, 'batchType' : '!SHI_JUAN_FU_SHEN'}:true).length}}</span>
					</button>
				</span>
				<!-- 校对任务 -->
				<button class="btn m-b-xs {{search.status=='!ARCHIVED' && search.assistantSecretary ? 'btn-info' : 'btn-green'}}" 
					type="button" ng-click="filterBy({'assistantSecretary':curUser.id,'status':'!ARCHIVED', 'batchType' : '!SHI_JUAN_FU_SHEN'});"
					ng-if="(array | filter:{'assistantSecretary':curUser.id,'status':'!ARCHIVED', 'batchType' : '!SHI_JUAN_FU_SHEN'}:true).length > 0">
			 		 未完成(校对任务)  <span class="badge">{{(array | filter:{'assistantSecretary':curUser.id,'status':'!ARCHIVED', 'batchType' : '!SHI_JUAN_FU_SHEN'}:true).length}}</span>
				</button>
				<span ng-repeat="row in paperTaskStatus">
					<button class="btn m-b-xs {{search.status==row.key && search.assistantSecretary ? 'btn-info' : 'btn-green'}}" type="button" 
							ng-click="filterBy({'assistantSecretary':curUser.id,'status': row.key, 'batchType' : '!SHI_JUAN_FU_SHEN'});" 
							ng-if="(array | filter:{'assistantSecretary':curUser.id, 'status': row.key, 'batchType' : '!SHI_JUAN_FU_SHEN'}:true).length > 0">
				 		 {{row.value}}(校) <span class="badge">{{(array | filter:{'assistantSecretary':curUser.id,'status': row.key, 'batchType' : '!SHI_JUAN_FU_SHEN'}:true).length}}</span>
					</button>
				</span>
				<!-- 命题任务 -->
				<button class="btn m-b-xs {{search.status=='!ARCHIVED' && search.propositionTeacher ? 'btn-info' : 'btn-pink'}}" 
					type="button" ng-click="filterBy({'propositionTeacher':curUser.id,'status':'!ARCHIVED', 'batchType' : '!SHI_JUAN_FU_SHEN'});"
					ng-if="(array | filter:{'propositionTeacher':curUser.id,'status':'!ARCHIVED', 'batchType' : '!SHI_JUAN_FU_SHEN'}:true).length > 0">
			 		 未完成(命题任务)  <span class="badge">{{(array | filter:{'propositionTeacher':curUser.id,'status':'!ARCHIVED', 'batchType' : '!SHI_JUAN_FU_SHEN'}:true).length}}</span>
				</button>
				<span ng-repeat="row in paperTaskStatus">
					<button class="btn m-b-xs {{search.status==row.key && search.propositionTeacher ? 'btn-info' : 'btn-pink'}}" type="button" 
							ng-click="filterBy({'propositionTeacher':curUser.id,'status': row.key, 'batchType' : '!SHI_JUAN_FU_SHEN'});" 
							ng-if="(array | filter:{'propositionTeacher':curUser.id, 'status': row.key, 'batchType' : '!SHI_JUAN_FU_SHEN'}:true).length > 0">
				 		 {{row.value}}(命) <span class="badge">{{(array | filter:{'propositionTeacher':curUser.id,'status': row.key, 'batchType' : '!SHI_JUAN_FU_SHEN'}:true).length}}</span>
					</button>
				</span>
				
				<!-- 审核任务 -->
				<button class="btn m-b-xs {{search.status=='!ARCHIVED' && search.auditTeacher ? 'btn-info' : 'btn-kilo'}}" 
					type="button" m-b-xs ng-click="filterBy({'auditTeacher':curUser.id,'status':'!ARCHIVED', 'batchType':'!SHI_JUAN_FU_SHEN'});"
					ng-if="(array | filter:{'auditTeacher':curUser.id,'status':'!ARCHIVED', 'batchType':'!SHI_JUAN_FU_SHEN'}:true).length > 0">
			 		 未完成(审核任务)  <span class="badge">{{(array | filter:{'auditTeacher':curUser.id,'status':'!ARCHIVED', 'batchType':'!SHI_JUAN_FU_SHEN'}:true).length}}</span>
				</button>
				<span ng-repeat="row in paperTaskStatus">
					<button class="btn m-b-xs {{search.status==row.key && search.auditTeacher ? 'btn-info' : 'btn-kilo'}}" type="button" 
							ng-click="filterBy({'auditTeacher':curUser.id,'status': row.key, 'batchType' : '!SHI_JUAN_FU_SHEN'});" 
							ng-if="(array | filter:{'auditTeacher':curUser.id, 'status': row.key, 'batchType' : '!SHI_JUAN_FU_SHEN'}:true).length > 0">
				 		 {{row.value}}(审) <span class="badge">{{(array | filter:{'auditTeacher':curUser.id,'status': row.key, 'batchType' : '!SHI_JUAN_FU_SHEN'}:true).length}}</span>
					</button>
				</span>
				
				<!-- 排版任务 -->
				<button class="btn m-b-xs {{search.status=='!ARCHIVED' && search.typesetter ? 'btn-info' : 'btn-pink'}}" 
					type="button" m-b-xs ng-click="filterBy({'typesetter':curUser.id,'status':'!ARCHIVED', 'batchType' : '!SHI_JUAN_FU_SHEN'});"
					ng-if="(array | filter:{'typesetter':curUser.id,'status':'!ARCHIVED', 'batchType' : '!SHI_JUAN_FU_SHEN'}:true).length > 0">
			 		 未完成(排版任务)  <span class="badge">{{(array | filter:{'typesetter':curUser.id,'status':'!ARCHIVED', 'batchType' : '!SHI_JUAN_FU_SHEN'}:true).length}}</span>
				</button>
				<span ng-repeat="row in paperTaskStatus">
					<button class="btn m-b-xs {{search.status==row.key && search.typesetter ? 'btn-info' : 'btn-pink'}}" type="button" 
							ng-click="filterBy({'typesetter':curUser.id,'status': row.key, 'batchType' : '!SHI_JUAN_FU_SHEN'});" 
							ng-if="(array | filter:{'typesetter':curUser.id, 'status': row.key, 'batchType' : '!SHI_JUAN_FU_SHEN'}:true).length > 0">
				 		 {{row.value}}(排) <span class="badge">{{(array | filter:{'typesetter':curUser.id,'status': row.key, 'batchType' : '!SHI_JUAN_FU_SHEN'}:true).length}}</span>
					</button>
				</span>
				
				<!-- 复审任务 -->
				<button class="btn m-b-xs {{search.status=='!ARCHIVED' && search.auditTeacher ? 'btn-info' : 'btn-kilo'}}" 
					type="button" m-b-xs ng-click="filterBy([{'batchType' : 'SHI_JUAN_FU_SHEN'},{'curDealer':curUser.id,'status':'TO_AUDIT_PAPER_REVIEW'}]);"
					ng-if="(array | filter:{'curDealer':curUser.id,'status':'TO_AUDIT_PAPER_REVIEW'}:true).length > 0">
			 		 试卷审核(复审)  <span class="badge">{{(array | filter:{'curDealer':curUser.id,'status':'TO_AUDIT_PAPER_REVIEW'}:true).length}}</span>
				</button>
				
				<button class="btn m-b-xs {{search.status=='!ARCHIVED' && search.auditTeacher ? 'btn-info' : 'btn-kilo'}}" 
					type="button" m-b-xs ng-click="filterBy([{'batchType' : 'SHI_JUAN_FU_SHEN'},{'curDealer':curUser.id,'status':'ARCHIVED_REVIEW'}]);"
					ng-if="(array | filter:{'curDealer':curUser.id,'status':'ARCHIVED_REVIEW'}:true).length > 0">
			 		 已归档(复审)  <span class="badge">{{(array | filter:{'curDealer':curUser.id,'status':'ARCHIVED_REVIEW'}:true).length}}</span>
				</button>
			</div>
			
			<div class="col-md-4">
				<label>
			      <input type="checkbox" ng-change="filterByPaperId()" ng-model="nonPaper"> 未组卷
			      	 <span class="badge">{{(array | filter:{'paperId': null, 'batchType' : '!SHI_JUAN_FU_SHEN'}).length}}/{{(array | filter:{'batchType' : '!SHI_JUAN_FU_SHEN'}).length}}</span>
			    </label>
				<label>
			      <input type="checkbox" ng-change="filterByAssessmentId()" ng-model="nonAssessment"> 未评价
			      	 <span class="badge">{{(array | filter:{'teacherAssessmentId': null, 'batchType' : '!SHI_JUAN_FU_SHEN'}).length}}/{{(array | filter:{'batchType' : '!SHI_JUAN_FU_SHEN'}).length}}</span>
			    </label>
				<label>
			      <input type="checkbox" ng-change="filterByDifficultyEstimateTableId()" ng-model="nonDifficultyEstimate"> 未填写难度预估表
			      	 <span class="badge">{{(array | filter:{'difficultyEstimateTableId': null, 'batchType' : '!SHI_JUAN_FU_SHEN'}).length}}/{{(array | filter:{'batchType' : '!SHI_JUAN_FU_SHEN'}).length}}</span>
			    </label>
			</div>
		    
			<table class="table table-striped">
				<thead>
					<tr>
						<th>试卷编号</th>
						<th>状态</th>
						<th>当前处理人</th>
						<th>课程</th>
						<th>类型</th>
						<!-- 
						<th>命题教师1</th>
						<th>命题教师2</th>
						<th>学科秘书1</th>
						<th>学科秘书2</th>
						<th>排版员</th>
						 -->
						<th class="{{isBusinessManager ? 'col-md-4' : 'col-md-3'}}">操作</th>
					</tr>										
				</thead>
				<tbody>
					<tr ng-repeat="row in array | filter:search:matchType | filter:search1:matchType | orderBy: 'taskNo'">
						<td title="点击查看任务详情" class="text-info" ng-click="showTaskDetail(row)">
							<a>
								{{row.taskNo}}
								<i class="glyphicon glyphicon-eye-open text-info"></i>
							</a>
						</td>
						<td>
							<span ng-if="row.batchType == 'RU_WEI_MING_TI'">{{row.statusName}}</span>
							<span ng-if="row.batchType == 'SHI_JUAN_FU_SHEN'">{{row.reviewStatusName}}</span>
						</td>
						<td title="{{row.propositionTeacherBean.name}}(命题教师1) {{row.auditTeacherBean.name}}(命题教师2) {{row.primarySecretaryBean.name}}(学科秘书){{row.typesetterBean.name}}(排版员)">
							{{row.curDealerBean.name}}
							<i class="glyphicon glyphicon-info-sign text-info"></i>
						</td>
						<td>{{row.course.code}} - {{row.course.name}}</td>
						<td>
							{{row.batchTypeName}}
							<!-- <i class="glyphicon glyphicon-info-sign text-info"></i> -->
						</td>
						<!-- 
						<td>{{row.propositionTeacherBean.name}}</td>
						<td>{{row.auditTeacherBean.name}}</td>
						<td>{{row.primarySecretaryBean.name}}</td>
						<td>{{row.assistantSecretaryBean.name}}</td>
						<td>{{row.typesetterBean.name}}</td>
						 -->
						<td nowrap="nowrap">
							<button ng-if="curUserRole.code=='processManagement'" ng-click="showAddPaperTaskModal(row)" class="btn btn-primary btn-xs">
								修改相关人员
							</button>
							<button ng-if="curUserRole.code=='processManagement' && row.propositionTeacherBean.isEnabled != 1" ng-click="enableTeachers(row)" class="btn btn-primary btn-xs">
								启用教师
							</button>
							<button ng-if="curUserRole.code=='processManagement' && row.propositionTeacherBean.isEnabled == 1" ng-click="disableTeachers(row)" class="btn btn-primary btn-xs">
								禁用教师
							</button>
							<button ng-if="row.batchType != 'SHI_JUAN_FU_SHEN'" ng-click="viewPaper(row)" class="btn {{row.paperId > 0 ? 'btn-default' : 'btn-disabled'}} btn-xs">
								查看试卷								
							</button>
							<button ng-if="row.batchType != 'SHI_JUAN_FU_SHEN'" ng-click="viewTeacherAssessment(row)" class="btn {{row.teacherAssessmentId > 0 ? 'btn-default' : 'btn-disabled'}} btn-xs">
								教师评价						
							</button>
							<button ng-if="row.batchType != 'SHI_JUAN_FU_SHEN'" ng-click="viewDifficultyEstimate(row)" class="btn {{row.difficultyEstimateTableId > 0 ? 'btn-default' : 'btn-disabled'}} btn-xs">
								难度预估表					
							</button>
							<button ng-if="row.batchType == 'RU_WEI_MING_TI' && row.status == 'TO_CREATE_SKEL' " ng-click="deleteDetail(row)" class="btn btn-primary btn-xs">
								删除细目表					
							</button>
						</td>
					</tr>
				</tbody>

			</table>
		</div>
	</div>
</div>