import microRequest from '../../utils/micro_request';

const sciPath = import.meta.env.VITE_SCIENTIFIC;

export function useDocumentApi() {
  return {
    // 纵向项目 (sci_project_vertical, pre_sci_project_vertical, sci_project_spontaneity_declaration_project)
    getVerticalByCode: (code: string) => {
      return microRequest.postRequest(sciPath, 'SciProjectVertical', 'GetSciProjectVerticalByCode', { projectCode: code });
    },
    // 横向项目 (sci_project_horizontal) 
    getHorizontalByCode: (code: string) => {
      return microRequest.postRequest(sciPath, 'SciProjectHorizontal', 'GetEntityByCode', { projectCode: code });
    },
    // 校内项目 (sci_project_spontaneity)
    getSpontaneityByCode: (code: string) => {
      return microRequest.postRequest(sciPath, 'SciProjectSpontaneity', 'GetSciProjectSpontaneityByCode', { projectCode: code });
    },
    // 本科室子学科 (sci_project_discipline) 
    getDisciplineByCode: (code: string) => {
      return microRequest.postRequest(sciPath, 'SciProjectDiscipline', 'GetDetail', { id: Number(code) });
    },
    // 获取学科评分模板列表
    getDisciplineTmplList: () => {
      return microRequest.postRequest(sciPath, 'SciProjectGradeTemplate', 'GetList', {});
    },
    // 学术成果（论文、奖项、专利、著作等共用 SciAchieve 控制器） 
    getPaperByCode: (code: string) => {
      return microRequest.postRequest(sciPath, 'SciAchieve', 'GetPaperEntityByCode', { PaperCode: code });
    },
    getAwardsByCode: (code: string) => {
      return microRequest.postRequest(sciPath, 'SciAchieve', 'GetAwardsEntityByCode', { awardCode: code });
    },
    getPatentByCode: (code: string) => {
      return microRequest.postRequest(sciPath, 'SciAchieve', 'GetPatentEntityByCode', { patentCode: code });
    },
    getWorkByCode: (code: string) => {
      return microRequest.postRequest(sciPath, 'SciAchieve', 'GetWorkEntityByCode', { workCode: code });
    },
    // 学术委员会 (sci_academic_committee)
    getCommitteeByCode: (code: string) => {
      return microRequest.postRequest(sciPath, 'SciCommittee', 'GetChangeEntity', { id: Number(code) });
    },
    // 获取学术委员会原始详情
    getCommitteeById: (id: number, changeType?: string) => {
      return microRequest.postRequest(sciPath, 'SciCommittee', 'GetEntityById', { id, userType: changeType });
    },
    // 获取委员会列表
    getCommitteeList: () => {
      return microRequest.postRequest(sciPath, 'SciCommittee', 'GetList', {});
    },
    // 学术会议 (sci_academic_conferences)
    getConferenceById: (id: string | number) => {
      return microRequest.postRequest(sciPath, 'SciConference', 'GetEntityById', { id: Number(id) });
    },
    // 学术讲座 (sci_academic_lectures)
    getLectureById: (id: string | number) => {
      return microRequest.postRequest(sciPath, 'SciLecture', 'GetEntityById', { id: Number(id) });
    },
    // 社会任职 (sci_academic_committee_positions)
    getDutiesById: (id: string | number) => {
      return microRequest.postRequest(sciPath, 'SciDuties', 'GetEntityById', { id: Number(id) });
    },
    // 人员派驻 (sci_scientific_researchers_dispatch)
    getDispatchById: (id: string | number) => {
      return microRequest.postRequest(sciPath, 'SciDispatch', 'GetEntityById', { id: Number(id) });
    },
    // 经费认领 (sci_fund_allot_apply) 
    getFundClaimById: (id: string | number) => {
      return microRequest.postRequest(sciPath, 'SciFundAllotApply', 'GetEntityById', { id: Number(id) });
    },
    // 获取财务到账详情
    getFundById: (id: string | number) => {
      return microRequest.postRequest(sciPath, 'SciFund', 'GetEntityById', { id: Number(id) });
    },
    // 经费报销 (sci_fund_expense) 
    getFundExpenseById: (id: string | number) => {
      return microRequest.postRequest(sciPath, 'SciFundExpense', 'GetEntityById', { id: Number(id) });
    },
    // 获取经费卡科目余额
    getSubjAmount: (params: any) => {
      return microRequest.postRequest(sciPath, 'SciFundCard', 'GetSubjAmount', params);
    },
    // 获取经费卡详情
    getFundCardById: (id: string | number) => {
      return microRequest.postRequest(sciPath, 'SciFundCard', 'GetEntityById', { id: Number(id) });
    },
    // 获取所有一级科目
    getAllFirstSubj: () => {
      return microRequest.postRequest(sciPath, 'SciSubj', 'GetAllFirstSubj', {});
    },
    // 经费奖励 (sci_fund_reward) 
    getFundRewardById: (id: string | number) => {
      return microRequest.postRequest(sciPath, 'SciFundReward', 'GetEntityById', { id: Number(id) });
    },
    // 经费结转 (sci_fund_carryover) 
    getFundCarryoverById: (id: string | number) => {
      return microRequest.postRequest(sciPath, 'SciFundCarryover', 'GetEntityById', { id: Number(id) });
    },
    // 考核批次 (sci_assessment_batch) 
    getAssessmentBatchById: (id: string | number) => {
      return microRequest.postRequest(sciPath, 'SciBatch', 'GetEntityById', { id: Number(id) });
    },
    // 获取考核方案列表
    getAssessmentSchemeList: () => {
      return microRequest.postRequest(sciPath, 'SciAssessmentScheme', 'GetAllList', { schemeStatus: '10' });
    },
    // 项目中期/结项 (sci_project_audit)
    getProjectAuditById: (id: string | number) => {
      return microRequest.postRequest(sciPath, 'SciProjectAudit', 'GetEntityById', { id: Number(id) });
    },
        
    // 项目中检 (sci_project_inspection) 
    getInspectionByCode: (code: string) => {
      return microRequest.postRequest(sciPath, 'SciProjectInspection', 'GetTaskDetail', { id: Number(code) });
    },
    
    // 项目结题 (sci_project_conclusion) 
    getConclusionByCode: (code: string) => {
      return microRequest.postRequest(sciPath, 'SciProjectConclusion', 'GetTaskDetail', { id: Number(code) });
    },
    
    // 项目变更 (sci_project_change) 
    getProjectChangeByCode: (code: string) => {
      return microRequest.postRequest(sciPath, 'SciProjectChange', 'GetDetail', { id: Number(code) });
    },
    
    // 学科中期 (sci_project_discipline_midterm) 
    getDisciplineMidtermByCode: (code: string) => {
      return microRequest.postRequest(sciPath, 'SciDisciplineMidterm', 'GetEntityById', { id: Number(code) });
    },
    
    // 学科结题 (sci_project_discipline_final) 
    getDisciplineFinalByCode: (code: string) => {
      return microRequest.postRequest(sciPath, 'SciDisciplineFinal', 'GetEntityById', { id: Number(code) });
    },
    
    // 论文投稿 (sci_paper_submission) 
    getPaperSubmissionByCode: (code: string) => {
      return microRequest.postRequest(sciPath, 'SciAchieve', 'GetPaperSubmissionEntity', { id: Number(code) });
    },
    
    // 集成电路 (sci_property_circuit) 
    getCircuitByCode: (code: string) => {
      return microRequest.postRequest(sciPath, 'SciProperty', 'GetCircuitEntity', { id: Number(code) });
    },
    
    // 著作权 (sci_property_copyright) 
    getCopyrightByCode: (code: string) => {
      return microRequest.postRequest(sciPath, 'SciProperty', 'GetCopyrightEntity', { id: Number(code) });
    },
    
    // 医药凭证 (sci_property_medicine_credential) 
    getCredentialByCode: (code: string) => {
      return microRequest.postRequest(sciPath, 'SciProperty', 'GetCredentialEntity', { id: Number(code) });
    },
    
    // 新品种 (sci_property_new_variety) 
    getVarietyByCode: (code: string) => {
      return microRequest.postRequest(sciPath, 'SciProperty', 'GetVarietyEntity', { id: Number(code) });
    },
    
    // 标准 (sci_property_standard) 
    getStandardByCode: (code: string) => {
      return microRequest.postRequest(sciPath, 'SciProperty', 'GetStandardEntity', { id: Number(code) });
    },
    
    // 伦理审查 (sci_ethical_review_form) 
    getReviewByCode: (code: string) => {
      return microRequest.postRequest(sciPath, 'SciEthicalReview', 'GetEntityById', { id: Number(code) });
    },
    
    // 自发项目申报 (sci_project_spontaneity_declaration_project) 
    getSpontaneityPlanByCode: (code: string) => {
      return microRequest.postRequest(sciPath, 'SciProjectSpontaneityDeclarationProject', 'GetSciProjectSpontaneityDeclarationProjectByCode', { projectCode: code });
    },
    
    // 经费冲正 (sci_fund_reverse) 
    getFundReverseByCode: (code: string) => {
      return microRequest.postRequest(sciPath, 'SciFundReverse', 'GetEntityById', { id: Number(code) });
    },
    
    // 临时借款 (sci_temporary_fund_borrowing) 
    getTemporaryFundByCode: (code: string) => {
      return microRequest.postRequest(sciPath, 'SciTemporaryFundBorrowing', 'GetDetail', { id: Number(code) });
    },

    // 获取成果标准详情 (通过ID)
    getAchievementStandardById: (id: string | number) => {
      return microRequest.postRequest(sciPath, 'SciAchievementStandard', 'GetEntityById', { id: Number(id) });
    },
    
    // 获取论文认领详情 (通过ID)
    getPaperPushById: (id: string | number) => {
      return microRequest.postRequest(sciPath, 'SciAchievementPaperPush', 'GetSciAchievementPaperPushEntity', { id: Number(id) });
    },
    
    // 获取其他成果详情 (通过ID)
    getOtherAchievementById: (id: string | number) => {
      return microRequest.postRequest(sciPath, 'SciAchievementOther', 'GetOtherEntity', { id: Number(id) });
    },
    
    // 获取软件著作权详情 (通过ID)
    getSoftwareAchievementById: (id: string | number) => {
      return microRequest.postRequest(sciPath, 'SciAchievementSoftware', 'GetSoftwareEntity', { id: Number(id) });
    },
    // 预申报 (sci_project_declaration_list)
    getDeclarationById: (id: string | number) => {
      return microRequest.postRequest(sciPath, 'SciProjectDeclarationList', 'GetEntityById', { id: Number(id) });
    }
  };
}
