From eef2316f4d39cea112e5642aca42c4bc7a8a790a Mon Sep 17 00:00:00 2001 From: zh <1523826083@qq.com> Date: Wed, 21 May 2025 22:11:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=89=8D=E7=AB=AF=E4=B8=8A=E4=BC=A0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=20=E8=81=94=E7=B3=BB=E4=BA=BA=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=99=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.local | 2 +- jsconfig.json | 10 + src/api/infra/file/index.ts | 4 + src/components/UploadFile/src/useUpload.ts | 6 +- .../crm/customer/components/FileForm.vue | 103 +++++++++ .../crm/customer/components/FileList.vue | 207 ++++++++++++++++++ src/views/crm/customer/detail/index.vue | 3 +- yudao-ui-admin-vue3.iml | 9 + 8 files changed, 341 insertions(+), 3 deletions(-) create mode 100644 jsconfig.json create mode 100644 src/views/crm/customer/components/FileForm.vue create mode 100644 src/views/crm/customer/components/FileList.vue create mode 100644 yudao-ui-admin-vue3.iml diff --git a/.env.local b/.env.local index 35765584d..17ec76983 100644 --- a/.env.local +++ b/.env.local @@ -7,7 +7,7 @@ VITE_DEV=true VITE_BASE_URL='http://localhost:48080' # 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持 S3 服务 -VITE_UPLOAD_TYPE=server +VITE_UPLOAD_TYPE=client # 接口地址 VITE_API_URL=/admin-api diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 000000000..a0f9272c8 --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "baseUrl": "./", + "paths": { + "@/*": ["src/*"] + } + }, + "include": ["src/**/*"], + "exclude": ["node_modules"] +} \ No newline at end of file diff --git a/src/api/infra/file/index.ts b/src/api/infra/file/index.ts index 5c042393b..902188e9f 100644 --- a/src/api/infra/file/index.ts +++ b/src/api/infra/file/index.ts @@ -10,6 +10,10 @@ export interface FilePresignedUrlRespVO { url: string // 文件路径 path: string + // 文件类型 + category: string + // 编号 + categoryId: number } // 查询文件列表 diff --git a/src/components/UploadFile/src/useUpload.ts b/src/components/UploadFile/src/useUpload.ts index 951b23978..b26b41530 100644 --- a/src/components/UploadFile/src/useUpload.ts +++ b/src/components/UploadFile/src/useUpload.ts @@ -10,7 +10,7 @@ export const getUploadUrl = (): string => { return import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL + '/infra/file/upload' } -export const useUpload = (directory?: string) => { +export const useUpload = (directory?: string, category?: string, categoryId?: number) => { // 后端上传地址 const uploadUrl = getUploadUrl() // 是否使用前端直连上传 @@ -23,6 +23,8 @@ export const useUpload = (directory?: string) => { const fileName = await generateFileName(options.file) // 1.2 获取文件预签名地址 const presignedInfo = await FileApi.getFilePresignedUrl(fileName, directory) + presignedInfo.category = category ?? '' + presignedInfo.categoryId = categoryId ?? 0 // 1.3 上传文件(不能使用 ElUpload 的 ajaxUpload 方法的原因:其使用的是 FormData 上传,Minio 不支持) return axios .put(presignedInfo.uploadUrl, options.file, { @@ -72,6 +74,8 @@ function createFile(vo: FileApi.FilePresignedUrlRespVO, file: UploadRawFile) { configId: vo.configId, url: vo.url, path: vo.path, + category: vo.category, + categoryId: vo.categoryId, name: file.name, type: file.type, size: file.size diff --git a/src/views/crm/customer/components/FileForm.vue b/src/views/crm/customer/components/FileForm.vue new file mode 100644 index 000000000..d7e41f97c --- /dev/null +++ b/src/views/crm/customer/components/FileForm.vue @@ -0,0 +1,103 @@ + + + + + 将文件拖到此处,或 点击上传 + + + 提示:仅允许导入 jpg、png、gif、txt、doc、docx、xls格式文件! + + + + + 确 定 + 取 消 + + + + + diff --git a/src/views/crm/customer/components/FileList.vue b/src/views/crm/customer/components/FileList.vue new file mode 100644 index 000000000..b04d1dc77 --- /dev/null +++ b/src/views/crm/customer/components/FileList.vue @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + 搜索 + 重置 + + 上传文件 + + + + + + + + + + + + + + + + + 预览 + 下载 + + + + + + + 复制链接 + + + 删除 + + + + + + + + + + + + + diff --git a/src/views/crm/customer/detail/index.vue b/src/views/crm/customer/detail/index.vue index 31e44eb2f..b7883c898 100644 --- a/src/views/crm/customer/detail/index.vue +++ b/src/views/crm/customer/detail/index.vue @@ -68,7 +68,7 @@ - + @@ -95,6 +95,7 @@ import { BizTypeEnum } from '@/api/crm/permission' import type { OperateLogVO } from '@/api/system/operatelog' import { getOperateLogPage } from '@/api/crm/operateLog' import CustomerDistributeForm from '@/views/crm/customer/pool/CustomerDistributeForm.vue' +import FileList from '../components/FileList.vue' defineOptions({ name: 'CrmCustomerDetail' }) diff --git a/yudao-ui-admin-vue3.iml b/yudao-ui-admin-vue3.iml new file mode 100644 index 000000000..8021953ed --- /dev/null +++ b/yudao-ui-admin-vue3.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file