添加合同和卷宗数据隔离
This commit is contained in:
@@ -2,7 +2,6 @@ import { postgrestGet, type PostgrestParams } from '../postgrest-client';
|
||||
import dayjs from 'dayjs';
|
||||
// import { API_BASE_URL } from '../client';
|
||||
|
||||
|
||||
/**
|
||||
* 从不同格式的 API 响应中提取数据
|
||||
* @param responseData API 响应数据
|
||||
@@ -222,9 +221,10 @@ export async function uploadDocumentToServer(
|
||||
|
||||
/**
|
||||
* 获取当天的文档列表
|
||||
* @param reviewType 审核类型(可选)
|
||||
* @returns 文档列表
|
||||
*/
|
||||
export async function getTodayDocuments(): Promise<{data: Document[]; error?: never} | {data?: never; error: string; status?: number}> {
|
||||
export async function getTodayDocuments(reviewType?: string): Promise<{data: Document[]; error?: never} | {data?: never; error: string; status?: number}> {
|
||||
try {
|
||||
const today = dayjs().startOf('day').format('YYYY-MM-DD');
|
||||
// console.log('查询当天文档,日期范围:', today);
|
||||
@@ -245,7 +245,8 @@ export async function getTodayDocuments(): Promise<{data: Document[]; error?: ne
|
||||
ocr_result,
|
||||
extracted_results,
|
||||
sumary,
|
||||
remark
|
||||
remark,
|
||||
audit_status
|
||||
`,
|
||||
order: 'created_at.desc',
|
||||
filter: {
|
||||
@@ -253,6 +254,23 @@ export async function getTodayDocuments(): Promise<{data: Document[]; error?: ne
|
||||
}
|
||||
};
|
||||
|
||||
// 根据reviewType添加过滤条件
|
||||
if (reviewType === 'contract') {
|
||||
// 如果是合同类型,只显示type_id=1的文档
|
||||
if (params.filter) {
|
||||
params.filter['type_id'] = 'eq.1';
|
||||
} else {
|
||||
params.filter = { 'type_id': 'eq.1' };
|
||||
}
|
||||
} else if (reviewType === 'record') {
|
||||
// 如果是卷宗类型,只显示type_id=2或type_id=3的文档
|
||||
if (params.filter) {
|
||||
params.filter['type_id'] = 'in.(2,3)';
|
||||
} else {
|
||||
params.filter = { 'type_id': 'in.(2,3)' };
|
||||
}
|
||||
}
|
||||
|
||||
// console.log('发送请求参数:', params);
|
||||
const response = await postgrestGet<Document[]>('documents', params);
|
||||
// console.log('API 响应:', response);
|
||||
@@ -282,14 +300,33 @@ export async function getTodayDocuments(): Promise<{data: Document[]; error?: ne
|
||||
|
||||
/**
|
||||
* 获取文档类型列表
|
||||
* @param reviewType 审核类型(可选)
|
||||
* @returns 文档类型列表
|
||||
*/
|
||||
export async function getDocumentTypes(): Promise<{data: DocumentType[]; error?: never} | {data?: never; error: string; status?: number}> {
|
||||
export async function getDocumentTypes(reviewType?: string): Promise<{data: DocumentType[]; error?: never} | {data?: never; error: string; status?: number}> {
|
||||
try {
|
||||
const params: PostgrestParams = {
|
||||
select: 'id, name'
|
||||
select: 'id, name',
|
||||
filter: {} // 初始化为空对象
|
||||
};
|
||||
|
||||
// 根据reviewType添加过滤条件
|
||||
if (reviewType === 'contract') {
|
||||
// 如果是合同类型,只显示id=1的文档类型
|
||||
if (params.filter) {
|
||||
params.filter['id'] = 'eq.1';
|
||||
} else {
|
||||
params.filter = { 'id': 'eq.1' };
|
||||
}
|
||||
} else if (reviewType === 'record') {
|
||||
// 如果是卷宗类型,只显示id=2或id=3的文档类型
|
||||
if (params.filter) {
|
||||
params.filter['id'] = 'in.(2,3)';
|
||||
} else {
|
||||
params.filter = { 'id': 'in.(2,3)' };
|
||||
}
|
||||
}
|
||||
|
||||
const response = await postgrestGet<DocumentType[]>('document_types', params);
|
||||
|
||||
if (response.error) {
|
||||
|
||||
Reference in New Issue
Block a user