mirror of
https://github.com/continew-org/continew-admin-ui.git
synced 2025-09-13 02:57:11 +08:00
style: 优化导入用户部分界面及接口路径
This commit is contained in:
@@ -44,13 +44,13 @@ export function resetUserPwd(data: any, id: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @desc 下载用户导入模板 */
|
/** @desc 下载用户导入模板 */
|
||||||
export function downloadImportUserTemplate() {
|
export function downloadUserImportTemplate() {
|
||||||
return http.download(`${BASE_URL}/downloadImportUserTemplate`)
|
return http.download(`${BASE_URL}/import/template`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @desc 解析用户导入数据 */
|
/** @desc 解析用户导入数据 */
|
||||||
export function parseImportUser(data: FormData) {
|
export function parseImportUser(data: FormData) {
|
||||||
return http.post(`${BASE_URL}/parseImportUser`, data)
|
return http.post(`${BASE_URL}/import/parse`, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @desc 导入用户 */
|
/** @desc 导入用户 */
|
||||||
|
@@ -10,7 +10,7 @@ import { Message, Notification } from '@arco-design/web-vue'
|
|||||||
interface NavigatorWithMsSaveOrOpenBlob extends Navigator {
|
interface NavigatorWithMsSaveOrOpenBlob extends Navigator {
|
||||||
msSaveOrOpenBlob: (blob: Blob, fileName: string) => void
|
msSaveOrOpenBlob: (blob: Blob, fileName: string) => void
|
||||||
}
|
}
|
||||||
export const useDownload = async (api: () => Promise<any>, isNotify = true, tempName = '', fileType = '.xlsx') => {
|
export const useDownload = async (api: () => Promise<any>, isNotify = false, tempName = '', fileType = '.xlsx') => {
|
||||||
try {
|
try {
|
||||||
const res = await api()
|
const res = await api()
|
||||||
if (res.headers['content-disposition']) {
|
if (res.headers['content-disposition']) {
|
||||||
|
@@ -11,14 +11,17 @@
|
|||||||
@close="reset"
|
@close="reset"
|
||||||
>
|
>
|
||||||
<a-form ref="formRef" :model="form" size="large" auto-label-width>
|
<a-form ref="formRef" :model="form" size="large" auto-label-width>
|
||||||
<a-alert v-if="!form.disabled" :show-icon="false" style="margin-bottom: 15px">
|
<a-alert v-if="!form.disabled" style="margin-bottom: 15px">
|
||||||
数据导入请严格按照模板填写,格式要求和新增一致!
|
请按照模板要求填写数据,填写完毕后,请先上传并进行解析。
|
||||||
<template #action>
|
<template #action>
|
||||||
<a-button size="small" type="primary" @click="downloadTemplate">下载模板</a-button>
|
<a-link @click="downloadTemplate">
|
||||||
|
<template #icon><GiSvgIcon name="file-excel" :size="16" /></template>
|
||||||
|
<template #default>下载模板</template>
|
||||||
|
</a-link>
|
||||||
</template>
|
</template>
|
||||||
</a-alert>
|
</a-alert>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>1.上传解析文件</legend>
|
<legend>1.解析数据</legend>
|
||||||
<div class="file-box">
|
<div class="file-box">
|
||||||
<a-upload
|
<a-upload
|
||||||
draggable
|
draggable
|
||||||
@@ -85,7 +88,12 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { type FormInstance, Message, type RequestOption } from '@arco-design/web-vue'
|
import { type FormInstance, Message, type RequestOption } from '@arco-design/web-vue'
|
||||||
import { useWindowSize } from '@vueuse/core'
|
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'
|
import { useDownload, useForm } from '@/hooks'
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
@@ -129,7 +137,7 @@ const onImport = () => {
|
|||||||
|
|
||||||
// 下载模板
|
// 下载模板
|
||||||
const downloadTemplate = () => {
|
const downloadTemplate = () => {
|
||||||
useDownload(() => downloadImportUserTemplate())
|
useDownload(() => downloadUserImportTemplate())
|
||||||
}
|
}
|
||||||
|
|
||||||
// 上传解析导入数据
|
// 上传解析导入数据
|
||||||
@@ -160,11 +168,12 @@ const handleUpload = (options: RequestOption) => {
|
|||||||
const save = async () => {
|
const save = async () => {
|
||||||
try {
|
try {
|
||||||
if (!dataResult.value.importKey) {
|
if (!dataResult.value.importKey) {
|
||||||
|
Message.warning('请先上传文件,解析导入数据')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
form.importKey = dataResult.value.importKey
|
form.importKey = dataResult.value.importKey
|
||||||
const res = await importUser(form)
|
const res = await importUser(form)
|
||||||
Message.success(`导入成功,新增${res.data.insertRows},修改${res.data.updateRows}`)
|
Message.success(`导入成功! 新增${res.data.insertRows}, 修改${res.data.updateRows}`)
|
||||||
emit('save-success')
|
emit('save-success')
|
||||||
return true
|
return true
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Reference in New Issue
Block a user