From 11f9c58ee1ede5011a8b19d375bd2285ffa7ee49 Mon Sep 17 00:00:00 2001 From: louis <869322496@qq.com> Date: Tue, 5 Mar 2024 13:56:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BA=A7=E5=93=81=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- src/api/backend/api/typings.d.ts | 14 ++++ .../core/schema-form/src/schema-form-item.vue | 8 +- .../demos/tables/edit-row-table/columns.tsx | 2 + .../meterials-inventory/in-out/columns.tsx | 2 - .../meterials-inventory/in-out/formSchemas.ts | 6 +- .../meterials-inventory/in-out/index.vue | 1 - .../meterials-inventory/product/columns.tsx | 10 ++- .../product/formSchemas.ts | 76 ++++++++++++++++++- .../meterials-inventory/product/index.vue | 19 ++++- 10 files changed, 121 insertions(+), 19 deletions(-) diff --git a/index.html b/index.html index 516b2b9..01d8eb8 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ - 华信办公系统 + 华信办公
diff --git a/src/api/backend/api/typings.d.ts b/src/api/backend/api/typings.d.ts index 2762b15..01a9d5c 100644 --- a/src/api/backend/api/typings.d.ts +++ b/src/api/backend/api/typings.d.ts @@ -1536,6 +1536,7 @@ declare namespace API { type CompanyParams = { page?: number; pageSize?: number; + name?:string; field?: string; order?: 'ASC' | 'DESC'; _t?: number; @@ -1556,6 +1557,10 @@ declare namespace API { type ProductEntity = { /** 产品名称 */ name: string; + /** 所属公司 */ + company: CompanyEntity; + /** 单位 */ + unit: string; /** 是否删除 */ isDelete: string; /** 附件 */ @@ -1567,6 +1572,10 @@ declare namespace API { type ProductDto = { /** 产品名称 */ name: string; + /** 所属公司 */ + companyId?: number; + /** 单位 */ + unit?: string; fileIds?: number[]; }; type ProductUpdateParams = { @@ -1575,6 +1584,7 @@ declare namespace API { type ProductParams = { page?: number; pageSize?: number; + company?:string; field?: string; order?: 'ASC' | 'DESC'; _t?: number; @@ -1585,6 +1595,10 @@ declare namespace API { type ProductUpdateDto = { /** 产品名称 */ name?: string; + /** 所属公司 */ + companyId?: number; + /** 单位 */ + unit?: string; /** 附件 */ fileIds?: number[]; }; diff --git a/src/components/core/schema-form/src/schema-form-item.vue b/src/components/core/schema-form/src/schema-form-item.vue index bc0bfb2..ead3a31 100644 --- a/src/components/core/schema-form/src/schema-form-item.vue +++ b/src/components/core/schema-form/src/schema-form-item.vue @@ -406,16 +406,16 @@ componentProps: { ...unref(getComponentProps), options: [], - }, + } as ComponentProps, }); - const componentProps = newSchema.componentProps as ComponentProps; + // const componentProps = newSchema.componentProps as ComponentProps; updateSchema(newSchema); // @ts-ignore const result = await request({ ...unref(getValues), schema: newSchema }); if (['Select', 'RadioGroup', 'CheckBoxGroup'].some((n) => n === component)) { - componentProps.options = result; + newSchema.componentProps.options = result; } else if (['TreeSelect', 'Tree'].some((n) => n === component)) { - componentProps.treeData = result; + newSchema.componentProps.treeData = result; } if (newSchema.componentProps) { newSchema.componentProps.requestResult = result; diff --git a/src/views/demos/tables/edit-row-table/columns.tsx b/src/views/demos/tables/edit-row-table/columns.tsx index bef4fbb..7dd1a4c 100644 --- a/src/views/demos/tables/edit-row-table/columns.tsx +++ b/src/views/demos/tables/edit-row-table/columns.tsx @@ -44,6 +44,8 @@ export const columns: TableColumn[] = [ formItemProps: { component: 'Select', componentProps: ({ formInstance, formModel }) => ({ + showSearch: true, + filterOption: false, options: [ { label: '男', diff --git a/src/views/meterials-inventory/in-out/columns.tsx b/src/views/meterials-inventory/in-out/columns.tsx index a93c61f..a765eac 100644 --- a/src/views/meterials-inventory/in-out/columns.tsx +++ b/src/views/meterials-inventory/in-out/columns.tsx @@ -1,5 +1,4 @@ import type { TableColumn } from '@/components/core/dynamic-table'; -import { ContractStatusEnum } from '@/enums/contractEnum'; import { DictEnum } from '@/enums/dictEnum'; import { MaterialsInOutEnum } from '@/enums/materialsInventoryEnum'; import { useDictStore } from '@/store/modules/dict'; @@ -40,7 +39,6 @@ export const baseColumns: TableColumnItem[] = [ title: '入库/出库', width: 80, dataIndex: 'inOrOut', - fixed: 'right', formItemProps: { component: 'Select', componentProps: { diff --git a/src/views/meterials-inventory/in-out/formSchemas.ts b/src/views/meterials-inventory/in-out/formSchemas.ts index ac2997e..3b3ecd1 100644 --- a/src/views/meterials-inventory/in-out/formSchemas.ts +++ b/src/views/meterials-inventory/in-out/formSchemas.ts @@ -2,9 +2,7 @@ import type { FormSchema } from '@/components/core/schema-form/'; import { ContractStatusEnum } from '@/enums/contractEnum'; import { formatStatus } from './columns'; -export const contractSchemas = ( - contractTypes: API.DictItemEntity[], -): FormSchema[] => [ +export const formSchemas: FormSchema[] = [ // { // field: 'contractNumber', // component: 'Input', @@ -23,7 +21,6 @@ export const contractSchemas = ( // span: 12, // }, // }, - // { // field: 'partyA', // component: 'Input', @@ -42,7 +39,6 @@ export const contractSchemas = ( // span: 12, // }, // }, - // { // field: 'signingDate', // label: '签订时间', diff --git a/src/views/meterials-inventory/in-out/index.vue b/src/views/meterials-inventory/in-out/index.vue index 0508e19..cf1d717 100644 --- a/src/views/meterials-inventory/in-out/index.vue +++ b/src/views/meterials-inventory/in-out/index.vue @@ -40,7 +40,6 @@ const [fnModal] = useModal(); const isUploadPopupVisiable = ref(false); - // contractList; let columns = ref(); onMounted(() => { columns.value = [ diff --git a/src/views/meterials-inventory/product/columns.tsx b/src/views/meterials-inventory/product/columns.tsx index 830642d..56936c3 100644 --- a/src/views/meterials-inventory/product/columns.tsx +++ b/src/views/meterials-inventory/product/columns.tsx @@ -1,10 +1,18 @@ +import Api from '@/api'; import type { TableColumn } from '@/components/core/dynamic-table'; export type TableListItem = API.ProductEntity; export type TableColumnItem = TableColumn; export const baseColumns: TableColumnItem[] = [ { - title: '产品名称', + title: '名称', dataIndex: 'name', }, + { + title: '所属公司', + dataIndex: 'company', + customRender: ({ record }) => { + return record?.company?.name || ''; + }, + }, ]; diff --git a/src/views/meterials-inventory/product/formSchemas.ts b/src/views/meterials-inventory/product/formSchemas.ts index 62d7f35..03d8371 100644 --- a/src/views/meterials-inventory/product/formSchemas.ts +++ b/src/views/meterials-inventory/product/formSchemas.ts @@ -1,5 +1,8 @@ +import Api from '@/api'; import type { FormSchema } from '@/components/core/schema-form/'; -export const formSchemas: FormSchema[] = [ +import { debounce } from 'lodash-es'; +import { nextTick, toRaw } from 'vue'; +export const formSchemas: FormSchema[] = [ { field: 'name', component: 'Input', @@ -9,4 +12,75 @@ export const formSchemas: FormSchema[] = [ span: 12, }, }, + { + field: 'companyId', + component: 'Select', + label: '所属公司', + // componentProps: { + // request: async () => { + // const { items: result } = await Api.company.companyList({ pageSize: 100 }); + // return result?.map((item) => ({ label: item.name, value: item.id })); + // }, + // }, + componentProps: ({ formInstance, schema }) => ({ + showSearch: true, + filterOption: false, + fieldNames: { + label: 'label', + value: 'value', + }, + options: [], + getPopupContainer: () => document.body, + defaultActiveFirstOption: true, + onChange: async (value, option) => { + console.log('onChange'); + if (!value) { + formInstance?.setFieldsValue({ companyId: undefined }); + const { items: result } = await Api.company.companyList({ pageSize: 100 }); + const newSchema = { + field: schema.field, + componentProps: { + options: result?.map((item) => ({ label: item.name, value: item.id })), + }, + }; + formInstance?.updateSchema([newSchema]); + } + }, + + request: () => { + return getCompanyOptions(); + + }, + onSearch: debounce(async (keyword) => { + schema.loading = true; + const newSchema = { + field: schema.field, + componentProps: { + options: [] as LabelValueOptions, + }, + }; + formInstance?.updateSchema([newSchema]); + const { items: result } = await Api.company + .companyList({ pageSize: 100, name: keyword }) + .finally(() => (schema.loading = false)); + if (result) { + newSchema.componentProps.options = result.map((item) => ({ + value: item.id, + label: item.name, + })); + } + formInstance?.updateSchema([newSchema]); + }, 500), + }), + }, ]; + +const getCompanyOptions = async (keyword?): Promise => { + const { items: result } = await Api.company.companyList({ pageSize: 100 }); + return ( + result?.map((item) => ({ + label: item.name, + value: item.id, + })) || [] + ); +}; diff --git a/src/views/meterials-inventory/product/index.vue b/src/views/meterials-inventory/product/index.vue index 05be11b..3c9ca22 100644 --- a/src/views/meterials-inventory/product/index.vue +++ b/src/views/meterials-inventory/product/index.vue @@ -23,7 +23,7 @@