Merge branch 'master' into net6.0

This commit is contained in:
不做码农 2022-03-27 14:18:34 +08:00
commit 030db5b971
20 changed files with 216 additions and 149 deletions

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
namespace Infrastructure.Enums
{
@ -30,5 +25,10 @@ namespace Infrastructure.Enums
[Description("腾讯云")]
TENCENT = 3,
/// <summary>
/// 七牛
/// </summary>
[Description("七牛云")]
QINIU = 4
}
}

View File

@ -15,6 +15,7 @@
* 后端采用Net5/Net6、Sqlsugar、MySQL。
* 权限认证使用Jwt支持多终端认证系统。
* 支持加载动态权限菜单,多方式轻松权限控制
* 提供了技术栈(Ant Design Vue)版[Ant Design Vue](https://gitee.com/billzh/mc-dull.git)
* 七牛云通用云产品优惠券:[点我进入](https://s.qiniu.com/FzEfay)。
* 腾讯云秒杀场:[点我进入](https://curl.qcloud.com/4yEoRquq)。
* 腾讯云优惠券:[点我领取](https://curl.qcloud.com/5J4nag8D)。

View File

@ -1,5 +1,6 @@
using Infrastructure;
using Infrastructure.Attribute;
using Infrastructure.Enums;
using Infrastructure.Extensions;
using Infrastructure.Model;
using Microsoft.AspNetCore.Hosting;
@ -91,26 +92,60 @@ namespace ZR.Admin.WebApi.Controllers
/// <param name="formFile"></param>
/// <param name="fileDir">存储目录</param>
/// <param name="fileName">自定义文件名</param>
/// <param name="uploadType">上传类型 1、发送邮件</param>
/// <param name="storeType">上传类型1、保存到本地 2、保存到阿里云</param>
/// <returns></returns>
[HttpPost()]
[Verify]
[ActionPermissionFilter(Permission = "common")]
public async Task<IActionResult> UploadFile([FromForm(Name = "file")] IFormFile formFile, string fileName = "", string fileDir = "uploads", int uploadType = 0)
public async Task<IActionResult> UploadFile([FromForm(Name = "file")] IFormFile formFile, string fileName = "", string fileDir = "uploads", StoreType storeType = StoreType.LOCAL)
{
if (formFile == null) throw new CustomException(ResultCode.PARAM_ERROR, "上传文件不能为空");
SysFile file = new();
string fileExt = Path.GetExtension(formFile.FileName);//文件后缀
double fileSize = Math.Round(formFile.Length / 1024.0, 2);//文件大小KB
string[] NotAllowedFileExtensions = new string[] { ".bat", ".exe", ".jar", ".js" };
int MaxContentLength = 15;
if (NotAllowedFileExtensions.Contains(fileExt))
{
return ToResponse(ResultCode.CUSTOM_ERROR, "上传失败,未经允许上传类型");
}
switch (storeType)
{
case StoreType.LOCAL:
file = await SysFileService.SaveFileToLocal(WebHostEnvironment.WebRootPath, fileName, fileDir, HttpContext.GetName(), formFile);
SysFile file = await SysFileService.SaveFileToLocal(WebHostEnvironment.WebRootPath, fileName, fileDir, HttpContext.GetName(), formFile);
break;
case StoreType.ALIYUN:
if ((fileSize / 1024) > MaxContentLength)
{
return ToResponse(ResultCode.CUSTOM_ERROR, "上传文件过大,不能超过 " + MaxContentLength + " MB");
}
file = new(formFile.FileName, fileName, fileExt, fileSize + "kb", fileDir, HttpContext.GetName())
{
StoreType = (int)StoreType.ALIYUN,
FileType = formFile.ContentType
};
file = await SysFileService.SaveFileToAliyun(file, formFile);
if (file.Id <= 0) { return ToResponse(ApiResult.Error("阿里云连接失败")); }
break;
case StoreType.TENCENT:
break;
case StoreType.QINIU:
break;
default:
break;
}
return SUCCESS(new
{
url = uploadType == 1 ? file.FileUrl : file.AccessUrl,
url = file.AccessUrl,
fileName,
fileId = file.Id.ToString()
});
}
/// <summary>
/// 存储文件到阿里云
/// 存储文件到阿里云(已弃用)
/// </summary>
/// <param name="formFile"></param>
/// <param name="fileName">自定义文件名</param>
@ -134,7 +169,7 @@ namespace ZR.Admin.WebApi.Controllers
{
return ToResponse(ResultCode.CUSTOM_ERROR, "上传文件过大,不能超过 " + MaxContentLength + " MB");
}
SysFile file = new(formFile.FileName, fileName, fileExt, fileSize + "kb", fileDir, "", HttpContext.GetName())
SysFile file = new(formFile.FileName, fileName, fileExt, fileSize + "kb", fileDir, HttpContext.GetName())
{
StoreType = (int)Infrastructure.Enums.StoreType.ALIYUN,
FileType = formFile.ContentType

View File

@ -86,8 +86,8 @@ namespace ZR.Admin.WebApi.Controllers.System
List<string> permissions = permissionService.GetMenuPermission(user);
LoginUser loginUser = new(user, roles, permissions);
CacheHelper.SetCache(GlobalConstant.UserPermKEY + user.UserId, loginUser);
return SUCCESS(JwtUtil.GenerateJwtToken(HttpContext.AddClaims(loginUser), jwtSettings.JwtSettings));
CacheHelper.SetCache(GlobalConstant.UserPermKEY + user.UserId, permissions);
return SUCCESS(JwtUtil.GenerateJwtToken(JwtUtil.AddClaims(loginUser), jwtSettings.JwtSettings));
}
/// <summary>
@ -103,11 +103,11 @@ namespace ZR.Admin.WebApi.Controllers.System
// //注销登录的用户相当于ASP.NET中的FormsAuthentication.SignOut
// await HttpContext.SignOutAsync();
//}).Wait();
var id = HttpContext.GetUId();
var userid = HttpContext.GetUId();
var name = HttpContext.GetName();
CacheHelper.Remove(GlobalConstant.UserPermKEY + id);
return SUCCESS(new { name , id});
CacheHelper.Remove(GlobalConstant.UserPermKEY + userid);
return SUCCESS(new { name , id = userid });
}
/// <summary>

View File

@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using ZR.Admin.WebApi.Extensions;
using ZR.Admin.WebApi.Filters;
using ZR.Common;
using ZR.Model;
@ -94,7 +95,7 @@ namespace ZR.Admin.WebApi.Controllers.System
return ToResponse(ApiResult.Error($"新增用户 '{user.UserName}'失败,登录账号已存在"));
}
user.Create_by = User.Identity.Name;
user.Create_by = HttpContext.GetName();
user.Password = NETCore.Encrypt.EncryptProvider.Md5(user.Password);
return ToResponse(UserService.InsertUser(user));
@ -112,7 +113,7 @@ namespace ZR.Admin.WebApi.Controllers.System
{
if (user == null || user.UserId <= 0) { return ToResponse(ApiResult.Error(101, "请求参数错误")); }
user.Update_by = User.Identity.Name;
user.Update_by = HttpContext.GetName();
int upResult = UserService.UpdateUser(user);
return ToResponse(upResult);

View File

@ -130,27 +130,6 @@ namespace ZR.Admin.WebApi.Extensions
return context != null ? context.Request.Path.Value : "";
}
/// <summary>
///组装Claims
/// </summary>
/// <param name="context"></param>
/// <param name="user"></param>
/// <returns></returns>
public static List<Claim> AddClaims(this HttpContext context, LoginUser user)
{
//1、创建Cookie保存用户信息使用claim
var claims = new List<Claim>()
{
new Claim(ClaimTypes.PrimarySid, user.UserId.ToString()),
new Claim(ClaimTypes.Name, user.UserName),
new Claim(ClaimTypes.UserData, JsonConvert.SerializeObject(user))
};
//写入Cookie
//WhiteCookie(context, claims);
return claims;
}
private static void WhiteCookie(HttpContext context, List<Claim> claims)
{
//2.创建声明主题 指定认证方式 这里使用cookie

View File

@ -33,11 +33,12 @@ namespace ZR.Admin.WebApi.Extensions
/// <returns></returns>
public static IApplicationBuilder UseAddTaskSchedulers(this IApplicationBuilder app)
{
var _tasksQzService = (ISysTasksQzService)App.GetRequiredService(typeof(ISysTasksQzService));
//var _tasksQzService = (ISysTasksQzService)App.GetRequiredService(typeof(ISysTasksQzService));
ITaskSchedulerServer _schedulerServer = App.GetRequiredService<ITaskSchedulerServer>();
var tasks = _tasksQzService.GetList(m => m.IsStart);
//var tasks = _tasksQzService.GetList(m => m.IsStart);
var tasks = SqlSugar.IOC.DbScoped.SugarScope.Queryable<Model.System.SysTasksQz>().Where(m => m.IsStart).ToList();
//程序启动后注册所有定时任务
foreach (var task in tasks)

View File

@ -6,6 +6,7 @@ using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using System.Text;
using ZR.Admin.WebApi.Extensions;
using ZR.Common;
using ZR.Model.System;
namespace ZR.Admin.WebApi.Framework
@ -124,9 +125,15 @@ namespace ZR.Admin.WebApi.Framework
{
try
{
var userData = jwtToken.FirstOrDefault(x => x.Type == ClaimTypes.UserData);
LoginUser loginUser = JsonConvert.DeserializeObject<LoginUser>(value: userData?.Value);
var userData = jwtToken.FirstOrDefault(x => x.Type == ClaimTypes.UserData).Value;
var loginUser = JsonConvert.DeserializeObject<LoginUser>(userData);
var permissions = (List<string>)CacheHelper.GetCache(GlobalConstant.UserPermKEY + loginUser?.UserId);
if (loginUser?.UserName == "admin")
{
permissions = new List<string>() { GlobalConstant.AdminPerm };
}
if (permissions == null) return null;
loginUser.Permissions = permissions;
return loginUser;
}
catch (Exception ex)
@ -135,5 +142,27 @@ namespace ZR.Admin.WebApi.Framework
return null;
}
}
/// <summary>
///组装Claims
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
public static List<Claim> AddClaims(LoginUser user)
{
if (user?.Permissions.Count > 50)
{
user.Permissions = new List<string>();
}
var claims = new List<Claim>()
{
new Claim(ClaimTypes.PrimarySid, user.UserId.ToString()),
new Claim(ClaimTypes.Name, user.UserName),
new Claim(ClaimTypes.UserData, JsonConvert.SerializeObject(user))
};
return claims;
}
}
}

View File

@ -89,7 +89,7 @@ namespace ZR.CodeGenerator
//图片
sb.AppendLine(" <el-col :lg=\"24\">");
sb.AppendLine($" <el-form-item label=\"{labelName}\" prop=\"{columnName}\">");
sb.AppendLine($@" <UploadImage v-model=""form.{columnName}"" column=""{columnName}"" @input=""handleUploadSuccess"" />");
sb.AppendLine($@" <UploadImage v-model=""form.{columnName}"" :data=""{{ 'storeType' : 1}}"" column=""{columnName}"" @input=""handleUploadSuccess"" />");
sb.AppendLine(" </el-form-item>");
sb.AppendLine(" </el-col>");
}

