<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('保单内容')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-ins-edit">
            <input name="comInsId" th:value="${comIns.comInsId}" type="hidden">
            <input id="comId11" th:value="${comIns.comId}" type="hidden">
            <input id="policyUrl11" th:value="${comIns.policyUrl}" type="hidden">
            <input id="riderUrl11" th:value="${comIns.riderUrl}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">公司名称：</label>
                <div class="col-sm-8">
                    <input name="comName" th:value="${comIns.comName}" class="form-control" type="text" disabled>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">在保人数：</label>
                <div class="col-sm-8">
                    <input name="perNum" th:value="${comIns.perNum}" id="perNum" class="form-control" type="number">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">保险产品名称：</label>
                <div class="col-sm-8">
                    <input name="productName" th:value="${comIns.productName}" class="form-control" type="text" disabled>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">保险有效期：</label>
                <div class="col-sm-8">
                    <input name="effectStartDate" th:value="${comIns.effectStartDate}" class="form-control" type="text" disabled>
                    <input name="effectEndDate" th:value="${comIns.effectEndDate}" class="form-control" type="text" disabled>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">保险公司名称：</label>
                <div class="col-sm-8">
                    <input name="insComName" th:value="${comIns.insComName}" class="form-control" type="text" disabled>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">保单号：</label>
                <div class="col-sm-8">
                    <input name="policyNo" th:value="${comIns.policyNo}" class="form-control" type="text" disabled>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">保单：</label>
                <div class="col-sm-8" id="somePDown">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">批单：</label>
                <div class="col-sm-8" id="someIDown">
                </div>
            </div>
    	</form>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script type="text/javascript">
	    var prefix = ctx + "manage/insurance";

	    $("#form-ins-edit").validate({
	    	onkeyup: false,
	        rules: {
                perNum: {
                    required: true
                },
	        },
	        messages: {
                perNum: {
                    required: "在保人数不能为空"
                }
	        },
            focusCleanup: true
	    });
	    
	    function submitHandler() {
	        if ($.validate.form()) {
	        	$.operate.save(prefix + "/update-per-num", $('#form-ins-edit').serialize());
	        }
	    }
        $(function() {
            loadUrl();
        });

	    function loadUrl(){
	        var policyUrl = $('#policyUrl11').val();
	        var riderUrl = $('#riderUrl11').val();
            if(policyUrl){
                var arr = policyUrl.split(',');
                var _a = '';
                for(var i=0;i<arr.length;i++){
                    if(arr[i]){
                        _a = _a + '<a href="'+arr[i]+'" style="margin-right: 5px;" target="_blank" class="btn btn-info btn-sm "><i class="glyphicon glyphicon-cloud-download"></i>下载'+(i+1)+'</a>';
                    }
                }
                $('#somePDown').html(_a);
            }
            if(riderUrl){
                var arr = riderUrl.split(',');
                var _a = '';
                for(var i=0;i<arr.length;i++){
                    if(arr[i]){
                        _a = _a + '<a href="'+arr[i]+'" style="margin-right: 5px;" target="_blank" class="btn btn-info btn-sm "><i class="glyphicon glyphicon-cloud-download"></i>下载'+(i+1)+'</a>';
                    }
                }
                $('#someIDown').html(_a);
            }
            principalListLoad($('#comId11').val());
        }

        function principalListLoad(comId) {
            $(function() {
                var options = {
                    search: false,
                    showSearch: false,
                    showPageGo: false,
                    showRefresh: false,
                    showColumns: false,
                    showToggle: false,
                    showExport: false,
                    url: prefix + "/select-principal-by-comId?comId="+comId,
                    modalName: "保险负责人",
                    pagination: false,
                    columns: [
                        {field:'name',title:'姓名'},
                        {field:'mobilePhone',title:'手机号'},
                        {field:'idCardNo',title:'身份证'},
                        {field:'departName',title:'部门'}
                    ]
                };
                $.table.init(options);
            });

        };

    </script>
</body>
</html>
