完善卷宗和合同的数据隔离的效果
This commit is contained in:
@@ -58,6 +58,7 @@ interface AuditStatus {
|
||||
document_id: string | number;
|
||||
evaluation_point_id: string | number;
|
||||
edit_audit_status: number;
|
||||
message: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
@@ -205,13 +206,13 @@ export async function getReviewPoints(fileId: string) {
|
||||
const manualReviewPointsData = extractApiData<AuditStatus[]>(manualReviewPointsResponse.data);
|
||||
|
||||
// 构建评查点ID到editAuditStatus的映射
|
||||
const editAuditStatusMap = new Map<string | number, {id: string | number, status: number}>();
|
||||
const editAuditStatusMap = new Map<string | number, {id: string | number, status: number, message: string}>();
|
||||
|
||||
// 如果有查询结果,则根据evaluation_point_id索引到对应数据
|
||||
if (manualReviewPointsData && Array.isArray(manualReviewPointsData)) {
|
||||
manualReviewPointsData.forEach(auditStatus => {
|
||||
if (auditStatus.evaluation_point_id && auditStatus.edit_audit_status !== undefined) {
|
||||
editAuditStatusMap.set(auditStatus.evaluation_point_id, {id: auditStatus.id, status: auditStatus.edit_audit_status});
|
||||
editAuditStatusMap.set(auditStatus.evaluation_point_id, {id: auditStatus.id, status: auditStatus.edit_audit_status, message: auditStatus.message});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -220,7 +221,7 @@ export async function getReviewPoints(fileId: string) {
|
||||
if (manualReviewPointsIds.length > 0) {
|
||||
manualReviewPointsIds.forEach(pointId => {
|
||||
if (!editAuditStatusMap.has(pointId)) {
|
||||
editAuditStatusMap.set(pointId, {id: '', status: 0});
|
||||
editAuditStatusMap.set(pointId, {id: '', status: 0, message: ''});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -247,7 +248,7 @@ export async function getReviewPoints(fileId: string) {
|
||||
const resultData: ReviewPointResult[] = evaluationResultsData.map(result => {
|
||||
const point = pointsMap.get(result.evaluation_point_id) || {} as EvaluationPoint;
|
||||
const group = groupsMap.get(point.evaluation_point_groups_id || 0) || {} as EvaluationPointGroup;
|
||||
const editAuditStatus = editAuditStatusMap.get(result.evaluation_point_id) || {id: '', status: 0};
|
||||
const editAuditStatus = editAuditStatusMap.get(result.evaluation_point_id) || {id: '', status: 0, message: ''};
|
||||
|
||||
// 评查结果内容改成由evaluated_point_results_log中获取
|
||||
const evaluatedPointResultsLog = result.evaluated_point_results_log || {};
|
||||
@@ -304,6 +305,7 @@ export async function getReviewPoints(fileId: string) {
|
||||
pointId: point.id,
|
||||
editAuditStatusId: editAuditStatus.id,
|
||||
editAuditStatus: editAuditStatus.status,
|
||||
editAuditStatusMessage: editAuditStatus.message,
|
||||
title: message,
|
||||
pointName: point.name || '',
|
||||
groupName: group.name || '',
|
||||
@@ -667,8 +669,8 @@ export async function updateReviewResult(resultId: string, editAuditStatusId: st
|
||||
// 构建要更新的数据,保留原有字段
|
||||
const updatedEvaluatedResults = {
|
||||
...currentEvaluatedResults,
|
||||
// 如果是重新审核操作,不更新result,只更新message
|
||||
...(isReview ? { message } : { result: result === 'true' ? true : false, message }),
|
||||
// 如果是重新审核操作,不更新result和message
|
||||
...(isReview ? {} : { result: result === 'true' ? true : false, message }),
|
||||
};
|
||||
|
||||
const updatedData = {
|
||||
@@ -696,7 +698,11 @@ export async function updateReviewResult(resultId: string, editAuditStatusId: st
|
||||
// 更新现有审核状态记录
|
||||
const auditStatusResponse = await postgrestPut(
|
||||
'audit_status',
|
||||
{ edit_audit_status: editAuditStatusValue },
|
||||
{
|
||||
edit_audit_status: editAuditStatusValue,
|
||||
// 重新审核时不更新message
|
||||
...(isReview ? {} : { message })
|
||||
},
|
||||
{ id: editAuditStatusId }
|
||||
);
|
||||
|
||||
@@ -714,7 +720,8 @@ export async function updateReviewResult(resultId: string, editAuditStatusId: st
|
||||
document_id: documentId,
|
||||
evaluation_point_id: evaluationPointId,
|
||||
evaluation_result_id: resultId,
|
||||
edit_audit_status: editAuditStatusValue
|
||||
edit_audit_status: editAuditStatusValue,
|
||||
message: isReview ? '' : message
|
||||
};
|
||||
|
||||
// 使用postgrestPost创建新记录
|
||||
|
||||
@@ -267,11 +267,12 @@ export async function getReviewFiles(searchParams: DocumentSearchParams = {}): P
|
||||
|
||||
// 处理文件类型筛选
|
||||
if (searchParams.fileType) {
|
||||
// console.log('API处理文件类型筛选:', searchParams.fileType);
|
||||
// 特殊处理 'record' 类型,表示 type_id 为 2 或 3
|
||||
if (searchParams.fileType === 'record') {
|
||||
filter['type_id'] = 'in.(2,3)';
|
||||
} else {
|
||||
filter['type_id'] = `eq.${searchParams.fileType}`;
|
||||
filter['type_id'] = `eq.${Number(searchParams.fileType)}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,7 +320,7 @@ export async function getReviewFiles(searchParams: DocumentSearchParams = {}): P
|
||||
// }
|
||||
|
||||
params.filter = filter;
|
||||
// console.log('params-----',params);
|
||||
// console.log('API请求参数:', params);
|
||||
|
||||
// 发送API请求获取文档列表
|
||||
const response = await postgrestGet<Document[]>('documents', params);
|
||||
|
||||
@@ -34,6 +34,7 @@ export interface RulesQueryParams {
|
||||
keyword?: string;
|
||||
orderBy?: string;
|
||||
orderDirection?: 'asc' | 'desc';
|
||||
reviewType?: string; // 添加 reviewType 参数,值为 contract 或 record
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -162,7 +163,8 @@ export async function getRulesList(params: RulesQueryParams): Promise<{data: Rul
|
||||
isActive,
|
||||
keyword,
|
||||
orderBy = 'created_at',
|
||||
orderDirection = 'desc'
|
||||
orderDirection = 'desc',
|
||||
reviewType
|
||||
} = params;
|
||||
|
||||
// 构建PostgrestParams参数
|
||||
@@ -204,6 +206,46 @@ export async function getRulesList(params: RulesQueryParams): Promise<{data: Rul
|
||||
postgrestParams.filter!['is_enabled'] = `eq.${isActive}`;
|
||||
}
|
||||
|
||||
// 根据reviewType添加过滤条件
|
||||
if (reviewType) {
|
||||
try {
|
||||
// 先获取所有评查点组数据,用于找到对应的pid
|
||||
const groupsAllResponse = await postgrestGet<{code: number; msg: string; data: Array<{id: number; pid: number}>}>('evaluation_point_groups', {
|
||||
select: 'id,pid'
|
||||
});
|
||||
|
||||
let groups: Array<{id: number; pid: number}> = [];
|
||||
|
||||
if (!groupsAllResponse.error) {
|
||||
if (groupsAllResponse.data && 'code' in groupsAllResponse.data && groupsAllResponse.data.data) {
|
||||
groups = groupsAllResponse.data.data;
|
||||
} else if (Array.isArray(groupsAllResponse.data)) {
|
||||
groups = groupsAllResponse.data;
|
||||
}
|
||||
}
|
||||
|
||||
// 根据reviewType过滤pid
|
||||
let pidList: number[] = [];
|
||||
|
||||
if (reviewType === 'contract') {
|
||||
// 合同类型,找到所有pid=3的评查点组
|
||||
const contractGroups = groups.filter(g => g.pid === 3).map(g => g.id);
|
||||
pidList = contractGroups;
|
||||
} else if (reviewType === 'record') {
|
||||
// 卷宗类型,找到所有pid=1或pid=2的评查点组
|
||||
const recordGroups = groups.filter(g => g.pid === 1 || g.pid === 2).map(g => g.id);
|
||||
pidList = recordGroups;
|
||||
}
|
||||
|
||||
// 如果有过滤的组id,则添加到查询条件中
|
||||
if (pidList.length > 0) {
|
||||
postgrestParams.filter!['evaluation_point_groups_id'] = `in.(${pidList.join(',')})`;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取评查点组数据出错:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果指定了评查点类型ID,需要先查询该类型下的所有规则组ID
|
||||
if (ruleType) {
|
||||
try {
|
||||
@@ -790,9 +832,10 @@ export interface RuleGroup {
|
||||
|
||||
/**
|
||||
* 获取评查点类型列表
|
||||
* @param reviewType 评查类型,contract表示合同,record表示卷宗
|
||||
* @returns 评查点类型列表
|
||||
*/
|
||||
export async function getRuleTypes(): Promise<{data: RuleType[]; error?: never} | {data?: never; error: string; status?: number}> {
|
||||
export async function getRuleTypes(reviewType?: string): Promise<{data: RuleType[]; error?: never} | {data?: never; error: string; status?: number}> {
|
||||
try {
|
||||
// 构建PostgrestParams参数
|
||||
const postgrestParams: PostgrestParams = {
|
||||
@@ -810,6 +853,15 @@ export async function getRuleTypes(): Promise<{data: RuleType[]; error?: never}
|
||||
}
|
||||
};
|
||||
|
||||
// 根据 reviewType 添加过滤条件
|
||||
if (reviewType === 'contract') {
|
||||
// 如果是合同类型,只加载id=3的评查点类型
|
||||
postgrestParams.filter!['id'] = 'eq.3';
|
||||
} else if (reviewType === 'record') {
|
||||
// 如果是卷宗类型,只加载id=1和id=2的评查点类型
|
||||
postgrestParams.filter!['id'] = 'in.(1,2)';
|
||||
}
|
||||
|
||||
// 发送请求获取评查点类型列表
|
||||
const response = await postgrestGet<{code: number; msg: string; data: Array<{
|
||||
id: number;
|
||||
|
||||
Reference in New Issue
Block a user