import request from "../utils/request";
let baseUrlMaintain = ''
let baseUrlPurchase = ''
const OPERATIONSE = ''

const mock = "/mock"

// 查询公司船舶
export function companyVessels (data) {
  return request({
    url: "/baseVessel/query/companyVessels",
    method: "get",
    params: data
  });
}

// 创建船舶
export function createShip (data) {
  return request({
    url: "/baseVessel/api/create",
    method: "post",
    data
  });
}

// 修改
export function changeInfo (data) {
  return request({
    url: '/baseVessel/api/changeInfo',
    method: "post",
    data
  });
}

// 船舶所属公司下拉列表查询
export function getOwnerCompList (params) {
  return request({
    url: "/contactCompany/query/getOwnerCompList",
    method: "get",
    params: params
  });
}

// 船舶所属公司下拉列表查询
export function getManageCompList (params) {
  return request({
    url: "/contactCompany/query/getManageCompList",
    method: "get",
    params: params
  });
}

// 删除船舶
export function removeShip (data) {
  return request({
    url: "/baseVessel/api/remove",
    method: "post",
    data
  });
}

// 获取船舶详情
export function getVesselInfo (params) {
  return request({
    url: '/baseVessel/query/vesselInfo',
    method: "get",
    params: params
  });
}

// 维保导入
export function maintainImportFile (data, type, callback) {
  let url
  switch (type) {
    case 'WB':
      url = `${baseUrlMaintain}/maintainImport/api/importMaintainFile`;
      break
    case 'SP':
      url = `${baseUrlPurchase}/sparepartImport/api/importSparepartFile`;
      break
    case 'MA':
      url = `${baseUrlPurchase}/materialImport/api/importMaterialFile`;
      break
    case 'HT':
      url = `${baseUrlPurchase}/navigationImport/api/importNavigationFile`;
      break
  }
  var config = {
    headers: { 'Content-Type': 'multipart/form-data' }
    // onUploadProgress: progressEvent => {
    //   var complete = (progressEvent.loaded / progressEvent.total * 100 | 0) + '%'
    //   if (callback) {
    //     callback(complete)
    //   }
    // }
  }
  return request.post(url, data, config)
}

// 物料导入
export function materialImportFile (data) {
  return request({
    url: `${baseUrlPurchase}/materialImport/api/importMaterialFile`,
    method: "post",
    data
  });
}

// 备件导入
export function sparepartImportFile (data) {
  return request({
    url: `${baseUrlPurchase}/sparepartImport/api/importSparepartFile`,
    method: "post",
    data
  });
}


/**
 * 获取公司信息
 * @param {*} data {tenantId=f25b66cc57e943ee9ef5733d38e181b2}
 */
export function getTenantDetail (params) {
  return request({
    url: `${OPERATIONSE}/trialTenant/query/tenantDetail`,
    method: "get",
    params: params
  });
}
