import request from "@/utils/request";
import MockData from "@/mock/rightTree";
import { Data } from "@/mock/table";

export function fetchList(query) {
  return new Promise(function(resolve, reject) {
    resolve(Data);
  });
  return request({
    url: request.apiModule.rdfm + "/information",
    method: "get",
    params: query
  });
}

export function createFMEA(data) {
  // return MockData;
  return request({
    url: request.apiModule.rdfm + "/information/fmea",
    method: "post",
    data
  });
}

export function updateFMEA(data) {
  // return MockData;
  return request({
    url: request.apiModule.rdfm + "/information",
    method: "put",
    data
  });
}

export function deleteFMEA(data) {
  // return MockData;
  return request({
    url: request.apiModule.rdfm + "/information",
    method: "delete",
    data: data
  });
}
//获取fmea管理基本信息
export function getBasicInfo(fmeaId) {
  // return MockData;
  return request({
    url: request.apiModule.rdfm + "/information/info/" + fmeaId,
    method: "get"
  });
}
//获取fmea当前显示语言信息
export function getLanguage(fmeaId) {
  // return MockData;
  return request({
    url: request.apiModule.rdfm + "/information/language/" + fmeaId,
    method: "get"
  });
}
//基本管理信息，语言下拉框，改变的时候
export function updateLanguage(fmeaId, languageKey) {
  // return MockData;
  return request({
    url: request.apiModule.rdfm + "/information/language",
    method: "put",
    data: { fmeaId: fmeaId, languageKey: languageKey }
  });
}
//查询语言是否翻译完成
export function checkTranslationProgress(query) {
  // return MockData;
  return request({
    url: request.apiModule.rdfm + "/information/language",
    method: "get",
    params: query
  });
}

//更新fmea管理基本信息
export function updateBasicInfo(data) {
  // return MockData;
  return request({
    url: request.apiModule.rdfm + "/information",
    method: "put",
    data
  });
}
//翻译多语言
export function postLanguageBase(data) {
  // return MockData;
  return request({
    url: request.apiModule.rdfm + "/information/translation",
    method: "post",
    data
  });
}
// 还原删除的FMea
export function revertFmea(data) {
  // return MockData;
  return request({
    url: request.apiModule.rdfm + "/information/reduction",
    method: "put",
    data: data
  });
}

//xml导入
export function xmlImport(data) {
  // return MockData;
  return request({
    url: request.apiModule.rdfm + "/import/import-xml",
    method: "upload",
    data
  });
}
