From 881c7e720e5a753115a4121276333ff121a8d741 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Wed, 30 Oct 2024 22:22:25 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E4=BC=98=E5=8C=96=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E9=83=A8=E5=88=86=E7=95=8C=E9=9D=A2=E5=8F=8A?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/system/user.ts | 6 +++--- src/hooks/modules/useDownload.ts | 2 +- src/views/system/user/UserImportDrawer.vue | 23 +++++++++++++++------- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/apis/system/user.ts b/src/apis/system/user.ts index b899733b..13acd999 100644 --- a/src/apis/system/user.ts +++ b/src/apis/system/user.ts @@ -44,13 +44,13 @@ export function resetUserPwd(data: any, id: string) { } /** @desc 下载用户导入模板 */ -export function downloadImportUserTemplate() { - return http.download(`${BASE_URL}/downloadImportUserTemplate`) +export function downloadUserImportTemplate() { + return http.download(`${BASE_URL}/import/template`) } /** @desc 解析用户导入数据 */ export function parseImportUser(data: FormData) { - return http.post(`${BASE_URL}/parseImportUser`, data) + return http.post(`${BASE_URL}/import/parse`, data) } /** @desc 导入用户 */ diff --git a/src/hooks/modules/useDownload.ts b/src/hooks/modules/useDownload.ts index f5799d4a..0cc32cfc 100644 --- a/src/hooks/modules/useDownload.ts +++ b/src/hooks/modules/useDownload.ts @@ -10,7 +10,7 @@ import { Message, Notification } from '@arco-design/web-vue' interface NavigatorWithMsSaveOrOpenBlob extends Navigator { msSaveOrOpenBlob: (blob: Blob, fileName: string) => void } -export const useDownload = async (api: () => Promise, isNotify = true, tempName = '', fileType = '.xlsx') => { +export const useDownload = async (api: () => Promise, isNotify = false, tempName = '', fileType = '.xlsx') => { try { const res = await api() if (res.headers['content-disposition']) { diff --git a/src/views/system/user/UserImportDrawer.vue b/src/views/system/user/UserImportDrawer.vue index 55aa2969..27d96fc6 100644 --- a/src/views/system/user/UserImportDrawer.vue +++ b/src/views/system/user/UserImportDrawer.vue @@ -11,14 +11,17 @@ @close="reset" > - - 数据导入请严格按照模板填写,格式要求和新增一致! + + 请按照模板要求填写数据,填写完毕后,请先上传并进行解析。
- 1.上传解析文件 + 1.解析数据
import { type FormInstance, Message, type RequestOption } from '@arco-design/web-vue' import { useWindowSize } from '@vueuse/core' -import { type UserImportResp, downloadImportUserTemplate, importUser, parseImportUser } from '@/apis/system' +import { + type UserImportResp, + downloadUserImportTemplate, + importUser, + parseImportUser, +} from '@/apis/system/user' import { useDownload, useForm } from '@/hooks' const emit = defineEmits<{ @@ -129,7 +137,7 @@ const onImport = () => { // 下载模板 const downloadTemplate = () => { - useDownload(() => downloadImportUserTemplate()) + useDownload(() => downloadUserImportTemplate()) } // 上传解析导入数据 @@ -160,11 +168,12 @@ const handleUpload = (options: RequestOption) => { const save = async () => { try { if (!dataResult.value.importKey) { + Message.warning('请先上传文件,解析导入数据') return false } form.importKey = dataResult.value.importKey const res = await importUser(form) - Message.success(`导入成功,新增${res.data.insertRows},修改${res.data.updateRows}`) + Message.success(`导入成功! 新增${res.data.insertRows}, 修改${res.data.updateRows}`) emit('save-success') return true } catch (error) {