import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AfterSalesVO, AfterSalesForm, AfterSalesQuery } from '@/api/oa/erp/afterSales/types';

/**
 * 查询项目售后信息列表
 * @param query
 * @returns {*}
 */

export const listAfterSales = (query?: AfterSalesQuery): AxiosPromise<AfterSalesVO[]> => {
  return request({
    url: '/oa/erp/afterSales/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询项目售后信息详细
 * @param afterSalesId
 */
export const getAfterSales = (afterSalesId: string | number): AxiosPromise<AfterSalesVO> => {
  return request({
    url: '/oa/erp/afterSales/' + afterSalesId,
    method: 'get'
  });
};

/**
 * 新增项目售后信息
 * @param data
 */
export const addAfterSales = (data: AfterSalesForm) => {
  return request({
    url: '/oa/erp/afterSales',
    method: 'post',
    data: data
  });
};

/**
 * 修改项目售后信息
 * @param data
 */
export const updateAfterSales = (data: AfterSalesForm) => {
  return request({
    url: '/oa/erp/afterSales',
    method: 'put',
    data: data
  });
};

/**
 * 删除项目售后信息
 * @param afterSalesId
 */
export const delAfterSales = (afterSalesId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/erp/afterSales/' + afterSalesId,
    method: 'delete'
  });
};

/**
 * 下拉框查询项目售后信息列表
 * @param query
 * @returns {*}
 */
export function getErpAfterSalesList (query) {
    return request({
        url: '/oa/erp/afterSales/getErpAfterSalesList',
        method: 'get',
        params: query
    });
};

/**
 * 项目售后信息提交并发起流程
 * @param data 表单数据
 */
export const submitAfterSalesAndFlowStart = (data: any) => {
  return request({
    url: '/oa/erp/afterSales/submitAndFlowStart',
    method: 'post',
    data: data
  });
};
