用户导入添加验证提示

This commit is contained in:
RuoYi
2025-08-23 11:47:43 +08:00
parent d2f588ffcc
commit a684b1d98b

View File

@@ -190,7 +190,7 @@
<!-- 用户导入对话框 -->
<el-dialog :title="upload.title" v-model="upload.open" width="400px" append-to-body>
<el-upload ref="uploadRef" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
<el-upload ref="uploadRef" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :on-change="handleFileChange" :on-remove="handleFileRemove" :auto-upload="false" drag>
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<template #tip>
@@ -432,6 +432,7 @@ function handleSelectionChange(selection) {
function handleImport() {
upload.title = "用户导入"
upload.open = true
upload.selectedFile = null
}
/** 下载模板操作 */
@@ -445,6 +446,16 @@ const handleFileUploadProgress = (event, file, fileList) => {
upload.isUploading = true
}
/** 文件选择处理 */
const handleFileChange = (file, fileList) => {
upload.selectedFile = file
}
/** 文件删除处理 */
const handleFileRemove = (file, fileList) => {
upload.selectedFile = null
}
/** 文件上传成功处理 */
const handleFileSuccess = (response, file, fileList) => {
upload.open = false
@@ -456,6 +467,11 @@ const handleFileSuccess = (response, file, fileList) => {
/** 提交上传文件 */
function submitFileForm() {
const file = upload.selectedFile
if (!file || file.length === 0 || !file.name.toLowerCase().endsWith('.xls') && !file.name.toLowerCase().endsWith('.xlsx')) {
proxy.$modal.msgError("请选择后缀为 “xls”或“xlsx”的文件。")
return
}
proxy.$refs["uploadRef"].submit()
}