View File

@ -43,5 +43,25 @@ namespace ZR.Common
return System.Net.HttpStatusCode.BadRequest;
}
/// <summary>
/// 删除资源
/// </summary>
/// <param name="dirPath"></param>
/// <param name="bucketName"></param>
/// <returns></returns>
public static System.Net.HttpStatusCode DeleteFile(string dirPath, string bucketName = "")
{
if (string.IsNullOrEmpty(bucketName)) { bucketName = bucketName1; }
try
{
OssClient client = new(endpoint, accessKeyId, accessKeySecret);
DeleteObjectResult putObjectResult = client.DeleteObject(bucketName, dirPath);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return System.Net.HttpStatusCode.BadRequest;
}
}
}

View File

@ -24,7 +24,7 @@ namespace ZR.Model.System
/// <summary>
/// 权限集合
/// </summary>
public List<string> Permissions { get; set; }
public List<string> Permissions { get; set; } = new List<string>();
public LoginUser()
{
}

View File

@ -72,14 +72,13 @@ namespace ZR.Model.System
public string AccessUrl { get; set; }
public SysFile() { }
public SysFile(string originFileName, string fileName, string ext, string fileSize, string storePath, string accessUrl,string create_by)
public SysFile(string originFileName, string fileName, string ext, string fileSize, string storePath, string create_by)
{
StorePath = storePath;
RealName = originFileName;
FileName = fileName;
FileExt = ext;
FileSize = fileSize;
AccessUrl = accessUrl;
Create_by = create_by;
Create_time = DateTime.Now;
}

