import { request } from '@@/plugin-request/request';
import { stringify } from 'qs';

/**
 * 报备列表
 * @param param
 */
export async function reportingQuery(param: object) {
  return request(`/web/v1/report_projects?${stringify(param)}`);
}

/**
 * 报备详情
 * @param id
 */
export async function reportingDetailQuery(id: string) {
  return request(`/web/v1/report_projects/${id}`);
}

/**
 * 业务员列表
 * @param param
 */
export async function salesQuery(param: object) {
  return request(`/web/v1/users?${stringify(param)}`);
}

/**
 * 当前账号信息
 */
export async function infoQuery() {
  return request(`/web/v1/users/current`);
}

/**
 * 城市列表
 * @param params
 */
export async function cityQuery(params: any) {
  return request(`/web/v1/cities?${stringify(params)}`);
}

/**
 * 创建报备
 * @param params
 */
export async function createReporting(params: object) {
  return request(`/web/v1/report_projects`, {
    method: 'POST',
    data: params,
  });
}

/**
 * 编辑报备
 * @param params
 */
export async function editReporting(params: any) {
  return request(`/web/v1/report_projects/${params.record_id}`, {
    method: 'PUT',
    data: params,
  });
}

/**
 * 报备成交
 * @param id
 */
export async function reportingSuccess(id: string) {
  return request(`/web/v1/report_projects/${id}/success`, {
    method: 'PATCH',
  });
}

/**
 * 报备放弃
 * @param id
 */
export async function reportingAbandon(id: string) {
  return request(`/web/v1/report_projects/${id}/abandon`, {
    method: 'PATCH',
  });
}
