Files
SIPAIIS_WMS_JSSW/WebRoot/jsp/teacher/teacherFileEditview.jsp

306 lines
14 KiB
Plaintext
Raw Normal View History

2026-01-16 14:13:44 +08:00
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<style type="text/css">
.select2-container .select2-selection--single{
height:34px;
line-height: 34px;
}
.select2-selection__arrow{
margin-top:3px;
}
</style>
<script type="text/javascript">
var masterId='${param.id}';
var tbName ='tb_teacher_file'; //数据表
var nameSpace='Document';//保存文件夹
//编辑模态框
var editModelFun = function (id) {
$.post(ext.contextPath + '/teacher/teacherfile/doedit.do', {id : id}, function (data) {
$("#editDiv").html(data);
openModal('editModel');
});
};
//上传文件
var fileinput = function() {
$.post(ext.contextPath + '/teacher/teacherfile/fileinput.do', {masterId:masterId,tbName:tbName,nameSpace:nameSpace} , function(data) {
$("#fileInputDiv").html(data);
openModal('fileInputModal');
});
};
//下载文件
var fileDownload = function(id) {
window.open(ext.contextPath + "/base/downloadFile.do?key="+id+"&tbName="+tbName,"_self");
// $.post(ext.contextPath + '/base/downloadFile.do', {key:id,tbName:tbName} , function(data) {
// });
};
//浏览 暂时浏览图片
var viewFun = function(urlpath,id){
$.post(ext.contextPath + '/teacher/teacherfile/doview.do', {urlpath:urlpath,id} , function(data) {
$("#subDiv").html(data);
openModal('subModal');
});
}
var delFileFun = function(id) {
stopBubbleDefaultEvent();
swal({
text: "您确定要删除此记录?",
dangerMode: true,
buttons: {
cancel: {
text: "取消",
value: null,
visible: true,
className: "btn btn-default btn-sm",
closeModal: true,
},
confirm: {
text: "确定",
value: true,
visible: true,
className: "btn btn-danger btn-sm",
closeModal: true
}
}
})
.then(function(willDelete){
if (willDelete) {
$.post(ext.contextPath + '/teacher/teacherfile/dodeleteFile.do', {id : id,tbName:tbName}, function(data) {
if(data == 1){
$("#fileTable").bootstrapTable('refresh');
}else{
showAlert('d','删除失败','mainAlertdiv');
}
});
}
});
};
$(function() {
$("#fileTable").bootstrapTable({ // 对应table标签的id
url: ext.contextPath + '/teacher/teacherfile/getFileList.do', // 获取表格数据的url
cache: false, // 设置为 false 禁用 AJAX 数据缓存, 默认为true
striped: true, //表格显示条纹默认为false
pagination: true, // 在表格底部显示分页组件默认false
pageList: [8,10,15], // 设置页面可以显示的数据条数
pageSize: 8, // 页面数据条数
pageNumber: 1, // 首页页码
sidePagination: 'server', // 设置为服务器端分页
queryParams: function (params) { // 请求服务器数据时发送的参数可以在这里添加额外的查询参数返回false则终止请求
return {
rows: params.limit, // 每页要显示的数据条数
page: params.offset/params.limit+1, // 每页显示数据的开始页码
sort: params.sort, // 要排序的字段
order: params.order, // 排序规则
masterId: masterId,
tbName : tbName
}
},
sortName: 'id', // 要排序的字段
sortOrder: 'desc', // 排序规则
columns: [
{
field: 'filename', // 返回json数据中的name
title: '名称', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle' // 上下居中
}, {
field: 'filefolder', // 返回json数据中的name
title: '归属文件夹', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',// 上下居中
// formatter:function(value,row,index){
// return '<a onclick="fileDownload(\'' + row.id + '\')">'+value+'</a>'
// }
}, {
field: 'type', // 返回json数据中的name
title: '类型', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',// 上下居中
}, {
field: 'size', // 返回json数据中的name
title: '大小', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',// 上下居中
formatter: function (value, row, index) {
// console.log(typeof value);
// console.log(value);
// if(value<1073741825){
// console.log('right');
// return 1000000;
// }
if(value<1024){
return value.toFixed(2)+"B";
}else if(1024<=value&&value<1048576){
return (value/1024).toFixed(2)+"K";
}else if(1048576<=value&&value<1073741824){
return (value/1048576).toFixed(2)+"M";
}
}
}, {
// field: '大小', // 返回json数据中的name
// title: '上传者', // 表格表头显示文字
// align: 'center', // 左右居中
// valign: 'middle',// 上下居中
// }, {
// field: 'insdt', // 返回json数据中的name
// title: '上传时间', // 表格表头显示文字
// align: 'center', // 左右居中
// valign: 'middle', // 上下居中
// }, {
field: 'memo', // 返回json数据中的name
title: '摘要', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle', // 上下居中
}, {
title: "操作",
align: 'center',
valign: 'middle',
width: 200, // 定义列的宽度单位为像素px
formatter: function (value, row, index) {
var buts= '';
buts+='<button class="btn btn-default btn-sm" title="下载" onclick="fileDownload(\'' + row.id + '\')"><i class="fa fa-download"></i><span class="hidden-md hidden-lg">下载</span></button>';
buts+='<button class="btn btn-default btn-sm" title="浏览" onclick="viewFun(\'' + row.urlpath + '\',\'' + row.id + '\')"><i class="fa fa-eye"></i><span class="hidden-md hidden-lg">浏览</span></button>';
buts='<div class="btn-group" >'+buts+'</div>';
return buts;
}
}
],
onLoadSuccess: function(){ //加载成功时执行
//$(".bs-checkbox").css({'text-align':'center','vertical-align':'middle'})
adjustBootstrapTableView("fileTable");
},
onLoadError: function(){ //加载失败时执行
console.info("加载数据失败");
}
})
});
$(function() {
$("#parentTable").bootstrapTable({ // 对应table标签的id
url: ext.contextPath + '/teacher/teacherfile/getparentFileList.do', // 获取表格数据的url
cache: false, // 设置为 false 禁用 AJAX 数据缓存, 默认为true
striped: true, //表格显示条纹默认为false
pagination: true, // 在表格底部显示分页组件默认false
pageList: [5,10,15], // 设置页面可以显示的数据条数
pageSize: 5, // 页面数据条数
pageNumber: 1, // 首页页码
sidePagination: 'server', // 设置为服务器端分页
queryParams: function (params) { // 请求服务器数据时发送的参数可以在这里添加额外的查询参数返回false则终止请求
return {
rows: params.limit, // 每页要显示的数据条数
page: params.offset/params.limit+1, // 每页显示数据的开始页码
sort: params.sort, // 要排序的字段
order: params.order, // 排序规则
masterId: masterId,
tbName : tbName
}
},
sortName: 'id', // 要排序的字段
sortOrder: 'desc', // 排序规则
columns: [
{
field: 'filename', // 返回json数据中的name
title: '名称', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle' // 上下居中
}, {
field: 'filefolder', // 返回json数据中的name
title: '归属文件夹', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',// 上下居中
// formatter:function(value,row,index){
// return '<a onclick="fileDownload(\'' + row.id + '\')">'+value+'</a>'
// }
}, {
field: 'type', // 返回json数据中的name
title: '类型', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',// 上下居中
}, {
field: 'size', // 返回json数据中的name
title: '大小', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',// 上下居中
formatter: function (value, row, index) {
// console.log(typeof value);
// console.log(value);
// if(value<1073741825){
// console.log('right');
// return 1000000;
// }
if(value<1024){
return value.toFixed(2)+"B";
}else if(1024<=value&&value<1048576){
return (value/1024).toFixed(2)+"K";
}else if(1048576<=value&&value<1073741824){
return (value/1048576).toFixed(2)+"M";
}
}
}, {
// field: '大小', // 返回json数据中的name
// title: '上传者', // 表格表头显示文字
// align: 'center', // 左右居中
// valign: 'middle',// 上下居中
// }, {
// field: 'insdt', // 返回json数据中的name
// title: '上传时间', // 表格表头显示文字
// align: 'center', // 左右居中
// valign: 'middle', // 上下居中
// }, {
field: 'memo', // 返回json数据中的name
title: '摘要', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle', // 上下居中
}, {
title: "操作",
align: 'center',
valign: 'middle',
width: 200, // 定义列的宽度单位为像素px
formatter: function (value, row, index) {
var buts= '';
buts+='<button class="btn btn-default btn-sm" title="下载" onclick="fileDownload(\'' + row.id + '\')"><i class="fa fa-download"></i><span class="hidden-md hidden-lg">下载</span></button>';
buts+='<button class="btn btn-default btn-sm" title="浏览" onclick="viewFun(\'' + row.urlpath + '\',\'' + row.masterid + '\')"><i class="fa fa-eye"></i><span class="hidden-md hidden-lg">浏览</span></button>';
buts='<div class="btn-group" >'+buts+'</div>';
return buts;
}
}
],
onLoadSuccess: function(){ //加载成功时执行
//$(".bs-checkbox").css({'text-align':'center','vertical-align':'middle'})
adjustBootstrapTableView("fileTable");
},
onLoadError: function(){ //加载失败时执行
console.info("加载数据失败");
}
})
});
</script>
<div class="box box-solid" >
<div class="box-header with-border">
<h3 class="box-title">课件资料</h3>
<div class="box-tools pull-right">
</div>
</div>
<!-- /.box-header -->
<div class="box-body ">
<div >
<div class="btn-group" style="width: 220px;padding-bottom:10px;">
<c:if test="${lastnode=='yes'}">
<!-- <button type="button" class="btn btn-default" onclick="fileinput();"><i class="fa fa-plus"></i>上传文件</button> -->
</c:if>
<!-- <button type="button" class="btn btn-default" onclick="delDocFun();"><i class="fa fa-trash"></i> 删除</button> -->
</div>
<c:if test="${lastnode=='yes'}">
<table id="fileTable"></table>
</c:if>
<c:if test="${lastnode=='no'}">
<table id="parentTable"></table>
</c:if>
</div>
</div>
</div>