// 流程管理接口
import request from '../index'
const prefix = '/system/flow'

// 列表
export function getProcessList(data: { offset: number; limit: number }) {
  return request({
    url: `${prefix}/listPage?offset=${data.offset}&limit=${data.limit}`,
    method: 'post',
    data,
  })
}

// 删除
export function delProcessList(id: string) {
  const param = {
    deployId: id,
  }
  return request({
    url: `${prefix}/delete`,
    method: 'post',
    data: param,
  })
}
// 废止
export function updateState(id: string, state: number) {
  const param = {
    deployId: id,
    state,
  }
  return request({
    url: `${prefix}/updateState`,
    method: 'post',
    data: param,
  })
}

// 加载流程定义
export function unloadProcess(params: Object) {
  const param = {
    _value: params,
  }
  return request({
    url: `${prefix}/jsonToBpmn`,
    method: 'post',
    data: param,
  })
}

// 流程定义编辑
export function efitProcess(params: Object) {
  const param = {
    _value: params,
  }
  return request({
    url: `${prefix}/update`,
    method: 'post',
    data: param,
  })
}

// 获取流程定义详情
export function getProcessDetail(formId: string) {
  const param = {
    formId,
  }
  return request({
    url: `${prefix}/detail`,
    method: 'post',
    data: param,
  })
}

// 获取关联业务列表
export function getBusinessList() {
  return request({
    url: `${prefix}/flowFormList`,
    method: 'get',
  })
}

// 获取发起人的主管层级数
export function getDirectorLevel(userId: number | string) {
  return request({
    url: `${prefix}/directorLevel`,
    method: 'get',
    params: { userId },
  })
}
