<!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>
                        </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>
                        </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 removeFlag = [[${@permission.hasPermi('per-wallet:remove')}]];
        var prefix = ctx + "manage/com-wallet";

        $(function() {
            var options = {
                url: prefix + "/page-com-wallet-list",
                updateUrl: prefix + "/com-wallet-account-view/{id}",
                columns: [
                    {field: 'comId', title: '序号'},
                    {field: 'comName', title: '名称'},
                    {field: 'comCerNo', title: '证件代码'},
                    {field: 'institutionName', title: '机构类型'},
                    {field: 'region', title: '所属地区'},
                    {field: 'walletAccountNo', title: '钱包账户号'},
                    {field: 'createTime', title: '开户时间'},
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function(value, row, index) {
                            var actions = [];
                            var comWalletInfoClick = "comWalletInfo('" + row.comId + "')";
                            var comPaymentDetailsClick = "comPaymentDetails('" + row.comId + "','" + row.walletAccountNo + "')";
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.comId + '\')"><i class="fa fa-edit"></i>账户信息</a> ');
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="' + comPaymentDetailsClick + '"><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 comWalletInfoView(_comId) {
            $.modal.open('账户信息', prefix+'/com-wallet-account-view/'+_comId, '900', '600');
        }

        //点击编辑弹窗
        function comWalletInfo(_comId) {
            comWalletInfoView(_comId);
        }

        //收支明细
        function comPaymentDetailsView(_comId,_walletAccountNo) {
            $.modal.open('收支明细', prefix+'/com-wallet-account-trade-detail-view/'+_comId+'/'+_walletAccountNo, '900', '600');
        }

        //点击编辑弹窗
        function comPaymentDetails(_comId,_walletAccountNo) {
            comPaymentDetailsView(_comId,_walletAccountNo);
        }

        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>