From b6b6953c8a27907f5f61ed829cb1a2746a259619 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B0=8F=E5=BA=86?= <1576331433@qq.com>
Date: Mon, 11 Jan 2021 17:33:19 +0800
Subject: [PATCH 1/3] =?UTF-8?q?=E3=80=90file=E3=80=91=E6=96=87=E4=BB=B6?=
=?UTF-8?q?=E7=AE=A1=E7=90=86=E5=88=97=E8=A1=A8=E6=98=BE=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../file/controller/FileViewController.java | 24 ++++
.../modular/system/fileInfo/file_info.js | 135 ++++++++++++++++++
.../modular/system/fileInfo/file_info.html | 63 ++++++++
3 files changed, 222 insertions(+)
create mode 100644 src/main/java/cn/stylefeng/guns/modular/file/controller/FileViewController.java
create mode 100644 src/main/webapp/assets/modular/system/fileInfo/file_info.js
create mode 100644 src/main/webapp/pages/modular/system/fileInfo/file_info.html
diff --git a/src/main/java/cn/stylefeng/guns/modular/file/controller/FileViewController.java b/src/main/java/cn/stylefeng/guns/modular/file/controller/FileViewController.java
new file mode 100644
index 00000000..ae47c352
--- /dev/null
+++ b/src/main/java/cn/stylefeng/guns/modular/file/controller/FileViewController.java
@@ -0,0 +1,24 @@
+package cn.stylefeng.guns.modular.file.controller;
+
+import cn.stylefeng.roses.kernel.resource.api.annotation.ApiResource;
+import cn.stylefeng.roses.kernel.resource.api.annotation.GetResource;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Controller;
+
+/**
+ * 文件管理界面
+ * @author : lgq
+ * @date : 2021/1/9
+ */
+@Controller
+@Slf4j
+@ApiResource(name = "文件管理界面")
+public class FileViewController {
+
+ @GetResource(name = "菜单管理首页", path = "/view/file")
+ public String fileIndex() {
+ return "/modular/system/fileInfo/file_info.html";
+ }
+
+
+}
diff --git a/src/main/webapp/assets/modular/system/fileInfo/file_info.js b/src/main/webapp/assets/modular/system/fileInfo/file_info.js
new file mode 100644
index 00000000..7f1d60a1
--- /dev/null
+++ b/src/main/webapp/assets/modular/system/fileInfo/file_info.js
@@ -0,0 +1,135 @@
+layui.use(['table', 'form', 'func', 'HttpRequest', 'util'], function () {
+ var $ = layui.$;
+ var table = layui.table;
+ var form = layui.form;
+ var func = layui.func;
+ var HttpRequest = layui.HttpRequest;
+ var util = layui.util;
+
+ // 职位表管理
+ var FileInfo = {
+ tableId: "fileTable"
+ };
+
+ // 初始化表格的列
+ FileInfo.initColumn = function () {
+ return [[
+ {type: 'checkbox'},
+ {field: 'fileId', hide: true, title: '主键id'},
+ {field: 'fileLocation', sort: true, title: '位置'},
+ {field: 'fileOriginName', sort: true, title: '文件名称'},
+ {field: 'fileSuffix', sort: true, title: '文件后缀'},
+ {field: 'fileSizeInfo', sort: true, title: '文件大小'},
+ {
+ field: 'createTime', sort: true, title: '创建时间', templet: function (d) {
+ return util.toDateString(d.createTime);
+ }
+ },
+ {field: 'createUserName', sort: true, title: '创建人'},
+ {align: 'center', toolbar: '#tableBar', title: '操作'}
+ ]];
+ };
+
+ // 点击查询按钮
+ FileInfo.search = function () {
+ var queryData = {};
+ queryData['fileInfoName'] = $("#fileInfoName").val();
+ //queryData['positionCode'] = $("#positionCode").val();
+ table.reload(FileInfo.tableId, {
+ where: queryData,
+ page: {curr: 1}
+ });
+ };
+
+ // 弹出添加对话框
+ FileInfo.openAddDlg = function () {
+ func.open({
+ height: 800,
+ title: '添加职位',
+ content: Feng.ctxPath + '/fileInfo/addView',
+ tableId: FileInfo.tableId
+ });
+ };
+
+ // 点击编辑
+ FileInfo.openEditDlg = function (data) {
+ func.open({
+ height: 800,
+ title: '修改职位',
+ content: Feng.ctxPath + '/position/editView?positionId=' + data.positionId,
+ tableId: FileInfo.tableId
+ });
+ };
+
+ // 导出excel按钮
+ FileInfo.exportExcel = function () {
+ var checkRows = table.checkStatus(FileInfo.tableId);
+ if (checkRows.data.length === 0) {
+ Feng.error("请选择要导出的数据");
+ } else {
+ table.exportFile(tableResult.config.id, checkRows.data, 'xls');
+ }
+ };
+
+ // 点击删除
+ FileInfo.delete = function (data) {
+ var operation = function () {
+ var httpRequest = new HttpRequest(Feng.ctxPath + "/hrPosition/delete", 'post', function (data) {
+ Feng.success("删除成功!");
+ table.reload(FileInfo.tableId);
+ }, function (data) {
+ Feng.error("删除失败!" + data.message + "!");
+ });
+ httpRequest.set(data);
+ httpRequest.start(true);
+ };
+ Feng.confirm("是否删除?", operation);
+ };
+
+
+ // 渲染表格
+ var tableResult = table.render({
+ elem: '#' + FileInfo.tableId,
+ url: Feng.ctxPath + '/sysFileInfo/fileInfoListPage',
+ page: true,
+ request: {pageName: 'pageNo', limitName: 'pageSize'}, //自定义分页参数
+ height: "full-158",
+ cellMinWidth: 100,
+ cols: FileInfo.initColumn(),
+ parseData: Feng.parseData
+ });
+
+ // 搜索按钮点击事件
+ $('#btnSearch').click(function () {
+ FileInfo.search();
+ });
+
+ // 添加按钮点击事件
+ $('#btnAdd').click(function () {
+ FileInfo.openAddDlg();
+ });
+
+ // 导出excel
+ $('#btnExp').click(function () {
+ FileInfo.exportExcel();
+ });
+
+ // 工具条点击事件
+ table.on('tool(' + FileInfo.tableId + ')', function (obj) {
+ var data = obj.data;
+ var event = obj.event;
+ if (event === 'edit') {
+ FileInfo.openEditDlg(data);
+ } else if (event === 'delete') {
+ FileInfo.delete(data);
+ }
+ dropdown.hideAll();
+ });
+
+ // 修改状态
+ form.on('switch(status)', function (obj) {
+ var fileInfoId = obj.elem.value;
+ var checked = obj.elem.checked ? 1 : 2;
+ FileInfo.updateStatus(fileInfoId, checked);
+ });
+});
diff --git a/src/main/webapp/pages/modular/system/fileInfo/file_info.html b/src/main/webapp/pages/modular/system/fileInfo/file_info.html
new file mode 100644
index 00000000..cca93648
--- /dev/null
+++ b/src/main/webapp/pages/modular/system/fileInfo/file_info.html
@@ -0,0 +1,63 @@
+@layout("/layout/_container.html",{js:["/assets/modular/system/fileInfo/file_info.js"]}){
+
+
+ 系统文件管理
+
+
+
+
+
+
+@}
From e21e67faa4044ed605e211eb189452c730cc961f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B0=8F=E5=BA=86?= <1576331433@qq.com>
Date: Mon, 11 Jan 2021 20:20:12 +0800
Subject: [PATCH 2/3] =?UTF-8?q?=E3=80=90file=E3=80=91=E6=96=87=E4=BB=B6?=
=?UTF-8?q?=E7=AE=A1=E7=90=86=E4=B8=8A=E4=BC=A0=E3=80=81=E4=B8=8B=E8=BD=BD?=
=?UTF-8?q?=E3=80=81=E6=90=9C=E7=B4=A2=E3=80=81=E5=88=A0=E9=99=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../modular/system/fileInfo/file_info.js | 76 ++++++++++---------
.../modular/system/fileInfo/file_info.html | 76 +++++++++++--------
2 files changed, 85 insertions(+), 67 deletions(-)
diff --git a/src/main/webapp/assets/modular/system/fileInfo/file_info.js b/src/main/webapp/assets/modular/system/fileInfo/file_info.js
index 7f1d60a1..641daaab 100644
--- a/src/main/webapp/assets/modular/system/fileInfo/file_info.js
+++ b/src/main/webapp/assets/modular/system/fileInfo/file_info.js
@@ -1,10 +1,11 @@
-layui.use(['table', 'form', 'func', 'HttpRequest', 'util'], function () {
+layui.use(['table', 'form', 'func', 'HttpRequest', 'util', 'upload'], function () {
var $ = layui.$;
var table = layui.table;
var form = layui.form;
var func = layui.func;
var HttpRequest = layui.HttpRequest;
var util = layui.util;
+ var upload = layui.upload;
// 职位表管理
var FileInfo = {
@@ -16,8 +17,9 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'util'], function () {
return [[
{type: 'checkbox'},
{field: 'fileId', hide: true, title: '主键id'},
- {field: 'fileLocation', sort: true, title: '位置'},
+ {field: 'fileLocation', sort: true, title: '存储位置'},
{field: 'fileOriginName', sort: true, title: '文件名称'},
+ {field: 'secretFlag', sort: true, title: '是否机密'},
{field: 'fileSuffix', sort: true, title: '文件后缀'},
{field: 'fileSizeInfo', sort: true, title: '文件大小'},
{
@@ -26,14 +28,33 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'util'], function () {
}
},
{field: 'createUserName', sort: true, title: '创建人'},
- {align: 'center', toolbar: '#tableBar', title: '操作'}
+ {align: 'center', toolbar: '#tableBar', title: '操作', width: 230}
]];
};
+
+
+ //上传
+ var uploadInst = upload.render({
+ elem: '#btnUpload' //绑定元素
+ ,url: Feng.ctxPath + '/sysFileInfo/upload?secretFlag=N' //上传接口
+ ,done: function(res){
+ //上传完毕回调
+ Feng.success("上传成功!");
+
+ FileInfo.search();
+ }
+ ,error: function(err){
+ //请求异常回调
+ Feng.error("上传失败!"+ err.message);
+ }
+ });
+
+
// 点击查询按钮
FileInfo.search = function () {
var queryData = {};
- queryData['fileInfoName'] = $("#fileInfoName").val();
+ queryData['fileOriginName'] = $("#fileOriginName").val();
//queryData['positionCode'] = $("#positionCode").val();
table.reload(FileInfo.tableId, {
where: queryData,
@@ -41,15 +62,7 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'util'], function () {
});
};
- // 弹出添加对话框
- FileInfo.openAddDlg = function () {
- func.open({
- height: 800,
- title: '添加职位',
- content: Feng.ctxPath + '/fileInfo/addView',
- tableId: FileInfo.tableId
- });
- };
+
// 点击编辑
FileInfo.openEditDlg = function (data) {
@@ -61,20 +74,11 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'util'], function () {
});
};
- // 导出excel按钮
- FileInfo.exportExcel = function () {
- var checkRows = table.checkStatus(FileInfo.tableId);
- if (checkRows.data.length === 0) {
- Feng.error("请选择要导出的数据");
- } else {
- table.exportFile(tableResult.config.id, checkRows.data, 'xls');
- }
- };
// 点击删除
- FileInfo.delete = function (data) {
+ FileInfo.onDeleteFile = function (data) {
var operation = function () {
- var httpRequest = new HttpRequest(Feng.ctxPath + "/hrPosition/delete", 'post', function (data) {
+ var httpRequest = new HttpRequest(Feng.ctxPath + "/sysFileInfo/deleteReally", 'post', function (data) {
Feng.success("删除成功!");
table.reload(FileInfo.tableId);
}, function (data) {
@@ -87,6 +91,16 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'util'], function () {
};
+ // 下载
+ FileInfo.onFileDownload = function (data) {
+ if (data.secretFlag === 'Y'){
+ window.location.href = Feng.ctxPath + '/sysFileInfo/privateDownload?fileId='+ data.fileId;
+ }else {
+ window.location.href = Feng.ctxPath + '/sysFileInfo/publicDownload?fileId='+ data.fileId;
+ }
+ }
+
+
// 渲染表格
var tableResult = table.render({
elem: '#' + FileInfo.tableId,
@@ -104,15 +118,6 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'util'], function () {
FileInfo.search();
});
- // 添加按钮点击事件
- $('#btnAdd').click(function () {
- FileInfo.openAddDlg();
- });
-
- // 导出excel
- $('#btnExp').click(function () {
- FileInfo.exportExcel();
- });
// 工具条点击事件
table.on('tool(' + FileInfo.tableId + ')', function (obj) {
@@ -121,9 +126,10 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'util'], function () {
if (event === 'edit') {
FileInfo.openEditDlg(data);
} else if (event === 'delete') {
- FileInfo.delete(data);
+ FileInfo.onDeleteFile(data);
+ }else if (event === 'download'){
+ FileInfo.onFileDownload(data);
}
- dropdown.hideAll();
});
// 修改状态
diff --git a/src/main/webapp/pages/modular/system/fileInfo/file_info.html b/src/main/webapp/pages/modular/system/fileInfo/file_info.html
index cca93648..2632c309 100644
--- a/src/main/webapp/pages/modular/system/fileInfo/file_info.html
+++ b/src/main/webapp/pages/modular/system/fileInfo/file_info.html
@@ -11,28 +11,47 @@
@@ -42,22 +61,15 @@
@}
From aa943e3657e2a134d27981b17b94f70626c5d92d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B0=8F=E5=BA=86?= <1576331433@qq.com>
Date: Tue, 12 Jan 2021 22:31:46 +0800
Subject: [PATCH 3/3] =?UTF-8?q?=E3=80=90file=E3=80=91=E6=96=87=E4=BB=B6?=
=?UTF-8?q?=E7=AE=A1=E7=90=86=20=E9=A2=84=E8=A7=88=EF=BC=88=E6=9C=AA?=
=?UTF-8?q?=E5=AE=8C=E6=88=90=EF=BC=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../modular/system/fileInfo/file_info.js | 40 +++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/src/main/webapp/assets/modular/system/fileInfo/file_info.js b/src/main/webapp/assets/modular/system/fileInfo/file_info.js
index 641daaab..664c359b 100644
--- a/src/main/webapp/assets/modular/system/fileInfo/file_info.js
+++ b/src/main/webapp/assets/modular/system/fileInfo/file_info.js
@@ -6,6 +6,8 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'util', 'upload'], function (
var HttpRequest = layui.HttpRequest;
var util = layui.util;
var upload = layui.upload;
+ var layer = layui.layer;
+
// 职位表管理
var FileInfo = {
@@ -100,6 +102,42 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'util', 'upload'], function (
}
}
+ // 预览
+ FileInfo.openPreview = function (data) {
+ var imgUrl = Feng.ctxPath + '/sysFileInfo/previewByObjectName?fileBucket=' + data.fileBucket + '&fileObjectName=' + data.fileObjectName;
+
+ // layer.open({
+ // type: 1,
+ // title: false,
+ // closeBtn: 0,
+ // skin: 'layui-layer-nobg', //没有背景色
+ // shadeClose: true,
+ // content: '' +
+ // '
' +
+ // '
'
+ // // content: Feng.ctxPath + '/sysFileInfo/previewByObjectName?fileBucket=' + data.fileBucket + '&fileObjectName=' + data.fileObjectName,
+ // });
+ //
+
+ var imgUrl = Feng.ctxPath + '/sysFileInfo/previewByObjectName?fileBucket=' + data.fileBucket + '&fileObjectName=' + data.fileObjectName;
+
+ layer.open({
+ type: 2,
+ title: false,
+ closeBtn: 0,
+ area: ['500px', '300px'],
+ shadeClose: true,
+ content: imgUrl
+ })
+
+
+
+
+ };
+
+
// 渲染表格
var tableResult = table.render({
@@ -129,6 +167,8 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'util', 'upload'], function (
FileInfo.onDeleteFile(data);
}else if (event === 'download'){
FileInfo.onFileDownload(data);
+ }else if(event === 'preview'){
+ FileInfo.openPreview(data);
}
});