<!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('教育培训列表')" />
    <link th:href="@{/ruoyi/css/meeting.css}" rel="stylesheet"/>
    <th:block th:include="include :: datetimepicker-css" />
</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="meetingName"/>
                            </li>
                            <li>
                                <label class="control-label">培训日期：</label>
                                <input type="text" class="time-input" placeholder="请选择培训日期" name="startDate"/> -
                                <input type="text" class="time-input" placeholder="请选择培训日期" name="endDate"/>
                            </li>
                            <li>
                                <a class="btn btn-unite btn-rounded btn-sm" onclick="$.table.search()">搜索</a>
                                <a class="btn btn-unite btn-rounded btn-sm" onclick="$.form.reset()">重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div id="toolbar" role="group">
                <a class="btn btn-unite" onclick="meetingAdd()" shiro:hasPermission="system:meeting:add">
                    添加
                </a>
                <a class="btn btn-unite single disabled" onclick="meetingUpdate()" shiro:hasPermission="system:information:edit">
                    修改
                </a>
                <a class="btn btn-unite multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:information:remove">
                    删除
                </a>
                <a class="btn btn-unite" onclick="$.table.exportExcel()" shiro:hasPermission="system:information:export">
                    导出
                </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" />
     <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:meeting:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:meeting:remove')}]];
        var prefix = ctx + "system/meeting";
        $(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: 'meetingName',
                    title: '培训标题'
                },
                {
                    field: 'rwkMeetingStaffList',
                    title: '参与人数/受邀人数',
                    formatter: function(value, row, index) {
                        var str = "0/0";
                        if (value && value.length > 0){
                            var totalInvited = value.length; // 受邀人员总数
                            //提取已签到数量的数 不使用filter方法
                           // var signedInCount = value.filter(person => person.isSign === 1).length; // 签到人数
                           // str = signedInCount+"/"+totalInvited;
                        }
                        return str;
                    }
                },
                {
                    field: 'meetingDate',
                    title: '培训时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-unite btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="meetingUpdate(\'' + row.id + '\')">编辑</a> ');
                        actions.push('<a class="btn btn-unite btn-xs" href="javascript:void(0)" onclick="meetingView(\'' + row.id + '\')">查看</a> ');
                        actions.push('<a class="btn btn-unite btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')">删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        //新增
        function meetingAdd() {
            var options = {
                title: '新增培训活动',
                url: prefix + "/add",
                skin: 'layui-layer-blue',
                btn: ['保存','取消'],
                width: 1400,
                height: 800,
                maxmin: false,
                full: false,
                yes: function(index, layero) {
                    var iframeWin = layero.find('iframe')[0];
                    iframeWin.contentWindow.submitHandler(index, layero);
                }
            };
            $.modal.openOptions(options);
        }

        //修改
        function meetingUpdate(id) {
            var url = $.operate.editUrl(id);
            var options = {
                title: '修改培训活动',
                url: url,
                skin: 'layui-layer-blue',
                btn: ['保存', '取消'],
                width: 1400,
                height: 800,
                maxmin: false,
                full: false,
                yes: function(index, layero) {
                    var iframeWin = layero.find('iframe')[0];
                    iframeWin.contentWindow.submitHandler(index, layero);
                }
            };
            $.modal.openOptions(options);
        }

        //查看
        function meetingView(id) {
            var options = {
                title: '培训会议详情',
                url: prefix + "/meetingView/"+id,
                skin: 'layui-layer-gray',
                btn: ['关闭'],
                width: 1400,
                height: 800,
                maxmin: false,
                full: false,
                yes: function (index) {
                    $.modal.close(index);
                }
            };
            $.modal.openOptions(options);
        }
    </script>
</body>
</html>