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" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="user-scalable=yes" />
<title>华信办公系统</title>
<title>华信办公</title>
</head>
<body>
<div id="app"></div>

View File

@ -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[];
};

View File

@ -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;

View File

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

View File

@ -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: {

View File

@ -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<API.ContractEntity>[] => [
export const formSchemas: FormSchema<API.ContractEntity>[] = [
// {
// 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: '签订时间',

View File

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

View File

@ -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<TableListItem>;
export const baseColumns: TableColumnItem[] = [
{
title: '产品名称',
title: '名称',
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/';
export const formSchemas: FormSchema<API.CompanyEntity>[] = [
import { debounce } from 'lodash-es';
import { nextTick, toRaw } from 'vue';
export const formSchemas: FormSchema<API.ProductDto>[] = [
{
field: 'name',
component: 'Input',
@ -9,4 +12,75 @@ export const formSchemas: FormSchema<API.CompanyEntity>[] = [
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>
<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 Api from '@/api/';
import { useFormModal, useModal } from '@/hooks/useModal';
@ -41,8 +41,19 @@ import { useDictStore } from '@/store/modules/dict';
const [fnModal] = useModal();
const isUploadPopupVisiable = ref(false);
const dictStore = useDictStore();
// productList;
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(() => {
columns.value = [
...baseColumns,