import httpFetch from "@/api/fetch" import { usePermissionStore } from "../../store/auth" import { BASE_LABEL_API } from "../label" import { Project, ProjectDetail, ReviewUsers } from "./typing" // 获取项目列表 export const getProjectList = (data: Project.ListRequest) => { return httpFetch({ url: BASE_LABEL_API + "/api/v1/label_server/project/list", method: "POST", body: JSON.stringify(data), headerAttr: { ["Token"]: usePermissionStore.getState().token, ["Refresh-Token"]: usePermissionStore.getState().refresh_token, }, }) } // 获取项目详情 export const getProjectDetailById = (id: number) => { return httpFetch({ url: BASE_LABEL_API + `/api/v1/label_server/project/detail/${id}`, method: "GET", headerAttr: { ["Token"]: usePermissionStore.getState().token, ["Refresh-Token"]: usePermissionStore.getState().refresh_token, }, }) } // 校验项目源数据 export const checkLabelDataSource = (data: Project.CheckRequest) => { return httpFetch({ url: BASE_LABEL_API + "/api/v1/label_server/project/check_data", method: "POST", body: JSON.stringify(data), headerAttr: { ["Token"]: usePermissionStore.getState().token, ["Refresh-Token"]: usePermissionStore.getState().refresh_token, }, }) } // 创建项目 export const projectAdd = (data: Project.CreateProps) => { return httpFetch({ url: BASE_LABEL_API + "/api/v1/label_server/project/add", method: "POST", body: JSON.stringify(data), headerAttr: { ["Token"]: usePermissionStore.getState().token, ["Refresh-Token"]: usePermissionStore.getState().refresh_token, }, }) } // 审核项目 export const projectReview = (data: Project.CreateProps) => { return httpFetch({ url: BASE_LABEL_API + "/api/v1/label_server/project/review", method: "POST", body: JSON.stringify(data), headerAttr: { ["Token"]: usePermissionStore.getState().token, ["Refresh-Token"]: usePermissionStore.getState().refresh_token, }, }) } // 配置项目 export const projectConfig = (data: Project.ConfigProps) => { return httpFetch({ url: BASE_LABEL_API + "/api/v1/label_server/project/config", method: "POST", body: JSON.stringify(data), headerAttr: { ["Token"]: usePermissionStore.getState().token, ["Refresh-Token"]: usePermissionStore.getState().refresh_token, }, }) } // 编辑项目 export const projectEditById = (data: any, id: number) => { return httpFetch({ url: BASE_LABEL_API + `/api/v1/label_server/project/edit/${id}`, method: "POST", body: JSON.stringify(data), headerAttr: { ["Token"]: usePermissionStore.getState().token, ["Refresh-Token"]: usePermissionStore.getState().refresh_token, }, }) } // 审核试标项目 export const projectPreLabelReview = (data: Project.PreLabelProps) => { return httpFetch({ url: BASE_LABEL_API + "/api/v1/label_server/project/prototype_review", method: "POST", body: JSON.stringify(data), headerAttr: { ["Token"]: usePermissionStore.getState().token, ["Refresh-Token"]: usePermissionStore.getState().refresh_token, }, }) } // 提交验收 export const projectDeliver = (data: { project_id: number }) => { return httpFetch({ url: BASE_LABEL_API + "/api/v1/label_server/project/deliver", method: "POST", body: JSON.stringify(data), headerAttr: { ["Token"]: usePermissionStore.getState().token, ["Refresh-Token"]: usePermissionStore.getState().refresh_token, }, }) } // 完成项目 export const projectAccept = (data: { project_id: number; pass: boolean }) => { return httpFetch({ url: BASE_LABEL_API + "/api/v1/label_server/project/accept", method: "POST", body: JSON.stringify(data), headerAttr: { ["Token"]: usePermissionStore.getState().token, ["Refresh-Token"]: usePermissionStore.getState().refresh_token, }, }) } // 收藏项目 export const projectCollect = (data: { project_id: number is_collect: boolean }) => { return httpFetch({ url: BASE_LABEL_API + "/api/v1/label_server/project/collect", method: "POST", body: JSON.stringify(data), headerAttr: { ["Token"]: usePermissionStore.getState().token, ["Refresh-Token"]: usePermissionStore.getState().refresh_token, }, }) } // 获取项目抽检比例 export const getReviewScaleList = (params: { project_id: number }) => { return httpFetch({ url: BASE_LABEL_API + "/api/v1/label_server/review_scale/list", method: "GET", data: params, headerAttr: { ["Token"]: usePermissionStore.getState().token, ["Refresh-Token"]: usePermissionStore.getState().refresh_token, }, }) } // 保存抽检比例 export const saveUserReviewScale = (data: Project.ReviewScaleProps) => { return httpFetch({ url: BASE_LABEL_API + "/api/v1/label_server/review_scale/save", method: "POST", body: JSON.stringify(data), headerAttr: { ["Token"]: usePermissionStore.getState().token, ["Refresh-Token"]: usePermissionStore.getState().refresh_token, }, }) } export const getProjectDetail = (id: number) => { return httpFetch({ url: BASE_LABEL_API + `/api/v1/label_server/project/detail/${id}`, method: "GET", headerAttr: { ["Token"]: usePermissionStore.getState().token, ["Refresh-Token"]: usePermissionStore.getState().refresh_token, }, }) } // 重新生成Embedding export const regenerateProjectEmbedding = (data: { project_id: number }) => { return httpFetch({ url: BASE_LABEL_API + `/api/v1/label_server/project/regenerate_embedding`, method: "POST", body: JSON.stringify(data), headerAttr: { ["Token"]: usePermissionStore.getState().token, ["Refresh-Token"]: usePermissionStore.getState().refresh_token, }, }) } // 获取个人参与项目 export const getPersonProjectDashBoard = () => { return httpFetch>({ url: BASE_LABEL_API + `/api/v1/label_server/data_statistics/personal_project`, method: "GET", headerAttr: { ["Token"]: usePermissionStore.getState().token, ["Refresh-Token"]: usePermissionStore.getState().refresh_token, }, }) } // 获取个人看板数据 export const getCurrentPersonData = (params: { date: string }) => { return httpFetch<{ label_data_size: number label_work_time: number review1_data_size: number review1_work_time: number review2_data_size: number review2_work_time: number }>({ url: BASE_LABEL_API + "/api/v1/label_server/data_statistics/personal_dashboard", method: "GET", data: params, headerAttr: { ["Token"]: usePermissionStore.getState().token, ["Refresh-Token"]: usePermissionStore.getState().refresh_token, }, }) } /* ****************************** Options ****************************** */ // 获取项目所属业务列表 export const getProjectTypeList = () => { return httpFetch({ url: BASE_LABEL_API + "/api/v1/label_server/project/type_list", method: "GET", headerAttr: { ["Token"]: usePermissionStore.getState().token, ["Refresh-Token"]: usePermissionStore.getState().refresh_token, }, }) } // 获取项目管理员列表 export const getProjectAdminList = () => { return httpFetch>({ url: BASE_LABEL_API + "/api/v1/label_server/project/admin_list", method: "GET", headerAttr: { ["Token"]: usePermissionStore.getState().token, ["Refresh-Token"]: usePermissionStore.getState().refresh_token, }, }) } // 获取项目审核员 export const getProjectReviewers = () => { return httpFetch({ url: BASE_LABEL_API + "/api/v1/label_server/project/reviewer_map", method: "GET", headerAttr: { ["Token"]: usePermissionStore.getState().token, ["Refresh-Token"]: usePermissionStore.getState().refresh_token, }, }) } // 获取用户有权限的项目 export const getSelfProjectList = () => { return httpFetch>({ url: BASE_LABEL_API + "/api/v1/label_server/project/self", method: "GET", headerAttr: { ["Token"]: usePermissionStore.getState().token, ["Refresh-Token"]: usePermissionStore.getState().refresh_token, }, }) }