| | |
| | | import { useVbenModal } from '@vben/common-ui'; |
| | | import { downloadFileFromBlobPart } from '@vben/utils'; |
| | | |
| | | import { Button, message, Upload } from 'ant-design-vue'; |
| | | import { Button, Upload } from 'ant-design-vue'; |
| | | |
| | | import { useVbenForm } from '#/adapter/form'; |
| | | import { importUser, importUserTemplate } from '#/api/system/user'; |
| | | import { $t } from '#/locales'; |
| | | import { notifyImportResult } from '#/utils'; |
| | | |
| | | import { useImportFormSchema } from '../data'; |
| | | |
| | |
| | | // 提交表单 |
| | | const data = await formApi.getValues(); |
| | | try { |
| | | await importUser(data.file, data.updateSupport); |
| | | // 关闭并提示 |
| | | const importData = await importUser(data.file, data.updateSupport); |
| | | const createCount = importData.createUsernames?.length || 0; |
| | | const updateCount = importData.updateUsernames?.length || 0; |
| | | |
| | | // 关闭并按导入结果提示:仅在确有数据写入时通知列表刷新 |
| | | await modalApi.close(); |
| | | emit('success'); |
| | | message.success($t('ui.actionMessage.operationSuccess')); |
| | | if (createCount + updateCount > 0) { |
| | | emit('success'); |
| | | } |
| | | notifyImportResult({ |
| | | subject: '用户', |
| | | createCount, |
| | | updateCount, |
| | | failures: importData.failureUsernames, |
| | | }); |
| | | } finally { |
| | | modalApi.unlock(); |
| | | } |