import { http } from '@/utils/http/axios';

//删除公司主页布局
export const delCompanyLayout = (layoutld: number) => {
  return http.request({
    url: `/homepageConfig/deleteCompanyLayout?layoutld=${layoutld}`,
    method: 'DELETE',
  });
};
// /homepageConfig/CLLaaegimnoopstttuyy;
//   /homepageConfig/deleteCompanyLayout
// Promise<SceneLabelByCompanyType[]>;

export interface CompanyLayoutDetail {
  id?: number;
  viewType?: number;
  targetId?: number;
  name?: string;
  labelId?: number;
  layout?: number; //后面修改
  version?: string;
  status?: number;
  createdAt?: string;
  updatedAt?: string;
  isDeleted?: number;
}

////查询公司主页布局
export const getCompanyLayout = (params: string | null) => {
  return http.request<CompanyLayoutDetail[]>({
    url: `/homepageConfig/getCompanyLayoutList`,
    method: 'get',
    params,
  });
};

// /homepageConfig/saveCompanyLayout

export interface CompanyLayoutSave {
  layout?: number; //后面修改
  labelId?: number;
  version?: string;
  status?: number;
  viewType?: number;
  targetId?: number;
  id?: number;
}

//新建公司主页布局
export const saveCompanyLayout = (data: CompanyLayoutSave) => {
  return http.request({
    url: `/homepageConfig/saveCompanyLayout`,
    method: 'post',
    data,
  });
};

//更新公司主页布局
export const updateCompanyLayout = (data: CompanyLayoutSave) => {
  return http.request({
    url: `/homepageConfig/updateCompanyLayout`,
    method: 'put',
    data,
  });
};

export interface WorkshopPic {
  deleteFileName?: string;
  workshopld?: number;
  file?: File;
}

//上传车间缩略图   会返回图片的名字
export const uploadWorkshopPicture = (data: WorkshopPic) => {
  return http.request({
    url: `/homepageConfig/uploadWorkshopPicture`,
    method: 'post',
    data,
  });
};

//更新车间缩略图
export const updateWorkshopPicture = (data: WorkshopPic) => {
  return http.request({
    url: `/homepageConfig/updateWorkshopPicture`,
    method: 'post',
    data,
  });
};

export interface CompanyPic {
  companyld?: number;
  deleteFileName?: string;
  labelld?: number;
  file?: File;
}

//上传公司缩略图   会返回图片的名字
export const uploadCompanyPicture = (data: CompanyPic) => {
  return http.request({
    url: `/homepageConfig//uploadCompanyPicture`,
    method: 'post',
    data,
  });
};

//更新车间缩略图
export const updateCompanyPicture = (data: CompanyPic) => {
  return http.request({
    url: `/homepageConfig/updateCompanyPicture`,
    method: 'post',
    data,
  });
};
