import request from '@/utils/request';

/**
 * 获取客户信息列表
 */
export async function contactPage(params) {
  const res = await request.get(`/eom/contact/page`, { params });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

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

/**
 * 更新客户信息
 */
export async function contactUpdate(data) {
  const res = await request.put(`/eom/contact/update`, data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 新增客户信息
 */
export async function contactSave(data) {
  const res = await request.post(`/eom/contact/save`, data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 客户证书资质信息分页
 */
export async function contactQcPackPageAPI(data) {
  const res = await request.post(`/eom/contactqcpack/page`, data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 新增客户证书资质信息
 */
export async function contactQcPackSaveAPI(data) {
  const res = await request.post(`/eom/contactqcpack/save`, data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 修改客户证书资质信息
 */
export async function contactQcPackUpdateAPI(data) {
  const res = await request.put(`/eom/contactqcpack/update`, data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 获取客户证书资质信息详情
 */
export async function contactQcPackDetailAPI(id) {
  const res = await request.get(`/eom/contactqcpack/getById/${id}`, {});
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 删除客户证书资质包
 */
export async function contactQcPackDeleteAPI(data) {
  const res = await request.delete(`/eom/contactqcpack/delete`, {data});
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 提交客户证书资质信息  开启流程
 */
export async function contactQcSubmit(data) {
  const res = await request.post(`/bpm/contactQc/submit`, 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/contactQc/cancel`, data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}


/**
 * 删除事项
 */
export async function contactDelete(data) {
  const res = await request.post('/eom/contact/delete', data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}


/**
 * 获取客户分类树
 */
export async function contactTypeTree(data) {
  const res = await request.get(`/main/categoryLevel/getTreeByPid/${data.type}`);
  if (res.data.code == 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 更新用户状态
 */
export async function updateStatus(id, status) {
  const res = await request.get(`/eom/contact/updateStatus?id=` + id + '&status=' + status);
  if (res.data.code == 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 指派
 */
export async function assign(data) {
  const res = await request.post('/eom/contact/assign', data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 释放
 */
export async function free(data) {
  const res = await request.post('/eom/contact/free', data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 申请
 */
export async function apply(data) {
  const res = await request.post('/bpm/contactlistapply/apply', data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}



