<!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="sitename"/>
                            </li>
                            <li>
                                <label>标识：</label>
                                <input type="text" name="record"/>
                            </li>
                            <li>
                                <label>主域名：</label>
                                <input type="text" name="domain"/>
                            </li>
                            <!--<li>
                                <label>文件路径：</label>
                                <input type="text" name="filepath"/>
                            </li>
                            <li>
                                <label>信息：</label>
                                <input type="text" name="msg"/>
                            </li>
                            <li>
                                <label>其他：</label>
                                <input type="text" name="other"/>
                            </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="project:siteconfig:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="project:siteconfig:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="project:siteconfig:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="project:siteconfig: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 doFlag = [[${@permission.hasPermi('project:siteconfig:edit')}]];
        var detailFlag = [[${@permission.hasPermi('project:siteconfig:edit')}]];
        var editFlag = [[${@permission.hasPermi('project:siteconfig:edit')}]];
        var removeFlag = [[${@permission.hasPermi('project:siteconfig:remove')}]];
        var prefix = ctx + "project/siteconfig";

        $(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: '主键',
                    visible: false
                },
                {
                    field: 'sitename',
                    title: '站点名称'
                },
                {
                    field: 'record',
                    title: '标识'
                },
                {
                    field: 'domain',
                    title: '主域名'
                },
                /*{
                    field: 'filepath',
                    title: '文件路径'
                },
                {
                    field: 'msg',
                    title: '信息'
                },
                {
                    field: 'other',
                    title: '其他'
                },*/
                {
                    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-primary btn-xs ' + doFlag + '" href="javascript:void(0)" onclick="docon(\'' + row.id + '\')"><i class="fa fa-play"></i>链接扫描</a> ');
                        /*actions.push('<a class="btn btn-primary btn-xs ' + doFlag + '" href="javascript:void(0)" onclick="dosysn(\'' + row.id + '\')"><i class="fa fa-play"></i>执行同步</a> ');*/
                        actions.push('<a class="btn btn-primary btn-xs ' + doFlag + '" href="javascript:void(0)" onclick="doscan(\'' + row.id + '\')"><i class="fa fa-play"></i>扫描</a> ');
                        actions.push('<a class="btn btn-primary btn-xs ' + doFlag + '" href="javascript:void(0)" onclick="doreview(\'' + row.id + '\')"><i class="fa fa-play"></i>复核</a> ');
                        /*actions.push('<a class="btn btn-success btn-xs ' + detailFlag + '" href="javascript:void(0)" onclick="detail(\'' + row.id + '\')"><i class="fa fa-bar-chart"></i>扫描结果</a> ');*/
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
     <script>
         /*执行扫描*/
         function doscan (dataid) {
             $.modal.confirm("是否执行扫描操作？", function() {
                 var data = { "id": dataid, "type": "1" };
                 $.operate.saveModal(prefix + "/doscan", data, null);
             })
         }
         /*执行复核*/
         function doreview (dataid) {
             $.modal.confirm("是否执行复核操作？", function() {
                 var data = { "id": dataid, "type": "2" };
                 $.operate.saveModal(prefix + "/doscan", data, null);
             })
         }
         /*执行同步*/
         function dosysn(dataid) {
             var data = { "id": dataid };
             $.operate.saveModal(prefix + "/dosysn", data, null);
         }
         /*执行扫描正文*/
         function docon(dataid) {
             $.modal.confirm("是否执行扫描操作？", function() {
                 var data = { "id": dataid };
                 $.operate.saveModal(prefix + "/docon", data, null);
             })
         }
         function detail(dataid) {
             var url = prefix + '/detail/' + dataid;
             $.modal.openTab("扫描详情", url);
         }
         $(function() {
             // 监听表单的 Enter 键按下事件
             $('#formId').on('keydown', function(e) {
                 if (e.key === 'Enter') {
                     e.preventDefault(); // 阻止默认提交行为
                     $.table.search();   // 触发搜索
                 }
             });
         });
     </script>
</body>
</html>