<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<c:set var="path" value="${pageContext.request.contextPath}"/>
<%@ include file="/WEB-INF/jspf/common.jspf" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <title>自定义模板选择iframe页面</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv=X-UA-Compatible IE=EmulateIE7>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="${path}/static/js/html5shiv.min.js"></script>
    <script type="text/javascript" src="${path}/static/js/jquery-1.11.3.min.js"></script>
    <script type="text/javascript" src="${path}/static/js/respond.min.js"></script>
    <![endif]-->
    <script>
        var path = "${path}";
    </script>
    <style type="text/css">
        .saveBtn {
            text-align: center;
            margin-bottom: 10px;
        }

        .right {
            float: right;
        }

        th td {
            text-align: center !important;
        }

        .control-label {
            margin-left: 20px;
            text-align: right;
            width: 130px;
        }

        .checkBoxClass {
            cursor: pointer;
        }
    </style>
</head>
<body>
<div class="row clearfix">
    <div class="col-md-12 table-responsive" style="overflow: auto">
        <table class="table text-nowrap table-bordered">
            <tr>
                <th>模板标志</th>
                <th>模板名称</th>
                <th>排序</th>
                <th>有效时间</th>
                <th>有效否</th>
                <th>选中否</th>
                <%--<th>备注</th>--%>
                <th>创建人</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
            <tr style="height:20%">
                <td id="modleFlag" style="height:20%">${emrModle.modleFlag}</td>
                <td id="modleName">${emrModle.modleName}</td>
                <td id="modleSort">${emrModle.modleSort}</td>
                <td id="effeTime">${emrModle.effeTime}</td>
                <c:choose>
                    <c:when test="${emrModle.effective == 1}">
                        <td id="effective">是</td>
                    </c:when>
                    <c:when test="${emrModle.effective == 0}">
                        <td id="effective">否</td>
                    </c:when>
                    <c:otherwise>
                        <td id="effective"></td>
                    </c:otherwise>
                </c:choose>
                <c:choose>
                    <c:when test="${emrModle.selectFlag == 1}">
                        <td id="selectFlag">是</td>
                    </c:when>
                    <c:when test="${emrModle.selectFlag == 0}">
                        <td id="selectFlag">否</td>
                    </c:when>
                    <c:otherwise>
                        <td id="selectFlag"></td>
                    </c:otherwise>
                </c:choose>
                <%--<td id="remark"></td>--%>
                <td id="creater">${emrModle.creater}</td>
                <td id="createTime">${emrModle.createTime}</td>
                <td id="operId">
                    <c:if test="${emrModle.isOper == 1}">
                        <shiro:hasPermission name="/template/updateTemplateSelect">
                            <button type="button" class="btn btn-sm btn-info btns " data-toggle="modal"
                                    data-target="#myModal2">编辑
                            </button>
                        </shiro:hasPermission>
                        <shiro:hasPermission name="/template/deleteTemplateSelect">
                            <button type="button" class="btn btn-sm btn-danger btns" style="margin-left:2%"
                                    onclick="del()">删除
                            </button>
                        </shiro:hasPermission>
                    </c:if>
                </td>
            </tr>
        </table>
    </div>
</div>
<input type="hidden" id="modleId" value="${modleId}">
<c:forEach items="${checks}" var="check">
    <div class="panel-group" id="accordion">
        <div class="panel">
            <div class="panel-heading">
                <a data-toggle="collapse" href="#tab${check.id}" style="font-size: 16px">
                        ${check.columnName}
                </a>
                <span class="right">全选</span><input type="checkbox" class="right" value="全选" id="checkAll${check.id}"
                                                    onclick="checkAll(${check.id})">
            </div>
            <div id="tab${check.id}" class="panel-collapse collapse in">
                <div class="panel-body">
                    <div class="row">
                        <c:forEach items="${check.data}" var="data">
                            <div class="col-xs-2"><input type='checkbox' name="check" id="${data.id}"
                                                         class="check${data.parentId}" value="${data.id}"
                                                         onclick="check(${data.parentId})"
                                                         <c:if test="${data.checked == 'true'}">checked</c:if>/><label
                                    for="${data.id}" class="checkBoxClass">${data.columnName}</label></div>
                        </c:forEach>
                    </div>
                </div>
            </div>
        </div>
    </div>
</c:forEach>
<c:if test="${emrModle.isOper == 1}">
    <shiro:hasPermission name="/template/addModleRelated">
        <div class="row">
            <div class="saveBtn">
                <button type="button" class="btn btn-primary btn-info" style="width:24%;" onclick="update()">保存</button>
            </div>
        </div>
    </shiro:hasPermission>
</c:if>
<!-- 模态框2（Modal） -->
<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    <font size="30">&times;</font>
                </button>
                <h4 class="modal-title">
                    模板信息
                </h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" role="form" id="updateForm">
                    <input type="hidden" id="selectFlagId" name="selectFlagId" value="${flagModle.id}">
                    <input type="hidden" id="id" name="id" value="${emrModle.id}">
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-5 control-label left">模板标志：</label>
                            <div class="col-sm-7 left">
                                <input type="text" class="form-control input-sm input" name="modleFlag" id="modleFlag1"
                                       value="${emrModle.modleFlag}" maxlength="25">
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-5 control-label  left">模板名称：</label>
                            <div class="col-sm-7  left">
                                <input type="text" class="form-control input-sm input" name="modleName" id="modleName1"
                                       value="${emrModle.modleName}" maxlength="25">
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label  left">有效时间：</label>
                            <div class="col-sm-6 input-group  left" style="padding-left:15px;width: 31%;">
                                <input type="text" class="form-control input-sm dateInput datepicker" name="effeTime" id="effeTime1" value="${emrModle.effeTime}" autocomplete="off" maxlength="10">
                                <div class="input-group-addon">
                                    <i class="fa fa-calendar"></i>
                                </div>
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label  left">有效否：</label>
                            <div class="col-sm-7  left">
                                <select class="form-control input-sm input" name="effective" id="effective1">
                                    <option value="1" <c:if test="${emrModle.effective == 1}">selected</c:if>>是</option>
                                    <option value="0" <c:if test="${emrModle.effective == 0}">selected</c:if>>否</option>
                                </select>
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label  left">排序：</label>
                            <div class="col-sm-7  left">
                                <input type="number" class="form-control input-sm input" name="modleSort"
                                       id="modleSort1" value="${emrModle.modleSort}"
                                       oninput="if(value.length>9)value=value.slice(0,9)">
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label  left">备注：</label>
                            <div class="col-sm-7  left">
                                <textarea class="form-control input-sm input" name="remark" id="remark1"
                                          maxlength="25">${emrModle.remark}</textarea>
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group" style="margin-left: 76px;">
                            <div class="col-sm-4"></div>
                            <div class="col-sm-8">
                                <input type="radio" value="1" name="selectFlag" id="selectFlag1"
                                       <c:if test="${emrModle.selectFlag == 1}">checked</c:if>>选中模板为当前使用
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">关闭
                </button>
                <button type="button" class="btn btn-sm btn-primary" onclick="updateModle()">
                    提交更改
                </button>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="${path}/static/js/recordManage/templateSearch/templateSelectIframe.js"></script>
</body>
</html>
