import { request } from '/@/utils/service';
import { Session } from '/@/utils/storage';


const apiPrefix = '/api/assets/computer/';

// 卡片展示接口
export function getCardData(query: any) {
  return request({
    url: apiPrefix + 'card/',
    method: 'GET',
    params: query,
  });
}

// 单条查询接口
export function getComputerDetailOverview(id: number) {
  return request({
		url: `${apiPrefix}${id}/`,
		method: 'GET',
	});
}

export function getCurrentTableData(query: any) {
  return request({
    url: apiPrefix + 'current/',
    method: 'GET',
    params: query,
  });
}
export function getPastTableData(query: any) {
  return request({
    url: apiPrefix + 'past/',
    method: 'GET',
    params: query,
  });
}

// 下拉框接口
export function getShopList(query: any) {
  return request({
    url: '/api/assets/computer/shop/box/',
    method: 'GET',
    params: query,
  });
}

export function getUserList(query: any) {
  return request({
    url: '/api/assets/people/box/',
    method: 'GET',
    params: query,
  });
}

export function getShopFilterList(query: any) {
  return request({
    url: '/api/assets/shop/filter/box/',
    method: 'GET',
    params: query,
  });
}

// 创建接口
export function createComputer(body: any) {
  return request({
    url: apiPrefix + 'create/',
    method: 'POST',
    data: body,
    headers: {
      'Content-Type': 'multipart/form-data',
      // 'Authorization': 'JWT ' + Session.get('token')
    }
  });
}

// 更新接口
export function updateComputerDetail(query: any) {
  return request({
    url: apiPrefix + `${query.id}/`,
    method: 'POST',
    params: { partial: query.partial },
    data: query.dataToUpload,
    headers: {
      'Content-Type': 'multipart/form-data',
    }
  });
}