View File

@ -1,4 +1,5 @@
using ZR.Model.System;
using System.Threading.Tasks;
using ZR.Model.System;
using ZR.Repository;
namespace ZR.Service.System.IService
@ -10,6 +11,6 @@ namespace ZR.Service.System.IService
/// </summary>
/// <returns></returns>
//public int AddTaskLog(string jobId);
SysTasksLog AddTaskLog(string jobId, SysTasksLog tasksLog);
Task<SysTasksLog> AddTaskLog(string jobId, SysTasksLog tasksLog);
}
}

View File

@ -51,14 +51,15 @@ namespace ZR.Service.System
using (var stream = new FileStream(finalFilePath, FileMode.Create))
{
await formFile.CopyToAsync(stream);
await formFile.CopyToAsync(stream);//await 不能少
}
string accessPath = string.Concat(OptionsSetting.Upload.UploadUrl, "/", filePath.Replace("\\", "/"), "/", fileName);
SysFile file = new(formFile.FileName, fileName, fileExt, fileSize + "kb", filePath, accessPath, userName)
SysFile file = new(formFile.FileName, fileName, fileExt, fileSize + "kb", filePath, userName)
{
StoreType = (int)Infrastructure.Enums.StoreType.LOCAL,
FileType = formFile.ContentType,
FileUrl = finalFilePath
FileUrl = finalFilePath,
AccessUrl = accessPath
};
file.Id = await InsertFile(file);
return file;

