<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('选择接口应用')" />
</head>
<body>
<div class="main-content">
    <form id="form-user-add" class="form-horizontal">
        <div class="row">
            <div class="col-sm-12">
                <div class="col-sm-12 select-table table-striped">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    let prefix = ctx + "system/interfaceinfo";
    let list = [[${list}]];
    let shareType_datas = [[${@dict.getType('share_type')}]];
    let interfaceType_datas = [[${@dict.getType('interface_type')}]];
    let shareType = [[${shareType}]];

    $(function() {
        let options = {
            data: list,
            sidePagination: "client",
            sortName: "roleSort",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            clickToSelect: true,
            maintainSelected: true,
            columns: [{
                checkbox: true,
                formatter:function (value, row, index) {
                    if($.common.isEmpty(value)) {
                        return { checked: row.flag };
                    } else {
                        return { checked: value }
                    }
                }
            },
            {
                field: 'id',
                title: '主键ID',
                visible: false
            },
            {
                field: 'rownum',
                title: '序号',
                formatter: function (value, item, index) {
                    return index + 1;
                },
            },
            {
                field: 'remark',
                title: '注释',
                visible: false
            },
            {
                field: 'code',
                title: '接口码',
                visible: false
            },
            {
                field: 'interfaceName',
                title: '接口名称'
            },
            {
                field: 'infoItem',
                title: '信息项',
                visible: false
            },
            {
                field: 'usageScenarios',
                title: '使用场景描述'
            },
            {
                field: 'shareType',
                title: '接口方式',
                formatter: function (value, item, index) {
                    return $.table.selectDictLabel(shareType_datas, item.shareType);
                }
            },
            {
                field: 'interfaceType',
                title: '请求方式',
                formatter: function (value, item, index) {
                    return $.table.selectDictLabel(interfaceType_datas, item.interfaceType);
                }
            },
            {
                field: 'env',
                title: '环境',
                visible: false
            },
            {
                field: 'signServeraddress',
                title: '签名服务地址',
                visible: false
            },
            {
                field: 'interfaceAddress',
                title: '接口地址',
                visible: false
            },
            {
                title: '接口状态',
                align: 'center',
                formatter: function (value, row, index) {
                    return statusTools(row);
                },
                visible: false
            },
            {
                field: 'typeIam',
                title: 'IAM方式',
                visible: false
            },
            {
                field: 'typeAksk',
                title: 'AK/SK方式',
                visible: false
            }]
        };
        $.table.init(options);
    });

    /* 状态显示 */
    function statusTools(row) {
        if (row.status === '1') {
            return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.id + '\')"></i> ';
        } else {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.id + '\')"></i> ';
        }
    }

    /* 提交 */
    function submitHandler(index, layero){
        let rows = $.table.selectFirstColumns();
        parent.interfaceCallback("123");
        closeItem();
    }
</script>
</body>
</html>
