|
|
|
|
@ -22,7 +22,7 @@ |
|
|
|
|
<el-table-column label="文件名称" align="center" key="source" prop="source" :show-overflow-tooltip="true" /> |
|
|
|
|
<el-table-column label="更新时间" align="center" prop="uploadTime" width="160"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<span>{{ parseTime(scope.row.uploadTime) }}</span> |
|
|
|
|
<span>{{ formatISOTime(scope.row.uploadTime) }}</span> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column label="操作" align="center" width="160" class-name="small-padding fixed-width"> |
|
|
|
|
@ -56,6 +56,8 @@ |
|
|
|
|
:data="{ source: form.source }" |
|
|
|
|
:on-preview="handlePreview" |
|
|
|
|
:on-remove="handleRemove" |
|
|
|
|
:on-error="handleUploadError" |
|
|
|
|
:before-upload="beforeUpload" |
|
|
|
|
:file-list="fileList" |
|
|
|
|
:headers="headers" |
|
|
|
|
:auto-upload="false"> |
|
|
|
|
@ -298,6 +300,22 @@ export default { |
|
|
|
|
this.$modal.msgSuccess("删除成功") |
|
|
|
|
}).catch(() => {}) |
|
|
|
|
}, |
|
|
|
|
/** 格式化ISO时间字符串 */ |
|
|
|
|
formatISOTime(isoString) { |
|
|
|
|
if (!isoString) return ''; |
|
|
|
|
const date = new Date(isoString); |
|
|
|
|
if (isNaN(date.getTime())) return isoString; |
|
|
|
|
|
|
|
|
|
const year = date.getFullYear(); |
|
|
|
|
const month = String(date.getMonth() + 1).padStart(2, '0'); |
|
|
|
|
const day = String(date.getDate()).padStart(2, '0'); |
|
|
|
|
const hours = String(date.getHours()).padStart(2, '0'); |
|
|
|
|
const minutes = String(date.getMinutes()).padStart(2, '0'); |
|
|
|
|
const seconds = String(date.getSeconds()).padStart(2, '0'); |
|
|
|
|
|
|
|
|
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
/** 导出按钮操作 */ |
|
|
|
|
handleExport() { |
|
|
|
|
this.download('system/user/export', { |
|
|
|
|
@ -318,6 +336,31 @@ export default { |
|
|
|
|
handleFileUploadProgress(event, file, fileList) { |
|
|
|
|
this.upload.isUploading = true |
|
|
|
|
}, |
|
|
|
|
// 文件上传前校验 |
|
|
|
|
beforeUpload(file) { |
|
|
|
|
const isDocx = file.name.endsWith('.docx'); |
|
|
|
|
const isTxt = file.name.endsWith('.txt'); |
|
|
|
|
const isLt5M = file.size / 1024 / 1024 < 5; |
|
|
|
|
|
|
|
|
|
if (!isDocx && !isTxt) { |
|
|
|
|
this.$message.error('只允许上传docx/txt格式的文件!'); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if (!isLt5M) { |
|
|
|
|
this.$message.error('文件大小不能超过5MB!'); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// 文件上传失败处理 |
|
|
|
|
handleUploadError(err, file, fileList) { |
|
|
|
|
this.upload.isUploading = false; |
|
|
|
|
// 显示错误消息 |
|
|
|
|
this.$modal.msgError("上传失败,请重试"); |
|
|
|
|
console.error('上传失败:', err); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// 文件上传成功处理 |
|
|
|
|
handleFileSuccess(response, file, fileList) { |
|
|
|
|
this.upload.isUploading = false; |
|
|
|
|
|