44323
2023-11-06 3caee5ce51a218f4bc1f3757a4d09b0ed18aa6df
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/**
 * 用户详情对话框(可用于添加和修改对话框)
 */
var CourseInfo = {
    userInfoData: {},
};
 
 
 
/**
 * 关闭此对话框
 */
CourseInfo.close = function () {
    parent.layer.close(window.parent.Course.layerIndex);
};
 
 
/**
 * 提交添加用户
 */
CourseInfo.addSubmit = function () {
    let type = $('#type').val();
    let name = $('#name').val();
    let introduce = $('#introduce').val();
    let coverDrawing = $('#coverDrawing').val();
    let introductionDrawing = $('#introductionDrawing').val();
    let courseVideo = $('#courseVideo').val();
    if(null == name || '' == name){
        Feng.error("课程名称不能为空");
        return
    }
    if(null == coverDrawing || '' == coverDrawing){
        Feng.error("课程封面不能为空");
        return
    }
    if(null == introductionDrawing || '' == introductionDrawing){
        Feng.error("课程介绍不能为空");
        return
    }
    if(null == courseVideo || '' == courseVideo){
        Feng.error("课程内容不能为空");
        return
    }
 
    let obj = {
        type: type,
        name: name,
        introduce: introduce,
        coverDrawing: coverDrawing,
        introductionDrawing: introductionDrawing,
        courseVideo: courseVideo
    }
 
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/course/addCourse", function (data) {
        Feng.success("添加成功!");
        window.parent.Course.table.refresh();
        CourseInfo.close();
    }, function (data) {
        Feng.error("添加失败!" + data.responseJSON.message + "!");
    });
    ajax.set(obj);
    ajax.start();
};
 
/**
 * 提交修改
 */
CourseInfo.editSubmit = function () {
    let id = $('#id').val();
    let type = $('#type').val();
    let name = $('#name').val();
    let introduce = $('#introduce').val();
    let coverDrawing = $('#coverDrawing').val();
    let introductionDrawing = $('#introductionDrawing').val();
    let courseVideo = $('#courseVideo').val();
    if(null == name || '' == name){
        Feng.error("课程名称不能为空");
        return
    }
    if(null == coverDrawing || '' == coverDrawing){
        Feng.error("课程封面不能为空");
        return
    }
    if(null == introductionDrawing || '' == introductionDrawing){
        Feng.error("课程介绍不能为空");
        return
    }
    if(null == courseVideo || '' == courseVideo){
        Feng.error("课程内容不能为空");
        return
    }
 
    let obj = {
        id: id,
        type: type,
        name: name,
        introduce: introduce,
        coverDrawing: coverDrawing,
        introductionDrawing: introductionDrawing,
        courseVideo: courseVideo
    }
 
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/course/editCourse", function (data) {
        if(data.code == 200){
 
            window.parent.Course.table.refresh();
            CourseInfo.close();
 
            Feng.success("修改成功!");
        }else{
            Feng.error(data.msg);
        }
    }, function (data) {
        Feng.error("修改失败!" + data.responseJSON.message + "!");
    });
    ajax.set(obj);
    ajax.start();
};
 
 
 
function onBodyDown(event) {
    if (!(event.target.id == "menuBtn" || event.target.id == "menuContent" || $(
        event.target).parents("#menuContent").length > 0)) {
        CourseInfo.hideDeptSelectTree();
    }
}
 
 
function UploadFileFn(){
    $('#upFile').click();
}
 
 
$(function () {
 
    $('#upFile').on('change', function () {
        var formData = new FormData()  //创建一个forData
        formData.append('file', $('#upFile')[0].files[0]) //把file添加进去  name命名为img
        layer.load(); //上传loading
        $.ajax({
            url: Feng.ctxPath + '/mgr/uploadFile',
            data: formData,
            type: "POST",
            async: true,
            cache: false,
            contentType: false,
            processData: false,
            success: function(res) {
                layer.closeAll('loading'); //关闭loading
                $('#upFile').val('');
                $('#courseVideo').val(res);
            }
        })
    })
 
});