import request from '@/utils/request';

/**
 * 准入列表
 */
interface getPageData {
    pageNo: number;
    pageSize: number;
    deptId?: string;
    accessType?: string;
    reviewStatus?: string;
    approveStatus?: string;
    categoryId?: string;
}
export const getPage = (data: getPageData) => request.post('/coscoAccessWork/getPage', { data });

/**
 * 未准入的供应商分页列表查询
 */
interface coscoSupplierBaseData {
    pageNo: number;
    pageSize: number;
    accessStatus?: number;
    name?: string;
    supplierType?: string;
}
export const coscoSupplierBase = (data: coscoSupplierBaseData) => request.post('/coscoSupplierBase/getPage', { data });

/**
 * 未准入的供应商分页列表查询
 */
interface addInterface {
    categoryIds: string[];
    coscoAccessItems: CoscoAccessItem[];
    coscoAccessUserls: CoscoAccessUserl[];
    coscoAccessWork: CoscoAccessWork;
    supplierIds: string[];
    [property: string]: any;
}

interface CoscoAccessItem {
    itemName: string;
    reviewBy: string[];
    [property: string]: any;
}

interface CoscoAccessUserl {
    deptId: string;
    isLeader: number;
    userId: string;
    [property: string]: any;
}

interface CoscoAccessWork {
    accessType: string;
    accessWorkName: string;
    deptId: string;
    endTime: string;
    startTime: string;
    [property: string]: any;
}
export const add = (data: addInterface) => request.post('/coscoAccessWork/add', { data });

/**
 * 品类选择查询树
 */
export const categoryTree = () => request.get('/cosco/category/categoryTree');
/**
 * 供应商准入管理详情
 */
export const coscoAccessWork = (id: string) => request.get(`/coscoAccessWork/${id}`);

/**
 * 上传文件
 * @param file 上传的文件对象
 * @returns 上传结果
 */
export const uploadFile = async (file: File) => {
    const formData = new FormData();
    formData.append('file', file);

    return request('/fileConfig/files/upload', {
        method: 'POST',
        data: formData,

    });
};

/**
 * 发起审批
 */
interface startApproveData {
    id: string;
}
export const startApprove = (params: startApproveData) => request.get(`/coscoAccessWork/startApprove`, { params });

/**
 * 查看评审结果
 */
export const reviewInfoData = (params: startApproveData) => request.get(`/coscoAccessWork/reviewInfoData`, { params });