View File

@ -1,6 +1,7 @@
using Infrastructure.Attribute;
using System;
using System.Linq.Expressions;
using System.Threading.Tasks;
using ZR.Model;
using ZR.Model.System;
using ZR.Repository;
@ -12,7 +13,7 @@ namespace ZR.Service.System
/// 任务日志
/// </summary>
[AppService(ServiceLifetime = LifeTime.Transient, ServiceType = typeof(ISysTasksLogService))]
public class SysTasksLogService : BaseRepository<SysTasksLog>, ISysTasksLogService
public class SysTasksLogService : BaseService<SysTasksLog>, ISysTasksLogService
{
private ISysTasksQzService _tasksQzService;
public SysTasksLogService(ISysTasksQzService tasksQzService)
@ -20,10 +21,10 @@ namespace ZR.Service.System
_tasksQzService = tasksQzService;
}
public SysTasksLog AddTaskLog(string jobId, SysTasksLog logModel)
public async Task<SysTasksLog> AddTaskLog(string jobId, SysTasksLog logModel)
{
//获取任务信息
var model = _tasksQzService.GetId(jobId);
var model = await _tasksQzService.GetSingleAsync(f => f.ID == jobId);
if (model != null)
{
@ -33,7 +34,7 @@ namespace ZR.Service.System
logModel.CreateTime = DateTime.Now;
}
Add(logModel);
await InsertAsync(logModel);
return logModel;
}

View File

@ -56,7 +56,7 @@ namespace ZR.Tasks
JobMessage = logMsg
};
RecordTaskLog(context, logModel);
await RecordTaskLog(context, logModel);
return logModel;
}
@ -65,7 +65,7 @@ namespace ZR.Tasks
/// </summary>
/// <param name="context"></param>
/// <param name="logModel"></param>
protected void RecordTaskLog(IJobExecutionContext context, SysTasksLog logModel)
protected async Task RecordTaskLog(IJobExecutionContext context, SysTasksLog logModel)
{
var tasksLogService = (ISysTasksLogService)App.GetRequiredService(typeof(ISysTasksLogService));
var taskQzService = (ISysTasksQzService)App.GetRequiredService(typeof(ISysTasksQzService));
@ -74,15 +74,15 @@ namespace ZR.Tasks
IJobDetail job = context.JobDetail;
logModel.InvokeTarget = job.JobType.FullName;
logModel = tasksLogService.AddTaskLog(job.Key.Name, logModel);
logModel = await tasksLogService.AddTaskLog(job.Key.Name, logModel);
//成功后执行次数+1
if (logModel.Status == "0")
{
taskQzService.Update(f => f.ID == job.Key.Name, f => new SysTasksQz()
await taskQzService.UpdateAsync(f => new SysTasksQz()
{
RunTimes = f.RunTimes + 1,
LastRunTime = DateTime.Now
});
}, f => f.ID == job.Key.Name);
}
logger.Info($"执行任务【{job.Key.Name}|{logModel.JobName}】结果={logModel.JobMessage}");
}

View File

