<!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('callcenter参数配置列表')" />
    <style>
        /*!* 设置表格列的宽度 *!*/
        /*#bootstrap-table th[field="paramName"],*/
        /*#bootstrap-table td[field="paramName"] {*/
        /*    width: 150px;*/
        /*    min-width: 150px;*/
        /*    max-width: 150px;*/
        /*}*/

        /*#bootstrap-table th[field="paramCode"],*/
        /*#bootstrap-table td[field="paramCode"] {*/
        /*    width: 100px;*/
        /*    min-width: 100px;*/
        /*    max-width: 100px;*/
        /*}*/

        /*#bootstrap-table th[field="paramValue"],*/
        /*#bootstrap-table td[field="paramValue"] {*/
        /*    width: 200px;*/
        /*    min-width: 200px;*/
        /*    max-width: 200px;*/
        /*}*/

        /*#bootstrap-table th[field="paramType"],*/
        /*#bootstrap-table td[field="paramType"] {*/
        /*    width: 80px;*/
        /*    min-width: 80px;*/
        /*    max-width: 80px;*/
        /*}*/

        /*#bootstrap-table th[field="id"],*/
        /*#bootstrap-table td[field="id"] {*/
        /*    width: 80px;*/
        /*    min-width: 80px;*/
        /*    max-width: 80px;*/
        /*}*/

        /*#bootstrap-table th[field="操作"],*/
        /*#bootstrap-table td[field="操作"] {*/
        /*    width: 80px;*/
        /*    min-width: 80px;*/
        /*    max-width: 80px;*/
        /*}*/

        /*!* 通用样式：处理内容过长的情况 *!*/
        /*#bootstrap-table td {*/
        /*    !*white-space: normal; !* 防止内容换行 *!*!*/
        /*    !*word-wrap: break-word; !* 允许在单词内换行 *!*!*/
        /*    white-space: nowrap; !* 防止内容换行 *!*/
        /*    overflow: hidden; !* 隐藏超出部分 *!*/
        /*    text-overflow: ellipsis; !* 显示省略号 *!*/
        /*    cursor: pointer; !* 鼠标悬停时显示光标 *!*/
        /*}*/
    </style>
</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 th:text="#{params.manage.query.paramName}"></label>
                                <input type="text" name="paramName"/>
                            </li>
                            <li>
                                <label th:text="#{params.manage.query.paramCode}"></label>
                                <input type="text" name="paramCode"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;<span th:text="#{btn.search}"></span></a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;<span th:text="#{btn.reset}"></span></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:params:add">
                    <i class="fa fa-plus"></i> <span th:text="#{btn.add}"></span>
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:params:edit">
                    <i class="fa fa-edit"></i> <span th:text="#{btn.edit}"></span>
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:params:remove">
                    <i class="fa fa-remove"></i> <span th:text="#{btn.del}"></span>
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:params:export">
                    <i class="fa fa-download"></i> <span th:text="#{btn.export}"></span>
                </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:params:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:params:remove')}]];
        var prefix = ctx + "system/params";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: i18n('params.manage.table.modalName'),
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: i18n('params.manage.table.id'),
                    width: 50,
                    visible: true
                },
                {
                    field: 'paramName',
                    title: i18n('params.manage.table.paramName'),
                    width: 240
                },
                {
                    field: 'paramCode',
                    title: i18n('params.manage.table.paramCode'),
                    width: 150
                },
                {
                    field: 'paramValue',
                    title: i18n('params.manage.table.paramValue'),
                    width: 200,
                    formatter: function(value, row, index) {
                        var maxLength = 60; // 设置最大显示字符数
                        var displayValue = value.length > maxLength ? value.substring(0, maxLength) + '...' : value;
                        var fullContent = value; // 用于显示完整内容
                        // 创建一个可双击复制的元素
                        var cellContent = '<span title="' + fullContent + '" style="cursor: pointer;" ondblclick="copyText(\'' + fullContent + '\')">' + displayValue + '</span>';
                        return cellContent;
                    }
                },
                {
                    field: 'paramType',
                    title: i18n('params.manage.table.paramType'),
                    width: 80
                },
                {
                    title: i18n('params.manage.table.opra'),
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if (row.allowEdit === 1) {
                            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>' + i18n('btn.edit') + '</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>' + i18n('btn.del') + '</a>');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        // 复制文本的函数
        function copyText(text) {
            navigator.clipboard.writeText(text).then(function() {
                $.modal.msg("内容已复制到剪贴板");
            }, function(err) {
                console.error("复制失败", err);
            });
        }
    </script>
</body>
</html>