import request from '@/utils/request';


/**
 * 品类库管理/品类库审批列表
 */

export interface libraryData {
  deptId: string;
  approveType: string;
  area: string;
  categoryIds: CategoryId[];
  coscoCategoryLibrarAttachments?: CoscoCategoryLibrarAttachments;
  name: string;
  termOfValidity: string;
  [property: string]: any;
}

export interface CategoryId {
  id?: string;
  lockType?: number;
  [property: string]: any;
}

export interface CoscoCategoryLibrarAttachments {
  attachmentsType: string;
  fileName: string;
  filePath: string;
  fileSize: string;
  fileType: string;
  fileUrl: string;
  [property: string]: any;
}
 export const library = (data: libraryData) => request.post('/cosco/library', { data });
 

/**
 * 列表接口
 */

export interface getPageData {
  basePageRequest: BasePageRequest;
  [property: string]: any;
}

export interface BasePageRequest {
  pageNo: number;
  pageSize: number;
  [property: string]: any;
}
 export const getPage = (data: getPageData) => request.post('/cosco/apply/getPage', { data });
 /**
 * 品类库详情
 */
 interface detailData {
  id: string;
}
export const detail = (params: detailData) => request.get(`/cosco/apply/detail`, { params });
 /**
 * 查询上级部门锁定品类
 */
export const superiorLockList = () => request.get(`/cosco/library/superiorLockList`);
/**
 *添加供应商
 */

export interface applyData {
   categoryLibraryId: string;
   supplierIds: string[];
  [property: string]: any;
}
 export const apply = (data: applyData) => request.post('/cosco/apply', { data });
 

/**
 * 部门查询
 */

 export const getDeptList = () => request.get(`/user/getDeptList`);
  /**
 * 树形列表接口
 */
export const categoryTree = () => request.get('/cosco/category/categoryTree');


/**
 * 上传文件
 * @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 treeListData {
  categoryLibraryId: string;
}
 export const treeList = (params: treeListData) => request.get(`/cosco/contain/treeList`, { params });

 /**
 * 查询上级部门锁定品类
 */
 interface approvalData {
  id: string;
}
 export const approval = (data: approvalData) => request.post(`/cosco/apply/approval`, { data });

