From 4d281cd1cf8d6148df08b604843ca76d2b2e51da Mon Sep 17 00:00:00 2001 From: louis <869322496@qq.com> Date: Fri, 8 Mar 2024 13:19:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=99=84=E4=BB=B6=E5=AD=98=E5=82=A8?= =?UTF-8?q?=E5=8A=A0=E5=85=A5=E4=B8=9A=E5=8A=A1=E6=A8=A1=E5=9D=97=E5=92=8C?= =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E8=AE=B0=E5=BD=95id=E5=86=97=E4=BD=99?= =?UTF-8?q?=EF=BC=8C=E6=96=B9=E4=BE=BF=E8=BF=BD=E8=B8=AA=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=9D=A5=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/backend/api/toolsUpload.ts | 2 - src/api/backend/api/typings.d.ts | 8 ++++ .../business/attachment-upload/index.vue | 25 ++++++++--- src/enums/storageBussinessModuleEnum.ts | 7 +++ src/views/contract/index.vue | 2 + .../materials-inventory/company/index.vue | 2 + .../materials-inventory/in-out/columns.tsx | 44 ++++++++++++++++++- .../materials-inventory/in-out/formSchemas.ts | 2 +- .../materials-inventory/in-out/index.vue | 2 + .../materials-inventory/product/index.vue | 2 + .../materials-inventory/project/index.vue | 2 + src/views/tool/storage/columns.tsx | 31 +++++++++++++ src/views/vehicle-usage/index.vue | 2 + 13 files changed, 120 insertions(+), 11 deletions(-) create mode 100644 src/enums/storageBussinessModuleEnum.ts diff --git a/src/api/backend/api/toolsUpload.ts b/src/api/backend/api/toolsUpload.ts index 950d49e..5fb74cd 100644 --- a/src/api/backend/api/toolsUpload.ts +++ b/src/api/backend/api/toolsUpload.ts @@ -1,5 +1,3 @@ -// @ts-ignore -/* eslint-disable */ import { request, type RequestOptions } from '@/utils/request'; /** 上传 POST /api/tools/upload */ diff --git a/src/api/backend/api/typings.d.ts b/src/api/backend/api/typings.d.ts index 56818be..75785a9 100644 --- a/src/api/backend/api/typings.d.ts +++ b/src/api/backend/api/typings.d.ts @@ -315,6 +315,10 @@ declare namespace API { type FileUploadDto = { /** 文件 */ file: Buffer; + /** 业务模块 */ + bussinessModule?: string; + /** 业务记录ID */ + bussinessRecordId?: number; }; type FlowInfo = { @@ -928,6 +932,10 @@ declare namespace API { createdAt: string; /** 上传者 */ username: string; + /** 关联模块 */ + bussinessModule: string; + /** 关联模块记录ID */ + bussinessRecordId: string; }; type StorageListParams = { diff --git a/src/components/business/attachment-upload/index.vue b/src/components/business/attachment-upload/index.vue index 2306ac2..fdaa599 100644 --- a/src/components/business/attachment-upload/index.vue +++ b/src/components/business/attachment-upload/index.vue @@ -26,11 +26,18 @@ name: 'AttachmentUpload', }); const emit = defineEmits(['close']); - const { afterUploadCallback } = defineProps({ + const { afterUploadCallback, bussinessModule, bussinessRecordId } = defineProps({ afterUploadCallback: { type: Function, default: () => ({}), }, + bussinessModule: { + type: String, + default: '', + }, + bussinessRecordId: { + type: Number, + }, }); const [DynamicTable] = useTable(); @@ -67,13 +74,17 @@ const res = await Promise.all( uploadFileList.map(async (item) => { try { - const itemRes = await Api.toolsUpload.uploadUpload({ file: item.file }, undefined, { - onUploadProgress(progressEvent) { - const complete = ((progressEvent.loaded / progressEvent.total!) * 100) | 0; - item.percent = complete; - item.status = UploadResultStatus.UPLOADING; + const itemRes = await Api.toolsUpload.uploadUpload( + { file: item.file, bussinessModule, bussinessRecordId }, + undefined, + { + onUploadProgress(progressEvent) { + const complete = ((progressEvent.loaded / progressEvent.total!) * 100) | 0; + item.percent = complete; + item.status = UploadResultStatus.UPLOADING; + }, }, - }); + ); item.status = UploadResultStatus.SUCCESS; return itemRes; } catch (error) { diff --git a/src/enums/storageBussinessModuleEnum.ts b/src/enums/storageBussinessModuleEnum.ts new file mode 100644 index 0000000..9a4cd1e --- /dev/null +++ b/src/enums/storageBussinessModuleEnum.ts @@ -0,0 +1,7 @@ +export enum StorageBussinessModuleEnum { + Contract = 'contract', + Company = 'company', + MaterialsInOut = 'materialsInOut', + Product = 'product', + Project = 'project', +} diff --git a/src/views/contract/index.vue b/src/views/contract/index.vue index 3afeaab..195cc2b 100644 --- a/src/views/contract/index.vue +++ b/src/views/contract/index.vue @@ -101,6 +101,8 @@ content: () => { return ( { afterUploadCallback(files, record.id); diff --git a/src/views/materials-inventory/company/index.vue b/src/views/materials-inventory/company/index.vue index 4ee8e2e..65075b9 100644 --- a/src/views/materials-inventory/company/index.vue +++ b/src/views/materials-inventory/company/index.vue @@ -99,6 +99,8 @@ content: () => { return ( { afterUploadCallback(files, record.id); diff --git a/src/views/materials-inventory/in-out/columns.tsx b/src/views/materials-inventory/in-out/columns.tsx index d8dbbc1..73a02c6 100644 --- a/src/views/materials-inventory/in-out/columns.tsx +++ b/src/views/materials-inventory/in-out/columns.tsx @@ -2,6 +2,8 @@ import type { TableColumn } from '@/components/core/dynamic-table'; import { MaterialsInOutEnum } from '@/enums/materialsInventoryEnum'; import { formatToDate } from '@/utils/dateUtil'; import { Tag } from 'ant-design-vue'; +import { getProjectOptions } from './formSchemas'; +import { debounce } from 'lodash-es'; export type TableListItem = API.MaterialsInOutEntity; export type TableQueryItem = API.MaterialsInOutListParams; @@ -22,10 +24,50 @@ export const baseColumns: TableColumnItem[] = [ { title: '项目', width: 80, - dataIndex: 'project', + dataIndex: 'projectId', customRender: ({ record }) => { return record?.project?.name || ''; }, + formItemProps: { + component:'Select', + componentProps: ({ formInstance, schema, formModel }) => ({ + showSearch: true, + filterOption: false, + fieldNames: { + label: 'label', + value: 'value', + }, + getPopupContainer: () => document.body, + defaultActiveFirstOption: true, + onClear: async () => { + const newSchema = { + field: schema.field, + componentProps: { + options: [] as LabelValueOptions, + }, + }; + const options = await getProjectOptions().finally(() => (schema.loading = false)); + newSchema.componentProps.options = options; + formInstance?.updateSchema([newSchema]); + }, + request: () => { + return getProjectOptions(); + }, + onSearch: debounce(async (keyword) => { + schema.loading = true; + const newSchema = { + field: schema.field, + componentProps: { + options: [] as LabelValueOptions, + }, + }; + formInstance?.updateSchema([newSchema]); + const options = await getProjectOptions(keyword).finally(() => (schema.loading = false)); + newSchema.componentProps.options = options; + formInstance?.updateSchema([newSchema]); + }, 500), + }), + }, }, { title: '所属公司', diff --git a/src/views/materials-inventory/in-out/formSchemas.ts b/src/views/materials-inventory/in-out/formSchemas.ts index 106220e..50d6930 100644 --- a/src/views/materials-inventory/in-out/formSchemas.ts +++ b/src/views/materials-inventory/in-out/formSchemas.ts @@ -237,7 +237,7 @@ export const formSchemas = (isEdit?: boolean): FormSchema => { +export const getProjectOptions = async (keyword?: string): Promise => { const { items: result } = await Api.project.projectList({ pageSize: 100, name: keyword }); return ( result?.map((item) => ({ diff --git a/src/views/materials-inventory/in-out/index.vue b/src/views/materials-inventory/in-out/index.vue index 2258b3a..c740679 100644 --- a/src/views/materials-inventory/in-out/index.vue +++ b/src/views/materials-inventory/in-out/index.vue @@ -145,6 +145,8 @@ return ( { afterUploadCallback(files, record.id); }} diff --git a/src/views/materials-inventory/product/index.vue b/src/views/materials-inventory/product/index.vue index 0674801..cddc617 100644 --- a/src/views/materials-inventory/product/index.vue +++ b/src/views/materials-inventory/product/index.vue @@ -101,6 +101,8 @@ content: () => { return ( { afterUploadCallback(files, record.id); diff --git a/src/views/materials-inventory/project/index.vue b/src/views/materials-inventory/project/index.vue index b11055e..5d8a266 100644 --- a/src/views/materials-inventory/project/index.vue +++ b/src/views/materials-inventory/project/index.vue @@ -100,6 +100,8 @@ content: () => { return ( { afterUploadCallback(files, record.id); diff --git a/src/views/tool/storage/columns.tsx b/src/views/tool/storage/columns.tsx index bdb2eef..bd83a3b 100644 --- a/src/views/tool/storage/columns.tsx +++ b/src/views/tool/storage/columns.tsx @@ -3,6 +3,7 @@ import type { TableColumn } from '@/components/core/dynamic-table'; import type { FormSchema } from '@/components/core/schema-form'; import { formatToDateTime } from '@/utils/dateUtil'; import { baseApiUrl } from '@/utils/request'; +import { StorageBussinessModuleEnum } from '@/enums/storageBussinessModuleEnum'; export type TableListItem = API.StorageInfo; export type TableColumnItem = TableColumn; @@ -75,12 +76,26 @@ export const baseColumns: TableColumnItem[] = [ dataIndex: 'username', width: 120, }, + { title: '创建时间', dataIndex: 'createdAt', width: 160, customRender: ({ record }) => formatToDateTime(record.createdAt), }, + { + title: '关联业务模块', + dataIndex: 'bussinessModule', + width: 120, + customRender: ({ record }) => { + return formatBussinessModules(record.bussinessModule) || ''; + }, + }, + { + title: '关联业务ID', + dataIndex: 'bussinessRecordId', + width: 80, + }, ]; export const fileListColumns: TableColumn[] = [ @@ -151,3 +166,19 @@ export const searchFormSchema: FormSchema[] = [ colProps: { span: 8 }, }, ]; + +const formatBussinessModules = (moduleName: string) => { + switch (moduleName) { + case StorageBussinessModuleEnum.Contract: + return '合同审核'; + case StorageBussinessModuleEnum.Company: + return '乙方公司管理'; + case StorageBussinessModuleEnum.MaterialsInOut: + return '原材料出入库记录'; + case StorageBussinessModuleEnum.Product: + return '产品管理'; + case StorageBussinessModuleEnum.Project: + return '项目管理'; + default: + } +}; diff --git a/src/views/vehicle-usage/index.vue b/src/views/vehicle-usage/index.vue index 5f0fe83..9f82e5a 100644 --- a/src/views/vehicle-usage/index.vue +++ b/src/views/vehicle-usage/index.vue @@ -103,6 +103,8 @@ content: () => { return ( { afterUploadCallback(files, record.id);