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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/**
 * 系统管理--用户管理的单例对象
 */
var Course = {
    id: "managerTable",//表格id
    seItem: null,        //选中的条目
    table: null,
    layerIndex: -1,
    deptid:0
};
let language =$("#language").val()
/**
 * 初始化表格的列
 */
Course.initColumn = function () {
    let columns = [
        {field: 'selectItem', radio: true},
        {title: '序号', field: 'id', visible: true, align: 'center', valign: 'middle'},
        {title: '视频类型', field: 'type', align: 'center', valign: 'middle',
            formatter: function (v) {
                switch (v) {
                    case 1:
                        return '课后练习';
                    case 2:
                        return '运动教学视频';
                    case 3:
                        return '器材教学视频';
                }
 
            }
        },
        {title: '课程封面', field: 'coverDrawing', align: 'center', valign: 'middle',
            formatter: function (v) {
                return '<img src="' + v + '" height="100px" onclick="lookBigImg(' + v + ')"/>'
            }
        },
        {title: '课程名称', field: 'name', align: 'center', valign: 'middle'},
        {title: '课程简介', field: 'introduce', align: 'center', valign: 'middle'},
        {title: '状态', field: 'state', align: 'center', valign: 'middle',
            formatter: function (v) {
                return v == 1 ? '上架' : '下架';
            }
        }
    ];
    return columns;
};
 
/**
 * 检查是否选中
 */
Course.check = function () {
    let selected = $('#' + this.id).bootstrapTable('getSelections');
    if (selected.length == 0) {
        Feng.info("请先选中表格中的某一记录!");
        return false;
    } else {
        Course.seItem = selected[0];
        return true;
    }
};
 
/**
 * 点击添加管理员
 */
Course.addCourse = function () {
    let index = layer.open({
        type: 2,
        title: '添加',
        area: ['100%', '100%'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/course/showAddCourse'
    });
    this.layerIndex = index;
};
 
/**
 * 点击修改按钮时
 * @param userId 管理员id
 */
Course.editCourse = function () {
    if (this.check()) {
        let index = layer.open({
            type: 2,
            title: '编辑',
            area: ['100%', '100%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/course/showEditCourse?id=' + this.seItem.id
        });
        this.layerIndex = index;
    }
};
 
 
 
/**
 * 删除用户
 */
Course.delCourse = function () {
    if (this.check()) {
        console.log()
        if (Course.seItem.state == 1){
            Feng.error("只能删除已下架的视频课");
            return;
        }
        let operation = function(){
            let ajax = new $ax(Feng.ctxPath + "/course/delCourse", function () {
                Feng.success("删除成功!");
                Course.table.refresh();
            }, function (data) {
                Feng.error("删除失败!" + data.responseJSON.message + "!");
            });
            ajax.set("id", Course.seItem.id);
            ajax.start();
        };
 
        Feng.confirm("是否删除课程",operation);
    }
};
 
/**
 * 上下架
 * @param userId
 */
Course.editCourseState = function (state) {
    if (this.check()) {
        if(Course.seItem.state == state){
            Feng.error("不能重复操作");
            return
        }
        let ajax = new $ax(Feng.ctxPath + "/course/editCourseState", function (data) {
            Feng.success("下架成功!");
            Course.table.refresh();
        }, function (data) {
            Feng.error("下架失败!" + data.responseJSON.message + "!");
        });
        ajax.set("id", Course.seItem.id);
        ajax.set("state", state);
        ajax.start();
    }
};
 
 
Course.detailsCourse = function () {
    if (this.check()) {
        let index = layer.open({
            type: 2,
            title: '详情',
            area: ['100%', '100%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/course/showCourseDetails?id=' + this.seItem.id
        });
        this.layerIndex = index;
    }
};
 
 
 
Course.resetSearch = function () {
    $("#name").val("");
    $("#type").val("");
    Course.search();
}
 
Course.search = function () {
    let queryData = {};
    queryData['name'] = $("#name").val();
    queryData['courseType'] = $("#type").val();
    Course.table.refresh({query: queryData});
}
 
 
$(function () {
    let defaultColunms = Course.initColumn();
    let table = new BSTable(Course.id, "/course/queryCourseList", defaultColunms);
    // 设置物理分页server(逻辑分页client)
    table.setPaginationType("server");
    Course.table = table.init();
});