// WFProcess 流程模版基本信息
import { defHttp } from '@/utils/http/axios';
import {
  CreateParams,
  DeleteDraftParams,
  RevokeAuditParams,
  LoadNextAuditorsParams,
} from './model/WFProcessModel';
import { MyUncompletedParams } from './model/WFTaskModel';

enum Api {
  // 创建流程
  Create = '/api/WFProcess/Create',
  // 保存草稿
  SaveDraft = '/api/WFProcess/SaveDraft',
  // 我的流程
  LoadMyPage = '/api/WFProcess/LoadMyPage',
  // 我的草稿
  LoadMyDraftPage = '/api/WFProcess/LoadMyDraftPage',
  // 删除草稿
  DeleteDraft = '/api/WFProcess/DeleteDraft',
  // 催办
  Urge = '/api/WFProcess/Urge',
  // 撤销
  Revoke = '/api/WFProcess/Revoke',
  // 审核撤销
  RevokeAudit = '/api/WFProcess/RevokeAudit',
  // 获取流程图详情
  GetBPMN = '/api/WFProcess/GetBPMN',
  // 重新创建流程
  CreateAgain = '/api/WFProcess/CreateAgain',
  // 加签审核
  SignAudit = '/api/WFProcess/SignAudit',
  // 流程审核
  Audit = '/api/WFProcess/Audit',
  // 获取下一节点审核人
  LoadNextAuditors = '/api/WFProcess/LoadNextAuditors',
  // 确认阅读
  ReadFlow = '/api/WFProcess/ReadFlow',
  // 撤回
  Retract = '/api/WFProcess/Retract',
  // 判读发起流程检查
  GetDraft = '/api/WFProcess/GetDraft',
}

/**
 * @description: getLoadMyPage
 */
export function getLoadNextAuditors(params?: LoadNextAuditorsParams) {
  return defHttp.get({ url: Api.LoadNextAuditors, params });
}
/**
 * @description: 创建流程
 */
export function create(params?: CreateParams) {
  return defHttp.post({
    url: Api.Create,
    params,
  });
}
/**
 * @description: 重新创建流程
 */
export function createAgain(params?: CreateParams) {
  return defHttp.post({
    url: Api.CreateAgain,
    params,
  });
}
/**
 * @description: 加签审核
 */
export function signAudit(id?: String, params?: CreateParams) {
  return defHttp.post({
    url: Api.SignAudit + '?id=' + id,
    params,
  });
}
/**
 * @description: 流程审核
 */
export function audit(id: String, params?: CreateParams) {
  return defHttp.post({
    url: Api.Audit + '?id=' + id,
    params,
  });
}

/**
 * @description: 流程撤回
 */
export function retract(id: String, params?: any) {
  return defHttp.post({
    url: Api.Retract + '?id=' + id,
    params,
  });
}

/**
 * @description: 保存草稿
 */
export function saveDraft(params?: CreateParams) {
  return defHttp.post({
    url: Api.SaveDraft,
    params,
  });
}
/**
 * @description: getLoadMyPage
 */
export function getLoadMyPage(params?: MyUncompletedParams) {
  return defHttp.get({ url: Api.LoadMyPage, params });
}
/**
 * @description: getLoadMyDraftPage
 */
export function getLoadMyDraftPage(params?: MyUncompletedParams) {
  return defHttp.get({ url: Api.LoadMyDraftPage, params });
}
/**
 * @description: 删除草稿
 */
export function deleteDraft(params: DeleteDraftParams) {
  return defHttp.post({
    url: Api.DeleteDraft + '?id=' + params.id,
    params,
  });
}
/**
 * @description: 催办
 */
export function urge(params: DeleteDraftParams) {
  return defHttp.post({
    url: Api.Urge + '?id=' + params.id,
    params,
  });
}
/**
 * @description: 撤销
 */
export function revoke(params: DeleteDraftParams) {
  return defHttp.post({
    url: Api.Revoke + '?id=' + params.id,
    params,
  });
}
/**
 * @description: 审核撤销
 */
export function revokeAudit(params: RevokeAuditParams) {
  return defHttp.post({
    url: Api.RevokeAudit + '?id=' + params.id + '&taskId=' + params.taskId,
    params,
  });
}
/**
 * @description: getPBMN
 */
export function getBPMN(params: DeleteDraftParams) {
  return defHttp.get({ url: Api.GetBPMN, params });
}

/**
 * @description: 确认阅读
 */
export function ReadFlow(id: string) {
  return defHttp.post({
    url: Api.ReadFlow + '?id=' + id,
  });
}
export function GetDraft(params) {
  return defHttp.get({
    url: Api.GetDraft,
    params,
  });
}
