<!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="institutiontype" th:with="type=${@dict.getType('institutiontype')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>发薪权限：</label>
                                <select name="isOpenSalaryAuth" >
                                    <option value="">所有</option>
                                    <option value="0">未开通</option>
                                    <option value="1">已开通</option>
                                </select>
                            </li>
                        </ul>
                        <ul>
                            <li>
                                <label>开户日期：</label>
                                <input type="text" class="time-input" id="startTime" name="startDate"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" name="endDate"/>
                            </li>
                        </ul>
                        <ul id="element">
                            <li>
                                省：<select class="province"></select>
                            </li>
                            <li>
                                市：<select class="city"></select>
                            </li>
                            <li>
                                区：<select class="area"></select>
                            </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="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/bh-account";

        $(function() {
            var options = {
                url: prefix + "/page-com-bh-account-list",
                columns: [
                    {field: 'comName', title: '企业名称'},
                    {field: 'comCerNo', title: '证件代码'},
                    {field: 'label', title: '机构类型'},
                    {field: 'area', title: '注册地址'},
                    {field: 'bhVirlAcctNo', title: '发薪账户号'},
                    {field: 'isOpenSalaryAuth', title: '发薪权限'},
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function(value, row, index) {
                            var actions = [];
                            var accountInfoClick = "accountInfoClick('" + row.comId + "')";
                            var paymentDetailsClick = "paymentDetailsClick(" + index + ")";
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="' + accountInfoClick + '"><i class="fa fa-edit"></i>账户信息</a> ');
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="' + paymentDetailsClick + '"><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);
        });

        //账户信息
        function accountInfoClickView(_comId) {
            $.modal.open('账户信息', prefix+'/account-info-view/'+_comId, '900', '600');
        }

        //点击编辑弹窗
        function accountInfoClick(_comId) {
            accountInfoClickView(_comId);
        }

        //收支明细
        function paymentDetailsClickView() {
            $.modal.open('收支明细', prefix+'/payment-details-view', '900', '600');
        }

        //点击编辑弹窗
        function paymentDetailsClick(index) {
            pageParam = { //页面传递参数
                mark: "upd",
                row: $("#bootstrap-table").bootstrapTable('getData')[index]
            }
            paymentDetailsClickView();
        }

        var regions = {
            url: ctx + "region/getRegions",
            type: "post",
            dataType: "json",
            beforeSend: function () {
            },
            success: function(data) {
                $('#element').cxSelect({
                    selects: ['province', 'city', 'area'],
                    jsonValue: 'regionId',
                    jsonName: 'regionName',
                    data: data
                });
            }
        };
        $.ajax(regions);
    </script>
</body>
</html>