<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block 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>
                                <label>关键字：</label>
                                <input type="text" name="keyword" placeholder="请输入保险名称 、保险公司名称 、企业名称"/>
                            </li>
                            <li>
                                <label>购买方式：</label>
                                <select name="buyMode">
                                    <option value="">所有</option>
                                    <option value="1">在线购买</option>
                                    <option value="2">线下购买</option>
                                </select>
                            </li>
                            <li>
                                <label>所属企业：</label>
                                <select name="comId" th:with="type=${@com.getCom()}">
                                    <option value="">所有</option>
                                    <option th:each="com : ${type}" th:text="${com.comName}" th:value="${com.comId}"></option>
                                </select>
                            </li>
                        </ul>
                        <ul>
                            <li>
                                <label>起保日期：</label>
                                <input type="text" class="time-input" id="startTime" name="startTime"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" name="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>
                                <a class="btn btn-warning btn-rounded btn-sm" id="downBtn" onclick="javascript:void(0)"><i class="fa fa-refresh"></i>&nbsp;保险推荐报表</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-select-js" />
    <th:block th:include="include :: jquery-cxselect-js" />
    <script th:inline="javascript">
        var prefix = ctx + "manage/insurance";

        $(function() {
            var options = {
                url: prefix + "/page-com-ins-list",
                updateUrl: prefix + "/insurance-info/{id}",
                modalName: "保险列表",
                columns: [
                    {field: 'policyNo', title: '保单号'},
                    {field: 'productName', title: '保险产品名称'},
                    {title: '在保人数',align: 'center',formatter: function(value, row, index) {
                            return row.insCount + '/' + row.perNum;
                        }},
                    {field: 'buyMode_name', title: '购买方式'},
                    {field: 'effectDate', title: '有效期'},
                    {field: 'insComName', title: '保险公司'},
                    {field: 'comName', title: '关联企业'},
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.comInsId + '\')"><i class="fa fa-edit"></i>查看</a> ');
                        return actions.join('');
                    }
                }]
            };
            var _n = new Date();
            var initStart = new Date(_n.getTime()-2592000000);
            $('#startTime').val(initStart.format("yyyy-MM-dd"));
            $('#endTime').val(_n.format("yyyy-MM-dd"));
            $.table.init(options);
        });

        $("#downBtn").click(function () {
            var index = layer.confirm('是否下载保险推荐报表？',{
                btn:['下载','取消']
            },function () {
                location.href=prefix+'/down-ins-schedule';
                layer.close(index);
            });
        });
    </script>
</body>
</html>