import request from '@/utils/request';
import { download } from '@/utils/file';
/**
 * 获取商机列表
 */
export async function getTableList(params) {
  const res = await request.get(`/eom/businessopportunity/page`, { params });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 查询客户联系人列表
 */
export async function getcontactlink(params) {
  const res = await request.get(`/eom/contactlink/list/`, { params });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 获取信息详情
 */
export async function getDetail(id) {
  const res = await request.get(`/eom/quote/getById/${id}`, {});
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 更新信息
 */
export async function UpdateInformation(data) {
  const res = await request.put(`/eom/quote/update`, data);
  return res.data;
}
// 生产主管指派技术员
export async function assignTechnician(data) {
  const res = await request({
    url: '/bpm/quoteApprove/assignTechnician',
    method: 'post',
    data: data
  });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 更新信息
 */
export async function updateTech(data) {
  const res = await request.put(`/eom/quote/updateTech`, data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 生产主管复核
 */
export async function productionSupervisorReApprove(data) {
  const res = await request.put(
    `/bpm/quoteApprove/productionSupervisorReApprove`,
    data
  );
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 销售主管审批
 */
export async function salesManagerApprove(data) {
  const res = await request.put(`/bpm/quoteApprove/salesManagerApprove`, data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 销售员补充
 */
export async function salesmanApprove(data) {
  const res = await request.put(`/bpm/quoteApprove/salesmanApprove`, data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 流程作废
 */
export async function cancel(data) {
  const res = await request.put(`/bpm/quoteApprove/notPass`, data);
  if (res.data.code == 0) {
    return Promise.resolve(res.data);
  }
  return Promise.reject(new Error(res.data.message));
}
