diff --git a/apps/web-antd/src/api/license/customer/index.ts b/apps/web-antd/src/api/license/customer/index.ts index f79ae36..512bdb8 100644 --- a/apps/web-antd/src/api/license/customer/index.ts +++ b/apps/web-antd/src/api/license/customer/index.ts @@ -72,6 +72,19 @@ export function exportCustomer(params: any) { return requestClient.download('/license/customer/export-excel', params); } +/** 下载导入模板 */ +export function importTemplate() { + return requestClient.download('/license/customer/get-import-template'); +} + +/** 导入客户 */ +export function importCustomer(file: File, updateSupport: boolean) { + return requestClient.upload('/license/customer/import', { + file, + updateSupport, + }); +} + /** 客户名称是否唯一 */ export async function isCustomerNameUnique( name: string, diff --git a/apps/web-antd/src/api/license/project/index.ts b/apps/web-antd/src/api/license/project/index.ts index 64193b8..8d9a154 100644 --- a/apps/web-antd/src/api/license/project/index.ts +++ b/apps/web-antd/src/api/license/project/index.ts @@ -67,6 +67,19 @@ export function exportProject(params: any) { return requestClient.download('/license/project/export-excel', params); } +/** 下载导入模板 */ +export function importTemplate() { + return requestClient.download('/license/project/get-import-template'); +} + +/** 导入项目 */ +export function importProject(file: File, updateSupport: boolean) { + return requestClient.upload('/license/project/import', { + file, + updateSupport, + }); +} + /** 项目名称是否唯一 */ export async function isProjectNameUnique( name: string, diff --git a/apps/web-antd/src/views/license/customer/data.ts b/apps/web-antd/src/views/license/customer/data.ts index ef1ffb3..d8aaf73 100644 --- a/apps/web-antd/src/views/license/customer/data.ts +++ b/apps/web-antd/src/views/license/customer/data.ts @@ -281,3 +281,27 @@ export function useGridColumns( }, ]; } + +/** 客户导入的表单 */ +export function useImportFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'file', + label: '客户数据', + component: 'Upload', + rules: 'required', + help: '仅允许导入 xls、xlsx 格式文件', + }, + { + fieldName: 'updateSupport', + label: '是否覆盖', + component: 'Switch', + componentProps: { + checkedChildren: '是', + unCheckedChildren: '否', + }, + rules: z.boolean().default(false), + help: '是否更新已经存在的客户数据', + }, + ]; +} diff --git a/apps/web-antd/src/views/license/customer/index.vue b/apps/web-antd/src/views/license/customer/index.vue index e65dc61..10c1371 100644 --- a/apps/web-antd/src/views/license/customer/index.vue +++ b/apps/web-antd/src/views/license/customer/index.vue @@ -20,12 +20,18 @@ import { $t } from '#/locales'; import { useGridColumns, useGridFormSchema } from './data'; import Form from './modules/form.vue'; +import ImportForm from './modules/import-form.vue'; const [FormModal, formModalApi] = useVbenModal({ connectedComponent: Form, destroyOnClose: true, }); +const [ImportModal, importModalApi] = useVbenModal({ + connectedComponent: ImportForm, + destroyOnClose: true, +}); + /** 刷新表格 */ function onRefresh() { gridApi.query(); @@ -67,6 +73,11 @@ async function onExport() { }); } +/** 导入客户 */ +function handleImport() { + importModalApi.open(); +} + /** 表格操作按钮的回调函数 */ function onActionClick({ code, @@ -124,6 +135,7 @@ const [Grid, gridApi] = useVbenVxeGrid({