From f19f1921709cb5a2a4a84943bdf93e85dd18d0c3 Mon Sep 17 00:00:00 2001 From: insistence <3055204202@qq.com> Date: Fri, 29 Aug 2025 15:51:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=94=A8=E6=88=B7=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=AA=8C=E8=AF=81=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/system/user/index.vue | 46 ++++++++++++++----- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/ruoyi-fastapi-frontend/src/views/system/user/index.vue b/ruoyi-fastapi-frontend/src/views/system/user/index.vue index f513927..b464236 100644 --- a/ruoyi-fastapi-frontend/src/views/system/user/index.vue +++ b/ruoyi-fastapi-frontend/src/views/system/user/index.vue @@ -465,6 +465,8 @@ :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" + :on-change="handleFileChange" + :on-remove="handleFileRemove" :auto-upload="false" drag > @@ -642,14 +644,16 @@ function getList() { } /** 查询部门下拉树结构 */ function getDeptTree() { - deptTreeSelect().then(response => { + deptTreeSelect().then((response) => { deptOptions.value = response.data; - enabledDeptOptions.value = filterDisabledDept(JSON.parse(JSON.stringify(response.data))); + enabledDeptOptions.value = filterDisabledDept( + JSON.parse(JSON.stringify(response.data)) + ); }); -}; +} /** 过滤禁用的部门 */ function filterDisabledDept(deptList) { - return deptList.filter(dept => { + return deptList.filter((dept) => { if (dept.disabled) { return false; } @@ -658,7 +662,7 @@ function filterDisabledDept(deptList) { } return true; }); -}; +} /** 节点单击事件 */ function handleNodeClick(data) { queryParams.value.deptId = data.id; @@ -766,6 +770,7 @@ function handleSelectionChange(selection) { function handleImport() { upload.title = "用户导入"; upload.open = true; + upload.selectedFile = null; } /** 下载模板操作 */ function importTemplate() { @@ -779,6 +784,14 @@ function importTemplate() { 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; @@ -795,6 +808,16 @@ 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(); } /** 重置操作表单 */ @@ -867,12 +890,11 @@ function submitForm() { }); } - onMounted(() => { - getDeptTree() - getList() - proxy.getConfigKey("sys.user.initPassword").then(response => { - initPassword.value = response.msg - }) -}) + getDeptTree(); + getList(); + proxy.getConfigKey("sys.user.initPassword").then((response) => { + initPassword.value = response.msg; + }); +});