From 1f226513b56c144857a05325fc93920bd2dfb110 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 3 Apr 2026 08:56:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EExcel=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E7=BB=84=E4=BB=B6ExcelImportDialog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ExcelImportDialog/index.vue | 138 +++++++++++++++++++++ src/views/system/user/index.vue | 82 +----------- 2 files changed, 141 insertions(+), 79 deletions(-) create mode 100644 src/components/ExcelImportDialog/index.vue diff --git a/src/components/ExcelImportDialog/index.vue b/src/components/ExcelImportDialog/index.vue new file mode 100644 index 0000000..85c0a4c --- /dev/null +++ b/src/components/ExcelImportDialog/index.vue @@ -0,0 +1,138 @@ + + + diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index 0c1dd66..3bb8878 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -173,27 +173,7 @@ - - - -
将文件拖到此处,或点击上传
- -
- -
+ @@ -201,6 +181,7 @@ import { getToken } from "@/utils/auth" import useAppStore from '@/store/modules/app' import TreePanel from "@/components/TreePanel" +import ExcelImportDialog from "@/components/ExcelImportDialog" import { changeUserStatus, listUser, resetUserPwd, delUser, getUser, updateUser, addUser, deptTreeSelect } from "@/api/system/user" import type { SysUser, UserQueryParams, UserFormDataResult } from '@/types/api/system/user' import type { SysRole } from '@/types/api/system/role' @@ -227,21 +208,6 @@ const enabledDeptOptions = ref(undefined) const initPassword = ref(undefined) const postOptions = ref([]) const roleOptions = ref([]) -/*** 用户导入参数 */ -const upload = reactive({ - // 是否显示弹出层(用户导入) - open: false, - // 弹出层标题(用户导入) - title: "", - // 是否禁用上传 - isUploading: false, - // 是否更新已经存在的用户数据 - updateSupport: 0, - // 设置上传的请求头部 - headers: { Authorization: "Bearer " + getToken() }, - // 上传的地址 - url: import.meta.env.VITE_APP_BASE_API + "/system/user/importData" -}) // 列显隐信息 const columns = ref>({ userId: { label: '用户编号', visible: true }, @@ -406,49 +372,7 @@ function handleSelectionChange(selection: SysUser[]) { /** 导入按钮操作 */ function handleImport() { - upload.title = "用户导入" - upload.open = true - upload.selectedFile = null -} - -/** 下载模板操作 */ -function importTemplate() { - proxy.download("system/user/importTemplate", { - }, `user_template_${new Date().getTime()}.xlsx`) -} - -/**文件上传中处理 */ -const handleFileUploadProgress = (event: any, file: any, fileList: any[]) => { - upload.isUploading = true -} - -/** 文件选择处理 */ -const handleFileChange = (file: any, fileList: any[]) => { - upload.selectedFile = file -} - -/** 文件删除处理 */ -const handleFileRemove = (file: any, fileList: any[]) => { - upload.selectedFile = null -} - -/** 文件上传成功处理 */ -const handleFileSuccess = (response: AjaxResult, file: any, fileList: any[]) => { - upload.open = false - upload.isUploading = false - proxy.$refs["uploadRef"].handleRemove(file) - proxy.$alert("
" + response.msg + "
", "导入结果", { dangerouslyUseHTMLString: true }) - getList() -} - -/** 提交上传文件 */ -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() + proxy.$refs["importUserRef"].open() } /** 重置操作表单 */