From 0334c1e1e8a2e1b7517cfac890609ad2320f2ff8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com>
Date: Thu, 23 Dec 2021 21:22:38 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=96=87=E4=BB=B6=E5=AD=98?=
=?UTF-8?q?=E5=82=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controllers/CommonController.cs | 18 ++-
ZR.Model/System/SysFile.cs | 8 ++
ZR.Vue/src/components/FileUpload/index.vue | 11 --
ZR.Vue/src/components/UploadImage/index.vue | 11 --
ZR.Vue/src/views/tool/file/index.vue | 108 ++++++++++++------
5 files changed, 93 insertions(+), 63 deletions(-)
diff --git a/ZR.Admin.WebApi/Controllers/CommonController.cs b/ZR.Admin.WebApi/Controllers/CommonController.cs
index e7514de..b3b7b52 100644
--- a/ZR.Admin.WebApi/Controllers/CommonController.cs
+++ b/ZR.Admin.WebApi/Controllers/CommonController.cs
@@ -45,6 +45,10 @@ namespace ZR.Admin.WebApi.Controllers
return SUCCESS(true);
}
+ ///
+ /// hello
+ ///
+ ///
[Route("/")]
[HttpGet]
public IActionResult Index()
@@ -125,7 +129,9 @@ namespace ZR.Admin.WebApi.Controllers
FileSize = fileSize + "kb",
StoreType = 1,
FileUrl = finalFilePath,
- Create_time = DateTime.Now
+ RealName = formFile.FileName,
+ Create_time = DateTime.Now,
+ FileType = formFile.ContentType
};
long fileId = SysFileService.InsertFile(file);
return ToResponse(ResultCode.SUCCESS, new
@@ -149,8 +155,8 @@ namespace ZR.Admin.WebApi.Controllers
{
if (formFile == null) throw new CustomException(ResultCode.PARAM_ERROR, "上传文件不能为空");
string fileExt = Path.GetExtension(formFile.FileName);
- string[] AllowedFileExtensions = new string[] { ".jpg", ".gif", ".png", ".jpeg", ".webp", ".svga", ".xls" };
- int MaxContentLength = 1024 * 1024 * 5;
+ string[] AllowedFileExtensions = new string[] { ".jpg", ".gif", ".png", ".jpeg", ".webp", ".svga", ".xls", ".doc", ".zip", ".json", ".txt" };
+ int MaxContentLength = 1024 * 1024 * 15;
double fileSize = formFile.Length / 1024;
if (!AllowedFileExtensions.Contains(fileExt))
{
@@ -161,6 +167,7 @@ namespace ZR.Admin.WebApi.Controllers
{
return ToResponse(ResultCode.CUSTOM_ERROR, "上传文件过大,不能超过 " + (MaxContentLength / 1024).ToString() + " MB");
}
+
(bool, string, string) result = SysFileService.SaveFile(fileDir, formFile);
long fileId = SysFileService.InsertFile(new SysFile()
{
@@ -170,7 +177,10 @@ namespace ZR.Admin.WebApi.Controllers
FileName = result.Item3,
FileSize = fileSize + "kb",
StoreType = 2,
- StorePath = fileDir
+ StorePath = fileDir,
+ RealName = formFile.FileName,
+ Create_time = DateTime.Now,
+ FileType = formFile.ContentType
});
return ToResponse(ResultCode.SUCCESS, new
{
diff --git a/ZR.Model/System/SysFile.cs b/ZR.Model/System/SysFile.cs
index 0bfc99f..56f3e5c 100644
--- a/ZR.Model/System/SysFile.cs
+++ b/ZR.Model/System/SysFile.cs
@@ -16,6 +16,14 @@ namespace ZR.Model.System
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public long Id { get; set; }
///
+ /// 文件真实名
+ ///
+ public string RealName { get; set; }
+ ///
+ /// 文件类型
+ ///
+ public string FileType { get; set; }
+ ///
/// 描述 : 文件名
/// 空值 : true
///
diff --git a/ZR.Vue/src/components/FileUpload/index.vue b/ZR.Vue/src/components/FileUpload/index.vue
index 63fab4e..f314765 100644
--- a/ZR.Vue/src/components/FileUpload/index.vue
+++ b/ZR.Vue/src/components/FileUpload/index.vue
@@ -12,7 +12,6 @@
格式为 {{ fileType.join("/") }}
的文件
-
@@ -71,8 +70,6 @@ export default {
},
data() {
return {
- showProgress: false,
- uploadPercent: 0,
baseUrl: process.env.VUE_APP_BASE_API,
uploadFileUrl: process.env.VUE_APP_BASE_API + this.uploadUrl, // 上传的图片服务器地址
headers: {
@@ -140,7 +137,6 @@ export default {
return false;
}
}
- this.showProgress = true;
return true;
},
// 文件个数超出
@@ -151,14 +147,9 @@ export default {
handleUploadError(err) {
this.msgError("上传失败, 请重试");
this.fileList = [];
- this.showProgress = false;
- this.uploadPercent = 0;
},
// 上传成功回调
handleUploadSuccess(res, file) {
- this.showProgress = false;
- this.uploadPercent = 0;
-
if (res.code != 200) {
this.fileList = [];
this.msgError(`上传失败,原因:${res.msg}!`);
@@ -170,8 +161,6 @@ export default {
},
// 上传进度
uploadProcess(event, file, fileList) {
- this.showProgress = true;
- this.videoUploadPercent = file.percentage.toFixed(0);
console.log("上传进度" + file.percentage);
},
// 删除文件
diff --git a/ZR.Vue/src/components/UploadImage/index.vue b/ZR.Vue/src/components/UploadImage/index.vue
index a865575..4619f58 100644
--- a/ZR.Vue/src/components/UploadImage/index.vue
+++ b/ZR.Vue/src/components/UploadImage/index.vue
@@ -5,7 +5,6 @@
:file-list="fileList" :on-preview="handlePictureCardPreview" :on-progress="uploadProcess" :class="{hide: this.fileList.length >= this.limit}"
:headers="headers">
-
请上传
@@ -60,8 +59,6 @@ export default {
dialogImageUrl: "",
dialogVisible: false,
hideUpload: false,
- showProgress: false,
- uploadPercent: 0,
uploadImgUrl: process.env.VUE_APP_BASE_API + this.uploadUrl, // 上传的图片服务器地址
headers: {
Authorization: "Bearer " + getToken(),
@@ -115,9 +112,6 @@ export default {
//上传成功回调
handleUploadSuccess(res) {
console.log(res);
- this.showProgress = false;
- this.uploadPercent = 0;
-
if (res.code != 200) {
this.msgError(`上传失败,原因:${res.msg}!`);
return;
@@ -155,7 +149,6 @@ export default {
return false;
}
}
- this.showProgress = true;
},
// 文件个数超出
handleExceed() {
@@ -180,13 +173,9 @@ export default {
type: "error",
message: "上传失败",
});
- this.showProgress = false;
- this.uploadPercent = 0;
},
// 上传进度
uploadProcess(event, file, fileList) {
- this.showProgress = true;
- this.videoUploadPercent = file.percentage.toFixed(0);
console.log("上传进度" + file.percentage);
},
},
diff --git a/ZR.Vue/src/views/tool/file/index.vue b/ZR.Vue/src/views/tool/file/index.vue
index 154dfed..a8339da 100644
--- a/ZR.Vue/src/views/tool/file/index.vue
+++ b/ZR.Vue/src/views/tool/file/index.vue
@@ -36,17 +36,33 @@
-
-
+
+
+
+
+ {{ scope.row.fileName }}
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
-
+ 查看
删除
@@ -54,15 +70,15 @@
-
-
+
+
-
+
@@ -70,7 +86,7 @@
-
+
@@ -83,7 +99,7 @@
-
@@ -96,16 +112,50 @@
+
+
+
+
+
+ {{formView.id}}
+
+
+ {{formView.fileExt}}
+
+
+ {{formView.realName}}
+
+
+ {{formView.fileName}}
+
+
+ {{formView.storePath}}
+
+
+ {{formView.fileSize}}
+
+
+ {{formView.create_by}}
+
+
+ {{formView.fileUrl}}
+
+
+ {{formView.accessUrl}}
+
+
+
+
\ No newline at end of file