Skip to content

Commit 881c7e7

Browse files
committed
style: 优化导入用户部分界面及接口路径
1 parent 146637c commit 881c7e7

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

src/apis/system/user.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ export function resetUserPwd(data: any, id: string) {
4444
}
4545

4646
/** @desc 下载用户导入模板 */
47-
export function downloadImportUserTemplate() {
48-
return http.download(`${BASE_URL}/downloadImportUserTemplate`)
47+
export function downloadUserImportTemplate() {
48+
return http.download(`${BASE_URL}/import/template`)
4949
}
5050

5151
/** @desc 解析用户导入数据 */
5252
export function parseImportUser(data: FormData) {
53-
return http.post(`${BASE_URL}/parseImportUser`, data)
53+
return http.post(`${BASE_URL}/import/parse`, data)
5454
}
5555

5656
/** @desc 导入用户 */

src/hooks/modules/useDownload.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Message, Notification } from '@arco-design/web-vue'
1010
interface NavigatorWithMsSaveOrOpenBlob extends Navigator {
1111
msSaveOrOpenBlob: (blob: Blob, fileName: string) => void
1212
}
13-
export const useDownload = async (api: () => Promise<any>, isNotify = true, tempName = '', fileType = '.xlsx') => {
13+
export const useDownload = async (api: () => Promise<any>, isNotify = false, tempName = '', fileType = '.xlsx') => {
1414
try {
1515
const res = await api()
1616
if (res.headers['content-disposition']) {

src/views/system/user/UserImportDrawer.vue

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@
1111
@close="reset"
1212
>
1313
<a-form ref="formRef" :model="form" size="large" auto-label-width>
14-
<a-alert v-if="!form.disabled" :show-icon="false" style="margin-bottom: 15px">
15-
数据导入请严格按照模板填写,格式要求和新增一致!
14+
<a-alert v-if="!form.disabled" style="margin-bottom: 15px">
15+
请按照模板要求填写数据,填写完毕后,请先上传并进行解析。
1616
<template #action>
17-
<a-button size="small" type="primary" @click="downloadTemplate">下载模板</a-button>
17+
<a-link @click="downloadTemplate">
18+
<template #icon><GiSvgIcon name="file-excel" :size="16" /></template>
19+
<template #default>下载模板</template>
20+
</a-link>
1821
</template>
1922
</a-alert>
2023
<fieldset>
21-
<legend>1.上传解析文件</legend>
24+
<legend>1.解析数据</legend>
2225
<div class="file-box">
2326
<a-upload
2427
draggable
@@ -85,7 +88,12 @@
8588
<script setup lang="ts">
8689
import { type FormInstance, Message, type RequestOption } from '@arco-design/web-vue'
8790
import { useWindowSize } from '@vueuse/core'
88-
import { type UserImportResp, downloadImportUserTemplate, importUser, parseImportUser } from '@/apis/system'
91+
import {
92+
type UserImportResp,
93+
downloadUserImportTemplate,
94+
importUser,
95+
parseImportUser,
96+
} from '@/apis/system/user'
8997
import { useDownload, useForm } from '@/hooks'
9098
9199
const emit = defineEmits<{
@@ -129,7 +137,7 @@ const onImport = () => {
129137
130138
// 下载模板
131139
const downloadTemplate = () => {
132-
useDownload(() => downloadImportUserTemplate())
140+
useDownload(() => downloadUserImportTemplate())
133141
}
134142
135143
// 上传解析导入数据
@@ -160,11 +168,12 @@ const handleUpload = (options: RequestOption) => {
160168
const save = async () => {
161169
try {
162170
if (!dataResult.value.importKey) {
171+
Message.warning('请先上传文件,解析导入数据')
163172
return false
164173
}
165174
form.importKey = dataResult.value.importKey
166175
const res = await importUser(form)
167-
Message.success(`导入成功新增${res.data.insertRows},修改${res.data.updateRows}`)
176+
Message.success(`导入成功! 新增${res.data.insertRows}, 修改${res.data.updateRows}`)
168177
emit('save-success')
169178
return true
170179
} catch (error) {

0 commit comments

Comments
 (0)