/* * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn)  
 * Copyright (c) 2013-2018 北京泉江科技有限公司  
 * 创建人：超级管理员 
 * 日  期：2019-12-24 17:07 
 * 描  述：教学工作量 
 */
(function () {
    var begin = '';
    var end = '';
    var multipleData = null;
    var page = {
        grid: null,
        init: function ($page) {
            begin = '';
            end = '';
            multipleData = null;
            page.grid = $page.find('#lr_EducationalAdministrationTeacherWorkload_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);
                },
                btns: page.rowBtns
            });
            // 多条件查询 
            var $multiple = $page.find('.lr_multiple_search').multiplequery({
                callback: function (data) {
                    begin = '';
                    end = '';
                    multipleData = data || {};
                    page.grid.reload();
                }
            });
        },
        lclass: 'lr-list',
        loadData: function (param, callback, $page) {// 列表加载后台数据 
            var _postParam = {
                pagination: {
                    rows: param.rows,
                    page: param.page,
                    sidx: 'LessonNo',
                    sord: 'asc'
                },
                queryJson: '{}'
            };
            if (param.multipleData) {
                _postParam.queryJson = JSON.stringify(multipleData);
            }
            if (param.begin && param.end) {
                _postParam.queryJson = JSON.stringify({ StartTime: param.begin, EndTime: param.end });
            }
            learun.httpget(config.webapi + 'learun/EducationalAdministration/TeacherWorkload/pagelist', _postParam, (data) => {
                if (data) {
                    console.log(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.LessonName + "【" + _item.LessonNo + "】" }));
            _$item.append($('<p class="lr-ellipsis"><span>总课时：</span></p>').dataFormatter({ value: _item.lessoncount }));
            _$item.append($('<p class="lr-ellipsis"><span>系数：</span></p>').dataFormatter({ value: _item.coefficient }));
            _$item.append($('<p class="lr-ellipsis"><span>工作量：</span></p>').dataFormatter({ value: _item.lessoncount }));
            return '';
        },
    };
    return page;
})(); 