PlayRecordApe.js 8.0 KB
//*
// 录制管理模块
// */

import Loger from "../Loger";
import Ape from "./Ape";
import $ from "jquery";
import ClassDataProxy from "proxy/ClassDataProxy";
import ErrorApe from "./ErrorApe";

let loger = Loger.getLoger('PC-PlayRecordApe');
const adminListTit = `<table width="100%" align="center" cellpadding="0" cellspacing="0" border="0" class="t_box">
                        <tbody>
                            <tr align="center" height="44" class="tr_center" bgcolor="#fff" bordercolor="#e6e6e6">
                                <th width="8%" class="tr_center">
                                    课堂主题
                                </th>
                                <th width="8%" class="tr_center">
                                    课堂号
                                </th>
                                <th width="8%" class="tr_center">
                                    录制人
                                </th>
                                <th width="8%" class="tr_center">
                                    录制开始时间
                                </th>
                                <th width="8%" class="tr_center">
                                    录制结束时间
                                </th>
                                <th width="10%" class="tr_center">
                                    操作
                                </th>
                            </tr>
`;
//管理首页
const adminList = `<tr align="center" bgcolor="#FFFFFF" height="44" bordercolor="#e6e6e6">
                                <td width="8%" class="tr_main tr_mainLeft">{_loginName}</td>
                                <td width="8%" class="tr_main">{_userName}</td>
                                <td width="8%" class="tr_main">{_course}</td>
                                <td width="8%" class="tr_main">{_totalNmu}</td>
                                <td width="8%" class="tr_main">{_latest}</td>
                                <td  width="10%" class="tr_main tr_mainRight" align="center">
                                    <a id="{_removeInd}" class="classHandlePort playRecord" data="{_userName}" href="#">播放</a>
                                    <a id="{_removeInd}" class="classHandlePort deleteClass" data="{_aboutMsg}" href="###">删除</a>
                                    <a id="{_joinInd}" class="classHandlePort" href="###" data="{_aboutMsg}">设置为非公开</a>
                                </td>
                            </tr>
`;
const adminListEnd = `</tbody></table>`;
class PlayRecordApe extends Ape {
    constructor() {
        super();
        this.pageNo = 0;
        this.presentInd = 1;
        this.addEvent();
        this.init();
    }

    init() {

        $('#userClassList5 li').on('click',this._userClassListHandler.bind(this));//用户列表

        //录制回放
        $('#classHandlerHomePage5').on('click',this._homePageHandler.bind(this));//首页
        $('#classHandlerUpPage5').on('click',this._upPageHandler.bind(this));//上页
        $('#classHandlerDownPage5').on('click',this._downPageHandler.bind(this));//下页
        $('#classHandlerEndPage5').on('click',this._endPageHandler.bind(this));//尾页
        $('#classHandlerSpecificPage5').on('click',this._assignPageHandler.bind(this));//指定页

        $('#courseContent5').on('click','.playRecord',this.playRecord.bind(this));//回放
        $('#courseContent5').on('click','.deleteClass',this.deleteRecord.bind(this));//删除



    }

    addEvent() {

    }

    _switchover(evt){
        $(evt.currentTarget).addClass('liveInfoLeftLiCheck').siblings().removeClass('liveInfoLeftLiCheck');
    }
    playRecord(evt) {
        let ind = $(evt.target).attr('data');
        window.open("http://networkshool.xuedianyun.com/3m/doPlayRecord.do?meetingNumber=" + ind);
    }
    deleteRecord(evt){
        let ind = $(evt.target).attr('data');
        $.ajax({
            type : 'POST',
            url : 'http://networkshool.xuedianyun.com/recordingMeeting/deleteRecordingMeeting.do',
            dataType: "text",
            data: "recordingMeeting.id=" + id + "&temp=" + new Date().getTime(),
            success : function(_data){
                loger.log('_data','删除回放数据')
            },
            error: function () {
                loger.log("Request.failed !");
            }
        })
    }
    _userClassListHandler(evt){
        this._switchover(evt);
        this.detailPage(1);
    }
    //首页
    _homePageHandler(){
        this.presentInd = 1;
        this.detailPage(this.presentInd);
    }
    //上页
    _upPageHandler(){
        if(this.presentInd >1){
            this.presentInd--;
            this.detailPage(this.presentInd);
        }
    }
    //下页
    _downPageHandler(){
        if(this.presentInd < this.pageNo){
            this.presentInd++;
            this.detailPage(this.presentInd);
        }
    }
    //尾页
    _endPageHandler(){
        this.presentInd = this.pageNo;
        this.detailPage(this.presentInd);
    }
    //指定页
    _assignPageHandler(){
        let inputVal = $('#classHandlerPageInfoInput5').val();
        if(parseInt(inputVal) <= this.pageNo || parseInt(inputVal) >= 1 ){
            this.detailPage(parseInt(inputVal));
        }
    }
    detailPage(ind){
        let _url = ClassDataProxy.locationProtocol + ClassDataProxy.locationProt + '/meeting/getMeeting';
        let that = this;
        $.ajax({
            type: "POST",
            url: _url,
            data:{siteId : ClassDataProxy.siteId},
            headers: {siteId:ClassDataProxy.siteId,
                pageno:8,
                page:ind,
                'token':ClassDataProxy.token},
            success:function(_data){
                if(_data && _data.code == 200){
                  //  loger.log(_data,'录制回放数据信息')
                    that._gainUserClassData(_data.returnData.data);
                }
            },
            error:function(error){
                that._gainUserClassDataErr();
                console.log(error,'录制回放数据信息失败')
            }
        })
    }
    _gainUserClassData(_data){
        let _dataList = _data.meetingInfo;
        let courseContent = $('#courseContent5');
        courseContent.empty();
        let count = _data.count;
        let page = _data.page;
        let pageno = _data.pageno;
        let pagenum = Math.ceil(count / pageno);
        this.pageNo = pagenum;
        $('#classHandlerPageMsg5').html('第'+page+'页/共'+pagenum+'页,有'+count+'个记录');
        courseContent.append(adminListTit);
        if(_dataList){
            if(count <= 7){
                $('#classHandlerPageBox5').hide();
            }
            for(let i = 0;i<_dataList.length;i++){
                let _adminList = this._format(adminList,{
                    _loginName : _dataList[i].meetingName,
                    _userName : _dataList[i].meetingNumber,
                    _course : _dataList[i].create_user,
                    _totalNmu : _dataList[i].beginTime,
                    _latest : _dataList[i].endTime,
                    _removeInd : 'classDoc'+i,
                    _joinInd : 'classMedia'+i,
                    _aboutMsg : _dataList[i].id
                })
                courseContent.append(_adminList);
            }
            courseContent.append(adminListEnd);
        }
    }
    _gainUserClassDataErr(){
        let courseContent = $('#courseContent5');
        courseContent.empty();
        courseContent.append(adminListTit);
        let _adminList = '<tr align="center" bgcolor="#FFFFFF" height="44" bordercolor="#e6e6e6">' +
            '<td class="tr_main tr_mainNone">' +
            '该课堂暂无录制回放数据~'+
            '</td>>'+
            '</tr>'
        courseContent.append(_adminList);

        courseContent.append(adminListEnd);

    }
    //工具类
    _format(str, obj) {
        return str.replace(/\{(\w+)\}/g, function (match, group, index) {
            return obj[group];
        });
    };
}
export default PlayRecordApe;