import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { FileInfo } from './types';

//分页查询数据集列表
export function getModel(queryParams:any) {
  return request({
    url: '/modeltrain/model/getModel',
    method: 'post',
    params: queryParams
  });
}

export function addModel(data:any) {
  return request({
    url: '/modeltrain/model/addModel',
    method: 'post',
    data: data
  });
}
export function updateModel(data:any) {
  return request({
    url: '/modeltrain/model/updateModel',
    method: 'post',
    data: data
  });
}
export function delModel(data:any) {
  return request({
    url: '/modeltrain/model/delModel',
    method: 'post',
    data: data
  });
}

// 训练列表
export function getTrainRecord(queryParams:any) {
  return request({
    url: '/modeltrain/trainrecord/getTrainRecord',
    method: 'post',
    params: queryParams
  });
}

// 训练列表-不分页
export function getTrainRecordList(queryParams:any) {
  return request({
    url: '/modeltrain/trainrecord/getTrainRecordList',
    method: 'post',
    params: queryParams
  });
}

// 查看训练详情
export function getTrainRecordByName(queryParams:any) {
  return request({
    url: '/modeltrain/trainrecord/getTrainRecordByName',
    method: 'post',
    params: queryParams
  });
}



export function addTrainRecord(data:any) {
  return request({
    url: '/modeltrain/trainrecord/addTrainRecord',
    method: 'post',
    data: data
  });
}

export function updateTrainRecord(data:any) {
  return request({
    url: '/modeltrain/trainrecord/updateTrainRecord',
    method: 'post',
    data: data
  });
}

export function delTrainRecord(data:any) {
  return request({
    url: '/modeltrain/trainrecord/delTrainRecord',
    method: 'post',
    data: data
  });
}
export function copyTrainRecord(data:any) {
  return request({
    url: '/modeltrain/trainrecord/copyTrainRecord?id='+ data.id,
    method: 'post',
    data: data
  });
}

//人机交互流程图
//查询流程图列表
export function getFlowChart(data:any) {
  return request({
    url: '/modeltrain/humancomputer-interaction/getFlowChart',
    method: 'post',
    data: data
  });
}
// //新增流程图
// export function addFlowChart(data:any) {
//   return request({
//     url: '/modeltrain/humancomputer-interaction/addFlowChart',
//     method: 'post',
//     data: data
//   });
// }

/**
 * 新增流程图
 *
 * @param file
 */
 export function addFlowChart(data: any): AxiosPromise<FileInfo> {
  const formData = new FormData();
  formData.append('file', data.file);
  formData.append('name', data.name);
  formData.append('pointdata', "");
  return request({
    url: '/modeltrain/humancomputer-interaction/addFlowChart',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
}

//修改流程图-添加点位
export function updateFlowChart(data:any) {
  return request({
    url: '/modeltrain/humancomputer-interaction/updateFlowChart',
    method: 'post',
    data: data
  });
}
//删除流程图
export function delFlowChart(queryParams:any) {
  return request({
    url: '/modeltrain/humancomputer-interaction/delFlowChart',
    method: 'post',
    params: queryParams
  });
}


/**
 * 下载用户导入模板
 *
 * @returns
 */
 export function downloadModel(queryParams:any) {
  return request({
    url: '/modeltrain/trainrecord/downloadModel',
    method: 'post',
    params: queryParams,
    responseType: 'arraybuffer'
  });
}