@ -37,7 +37,14 @@
color: #2F4056;
border: 2px solid #2F4056;
border-radius: 5px;
padding: 3px;
padding: 2px;
}
.textType {
border: 1px solid #0f9cfd;
color: #0f9cfd;
border-radius: 5px;
padding: 3px
}
< / style >
< input name = "courseInfoId" type = "hidden" value = "${courseInfo.courseInfoId}" / >
@ -70,6 +77,80 @@
< / div >
<!-- 资源库上传 -->
< div id = "edit_dialog" class = "layui-form" style = "display: none;padding: 20px 20px 20px;height: 490px;overflow: auto;" >
< div class = "layui-inline" >
< label class = "layui-form-label" style = "width: 80px" > 资源名称:< / label >
< div class = "layui-input-block" style = "margin-left: 110px;" >
< input type = "text" id = "resourcesInfoName" name = "resourcesInfoName" class = "layui-input" >
< / div >
< / div >
< div class = "layui-inline" >
< 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))"
id="courseInfoIds" name="courseInfoId_1"
layFilter="select_courseInfoIds"/>
< / div >
< / div >
< div class = "layui-inline" style = "left: 30px;" >
< button type = "button" class = "layui-btn bg_button search" > < i class = "layui-icon" >  < / i > < / button >
< / div >
< table id = "resourcesInfoTable" lay-filter = "resourcesInfoTable" > < / table >
< / div >
<!-- 资源上传结束 -->
<!-- 添加链接 -->
< div id = "addLine_dialog" class = "layui-form" style = "display: none;padding-top: 20px" >
< div class = "layui-row" >
< div class = "layui-form-item" >
< label class = "layui-form-label" style = "width: 80px" > < span style = "color: red" > *< / span > 链接名称:< / label >
< div class = "layui-input-inline" >
< input type = "text" name = "resourcesInfoName" class = "layui-input" >
< / div >
< / div >
< / div >
< div class = "layui-row" >
< div class = "layui-form-item" >
< label class = "layui-form-label" style = "width: 80px" > < span style = "color: red" > *< / span > 链接地址:< / label >
< div class = "layui-input-inline" >
< input type = "text" name = "resourcesInfoContent" class = "layui-input" >
< / div >
< / div >
< / div >
< / div >
<!-- 添加图文 -->
< div id = "addPW_dialog" class = "layui-form" style = "display: none;padding-top: 20px" >
< div class = "layui-row" >
< div class = "layui-form-item" >
< label class = "layui-form-label" style = "width: 80px" > < span style = "color: red" > *< / span > 名称:< / label >
< div class = "layui-input-inline" >
< input type = "text" name = "resourcesInfoName" class = "layui-input" >
< / div >
< / div >
< / div >
< div class = "layui-row" >
< 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 = "resourcesInfoFiles" name = "resourcesInfoFiles" style = "display:none;" > < / textarea >
< / div >
< / div >
< / div >
< div class = "layui-row" >
< div class = "layui-form-item" >
< label class = "layui-form-label" style = "width: 80px" > 文件:< / label >
< div class = "layui-input-inline" style = "width: 130px!important" >
< button type = "button" class = "layui-btn" id = "test1" >
< i class = "layui-icon" >  < / i > 上传图片
< / button >
< / div >
< div class = "layui-form-mid" > 支持CS格式< / div >
< / div >
< / div >
< / div >
<!-- # } -->
< script type = "text/javascript" src = "${ctxPath}/plugins/xm-select.js?v=${jsVer}" > < / script >
< script >
@ -83,17 +164,19 @@
}).extend({ //设定组件别名
treetable: 'treetable'
});
layui.define(['form', 'transfer', 'table', 'tree', "laytpl", 'element', 'upload', 'treetable'], function (exports) {
layui.define(['form', 'transfer', 'table', 'tree', "laytpl", 'element', 'upload', 'treetable', "layedit" ], function (exports) {
var form = layui.form,
transfer = layui.transfer ,
table = layui.table ,
upload = layui.upload,
treetable = layui.treetable,
layedit = layui.layedit,
laytpl = layui.laytpl,
table = layui.table,
transfer = layui.transfer ,
tree = layui.tree,
element = layui.element,
treetable = layui.treetable;
var courseInfoParentId = $("input[name='courseInfoId']").val();
element = layui.element;
var courseInfoParentId = $("input[name='courseInfoId']").val();
var resourcesTable = [];
//拖拽上传
upload.render({
elem: '#resourcesUpload'
@ -103,6 +186,17 @@
layui.$('#uploadDemoView').removeClass('layui-hide').find('img').attr('src', Common.ctxPath + res.data.src);
}
});
var uploadInst = upload.render({
elem: '#test1' //绑定元素
, url: Common.ctxPath + '/jlw/file/update.do'
, done: function (res) {
//上传完毕回调
layer.msg('上传成功');
}
, error: function () {
//请求异常回调
}
});
var courseInfoTable = function () {
var ret = Common.getAjax("/jlw/courseInfo/getCourseResources.json", {courseInfoId: courseInfoParentId});
@ -184,7 +278,7 @@
} 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 = "add W P"> 添加图文< / a > ';
htm += '< a class = "layui-table-link" lay-event = "add PW "> 添加图文< / a > ';
}
if (!$.isEmpty(d.resourcesInfoType)) {
htm += '< a class = "layui-table-link" lay-event = "look" > 查看< / a > ';
@ -243,13 +337,13 @@
var that = this;
updataResourcesOpen();
}else if (obj.event === 'addLine') {//添加链接
}else if (obj.event === 'addW P') {//添加图文
addLine();
} else if (obj.event === 'addPW ') {//添加图文
addPW();
}else if (obj.event === 'look') {//查看
Lib.downloadFile(data);
}else if (obj.event === 'update') {//上传
updataResourcesOpenLocal();
}else if(obj.event === 'edit'){
var title="章节目录";
var param = {};
@ -297,6 +391,7 @@
}
});
/*添加、编辑弹窗*/
function addOpen(id,title,data,param) {
layer.open({
@ -332,6 +427,8 @@
}
});
}
/*资源类型弹出框*/
function updataResourcesOpen() {
layer.open({
title: '上传资源类型'
@ -352,7 +449,7 @@
if(type == '1'||type == 1){
updataResourcesOpenLocal();
}else {
updataResourcesOpenRe();
}
layer.close(index);
}
@ -362,7 +459,7 @@
});
}
/*上传 本地资源*/
/*本地资源上传弹出框 */
function updataResourcesOpenLocal() {
layer.open({
title: '本地上传'
@ -380,6 +477,202 @@
});
}
/*资源库上传弹出框*/
function updataResourcesOpenRe() {
layer.open({
type: 1,
title: "资源库上传",
shadeClose: true,
btn: ['保存', '关闭'],
btnAlign: 'c',
area: ['900px', '580px'],
content: $("#edit_dialog"),
success: function (layero, index) {
loadResourcesInfo(3);
$(".search").unbind();
$(".search").click(searchList); //搜索
}, yes: function (index) {
var checkStatus = table.checkStatus("resourcesInfoTable"); //获取选中行状态
var data = checkStatus.data, ids = Common.concatBatchId(data, "resourcesInfoId"); //获取选中行数据
if ($.isEmpty(ids)) {
layer.msg("请选择需要上传的资源!", {
offset: ['50%'],
icon: 2,
time: 2000 //2秒关闭( 如果不配置, 默认是3秒)
});
return;
}
var param = {courseInfoIdPlural: ids};
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 () {
layer.close(index);
});
}, btn2: function (index, layero) {
layer.close(index);
}
});
}
//资源库表格
function loadResourcesInfo(resourcesInfoType, ids) {
$("#edit_dialog input[name='resourcesInfoName']").val("");
resourcesTable = table.render({
elem: '#resourcesInfoTable',
height: Lib.getTableHeight(),
cellMinWidth: 100,
method: 'post',
even: true,
url: Common.ctxPath + '/jlw/resourcesInfo/list.json' // 数据接口
, page: Lib.tablePage // 开启分页
, limit: 10,
cols: [[ // 表头
{
type: 'checkbox'
},
{
field: 'resourcesInfoName', title: '资源名称', align: "center", style: "text-align: left;"
},
{
field: 'courseInfoParentParentName', title: '归属课程', align: "center"
},
{
field: 'resourcesInfoType', width: 150, title: '资源类型', align: "center", templet: function (d) {//(1视频 2PPT 3PDF)
var text = d.resourcesInfoType == 1 ? "视频" : d.resourcesInfoType == 2 ? "PPT" : d.resourcesInfoType == 3 ? "PDF" : d.resourcesInfoType == 4 ? "链接" : d.resourcesInfoType == 5 ? "图文" : '-';
return '< span class = "textType" > ' + text + '< / span > ';
}
},
{
field: 'userId',
title: '操作',
width: resourcesInfoType == 7 || resourcesInfoType == 8 || resourcesInfoType == 9 ? 150 : 100,
align: "center",
templet: function (d) {
var htm = '< button type = "button" class = "layui-btn layui-btn-xs bg_button" lay-event = "previewPage" > 查看< / button > < / a > ';
return htm;
}
}
]]
});
table.on('tool(resourcesInfoTable)', function (obj) {
var data = obj.data;
if (obj.event === 'previewPage') { //预览
Lib.downloadFile(data);
}
});
}
/*资源表格搜索*/
function searchList() {
var param = {
"courseInfoId": $("#edit_dialog select[name='courseInfoId_1']").val(),
"resourcesInfoName": $("#edit_dialog input[name = 'resourcesInfoName']").val()
};
resourcesTable.reload({
where: param,
page: {
curr: 1
}
});
}
/*添加链接*/
function addLine() {
layer.open({
type: 1,
title: "添加链接",
shadeClose: true,
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();
if ($.isEmpty(resourcesInfoName)) {
layer.msg("请输入链接名称!", {
offset: ['50%'],
icon: 2,
time: 2000 //2秒关闭( 如果不配置, 默认是3秒)
});
return;
}
if ($.isEmpty(resourcesInfoContent)) {
layer.msg("请输入链接地址!", {
offset: ['50%'],
icon: 2,
time: 2000 //2秒关闭( 如果不配置, 默认是3秒)
});
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);
}
});
}, btn2: function (index, layero) {
layer.close(index);
}
});
}
var courseInfoContent_ = layedit.build('resourcesInfoFiles', {height: 200}); //题干
/*添加图文*/
function addPW() {
layer.open({
type: 1,
title: "添加图文",
shadeClose: true,
btn: ['保存', '关闭'],
content: $("#addPW_dialog"),
success: function (layero, index) {
}, yes: function (index) {
var resourcesInfoName = $("#addPW_dialog input[name='resourcesInfoName']").val();
var resourcesInfoFiles = layedit.getContent(courseInfoContent_);
if ($.isEmpty(resourcesInfoName)) {
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);
}
});
}, btn2: function (index, layero) {
layer.close(index);
}
});
}
/*课程数据提交*/
function postCourseInfo(id, param) {
layer.load();