import request from "@/utils/request";
import { AxiosPromise } from "axios";

// excel表单列表查询
export function getExcelList(data: any = {}): AxiosPromise<any> {
  return request({
    url: "/api/v1/test/excelForm/list",
    method: "post",
    data: data,
  });
}

// 获取已经测试过的产品列表
export function getTestedProductList(data: any = {}): AxiosPromise<any> {
  return request({
    url: "/api/v1/test/engineering/list",
    method: "post",
    data: data,
  });
}

// 根据已经测试过的产品id获取产品编号列表
export function getProductCodeListById(
  id: string,
  code?: string
): AxiosPromise<any> {
  return request({
    url: "/api/v1/test/engineering/selectProductList",
    method: "post",
    data: {
      engineeringId: id,
      productCode: code,
    },
  });
}

// 查询产品和工程最新的日志
export function getTestingDataByCode(
  id: string,
  code: string
): AxiosPromise<any> {
  return request({
    url: "/api/v1/test/engrExecuteLog/selectLastList",
    method: "post",
    data: {
      engineeringId: id,
      productCode: code,
    },
  });
}

// 新增excel表单  保存模版
export function saveExcelTemplate(data: any = {}): AxiosPromise<any> {
  return request({
    url: "/api/v1/test/excelForm/add",
    method: "post",
    data: data,
  });
}

export function updateExcelTemplate(data: any = {}): AxiosPromise<any> {
  return request({
    url: "/api/v1/test/excelForm/update",
    method: "post",
    data: data,
  });
}

// 获取excel表单详情
export function getExcelTemplateDetail(id: string): AxiosPromise<any> {
  return request({
    url: `/api/v1/test/excelForm/get/${id}`,
    method: "get",
  });
}

//预览excel表单
export function previewExcelTemplateData(data: any = {}): AxiosPromise<any> {
  return request({
    url: "/api/v1/test/excelForm/previewForm",
    method: "post",
    data: data,
  });
}
