feat: 产品模块

This commit is contained in:
louis 2024-03-05 13:56:51 +08:00
parent b491933e4b
commit 11f9c58ee1
10 changed files with 121 additions and 19 deletions

View File

@ -5,7 +5,7 @@
<meta name="referrer" content="origin" /> <meta name="referrer" content="origin" />
<link rel="icon" href="/favicon.ico" /> <link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="user-scalable=yes" /> <meta name="viewport" content="user-scalable=yes" />
<title>华信办公系统</title> <title>华信办公</title>
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>

View File

@ -1536,6 +1536,7 @@ declare namespace API {
type CompanyParams = { type CompanyParams = {
page?: number; page?: number;
pageSize?: number; pageSize?: number;
name?:string;
field?: string; field?: string;
order?: 'ASC' | 'DESC'; order?: 'ASC' | 'DESC';
_t?: number; _t?: number;
@ -1556,6 +1557,10 @@ declare namespace API {
type ProductEntity = { type ProductEntity = {
/** 产品名称 */ /** 产品名称 */
name: string; name: string;
/** 所属公司 */
company: CompanyEntity;
/** 单位 */
unit: string;
/** 是否删除 */ /** 是否删除 */
isDelete: string; isDelete: string;
/** 附件 */ /** 附件 */
@ -1567,6 +1572,10 @@ declare namespace API {
type ProductDto = { type ProductDto = {
/** 产品名称 */ /** 产品名称 */
name: string; name: string;
/** 所属公司 */
companyId?: number;
/** 单位 */
unit?: string;
fileIds?: number[]; fileIds?: number[];
}; };
type ProductUpdateParams = { type ProductUpdateParams = {
@ -1575,6 +1584,7 @@ declare namespace API {
type ProductParams = { type ProductParams = {
page?: number; page?: number;
pageSize?: number; pageSize?: number;
company?:string;
field?: string; field?: string;
order?: 'ASC' | 'DESC'; order?: 'ASC' | 'DESC';
_t?: number; _t?: number;
@ -1585,6 +1595,10 @@ declare namespace API {
type ProductUpdateDto = { type ProductUpdateDto = {
/** 产品名称 */ /** 产品名称 */
name?: string; name?: string;
/** 所属公司 */
companyId?: number;
/** 单位 */
unit?: string;
/** 附件 */ /** 附件 */
fileIds?: number[]; fileIds?: number[];
}; };

View File

@ -406,16 +406,16 @@
componentProps: { componentProps: {
...unref(getComponentProps), ...unref(getComponentProps),
options: [], options: [],
}, } as ComponentProps,
}); });
const componentProps = newSchema.componentProps as ComponentProps; // const componentProps = newSchema.componentProps as ComponentProps;
updateSchema(newSchema); updateSchema(newSchema);
// @ts-ignore // @ts-ignore
const result = await request({ ...unref(getValues), schema: newSchema }); const result = await request({ ...unref(getValues), schema: newSchema });
if (['Select', 'RadioGroup', 'CheckBoxGroup'].some((n) => n === component)) { if (['Select', 'RadioGroup', 'CheckBoxGroup'].some((n) => n === component)) {
componentProps.options = result; newSchema.componentProps.options = result;
} else if (['TreeSelect', 'Tree'].some((n) => n === component)) { } else if (['TreeSelect', 'Tree'].some((n) => n === component)) {
componentProps.treeData = result; newSchema.componentProps.treeData = result;
} }
if (newSchema.componentProps) { if (newSchema.componentProps) {
newSchema.componentProps.requestResult = result; newSchema.componentProps.requestResult = result;

View File

@ -44,6 +44,8 @@ export const columns: TableColumn<ListItemType>[] = [
formItemProps: { formItemProps: {
component: 'Select', component: 'Select',
componentProps: ({ formInstance, formModel }) => ({ componentProps: ({ formInstance, formModel }) => ({
showSearch: true,
filterOption: false,
options: [ options: [
{ {
label: '男', label: '男',

View File

@ -1,5 +1,4 @@
import type { TableColumn } from '@/components/core/dynamic-table'; import type { TableColumn } from '@/components/core/dynamic-table';
import { ContractStatusEnum } from '@/enums/contractEnum';
import { DictEnum } from '@/enums/dictEnum'; import { DictEnum } from '@/enums/dictEnum';
import { MaterialsInOutEnum } from '@/enums/materialsInventoryEnum'; import { MaterialsInOutEnum } from '@/enums/materialsInventoryEnum';
import { useDictStore } from '@/store/modules/dict'; import { useDictStore } from '@/store/modules/dict';
@ -40,7 +39,6 @@ export const baseColumns: TableColumnItem[] = [
title: '入库/出库', title: '入库/出库',
width: 80, width: 80,
dataIndex: 'inOrOut', dataIndex: 'inOrOut',
fixed: 'right',
formItemProps: { formItemProps: {
component: 'Select', component: 'Select',
componentProps: { componentProps: {

View File

@ -2,9 +2,7 @@ import type { FormSchema } from '@/components/core/schema-form/';
import { ContractStatusEnum } from '@/enums/contractEnum'; import { ContractStatusEnum } from '@/enums/contractEnum';
import { formatStatus } from './columns'; import { formatStatus } from './columns';
export const contractSchemas = ( export const formSchemas: FormSchema<API.ContractEntity>[] = [
contractTypes: API.DictItemEntity[],
): FormSchema<API.ContractEntity>[] => [
// { // {
// field: 'contractNumber', // field: 'contractNumber',
// component: 'Input', // component: 'Input',
@ -23,7 +21,6 @@ export const contractSchemas = (
// span: 12, // span: 12,
// }, // },
// }, // },
// { // {
// field: 'partyA', // field: 'partyA',
// component: 'Input', // component: 'Input',
@ -42,7 +39,6 @@ export const contractSchemas = (
// span: 12, // span: 12,
// }, // },
// }, // },
// { // {
// field: 'signingDate', // field: 'signingDate',
// label: '签订时间', // label: '签订时间',

View File

@ -40,7 +40,6 @@
const [fnModal] = useModal(); const [fnModal] = useModal();
const isUploadPopupVisiable = ref(false); const isUploadPopupVisiable = ref(false);
// contractList;
let columns = ref<TableColumnItem[]>(); let columns = ref<TableColumnItem[]>();
onMounted(() => { onMounted(() => {
columns.value = [ columns.value = [

View File

@ -1,10 +1,18 @@
import Api from '@/api';
import type { TableColumn } from '@/components/core/dynamic-table'; import type { TableColumn } from '@/components/core/dynamic-table';
export type TableListItem = API.ProductEntity; export type TableListItem = API.ProductEntity;
export type TableColumnItem = TableColumn<TableListItem>; export type TableColumnItem = TableColumn<TableListItem>;
export const baseColumns: TableColumnItem[] = [ export const baseColumns: TableColumnItem[] = [
{ {
title: '产品名称', title: '名称',
dataIndex: 'name', dataIndex: 'name',
}, },
{
title: '所属公司',
dataIndex: 'company',
customRender: ({ record }) => {
return record?.company?.name || '';
},
},
]; ];

View File

@ -1,5 +1,8 @@
import Api from '@/api';
import type { FormSchema } from '@/components/core/schema-form/'; import type { FormSchema } from '@/components/core/schema-form/';
export const formSchemas: FormSchema<API.CompanyEntity>[] = [ import { debounce } from 'lodash-es';
import { nextTick, toRaw } from 'vue';
export const formSchemas: FormSchema<API.ProductDto>[] = [
{ {
field: 'name', field: 'name',
component: 'Input', component: 'Input',
@ -9,4 +12,75 @@ export const formSchemas: FormSchema<API.CompanyEntity>[] = [
span: 12, 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<LabelValueOptions> => {
const { items: result } = await Api.company.companyList({ pageSize: 100 });
return (
result?.map((item) => ({
label: item.name,
value: item.id,
})) || []
);
};

View File

@ -23,7 +23,7 @@
</template> </template>
<script setup lang="tsx"> <script setup lang="tsx">
import { useTable } from '@/components/core/dynamic-table'; import { useTable, type LoadDataParams } from '@/components/core/dynamic-table';
import { baseColumns, type TableColumnItem, type TableListItem } from './columns'; import { baseColumns, type TableColumnItem, type TableListItem } from './columns';
import Api from '@/api/'; import Api from '@/api/';
import { useFormModal, useModal } from '@/hooks/useModal'; import { useFormModal, useModal } from '@/hooks/useModal';
@ -41,8 +41,19 @@ import { useDictStore } from '@/store/modules/dict';
const [fnModal] = useModal(); const [fnModal] = useModal();
const isUploadPopupVisiable = ref(false); const isUploadPopupVisiable = ref(false);
const dictStore = useDictStore(); const dictStore = useDictStore();
// productList;
let columns = ref<TableColumnItem[]>(); let columns = ref<TableColumnItem[]>();
// const loadData = async (params): Promise<API.ProductEntity> => {
// console.log('params', params);
// return Api.product.productList(params);
// };
// const loadTableData = async (params: any) => {
// const { company, ...res } = params;
// const data = await Api.product.productList({
// ...res,
// company,
// });
// return data;
// };
onMounted(() => { onMounted(() => {
columns.value = [ columns.value = [
...baseColumns, ...baseColumns,