添加合同和卷宗数据隔离
This commit is contained in:
@@ -37,6 +37,7 @@ export interface DocumentSearchParams {
|
||||
dateTo?: string;
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
reviewType?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -210,7 +211,12 @@ export async function getDocuments(searchParams: DocumentSearchParams = {}): Pro
|
||||
}
|
||||
|
||||
if (searchParams.auditStatus) {
|
||||
filter['audit_status'] = `eq.${searchParams.auditStatus}`;
|
||||
// 处理"待审核"状态 - 特殊处理 audit_status = 0 的情况,同时包含 null 值
|
||||
if (searchParams.auditStatus === '0') {
|
||||
filter['or'] = `(audit_status.eq.0,audit_status.is.null)`;
|
||||
} else {
|
||||
filter['audit_status'] = `eq.${searchParams.auditStatus}`;
|
||||
}
|
||||
}
|
||||
|
||||
if (searchParams.fileStatus) {
|
||||
@@ -236,6 +242,20 @@ export async function getDocuments(searchParams: DocumentSearchParams = {}): Pro
|
||||
}
|
||||
}
|
||||
|
||||
// 根据 reviewType 添加过滤条件
|
||||
if (searchParams.reviewType) {
|
||||
// 如果已经有文档类型过滤,则不再添加 reviewType 的过滤
|
||||
if (!searchParams.documentType) {
|
||||
if (searchParams.reviewType === 'contract') {
|
||||
// 如果是合同类型,只显示 type_id=1 的文档
|
||||
filter['type_id'] = 'eq.1';
|
||||
} else if (searchParams.reviewType === 'record') {
|
||||
// 如果是卷宗类型,只显示 type_id=2 或 type_id=3 的文档
|
||||
filter['type_id'] = 'in.(2,3)';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// console.log('filter-----', filter);
|
||||
params.filter = filter;
|
||||
|
||||
|
||||
@@ -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