/* * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn)  
 * Copyright (c) 2013-2018 北京泉江科技有限公司  
 * 创建人：超级管理员 
 * 日  期：2020-06-03 14:29 
 * 描  述：听课记录 
 */
(function () { 
    var keyValue = ''; 
    var $header = null; 
    var titleText = ''; 
    var page = { 
        isScroll: true, 
        init: function ($page, param) { 
            keyValue = param.keyValue; 
            // 添加头部按钮列表 
            var _html = '\
                <div class="lr-form-header-cancel" >取消</div>\
                <div class="lr-form-header-btnlist" >\
                    <div class="lr-form-header-more" ><i class="iconfont icon-more" ></i></div>\
                    <div class="lr-form-header-edit" ><i class="iconfont icon-edit" ></i></div>\
                </div>\
                <div class="lr-form-header-submit" >提交</div>'; 
            $header = $page.parents('.f-page').find('.f-page-header'); 
            $header.append(_html); 
            // 取消 
            $header.find('.lr-form-header-cancel').on('tap', function () { 
                learun.layer.confirm('确定要退出当前编辑？', function (_index) { 
                    if (_index === '1') { 
                        if (keyValue) {// 如果是编辑状态 
                            learun.formblur(); 
                            $header.find('.lr-form-header-cancel').hide(); 
                            $header.find('.lr-form-header-submit').hide(); 
                            $header.find('.lr-form-header-btnlist').show(); 
                            $header.find('.f-page-title').text(titleText); 
                            $page.find('.lr-form-container').setFormRead(); 
                        } 
                        else {// 如果是新增状态 关闭当前页面 
                            learun.nav.closeCurrent(); 
                        } 
                    } 
                }, 'learun智慧校园提示', ['取消', '确定']); 
            }); 
            // 编辑 
            $header.find('.lr-form-header-edit').on('tap', function () { 
                $header.find('.lr-form-header-btnlist').hide(); 
                $header.find('.lr-form-header-cancel').show(); 
                $header.find('.lr-form-header-submit').show(); 
                titleText = $header.find('.f-page-title').text(); 
                $header.find('.f-page-title').text('编辑'); 
                $page.find('.lr-form-container').setFormWrite(); 
            }); 
            // 更多 
            $header.find('.lr-form-header-more').on('tap', function () { 
                learun.actionsheet({ 
                    id: 'more', 
                    data: [ 
                        { 
                            text: '删除', 
                            mark: true, 
                            event: function () {// 删除当前条信息 
                                learun.layer.confirm('确定要删除该笔数据吗？', function (_index) { 
                                    if (_index === '1') { 
                                        learun.layer.loading(true, '正在删除该笔数据'); 
                                        learun.httppost(config.webapi + 'learun/LogisticsManagement/ListenClassRecord/delete', keyValue, (data) => { 
                                            learun.layer.loading(false); 
                                            if (data) {// 删除数据成功 
                                                learun.nav.closeCurrent(); 
                                                var prepage = learun.nav.getpage('LogisticsManagement/ListenClassRecord'); 
                                                prepage.grid.reload(); 
                                            } 
                                        }); 
                                    } 
                                }, 'Learun智慧校园提示', ['取消', '确定']); 
                            } 
                        } 
                    ], 
                    cancel: function () { 
                    } 
                }); 
            }); 
            // 提交 
            $header.find('.lr-form-header-submit').on('tap', function () { 
                // 获取表单数据 
                if (!$page.find('.lr-form-container').lrformValid()) { 
                    return false; 
                } 
                var _postData = {} 
                _postData.keyValue = keyValue; 
                _postData.strEntity = JSON.stringify($page.find('.lr-form-container').lrformGet()); 
                learun.layer.loading(true, '正在提交数据'); 
                learun.httppost(config.webapi + 'learun/LogisticsManagement/ListenClassRecord/save', _postData, (data) => { 
                    learun.layer.loading(false); 
                    if (data) {// 表单数据保存成功 
                        if (keyValue) { 
                            learun.layer.toast('保存数据成功!'); 
                            learun.formblur(); 
                            $header.find('.lr-form-header-cancel').hide(); 
                            $header.find('.lr-form-header-submit').hide(); 
                            $header.find('.lr-form-header-btnlist').show(); 
                            $header.find('.f-page-title').text(titleText); 
                            $page.find('.lr-form-container').setFormRead(); 
                        } 
                        else {// 如果是 
                            learun.nav.closeCurrent(); 
                        } 
                        var prepage = learun.nav.getpage('LogisticsManagement/ListenClassRecord'); 
                        prepage.grid.reload(); 
                    } 
                }); 
            }); 
            page.bind($page, param); 
            if (keyValue) { 
                // 添加编辑按钮 
                $page.find('.lr-form-container').setFormRead(); 
                $header.find('.lr-form-header-btnlist').show(); 
                // 获取表单数据 
                learun.layer.loading(true, '获取表单数据'); 
                learun.httpget(config.webapi + 'learun/LogisticsManagement/ListenClassRecord/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]); 
                            } 
                        } 
                    } 
                    learun.layer.loading(false); 
                }); 
            } 
            else { 
                $header.find('.lr-form-header-cancel').show(); 
                $header.find('.lr-form-header-submit').show(); 
            } 
        }, 
        bind: function ($page, param) { 
            $page.find('#DeptNo').lrpickerex({ 
                type: 'sourceData', 
                code: 'CdDeptInfo', 
                ivalue: 'deptno', 
                itext: 'deptname',
                change:function(val) {
                    if (val != null) {
                        learun.httpget(config.webapi+'dept/majorbydept',val,(data) => {
                            if (data) {
                                $page.find('#MajorNo').lrpickerSetData(data); 
                            }
                        })
                    }
                }
            }); 
            $page.find('#MajorNo').lrpickerex({ 
                ivalue: 'MajorNo', 
                itext: 'MajorName',
                change:function(val) {
                    if (val != null) {
                        learun.httpget(config.webapi+'dept/classbymajor',val,(data) => {
                            if (data) {
                                console.log(data);
                                $page.find('#ClassNo').lrpickerSetData(data); 
                            }
                        })
                    }
                }
            }); 
            $page.find('#EmpNo').lrselect({ 
                type: 'user', 
                needPre:false
            }); 
            $page.find('#ClassNo').lrpickerex({ 
                ivalue: 'ClassNo', 
                itext: 'ClassName'
            }); 
            $page.find('#RecordTime').lrdate({ 
                type: 'date'
            }); 
            $page.find('#xxmb').lrpickerex({ 
                data:[{ text: '有', value: '1' }, { text: '无', value: '0' }]
             }); 
            $page.find('#xxmbsfkcl').lrpickerex({ 
           data:[{ text: '良好', value: '1' }, { text: '稍作修改', value: '2' }, { text: '较大修改', value: '3' }]            }); 
            var logininfo = learun.storage.get('userinfo');
            $page.find('#Creater').lrselect({ 
                type: 'user', 
                needPre:false            }).lrselectSet(logininfo.baseinfo.userId);

            console.log(logininfo);
            $page.find('#xxqjdsj').lrpickerex({ 
            data:[{ text: '满足', value: '1' }, { text: '基本满足', value: '2' }, { text: '不满足', value: '3' }]            }); 
            $page.find('#gzrwdsj').lrpickerex({ 
            data:[{ text: '合适', value: '1' }, { text: '基本合适', value: '2' }, { text: '不合适', value: '3' }]            }); 
            $page.find('#jxhddsj').lrpickerex({ 
            data:[{ text: '好', value: '1' }, { text: '一般', value: '2' }, { text: '较差', value: '3' }]            }); 
            $page.find('#jxzddfx').lrpickerex({ 
            data:[{ text: '分析清晰', value: '1' }, { text: '需要改进', value: '2' }]            }); 
            $page.find('#gczhdytw').lrpickerex({ 
            data:[{ text: '方法', value: '1' }, { text: '效果', value: '2' }]            }); 
            $page.find('#xsdcyhz').lrpickerex({ 
            data:[{ text: '良好', value: '1' }, { text: '一般', value: '2' }, { text: '较差', value: '3' }]            }); 
            $page.find('#xsdsjjn').lrpickerex({ 
            data:[{ text: '实践内容丰富', value: '1' }, { text: '实践内容较少', value: '2' }]            }); 
            $page.find('#xsxxxggc').lrpickerex({ 
            data:[{ text: '良好', value: '1' }, { text: '一般', value: '2' }, { text: '较差', value: '3' }]            }); 
            $page.find('#Evaluate').lrpickerex({ 
            data:[{ text: '优秀，可示范', value: '1' }, { text: '良好，有期待', value: '2' }, { text: '一般，待改进', value: '3' }, { text: '较差，需培训', value: '4' }]            }); 
        },        destroy: function (pageinfo) { 
            $header = null; 
            keyValue = ''; 
        } 
    }; 
    return page; 
})(); 