| | |
| | | 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 { importCustomer, importCustomerTemplate } from '#/api/crm/customer'; |
| | | import { $t } from '#/locales'; |
| | | import { notifyImportResult } from '#/utils'; |
| | | |
| | | import { useImportFormSchema } from '../data'; |
| | | |
| | |
| | | // 提交表单 |
| | | const data = await formApi.getValues(); |
| | | try { |
| | | await importCustomer({ |
| | | const importData = await importCustomer({ |
| | | ownerUserId: data.ownerUserId, |
| | | file: data.file, |
| | | updateSupport: data.updateSupport, |
| | | }); |
| | | // 关闭并提示 |
| | | const createCount = importData.createCustomerNames?.length || 0; |
| | | const updateCount = importData.updateCustomerNames?.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.failureCustomerNames, |
| | | }); |
| | | } finally { |
| | | modalApi.unlock(); |
| | | } |