import qs from 'qs'
import { http } from '@/utils/http/axios'
import type { ApprovalParam, PageParam } from '/#/api'
import { ContentTypeEnum } from '@/enums/httpEnum'

/**
 * 获取审核列表
 * @returns
 */
export async function getApprovalList(params: PageParam, assigneeId: string) {
  const res = await http.request({
    url: `/flow/task/listdata`,
    method: 'get',
    params: { ...params, assigneeId },
  })

  const { data: { list, totalPage } } = res
  return {
    pageCount: totalPage,
    data: list,
  }
}

/**
 * 审核
 * @param param
 */
export async function audit(params: ApprovalParam) {
  return http.request({
    url: `/flow/task/completeBatchFlow?`,
    method: 'post',
    params: qs.stringify(params, { indices: false }),
    headers: { 'Content-Type': ContentTypeEnum.FORM_DATA },
  })
}
