//回评模块
var arbitration_process = function(option, success) {
    var object = new ArbitrationProcess(option);
    success();
    return object;
}

function ArbitrationProcess(option) {
    this.markControl = option.markControl;
    this.container = this.markControl.container.sidebar;
    this.init();

    this.markControl.on('task.get.none', this, function(event, context, data) {
        this.container.list.empty();
        this.markControl.trigger('mark.sidebar.close');
        this.container.addClass('hide');
    });
    this.markControl.on('task.get.success', this, function(event, context, data) {
        if (context.task.previous != true) {
            var historyList = context.task.arbitrationList;
            this.container.list.empty();
            if (isArray(historyList) && historyList.length > 0) {
                for (var i in historyList) {
                    var history = historyList[i];
                    var row = getDom(this.history_row_dom, this.markControl).appendTo(this.container.list);
                    row.find('.history-name').html(history.markerName);

                    var date = new Date();
                    date.setTime(history.markTime);
                    row.find('.history-time').html(date.format('hh:mm:ss'));
                    row.find('.history-score').html(history.totalScore);
                }
            }
            this.markControl.trigger('mark.sidebar.open');
            this.container.removeClass('hide');
        }
    });
    this.markControl.on('mark.history.open', this, function(event, context, data) {
        this.container.addClass('hide');
    });
}

ArbitrationProcess.prototype.init = function() {
    this.container.empty();

    this.container.header = getDom(this.header_dom, this.markControl).appendTo(this.container);
    this.container.list = getDom(this.history_list_dom, this.markControl).appendTo(this.container).find('#history-list');
}


ArbitrationProcess.prototype.header_dom = '<div class="header">\
<p class="fl">给分记录</p></div>';

ArbitrationProcess.prototype.history_list_dom = '<div class="sublist"><table class="table table-hover">\
<thead><tr><th>评卷员</th><th>时间</th><th>总分</th></tr></thead>\
<tbody id="history-list"></tbody></table></div>';

ArbitrationProcess.prototype.history_row_dom = '<tr><td class="history-name"></td>\
<td class="history-time"></td><td class="history-score"></td></tr>';