diff --git a/src/api/backend/api/company.ts b/src/api/backend/api/company.ts new file mode 100644 index 0000000..7ec4e40 --- /dev/null +++ b/src/api/backend/api/company.ts @@ -0,0 +1,104 @@ +import { request, type RequestOptions } from '@/utils/request'; + +/** 获取公司列表 GET /api/company */ +export async function companyList(params: API.CompanyParams, options?: RequestOptions) { + return request<{ + items?: API.CompanyEntity[]; + meta?: { + itemCount?: number; + totalItems?: number; + itemsPerPage?: number; + totalPages?: number; + currentPage?: number; + }; + }>('/api/company', { + method: 'GET', + params: { + // page has a default value: 1 + page: '1', + // pageSize has a default value: 10 + pageSize: '10', + + ...params, + }, + ...(options || {}), + }); +} + +/** 新增公司 POST /api/company */ +export async function companyCreate(body: API.CompanyDto, options?: RequestOptions) { + return request('/api/company', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || { successMsg: '创建成功' }), + }); +} + +/** 获取公司信息 GET /api/company/${param0} */ +export async function companyInfo( + // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) + params: API.CompanyInfoParams, + options?: RequestOptions, +) { + const { id: param0, ...queryParams } = params; + return request(`/api/company/${param0}`, { + method: 'GET', + params: { ...queryParams }, + ...(options || {}), + }); +} + +/** 解除公司和附件关联 PUT /api/company/unlink-attachments/${param0} */ +export async function unlinkAttachments( + // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) + params: API.CompanyUpdateParams, + body: API.CompanyUpdateDto, + options?: RequestOptions, +) { + const { id: param0, ...queryParams } = params; + return request(`/api/company/unlink-attachments/${param0}`, { + method: 'PUT', + headers: { + 'Content-Type': 'application/json', + }, + params: { ...queryParams }, + data: body, + ...options, + }); +} + +/** 更新公司 PUT /api/company/${param0} */ +export async function companyUpdate( + // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) + params: API.CompanyUpdateParams, + body: API.CompanyUpdateDto, + options?: RequestOptions, +) { + const { id: param0, ...queryParams } = params; + return request(`/api/company/${param0}`, { + method: 'PUT', + headers: { + 'Content-Type': 'application/json', + }, + params: { ...queryParams }, + data: body, + ...(options || { successMsg: '更新成功' }), + }); +} + +/** 删除公司 DELETE /api/company/${param0} */ +export async function companyDelete( + // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) + params: API.CompanyDeleteParams, + options?: RequestOptions, +) { + const { id: param0, ...queryParams } = params; + return request(`/api/company/${param0}`, { + method: 'DELETE', + params: { ...queryParams }, + ...(options || { successMsg: '删除成功' }), + }); +} diff --git a/src/api/backend/api/index.ts b/src/api/backend/api/index.ts index e4a049a..3bc796a 100644 --- a/src/api/backend/api/index.ts +++ b/src/api/backend/api/index.ts @@ -27,6 +27,7 @@ import * as netDiskOverview from './netDiskOverview'; import * as businessTodo from './businessTodo'; import * as contract from './contract'; import * as materialsInventory from './materialsInventory'; +import * as company from './company'; export default { auth, @@ -53,5 +54,6 @@ export default { netDiskOverview, businessTodo, contract, - materialsInventory + materialsInventory, + company, }; diff --git a/src/api/backend/api/typings.d.ts b/src/api/backend/api/typings.d.ts index 040acf2..75ea030 100644 --- a/src/api/backend/api/typings.d.ts +++ b/src/api/backend/api/typings.d.ts @@ -1417,7 +1417,7 @@ declare namespace API { /** 备注 */ remark: string; /** 附件 */ - files: number[]; + files: StorageInfo[]; id: number; createdAt: string; updatedAt: string; @@ -1464,7 +1464,7 @@ declare namespace API { /** 备注 */ remark: string; /** 附件 */ - files: number[]; + files: StorageInfo[]; }; type MaterialsInventoryUpdateDto = { /** 公司名称 */ @@ -1508,9 +1508,48 @@ declare namespace API { /** 备注 */ remark: string; /** 附件 */ - files: number[]; + fileIds: number[]; }; type MaterialsInventoryDeleteParams = { id: number; }; + type CompanyEntity = { + /** 公司名称 */ + name: string; + /** 是否删除 */ + isDelete: string; + /** 附件 */ + files?: StorageInfo[]; + id: number; + createdAt: string; + updatedAt: string; + }; + type CompanyDto = { + /** 公司名称 */ + name: string; + fileIds?: number[]; + }; + type CompanyUpdateParams = { + id: number; + }; + type CompanyParams = { + page?: number; + pageSize?: number; + field?: string; + order?: 'ASC' | 'DESC'; + _t?: number; + }; + type CompanyInfoParams = { + id: number; + }; + type CompanyUpdateDto = { + /** 公司名称 */ + name?: string; + /** 附件 */ + fileIds?: number[]; + }; + type CompanyDeleteParams = { + id: number; + }; + } diff --git a/src/permission/permCode.ts b/src/permission/permCode.ts index 3fcc1c7..d324ccb 100644 --- a/src/permission/permCode.ts +++ b/src/permission/permCode.ts @@ -72,10 +72,19 @@ const permissions = [ "netdisk:manage:cut", "netdisk:overview:desc", "app:contract:list", + "app:materials_inventory:list", "app:contract:update", "app:contract:delete", "app:contract:read", - "app:contract:create" + "app:contract:create", + "app:materials_inventory:create", + "app:materials_inventory:update", + "app:materials_inventory:delete", + "app:company:list", + "app:company:read", + "app:company:create", + "app:company:update", + "app:company:delete" ] as const; export type PermissionType = (typeof permissions)[number]; diff --git a/src/views/company/columns.tsx b/src/views/company/columns.tsx new file mode 100644 index 0000000..e43cf01 --- /dev/null +++ b/src/views/company/columns.tsx @@ -0,0 +1,10 @@ +import type { TableColumn } from '@/components/core/dynamic-table'; + +export type TableListItem = API.CompanyEntity; +export type TableColumnItem = TableColumn; +export const baseColumns: TableColumnItem[] = [ + { + title: '公司名称', + dataIndex: 'name', + }, +]; diff --git a/src/views/company/formSchemas.ts b/src/views/company/formSchemas.ts new file mode 100644 index 0000000..23aa147 --- /dev/null +++ b/src/views/company/formSchemas.ts @@ -0,0 +1,12 @@ +import type { FormSchema } from '@/components/core/schema-form/'; +export const formSchemas: FormSchema[] = [ + { + field: 'name', + component: 'Input', + label: '公司名称', + rules: [{ required: true, type: 'string' }], + colProps: { + span: 12, + }, + }, +]; diff --git a/src/views/company/index.vue b/src/views/company/index.vue new file mode 100644 index 0000000..bcf53dd --- /dev/null +++ b/src/views/company/index.vue @@ -0,0 +1,201 @@ + + + + +