优化文档列表
This commit is contained in:
@@ -45,6 +45,8 @@ export interface DocumentSearchParams {
|
||||
documentNumber?: string;
|
||||
documentType?: string;
|
||||
status?: string;
|
||||
auditStatus?: string;
|
||||
fileStatus?: string;
|
||||
dateFrom?: string;
|
||||
dateTo?: string;
|
||||
page?: number;
|
||||
@@ -123,7 +125,7 @@ async function convertToUIDocument(doc: Document): Promise<DocumentUI> {
|
||||
typeName: docType?.name || '未知类型',
|
||||
size: doc.file_size,
|
||||
auditStatus: doc.audit_status,
|
||||
fileStatus: doc.file_status || 'Processed', // 默认为已处理
|
||||
fileStatus: doc.status || '', // 默认为''
|
||||
issues: 0, // 固定为0
|
||||
uploadTime: formatDate(doc.updated_at),
|
||||
fileType: getFileExtension(doc.name),
|
||||
@@ -173,20 +175,35 @@ export async function getDocuments(searchParams: DocumentSearchParams = {}): Pro
|
||||
filter['type_id'] = `eq.${searchParams.documentType}`;
|
||||
}
|
||||
|
||||
if (searchParams.status) {
|
||||
filter['status'] = `eq.${searchParams.status}`;
|
||||
if (searchParams.auditStatus) {
|
||||
filter['audit_status'] = `eq.${searchParams.auditStatus}`;
|
||||
}
|
||||
|
||||
if (searchParams.fileStatus) {
|
||||
filter['status'] = `eq.${searchParams.fileStatus}`;
|
||||
}
|
||||
|
||||
// 处理日期范围
|
||||
if (searchParams.dateFrom) {
|
||||
filter['updated_at'] = `gte.${searchParams.dateFrom}`;
|
||||
// 添加当天开始时间 00:00:00
|
||||
filter['created_at'] = `gte.'${searchParams.dateFrom} 00:00:00'`;
|
||||
}
|
||||
|
||||
if (searchParams.dateTo) {
|
||||
const dateToKey = searchParams.dateFrom ? 'and.updated_at.lte' : 'updated_at';
|
||||
filter[dateToKey] = `lte.${searchParams.dateTo}`;
|
||||
// 如果有开始日期,使用and条件;否则直接设置结束日期
|
||||
const dateToKey = searchParams.dateFrom ? 'and' : 'created_at';
|
||||
|
||||
// 添加当天结束时间 23:59:59
|
||||
if (dateToKey === 'and') {
|
||||
delete filter['created_at'];
|
||||
// 使用OR操作符连接两个条件
|
||||
filter[dateToKey] = `(created_at.gte.'${dayjs(searchParams.dateFrom).format()}',created_at.lte.'${dayjs(searchParams.dateTo).format()}')`;
|
||||
} else {
|
||||
filter['created_at'] = `lte.'${dayjs(searchParams.dateTo).format()}'`;
|
||||
}
|
||||
}
|
||||
|
||||
console.log('filter-----', filter);
|
||||
params.filter = filter;
|
||||
|
||||
// 发送请求
|
||||
@@ -204,7 +221,7 @@ export async function getDocuments(searchParams: DocumentSearchParams = {}): Pro
|
||||
|
||||
// 转换为UI格式
|
||||
const documents = await Promise.all(extractedData.map(convertToUIDocument));
|
||||
|
||||
// console.log('documentsItem',documents)
|
||||
// 获取总数
|
||||
let totalCount = 0;
|
||||
const responseWithHeaders = response as {
|
||||
|
||||
Reference in New Issue
Block a user