From 944015484a4442682c64fb6a56d8756573c3d0ca Mon Sep 17 00:00:00 2001 From: gexinzhineng/gxzn27 <1348660141@qq.com> Date: Tue, 28 Mar 2023 11:27:08 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E9=85=8D=E5=90=88=E5=9C=B0=E5=8C=BA?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E6=8E=A5=E5=8F=A3=E7=9A=84api=E6=96=87?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E5=90=8E=E7=AB=AF=E4=BF=AE=E6=94=B9=E7=9B=B8?= =?UTF-8?q?=E5=BA=94=E5=AD=97=E6=AE=B5=E5=8F=AF=E4=BB=A5=E4=B8=8D=E8=A6=81?= =?UTF-8?q?=E6=AD=A4=E6=96=87=E4=BB=B6=202=E3=80=81=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E8=AE=BE=E6=96=BD/=E6=96=87=E4=BB=B6=E7=AE=A1=E7=90=86/?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=88=97=E8=A1=A8=20=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E6=97=A0=E6=B3=95=E4=B8=8A=E4=BC=A0=E5=8F=AA?= =?UTF-8?q?=E8=83=BD=E5=88=B7=E6=96=B0=E9=A1=B5=E9=9D=A2=E6=89=8D=E8=83=BD?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0bug=203=E3=80=81=E5=9F=BA=E7=A1=80=E8=AE=BE?= =?UTF-8?q?=E6=96=BD/=E6=96=87=E4=BB=B6=E7=AE=A1=E7=90=86/=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=88=97=E8=A1=A8=20=E6=96=B0=E5=A2=9E=E6=98=AF?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E6=A1=86=E6=98=BE=E7=A4=BA0=20=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E4=B8=BAnull?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/infra/fileConfig/index.ts | 2 +- src/config/axios/request.ts | 50 ++++++++++++++++++++++++++++ src/views/infra/fileConfig/index.vue | 4 +-- src/views/infra/fileList/index.vue | 6 +++- 4 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 src/config/axios/request.ts diff --git a/src/api/infra/fileConfig/index.ts b/src/api/infra/fileConfig/index.ts index 2151141c..9a4f625c 100644 --- a/src/api/infra/fileConfig/index.ts +++ b/src/api/infra/fileConfig/index.ts @@ -16,7 +16,7 @@ export interface FileClientConfig { export interface FileConfigVO { id: number name: string - storage: number + storage: any master: boolean visible: boolean config: FileClientConfig diff --git a/src/config/axios/request.ts b/src/config/axios/request.ts new file mode 100644 index 00000000..d65842c2 --- /dev/null +++ b/src/config/axios/request.ts @@ -0,0 +1,50 @@ +import { service } from './service' + +import { config } from './config' + +const { default_headers } = config + +const request = (option: any) => { + const { url, method, params, data, headersType, responseType } = option + return service({ + url: url, + method, + params, + data, + responseType: responseType, + headers: { + 'Content-Type': headersType || default_headers + } + }) +} +export default { + get: async (option: any) => { + const res = await request({ method: 'GET', ...option }) + return res as unknown as T + }, + post: async (option: any) => { + const res = await request({ method: 'POST', ...option }) + return res as unknown as T + }, + delete: async (option: any) => { + const res = await request({ method: 'DELETE', ...option }) + return res as unknown as T + }, + put: async (option: any) => { + const res = await request({ method: 'PUT', ...option }) + return res as unknown as T + }, + patch: async (option: any) => { + const res = await request({ method: 'PATCH', ...option }) + return res as unknown as T + }, + download: async (option: any) => { + const res = await request({ method: 'GET', responseType: 'blob', ...option }) + return res as unknown as Promise + }, + upload: async (option: any) => { + option.headersType = 'multipart/form-data' + const res = await request({ method: 'POST', ...option }) + return res as unknown as Promise + } +} diff --git a/src/views/infra/fileConfig/index.vue b/src/views/infra/fileConfig/index.vue index 9d796a65..bd9a978a 100644 --- a/src/views/infra/fileConfig/index.vue +++ b/src/views/infra/fileConfig/index.vue @@ -183,7 +183,7 @@ const detailData = ref() // 详情 Ref const form = ref({ id: 0, name: '', - storage: 0, + storage: null, master: false, visible: false, config: { @@ -216,7 +216,7 @@ const handleCreate = (formEl: FormInstance | undefined) => { form.value = { id: 0, name: '', - storage: 0, + storage: null, master: false, visible: false, config: { diff --git a/src/views/infra/fileList/index.vue b/src/views/infra/fileList/index.vue index cda8b68d..b9bfb815 100644 --- a/src/views/infra/fileList/index.vue +++ b/src/views/infra/fileList/index.vue @@ -59,6 +59,7 @@ :on-exceed="handleExceed" :on-success="handleFileSuccess" :on-error="excelUploadError" + :before-remove="beforeRemove" :auto-upload="false" accept=".jpg, .png, .gif" > @@ -82,7 +83,7 @@