import request from '@/utils/request';

/**
 * 获取项目详情
 * @param {*} params
 * @returns
 */
export const getProjectDetailApi = (params = {}) => request({
  url: "",
  method: "get",
  params
});

//校验项目编码是否存在
export function checkProjectCodeExist(data) {
  return request({
    url: '/cbProjectRecord/checkProjectCodeExist/' + data,
    method: 'get',
  });
}
//新增项目
export function addProject(data) {
  return request({
    url: '/cbProjectRecord/addProject',
    method: 'post',
    data: data,
  });
}
//修改项目
export function editProjectInfo(data) {
  return request({
    url: '/cbProjectRecord/editProjectInfo',
    method: 'PUT',
    data: data,
  });
}
//删除项目
export function batchDeleteProject(ids) {
  return request({
    url: '/cbProjectRecord/batchDeleteProject/' + ids,
    method: 'Delete',
  });
}
//新增新阶段项目
export function addNewStageProject(data) {
  return request({
    url: '/cbProjectRecord/addNewStageProject',
    method: 'POST',
    data: data,
  });
}
//获取当前项目文件上传
export function getProjectFileUploadDetail(projectId) {
  return request({
    url: '/cbProjectFile/getProjectFileUploadDetail/' + projectId,
    method: 'get',
  });
}

//根据项目文件导入数据
export function importData(projectId) {
  return request({
    url: '/cbProjectRecord/importData/'+projectId,
    method: 'post',
  });
}

//获取草稿箱列表
export function getDraftDialogList(data) {
  return request({
    url: '/cbProjectRecord/getDraftDialogList',
    method: 'get',
    params:data
  });
}

//上传文件
export function uploadCbProjectFile(data) {
  return request({
    url: '/cbProjectFile/uploadCbProjectFile',
    method: 'post',
    data
  });
}
//删除文件
export function deleteCbProjectFile(data) {
  return request({
    url: '/cbProjectFile/deleteCbProjectFile',
    method: 'Delete',
    data: data
  });
}

//删除草稿
export function deleteDraft(projectId) {
  return request({
    url: '/cbProjectRecord/deleteDraft/' + projectId,
    method: 'Delete',
  });
}

//查询当前项目可删除成本阶段
export function getProjectCbStageNotDraft(relatedId) {
  return request({
    url: '/cbProjectRecord/getProjectCbStageNotDraft/' + relatedId,
    method: 'get',
  });
}

//查询当前项目可删除成本阶段
export function getProjectList(data) {
  return request({
    url: '/cbProjectRecord/getProjectList',
    method: 'get',
    params: data
  });
}

//查询当前项目可删除成本阶段
export function getProjectHistoryInfo(data) {
  return request({
    url: '/cbProjectRecord/getProjectHistoryInfo',
    method: 'get',
    params: data
  });
}

//盈亏分析对比 左侧菜单
export const getProfitLossMenuTreeApi = (params = {}) => request({
  url: "/cbSummary/cbNameList",
  method: "get",
  params
});

//盈亏分析对比 数据列表
export function getAnalysislist(data) {
  return request({
    url: '/cb/gain/loss/analysis/list',
    method: 'get',
    params: data
  });
}
// 措施项目 左侧菜单
export function getMeasureslist(projectId) {
  return request({
    url: '/cb/cost/measures/type/' + projectId,
    method: 'get',
  });
}
//措施费列表
export function getCostMeasureslist(data) {
  return request({
    url: '/cb/cost/measures/list',
    method: 'get',
    params: data
  });
}

//措施费汇总
export function getSummarydata(data) {
  return request({
    url: '/cb/cost/measures/summary/data',
    method: 'post',
    data: data
  });
}
//措施费推送工程量
export function pushProjectvolume(data) {
  return request({
    url: '/cb/cost/measures/push/project/volume',
    method: 'post',
    data: data
  });
}

//措措施费-获取上一次推送工程量
export function projectVolume(data) {
  return request({
    url: '/cb/cost/measures/last/project/volume/' + data,
    method: 'GET',
  });
}

//措施费-获取实际成本月份列表
export const getActualMonthsApi = (params = {}) => request({
  url: '/cb/cost/measures/actual/months',
  method: 'get',
  params
});

//批量保存或修改每月措施费
export function saveBatch(data) {
  return request({
    url: '/cb/cost/measures/saveBatch',
    method: 'post',
    data:data,
  });
}




// 工料汇总

/**
 * 获取工料汇总左侧菜单
 * @param {*} params
 * @returns
 */
export const getFeedSummaryMenuTreeApi = (params = {}) => request({
  url: "/cb/quantity/summary/subjectTree",
  method: "get",
  params
});

/**
 * 获取已记录月份集合
 * @param {*} params
 * @returns
 */
export const getFeedSummaryMonthListApi = (params = {}) => request({
  url: "/cb/quantity/summary/monthList",
  method: "get",
  params
});

/**
 * 获取科目月份列表
 * @param {{
 * cbSubjectName : string;
 * recordDate : string;
 * projectId : number;
 * cbStage : number
 * }} params
 * @returns
 */
export const getFeedSummaryListApi = (params = {}) => request({
  url: "/cb/quantity/summary/subjectList",
  method: "get",
  params
});



//工程项目信息
export const getCbProjectInfo = (relatedId) => request({
  url: '/cbProjectRecord/getCbProjectInfo/' + relatedId,
  method: "get",
});

// 其他项目

//其他项目左侧菜单
export const getProjectOtherMenuTreeApi = (relatedId) => request({
  url: '/cb/projectOther/type/' + relatedId,
  method: "get",
});

//其他费用-费用汇总
export const getProjectOtherStatistics = (relatedId) => request({
  url: '/cb/projectOther/statistics/' + relatedId,
  method: "get",
});

//其他费用-其他费用列表
export const getProjectOtherList = (params = {}) => request({
  url: "/cb/projectOther/list",
  method: "get",
  params
});
