<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								项目：
								<select id="projectId" name="projectId" th:with="type=${projects}">
								    <option value="">所有项目</option>
	                                <option th:each="projects : ${type}" th:text="${projects.projectName}" th:value="${projects.projectId}" th:selected="${projects.projectId == defaultProjectId}"></option>
	                            </select>
							</li>

							<li>
								事故状态：
								<select name="accidentStatus" th:with="type=${@dict.getType('qa_accident_status')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"></option>
								</select>
							</li>

							<li>
								事故等级：
								<select name="accidentLevel" th:with="type=${@dict.getType('qa_accident_level')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"></option>
								</select>
							</li>

							<li>
								事故类型：
								<select name="accidentType" th:with="type=${@dict.getType('qa_accident_type')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"></option>
								</select>
							</li>

							<li>
								提交者：<input type="text" name="createBy"/>
							</li>

							<li class="select-time">
								<label>发生时间： </label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
							</li>
							
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				<shiro:hasPermission name="qualitymanagmt:qaAccident:add">
				<a class="btn btn-success" onclick="$.operate.add()">
					<i class="fa fa-plus"></i> 添加
				</a>
				</shiro:hasPermission>
				<shiro:hasPermission name="qualitymanagmt:qaAccident:edit">
				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()">
					<i class="fa fa-edit"></i> 修改
				</a>
				</shiro:hasPermission>
				<shiro:hasPermission name="qualitymanagmt:qaAccident:remove">
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()">
					<i class="fa fa-remove"></i> 删除
				</a>
				</shiro:hasPermission>
				<a class="btn btn-info" onclick="showQueryGraph()">
					<i class="fa fa-pie-chart"></i> 图形分析
				</a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true" style="table-layout:fixed"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('qualitymanagmt:qaAccident:edit')}]];
        var removeFlag = [[${@permission.hasPermi('qualitymanagmt:qaAccident:remove')}]];
        var prefix = ctx + "qualitymanagmt/qaAccident";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                customUrl: prefix + "/showAccidentDetail/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "生产事故登记",
				search: false,
				queryParams: function(params) {
	            	return {
	        			// 传递参数查询参数
	                    pageSize:       params.limit,
	                    pageNum:        params.offset / params.limit + 1,
	                    searchValue:    params.search,
	                    orderByColumn:  params.sort,
	                    isAsc:          params.order,
	                    projectId:      $('#projectId').val()
	        		};
				},
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'accidentId', 
					title : '事故ID',
					visible: false
				},
				{
					field : 'project.projectName', 
					title : '项目名称',
					class : 'myTDLengthHidden',
					width : '10%',
				},
				{
					field : 'accidentStatus', 
					title : '事故状态',
					class : 'myTDLengthHidden',
					width : '10%',
					formatter : function(value,
							row, index) {
						if(value=='跟踪处理完成'){
						    return '<font style="color:#00DB00">跟踪处理完成</font>';					
						}else if(value=='已发生-初始状态'){
							return '<font style="color:#FFA54F">已发生-初始状态</font>';
						}else{
							return '<font style="color:#0066FF">'+value+'</font>';
						}						
					}
				},
				{
					field : 'accidentLevel', 
					title : '事故等级',
					class : 'myTDLengthHidden',
					width : '10%',
				},
				{
					field : 'accidentTime', 
					title : '发生时间',
					class : 'myTDLengthHidden',
					width : '10%',
				},
				{
					field : 'accidentType', 
					title : '事故类型',
					class : 'myTDLengthHidden',
					width : '10%',
				},
				{
					field : 'reportTime', 
					title : '事故报告时间',
					visible: false
				},
				{
					field : 'accidentDescription', 
					title : '事故描述',
					class : 'myTDLengthHidden',
					width : '35%',
				},
				{
					field : 'resolutionTime', 
					title : '解决时间',
					class : 'myTDLengthHidden',
					width : '10%',
		        	formatter: function (value, row, index) {
		    		    if (value == null) {
		        			return '暂未解决';
		        		} else{
		        			return value;
		        		}
		        	}
				},
				{
					field : 'accidentAnalysis', 
					title : '事故分析',
					visible: false
				},
				{
					field : 'accidentConsequence', 
					title : '事故影响后果',
					visible: false
				},
				{
					field : 'correctiveAction', 
					title : '纠正措施',
					visible: false
				},
				{
					field : 'resolutioner', 
					title : '解决处理人',
					visible: false
				},
				{
					field : 'preventiveAction', 
					title : '预防措施',
					visible: false
				},
				{
					field : 'preventiver', 
					title : '预防措施责任人',
					visible: false
				},
				{
					field : 'preventivePlanDate', 
					title : '预防措施计划完成时间',
					visible: false
				},
				{
					field : 'preventiveOverDate', 
					title : '预防措施实际完成时间',
					visible: false
				},
				{
					field : 'durationTime', 
					title : '事故持续时间',
					visible: false
				},
				{
					field : 'impactTime', 
					title : '事故影响时间',
					visible: false
				},
				{
					field : 'accidentFileName', 
					title : '事故报告附件路径',
					visible: false
				},
				{
					field : 'createBy', 
					title : '创建者',
					visible: false
				},
				{
					field : 'createTime', 
					title : '创建时间',
					visible: false
				},
				{
					field : 'updateBy', 
					title : '更新者',
					visible: false
				},
				{
					field : 'updateTime', 
					title : '更新时间',
					visible: false
				},
		        {
		            title: '操作',
		            align: 'center',
		            width : '5%',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="showAccidentDetail('+row.accidentId+')"><i class="fa fa-file-text"></i> 详情</a> ');
                        /* actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.accidentId + '\')"><i class="fa fa-remove"></i>删除</a>'); */
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
        
        /*查看生产事故详细内容*/
        function showAccidentDetail(accidentId) {       	
        	var url = "/404.html";
        	if ($.common.isNotEmpty(accidentId)) {
        	    url = $.table._option.customUrl.replace("{id}", accidentId);
        	}
        	$.modal.openViewFull("生产事故详细内容", url, null, null);
        }
        
        /*弹出层查看图形分析*/
        function showQueryGraph() {
        	var url = prefix+"/queryGraph";
        	 $.modal.open("查看图表", url,null,null,"查看");
        }
    </script>
</body>
</html>