import request from '@/utils/request.js'
import axios from "axios";
import {getToken} from "@/utils/auth";
//项目立项
export const getApplyProcess = (projectId) => {
    return request({
        url: `/workflow/mosr/project/approval/initiation/process/${projectId}`,
        method: "get"
    });
};
export const filterProjectName = (projectName,targetState) => {
    return request({
        url: `/workflow/mosr/project/approval/match/${projectName}/${targetState}`,
        method: "get"
    });
};
export const projectApply = (data) => {
    return request({
        url: '/workflow/mosr/project/approval/initiation/apply',
        method: "post",
        data: data
    });
};
export const getApplyDetail = (ProjectId) => {
    return request({
        url: `/workflow/mosr/project/approval/info/${ProjectId}`,
        method: "get"
    });
};

export const resubmitApply = (data) => {
    return request({
        url: '/workflow/mosr/project/approval/initiation/resubmit',
        method: "post",
        data: data
    });
};
export const getInitiationAttachment = (params) => {
    return request({
        url: '/workflow/mosr/project/approval/attachments',
        method: "get",
        params: params
    });
};
//项目实施
export const getCheckDetail = (projectId) => {
    return request({
        url: `/workflow/mosr/project/implementation/info/${projectId}`,
        method: "get"
    });
};
export const resubmitCheck = (data) => {
    return request({
        url: '/workflow/mosr/project/implementation/resubmit',
        method: "post",
        data: data
    });
};

export const projectCheck = (data) => {
    return request({
        url: '/workflow/mosr/project/implementation/initiation/check',
        method: "post",
        data: data
    });
};
export const getProjectCheckProcess = (projectId) => {
    return request({
        url: `/workflow/mosr/project/implementation/process/${projectId}`,
        method: "get"
    });
};

export const addLedger = (data) => {
    return request({
        url: '/workflow/mosr/expense/ledger',
        method: "post",
        data: data
    });
};

export const getTags = (projectId) => {
    return request({
        url: `/workflow/mosr/attachment/option/${projectId}`,
        method: "get"
    });
};
export const getPhaseProcess = () => {
    return request({
        url: '/workflow/phase/change/process',
        method: "get"
    });
};
export const submitPhaseChange = (data) => {
    return request({
        url: '/workflow/phase/change',
        method: "post",
        data: data
    });
};
export const getPhaseDetail = (projectId) => {
    return request({
        url: `/workflow/phase/change/info/${projectId}`,
        method: "get"
    });
};
export const getPhaseForm = (projectId) => {
    return request({
        url: `/workflow/phase/change/from/${projectId}`,
        method: "get"
    });
};
export const resubmitPhaseForm = (data) => {
    return request({
        url: '/workflow/phase/change/resubmit',
        method: "post",
        data: data
    });
};

//项目归档
export const getConclusionDetail = (ProjectId) => {
    return request({
        url: `/workflow/mosr/project/filing/info/${ProjectId}`,
        method: "get"
    });
};
export const resubmitConclusion = (data) => {
    return request({
        url: '/workflow/mosr/project/filing/resubmit',
        method: "post",
        data: data
    });
};

export const projectConclusion = (data) => {
    return request({
        url: '/workflow/mosr/project/filing/project/entry',
        method: "post",
        data: data
    });
};
export const getProjectConclusionProcess = () => {
    return request({
        url: '/workflow/mosr/project/filing/process',
        method: "get"
    });
};
//获取前置流程
export const getPreProcess = () => {
    return request({
        url: '/workflow/details/pre/process',
        method: "get"
    });
};
export const updateLedger = (data) => {
    return request({
        url: '/workflow/mosr/expense/ledger/replenishment',
        method: "post",
        data: data
    });
};
export const searchUpdateLedgerData = (projectId) => {
    return request({
        url: `/workflow/mosr/expense/ledger/${projectId}`,
        method: "get"
    });
};
//
// export const searchUpdateLedgerData = (projectId) => {
//     return request({
//         url: '/workflow/mosr/expense/ledger/import',
//         method: "get"
//     });
// };

export const exportExcel = (data) => {
    return axios.post(
        `${import.meta.env.VITE_BASE_URL}/workflow/mosr/project/implementation/export`,
        data, {
            responseType: 'blob',
            headers: {
                Authorization: getToken()
            }
        }
    );
};
//台账模板下载
export const ledgerTemplateDownload = () => {
    return axios.get(
      `${import.meta.env.VITE_BASE_URL}/workflow/mosr/project/implementation/download/template`,
      {
          responseType: 'blob',
          headers: {
              Authorization: getToken()
          }
      }
    );
};
