import request from '@/utils/request'
import { StrAnyObj } from '@/typings'

// 查询流程定义列表
export function getDefinitionPageApi(params: StrAnyObj): Promise<StrAnyObj> {
  return request.get('/flow/definition/list', params)
}

// 查询流程定义详细
export function getDefinitionApi(id: string): Promise<StrAnyObj> {
  return request.get(`/flow/definition/${id}`)
}

// 新增流程定义
export function addDefinitionApi(params: StrAnyObj): Promise<StrAnyObj> {
  return request.post('/flow/definition', params)
}

// 修改流程定义
export function updateDefinitionApi(params: StrAnyObj): Promise<StrAnyObj> {
  return request.put(`/flow/definition`, params)
}

// 删除流程定义
export function deleteDefinitionApi(id: string): Promise<StrAnyObj> {
  return request.delete(`/flow/definition/${id}`)
}

// 保存流程定义xml字符串
export function saveXmlApi(data: StrAnyObj): Promise<void> {
  return request.post(`/flow/definition/saveXml`, data)
}

// 获取流程定义xml字符串
export function getXmlApi(id: string): Promise<string> {
  return request.get(`/flow/definition/xmlString/${id}`)
}

// 根据id查用户名
export function getUsernameApi(id: string): Promise<string> {
  return request.get(`/flow/definition/idReverseDisplayName/${id}`)
}

// 查看流程图
export function getChartNoColorApi(id: string): Promise<string> {
  return request.get(`/flow/definition/flowChartNoColor/${id}`)
}

// 发布流程定义
export function publishApi(id: string): Promise<StrAnyObj> {
  return request.get(`/flow/definition/publish/${id}`)
}

// 取消发布流程定义
export function unPublishApi(id: string): Promise<StrAnyObj> {
  return request.get(`/flow/definition/unPublish/${id}`)
}

// 激活流程
export function activeApi(id: string): Promise<StrAnyObj> {
  return request.get(`/flow/definition/active/${id}`)
}

// 挂起流程
export function unActiveApi(id: string): Promise<StrAnyObj> {
  return request.get(`/flow/definition/unActive/${id}`)
}

// 复制流程定义
export function copyDefApi(id: string): Promise<StrAnyObj> {
  return request.get(`/flow/definition/copyDef/${id}`)
}

// 查看流程图
export function getChartApi(id: string): Promise<string> {
  return request.get(`/flow/definition/flowChart/${id}`)
}
