feat: 1. 重构交叉评查任务的文档列表的显示,对接接口查询当前任务的文档相关信息。
2.文档上传通过接口去查询是否存在同名的文件,做上传前拦截提示。 3.交叉评查的评查结果也同步添加企查查的企业信息查询模块。 4. 封装上传附件和上传模板的模态框的组件,在交叉评查的文档列表中引入显示。 5. 交叉评查的评查结果中关于合同类型的文档同步加入结构比对的功能。
This commit is contained in:
@@ -1,7 +1,64 @@
|
||||
import { postgrestGet, type PostgrestParams } from '../postgrest-client';
|
||||
import dayjs from 'dayjs';
|
||||
import { UPLOAD_URL } from '../../config/api-config';
|
||||
import { UPLOAD_URL, API_BASE_URL } from '../../config/api-config';
|
||||
import axios from 'axios';
|
||||
|
||||
/**
|
||||
* 检查文档名称是否重复
|
||||
* @param name 文档名称
|
||||
* @param typeId 文档类型ID
|
||||
* @returns 重复检查结果
|
||||
*/
|
||||
export async function checkDocumentDuplicate(
|
||||
name: string,
|
||||
typeId: number
|
||||
): Promise<{ is_duplicate: boolean; count: number }> {
|
||||
try {
|
||||
// 获取 token
|
||||
let token: string | null = null;
|
||||
if (typeof window !== 'undefined') {
|
||||
token = localStorage.getItem('access_token');
|
||||
}
|
||||
|
||||
const headers: Record<string, string> = {
|
||||
'Accept': 'application/json'
|
||||
};
|
||||
if (token) {
|
||||
headers['Authorization'] = `Bearer ${token}`;
|
||||
}
|
||||
|
||||
const response = await axios.get(
|
||||
`${API_BASE_URL}/api/v2/documents/check-duplicate`,
|
||||
{
|
||||
params: { name, type_id: typeId },
|
||||
headers
|
||||
}
|
||||
);
|
||||
|
||||
// 解析响应数据
|
||||
const data = response.data;
|
||||
if (data && typeof data === 'object') {
|
||||
// 处理标准响应格式 { code, msg, data }
|
||||
if ('data' in data && data.data) {
|
||||
return {
|
||||
is_duplicate: data.data.is_duplicate ?? false,
|
||||
count: data.data.count ?? 0
|
||||
};
|
||||
}
|
||||
// 直接返回数据格式
|
||||
return {
|
||||
is_duplicate: data.is_duplicate ?? false,
|
||||
count: data.count ?? 0
|
||||
};
|
||||
}
|
||||
|
||||
return { is_duplicate: false, count: 0 };
|
||||
} catch (error) {
|
||||
console.error('【文档重名检查】检查失败:', error);
|
||||
// 检查失败时默认允许上传
|
||||
return { is_duplicate: false, count: 0 };
|
||||
}
|
||||
}
|
||||
// import { API_BASE_URL } from '../client';
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user