修改时间范围组件,评查详情创建新的数据结构来适配新的返回格式
This commit is contained in:
@@ -251,7 +251,7 @@ export async function getReviewPoints(fileId: string) {
|
||||
}
|
||||
|
||||
// 提取页码数组
|
||||
let contentPage: Record<string, number[]> = {};
|
||||
let contentPage: Record<string, object> = {};
|
||||
// console.log('result-------', result.evaluated_results?.result);
|
||||
// console.log('datacontent-------', data);
|
||||
if (data && typeof data === 'object') {
|
||||
@@ -296,7 +296,17 @@ export async function getReviewPoints(fileId: string) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
// // 4-22 更改数据结构:通过拿到的data数据(每一个key对应一个object),将object中的page提取出来
|
||||
// try{
|
||||
// const dataObj = data as Record<string, object>;
|
||||
// for (const key in dataObj) {
|
||||
// if (Object.prototype.hasOwnProperty.call(dataObj, key)) {
|
||||
// contentPage[key] = dataObj[key];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
catch (e) {
|
||||
console.error('解析评查点data失败:', e);
|
||||
contentPage = {};
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { postgrestGet, postgrestPut, type PostgrestParams } from '../postgrest-client';
|
||||
import dayjs from 'dayjs';
|
||||
// import dayjs from 'dayjs';
|
||||
import { getDocumentTypes } from '../document-types/document-types';
|
||||
import type { DocumentTypeUI } from '../document-types/document-types';
|
||||
import weekday from 'dayjs/plugin/weekday';
|
||||
import updateLocale from 'dayjs/plugin/updateLocale';
|
||||
// import weekday from 'dayjs/plugin/weekday';
|
||||
// import updateLocale from 'dayjs/plugin/updateLocale';
|
||||
import { formatDate } from '../../utils';
|
||||
|
||||
// 配置 dayjs
|
||||
dayjs.extend(weekday);
|
||||
dayjs.extend(updateLocale);
|
||||
// 设置一周的第一天为周一
|
||||
dayjs.updateLocale('en', {
|
||||
weekStart: 1
|
||||
});
|
||||
// // 配置 dayjs
|
||||
// dayjs.extend(weekday);
|
||||
// dayjs.extend(updateLocale);
|
||||
// // 设置一周的第一天为周一
|
||||
// dayjs.updateLocale('en', {
|
||||
// weekStart: 1
|
||||
// });
|
||||
|
||||
// 文档数据库表接口
|
||||
export interface Document {
|
||||
@@ -79,7 +79,9 @@ export interface ReviewFileUI {
|
||||
export interface DocumentSearchParams {
|
||||
fileType?: string; // 文件类型ID
|
||||
reviewStatus?: string; // 评查状态
|
||||
dateRange?: string; // 日期范围
|
||||
// dateRange?: string; // 日期范围
|
||||
dateFrom?: string; // 开始日期
|
||||
dateTo?: string; // 结束日期
|
||||
keyword?: string; // 搜索关键字
|
||||
sortOrder?: string; // 排序方式
|
||||
page?: number; // 当前页码
|
||||
@@ -277,28 +279,41 @@ export async function getReviewFiles(searchParams: DocumentSearchParams = {}): P
|
||||
}
|
||||
|
||||
// 处理日期范围筛选
|
||||
if (searchParams.dateRange) {
|
||||
const now = dayjs();
|
||||
const today = now.startOf('day').format('YYYY-MM-DD HH:mm:ss');
|
||||
switch (searchParams.dateRange) {
|
||||
case 'today':
|
||||
filter['created_at'] = `gte.${today}`;
|
||||
break;
|
||||
case 'week': {
|
||||
const weekStart = now.startOf('week').format('YYYY-MM-DD HH:mm:ss');
|
||||
filter['created_at'] = `gte.${weekStart}`;
|
||||
break;
|
||||
}
|
||||
case 'month': {
|
||||
const monthStart = now.startOf('month').format('YYYY-MM-DD HH:mm:ss');
|
||||
filter['created_at'] = `gte.${monthStart}`;
|
||||
break;
|
||||
}
|
||||
if(searchParams.dateFrom){
|
||||
filter['created_at'] = `gte.${searchParams.dateFrom+ ' 00:00:00'}`;
|
||||
}
|
||||
|
||||
if(searchParams.dateTo){
|
||||
const dateToKey = searchParams.dateFrom ? 'and' : 'created_at';
|
||||
if(dateToKey === 'and'){
|
||||
delete filter['created_at'];
|
||||
filter[dateToKey] = `(created_at.gte.${searchParams.dateFrom+' 00:00:00'},created_at.lte.${searchParams.dateTo+' 23:59:59'})`;
|
||||
}else{
|
||||
filter['created_at'] = `lte.${searchParams.dateTo+' 23:59:59'}`;
|
||||
}
|
||||
}
|
||||
// if (searchParams.dateRange) {
|
||||
// const now = dayjs();
|
||||
// const today = now.startOf('day').format('YYYY-MM-DD HH:mm:ss');
|
||||
// switch (searchParams.dateRange) {
|
||||
// case 'today':
|
||||
// filter['created_at'] = `gte.${today}`;
|
||||
// break;
|
||||
// case 'week': {
|
||||
// const weekStart = now.startOf('week').format('YYYY-MM-DD HH:mm:ss');
|
||||
// filter['created_at'] = `gte.${weekStart}`;
|
||||
// break;
|
||||
// }
|
||||
// case 'month': {
|
||||
// const monthStart = now.startOf('month').format('YYYY-MM-DD HH:mm:ss');
|
||||
// filter['created_at'] = `gte.${monthStart}`;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// console.log('filter-----',filter);
|
||||
params.filter = filter;
|
||||
console.log('params-----',params);
|
||||
|
||||
// 发送API请求获取文档列表
|
||||
const response = await postgrestGet<Document[]>('documents', params);
|
||||
|
||||
Reference in New Issue
Block a user