/**
 * 溯源链变更
 */
import request from '../../index'
import type { IListQuery } from '@/views/equipement/source/change/change-interface'
const prefix = 'equipment/trace/chainChange'
// 列表查询
export function getChangeList(data: IListQuery) {
  return request({
    url: `${prefix}/approval/listPage?offset=${data.offset}&limit=${data.limit}`,
    method: 'post',
    data,
  })
}

// 新建(保存至草稿箱)
export function addChangeList(data: object) {
  return request({
    url: `${prefix}/save`,
    method: 'post',
    data,
  })
}

// 编辑--草稿箱
export function updateChangeList(data: object) {
  return request({
    url: `${prefix}/draftUpdate`,
    method: 'post',
    data,
  })
}
// 编辑--未通过、已取消
export function failUpdateChangeList(data: object) {
  return request({
    url: `${prefix}/failUpdate`,
    method: 'post',
    data,
  })
}

// 获取详情信息
export function getInfo(data: { id: string }) {
  return request({
    url: `${prefix}/detail`,
    method: 'post',
    data,
  })
}

// 提交
export function submit(data: { id: string; formId: string; processId?: string }) {
  return request({
    url: `${prefix}/submit`,
    method: 'post',
    data,
  })
}

// 删除--草稿箱
export function draftDelete(data: { id: string }) {
  return request({
    url: `${prefix}/draftDelete`,
    method: 'post',
    data,
  })
}

// 审批删除--已取消、全部
export function approvalDelete(data: { id: string; taskId: string }) {
  return request({
    url: `${prefix}/approval/delete`,
    method: 'post',
    data,
  })
}

// 取消
export function cancelApproval(data: { processInstanceId?: string; comments: string; id: string }) {
  return request({
    url: `${prefix}/approval/revoke`,
    method: 'post',
    data,
  })
}

// 拒绝
export function refuseApproval(data: { id: string; taskId: string; comments: string }) {
  return request({
    url: `${prefix}/approval/refuse`,
    method: 'post',
    data,
  })
}

