import request from '@/utils/request'

// 查询AI工作流列表
export function listWorkflow(query) {
  return request({
    url: '/company/companyWorkflow/list',
    method: 'get',
    params: query
  })
}

export function myListWorkflow(query) {
    return request({
        url: '/company/companyWorkflow/myList',
        method: 'get',
        params: query
    })
}

// 查询AI工作流详细
export function getWorkflow(workflowId) {
  return request({
    url: '/company/companyWorkflow/' + workflowId,
    method: 'get'
  })
}

// 新增AI工作流
export function addWorkflow(data) {
  return request({
    url: '/company/companyWorkflow/save',
    method: 'post',
    data: data
  })
}

// 修改AI工作流
export function updateWorkflow(data) {
  return request({
    url: '/company/companyWorkflow/save',
    method: 'post',
    data: data
  })
}

// 修改AI工作流状态
export function updateWorkflowStatus(workflowId, status) {
  return request({
    url: '/company/companyWorkflow/status/' + workflowId + '/' + status,
    method: 'put'
  })
}

// 删除AI工作流
export function delWorkflow(workflowId) {
  return request({
    url: '/company/companyWorkflow/' + workflowId,
    method: 'delete'
  })
}

// 复制AI工作流
export function copyWorkflow(workflowId) {
  return request({
    url: '/company/companyWorkflow/copy/' + workflowId,
    method: 'post'
  })
}

// 获取节点类型列表
export function getNodeTypes() {
  return request({
    url: '/company/companyWorkflow/nodeTypes',
    method: 'get'
  })
}

// 导出AI工作流
export function exportWorkflow(query) {
  return request({
    url: '/company/companyWorkflow/export',
    method: 'get',
    params: query
  })
}

// 根据workflowId获取绑定的销售列表
export function getBindCompanyUserByWorkflowId(workflowId) {
  return request({
    url: '/company/companyWorkflow/getBindCompanyUserByWorkflowId/' + workflowId,
    method: 'get'
  })
}

// 获取销售列表
export function listCompanyUser() {
  return request({
    url: '/company/companyWorkflow/listCompanyUser',
    method: 'get'
  })
}

// 检查销售是否已被绑定
export function checkCompanyUserBeUsed(companyUserId) {
  return request({
    url: '/company/companyWorkflow/checkCompanyUserBeUsed/' + companyUserId,
    method: 'get'
  })
}

// 更新工作流绑定销售
export function updateWorkflowBindCompanyUser(data) {
  return request({
    url: '/company/companyWorkflow/updateWorkflowBindCompanyUser',
    method: 'post',
    data: data
  })
}
// 更新工作流绑定销售
export function optionList() {
  return request({
    url: '/company/companyWorkflow/optionList',
    method: 'get'
  })
}

//查看工作流历史版本
export function getWorkflowVersionList(workflowId) {
    return request({
        url: '/company/companyWorkflow/versionList/' + workflowId,
        method: 'get'
    })
}

// 查询版本详情
export function getWorkflowVersionDetail(versionId) {
    return request({
        url: '/company/companyWorkflow/versionDetail/' + versionId,
        method: 'get'
    })
}

// 回退到指定版本
export function rollbackWorkflowVersion(versionId) {
    return request({
        url: '/company/companyWorkflow/versionRollback/' + versionId,
        method: 'post'
    })
}
