新增提示Toast组件
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { postgrestGet, postgrestDelete, postgrestPut, type PostgrestParams } from '../postgrest-client';
|
||||
import dayjs from 'dayjs';
|
||||
import { getDocumentTypes } from '../document-types/document-types';
|
||||
import { formatDate } from '../../utils';
|
||||
|
||||
/**
|
||||
* 从不同格式的 API 响应中提取数据
|
||||
@@ -22,20 +23,6 @@ function extractApiData<T>(responseData: unknown): T | null {
|
||||
return responseData as T;
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化日期
|
||||
* @param dateString 日期字符串
|
||||
* @returns 格式化后的日期字符串
|
||||
*/
|
||||
function formatDate(dateString: string): string {
|
||||
if (!dateString) return '';
|
||||
try {
|
||||
return dayjs(dateString).format('YYYY-MM-DD HH:mm:ss');
|
||||
} catch (error) {
|
||||
console.error('日期格式化失败:', error);
|
||||
return dateString;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询参数
|
||||
@@ -94,7 +81,7 @@ export interface DocumentUI {
|
||||
typeName: string;
|
||||
size: number;
|
||||
auditStatus: number; // -1: 不通过, 0: 待审核, 1: 通过, 2: 警告, 3: 审核中
|
||||
fileStatus: string; // Waiting, Cutting, Extractioning, Evaluationing, Processed
|
||||
fileStatus: string; // Waiting, Cutting, Extractioning, Failed, Evaluationing, Processed
|
||||
issues: number | null;
|
||||
uploadTime: string;
|
||||
fileType: string;
|
||||
@@ -161,6 +148,7 @@ async function convertToUIDocument(doc: Document): Promise<DocumentUI> {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
id: doc.id,
|
||||
name: doc.name,
|
||||
@@ -233,21 +221,19 @@ export async function getDocuments(searchParams: DocumentSearchParams = {}): Pro
|
||||
// 处理日期范围
|
||||
if (searchParams.dateFrom) {
|
||||
// 添加当天开始时间 00:00:00
|
||||
filter['created_at'] = `gte.'${dayjs(`${searchParams.dateFrom} 00:00:00`).format()}'`;
|
||||
filter['created_at'] = `gte.${searchParams.dateFrom + ' 00:00:00'}`;
|
||||
}
|
||||
|
||||
if (searchParams.dateTo) {
|
||||
// 如果有开始日期,使用and条件;否则直接设置结束日期
|
||||
const dateToKey = searchParams.dateFrom ? 'and' : 'created_at';
|
||||
const newDateFrom = dayjs(`${searchParams.dateFrom} 00:00:00`).format();
|
||||
const newDateTo = dayjs(`${searchParams.dateTo} 23:59:59`).format();
|
||||
// 添加当天结束时间 23:59:59
|
||||
if (dateToKey === 'and') {
|
||||
delete filter['created_at'];
|
||||
// 使用OR操作符连接两个条件
|
||||
filter[dateToKey] = `(created_at.gte.'${newDateFrom}',created_at.lte.'${newDateTo}')`;
|
||||
filter[dateToKey] = `(created_at.gte.${searchParams.dateFrom+' 00:00:00'},created_at.lte.${searchParams.dateTo+' 23:59:59'})`;
|
||||
} else {
|
||||
filter['created_at'] = `lte.'${newDateTo}'`;
|
||||
filter['created_at'] = `lte.${searchParams.dateTo+' 23:59:59'}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,6 +253,8 @@ export async function getDocuments(searchParams: DocumentSearchParams = {}): Pro
|
||||
return { error: '获取文档数据失败', status: 500 };
|
||||
}
|
||||
|
||||
// console.log('extractedData---1--',extractedData[0]);
|
||||
|
||||
// 转换为UI格式
|
||||
const documents = await Promise.all(extractedData.map(convertToUIDocument));
|
||||
// console.log('documentsItem',documents)
|
||||
|
||||
@@ -82,6 +82,7 @@ export interface Document {
|
||||
extracted_results?: ExtractedResult;
|
||||
sumary?: Summary;
|
||||
remark?: string;
|
||||
audit_status?: number;
|
||||
}
|
||||
|
||||
// 文件上传响应接口
|
||||
|
||||
Reference in New Issue
Block a user