添加根据合同/卷宗的入口进行分类评查点列表,同时区分卷宗添加的分组属于卷宗,合同添加的分组属于合同
This commit is contained in:
@@ -24,6 +24,7 @@ export interface ApiRuleGroup {
|
||||
code?: string;
|
||||
description?: string;
|
||||
is_enabled: boolean;
|
||||
m_type?: number; // 文档类型:0=合同,1=其他
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
@@ -35,6 +36,7 @@ export interface RuleGroupCreateUpdateDto {
|
||||
pid: string | null; // 父分组ID,如果是一级分组则为null或'0'
|
||||
description?: string;
|
||||
is_enabled: boolean;
|
||||
reviewType?: string; // 审核类型:'contract'=合同,其他为卷宗
|
||||
}
|
||||
|
||||
// 用于替换代码中的 any 类型
|
||||
@@ -446,13 +448,18 @@ export async function createRuleGroup(groupData: RuleGroupCreateUpdateDto, token
|
||||
return { error: '父分组ID格式错误', status: 400 };
|
||||
}
|
||||
|
||||
// 根据 reviewType 确定 m_type 的值
|
||||
// contract -> 0, 其他 -> 1
|
||||
const mType = groupData.reviewType === 'contract' ? 0 : 1;
|
||||
|
||||
// 构建API请求数据 - 确保字段类型符合数据库要求
|
||||
const apiGroup: ApiRuleGroup = {
|
||||
pid: pidValue,
|
||||
name: groupData.name.trim(),
|
||||
code: groupData.code.trim(),
|
||||
description: groupData.description || '',
|
||||
is_enabled: groupData.is_enabled
|
||||
is_enabled: groupData.is_enabled,
|
||||
m_type: mType
|
||||
};
|
||||
|
||||
// console.log('创建评查点分组请求数据:', JSON.stringify(apiGroup, null, 2));
|
||||
|
||||
@@ -213,12 +213,12 @@ export async function getRulesList(params: RulesQueryParams): Promise<{data: Rul
|
||||
if (reviewType) {
|
||||
try {
|
||||
// 先获取所有评查点组数据,用于找到对应的pid
|
||||
const groupsAllResponse = await postgrestGet<{code: number; msg: string; data: Array<{id: number; pid: number}>}>('evaluation_point_groups', {
|
||||
select: 'id,pid',
|
||||
const groupsAllResponse = await postgrestGet<{code: number; msg: string; data: Array<{id: number; pid: number; m_type: number}>}>('evaluation_point_groups', {
|
||||
select: 'id,pid,m_type',
|
||||
token
|
||||
});
|
||||
|
||||
let groups: Array<{id: number; pid: number}> = [];
|
||||
let groups: Array<{id: number; pid: number; m_type: number}> = [];
|
||||
|
||||
if (!groupsAllResponse.error) {
|
||||
if (groupsAllResponse.data && 'code' in groupsAllResponse.data && groupsAllResponse.data.data) {
|
||||
@@ -232,12 +232,14 @@ export async function getRulesList(params: RulesQueryParams): Promise<{data: Rul
|
||||
let pidList: number[] = [];
|
||||
|
||||
if (reviewType === 'contract') {
|
||||
// 合同类型,找到所有pid=3的评查点组
|
||||
const contractGroups = groups.filter(g => g.pid === 3).map(g => g.id);
|
||||
// 合同类型,找到所有pid=3的评查点组 2025/10/29: 修改为通过m_type = 0 去查找评查点组
|
||||
// const contractGroups = groups.filter(g => g.pid === 3).map(g => g.id);
|
||||
const contractGroups = groups.filter(g => g.m_type === 0).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);
|
||||
// 卷宗类型,找到所有pid=1或pid=2的评查点组 2025/10/29: 修改为通过m_type = 1 去查找评查点组
|
||||
// const recordGroups = groups.filter(g => g.pid === 1 || g.pid === 2).map(g => g.id);
|
||||
const recordGroups = groups.filter(g => g.m_type === 1).map(g => g.id);
|
||||
pidList = recordGroups;
|
||||
}
|
||||
|
||||
@@ -860,7 +862,8 @@ export async function getRuleTypes(reviewType?: string, token?: string): Promise
|
||||
code,
|
||||
name,
|
||||
description,
|
||||
is_enabled
|
||||
is_enabled,
|
||||
m_type
|
||||
`,
|
||||
// 查询父ID为0的类型(顶级类型)
|
||||
filter: {
|
||||
@@ -871,11 +874,11 @@ export async function getRuleTypes(reviewType?: string, token?: string): Promise
|
||||
|
||||
// 根据 reviewType 添加过滤条件
|
||||
if (reviewType === 'contract') {
|
||||
// 如果是合同类型,只加载id=3的评查点类型
|
||||
postgrestParams.filter!['id'] = 'eq.3';
|
||||
// 如果是合同类型,只加载id=3的评查点类型 2025/10/29: 修改为通过m_type = 0 去查找评查点组
|
||||
postgrestParams.filter!['m_type'] = 'eq.0';
|
||||
} else if (reviewType === 'record') {
|
||||
// 如果是卷宗类型,只加载id=1和id=2的评查点类型
|
||||
postgrestParams.filter!['id'] = 'in.(1,2)';
|
||||
// 如果是卷宗类型,只加载id=1和id=2的评查点类型 2025/10/29: 修改为通过m_type = 1 去查找评查点组
|
||||
postgrestParams.filter!['m_type'] = 'eq.1';
|
||||
}
|
||||
|
||||
// 发送请求获取评查点类型列表
|
||||
|
||||
Reference in New Issue
Block a user