import request from '@/utils/request'

// 获取左侧的结构树
export function getStruTree(params) {
  return request({
    url: request.apiModule.rpfm + '/structure/tree/left',
    method: 'get',
    params
  })
}

//历史输入查询，历史添加，获取结构
export function getHistory(params) {
  return request({
    url: request.apiModule.rpfm + '/structure/history/',
    method: 'get',
    params
  })
}

//节点转换
export function getStruSwitch(data) {
  return request({
    url: request.apiModule.rpfm + '/structure/type/' + data,
    method: 'put'
  })
}

//导出结构操作
export function postFmeaExport(data) {
  return request({
    url: request.apiModule.rpfm + '/structure/export',
    method: 'post',
    data
  })
}

//导入结构操作
export function putFmeaImport(data) {
  return request({
    url: request.apiModule.rpfm + '/structure/import',
    method: 'put',
    data
  })
}

//excel导入
export function importExcel(data) {
  return request({
    url: request.apiModule.rpfm + '/structure/import-excel',
    method: 'upload',
    data
  })
}

//新增历史输入
export function addHistory(data) {
  return request({
    url: request.apiModule.rpfm + '/structure/history',
    method: 'put',
    data
  })
}

//新增知识库
export function addRepo(data) {
  return request({
    url: request.apiModule.rpfm + '/structure/repository',
    method: 'put',
    data
  })
}

// 添加结构，功能
export function addNode(data) {
  return request({
    url: request.apiModule.rpfm + '/structure',
    method: 'post',
    data
  })
}

// 结构：多级添加
export function addMultiStruNode(data) {
  return request({
    url: request.apiModule.rpfm + '/structure/multilevel',
    method: 'post',
    data
  })
}

// 结构：多级元素添加
export function addMultiElementNode(data) {
  return request({
    url: request.apiModule.rpfm + '/structure/multilevel/ele',
    method: 'post',
    data
  })
}

// 添加上级
export function addSuperiorStructure(data) {
  return request({
    url: request.apiModule.rpfm + '/structure/superior',
    method: 'post',
    data: { id: data }
  })
}

//删除根节点
export function delRoot(id) {
  return request({
    url: request.apiModule.rpfm + '/structure/root',
    method: 'delete',
    data: { id: id }
  })
}

// 获取右侧的结构树
export function getFailTree(params) {
  return request({
    url: request.apiModule.rpfm + '/structure/tree/right',
    method: 'get',
    params
  })
}

// 删除节点
export function delNode(id) {
  return request({
    url: request.apiModule.rpfm + '/structure',
    method: 'delete',
    data: { id: id }
  })
}

//获取属性初始Data
export function getAttr(params) {
  return request({
    url: request.apiModule.rpfm + '/strucdetail',
    method: 'get',
    params
  })
}
//获取作业要素措施组双击详细信息
export function getMeasureElementData(fmeaId) {
  return request({
    url: request.apiModule.rpfm + '/strucdetail/measure/element/' + fmeaId,
    method: 'get'
  })
}
//获取过程步骤措施组双击详细信息
export function getMeasureStepData(fmeaId) {
  return request({
    url: request.apiModule.rpfm + '/strucdetail/measure/step/' + fmeaId,
    method: 'get'
  })
}
//更新过程步骤作业要素措施组OD值
export function updateMeasureScore(data) {
  return request({
    url: request.apiModule.rpfm + '/strucdetail/score',
    method: 'put',
    data
  })
}

//修改组件名称
export function changeNodeName(data) {
  return request({
    url: request.apiModule.rpfm + '/strucdetail/name',
    method: 'put',
    data
  })
}

// 修改节点属性
export function editNode(data) {
  return request({
    url: request.apiModule.rpfm + '/strucdetail',
    method: 'put',
    data
  })
}

// 添加现行/优化措施
export function addMeas(data) {
  return request({
    url: request.apiModule.rpfm + '/structure/measure',
    method: 'post',
    data
  })
}

// 新增功能网关联信息
export function addFuncNet(data) {
  return request({
    url: request.apiModule.rpfm + '/function/net',
    method: 'post',
    data
  })
}

//节点上下移动
export function moveNode(data) {
  return request({
    url: request.apiModule.rpfm + '/structure/move',
    method: 'put',
    data
  })
}

//节点上下移动
export function paste(data) {
  return request({
    url: request.apiModule.rpfm + '/structure/paste',
    method: 'put',
    data
  })
}

// 获取当前节点的功能网信息
export function getFuncNet(structureId) {
  return request({
    url: request.apiModule.rpfm + '/function/net/' + structureId,
    method: 'get'
  })
}

// 获取可选择的下级结构
export function getFuncNetChildrenStruList(structureId) {
  return request({
    url: request.apiModule.rpfm + '/function/net/children/' + structureId,
    method: 'get'
  })
}

// 获取可选择的上级结构
export function getFuncNetParentStruList(structureId) {
  return request({
    url: request.apiModule.rpfm + '/function/net/parent/' + structureId,
    method: 'get'
  })
}

// 获取所选择节点下功能结构信息
export function getFuncNetStruList(structureId) {
  return request({
    url: request.apiModule.rpfm + '/function/net/structure/' + structureId,
    method: 'get'
  })
}

// 删除节点
export function delFuncNetNode(data) {
  return request({
    url: request.apiModule.rpfm + '/function/net/',
    method: 'delete',
    data
  })
}

//转换节点类型
export function changeNodeType(structureId) {
  return request({
    url: request.apiModule.rpfm + '/structure/type',
    method: 'put',
    data: { id: structureId }
  })
}

// 新增失效网关联信息
export function addFailNet(data) {
  return request({
    url: request.apiModule.rpfm + '/fault/net',
    method: 'post',
    data
  })
}

// 获取失效节点的功能网信息
export function getFailNet(structureId) {
  return request({
    url: request.apiModule.rpfm + '/fault/net/' + structureId,
    method: 'get'
  })
}

// 获取失效网可选择的下级结构
export function getFailNetChildrenStruList(structureId) {
  return request({
    url: request.apiModule.rpfm + '/fault/net/children/' + structureId,
    method: 'get'
  })
}

// 获取失效网可选择的上级结构
export function getFailNetParentStruList(structureId) {
  return request({
    url: request.apiModule.rpfm + '/fault/net/parent/' + structureId,
    method: 'get'
  })
}

// 获取失效网所选择节点下功能结构信息
export function getFailNetStruList(structureId) {
  return request({
    url: request.apiModule.rpfm + '/fault/net/structure/' + structureId,
    method: 'get'
  })
}

// 删除失效网节点
export function delFailNetNode(data) {
  return request({
    url: request.apiModule.rpfm + '/fault/net/',
    method: 'delete',
    data
  })
}

// 获取接口连线信息
export function getChartConnect(params) {
  return request({
    url: request.apiModule.rpfm + '/chartmap/chartConnect',
    method: 'get',
    params
  })
}

// 获取合并列表
export function getMergeList(params) {
  return request({
    url: request.apiModule.rpfm + '/structure/merger',
    method: 'get',
    params
  })
}

// 合并
export function addMerge(data) {
  return request({
    url: request.apiModule.rpfm + '/structure/merger',
    method: 'post',
    data
  })
}

//升级
export function addUpper(structureId) {
  return request({
    url: request.apiModule.rpfm + '/structure/upper',
    method: 'put',
    data: { id: structureId }
  })
}
