// import request from '@/utils/request';
import { useHttp } from '@crami/http';

export interface saveData {
  ObjectType: string;
  companyId: string;
  connect: string;
  data: {
    ECODE: string;
    EID: string;
    ENAME: string;
    ERROPTION: string;
    FILETYPE: string;
    MAXCOUNT: string;
    SETTING: string;
    STATEID: string;
    TEMPLATE: string;
    CHECKOPTION: string;
    CHECKPLUGIN: string;
    SAVEPLUGIN: string;
  };
  lang: string;
  mode: string;
  modelName: string;
  newObject: string;
  objectID: string;
  productLine: string;
  projectCode: string;
  type: string;
  userId: string;
}
export async function saveDataAPI(data: saveData) {
  return await useHttp({
    url: '/system/model/saveObjectData',
    method: 'post',
    data,
  });
}

export interface editData {
  companyId: string;
  connect: string;
  lang: string;
  objectID: string;
  // userId: string;
}
export async function editDataAPI(data: editData) {
  return await useHttp({
    url: '/system/model/GetObjectDataTestList',
    method: 'post',
    data,
  });
}

// sheet页
export interface analysis {
  dataList: any;
  dataCache: string; //可以为空
  companyId: string;
  objectID: string;
  connect: string;
  lang: string;
  userId: string;
}
export async function analysisTableAPI(data: analysis) {
  return await useHttp({
    url: '/importservice/importMaintain/getSheetNameTab',
    method: 'post',
    data,
  });
}

//校验
export interface analysis2 {
  dataList: any;
  dataCache: string; //可以为空
  companyId: string;
  connect: string;
  lang: string;
  userId: string;
}
export async function verifyDataAPI(data: analysis2) {
  return await useHttp({
    url: '/importservice/import/checkData',
    method: 'post',
    data,
    timeout: 999999999,
  });
}

//解析
export interface analysisData {
  fileId: string;
  dataList: any;
  companyId: string;
  connect: string;
  lang: string;
  userId: string;
}
export async function analysisDataAPI(data: analysisData) {
  return await useHttp({
    url: '/importservice/import/extractData',
    method: 'post',
    data,
    timeout: 999999999,
  });
}

//下载获取文件id
export async function getFileId(data: analysis) {
  return await useHttp({
    url: '/importservice/importMaintain/getFileId',
    method: 'post',
    data,
  });
}

//导入
export interface importErrList {
  ecode: string; //编码 导入按钮上默认配置
  dataCache: string; //数据缓存key
  customValid: [];
  companyId: string;
  connect: string;
  userId: string;
  lang: string;
}
export async function importErrListAPI(data: importErrList) {
  return await useHttp({
    url: '/importservice/import/saveData',
    method: 'post',
    data,
    timeout: 999999999,
  });
}

export interface ExpRule {
  companyId: string;
  connect: string;
  lang: string;
  objectType: string;
  dataRoute: string;
  dataCache: string;
  viewName: string;
  isAll: string;
  eids: [];
}

export async function ExpDataAPI(data: ExpRule) {
  return await useHttp({
    url: '/exportservice/export/exportGridData',
    method: 'post',
    data,
  });
}
