feat: 1. 完善起草合同页面的逻辑交互,对接minio的接口操作

This commit is contained in:
2025-12-05 20:17:37 +08:00
parent 3d1dbb3f97
commit 91b7518c99
21 changed files with 1249 additions and 1057 deletions
+9 -9
View File
@@ -82,7 +82,7 @@ export async function getContractCategories(jwt?: string) {
token: jwt
};
const response = await postgrestGet<ContractCategory[]>('contract_categories', params);
const response = await postgrestGet<ContractCategory[]>('/api/postgrest/proxy/contract_categories', params);
if (response.error) {
return { error: response.error, status: response.status || 500 };
@@ -107,7 +107,7 @@ export async function getContractCategories(jwt?: string) {
export async function getContractCategoriesWithCount(jwt?: string) {
try {
// 获取所有分类
const categoriesResponse = await postgrestGet<ContractCategory[]>('contract_categories', {
const categoriesResponse = await postgrestGet<ContractCategory[]>('/api/postgrest/proxy/contract_categories', {
select: '*',
order: 'sort_order.asc,name.asc',
token: jwt
@@ -124,7 +124,7 @@ export async function getContractCategoriesWithCount(jwt?: string) {
categories.map(async (category) => {
try {
// 简化方案:获取该分类下的所有模板ID,然后计算数量
const countResponse = await postgrestGet<{ id: number }[]>('contract_templates', {
const countResponse = await postgrestGet<{ id: number }[]>('/api/postgrest/proxy/contract_templates', {
select: 'id',
filter: { 'category_id': `eq.${category.id}` },
token: jwt
@@ -214,7 +214,7 @@ export async function getContractTemplates(searchParams: TemplateSearchParams =
// 先查询匹配的分类ID
let matchingCategoryIds: number[] = [];
try {
const categoryResponse = await postgrestGet<ContractCategory[]>('contract_categories', {
const categoryResponse = await postgrestGet<ContractCategory[]>('/api/postgrest/proxy/contract_categories', {
select: 'id',
filter: { 'name': `ilike.*${cleanKeyword}*` },
token
@@ -245,7 +245,7 @@ export async function getContractTemplates(searchParams: TemplateSearchParams =
// 如果有分类名称,需要先获取分类ID
if (category && !category_id) {
const categoryResponse = await postgrestGet<ContractCategory[]>('contract_categories', {
const categoryResponse = await postgrestGet<ContractCategory[]>('/api/postgrest/proxy/contract_categories', {
select: 'id',
filter: { 'name': `eq.${category}` },
token
@@ -264,7 +264,7 @@ export async function getContractTemplates(searchParams: TemplateSearchParams =
}
// 执行查询
const response = await postgrestGet<ContractTemplate[]>('contract_templates', params);
const response = await postgrestGet<ContractTemplate[]>('/api/postgrest/proxy/contract_templates', params);
if (response.error) {
return { error: response.error, status: response.status || 500 };
@@ -280,7 +280,7 @@ export async function getContractTemplates(searchParams: TemplateSearchParams =
token
};
const countResponse = await postgrestGet<{ id: number }[]>('contract_templates', countParams);
const countResponse = await postgrestGet<{ id: number }[]>('/api/postgrest/proxy/contract_templates', countParams);
let total = 0;
if (!countResponse.error && countResponse.data) {
const countData = extractApiData<{ id: number }[]>(countResponse.data) || [];
@@ -318,7 +318,7 @@ export async function getContractTemplate(id: string | number, jwt?: string) {
token: jwt
};
const response = await postgrestGet<ContractTemplate[]>('contract_templates', params);
const response = await postgrestGet<ContractTemplate[]>('/api/postgrest/proxy/contract_templates', params);
if (response.error) {
return { error: response.error, status: response.status || 500 };
@@ -355,7 +355,7 @@ export async function getFeaturedTemplates(limit: number = 6, jwt?: string) {
token: jwt
};
const response = await postgrestGet<ContractTemplate[]>('contract_templates', params);
const response = await postgrestGet<ContractTemplate[]>('/api/postgrest/proxy/contract_templates', params);
if (response.error) {
return { error: response.error, status: response.status || 500 };