import request from '@/utils/request';
import type { AnamalyQuery, AnamalyForm } from './types';

/**
 * 获取异常上报列表
 * @param query 查询参数
 */
export function getAnamalyList(query: AnamalyQuery) {
    return request({
        url: '/fulfiller/anamaly/list',
        method: 'get',
        params: query
    });
}

/**
 * 获取异常上报详情
 * @param id 记录ID
 */
export function getAnamaly(id: number | string) {
    return request({
        url: `/fulfiller/anamaly/getInfo`,
        method: 'get',
        params: { id }
    });
}

/**
 * 新增异常上报
 * @param data 表单数据
 */
export function addAnamaly(data: AnamalyForm) {
    return request({
        url: '/fulfiller/anamaly/add',
        method: 'post',
        data: data
    });
}

/**
 * 审核异常上报
 * @param data 审核数据
 */
export function auditAnamaly(data: { id: number, result: number, remark?: string }) {
    return request({
        url: '/fulfiller/anamaly/audit',
        method: 'put',
        data: data
    });
}

/**
 * 删除异常上报
 * @param id 记录ID
 */
export function deleteAnamaly(id: number | string) {
    return request({
        url: `/fulfiller/anamaly/remove`,
        method: 'delete',
        params: { id }
    });
}
