<!DOCTYPE html>
<html lang="zh">
<head>
	<th:block th:include="include :: header('弹层表格')" />
</head>
<body class="gray-bg">
	<div class="wrapper wrapper-content fadeInRight">
	    <div class="row">
	        <div class="col-sm-12">
	            <div class="ibox">
	                <div class="ibox-title">
	                <h5>弹层框</h5>
	                </div>
	                <div class="ibox-content" id="test">
	                    <p>弹出复选框表格及单选框表格（点击提交后得到数据）。 </p>
	                    <button type="button" class="btn btn-primary" onclick="selectCheckUser()">弹出表格（复选框）</button>
	                    <button type="button" class="btn btn-success" onclick="selectRadioUser()">弹出表格（单选框）</button>
	                </div>
	            </div>
	        </div>
	        <div class="col-sm-12">
	            <div class="ibox">
	                <div class="ibox-title">
	                <h5>弹层框</h5>
	                </div>
	                <div class="ibox-content" id="test">
	                    <p>弹出复选框表格及单选框表格（点击提交后得到数据并回显到父窗体）。 </p>
	                    <button type="button" class="btn btn-info" onclick="selectUsersToParent()">弹出表格（复选框）</button>
	                    <button type="button" class="btn btn-warning" onclick="selectUsersToParentCallBack()">弹出表格（复选框）- 回调形式</button>
	                    <p id="userids"> </p>
	                </div>
	            </div>
	        </div>
	    </div>
	</div>
    <th:block th:include="include :: footer" />
    <script type="text/javascript">
        var prefix = ctx + "demo/modal";
        
        function selectCheckUser(){
        	$.modal.open("选择用户", prefix + "/check");
        }
        
		function selectRadioUser(){
			$.modal.open("选择用户", prefix + "/radio");
        }
		
		function selectUsersToParent(){
			$.modal.open("选择用户", prefix + "/parent");
        }
		
		function selectUsersToParentCallBack(){
            var options = {
                title: '选择用户',
                url: prefix + "/parent",
                callBack: doSubmit
             };
             $.modal.openOptions(options);
        }
		
		function doSubmit(index, layero){
		    var rows = layero.find("iframe")[0].contentWindow.getSelections();
		    if (rows.length == 0) {
                $.modal.alertWarning("请至少选择一条记录");
                return;
            }
		    $('#userids').html(rows.join())
		    layer.close(index);
		}
		
		function selectUsers(){
			alert(1);
		}
	</script>
</body>
</html>