@ -123,6 +123,10 @@ namespace ZR.Tasks
{
return ApiResult.Error(500, $"该计划任务已经在执行:【{tasksQz.Name}】,请勿重复添加!");
}
if (tasksQz?.EndTime <= DateTime.Now)
{
return ApiResult.Error(500, $"结束时间小于当前时间计划将不会被执行");
}
#region
tasksQz.BeginTime = tasksQz.BeginTime == null ? DateTime.Now : tasksQz.BeginTime;
@ -166,10 +170,12 @@ namespace ZR.Tasks
// 5、将触发器和任务器绑定到调度器中
await _scheduler.Result.ScheduleJob(job, trigger);
//任务没有启动、暂停任务
if (!tasksQz.IsStart)
{
_scheduler.Result.PauseJob(jobKey).Wait();
}
//if (!tasksQz.IsStart)
//{
// _scheduler.Result.PauseJob(jobKey).Wait();
//}
//按新的trigger重新设置job执行
await _scheduler.Result.ResumeTrigger(trigger.Key);
return ApiResult.Success($"启动计划任务:【{tasksQz.Name}】成功!");
}
catch (Exception ex)

View File

@ -52,7 +52,7 @@ export default {
// , ['png', 'jpg', 'jpeg']
fileType: {
type: Array,
default: () => ['doc', 'xls', 'ppt', 'txt', 'pdf', 'svga', 'json']
default: () => ['doc', 'xls', 'ppt', 'txt', 'pdf', 'json']
},
//
isShowTip: {

View File

@ -1,7 +1,7 @@
<template>
<div class="component-upload-image">
<el-upload list-type="picture-card" :action="uploadImgUrl" :on-success="handleUploadSuccess" :before-upload="handleBeforeUpload"
:on-exceed="handleExceed" :on-remove="handleRemove" :on-error="handleUploadError" name="file" :show-file-list="true" :limit="limit"
:on-exceed="handleExceed" :on-remove="handleRemove" :on-error="handleUploadError" name="file" :show-file-list="true" :data="data" :limit="limit"
:file-list="fileList" :on-preview="handlePictureCardPreview" :on-progress="uploadProcess" :class="{hide: this.fileList.length >= this.limit}"
:headers="headers">
<i slot="default" class="el-icon-plus"></i>
@ -20,7 +20,7 @@
</template>
<script>
import { getToken } from "@/utils/auth";
import { getToken } from '@/utils/auth'
export default {
props: {
@ -28,44 +28,48 @@ export default {
//
limit: {
type: Number,
default: 1,
default: 1
},
column: [String],
//
uploadUrl: {
type: String,
default: process.env.VUE_APP_UPLOAD_URL ?? "/Common/UploadFile",
default: process.env.VUE_APP_UPLOAD_URL ?? '/Common/UploadFile'
},
// , ['png', 'jpg', 'jpeg']
fileType: {
type: Array,
default: () => ["png", "jpg", "jpeg", "webp"],
default: () => ['png', 'jpg', 'jpeg', 'webp']
},
// (MB)
fileSize: {
type: Number,
default: 5,
default: 5
},
//
showInput: false,
//
isShowTip: {
type: Boolean,
default: true,
default: true
},
//
data: {
type: Object
}
},
data() {
return {
dialogImageUrl: "",
dialogImageUrl: '',
dialogVisible: false,
hideUpload: false,
uploadImgUrl: process.env.VUE_APP_BASE_API + this.uploadUrl, //
headers: {
Authorization: "Bearer " + getToken(),
Authorization: 'Bearer ' + getToken()
},
imageUrl: "",
fileList: [],
};
imageUrl: '',
fileList: []
}
},
watch: {
// v-model
@ -75,111 +79,111 @@ export default {
handler: function(val) {
if (val) {
//
const list = Array.isArray(val) ? val : this.value.split(",");
const list = Array.isArray(val) ? val : this.value.split(',')
//
this.fileList = list.map((item) => {
if (typeof item === "string") {
if (typeof item === 'string') {
// if (item.indexOf(this.baseUrl) === -1) {
// item = { name: this.baseUrl + item, url: this.baseUrl + item };
// } else {
item = { name: item, url: item };
item = { name: item, url: item }
// }
}
return item;
});
return item
})
} else {
this.fileList = [];
return [];
this.fileList = []
return []
}
}
}
},
},
},
computed: {
//
showTip() {
return this.isShowTip && (this.fileType || this.fileSize);
},
return this.isShowTip && (this.fileType || this.fileSize)
}
},
methods: {
//
handleRemove(file, fileList) {
const findex = this.fileList.map((f) => f.name).indexOf(file.name);
const findex = this.fileList.map((f) => f.name).indexOf(file.name)
if (findex > -1) {
this.fileList.splice(findex, 1);
this.$emit("input", this.column, this.listToString(this.fileList));
this.fileList.splice(findex, 1)
this.$emit('input', this.column, this.listToString(this.fileList))
}
},
//
handleUploadSuccess(res) {
console.log(res);
console.log(res)
if (res.code != 200) {
this.msgError(`上传失败,原因:${res.msg}!`);
return;
this.msgError(`上传失败,原因:${res.msg}!`)
return
}
this.fileList.push({ name: res.data.fileName, url: res.data.url });
this.$emit(`input`, this.column, this.listToString(this.fileList));
this.fileList.push({ name: res.data.fileName, url: res.data.url })
this.$emit(`input`, this.column, this.listToString(this.fileList))
},
// loading
handleBeforeUpload(file) {
let isImg = false;
let isImg = false
if (this.fileType.length) {
let fileExtension = "";
if (file.name.lastIndexOf(".") > -1) {
fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1);
let fileExtension = ''
if (file.name.lastIndexOf('.') > -1) {
fileExtension = file.name.slice(file.name.lastIndexOf('.') + 1)
}
isImg = this.fileType.some((type) => {
if (file.type.indexOf(type) > -1) return true;
if (fileExtension && fileExtension.indexOf(type) > -1) return true;
return false;
});
if (file.type.indexOf(type) > -1) return true
if (fileExtension && fileExtension.indexOf(type) > -1) return true
return false
})
} else {
isImg = file.type.indexOf("image") > -1;
isImg = file.type.indexOf('image') > -1
}
if (!isImg) {
this.msgError(
`文件格式不正确, 请上传${this.fileType.join("/")}图片格式文件!`
);
return false;
`文件格式不正确, 请上传${this.fileType.join('/')}图片格式文件!`
)
return false
}
if (this.fileSize) {
const isLt = file.size / 1024 / 1024 < this.fileSize;
const isLt = file.size / 1024 / 1024 < this.fileSize
if (!isLt) {
this.msgError(`上传头像图片大小不能超过 ${this.fileSize} MB!`);
return false;
this.msgError(`上传头像图片大小不能超过 ${this.fileSize} MB!`)
return false
}
}
},
//
handleExceed() {
this.$message.error(`上传文件数量不能超过 ${this.limit} 个!`);
this.$message.error(`上传文件数量不能超过 ${this.limit} 个!`)
},
//
handlePictureCardPreview(file) {
this.dialogImageUrl = file.url;
this.dialogVisible = true;
this.dialogImageUrl = file.url
this.dialogVisible = true
},
//
listToString(list, separator) {
let strs = "";
separator = separator || ",";
for (let i in list) {
strs += list[i].url.replace(this.baseUrl, "") + separator;
let strs = ''
separator = separator || ','
for (const i in list) {
strs += list[i].url.replace(this.baseUrl, '') + separator
}
return strs != "" ? strs.substr(0, strs.length - 1) : "";
return strs != '' ? strs.substr(0, strs.length - 1) : ''
},
handleUploadError() {
this.$message({
type: "error",
message: "上传失败",
});
type: 'error',
message: '上传失败'
})
},
//
uploadProcess(event, file, fileList) {
console.log("上传进度" + file.percentage);
},
},
};
console.log('上传进度' + file.percentage)
}
}
}
</script>
<style scoped lang="scss">

