优化文件上传、新增加是否自动上传

This commit is contained in:
不做码农 2022-03-22 17:26:53 +08:00
parent 04acf820f7
commit 21a0d27aa9
5 changed files with 24 additions and 36 deletions

View File

@ -16,16 +16,11 @@ namespace Infrastructure
public static string GetdirPath(string path = "") public static string GetdirPath(string path = "")
{ {
DateTime date = DateTime.Now; DateTime date = DateTime.Now;
int year = date.Year; string timeDir = Path.Combine(date.ToString("yyyyMMdd"));// date.ToString("yyyyMM/dd/HH/");
int month = date.Month;
int day = date.Day;
int hour = date.Hour;
string timeDir = $"{year}{month}{day}/";// date.ToString("yyyyMM/dd/HH/");
if (!string.IsNullOrEmpty(path)) if (!string.IsNullOrEmpty(path))
{ {
timeDir = $"{path}/{timeDir}/"; timeDir = Path.Combine(path, timeDir);
} }
return timeDir; return timeDir;
} }
@ -41,7 +36,7 @@ namespace Infrastructure
{ {
str = Guid.NewGuid().ToString(); str = Guid.NewGuid().ToString();
} }
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); MD5CryptoServiceProvider md5 = new();
return BitConverter.ToString(md5.ComputeHash(Encoding.Default.GetBytes(str)), 4, 8).Replace("-", ""); return BitConverter.ToString(md5.ComputeHash(Encoding.Default.GetBytes(str)), 4, 8).Replace("-", "");
} }
} }

View File

@ -9,6 +9,7 @@ using Microsoft.Extensions.Options;
using Newtonsoft.Json; using Newtonsoft.Json;
using Snowflake.Core; using Snowflake.Core;
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;

View File

@ -1,15 +0,0 @@
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Text;
namespace ZR.Model
{
public class JsonDateConverter: IsoDateTimeConverter
{
public JsonDateConverter()
{
DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
}
}
}

View File

@ -262,7 +262,7 @@ namespace ZR.Tasks
List<JobKey> jobKeys = _scheduler.Result.GetJobKeys(GroupMatcher<JobKey>.GroupEquals(tasksQz.JobGroup)).Result.ToList(); List<JobKey> jobKeys = _scheduler.Result.GetJobKeys(GroupMatcher<JobKey>.GroupEquals(tasksQz.JobGroup)).Result.ToList();
if (jobKeys == null || jobKeys.Count == 0) if (jobKeys == null || jobKeys.Count == 0)
{ {
return new ApiResult(110, $"未找到分组[{ tasksQz.JobGroup }]"); await AddTaskScheduleAsync(tasksQz);
} }
var triggers = await _scheduler.Result.GetTriggersOfJob(jobKey); var triggers = await _scheduler.Result.GetTriggersOfJob(jobKey);

View File

@ -1,11 +1,12 @@
<template> <template>
<div class="upload-file"> <div class="upload-file">
<el-upload :action="uploadFileUrl" :before-upload="handleBeforeUpload" :file-list="fileList" :limit="limit" :on-error="handleUploadError" <el-upload :action="uploadFileUrl" :before-upload="handleBeforeUpload" :file-list="fileList" :limit="limit" :on-error="handleUploadError"
:on-exceed="handleExceed" :on-success="handleUploadSuccess" :on-progress="uploadProcess" :show-file-list="true" :data="data" :headers="headers" :on-exceed="handleExceed" :on-success="handleUploadSuccess" :show-file-list="true" :data="data" :headers="headers" :drag="drag" ref="upload"
:drag="drag" ref="upload"> :auto-upload="autoUpload">
<i class="el-icon-upload" v-if="drag"></i> <!-- 拖拽上传文件 -->
<div class="el-upload__text" v-if="drag">将文件拖到此处<em>点击上传</em></div> <i class="el-icon-upload" v-if="drag"></i>
<!-- 上传按钮 --> <div class="el-upload__text" v-if="drag">将文件拖到此处<em>点击上传</em></div>
<!-- 选择文件按钮 -->
<el-button size="mini" icon="el-icon-upload" v-if="!drag">选取文件</el-button> <el-button size="mini" icon="el-icon-upload" v-if="!drag">选取文件</el-button>
<!-- 上传提示 --> <!-- 上传提示 -->
<div class="el-upload__tip" slot="tip" v-if="showTip"> <div class="el-upload__tip" slot="tip" v-if="showTip">
@ -23,7 +24,7 @@
<span class="el-icon-document"> {{ getFileName(file.name) }} </span> <span class="el-icon-document"> {{ getFileName(file.name) }} </span>
</el-link> </el-link>
<div class="ele-upload-list__item-content-action"> <div class="ele-upload-list__item-content-action">
<el-link :underline="false" @click="handleDelete(index)" type="danger">删除</el-link> <el-link @click="handleDelete(index)" type="danger">删除</el-link>
</div> </div>
</li> </li>
</transition-group> </transition-group>
@ -73,6 +74,11 @@ export default {
drag: { drag: {
type: Boolean, type: Boolean,
default: false default: false
},
//
autoUpload: {
type: Boolean,
default: true
} }
}, },
data() { data() {
@ -181,10 +187,6 @@ export default {
res.data res.data
) )
}, },
//
uploadProcess(event, file, fileList) {
// console.log("" + file.percentage);
},
// //
handleDelete(index) { handleDelete(index) {
this.fileList.splice(index, 1) this.fileList.splice(index, 1)
@ -206,6 +208,11 @@ export default {
strs += list[i].url + separator strs += list[i].url + separator
} }
return strs != '' ? strs.substr(0, strs.length - 1) : '' return strs != '' ? strs.substr(0, strs.length - 1) : ''
},
//
submitUpload() {
console.log(this.fileList)
this.$refs.upload.submit()
} }
} }
} }
@ -228,7 +235,7 @@ export default {
margin-right: 10px; margin-right: 10px;
} }
::v-deep .el-upload-dragger { ::v-deep .el-upload-dragger {
width: 270px; width: 270px;
height: 150px; height: 150px;
} }
</style> </style>