<!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="code"/>
                        </li>
                        <li>
                            <label>接口名称：</label>
                            <input type="text" name="interfaceName"/>
                        </li>
                        <li>
                            <label>共享方式：</label>
                            <select name="shareType" th:with="type=${@dict.getType('share_type')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>请求方式：</label>
                            <select name="interfaceType" th:with="type=${@dict.getType('interface_type')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>签名服务地址：</label>
                            <input type="text" name="signServeraddress"/>
                        </li>
                        <li>
                            <label>接口地址：</label>
                            <input type="text" name="interfaceAddress"/>
                        </li>
                        <li>
                            <label>IAM方式：</label>
                            <input type="text" name="typeIam"/>
                        </li>
                        <li>
                            <label>AK/SK方式：</label>
                            <input type="text" name="typeAksk"/>
                        </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="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:interfaceinfo:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
               shiro:hasPermission="system:interfaceinfo:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="system:interfaceinfo:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()"
               shiro:hasPermission="system:interfaceinfo:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:interfaceinfo:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:interfaceinfo:remove')}]];
    var prefix = ctx + "system/interfaceinfo";
    var shareType_datas = [[${@dict.getType('share_type')}]];
    var interfaceType_datas = [[${@dict.getType('interface_type')}]];
    console.log(interfaceType_datas)


    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "【请填写功能名称】",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '主键ID',
                    visible: false
                },
                {
                    field: 'status',
                    title: '状态',
                    visible: false
                },
                {
                    field: 'remark',
                    title: '注释',
                    visible: false
                },
                {
                    field: 'code',
                    title: '接口码'
                },
                {
                    field: 'interfaceName',
                    title: '接口名称'
                },
                {
                    field: 'infoItem',
                    title: '信息项'
                },
                {
                    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: '环境'
                },
                {
                    field: 'signServeraddress',
                    title: '签名服务地址'
                },
                {
                    field: 'interfaceAddress',
                    title: '接口地址'
                },
                {
                    field: 'typeIam',
                    title: 'IAM方式'
                },
                {
                    field: 'typeAksk',
                    title: 'AK/SK方式'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="settingParams(\'' + row.id + '\')"><i class="fa fa-edit"></i>设置参数</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="execInterface(\'' + row.id + '\')"><i class="fa fa-edit"></i>调用接口</a> ');

                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });


    function settingParams(id) {
        var url = prefix + "/settingParams/" + id;
        console.log(url)
        $.modal.openTab("设置业务接口参数", url);
    }

    function execInterface(id) {
        var url = prefix + "/execInterface/" + id;
        console.log(url)
        $.modal.openTab("设置业务接口参数", url);
    }


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