/**
|
* 系统管理--用户管理的单例对象
|
*/
|
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();
|
});
|