@ -88,7 +88,7 @@
< label class = "layui-form-label" style = "width: 80px" > 归属课程:< / label >
< div class = "layui-input-block" style = "margin-left: -80px;" >
< layui:simpleDictSelect style = 'layui-input-block'
type="course_info.course_info_name.course_info_status=1 ,course_info_type=1,find_in_set(course_label_id,(select group_concat(course_label_id) from course_label where course_label_status = 1))"
type="course_info.course_info_name.course_info_status!=3 ,course_info_type=1,find_in_set(course_label_id,(select group_concat(course_label_id) from course_label where course_label_status = 1))"
id="courseInfoIds" name="courseInfoId_1"
layFilter="select_courseInfoIds"/>
< / div >
@ -135,7 +135,7 @@
< div class = "layui-form-item" >
< label class = "layui-form-label" style = "width: 80px" > 内容:< / label >
< div class = "layui-input-inline" style = "width: 60% !important;min-width: 500px;" >
< textarea id = "resourcesInfo Files" name = "resourcesInfoFiles " style = "display:none;" > < / textarea >
< textarea id = "resourcesInfo Content" name = "resourcesInfoContent " style = "display:none;" > < / textarea >
< / div >
< / div >
< / div >
@ -180,15 +180,16 @@
//拖拽上传
upload.render({
elem: '#resourcesUpload'
,url: Common.ctxPath + '/jlw/file/update.do' //此处用的是第三方的 http 请求演示,实际使用时改成您自己的上传接口即可。
,url: Common.ctxPath + '/jlw/file/update.do'
,done: function(res){
layer.msg('上传成功');
layui.$('#uploadDemoView').removeClass('layui-hide').find('img').attr('src', Common.ctxPath + res.data.src);
}
});
var uploadInst = upload.render({
elem: '#test1' //绑定元素
elem: '#test1' //上传图文
, url: Common.ctxPath + '/jlw/file/update.do'
,accept:'file'
, done: function (res) {
//上传完毕回调
layer.msg('上传成功');
@ -199,104 +200,110 @@
});
var courseInfoTable = function () {
var ret = Common.getAjax("/jlw/courseInfo/getCourseResources.json", {courseInfoId: courseInfoParentId});
var data = ret.data;
if (ret.code == 0) {
ret.data.forEach(item => {
item.resourcesInfo.forEach(function (e, i) {
e.courseInfoParentId = e.courseInfoId;
e.courseInfoId = 0;
e.courseInfoName = e.resourcesInfoName;
data.push(e);
})
});
}
treetable.render({
elem: '#courseInfoTable',
height: Lib.getTableHeight(1),
cellMinWidth: 100,
data: data,
treeColIndex: 0, //树形图标显示在第几列
treeSpid: courseInfoParentId, //最上级的父级id
treeIdName: 'courseInfoId', //id字段的名称
treePidName: 'courseInfoParentId', //父级节点字段
treeDefaultClose: true, //是否默认折叠
treeLinkage: true //父级展开时是否自动展开所有子级
, limit: 1000
, parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
return {
"code": res.status, //解析接口状态
"msg": res.message, //解析提示文本
"count": res.total, //解析数据长度
"data": res.rows.item //解析数据列表
};
}
, cols: [[ // 表头
{
field: 'LAY_TABLE_INDEX',
title: '序号',
align: "center",
},
{
field: 'courseInfoName',
title: '目录名称',
},
{
field: 'resourcesInfoType',
title: '资源类型',
align: "center",
templet: function (d) {
//资源类型(1视频 2PPT 3PDF 4链接 5图片)
var css = '';
var value = "";
if (d.resourcesInfoType === 1) {
value = "视频";
css = "shiping";
} else if (d.resourcesInfoType === 2) {
value = "PPT";
css = "ppt";
} else if (d.resourcesInfoType === 3) {
value = "PDF";
css = "pdf";
} else if (d.resourcesInfoType === 4) {
value = "链接";
css = "lianjie";
} else if (d.resourcesInfoType === 5) {
value = "图片";
css = "tupian";
}
return '< span class = ' + css + ' > ' + value + '< / span > ';
layer.load(1);
var data=[];
setTimeout(function () {
var ret = Common.getAjax("/jlw/courseInfo/getCourseResources.json", {courseInfoId: courseInfoParentId});
data = ret.data;
if(ret.code == 0){
data.forEach(item => {
item.resourcesInfo.forEach(function (e, i) {
e.courseInfoParentId = e.courseInfoId;
e.courseInfoId = 0;
e.courseInfoName = e.resourcesInfoName;
data.push(e);
})
});
treetable.render({
elem: '#courseInfoTable',
height: Lib.getTableHeight(1),
cellMinWidth: 100,
data: data,
treeColIndex: 0, //树形图标显示在第几列
treeSpid: courseInfoParentId, //最上级的父级id
treeIdName: 'courseInfoId', //id字段的名称
treePidName: 'courseInfoParentId', //父级节点字段
treeDefaultClose: true, //是否默认折叠
treeLinkage: true //父级展开时是否自动展开所有子级
, limit: 1000
, parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
return {
"code": res.status, //解析接口状态
"msg": res.message, //解析提示文本
"count": res.total, //解析数据长度
"data": res.rows.item //解析数据列表
};
}
},
{
field: 'courseInfoId',
title: '操作',
align: "center",
templet: function (d) {
var htm = '';
if (d.courseInfoType === 2) {
htm += '< a class = "layui-table-link" lay-event = "add" > 添加子章节< / a > ';
} else if (d.courseInfoType === 3) {
htm += '< a class = "layui-table-link" lay-event = "updataResources" > 上传资源< / a > ';
htm += '< a class = "layui-table-link" lay-event = "addLine" > 添加链接< / a > ';
htm += '< a class = "layui-table-link" lay-event = "addPW" > 添加图文< / a > ';
}
if (!$.isEmpty(d.resourcesInfoType)) {
htm += '< a class = "layui-table-link" lay-event = "look" > 查看< / a > ';
htm += '< a class = "layui-table-link" lay-event = "update" > 上传< / a > ';
, cols: [[ // 表头
{
field: 'LAY_TABLE_INDEX',
title: '序号',
align: "center",
},
{
field: 'courseInfoName',
title: '目录名称',
},
{
field: 'resourcesInfoType',
title: '资源类型',
width:120,
align: "center",
templet: function (d) {
//资源类型(1视频 2PPT 3PDF 4链接 5图片)
var css = '';
var value = "";
if (d.resourcesInfoType === 1) {
value = "视频";
css = "shiping";
} else if (d.resourcesInfoType === 2) {
value = "PPT";
css = "ppt";
} else if (d.resourcesInfoType === 3) {
value = "PDF";
css = "pdf";
} else if (d.resourcesInfoType === 4) {
value = "链接";
css = "lianjie";
} else if (d.resourcesInfoType === 5) {
value = "图片";
css = "tupian";
}
return '< span class = ' + css + ' > ' + value + '< / span > ';
}
},
{
field: 'courseInfoId',
title: '操作',
align: "center",
templet: function (d) {
var htm = '';
if (d.courseInfoType === 2) {
htm += '< a class = "layui-table-link" lay-event = "add" > 添加子章节< / a > ';
} else if (d.courseInfoType === 3) {
htm += '< a class = "layui-table-link" lay-event = "updataResources" > 上传资源< / a > ';
htm += '< a class = "layui-table-link" lay-event = "addLine" > 添加链接< / a > ';
htm += '< a class = "layui-table-link" lay-event = "addPW" > 添加图文< / a > ';
}
if (!$.isEmpty(d.resourcesInfoType)) {
htm += '< a class = "layui-table-link" lay-event = "look" > 查看< / a > ';
htm += '< a class = "layui-table-link" lay-event = "update" > 上传< / a > ';
}
htm += '< a class = "layui-table-link" lay-event = "edit" > 编辑< / a > ';
htm += '< a class = "layui-table-link" lay-event = "del" > 删除< / a > ';
htm += '< a class = "layui-table-link" lay-event = "move" > 拖动< / a > ';
if (!$.isEmpty(d.resourcesInfoType)) {
htm += '< a class = "layui-table-link" lay-event = "moveUp" > 上移< / a > ';
htm += '< a class = "layui-table-link" lay-event = "moveDown" > 下移< / a > ';
}
return htm;
}
}
htm += '< a class = "layui-table-link" lay-event = "edit" > 编辑< / a > ';
htm += '< a class = "layui-table-link" lay-event = "del" > 删除< / a > ';
htm += '< a class = "layui-table-link" lay-event = "move" > 拖动< / a > ';
if (!$.isEmpty(d.resourcesInfoType)) {
htm += '< a class = "layui-table-link" lay-event = "moveUp" > 上移< / a > ';
htm += '< a class = "layui-table-link" lay-event = "moveDown" > 下移< / a > ';
}
return htm;
}
}
]]
});
]]
});
layer.closeAll();
}
}, 10);
};
courseInfoTable();
/*新增章目录*/
@ -335,16 +342,15 @@
};
addOpen("",'子章节名称',"",param);
}else if (obj.event === 'updataResources') {//上传资源
var that = this;
updataResourcesOpen();
}else if (obj.event === 'addLine') {//添加链接
addLine();
addLine(data.courseInfoId );
} else if (obj.event === 'addPW') {//添加图文
addPW();
addPW(data.courseInfoId );
}else if (obj.event === 'look') {//查看
Lib.downloadFile(data);
}else if (obj.event === 'update') {//上传
updataResourcesOpenLocal ();
updataResourcesOpen();
}else if(obj.event === 'edit'){
var title="章节目录";
var param = {};
@ -571,7 +577,7 @@
/*资源表格搜索*/
function searchList() {
var param = {
"courseInfoId": $("#edit_dialog select[name='courseInfoId_1']").val(),
"courseInfoFull Id": $("#edit_dialog select[name='courseInfoId_1']").val(),
"resourcesInfoName": $("#edit_dialog input[name = 'resourcesInfoName']").val()
};
resourcesTable.reload({
@ -583,7 +589,7 @@
}
/*添加链接*/
function addLine() {
function addLine(courseInfoId ) {
layer.open({
type: 1,
title: "添加链接",
@ -591,7 +597,6 @@
btn: ['保存', '关闭'],
content: $("#addLine_dialog"),
success: function (layero, index) {
}, yes: function (index) {
var resourcesInfoName = $("#addLine_dialog input[name='resourcesInfoName']").val();
var resourcesInfoContent = $("#addLine_dialog input[name='resourcesInfoContent']").val();
@ -611,30 +616,41 @@
});
return;
}
var param = {resourcesInfoName: resourcesInfoName, resourcesInfoContent: resourcesInfoContent,resourcesInfoType:4};
Common.info("保存成功!!");
console.log(param)
layer.close(index);
return;
var ret = Common.postAjax("/jlw/courseInfo/edit.json", param);
layer.msg(ret.code == 0 ? "保存成功!" : ret.msg, {
offset: ['50%'],
icon: ret.code == 0 ? 1 : 2,
time: 1500 //2秒关闭( 如果不配置, 默认是3秒)
}, function () {
if (ret.code == 0) {
layer.close(index);
}
var param = {
'resourcesInfoName': resourcesInfoName,
'resourcesInfoContent': resourcesInfoContent,
'resourcesInfoType':4,
'courseInfoId':courseInfoId
};
layer.load(0,{
shadeClose: false,
shade: [0.5]
});
setTimeout(function () {
var ret = Common.postAjax("/jlw/resourcesInfo/add.json", param);
layer.close();
layer.msg(ret.code == 0 ? "保存成功!" : ret.msg, {
offset: ['50%'],
icon: ret.code == 0 ? 1 : 2,
time: 1500 //2秒关闭( 如果不配置, 默认是3秒)
},function () {
if (ret.code == 0) {
courseInfoTable();
layer.close(index);
}
});
}, 50);
}, btn2: function (index, layero) {
layer.close(index);
}
});
}
var courseInfoContent_ = layedit.build('resourcesInfoFiles', {height: 200}); //题干
var courseInfoContent_ = layedit.build('resourcesInfoContent ', {height: 200}); //题干
/*添加图文*/
function addPW() {
function addPW(courseInfoId ) {
layer.open({
type: 1,
title: "添加图文",
@ -645,30 +661,40 @@
}, yes: function (index) {
var resourcesInfoName = $("#addPW_dialog input[name='resourcesInfoName']").val();
var resourcesInfoFiles = layedit.getContent(courseInfoContent_);
var resourcesInfoContent = layedit.getContent(courseInfoContent_);
if ($.isEmpty(resourcesInfoName)) {
layer.msg("请输入资源 名称!", {
layer.msg("请输入图文 名称!", {
offset: ['50%'],
icon: 2,
time: 2000 //2秒关闭( 如果不配置, 默认是3秒)
});
return;
}
var param = {resourcesInfoName: resourcesInfoName, resourcesInfoFiles: resourcesInfoFiles};
Common.info("保存成功!!");
console.log(param)
layer.close(index);
return;
var ret = Common.postAjax("/jlw/courseInfo/edit.json", param);
layer.msg(ret.code == 0 ? "保存成功!" : ret.msg, {
offset: ['50%'],
icon: ret.code == 0 ? 1 : 2,
time: 1500 //2秒关闭( 如果不配置, 默认是3秒)
}, function () {
if (ret.code == 0) {
layer.close(index);
}
var param = {
'resourcesInfoName': resourcesInfoName,
'resourcesInfoContent': resourcesInfoContent,
'resourcesInfoType':5,
'courseInfoId':courseInfoId
};
layer.load(0,{
shadeClose: false,
shade: [0.5]
});
setTimeout(function () {
var ret = Common.postAjax("/jlw/resourcesInfo/add.json", param);
layer.close();
layer.msg(ret.code == 0 ? "保存成功!" : ret.msg, {
offset: ['50%'],
icon: ret.code == 0 ? 1 : 2,
time: 1500 //2秒关闭( 如果不配置, 默认是3秒)
}, function () {
if (ret.code == 0) {
layer.close(index)
courseInfoTable();
}
});
}, 10);
}, btn2: function (index, layero) {
layer.close(index);
}