2025-11-27 16:55:35 +08:00
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html lang="en">
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
|
<title>文件共享</title>
|
|
|
|
|
</head>
|
|
|
|
|
<link rel="stylesheet" href="../../../layui2.3.6/css/layui.css">
|
|
|
|
|
<style>
|
|
|
|
|
html, body{
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
height: 100%;
|
|
|
|
|
}
|
|
|
|
|
.demo-form{
|
|
|
|
|
width: 98%;
|
|
|
|
|
height: 50px;
|
|
|
|
|
margin: 15px auto;
|
|
|
|
|
margin-bottom: 0;
|
|
|
|
|
display: flex;
|
|
|
|
|
}
|
|
|
|
|
.layui-input-block{
|
|
|
|
|
margin-left: 0;
|
|
|
|
|
}
|
|
|
|
|
.bread-crumb{
|
|
|
|
|
width: 98%;
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
line-height: 20px;
|
|
|
|
|
}
|
|
|
|
|
.bread-crumb>a{
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
.file-area{
|
|
|
|
|
margin-top: 10px;
|
|
|
|
|
flex: 1;
|
|
|
|
|
/*background-color: #1E9FFF;*/
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
padding: 25px;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
}
|
|
|
|
|
.layui-upload-file{
|
|
|
|
|
display: block !important;
|
|
|
|
|
opacity: 100%;
|
|
|
|
|
padding-top: 6px;
|
|
|
|
|
margin-left: 10px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
<div id="files">
|
|
|
|
|
<form class="layui-form demo-form" action="" >
|
|
|
|
|
<div class="layui-form-item">
|
|
|
|
|
<div class="layui-input-block" style="width: 300px">
|
|
|
|
|
<input type="text" name="fileName" placeholder="请输入文件名" autocomplete="off" class="layui-input">
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="layui-form-item">
|
|
|
|
|
<div class="layui-inline" style="margin-left: 15px">
|
|
|
|
|
<div class="layui-input-inline">
|
|
|
|
|
<input type="text" name="startTime" class="layui-input" autocomplete="off" id="ID-laydate-format-1" placeholder="请输入起始日期">
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="layui-inline">
|
|
|
|
|
<div class="layui-input-inline">
|
|
|
|
|
<input type="text" name="endTime" class="layui-input" autocomplete="off" id="ID-laydate-format-2" placeholder="请输入结束日期">
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<button type="button" lay-submit lay-filter="sub-form" class="layui-btn">查询</button>
|
|
|
|
|
<button type="button" class="layui-btn" onclick="addFile()">新建文件夹</button>
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
class="layui-btn"
|
|
|
|
|
id="ID-upload-demo-choose"
|
|
|
|
|
style="padding: 0; cursor: default"
|
|
|
|
|
onclick="initUpload()"
|
|
|
|
|
>
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
class="layui-btn"
|
|
|
|
|
id="ID-upload-demo-action"
|
|
|
|
|
>
|
|
|
|
|
上传文件
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
class="layui-btn"
|
|
|
|
|
style="margin-left: 10px"
|
|
|
|
|
onclick="downloadMulti()"
|
|
|
|
|
>
|
|
|
|
|
下载
|
|
|
|
|
</button>
|
|
|
|
|
<button type="button" class="layui-btn layui-btn-danger" onclick="delFile()">删除</button>
|
|
|
|
|
</form>
|
|
|
|
|
<div class="bread-crumb">
|
|
|
|
|
<a onclick="backTit()" class="tit" file-tag-id="0">文件 > </a>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
<div class="file-area">
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div id="files_name" class="files_name"></div>
|
|
|
|
|
|
|
|
|
|
</body>
|
|
|
|
|
|
|
|
|
|
<script src="../../../layui2.3.6/layui.js"></script>
|
|
|
|
|
<script src="../../../js/jquery-3.6.0.js"></script>
|
2025-12-09 18:44:29 +08:00
|
|
|
<script type="text/javascript" src="../../../../public/public.js"></script>
|
2025-11-27 16:55:35 +08:00
|
|
|
<script src="../../../js/publicJs.js"></script>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
|
|
let form = layui.form;
|
|
|
|
|
let initId = 0;
|
|
|
|
|
let dropMenu = layui.dropdown;
|
|
|
|
|
let count = 0;
|
|
|
|
|
let upload = layui.upload;
|
|
|
|
|
|
|
|
|
|
var usernameLogin = localStorage.getItem("usernameLogin");
|
|
|
|
|
|
|
|
|
|
var filesForm = document.getElementById("files");
|
|
|
|
|
|
|
|
|
|
console.log("usernameLogin=="+usernameLogin);
|
|
|
|
|
if(usernameLogin == "bnsAdmin"){
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
filesForm.style.display = "none";
|
|
|
|
|
$('.files_name').append('<div style="text-align: center;font-size: 18px;color: #0c0c0c;width: 100%;">没有权限,请联系管理员</div>')
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 上传文件
|
|
|
|
|
let initUpload = () => {
|
|
|
|
|
$('#ID-upload-demo-choose').css({
|
|
|
|
|
'opacity': '0'
|
|
|
|
|
})
|
|
|
|
|
upload.render({
|
|
|
|
|
elem: '#ID-upload-demo-choose',
|
2025-12-09 18:44:29 +08:00
|
|
|
url: smz_ht_url + '/file',
|
2025-11-27 16:55:35 +08:00
|
|
|
accept: 'file',
|
|
|
|
|
exts: 'doc|docx|pdf|xls|xlsx|png|jpg|jpeg',
|
|
|
|
|
data: {
|
|
|
|
|
token: localStorage.getItem('token'),
|
|
|
|
|
fileType: '1',
|
|
|
|
|
id: $('.bread-crumb').children().last().attr('file-tag-id')
|
|
|
|
|
},
|
|
|
|
|
auto: false,
|
|
|
|
|
bindAction: '#ID-upload-demo-action',
|
|
|
|
|
choose: (obj) => {
|
|
|
|
|
/*$('.preview-name').remove()
|
|
|
|
|
obj.preview((index, file, result) => {
|
|
|
|
|
console.log(file)
|
|
|
|
|
$('#ID-upload-demo-choose').after(`<div class="preview-name" style="padding-top: 10px; margin: 0px 20px 0 10px">${file.name}</div>`)
|
|
|
|
|
})*/
|
|
|
|
|
},
|
|
|
|
|
done: (res) => {
|
|
|
|
|
console.log(res)
|
|
|
|
|
if (res.res === 0) {
|
|
|
|
|
layer.msg(res.resMsg, {
|
|
|
|
|
icon: 2,
|
|
|
|
|
time: 1500
|
|
|
|
|
}, () => {
|
|
|
|
|
fetchFiles({
|
|
|
|
|
token: localStorage.getItem('token'),
|
|
|
|
|
id: $('.bread-crumb').children().last().attr('file-tag-id')
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
} else if (res.res === 1) {
|
|
|
|
|
layer.msg(res.resMsg, {
|
|
|
|
|
icon: 1,
|
|
|
|
|
time: 1500
|
|
|
|
|
}, () => {
|
|
|
|
|
fetchFiles({
|
|
|
|
|
token: localStorage.getItem('token'),
|
|
|
|
|
id: $('.bread-crumb').children().last().attr('file-tag-id')
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
$('.preview-name').remove()
|
|
|
|
|
},
|
|
|
|
|
error: (err) => {
|
|
|
|
|
console.log(err)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
layui.use(() => {
|
|
|
|
|
|
|
|
|
|
let laydate = layui.laydate
|
|
|
|
|
let layer = layui.layer
|
|
|
|
|
let form = layui.form
|
|
|
|
|
|
|
|
|
|
// 日期选择器渲染
|
|
|
|
|
laydate.render({
|
|
|
|
|
elem: '#ID-laydate-format-1',
|
|
|
|
|
format: 'yyyy-MM-dd',
|
|
|
|
|
max: 0
|
|
|
|
|
});
|
|
|
|
|
laydate.render({
|
|
|
|
|
elem: '#ID-laydate-format-2',
|
|
|
|
|
format: 'yyyy-MM-dd',
|
|
|
|
|
max: 0
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 提交表单
|
|
|
|
|
form.on('submit(sub-form)', (res) => {
|
|
|
|
|
console.log(res.field)
|
|
|
|
|
let startIpt = $('#ID-laydate-format-1').val()
|
|
|
|
|
let endIpt = $('#ID-laydate-format-2').val()
|
|
|
|
|
console.log(startIpt, endIpt)
|
|
|
|
|
res.field.token = localStorage.getItem('token')
|
|
|
|
|
if (
|
|
|
|
|
startIpt === '' && endIpt !== ''
|
|
|
|
|
||
|
|
|
|
|
startIpt !== '' && endIpt === ''
|
|
|
|
|
||
|
|
|
|
|
startIpt === null && endIpt !== null
|
|
|
|
|
||
|
|
|
|
|
startIpt !== null && endIpt === null
|
|
|
|
|
) {
|
|
|
|
|
layer.msg('请填写完整日期!', {
|
|
|
|
|
icon: 2,
|
|
|
|
|
time: 2000
|
|
|
|
|
})
|
|
|
|
|
} else if (Date.parse(startIpt) > Date.parse(endIpt)) {
|
|
|
|
|
layer.msg('请选择正确的日期范围!', { icon: 5, time: 1500 }, () => {
|
|
|
|
|
$('#ID-laydate-format-1').val('')
|
|
|
|
|
$('#ID-laydate-format-2').val('')
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
fetchFiles(res.field)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// 新建文件
|
|
|
|
|
let addFile = () => {
|
|
|
|
|
layer.open({
|
|
|
|
|
type: 1,
|
|
|
|
|
area: ['400px', '400px'],
|
|
|
|
|
content: '<div style="width: 100%; height: 100%; box-sizing: border-box; padding: 20px 100px; display: flex; flex-direction: column">' +
|
|
|
|
|
'<div style="width: 100%; height: 60%"><img style="width: 100%; height: 100%" src="../../../img/fileIcon/file.png" alt=""/></div>' +
|
|
|
|
|
'<input style="margin-top: 20px" class="layui-input file-name-ipt" placeholder="请输入文件名"/>' +
|
|
|
|
|
'<button style="margin-top: 20px" class="layui-btn" onclick="createFile()">确定新建</button>' +
|
|
|
|
|
'</div>'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 多选下载
|
|
|
|
|
let downloadMulti = () => {
|
|
|
|
|
let fileLength = $('.file-area').children().length
|
|
|
|
|
let filePathList = []
|
|
|
|
|
for (let i = 0; i < fileLength; i++) {
|
|
|
|
|
if ($(`.lef-ipt${i}`)[0].checked) {
|
|
|
|
|
filePathList.push($(`.lef-ipt${i}`).attr('single-path'))
|
|
|
|
|
$(`.lef-ipt${i}`)[0].checked = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
console.log(filePathList)
|
|
|
|
|
if (filePathList.length == 0) {
|
|
|
|
|
layer.msg('未选中下载文件!', { icon: 5, time: 1500 })
|
|
|
|
|
} else {
|
2025-12-09 18:44:29 +08:00
|
|
|
window.location.href = smz_ht_url + "/file/download?filePaths=" + filePathList + "&token=" + localStorage.getItem('token')
|
2025-11-27 16:55:35 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 删除文件
|
|
|
|
|
let delFile = () => {
|
|
|
|
|
let multiList = []
|
|
|
|
|
let fileLength = $('.file-area').children().length
|
|
|
|
|
for (let i = 0; i < fileLength; i++) {
|
|
|
|
|
if ($(`.lef-ipt${i}`)[0].checked) {
|
|
|
|
|
multiList.push($(`.lef-ipt${i}`).attr('single-id'))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
console.log(multiList)
|
|
|
|
|
if (multiList.length == 0) {
|
|
|
|
|
layer.msg('未选择删除文件!', { icon: 5, time: 1500 })
|
|
|
|
|
} else {
|
|
|
|
|
let delArea = layer.confirm('确认删除这些文件吗?', {
|
|
|
|
|
btn: ['确认', '取消']
|
|
|
|
|
}, () => {
|
|
|
|
|
console.log('删除了')
|
|
|
|
|
delMultiFile(multiList)
|
|
|
|
|
layer.close(delArea)
|
|
|
|
|
}, () => {
|
|
|
|
|
console.log('取消了')
|
|
|
|
|
layer.close(delArea)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let backTit = () => {
|
|
|
|
|
$('.tit').nextAll().remove()
|
|
|
|
|
initUpload()
|
|
|
|
|
fetchFiles({
|
|
|
|
|
token: localStorage.getItem('token'),
|
|
|
|
|
id: initId
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 页面初始化发送请求渲染所有文件
|
|
|
|
|
let fetchFiles = (fileData = {}) => $.ajax({
|
2025-12-09 18:44:29 +08:00
|
|
|
url: smz_ht_url + "/file",
|
2025-11-27 16:55:35 +08:00
|
|
|
method: 'get',
|
|
|
|
|
data: fileData,
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
success: (res) => {
|
|
|
|
|
console.log(res)
|
|
|
|
|
if (res === '' || res === null || res.length === 0) {
|
|
|
|
|
$('.file-area').html('');
|
|
|
|
|
|
|
|
|
|
$('.file-area').append('<div style="text-align: center;font-size: 18px;color: #0c0c0c;width: 100%;">没有文件或文件夹</div>')
|
|
|
|
|
|
|
|
|
|
// layer.msg('没有文件或文件夹', {
|
|
|
|
|
// icon: 2,
|
|
|
|
|
// time: 1500
|
|
|
|
|
// })
|
|
|
|
|
} else {
|
|
|
|
|
$('.file-area').html('')
|
|
|
|
|
count++
|
|
|
|
|
for (let i = 0; i < res.length; i++) {
|
|
|
|
|
$('.file-area').append('<div class="single-file"></div>')
|
|
|
|
|
$('.single-file').attr('class', `single-file${i}`)
|
|
|
|
|
$(`.single-file${i}`).css({
|
|
|
|
|
'width': '12%',
|
|
|
|
|
'height': '240px',
|
|
|
|
|
'marginRight': '30px',
|
|
|
|
|
'display': 'flex',
|
|
|
|
|
'flexDirection': 'column'
|
|
|
|
|
}).attr('file-id', `${res[i].id}`).attr('file-name', `${res[i].fileName}`).attr('file-path', `${res[i].filePath}`).attr('file-type', `${res[i].fileType}`).append('<div class="file-operate"> <input type="checkbox" class="lef-ipt" name="multiSelect"> <button class="layui-btn-sm drop-menu" style="background-color: #7b7977; height: 100%; line-height: 100%; cursor: pointer; color: #fff; border: none">...</button> </div>').append('<div class="file-icon"></div>').append('<div class="file-name"></div>').append('<div class="file-time"></div>')
|
|
|
|
|
if (!res[i].fileName.includes('.')) {
|
|
|
|
|
$(`.single-file${i}`).dblclick(() => {
|
|
|
|
|
let selectedId = $(`.single-file${i}`).attr('file-id')
|
|
|
|
|
let selectedName = $(`.single-file${i}`).attr('file-name')
|
|
|
|
|
$('.bread-crumb').append(`<a class="add-tag">${selectedName} > </a>`)
|
|
|
|
|
$('.add-tag').attr('class', `add-tag${count}`)
|
|
|
|
|
$(`.add-tag${count}`).attr('file-tag-id', selectedId).click((e) => {
|
|
|
|
|
console.log('移除面包屑')
|
|
|
|
|
$(e.target).nextAll().remove()
|
|
|
|
|
initUpload()
|
|
|
|
|
fetchFiles({
|
|
|
|
|
token: localStorage.getItem('token'),
|
|
|
|
|
id: selectedId
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
initUpload()
|
|
|
|
|
fetchFiles({
|
|
|
|
|
token: localStorage.getItem('token'),
|
|
|
|
|
id: selectedId
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
$('.lef-ipt').attr('class', `lef-ipt${i}`).attr('single-id', `${res[i].id}`).attr('single-path', `${res[i].filePath}`).attr('single-type', `${res[i].fileType}`).change(() => {
|
|
|
|
|
console.log('点击单选框', $(`.lef-ipt${i}`)[0].checked)
|
|
|
|
|
})
|
|
|
|
|
$('.drop-menu').attr('class', `drop-menu${i} layui-btn-sm`)
|
|
|
|
|
$('.file-operate').attr('class', `file-operate${i}`)
|
|
|
|
|
$(`.file-operate${i}`).css({
|
|
|
|
|
'width': '80%',
|
|
|
|
|
'height': '10%',
|
|
|
|
|
'margin': '0 auto',
|
|
|
|
|
'display': 'flex',
|
|
|
|
|
'justifyContent': 'space-between'
|
|
|
|
|
})
|
|
|
|
|
$('.file-icon').attr('class', `file-icon${i}`)
|
|
|
|
|
$(`.file-icon${i}`).css({
|
|
|
|
|
'width': '100%',
|
|
|
|
|
'height': '70%',
|
|
|
|
|
'display': 'flex',
|
|
|
|
|
'justifyContent': 'center',
|
|
|
|
|
'alignItems': 'center',
|
|
|
|
|
'boxSizing': 'border-box',
|
|
|
|
|
'padding': '10px'
|
|
|
|
|
})
|
|
|
|
|
if (res[i].fileName.substring(res[i].fileName.lastIndexOf('.')+1) === 'xlsx' || res[i].fileName.substring(res[i].fileName.lastIndexOf('.')+1) === 'xls') {
|
|
|
|
|
$(`.file-icon${i}`).append('<img src="../../../img/fileIcon/xlsx.png" alt="" class="file-img"/>')
|
|
|
|
|
} else if (res[i].fileName.substring(res[i].fileName.lastIndexOf('.')+1) === 'doc' || res[i].fileName.substring(res[i].fileName.lastIndexOf('.')+1) === 'docx') {
|
|
|
|
|
$(`.file-icon${i}`).append('<img src="../../../img/fileIcon/WORD.png" alt="" class="file-img"/>')
|
|
|
|
|
} else if (res[i].fileName.substring(res[i].fileName.lastIndexOf('.')+1) === 'pdf') {
|
|
|
|
|
$(`.file-icon${i}`).append('<img src="../../../img/fileIcon/pdf.png" alt="" class="file-img"/>')
|
|
|
|
|
} else if (res[i].fileName.substring(res[i].fileName.lastIndexOf('.')+1) === 'png' || res[i].fileName.substring(res[i].fileName.lastIndexOf('.')+1) === 'jpg' || res[i].fileName.substring(res[i].fileName.lastIndexOf('.')+1) === 'jpeg') {
|
|
|
|
|
$(`.file-icon${i}`).append('<img src="../../../img/fileIcon/picture.png" alt="" class="file-img"/>')
|
|
|
|
|
} else {
|
|
|
|
|
$(`.file-icon${i}`).append('<img src="../../../img/fileIcon/file.png" alt="" class="file-img"/>')
|
|
|
|
|
}
|
|
|
|
|
$('.file-img').css({
|
|
|
|
|
'width': '100%',
|
|
|
|
|
'height': '100%'
|
|
|
|
|
})
|
|
|
|
|
$('.file-name').attr('class', `file-name${i}`)
|
|
|
|
|
$(`.file-name${i}`).css({
|
|
|
|
|
'width': '100%',
|
|
|
|
|
'height': '10%',
|
|
|
|
|
'display': 'flex',
|
|
|
|
|
'justifyContent': 'center',
|
|
|
|
|
'alignItems': 'center',
|
|
|
|
|
}).html(`<h4 style="font-size: 18px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap;">${res[i].fileName}</h4>`)
|
|
|
|
|
$('.file-time').attr('class', `file-time${i}`)
|
|
|
|
|
$(`.file-time${i}`).css({
|
|
|
|
|
'flex': '1',
|
|
|
|
|
'display': 'flex',
|
|
|
|
|
'justifyContent': 'center'
|
|
|
|
|
}).html(`<h4 style="font-size: 12px">${res[i].updateTime}</h4>`)
|
|
|
|
|
dropMenu.render({
|
|
|
|
|
elem: `.drop-menu${i}`,
|
|
|
|
|
data: [
|
|
|
|
|
{
|
|
|
|
|
title: '下载',
|
|
|
|
|
id: 1,
|
|
|
|
|
fileId: $(`.single-file${i}`).attr('file-id'),
|
|
|
|
|
filePath: $(`.single-file${i}`).attr('file-path')
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '删除',
|
|
|
|
|
id: 2,
|
|
|
|
|
fileId: $(`.single-file${i}`).attr('file-id'),
|
|
|
|
|
filePath: $(`.single-file${i}`).attr('file-path')
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
click: (data) => {
|
|
|
|
|
console.log(data)
|
|
|
|
|
// 下载
|
|
|
|
|
if (data.id === 1) {
|
|
|
|
|
console.log('下载')
|
|
|
|
|
downloadFile(data.filePath)
|
|
|
|
|
}
|
|
|
|
|
// 删除
|
|
|
|
|
if (data.id === 2) {
|
|
|
|
|
console.log('fileId:', data.fileId)
|
|
|
|
|
deleteFile(data.fileId)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
error: (err) => {
|
|
|
|
|
console.log(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// 创建文件
|
|
|
|
|
let createFile = () => {
|
|
|
|
|
let fileNameIpt = $('.file-name-ipt').val()
|
|
|
|
|
console.log(fileNameIpt)
|
|
|
|
|
if (fileNameIpt == '' || fileNameIpt == null) {
|
|
|
|
|
layer.msg('文件夹名不能为空!', { icon: 2, time: 1500 })
|
|
|
|
|
} else if (fileNameIpt.includes('.')) {
|
|
|
|
|
layer.msg('请输入正确格式的文件夹名称!', { icon: 2, time: 1500 })
|
|
|
|
|
} else {
|
|
|
|
|
let lastCrumbId = $('.bread-crumb').children().last().attr('file-tag-id')
|
|
|
|
|
let createData = {
|
|
|
|
|
id: lastCrumbId,
|
|
|
|
|
fileName: fileNameIpt,
|
|
|
|
|
fileType: 0,
|
|
|
|
|
token: localStorage.getItem('token')
|
|
|
|
|
}
|
|
|
|
|
$.ajax({
|
2025-12-09 18:44:29 +08:00
|
|
|
url: smz_ht_url + '/file',
|
2025-11-27 16:55:35 +08:00
|
|
|
method: 'post',
|
|
|
|
|
data: createData,
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
success: (res) => {
|
|
|
|
|
layer.msg(res.resMsg, {
|
|
|
|
|
icon: 1,
|
|
|
|
|
time: 1500
|
|
|
|
|
}, () => {
|
|
|
|
|
layer.closeAll()
|
|
|
|
|
fetchFiles({
|
|
|
|
|
token: localStorage.getItem('token'),
|
|
|
|
|
id: $('.bread-crumb').children().last().attr('file-tag-id')
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 下载文件
|
|
|
|
|
let downloadFile = (path) => {
|
|
|
|
|
/*let filePath = []
|
|
|
|
|
filePath.push(path)*/
|
2025-12-09 18:44:29 +08:00
|
|
|
window.location.href = smz_ht_url + "/file/download?filePaths=" + path + "&token=" + localStorage.getItem('token');
|
2025-11-27 16:55:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 删除文件
|
|
|
|
|
let deleteFile = (ids) => {
|
|
|
|
|
let idList = []
|
|
|
|
|
idList.push(ids)
|
|
|
|
|
console.log(idList)
|
|
|
|
|
let confirmBtn = layer.confirm('确认删除文件吗?',{
|
|
|
|
|
btn: ['确认', '取消']
|
|
|
|
|
}, () => {
|
|
|
|
|
$.ajax({
|
2025-12-09 18:44:29 +08:00
|
|
|
url: smz_ht_url + '/file' + '?' + `idList=${idList}`,
|
2025-11-27 16:55:35 +08:00
|
|
|
method: 'delete',
|
|
|
|
|
data: {
|
|
|
|
|
token: localStorage.getItem('token')
|
|
|
|
|
},
|
|
|
|
|
success: (res) => {
|
|
|
|
|
console.log(res)
|
|
|
|
|
if (res.res === 0) {
|
|
|
|
|
layer.msg(res.resMsg, {
|
|
|
|
|
icon: 1,
|
|
|
|
|
time: 1500
|
|
|
|
|
}, () => {
|
|
|
|
|
fetchFiles({
|
|
|
|
|
token: localStorage.getItem('token'),
|
|
|
|
|
id: $('.bread-crumb').children().last().attr('file-tag-id')
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}, () => {
|
|
|
|
|
layer.close(confirmBtn)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let delMultiFile = (totalIds) => {
|
|
|
|
|
$.ajax({
|
2025-12-09 18:44:29 +08:00
|
|
|
url: smz_ht_url + '/file' + '?' + `idList=${totalIds}`,
|
2025-11-27 16:55:35 +08:00
|
|
|
method: 'delete',
|
|
|
|
|
data: {
|
|
|
|
|
token: localStorage.getItem('token')
|
|
|
|
|
},
|
|
|
|
|
success: (res) => {
|
|
|
|
|
console.log(res)
|
|
|
|
|
if (res.res === 0) {
|
|
|
|
|
layer.msg(res.resMsg, {
|
|
|
|
|
icon: 1,
|
|
|
|
|
time: 1500
|
|
|
|
|
}, () => {
|
|
|
|
|
fetchFiles({
|
|
|
|
|
token: localStorage.getItem('token'),
|
|
|
|
|
id: $('.bread-crumb').children().last().attr('file-tag-id')
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 页面初始化
|
|
|
|
|
fetchFiles({
|
|
|
|
|
token: localStorage.getItem('token'),
|
|
|
|
|
id: initId
|
|
|
|
|
})
|
|
|
|
|
initUpload()
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
</html>
|