import { appservice } from '@/utils/apiService'
const baseUrl = '/api/audit-flows'

export function getFlow(id) {
  return appservice({
    url: `${baseUrl}/${id}`,
    method: 'get'
  })
}

export function getFlows(params) {
  return appservice({
    url: `${baseUrl}`,
    method: 'get',
    params
  })
}

export function createFlow(data) {
  return appservice({
    url: `${baseUrl}`,
    method: 'post',
    data
  })
}

export function updateFlow(id, data) {
  return appservice({
    url: `${baseUrl}/${id}`,
    method: 'post',
    data
  })
}

export function deleteFlow(id) {
  return appservice({
    url: `${baseUrl}/${id}/remove`,
    method: 'post'
  })
}

export function getSteps(auditFlowId) {
  return appservice({
    url: `${baseUrl}/${auditFlowId}/steps`,
    method: 'get'
  })
}

export function createStep(auditFlowId, data) {
  return appservice({
    url: `${baseUrl}/${auditFlowId}/steps`,
    method: 'post',
    data
  })
}

export function updateStep(auditFlowId, data) {
  return appservice({
    url: `${baseUrl}/${auditFlowId}/steps/update`,
    method: 'post',
    data
  })
}

export function deleteStep(auditFlowId, id) {
  return appservice({
    url: `${baseUrl}/${auditFlowId}/steps/${id}/remove`,
    method: 'post'
  })
}

export function audit(data) {
  return appservice({
    url: `${baseUrl}/audit`,
    method: 'post',
    data
  })
}

export function batchAudit(data) {
  return appservice({
    url: `${baseUrl}/batch-audit`,
    method: 'post',
    data
  })
}

export function getConditionField(category) {
  return appservice({
    url: `${baseUrl}/condition-fields/${category}`,
    method: 'get'
  })
}

export function getProgresses(progressId) {
  return appservice({
    url: `${baseUrl}/progresses/${progressId}`,
    method: 'get'
  })
}

export function getHistoryProgresses(progressId) {
  return appservice({
    url: `${baseUrl}/history-progresses/${progressId}`,
    method: 'get'
  })
}

export function sync(data) {
  return appservice({
    url: `${baseUrl}/sync`,
    method: 'post',
    data
  })
}

export function clear(data) {
  return appservice({
    url: `${baseUrl}/clear`,
    method: 'post',
    data
  })
}
