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

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 = "")
{
DateTime date = DateTime.Now;
int year = date.Year;
int month = date.Month;
int day = date.Day;
int hour = date.Hour;
string timeDir = $"{year}{month}{day}/";// date.ToString("yyyyMM/dd/HH/");
string timeDir = Path.Combine(date.ToString("yyyyMMdd"));// date.ToString("yyyyMM/dd/HH/");
if (!string.IsNullOrEmpty(path))
{
timeDir = $"{path}/{timeDir}/";
timeDir = Path.Combine(path, timeDir);
}
return timeDir;
}
@ -41,7 +36,7 @@ namespace Infrastructure
{
str = Guid.NewGuid().ToString();
}
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
MD5CryptoServiceProvider md5 = new();
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 Snowflake.Core;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
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();
if (jobKeys == null || jobKeys.Count == 0)
{
return new ApiResult(110, $"未找到分组[{ tasksQz.JobGroup }]");
await AddTaskScheduleAsync(tasksQz);
}
var triggers = await _scheduler.Result.GetTriggersOfJob(jobKey);

View File

@ -1,11 +1,12 @@
<template>
<div class="upload-file">
<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"
:drag="drag" ref="upload">
:on-exceed="handleExceed" :on-success="handleUploadSuccess" :show-file-list="true" :data="data" :headers="headers" :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>
<!-- 上传按钮 -->
<!-- 选择文件按钮 -->
<el-button size="mini" icon="el-icon-upload" v-if="!drag">选取文件</el-button>
<!-- 上传提示 -->
<div class="el-upload__tip" slot="tip" v-if="showTip">
@ -23,7 +24,7 @@
<span class="el-icon-document"> {{ getFileName(file.name) }} </span>
</el-link>
<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>
</li>
</transition-group>
@ -73,6 +74,11 @@ export default {
drag: {
type: Boolean,
default: false
},
//
autoUpload: {
type: Boolean,
default: true
}
},
data() {
@ -181,10 +187,6 @@ export default {
res.data
)
},
//
uploadProcess(event, file, fileList) {
// console.log("" + file.percentage);
},
//
handleDelete(index) {
this.fileList.splice(index, 1)
@ -206,6 +208,11 @@ export default {
strs += list[i].url + separator
}
return strs != '' ? strs.substr(0, strs.length - 1) : ''
},
//
submitUpload() {
console.log(this.fileList)
this.$refs.upload.submit()
}
}
}