(function () {
    var keyValue = '';
    var weekChina = ["一", "二", "三", "四", "五", "六", "日"];
    var $header = null;
    var titleText = '';
    var page = {
        isScroll: true,
        init: function ($page, param) {
            keyValue = param.keyValue;
            $header = $page.parents('.f-page').find('.f-page-header');
            // 取消 
            $header.find('.lr-form-header-cancel').on('tap', function () {
                learun.nav.closeCurrent();
            });
            
            page.bind($page, param);
            if (keyValue) {
                $page.find('.lr-form-container').setFormRead();
                // 获取表单数据 
                learun.layer.loading(true, '获取表单数据');
                learun.httpget(config.webapi + 'learun/EducationalAdministration/OpenLessonPlanOfElectiveStudent/form', keyValue, (data) => {
                    if (data) {
                        for (var id in data) {
                            if (data[id].length) {
                                $page.find('#' + id).lrgridSet(data[id]);
                            }
                            else {
                                $page.find('[data-table="' + id + '"]').lrformSet(data[id]);
                                var ls = "";
                                if (data[id].LessonSection.indexOf(',') == -1)
                                    ls = "星期" + weekChina[data[id].LessonSection.slice(0, 1) - 1] + "第" + data[id].LessonSection.slice(1) + "节";
                                else
                                    ls = "星期" + weekChina[data[id].LessonSection.slice(0, 1) - 1] + "第" + data[id].LessonSection.slice(1, 2) + "、" + data[id].LessonSection.slice(4) + "节";
                                $("#LessonSection").val(ls);
                                $("#Introduction").html(data[id].Introduction);
                                $("#resume").html(data[id].resume);
                            }
                        }
                    }
                    learun.layer.loading(false);
                });
            }
        },
        bind: function ($page, param) {

        }, destroy: function (pageinfo) {
            $header = null;
            keyValue = '';
        }
    };
    return page;
})(); 