fix: 1. 继续对齐交叉评查的接口,完善创建交叉评查的逻辑 和 相关组件的渲染布局。
2. 文档的基本信息修改改用接口。 3. 重新完善角色权限管理的页面逻辑。 4.将评查点列表中的返回逻辑改用浏览器的记忆返回。
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { postgrestGet, postgrestPut } from "../postgrest-client";
|
||||
import axios from 'axios';
|
||||
import { API_BASE_URL } from '../../config/api-config';
|
||||
|
||||
/**
|
||||
* 从不同格式的 API 响应中提取数据
|
||||
@@ -83,32 +84,50 @@ async function safeGetJWT(jwtToken?: string): Promise<string> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前登录用户是否是发起人
|
||||
* 检查用户是否有权确认完成文档评查
|
||||
*
|
||||
* 🔥 接口文档: auth_doc/交叉评查接口文档.md 接口11
|
||||
* 📍 API地址: GET /api/v2/cross_review/tasks/{task_id}/can-confirm
|
||||
*
|
||||
* @param taskId 任务ID
|
||||
* @param userId 用户ID
|
||||
* @returns 是否是发起人
|
||||
* @param frontendJWT JWT token
|
||||
* @returns 是否有权确认完成
|
||||
*/
|
||||
export async function findIsProposer(taskId: string | number, userId: number | undefined, frontendJWT?: string): Promise<boolean> {
|
||||
// 通过postgrest的get请求去cross_examination_tasks表中进行查找assignee_id是否等于userId
|
||||
const response = await postgrestGet(`/api/postgrest/proxy/cross_examination_tasks`, {
|
||||
select: 'assigner_id',
|
||||
filter: {
|
||||
id: `eq.${taskId}`
|
||||
},
|
||||
token: frontendJWT
|
||||
});
|
||||
if (response.error) {
|
||||
console.error('获取任务数据失败:', response.error);
|
||||
try {
|
||||
if (!taskId) {
|
||||
console.error('任务ID不能为空');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 调用新的接口检查用户是否有权确认完成
|
||||
// GET /api/v2/cross_review/tasks/{task_id}/can-confirm
|
||||
const response = await axios.get(
|
||||
`${API_BASE_URL}/api/v2/cross_review/tasks/${taskId}/can-confirm`,
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${frontendJWT}`
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
const data = response.data;
|
||||
console.log('[findIsProposer] 检查权限响应:', data);
|
||||
|
||||
// 返回 can_confirm 字段,表示是否有权确认完成
|
||||
// 有权限的用户:任务创建者(assigner_id) 或 主要负责人(principal_user_ids)
|
||||
return data?.can_confirm === true;
|
||||
} catch (error) {
|
||||
console.error('[findIsProposer] 检查权限失败:', error);
|
||||
|
||||
// 正确处理 axios 错误响应
|
||||
if (axios.isAxiosError(error) && error.response?.data) {
|
||||
console.error('[findIsProposer] 错误详情:', error.response.data);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
const data = extractApiData<{assigner_id: number}[]>(response.data);
|
||||
// console.log('data', data, userId);
|
||||
|
||||
if (data && data.length > 0) {
|
||||
return data[0].assigner_id.toString() === userId?.toString();
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,8 +199,6 @@ export async function submitCrossCheckingOpinion(
|
||||
* @param jwtToken JWT token
|
||||
* @returns 意见列表和总数
|
||||
*/
|
||||
import { API_BASE_URL } from '../../config/api-config';
|
||||
|
||||
export async function getCrossCheckingOpinions(
|
||||
documentId: string | number,
|
||||
page: number = 1,
|
||||
|
||||
Reference in New Issue
Block a user