(function () {
    var begin = '';
    var end = '';
    var multipleData = null;
    var page = {
        grid: null,
        init: function ($page) {
            begin = '';
            end = '';
            multipleData = null;
            page.grid = $page.find('#lr_EducationalAdministrationJournalReceive_list').lrpagination({
                lclass: page.lclass,
                rows: 10,                            // 每页行数 
                getData: function (param, callback) {// 获取数据 param 分页参数,callback 异步回调 
                    param.multipleData = multipleData;
                    page.loadData(param, callback, $page);
                },
                renderData: function (_index, _item, _$item) {// 渲染数据模板 
                    return page.rowRender(_index, _item, _$item, $page);
                },
                click: function (item, $item, $et) {// 列表行点击事件 
                    if ($et.hasClass('lr-btn-danger')) {
                        page.btnClick(item, $item, $page);
                    }
                    else {
                        page.rowClick(item, $item, $page);
                    }
                },
                btns: page.rowBtns
            });
            $page.find('#lr_EducationalAdministrationJournalReceive_btn').on('tap', function () {
                learun.nav.go({ path: 'EducationalAdministration/JournalReceive/form', title: '新增', type: 'right' });
            });
        },
        lclass: 'lr-list',
        loadData: function (param, callback, $page) {// 列表加载后台数据 
            var _postParam = {
                pagination: {
                    rows: param.rows,
                    page: param.page,
                    sidx: 'JournalReceiveId',
                    sord: 'DESC'
                },
                queryJson: '{}'
            };
            if (param.multipleData) {
                _postParam.queryJson = JSON.stringify(multipleData);
            }
            if (true) {
                _postParam.queryJson = JSON.stringify({ userId: JSON.parse(localStorage.userinfo).baseinfo.userId });
            }
            _postParam.queryJson
            learun.httpget(config.webapi + 'learun/EducationalAdministration/JournalReceive/pagelist', _postParam, (data) => {
                $page.find('.lr-badge').text('0');
                if (data) {
                    $page.find('.lr-badge').text(data.records);
                    callback(data.rows, parseInt(data.records));
                }
                else {
                    callback([], 0);
                }
            });
        },
        rowRender: function (_index, _item, _$item, $page) {// 渲染列表行数据 
            _$item.addClass('lr-list-item lr-list-item-multi');
            _$item.append($('<p class="lr-ellipsis"><span>发送人:</span></p>').dataFormatter({ value: _item.JSender }));
            _$item.append($('<p class="lr-ellipsis"><span>主题:</span></p>').dataFormatter({ value: _item.JTitle }));
            _$item.append($('<p class="lr-ellipsis"><span>日志类型:</span></p>').dataFormatter({
                value: _item.JTypeId,
                type: 'dataItem',
                code: 'JournalType'
            }));
            _$item.append($('<p class="lr-ellipsis"><span>内容:</span></p>').dataFormatter({ value: _item.JContent }));
            _$item.append($('<p class="lr-ellipsis"><span>发送时间:</span></p>').dataFormatter({
                value: _item.JSendTime,
                type: 'datetime',
                dateformat: 'yyyy-MM-dd'
            }));
            return '';
        },
        rowClick: function (item, $item, $page) {// 列表行点击触发方法 
            learun.nav.go({ path: 'EducationalAdministration/JournalReceive/form', title: '详情', type: 'right', param: { keyValue: item.JournalReceiveId } });
        },
        btnClick: function (item, $item, $page) {// 左滑按钮点击事件 
            learun.layer.confirm('确定要删除该笔数据吗？', function (_index) {
                if (_index === '1') {
                    learun.layer.loading(true, '正在删除该笔数据');
                    learun.httppost(config.webapi + 'learun/EducationalAdministration/JournalReceive/delete', item.JournalReceiveId, (data) => {
                        if (data) {// 删除数据成功 
                            page.grid.reload();
                        }
                        learun.layer.loading(false);
                    });
                }
            }, '数字化校园提示', ['取消', '确定']);
        },
        rowBtns: ['<a class="lr-btn-danger">删除</a>'] // 列表行左滑按钮 
    };
    return page;
})(); 