View File

@ -100,8 +100,8 @@
</el-col>
<el-col :lg="24">
<el-form-item prop="accessUrl">
<UploadFile ref="upload" v-model="form.accessUrl" :uploadUrl="uploadUrl" :fileType="[]" :limit="5" :fileSize="15" :drag="true"
:data="{ 'fileDir' : form.storePath, 'fileName': form.fileName}" :autoUpload="false" column="accessUrl"
<UploadFile ref="upload" v-model="form.accessUrl" :fileType="[]" :limit="5" :fileSize="15" :drag="true"
:data="{ 'fileDir' : form.storePath, 'fileName': form.fileName, 'storeType': form.storeType}" :autoUpload="false" column="accessUrl"
@input="handleUploadSuccess" />
</el-form-item>
</el-col>
@ -208,8 +208,8 @@ export default {
{ dictLabel: '本地存储', dictValue: 1 },
{ dictLabel: '阿里云存储', dictValue: 2 }
],
//
uploadUrl: '/common/uploadFile',
// 1 2
storeType: 0,
fileType: [],
//
dataList: [],
@ -240,17 +240,6 @@ export default {
//
this.getList()
},
watch: {
'form.storeType': {
handler: function(val) {
if (val == 1) {
this.uploadUrl = '/common/uploadFile'
} else if (val == 2) {
this.uploadUrl = '/common/UploadFileAliyun'
}
}
}
},
methods: {
//
getList() {