import request from '@/utils/request';
import { AxiosPromise } from 'axios';
// 复用销售线索的类型定义（因为数据结构相同）
import type { SalesLeadsVO, LeadsQuery } from '../leads/types';

/** 查询项目商机列表 */
export function listOpportunity(query: LeadsQuery): AxiosPromise<SalesLeadsVO[]> {
    query.projectType = '销售商机';
    return request({
        url: '/customer/salesleads/list',
        method: 'get',
        params: query
    });
}

/** 获取项目商机详细信息 */
export function getOpportunity(id: string | number): AxiosPromise<SalesLeadsVO> {
    return request({
        url: '/customer/salesleads/' + id,
        method: 'get'
    });
}

/** 新增项目商机 */
export function addOpportunity(data: any): AxiosPromise<void> {
    return request({
        url: '/customer/salesleads',
        method: 'post',
        data: data
    });
}

/** 修改项目商机 */
export function updateOpportunity(data: any): AxiosPromise<void> {
    return request({
        url: '/customer/salesleads',
        method: 'put',
        data: data
    });
}

/** 删除项目商机 */
export function delOpportunity(ids: string | number | (string | number)[]): AxiosPromise<void> {
    return request({
        url: '/customer/salesleads/' + ids,
        method: 'delete'
    });
}

/** 转移项目商机 */
export function transferOpportunity(data: any): AxiosPromise<void> {
    return request({
        url: '/customer/salesleads/transfer',
        method: 'post',
        data: data
    });
}
